diff options
| author | 2018-01-31 07:59:17 +0000 | |
|---|---|---|
| committer | 2018-01-31 08:03:29 +0000 | |
| commit | d960cc4a511e4f659aaae4aea9bc3b032d28c26b (patch) | |
| tree | 59e45d850f04cbd0297d7f189cae3a3956fefb51 | |
| parent | b6d5a85a9ccd2f691dc2e18746e91758414cdfdf (diff) | |
Show hidden API warning once per process
In order to not spam users with warning toasts, add a boolean flag
that guards the displaying of a warning message about hidden API
usage and is set after the first time a message is shown.
Bug: 64382372
Test: manual
Change-Id: If7ea995ddf4727a15eccf55dad42ef7775b1fc91
| -rw-r--r-- | core/java/android/app/Activity.java | 5 | ||||
| -rw-r--r-- | core/java/android/app/ActivityThread.java | 1 |
2 files changed, 5 insertions, 1 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 3abb24ce7b20..da324fc1b092 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -7071,7 +7071,10 @@ public class Activity extends ContextThemeWrapper boolean isApiWarningEnabled = SystemProperties.getInt("ro.art.hiddenapi.warning", 0) == 1; if (isAppDebuggable || isApiWarningEnabled) { - if (VMRuntime.getRuntime().hasUsedHiddenApi()) { + if (!mMainThread.mHiddenApiWarningShown && VMRuntime.getRuntime().hasUsedHiddenApi()) { + // Only show the warning once per process. + mMainThread.mHiddenApiWarningShown = true; + String appName = getApplicationInfo().loadLabel(getPackageManager()) .toString(); String warning = "Detected problems with API compatiblity\n" diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 2ecd3120345d..565eaeb632b1 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -266,6 +266,7 @@ public final class ActivityThread { boolean mJitEnabled = false; boolean mSomeActivitiesChanged = false; boolean mUpdatingSystemConfig = false; + /* package */ boolean mHiddenApiWarningShown = false; // These can be accessed by multiple threads; mResourcesManager is the lock. // XXX For now we keep around information about all packages we have |