summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorMakoto Onuki <omakoto@google.com>2017-04-26 14:38:18 -0700
committerMakoto Onuki <omakoto@google.com>2017-04-26 16:12:43 -0700
commite92f79450a0e3a55586eb2992577d09fc997761a (patch)
tree8c1173bdb1d4d32f1cb8854eb06eb25537aebdb5 /core/java/android
parent5313eee98a2e7bcac48105888bdfb25d61dce2ce (diff)
Change IMPORTANCE_PERCEPTIBLE_DEPRECATED to IMPORTANCE_PERCEPTIBLE_PRE_26
Also make sure to return the legacy value from RunningAppProcessInfo.importance. Bug: 37636026 Test: cts-tradefed run cts-dev --skip-device-info --skip-preconditions --skip-system-status-check com.android.compatibility.common.tradefed.targetprep.NetworkConnectivityChecker -a armeabi-v7a -l INFO -m CtsAppTestCases -t 'android.app.cts.ActivityManagerTest#testGetRunningAppProcesses' Test: cts-tradefed run cts-dev --skip-device-info --skip-preconditions --skip-system-status-check com.android.compatibility.common.tradefed.targetprep.NetworkConnectivityChecker -a armeabi-v7a -l INFO -m CtsAppTestCases -t 'android.app.cts.ActivityManagerTest#testGetMyMemoryState' Test: cts-tradefed run cts-dev --skip-device-info --skip-preconditions --skip-system-status-check com.android.compatibility.common.tradefed.targetprep.NetworkConnectivityChecker -a armeabi-v7a -l INFO -m CtsAppTestCases -t 'android.app.cts.AlertWindowsTests' Change-Id: Ie04e4dfa40c28ea391ae5ce3c769c6f8ee70a43d
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/ActivityManager.java39
-rw-r--r--core/java/android/content/pm/PackageManagerInternal.java5
2 files changed, 35 insertions, 9 deletions
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index 1ab45b56e5ca..f89f7cd2b3b3 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -3141,10 +3141,15 @@ public class ActivityManager {
* before {@link Build.VERSION_CODES#O}. Since the {@link Build.VERSION_CODES#O} SDK,
* the value of {@link #IMPORTANCE_PERCEPTIBLE} has been fixed.
*
- * @deprecated Use {@link #IMPORTANCE_PERCEPTIBLE} instead.
+ * <p>The system will return this value instead of {@link #IMPORTANCE_PERCEPTIBLE}
+ * on Android versions below {@link Build.VERSION_CODES#O}.
+ *
+ * <p>On Android version {@link Build.VERSION_CODES#O} and later, this value will still be
+ * returned for apps with the target API level below {@link Build.VERSION_CODES#O}.
+ * For apps targeting version {@link Build.VERSION_CODES#O} and later,
+ * the correct value {@link #IMPORTANCE_PERCEPTIBLE} will be returned.
*/
- @Deprecated
- public static final int IMPORTANCE_PERCEPTIBLE_DEPRECATED = 130;
+ public static final int IMPORTANCE_PERCEPTIBLE_PRE_26 = 130;
/**
* Constant for {@link #importance}: This process is not something the user
@@ -3158,11 +3163,17 @@ public class ActivityManager {
* before {@link Build.VERSION_CODES#O}. Since the {@link Build.VERSION_CODES#O} SDK,
* the value of {@link #IMPORTANCE_CANT_SAVE_STATE} has been fixed.
*
- * @deprecated Use {@link #IMPORTANCE_CANT_SAVE_STATE} instead.
+ * <p>The system will return this value instead of {@link #IMPORTANCE_CANT_SAVE_STATE}
+ * on Android versions below {@link Build.VERSION_CODES#O}.
+ *
+ * <p>On Android version {@link Build.VERSION_CODES#O} after, this value will still be
+ * returned for apps with the target API level below {@link Build.VERSION_CODES#O}.
+ * For apps targeting version {@link Build.VERSION_CODES#O} and later,
+ * the correct value {@link #IMPORTANCE_CANT_SAVE_STATE} will be returned.
+ *
* @hide
*/
- @Deprecated
- public static final int IMPORTANCE_CANT_SAVE_STATE_DEPRECATED = 170;
+ public static final int IMPORTANCE_CANT_SAVE_STATE_PRE_26 = 170;
/**
* Constant for {@link #importance}: This process is running an
@@ -3242,15 +3253,25 @@ public class ActivityManager {
*/
public static @Importance int procStateToImportanceForClient(int procState,
Context clientContext) {
+ return procStateToImportanceForTargetSdk(procState,
+ clientContext.getApplicationInfo().targetSdkVersion);
+ }
+
+ /**
+ * See {@link #procStateToImportanceForClient}.
+ * @hide
+ */
+ public static @Importance int procStateToImportanceForTargetSdk(int procState,
+ int targetSdkVersion) {
final int importance = procStateToImportance(procState);
// For pre O apps, convert to the old, wrong values.
- if (clientContext.getApplicationInfo().targetSdkVersion < VERSION_CODES.O) {
+ if (targetSdkVersion < VERSION_CODES.O) {
switch (importance) {
case IMPORTANCE_PERCEPTIBLE:
- return IMPORTANCE_PERCEPTIBLE_DEPRECATED;
+ return IMPORTANCE_PERCEPTIBLE_PRE_26;
case IMPORTANCE_CANT_SAVE_STATE:
- return IMPORTANCE_CANT_SAVE_STATE_DEPRECATED;
+ return IMPORTANCE_CANT_SAVE_STATE_PRE_26;
}
}
return importance;
diff --git a/core/java/android/content/pm/PackageManagerInternal.java b/core/java/android/content/pm/PackageManagerInternal.java
index 7bfde751e155..7f9fe3578203 100644
--- a/core/java/android/content/pm/PackageManagerInternal.java
+++ b/core/java/android/content/pm/PackageManagerInternal.java
@@ -333,4 +333,9 @@ public abstract class PackageManagerInternal {
* @param isolatedUid isolated uid that is no longer being used.
*/
public abstract void removeIsolatedUid(int isolatedUid);
+
+ /**
+ * Return the taget SDK version for the app with the given UID.
+ */
+ public abstract int getUidTargetSdkVersion(int uid);
}