summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorNate Myren <ntmyren@google.com>2022-02-17 17:51:38 -0800
committerNate Myren <ntmyren@google.com>2022-02-28 08:23:19 -0800
commiteb4e3d20da268a26cea68cb365ce7a26e384d351 (patch)
tree79fdc0f2b8a413b4af7a50e02a5a77120ae6adee /core/java/android
parent09076f0af2715438fd5ceeb052424f1ee0c936cf (diff)
Restrict what activity launches show permission prompts
Only show a permission prompt if the activity is a launcher, the calling app is the same as the opened intent app, or the isEligibleForLegacyPermissionPrompt ActivityOption is set. Also prevents the dialog from showing while the keyguard is locked. Test: atest NotificationPermissionTest Bug: 194833441 Fixes: 220891438 Change-Id: Ie5381af045d538a5b822bb1ccdf62b1dd916114f
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/ActivityOptions.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/core/java/android/app/ActivityOptions.java b/core/java/android/app/ActivityOptions.java
index 5ddaa80b1a82..1d14307e6294 100644
--- a/core/java/android/app/ActivityOptions.java
+++ b/core/java/android/app/ActivityOptions.java
@@ -174,6 +174,13 @@ public class ActivityOptions extends ComponentOptions {
public static final String KEY_SPLASH_SCREEN_THEME = "android.activity.splashScreenTheme";
/**
+ * Indicates that this activity launch is eligible to show a legacy permission prompt
+ * @hide
+ */
+ public static final String KEY_LEGACY_PERMISSION_PROMPT_ELIGIBLE =
+ "android:activity.legacyPermissionPromptEligible";
+
+ /**
* Callback for when the last frame of the animation is played.
* @hide
*/
@@ -445,6 +452,7 @@ public class ActivityOptions extends ComponentOptions {
private String mSplashScreenThemeResName;
@SplashScreen.SplashScreenStyle
private int mSplashScreenStyle = SplashScreen.SPLASH_SCREEN_STYLE_UNDEFINED;
+ private boolean mIsEligibleForLegacyPermissionPrompt;
private boolean mRemoveWithTaskOrganizer;
private boolean mLaunchedFromBubble;
private boolean mTransientLaunch;
@@ -1243,6 +1251,8 @@ public class ActivityOptions extends ComponentOptions {
mTransientLaunch = opts.getBoolean(KEY_TRANSIENT_LAUNCH);
mSplashScreenStyle = opts.getInt(KEY_SPLASH_SCREEN_STYLE);
mLaunchIntoPipParams = opts.getParcelable(KEY_LAUNCH_INTO_PIP_PARAMS);
+ mIsEligibleForLegacyPermissionPrompt =
+ opts.getBoolean(KEY_LEGACY_PERMISSION_PROMPT_ELIGIBLE);
}
/**
@@ -1474,6 +1484,24 @@ public class ActivityOptions extends ComponentOptions {
}
/**
+ * Whether the activity is eligible to show a legacy permission prompt
+ * @hide
+ */
+ @TestApi
+ public boolean isEligibleForLegacyPermissionPrompt() {
+ return mIsEligibleForLegacyPermissionPrompt;
+ }
+
+ /**
+ * Sets whether the activity is eligible to show a legacy permission prompt
+ * @hide
+ */
+ @TestApi
+ public void setEligibleForLegacyPermissionPrompt(boolean eligible) {
+ mIsEligibleForLegacyPermissionPrompt = eligible;
+ }
+
+ /**
* Sets whether the activity is to be launched into LockTask mode.
*
* Use this option to start an activity in LockTask mode. Note that only apps permitted by
@@ -1909,6 +1937,7 @@ public class ActivityOptions extends ComponentOptions {
mSpecsFuture = otherOptions.mSpecsFuture;
mRemoteAnimationAdapter = otherOptions.mRemoteAnimationAdapter;
mLaunchIntoPipParams = otherOptions.mLaunchIntoPipParams;
+ mIsEligibleForLegacyPermissionPrompt = otherOptions.mIsEligibleForLegacyPermissionPrompt;
}
/**
@@ -2084,6 +2113,10 @@ public class ActivityOptions extends ComponentOptions {
if (mLaunchIntoPipParams != null) {
b.putParcelable(KEY_LAUNCH_INTO_PIP_PARAMS, mLaunchIntoPipParams);
}
+ if (mIsEligibleForLegacyPermissionPrompt) {
+ b.putBoolean(KEY_LEGACY_PERMISSION_PROMPT_ELIGIBLE,
+ mIsEligibleForLegacyPermissionPrompt);
+ }
return b;
}