Change how we change the lcd density

This allows us to edit the props without re-zipping

Change-Id: I6d59ecf79f765009e57deabccd5de074b7a7d006
diff --git a/config/common.mk b/config/common.mk
index 66618e8..b0e2436 100644
--- a/config/common.mk
+++ b/config/common.mk
@@ -176,3 +176,5 @@
     ro.modversion=$(SLIM_MOD_VERSION) \
     ro.slim.buildtype=$(SLIM_BUILD_TYPE)
 
+EXTENDED_POST_PROCESS_PROPS := vendor/slim/tools/slim_process_props.py
+
diff --git a/tools/slim_process_props.py b/tools/slim_process_props.py
new file mode 100755
index 0000000..653110f
--- /dev/null
+++ b/tools/slim_process_props.py
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2009 The Android Open Source Project
+# Copyright (C) 2014 SlimRoms Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import os
+import sys
+
+# give us access to import the original post_process_props
+sys.path.append(os.path.join(os.getenv('ANDROID_BUILD_TOP'), 'build/tools'))
+from post_process_props import PropFile, validate
+
+
+lcd_changer = {"213": "182", "240": "182",
+               "320": "245", "480": "370"}
+
+
+def mangle_build_prop(prop):
+    lcd = prop.get('ro.sf.lcd_density')
+    new_lcd = lcd_changer.get(lcd, lcd)
+    prop.put('ro.sf.lcd_density', new_lcd)
+
+
+def mangle_default_prop(prop):
+    pass
+
+
+def main(argv):
+    fn = argv[1]
+    with open(fn) as f:
+        lines = f.readlines()
+    properties = PropFile(lines)
+
+    if fn.endswith('/build.prop'):
+        mangle_build_prop(properties)
+    elif fn.endswith('/default.prop'):
+        mangle_default_prop(properties)
+    else:
+        sys.stderr.write("%s: Unsupported file: %s\n" % (os.path.realpath(__file__), fn))
+        sys.exit(1)
+
+    if not validate(properties):
+        # the validate routine prints on error
+        sys.exit(1)
+
+    with open(fn, 'w+') as f:
+        properties.write(f)
+
+if __name__ == '__main__':
+    main(sys.argv)