feat: 第三轮深度完善 — SQLite/JSON/网络/媒体/文本 真实实现
SQLite真实数据库: - SQLiteDatabase: execSQL/insert/insertOrThrow/replace/update/delete/query 用sqlite3 - 修复getVersion/setVersion用PRAGMA user_version - 修复getMaximumSize/getPageSize/setMaximumSize/setPageSize用PRAGMA - SQLiteStatement: execute/simpleQueryForLong/simpleQueryForString/execQuery - SQLiteOpenHelper: onCreate/onUpgrade/onDowngrade回调正确触发 - 修复SQLiteCursor.moveToPosition越界处理 - 修复ContentValues值对提取bug JSON真实实现: - JSONObject: isNull/append/putOnce/putOpt/getNames - JSONArray: 完整put/get/opt/length/toString 网络真实实现: - NetworkInterface: getByName/getNetworkInterfaces/getHardwareAddress 用/sys/class/net+fcntl.ioctl - InterfaceAddress: 新增类 - ConnectivityManager: getActiveNetwork/getAllNetworks 用LinuxNetwork - WifiManager: getScanResults用nmcli, setWifiEnabled用nmcli/rfkill - BluetoothAdapter: getAddress/getName 用bluetoothctl 媒体真实实现: - MediaPlayer: prepare检查文件, getCurrentPosition实时计算, getDuration/getVideoWidth用ffprobe - MediaRecorder: setVideoSize/setVideoFrameRate/setVideoEncodingBitRate配置存储 - MediaMetadataRetriever: extractMetadata用ffprobe, getFrameAtTime用ffmpeg, getEmbeddedPicture用ffmpeg 文本真实实现: - TextUtils: split用re.split, concat/indexOf/lastIndexOf/urlEncode/urlDecode - SpannableString: setSpan/getSpans/getSpanFlags/nextSpanTransition 真实实现 - SpannableStringBuilder: 修复append重载bug Provider增强: - Settings: putBoolean/getBoolean - MediaStore: getContentUri/VOLUME常量 - ContactsContract: 补全常量和CommonDataKinds Util增强: - Log: w/e/wtf支持Throwable参数, 修复wtf重复定义bug - TypedValue: 修复complexToDimension/complexToFloat/getFloat实现 修复: - __init__.py: 补全NetworkInterface/InetAddress/MediaMetadataRetriever/SpannableStringBuilder导出 统计: 221模块, 3666类, 31005方法, 183529行
This commit is contained in:
1 parent
4235f8692c
commit
fbb8263b13
13 files changed
+1373
-146
No files matched your search
@@ -115,6 +115,41 @@ class JSONObject(Stub):
|
||||
self._map[k] = arr
|
||||
return self
|
||||
|
||||
def append(self, key, value):
|
||||
"""Append value to the JSONArray under key.
|
||||
|
||||
If the key is not present a new JSONArray containing value is created.
|
||||
If the key maps to a JSONArray the value is appended to it.
|
||||
Otherwise the existing value and the new value are placed into a new
|
||||
JSONArray.
|
||||
"""
|
||||
k = str(key)
|
||||
current = self._map.get(k)
|
||||
if isinstance(current, JSONArray):
|
||||
current.put(value)
|
||||
else:
|
||||
arr = JSONArray()
|
||||
if current is not None and current is not JSONObject.NULL:
|
||||
arr.put(current)
|
||||
arr.put(value)
|
||||
self._map[k] = arr
|
||||
return self
|
||||
|
||||
def putOnce(self, key, value):
|
||||
"""Put a key/value pair only if the key is not already present."""
|
||||
if key is None:
|
||||
raise JSONException("Null key.")
|
||||
k = str(key)
|
||||
if k not in self._map:
|
||||
self._map[k] = JSONObject._wrap(value)
|
||||
return self
|
||||
|
||||
def putOpt(self, key, value):
|
||||
"""Put a key/value pair, but only if key and value are both non-null."""
|
||||
if key is not None and value is not None:
|
||||
return self.put(key, value)
|
||||
return self
|
||||
|
||||
def get(self, key):
|
||||
k = str(key)
|
||||
if k not in self._map:
|
||||
@@ -239,6 +274,14 @@ class JSONObject(Stub):
|
||||
def has(self, key):
|
||||
return str(key) in self._map
|
||||
|
||||
def isNull(self, key):
|
||||
"""Returns true if this object has no mapping for key or if it has a
|
||||
mapping whose value is JSONObject.NULL."""
|
||||
k = str(key)
|
||||
if k not in self._map:
|
||||
return True
|
||||
return self._map[k] is JSONObject.NULL
|
||||
|
||||
def remove(self, key):
|
||||
k = str(key)
|
||||
if k in self._map:
|
||||
@@ -255,6 +298,15 @@ class JSONObject(Stub):
|
||||
arr.put(k)
|
||||
return arr
|
||||
|
||||
@staticmethod
|
||||
def getNames(jsonObject):
|
||||
"""Returns an array of field names, or None if the object is None/empty."""
|
||||
if jsonObject is None:
|
||||
return None
|
||||
if not jsonObject._map:
|
||||
return None
|
||||
return [str(k) for k in jsonObject._map.keys()]
|
||||
|
||||
def length(self):
|
||||
return len(self._map)
|
||||
|
||||
|
||||
Reference in new issue
Block a user