3 # Copyright (C) 2009 The Android Open Source Project
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
19 # Put the modifications that you need to make into the /system/build.prop into this
20 # function. The prop object has get(name) and put(name,value) methods.
21 def mangle_build_prop(prop):
24 # Put the modifications that you need to make into the /system/build.prop into this
25 # function. The prop object has get(name) and put(name,value) methods.
26 def mangle_default_prop(prop):
27 # If ro.debuggable is 1, then enable adb on USB by default
28 # (this is for userdebug builds)
29 if prop.get("ro.debuggable") == "1":
30 val = prop.get("persist.sys.usb.config")
35 prop.put("persist.sys.usb.config", val)
36 # UsbDeviceManager expects a value here. If it doesn't get it, it will
37 # default to "adb". That might not the right policy there, but it's better
39 if not prop.get("persist.sys.usb.config"):
40 prop.put("persist.sys.usb.config", "none");
43 def __init__(self, lines):
44 self.lines = [s[:-1] for s in lines]
48 for line in self.lines:
49 if line.startswith(key):
50 return line[len(key):]
53 def put(self, name, value):
55 for i in range(0,len(self.lines)):
56 if self.lines[i].startswith(key):
57 self.lines[i] = key + value
59 self.lines.append(key + value)
62 f.write("\n".join(self.lines))
71 properties = PropFile(lines)
72 if filename.endswith("/build.prop"):
73 mangle_build_prop(properties)
74 elif filename.endswith("/default.prop"):
75 mangle_default_prop(properties)
77 sys.stderr.write("bad command line: " + str(argv) + "\n")
80 f = open(filename, 'w+')
84 if __name__ == "__main__":