summaryrefslogtreecommitdiffstats
path: root/tools/post_process_props.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/post_process_props.py')
-rwxr-xr-xtools/post_process_props.py34
1 files changed, 26 insertions, 8 deletions
diff --git a/tools/post_process_props.py b/tools/post_process_props.py
index fa6106f..64af01d 100755
--- a/tools/post_process_props.py
+++ b/tools/post_process_props.py
@@ -16,6 +16,13 @@
import sys
+
+def iteritems(obj):
+ if hasattr(obj, 'iteritems'):
+ return obj.iteritems()
+ return obj.items()
+
+
# Usage: post_process_props.py file.prop [blacklist_key, ...]
# Blacklisted keys are removed from the property file, if present
@@ -27,15 +34,22 @@ PROP_VALUE_MAX = 91
# Put the modifications that you need to make into the /system/build.prop into this
# function. The prop object has get(name) and put(name,value) methods.
-def mangle_build_prop(prop):
+def mangle_build_prop(prop, overrides):
+ if len(overrides) == 0:
+ return
+ overridelist = overrides.replace(" ",",").split(",")
+ for proppair in overridelist:
+ values = proppair.split("=")
+ prop.put(values[0], values[1])
+
pass
# Put the modifications that you need to make into the /default.prop into this
# function. The prop object has get(name) and put(name,value) methods.
def mangle_default_prop(prop):
- # If ro.debuggable is 1, then enable adb on USB by default
- # (this is for userdebug builds)
- if prop.get("ro.debuggable") == "1":
+ # If ro.adb.secure is not 1, then enable adb on USB by default
+ # (this is for eng builds)
+ if prop.get("ro.adb.secure") != "1":
val = prop.get("persist.sys.usb.config")
if val == "":
val = "adb"
@@ -46,7 +60,7 @@ def mangle_default_prop(prop):
# default to "adb". That might not the right policy there, but it's better
# to be explicit.
if not prop.get("persist.sys.usb.config"):
- prop.put("persist.sys.usb.config", "none");
+ prop.put("persist.sys.usb.config", "none")
def validate(prop):
"""Validate the properties.
@@ -56,7 +70,7 @@ def validate(prop):
"""
check_pass = True
buildprops = prop.to_dict()
- for key, value in buildprops.iteritems():
+ for key, value in iteritems(buildprops):
# Check build properties' length.
if len(key) > PROP_NAME_MAX:
check_pass = False
@@ -110,6 +124,10 @@ class PropFile:
def main(argv):
filename = argv[1]
+ if (len(argv) > 2):
+ extraargs = argv[2]
+ else:
+ extraargs = ""
f = open(filename)
lines = f.readlines()
f.close()
@@ -117,7 +135,7 @@ def main(argv):
properties = PropFile(lines)
if filename.endswith("/build.prop"):
- mangle_build_prop(properties)
+ mangle_build_prop(properties, extraargs)
elif filename.endswith("/default.prop"):
mangle_default_prop(properties)
else:
@@ -128,7 +146,7 @@ def main(argv):
sys.exit(1)
# Drop any blacklisted keys
- for key in argv[2:]:
+ for key in argv[3:]:
properties.delete(key)
f = open(filename, 'w+')