diff options
author | Ricardo Cerqueira <cyanogenmod@cerqueira.org> | 2013-06-20 12:38:43 +0100 |
---|---|---|
committer | Danny Baumann <dannybaumann@web.de> | 2013-06-20 14:58:14 +0200 |
commit | 44eea56a88a6c016cbf2419a35d49c741fd143a9 (patch) | |
tree | 7be933392f639d536c4e2440fc70f0f20b926d31 /core/java | |
parent | 63e13f9b9d69b62d6bbd335f7de7de6cf837dcbd (diff) | |
download | frameworks_base-44eea56a88a6c016cbf2419a35d49c741fd143a9.zip frameworks_base-44eea56a88a6c016cbf2419a35d49c741fd143a9.tar.gz frameworks_base-44eea56a88a6c016cbf2419a35d49c741fd143a9.tar.bz2 |
ThemeUtils: Retain the original package name in themed UI context
In order for themes to reflect on system elements, we're changing
their context, including the package name.
This breaks anything that tries to identify system elements,
most notably any users of the uiautomator. Trying to do
'UiSelector().packageName("android")' to find, for example,
a force-close dialog will fail.
Fixes com.android.cts.uiautomatortest.CtsUiAutomatorTest#testUiWatcher
Change-Id: Ic05c3024b20ac3772ed5597846fbfa4a184ebb0d
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/com/android/internal/app/ThemeUtils.java | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/core/java/com/android/internal/app/ThemeUtils.java b/core/java/com/android/internal/app/ThemeUtils.java index 4265fd5..2eda7fd 100644 --- a/core/java/com/android/internal/app/ThemeUtils.java +++ b/core/java/com/android/internal/app/ThemeUtils.java @@ -17,6 +17,7 @@ package com.android.internal.app; import android.content.Context; +import android.content.ContextWrapper; import android.content.BroadcastReceiver; import android.content.IntentFilter; import android.content.pm.PackageManager; @@ -32,9 +33,25 @@ public class ThemeUtils { private static final String DATA_TYPE_TMOBILE_THEME = "vnd.tmobile.cursor.item/theme"; private static final String ACTION_TMOBILE_THEME_CHANGED = "com.tmobile.intent.action.THEME_CHANGED"; + private static class ThemedUiContext extends ContextWrapper { + private String mPackageName; + + public ThemedUiContext(Context context, String packageName) { + super(context); + mPackageName = packageName; + } + + @Override + public String getPackageName() { + return mPackageName; + } + } + public static Context createUiContext(final Context context) { try { - return context.createPackageContext("com.android.systemui", Context.CONTEXT_RESTRICTED); + Context uiContext = context.createPackageContext("com.android.systemui", + Context.CONTEXT_RESTRICTED); + return new ThemedUiContext(uiContext, context.getPackageName()); } catch (PackageManager.NameNotFoundException e) { } |