Loading api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -454,6 +454,7 @@ package android.app { public class BroadcastOptions { method public static android.app.BroadcastOptions makeBasic(); method @RequiresPermission("android.permission.START_ACTIVITIES_FROM_BACKGROUND") public void setAllowBackgroundActivityStarts(boolean); method public void setDontSendToRestrictedApps(boolean); method @RequiresPermission(android.Manifest.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST) public void setTemporaryAppWhitelistDuration(long); method public android.os.Bundle toBundle(); Loading core/java/android/app/BroadcastOptions.java +30 −1 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ public class BroadcastOptions { private int mMinManifestReceiverApiLevel = 0; private int mMaxManifestReceiverApiLevel = Build.VERSION_CODES.CUR_DEVELOPMENT; private boolean mDontSendToRestrictedApps = false; private boolean mAllowBackgroundActivityStarts; /** * How long to temporarily put an app on the power whitelist when executing this broadcast Loading @@ -54,11 +55,17 @@ public class BroadcastOptions { = "android:broadcast.maxManifestReceiverApiLevel"; /** * Corresponds to {@link #setMaxManifestReceiverApiLevel}. * Corresponds to {@link #setDontSendToRestrictedApps}. */ static final String KEY_DONT_SEND_TO_RESTRICTED_APPS = "android:broadcast.dontSendToRestrictedApps"; /** * Corresponds to {@link #setAllowBackgroundActivityStarts}. */ static final String KEY_ALLOW_BACKGROUND_ACTIVITY_STARTS = "android:broadcast.allowBackgroundActivityStarts"; public static BroadcastOptions makeBasic() { BroadcastOptions opts = new BroadcastOptions(); return opts; Loading @@ -74,6 +81,8 @@ public class BroadcastOptions { mMaxManifestReceiverApiLevel = opts.getInt(KEY_MAX_MANIFEST_RECEIVER_API_LEVEL, Build.VERSION_CODES.CUR_DEVELOPMENT); mDontSendToRestrictedApps = opts.getBoolean(KEY_DONT_SEND_TO_RESTRICTED_APPS, false); mAllowBackgroundActivityStarts = opts.getBoolean(KEY_ALLOW_BACKGROUND_ACTIVITY_STARTS, false); } /** Loading Loading @@ -147,6 +156,23 @@ public class BroadcastOptions { return mDontSendToRestrictedApps; } /** * Sets the process will be able to start activities from background for the duration of * the broadcast dispatch. Default value is {@code false} */ @RequiresPermission(android.Manifest.permission.START_ACTIVITIES_FROM_BACKGROUND) public void setAllowBackgroundActivityStarts(boolean allowBackgroundActivityStarts) { mAllowBackgroundActivityStarts = allowBackgroundActivityStarts; } /** * @hide * @return #setAllowBackgroundActivityStarts */ public boolean allowsBackgroundActivityStarts() { return mAllowBackgroundActivityStarts; } /** * Returns the created options as a Bundle, which can be passed to * {@link android.content.Context#sendBroadcast(android.content.Intent) Loading @@ -169,6 +195,9 @@ public class BroadcastOptions { if (mDontSendToRestrictedApps) { b.putBoolean(KEY_DONT_SEND_TO_RESTRICTED_APPS, true); } if (mAllowBackgroundActivityStarts) { b.putBoolean(KEY_ALLOW_BACKGROUND_ACTIVITY_STARTS, true); } return b.isEmpty() ? null : b; } } services/core/java/com/android/server/am/ActivityManagerService.java +19 −0 Original line number Diff line number Diff line Loading @@ -14455,6 +14455,25 @@ public class ActivityManagerService extends IActivityManager.Stub + " has background restrictions"); return ActivityManager.START_CANCELED; } if (brOptions.allowsBackgroundActivityStarts()) { // See if the caller is allowed to do this. Note we are checking against // the actual real caller (not whoever provided the operation as say a // PendingIntent), because that who is actually supplied the arguments. if (checkComponentPermission( android.Manifest.permission.START_ACTIVITIES_FROM_BACKGROUND, realCallingPid, realCallingUid, -1, true) != PackageManager.PERMISSION_GRANTED) { String msg = "Permission Denial: " + intent.getAction() + " broadcast from " + callerPackage + " (pid=" + callingPid + ", uid=" + callingUid + ")" + " requires " + android.Manifest.permission.START_ACTIVITIES_FROM_BACKGROUND; Slog.w(TAG, msg); throw new SecurityException(msg); } else { allowBackgroundActivityStarts = true; } } } // Verify that protected broadcasts are only being sent by system code, Loading
api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -454,6 +454,7 @@ package android.app { public class BroadcastOptions { method public static android.app.BroadcastOptions makeBasic(); method @RequiresPermission("android.permission.START_ACTIVITIES_FROM_BACKGROUND") public void setAllowBackgroundActivityStarts(boolean); method public void setDontSendToRestrictedApps(boolean); method @RequiresPermission(android.Manifest.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST) public void setTemporaryAppWhitelistDuration(long); method public android.os.Bundle toBundle(); Loading
core/java/android/app/BroadcastOptions.java +30 −1 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ public class BroadcastOptions { private int mMinManifestReceiverApiLevel = 0; private int mMaxManifestReceiverApiLevel = Build.VERSION_CODES.CUR_DEVELOPMENT; private boolean mDontSendToRestrictedApps = false; private boolean mAllowBackgroundActivityStarts; /** * How long to temporarily put an app on the power whitelist when executing this broadcast Loading @@ -54,11 +55,17 @@ public class BroadcastOptions { = "android:broadcast.maxManifestReceiverApiLevel"; /** * Corresponds to {@link #setMaxManifestReceiverApiLevel}. * Corresponds to {@link #setDontSendToRestrictedApps}. */ static final String KEY_DONT_SEND_TO_RESTRICTED_APPS = "android:broadcast.dontSendToRestrictedApps"; /** * Corresponds to {@link #setAllowBackgroundActivityStarts}. */ static final String KEY_ALLOW_BACKGROUND_ACTIVITY_STARTS = "android:broadcast.allowBackgroundActivityStarts"; public static BroadcastOptions makeBasic() { BroadcastOptions opts = new BroadcastOptions(); return opts; Loading @@ -74,6 +81,8 @@ public class BroadcastOptions { mMaxManifestReceiverApiLevel = opts.getInt(KEY_MAX_MANIFEST_RECEIVER_API_LEVEL, Build.VERSION_CODES.CUR_DEVELOPMENT); mDontSendToRestrictedApps = opts.getBoolean(KEY_DONT_SEND_TO_RESTRICTED_APPS, false); mAllowBackgroundActivityStarts = opts.getBoolean(KEY_ALLOW_BACKGROUND_ACTIVITY_STARTS, false); } /** Loading Loading @@ -147,6 +156,23 @@ public class BroadcastOptions { return mDontSendToRestrictedApps; } /** * Sets the process will be able to start activities from background for the duration of * the broadcast dispatch. Default value is {@code false} */ @RequiresPermission(android.Manifest.permission.START_ACTIVITIES_FROM_BACKGROUND) public void setAllowBackgroundActivityStarts(boolean allowBackgroundActivityStarts) { mAllowBackgroundActivityStarts = allowBackgroundActivityStarts; } /** * @hide * @return #setAllowBackgroundActivityStarts */ public boolean allowsBackgroundActivityStarts() { return mAllowBackgroundActivityStarts; } /** * Returns the created options as a Bundle, which can be passed to * {@link android.content.Context#sendBroadcast(android.content.Intent) Loading @@ -169,6 +195,9 @@ public class BroadcastOptions { if (mDontSendToRestrictedApps) { b.putBoolean(KEY_DONT_SEND_TO_RESTRICTED_APPS, true); } if (mAllowBackgroundActivityStarts) { b.putBoolean(KEY_ALLOW_BACKGROUND_ACTIVITY_STARTS, true); } return b.isEmpty() ? null : b; } }
services/core/java/com/android/server/am/ActivityManagerService.java +19 −0 Original line number Diff line number Diff line Loading @@ -14455,6 +14455,25 @@ public class ActivityManagerService extends IActivityManager.Stub + " has background restrictions"); return ActivityManager.START_CANCELED; } if (brOptions.allowsBackgroundActivityStarts()) { // See if the caller is allowed to do this. Note we are checking against // the actual real caller (not whoever provided the operation as say a // PendingIntent), because that who is actually supplied the arguments. if (checkComponentPermission( android.Manifest.permission.START_ACTIVITIES_FROM_BACKGROUND, realCallingPid, realCallingUid, -1, true) != PackageManager.PERMISSION_GRANTED) { String msg = "Permission Denial: " + intent.getAction() + " broadcast from " + callerPackage + " (pid=" + callingPid + ", uid=" + callingUid + ")" + " requires " + android.Manifest.permission.START_ACTIVITIES_FROM_BACKGROUND; Slog.w(TAG, msg); throw new SecurityException(msg); } else { allowBackgroundActivityStarts = true; } } } // Verify that protected broadcasts are only being sent by system code,