Remove T-mobile items not used by new theme engine

Change-Id: I1e9c14e63ec25fdff61cfd2b7b8a05b1e488e558

Conflicts:
	core/java/android/app/ResourcesManager.java
	policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
	services/java/com/android/server/pm/PackageManagerService.java

	modified:   Android.mk
	modified:   core/java/android/app/ActivityManager.java
	modified:   core/java/android/app/ActivityThread.java
	modified:   core/java/android/app/ApplicationPackageManager.java
	modified:   core/java/android/app/ResourcesManager.java
	modified:   core/java/android/content/Intent.java
	modified:   core/java/android/content/pm/ApplicationInfo.java
	modified:   core/java/android/content/pm/BaseThemeInfo.java
	modified:   core/java/android/content/pm/PackageInfo.java
	modified:   core/java/android/content/pm/PackageManager.java
	modified:   core/java/android/content/pm/PackageParser.java
	deleted:    core/java/android/content/pm/ThemeInfo.aidl
	modified:   core/java/android/content/res/AssetManager.java
	modified:   core/java/android/content/res/Configuration.java
	modified:   core/java/android/content/res/CustomTheme.java
	deleted:    core/java/android/content/res/PackageRedirectionMap.aidl
	deleted:    core/java/android/content/res/PackageRedirectionMap.java
	modified:   core/java/android/os/SystemProperties.java
	deleted:    core/java/com/android/internal/app/IAssetRedirectionManager.aidl
	deleted:    core/java/com/android/internal/app/ThemeUtils.java
	modified:   core/java/com/android/internal/os/ZygoteInit.java
	modified:   core/jni/Android.mk
	modified:   core/jni/AndroidRuntime.cpp
	modified:   core/jni/android_util_AssetManager.cpp
	deleted:    core/jni/android_util_PackageRedirectionMap.cpp
	modified:   core/res/AndroidManifest.xml
	modified:   data/etc/platform.xml
	modified:   include/androidfw/AssetManager.h
	deleted:    include/androidfw/PackageRedirectionMap.h
	modified:   include/androidfw/ResourceTypes.h
	deleted:    include/androidfw/ZipEntry.h
	deleted:    include/androidfw/ZipFile.h
	modified:   libs/androidfw/Android.mk
	modified:   libs/androidfw/AssetManager.cpp
	deleted:    libs/androidfw/PackageRedirectionMap.cpp
	modified:   libs/androidfw/ResourceTypes.cpp
	modified:   media/java/android/media/Ringtone.java
	modified:   media/java/android/media/RingtoneManager.java
	modified:   packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
	modified:   policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
	deleted:    services/java/com/android/server/AssetRedirectionManagerService.java
	modified:   services/java/com/android/server/content/SyncManager.java
	modified:   services/java/com/android/server/pm/PackageManagerService.java
	modified:   test-runner/src/android/test/mock/MockPackageManager.java
Runtime resource overlay, iteration 2

Support any number of overlay packages. Support any target package.

UPDATED PACKAGE MATCHING
------------------------
In Runtime resource overlay, iteration 1, only a single overlay package
was considered. Package matching was based on file paths:
/vendor/overlay/system/framework-res.apk corresponded to
/system/framework-res.apk. Introduce a more flexible matching scheme
where any package is an overlay package if its manifest includes

    <overlay targetPackage="com.target.package"/>

For security reasons, an overlay package must fulfill certain criteria
to take effect: see below.

THE IDMAP TOOL AND IDMAP FILES
------------------------------
Idmap files are created by the 'idmap' binary; idmap files must be
present when loading packages. For the Android system, Zygote calls
'idmap' as part of the resource pre-loading. For application packages,
'idmap' is invoked via 'installd' during package installation (similar
to 'dexopt').

UPDATED FLOW
------------
The following is an outline of the start-up sequences for the Android
system and Android apps. Steps marked with '+' are introduced by this
commit.

Zygote initialization
   Initial AssetManager object created
+    idmap --scan creates idmaps for overlays targeting 'android', \
           stores list of overlays in /data/resource-cache/overlays.list
   AssetManager caches framework-res.apk
+  AssetManager caches overlay packages listed in overlays.list

Android boot
   New AssetManager's ResTable acquired
     AssetManager re-uses cached framework-res.apk
+    AssetManager re-uses cached 'android' overlays (if any)

App boot
   ActivityThread prepares AssetManager to load app.apk
+  ActivityThread prepares AssetManager to load app overlays (if any)
   New AssetManager's ResTable acquired as per Android boot

SECURITY
--------
Overlay packages are required to be pre-loaded (in /vendor/overlay).
These packages are trusted by definition. A future iteration of runtime
resource overlay may add support for downloaded overlays, which would
likely require target and overlay signatures match for the overlay to
be trusted.

LOOKUP PRIORITY
---------------
During resource lookup, packages are sequentially queried to provide a
best match, given the constraints of the current configuration. If any
package provide a better match than what has been found so far, it
replaces the previous match. The target package is always queried last.

When loading a package with more than one overlay, the order in which
the overlays are added become significant if several packages overlay
the same resource.

Had downloaded overlays been supported, the install time could have been
used to determine the load order. Regardless, for pre-installed
overlays, the install time is randomly determined by the order in which
the Package Manager locates the packages during initial boot. To support
a well-defined order, pre-installed overlay packages are expected to
define an additional 'priority' attribute in their <overlay> tags:

    <overlay targetPackage="com.target.package" priority="1234"/>

Pre-installed overlays are loaded in order of their priority attributes,
sorted in ascending order.

Assigning the same priority to several overlays targeting the same base
package leads to undefined behaviour. It is the responsibility of the
vendor to avoid this.

The following example shows the ResTable and PackageGroups after loading
an application and two overlays. The resource lookup framework will
query the packages in the order C, B, A.

        +------+------+-     -+------+------+
        | 0x01 |      |  ...  |      | 0x7f |
        +------+------+-     -+------+------+
            |                           |
        "android"                Target package A
                                        |
                       Pre-installed overlay B (priority 1)
                                        |
                       Pre-installed overlay C (priority 2)

Change-Id: If49c963149369b1957f7d2303b3dd27f669ed24e

Conflicts:
	include/androidfw/AssetManager.h
	include/androidfw/ResourceTypes.h
	libs/androidfw/AssetManager.cpp
	packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java

	modified:   core/java/android/app/ActivityThread.java
	modified:   core/java/android/app/ApplicationPackageManager.java
	modified:   core/java/android/app/ContextImpl.java
	modified:   core/java/android/app/LoadedApk.java
	modified:   core/java/android/app/ResourcesManager.java
	modified:   core/java/android/content/pm/PackageInfo.java
	modified:   core/java/android/content/pm/PackageParser.java
	modified:   core/java/android/content/res/AssetManager.java
	modified:   core/jni/android_util_AssetManager.cpp
	modified:   core/res/res/values/attrs_manifest.xml
	modified:   include/androidfw/AssetManager.h
	modified:   include/androidfw/ResourceTypes.h
	modified:   libs/androidfw/AssetManager.cpp
	modified:   libs/androidfw/ResourceTypes.cpp
	modified:   services/java/com/android/server/pm/Installer.java
	modified:   services/java/com/android/server/pm/PackageManagerService.java
New Theme Engine [1/6]

[Summary]
Took the T-mobile theme engine, replaced redirection mechanism with a modified Sony idmap and then extended the feature set.

The new theme engine allows the following:
1. Simple creation of themes by compiling on the device
2. System level icon packs.
3. Font packs
4. Swappable boot animations
5. Lockscreen wallpaper
6. Alarms
7  Of course all the things the previous engine could do including skins, ringtones and
notifications. There is also legacy support for old themes.

[Theme Format]
For the time being themes are APKs with all theme elements in the assets folder. Since these resources
are compiled at runtime there is no reason we can't change it to a zip but creating an APK is well
understood by themers.

The directory structure looks like this:

AndroidManifest.xml
src/
res/
assets/
  boot-animation/
  fonts/
  icons/
    res/ (note: same dir structure as res/ in trebuchet icon packs)
  wallpapers/
  ringtones/
  notifications/
  alarms/
  overlays/
      [target-pkg-name1]
          res/
           drawable/
           drawable-hdpi/
           ...
           layouts/
           xml/
      [target-pkg-name2]
          res/

Where [target-pkg-name] is the package of the app you are trying to overlay. For example, to overlay
facebook's app you would make a directory under overlay called "com.facebook.katana". For frameworks
resources use the target name "android".

Under each target pkg is a res/ folder which follows the same format as a typical APK's res/. During
install time AAPT will actually compiling these res/ folders individually.

There are also non-overlay folders like boot-animation, wallpaper, fonts etc.

A theme APK is identified by meta-value data in AndroidManifest.xml. Here is an example:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.me.andytheme2"
    android:versionCode="1"
    android:versionName="1.0" >
    <uses-feature android:name="org.cyanogenmod.theme" />
    <meta-data android:name="org.cyanogenmod.theme.name" android:value="My Blue Theme"/>
    <meta-data android:name="org.cyanogenmod.theme.author" android:value="John Doe" />
</manifest>

By using meta-data we do not require special new tools.

[Changes to PackageManagerService]
During install time PackageManagerService will scan meta-data values in the manifest. If it finds
a meta-data name of "org.cyanogenmod.theme.name" then it will assume the APK is a theme and mark it as such.

Then PM will find all overlays from the theme. For each overlay target it will generate a resource table
and an idmap via Installd. Aapt will also run to compile 9patch and xml files. The new restable, idmap, and compiled resources
are stored under /data/resource-cache

[Changes to aapt]
Aapt has been extended to read zip entries and accept file descriptors to work with installd.

[Changes to frameworks/core]
Most of what TMO has done already here for runtime theme changes is kept so most changes
are simply plumbing to make Sony's overlays work at runtime. Additionally changes were made
to TMO classes to support mix n match better.

[Changes to libandroidfw]
Sony's idmap concept is one overlay apk -> one target apk, but themes support multiple target apks. So
most of the changes here are for support this. Also we support runtime overlay changes so functionality
had to be added to add/remove to the resource table during a configuration change.

[Security]
We run aapt in reduced priveledges via Installd. At the moment however a theme can overlay any resource. This
includes strings and layouts so any malicous theme could cause serious crashes to the device.

[See Also]
frameworks/native
external/skia
build
vendor/tmobile/providers/ThemeManager
vendor/tmobile/libs/com.tmobile.themes

[Contributors]
Andrew Mast <andy@cyngn.com>
Clark Scheff <clark@cyngn.com>
Special thanks to the T-Mobile theme team. This would not be possible without their efforts.
Special thanks to Mårten Kongstad and the rest of the Sony team for their work in idmap.

Change-Id: I812a3757bdb56c429b5870ff922485439ae00f8d

Conflicts:
	core/java/android/app/ContextImpl.java
	core/java/android/content/Context.java
	core/java/com/android/internal/os/ZygoteConnection.java
	include/androidfw/AssetManager.h
	libs/androidfw/AssetManager.cpp
	libs/androidfw/ResourceTypes.cpp
	packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
	packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
	packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
	policy/src/com/android/internal/policy/impl/GlobalActions.java
	services/java/com/android/server/InputMethodManagerService.java
	services/java/com/android/server/pm/PackageManagerService.java

	modified:   Android.mk
	modified:   cmds/bootanimation/BootAnimation.cpp
	modified:   core/java/android/app/ActivityManager.java
	modified:   core/java/android/app/ActivityThread.java
	modified:   core/java/android/app/ApplicationPackageManager.java
	modified:   core/java/android/app/ContextImpl.java
	new file:   core/java/android/app/IconPackHelper.java
	modified:   core/java/android/app/LoadedApk.java
	modified:   core/java/android/app/ResourcesManager.java
	modified:   core/java/android/content/Context.java
	modified:   core/java/android/content/pm/ApplicationInfo.java
	modified:   core/java/android/content/pm/IPackageManager.aidl
	new file:   core/java/android/content/pm/LegacyThemeInfo.aidl
	renamed:    core/java/android/content/pm/ThemeInfo.java -> core/java/android/content/pm/LegacyThemeInfo.java
	modified:   core/java/android/content/pm/PackageInfo.java
	modified:   core/java/android/content/pm/PackageItemInfo.java
	modified:   core/java/android/content/pm/PackageManager.java
	modified:   core/java/android/content/pm/PackageParser.java
	new file:   core/java/android/content/pm/ThemeInfo.aidl
	modified:   core/java/android/content/pm/ThemeInfo.java
	new file:   core/java/android/content/pm/ThemeUtils.java
	modified:   core/java/android/content/res/AssetManager.java
	modified:   core/java/android/content/res/Configuration.java
	modified:   core/java/android/content/res/CustomTheme.java
	new file:   core/java/android/content/res/IThemeChangeListener.aidl
	new file:   core/java/android/content/res/IThemeService.aidl
	modified:   core/java/android/content/res/Resources.java
	new file:   core/java/android/content/res/ThemeManager.java
	modified:   core/java/android/os/Process.java
	new file:   core/java/android/provider/ThemesContract.java
	modified:   core/java/com/android/internal/os/ZygoteConnection.java
	modified:   core/java/com/android/internal/os/ZygoteInit.java
	modified:   core/jni/android/graphics/Typeface.cpp
	modified:   core/jni/android_util_AssetManager.cpp
	modified:   core/res/AndroidManifest.xml
	modified:   graphics/java/android/graphics/Typeface.java
	modified:   include/androidfw/AssetManager.h
	modified:   include/androidfw/ResourceTypes.h
	modified:   libs/androidfw/AssetManager.cpp
	modified:   libs/androidfw/ResourceTypes.cpp
	modified:   media/java/android/media/AudioService.java
	modified:   packages/SystemUI/res/layout/status_bar.xml
	modified:   packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
	modified:   packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
	modified:   packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
	modified:   policy/src/com/android/internal/policy/impl/GlobalActions.java
	modified:   policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
	modified:   services/java/com/android/server/AppsLaunchFailureReceiver.java
	modified:   services/java/com/android/server/DeviceStorageMonitorService.java
	modified:   services/java/com/android/server/InputMethodManagerService.java
	modified:   services/java/com/android/server/NotificationManagerService.java
	modified:   services/java/com/android/server/SystemServer.java
	new file:   services/java/com/android/server/ThemeService.java
	modified:   services/java/com/android/server/UiModeManagerService.java
	modified:   services/java/com/android/server/am/ActivityManagerService.java
	modified:   services/java/com/android/server/connectivity/Tethering.java
	modified:   services/java/com/android/server/pm/Installer.java
	modified:   services/java/com/android/server/pm/PackageManagerService.java
	modified:   services/java/com/android/server/wm/WindowManagerService.java
	modified:   test-runner/src/android/test/mock/MockPackageManager.java
	modified:   tools/aapt/AaptAssets.cpp
	modified:   tools/aapt/AaptAssets.h
	modified:   tools/aapt/Bundle.h
	modified:   tools/aapt/Command.cpp
	modified:   tools/aapt/Images.cpp
	modified:   tools/aapt/Images.h
	modified:   tools/aapt/Main.cpp
	modified:   tools/aapt/Main.h
	modified:   tools/aapt/Package.cpp
	modified:   tools/aapt/Resource.cpp
	modified:   tools/aapt/XMLNode.cpp
	modified:   tools/aapt/XMLNode.h
	modified:   tools/aapt/ZipFile.cpp
	modified:   tools/aapt/ZipFile.h
Merge branch 'kitkat' of https://github.com/LiquidSmooth/android_frameworks_base into HEAD