From 3d2337eeb5c8b28bace281d049c5ca8cd13c8b70 Mon Sep 17 00:00:00 2001 From: Alan Viverette Date: Tue, 11 Aug 2015 17:27:04 -0400 Subject: Cherry-pick system theme rebase to fix square UI on round watches Our system themes were based on configurations that were added post- init of the system theme. I96e695441543379e4d5fdf3cc6f18d9e6cf953b4 broke this, because there was a race condition in the code for rebasing themes If8fecde76d62738a8e55eddf898eafc468afdba2 (the cherry-picked commit) fixes the race condition and adds the rebasing back in. This change cherry picks If8fecde76d62738a8e55eddf898eafc468afdba2. Bug:23387146 Change-Id: I0725028e48599fc6cd9731ae16c71474dd5827e5 --- core/java/android/content/res/Resources.java | 207 +++++++++++---------------- 1 file changed, 85 insertions(+), 122 deletions(-) (limited to 'core/java/android/content') diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java index 731903c..8272458 100644 --- a/core/java/android/content/res/Resources.java +++ b/core/java/android/content/res/Resources.java @@ -1438,10 +1438,12 @@ public class Resources { * if not already defined in the theme. */ public void applyStyle(int resId, boolean force) { - AssetManager.applyThemeStyle(mTheme, resId, force); + synchronized (mKey) { + AssetManager.applyThemeStyle(mTheme, resId, force); - mThemeResId = resId; - mKey.append(resId, force); + mThemeResId = resId; + mKey.append(resId, force); + } } /** @@ -1454,10 +1456,14 @@ public class Resources { * @param other The existing Theme to copy from. */ public void setTo(Theme other) { - AssetManager.copyTheme(mTheme, other.mTheme); + synchronized (mKey) { + synchronized (other.mKey) { + AssetManager.copyTheme(mTheme, other.mTheme); - mThemeResId = other.mThemeResId; - mKey.setTo(other.getKey()); + mThemeResId = other.mThemeResId; + mKey.setTo(other.getKey()); + } + } } /** @@ -1480,11 +1486,13 @@ public class Resources { * @see #obtainStyledAttributes(AttributeSet, int[], int, int) */ public TypedArray obtainStyledAttributes(@StyleableRes int[] attrs) { - final int len = attrs.length; - final TypedArray array = TypedArray.obtain(Resources.this, len); - array.mTheme = this; - AssetManager.applyStyle(mTheme, 0, 0, 0, attrs, array.mData, array.mIndices); - return array; + synchronized (mKey) { + final int len = attrs.length; + final TypedArray array = TypedArray.obtain(Resources.this, len); + array.mTheme = this; + AssetManager.applyStyle(mTheme, 0, 0, 0, attrs, array.mData, array.mIndices); + return array; + } } /** @@ -1494,7 +1502,7 @@ public class Resources { *

Be sure to call {@link TypedArray#recycle() TypedArray.recycle()} when you are done * with the array. * - * @param resid The desired style resource. + * @param resId The desired style resource. * @param attrs The desired attributes in the style. * * @throws NotFoundException Throws NotFoundException if the given ID does not exist. @@ -1507,39 +1515,15 @@ public class Resources { * @see #obtainStyledAttributes(int[]) * @see #obtainStyledAttributes(AttributeSet, int[], int, int) */ - public TypedArray obtainStyledAttributes(@StyleRes int resid, @StyleableRes int[] attrs) + public TypedArray obtainStyledAttributes(@StyleRes int resId, @StyleableRes int[] attrs) throws NotFoundException { - final int len = attrs.length; - final TypedArray array = TypedArray.obtain(Resources.this, len); - array.mTheme = this; - if (false) { - int[] data = array.mData; - - System.out.println("**********************************************************"); - System.out.println("**********************************************************"); - System.out.println("**********************************************************"); - System.out.println("Attributes:"); - String s = " Attrs:"; - int i; - for (i=0; ioutValue is valid, else false. */ public boolean resolveAttribute(int resid, TypedValue outValue, boolean resolveRefs) { - boolean got = mAssets.getThemeValue(mTheme, resid, outValue, resolveRefs); - if (false) { - System.out.println( - "resolveAttribute #" + Integer.toHexString(resid) - + " got=" + got + ", type=0x" + Integer.toHexString(outValue.type) - + ", data=0x" + Integer.toHexString(outValue.data)); + synchronized (mKey) { + return mAssets.getThemeValue(mTheme, resid, outValue, resolveRefs); } - return got; } /** @@ -1739,8 +1693,11 @@ public class Resources { * @see ActivityInfo */ public int getChangingConfigurations() { - final int nativeChangingConfig = AssetManager.getThemeChangingConfigurations(mTheme); - return ActivityInfo.activityInfoConfigNativeToJava(nativeChangingConfig); + synchronized (mKey) { + final int nativeChangingConfig = + AssetManager.getThemeChangingConfigurations(mTheme); + return ActivityInfo.activityInfoConfigNativeToJava(nativeChangingConfig); + } } /** @@ -1751,7 +1708,9 @@ public class Resources { * @param prefix Text to prefix each line printed. */ public void dump(int priority, String tag, String prefix) { - AssetManager.dumpTheme(mTheme, priority, tag, prefix); + synchronized (mKey) { + AssetManager.dumpTheme(mTheme, priority, tag, prefix); + } } @Override @@ -1801,19 +1760,21 @@ public class Resources { */ @ViewDebug.ExportedProperty(category = "theme", hasAdjacentMapping = true) public String[] getTheme() { - final int N = mKey.mCount; - final String[] themes = new String[N * 2]; - for (int i = 0, j = N - 1; i < themes.length; i += 2, --j) { - final int resId = mKey.mResId[j]; - final boolean forced = mKey.mForce[j]; - try { - themes[i] = getResourceName(resId); - } catch (NotFoundException e) { - themes[i] = Integer.toHexString(i); + synchronized (mKey) { + final int N = mKey.mCount; + final String[] themes = new String[N * 2]; + for (int i = 0, j = N - 1; i < themes.length; i += 2, --j) { + final int resId = mKey.mResId[j]; + final boolean forced = mKey.mForce[j]; + try { + themes[i] = getResourceName(resId); + } catch (NotFoundException e) { + themes[i] = Integer.toHexString(i); + } + themes[i + 1] = forced ? "forced" : "not forced"; } - themes[i + 1] = forced ? "forced" : "not forced"; + return themes; } - return themes; } /** @hide */ @@ -1834,13 +1795,15 @@ public class Resources { * @hide */ public void rebase() { - AssetManager.clearTheme(mTheme); - - // Reapply the same styles in the same order. - for (int i = 0; i < mKey.mCount; i++) { - final int resId = mKey.mResId[i]; - final boolean force = mKey.mForce[i]; - AssetManager.applyThemeStyle(mTheme, resId, force); + synchronized (mKey) { + AssetManager.clearTheme(mTheme); + + // Reapply the same styles in the same order. + for (int i = 0; i < mKey.mCount; i++) { + final int resId = mKey.mResId[i]; + final boolean force = mKey.mForce[i]; + AssetManager.applyThemeStyle(mTheme, resId, force); + } } } } -- cgit v1.1 From 61665cc4aeb51be0f293cf252dc43ca2ced08b92 Mon Sep 17 00:00:00 2001 From: Vinod Krishnan Date: Mon, 31 Aug 2015 19:30:20 -0700 Subject: Add some constants for Wear MNC Perms - Add an API for getting list of apps that has runtime perms Change-Id: I4ebfc01033ea96efaac062fd34982fbd0d081073 --- core/java/android/content/Intent.java | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'core/java/android/content') diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index 87d52e4..12c2632 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -1604,6 +1604,23 @@ public class Intent implements Parcelable, Cloneable { = "android.intent.action.GET_PERMISSIONS_COUNT"; /** + * Broadcast action that requests list of all apps that have runtime permissions. It will + * respond to the request by sending a broadcast with action defined by + * {@link #EXTRA_GET_PERMISSIONS_PACKAGES_RESPONSE_INTENT}. The response will contain + * {@link #EXTRA_GET_PERMISSIONS_APP_LIST_RESULT}, as well as + * {@link #EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT}, with contents described below or + * a null upon failure. + * + *

{@link #EXTRA_GET_PERMISSIONS_APP_LIST_RESULT} will contain a list of package names of + * apps that have runtime permissions. {@link #EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT} + * will contain the list of app labels corresponding ot the apps in the first list. + * + * @hide + */ + public static final String ACTION_GET_PERMISSIONS_PACKAGES + = "android.intent.action.GET_PERMISSIONS_PACKAGES"; + + /** * Extra included in response to {@link #ACTION_GET_PERMISSIONS_COUNT}. * @hide */ @@ -1618,6 +1635,20 @@ public class Intent implements Parcelable, Cloneable { = "android.intent.extra.GET_PERMISSIONS_GROUP_LIST_RESULT"; /** + * String list of apps that have one or more runtime permissions. + * @hide + */ + public static final String EXTRA_GET_PERMISSIONS_APP_LIST_RESULT + = "android.intent.extra.GET_PERMISSIONS_APP_LIST_RESULT"; + + /** + * String list of app labels for apps that have one or more runtime permissions. + * @hide + */ + public static final String EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT + = "android.intent.extra.GET_PERMISSIONS_APP_LABEL_LIST_RESULT"; + + /** * Required extra to be sent with {@link #ACTION_GET_PERMISSIONS_COUNT} broadcasts. * @hide */ @@ -1625,6 +1656,13 @@ public class Intent implements Parcelable, Cloneable { = "android.intent.extra.GET_PERMISSIONS_RESONSE_INTENT"; /** + * Required extra to be sent with {@link #ACTION_GET_PERMISSIONS_PACKAGES} broadcasts. + * @hide + */ + public static final String EXTRA_GET_PERMISSIONS_PACKAGES_RESPONSE_INTENT + = "android.intent.extra.GET_PERMISSIONS_PACKAGES_RESONSE_INTENT"; + + /** * Activity action: Launch UI to manage which apps have a given permission. *

* Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access -- cgit v1.1 From bc58f59da6226c6f1d240c95d566186f679fc310 Mon Sep 17 00:00:00 2001 From: Bryce Lee Date: Fri, 25 Sep 2015 16:43:01 -0700 Subject: Add ThermalObserver system service to capture thermal state uevents. Bug: 21445745 Change-Id: I980d60b66ca51942a1fd62502d6cf1f09208fc3a --- core/java/android/content/Intent.java | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'core/java/android/content') diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index 12c2632..6bbee56 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -3022,6 +3022,39 @@ public class Intent implements Parcelable, Cloneable { public static final String EXTRA_PROCESS_TEXT_READONLY = "android.intent.extra.PROCESS_TEXT_READONLY"; + /** + * Broadcast action: reports when a new thermal event has been reached. When the device + * is reaching its maximum temperatue, the thermal level reported + * {@hide} + */ + @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) + public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT"; + + /** {@hide} */ + public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE"; + + /** + * Thermal state when the device is normal. This state is sent in the + * {@link ACTION_THERMAL_EVENT} broadcast as {@link EXTRA_THERMAL_STATE}. + * {@hide} + */ + public static final int EXTRA_THERMAL_STATE_NORMAL = 0; + + /** + * Thermal state where the device is approaching its maximum threshold. This state is sent in + * the {@link ACTION_THERMAL_EVENT} broadcast as {@link EXTRA_THERMAL_STATE}. + * {@hide} + */ + public static final int EXTRA_THERMAL_STATE_WARNING = 1; + + /** + * Thermal state where the device has reached its maximum threshold. This state is sent in the + * {@link ACTION_THERMAL_EVENT} broadcast as {@link EXTRA_THERMAL_STATE}. + * {@hide} + */ + public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2; + + // --------------------------------------------------------------------- // --------------------------------------------------------------------- // Standard intent categories (see addCategory()). -- cgit v1.1 From 979b81ac33c2ba678414c5350c19fc78dbac724a Mon Sep 17 00:00:00 2001 From: Anthony Hugh Date: Tue, 29 Sep 2015 16:50:35 -0700 Subject: Give Android Wear system apps default permission This change grants Android Wear system components default permission. I have also added a new Intent category to help identify the main Home handler on Wear. BUG: 23419042 Change-Id: Ie669a9908bd3b03498f75c5ca22c0fddf52a5203 --- core/java/android/content/Intent.java | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'core/java/android/content') diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index 6bbee56..7173591 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -3157,6 +3157,13 @@ public class Intent implements Parcelable, Cloneable { @SdkConstant(SdkConstantType.INTENT_CATEGORY) public static final String CATEGORY_HOME = "android.intent.category.HOME"; /** + * This is the home activity that is displayed when the device is finished setting up and ready + * for use. + * @hide + */ + @SdkConstant(SdkConstantType.INTENT_CATEGORY) + public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN"; + /** * This is the setup wizard activity, that is the first activity that is displayed * when the user sets up the device for the first time. * @hide -- cgit v1.1 From 3575a400090a0863a5978d9550d171e0525d3b13 Mon Sep 17 00:00:00 2001 From: Anthony Hugh Date: Mon, 26 Oct 2015 17:47:05 -0700 Subject: Add intent extra for determining if apps are system apps This is being added to help identify system apps so that the UI can filter on that type. BUG: 24955055 Change-Id: Ie4be3717ce997f60eeb48a389c0f54ce5803141a --- core/java/android/content/Intent.java | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'core/java/android/content') diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index 7173591..5abf047 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -1649,6 +1649,14 @@ public class Intent implements Parcelable, Cloneable { = "android.intent.extra.GET_PERMISSIONS_APP_LABEL_LIST_RESULT"; /** + * Boolean list describing if the app is a system app for apps that have one or more runtime + * permissions. + * @hide + */ + public static final String EXTRA_GET_PERMISSIONS_IS_SYSTEM_APP_LIST_RESULT + = "android.intent.extra.GET_PERMISSIONS_IS_SYSTEM_APP_LIST_RESULT"; + + /** * Required extra to be sent with {@link #ACTION_GET_PERMISSIONS_COUNT} broadcasts. * @hide */ -- cgit v1.1 From e2ed23e6b221185ce2587fb19a6e904dbf7ec77b Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Thu, 29 Oct 2015 19:00:44 -0700 Subject: Handle "uninstalled" apps when pruning app-ops. During system boot, we prune app-ops belonging to apps that have been uninstalled. However, apps installed on adopted storage devices haven't been scanned at this point, so they appear to be uninstalled. To avoid pruning app-ops for these apps, we need a getPackageUid() variant that also considers "uninstalled" apps for which we still have PackageSetting values. Bug: 25206071 Change-Id: I1820f674d45c5ddc1c5f10ed7d859e7025005e28 --- core/java/android/content/pm/IPackageManager.aidl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'core/java/android/content') diff --git a/core/java/android/content/pm/IPackageManager.aidl b/core/java/android/content/pm/IPackageManager.aidl index a5e9faf..fec2c44 100644 --- a/core/java/android/content/pm/IPackageManager.aidl +++ b/core/java/android/content/pm/IPackageManager.aidl @@ -63,7 +63,9 @@ interface IPackageManager { boolean isPackageAvailable(String packageName, int userId); PackageInfo getPackageInfo(String packageName, int flags, int userId); int getPackageUid(String packageName, int userId); + int getPackageUidEtc(String packageName, int flags, int userId); int[] getPackageGids(String packageName, int userId); + int[] getPackageGidsEtc(String packageName, int flags, int userId); String[] currentToCanonicalPackageNames(in String[] names); String[] canonicalToCurrentPackageNames(in String[] names); -- cgit v1.1