当我尝试为名称为> = 32个字符
的属性设置值时出错adb shell setprop 01234567890123456789012345678901 VALUE
错误:
could not set property
这很好用
adb shell setprop 0123456789012345678901234567890 VALUE
adb shell getprop 0123456789012345678901234567890
VALUE
有没有办法设置名称较长的属性?
答案 0 :(得分:10)
看起来没有办法绕过这个限制。我在android java源代码中看到了相同的规则。
public class SystemProperties
{
public static final int PROP_NAME_MAX = 31;
public static final int PROP_VALUE_MAX = 91;
...
}
答案 1 :(得分:2)
我也面临同样的问题。作为上面提到的答案,不可能使用超过31的NAME。 所以我将包名更改为短于31,现在可以使用。
答案 2 :(得分:1)
更新:系统属性名称限制为32个字符,已在Android O中删除。现在您可以自由使用更长的名称。
class Ui_Form(object):
...
def setTime(self):
# This is how to put a date into QDateEdit Element using a timestamp
# aTime = '2018-07-24 19:24:11.272000'
unix_timestamp = float(self.date_input.text())
# tmToDate = datetime.datetime.utcfromtimestamp(unix_timestamp).strftime('%Y-%m-%d %H:%M:%S')
# utc_time = time.gmtime(unix_timestamp)
local_datetime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(unix_timestamp)) # converts timestampt to local time and apply the format
local_date = local_datetime.split(" ")[0] # get only the date
d = QtCore.QDate.fromString(local_date, "yyyy-MM-dd") # Convert date into QDate object
self.dateEdit.setDate(d)
def printTimestamp(self):
# This is how to get a date from QDateEdit Element
# pyDate_str = self.dateEdit.date().toString(self.outputDateFormat) # Returns QString
# pyDate = self.dateEdit.date().toPyDate()
# date = self.dateEdit.date().getDate()
pyDatetime = self.dateEdit.dateTime().toPyDateTime() # dateTime() returns QDateTime, toPyDateTime() converts to datetime.datetime
formalDate = pyDatetime.strftime('%d/%m/%Y %H:%M:%S') # Returns datetime.datetime
tstamp = time.mktime(datetime.datetime.strptime(formalDate, '%d/%m/%Y %H:%M:%S').timetuple())
self.timestamp.setText(str(tstamp))
答案 3 :(得分:0)
也许使用重定向?
设置小属性,该属性将保存conf文件的文件名:
setprop confFileName "myConf.yml"
该conf文件中的包含所有大的属性名称和值。