diff options
| author | David Brazdil <dbrazdil@google.com> | 2018-01-25 22:32:28 +0000 |
|---|---|---|
| committer | android-build-merger <android-build-merger@google.com> | 2018-01-25 22:32:28 +0000 |
| commit | 61c4d63c9837c2781039c53ee027bd9723a769da (patch) | |
| tree | cddcc3e030137a8f1fd5e16a339b31f34fade1bd /core/java/android | |
| parent | 33fc64360adfbf03f4b069b00ad76f15ced71d45 (diff) | |
| parent | d750a7c68c2381ff26e325689d4d2813ee81e361 (diff) | |
Merge "Show a warning toast/dialog when an app uses hidden APIs" am: fbef950d95
am: d750a7c68c
Change-Id: I9b62537d76e4ceb7ce03ca4de5ccf5a182c4439c
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/app/Activity.java | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index b21bcbcb13ef..bf4e1ded2a45 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -126,6 +126,8 @@ import com.android.internal.app.WindowDecorActionBar; import com.android.internal.policy.DecorView; import com.android.internal.policy.PhoneWindow; +import dalvik.system.VMRuntime; + import java.io.FileDescriptor; import java.io.PrintWriter; import java.lang.annotation.Retention; @@ -7035,11 +7037,12 @@ public class Activity extends ContextThemeWrapper mFragments.dispatchStart(); mFragments.reportLoaderStart(); - // This property is set for all builds except final release - boolean isDlwarningEnabled = SystemProperties.getInt("ro.bionic.ld.warning", 0) == 1; boolean isAppDebuggable = (mApplication.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; + // This property is set for all builds except final release + boolean isDlwarningEnabled = SystemProperties.getInt("ro.bionic.ld.warning", 0) == 1; + if (isAppDebuggable || isDlwarningEnabled) { String dlwarning = getDlWarning(); if (dlwarning != null) { @@ -7060,6 +7063,28 @@ public class Activity extends ContextThemeWrapper } } + // We might disable this for final builds. + boolean isApiWarningEnabled = true; + + if (isAppDebuggable || isApiWarningEnabled) { + if (VMRuntime.getRuntime().hasUsedHiddenApi()) { + String appName = getApplicationInfo().loadLabel(getPackageManager()) + .toString(); + String warning = "Detected problems with API compatiblity\n" + + "(please consult log for detail)"; + if (isAppDebuggable) { + new AlertDialog.Builder(this) + .setTitle(appName) + .setMessage(warning) + .setPositiveButton(android.R.string.ok, null) + .setCancelable(false) + .show(); + } else { + Toast.makeText(this, appName + "\n" + warning, Toast.LENGTH_LONG).show(); + } + } + } + mActivityTransitionState.enterReady(this); } |
