Loading core/java/android/app/BroadcastOptions.java +35 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ public class BroadcastOptions extends ComponentOptions { private @Nullable IntentFilter mDeliveryGroupMatchingFilter; private @DeferralPolicy int mDeferralPolicy; private @Nullable String[] mIncludedPackages; private @Nullable String mDebugReason; /** @hide */ @IntDef(flag = true, prefix = { "FLAG_" }, value = { Loading Loading @@ -239,6 +240,11 @@ public class BroadcastOptions extends ComponentOptions { private static final String KEY_INCLUDED_PACKAGES = "android:broadcast.includedPackageNames"; /** * Corresponds to {@link #setDebugReason(String)} */ private static final String KEY_DEBUG_REASON = "android:broadcast.debugReason"; /** * The list of delivery group policies which specify how multiple broadcasts belonging to * the same delivery group has to be handled. Loading Loading @@ -365,6 +371,7 @@ public class BroadcastOptions extends ComponentOptions { IntentFilter.class); mDeferralPolicy = opts.getInt(KEY_DEFERRAL_POLICY, DEFERRAL_POLICY_DEFAULT); mIncludedPackages = opts.getStringArray(KEY_INCLUDED_PACKAGES); mDebugReason = opts.getString(KEY_DEBUG_REASON); } /** @hide */ Loading Loading @@ -1143,6 +1150,31 @@ public class BroadcastOptions extends ComponentOptions { return mIncludedPackages; } /** * Set the reason for triggering the broadcast. This is meant to be used for * debugging and logging purposes. * * <p> This will only take effect when used by core uids, as determined by * {@link UserHandle#isCore(int)}. * * @hide */ public BroadcastOptions setDebugReason(@Nullable String debugReason) { mDebugReason = debugReason; return this; } /** * Get the reason for triggering the broadcast, that was previously set using * {@link #setDebugReason(String)}. * * @hide */ @Nullable public String getDebugReason() { return mDebugReason; } /** * Returns the created options as a Bundle, which can be passed to * {@link android.content.Context#sendBroadcast(android.content.Intent) Loading Loading @@ -1212,6 +1244,9 @@ public class BroadcastOptions extends ComponentOptions { if (!ArrayUtils.isEmpty(mIncludedPackages)) { b.putStringArray(KEY_INCLUDED_PACKAGES, mIncludedPackages); } if (mDebugReason != null) { b.putString(KEY_DEBUG_REASON, mDebugReason); } return b; } Loading services/core/java/com/android/server/am/BroadcastController.java +4 −0 Original line number Diff line number Diff line Loading @@ -1032,6 +1032,10 @@ class BroadcastController { brOptions.setDebugLogEnabled(false); } } if (!UserHandle.isCore(callingUid)) { brOptions.setDebugReason(null); } } // Verify that protected broadcasts are only being sent by system code, Loading Loading
core/java/android/app/BroadcastOptions.java +35 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ public class BroadcastOptions extends ComponentOptions { private @Nullable IntentFilter mDeliveryGroupMatchingFilter; private @DeferralPolicy int mDeferralPolicy; private @Nullable String[] mIncludedPackages; private @Nullable String mDebugReason; /** @hide */ @IntDef(flag = true, prefix = { "FLAG_" }, value = { Loading Loading @@ -239,6 +240,11 @@ public class BroadcastOptions extends ComponentOptions { private static final String KEY_INCLUDED_PACKAGES = "android:broadcast.includedPackageNames"; /** * Corresponds to {@link #setDebugReason(String)} */ private static final String KEY_DEBUG_REASON = "android:broadcast.debugReason"; /** * The list of delivery group policies which specify how multiple broadcasts belonging to * the same delivery group has to be handled. Loading Loading @@ -365,6 +371,7 @@ public class BroadcastOptions extends ComponentOptions { IntentFilter.class); mDeferralPolicy = opts.getInt(KEY_DEFERRAL_POLICY, DEFERRAL_POLICY_DEFAULT); mIncludedPackages = opts.getStringArray(KEY_INCLUDED_PACKAGES); mDebugReason = opts.getString(KEY_DEBUG_REASON); } /** @hide */ Loading Loading @@ -1143,6 +1150,31 @@ public class BroadcastOptions extends ComponentOptions { return mIncludedPackages; } /** * Set the reason for triggering the broadcast. This is meant to be used for * debugging and logging purposes. * * <p> This will only take effect when used by core uids, as determined by * {@link UserHandle#isCore(int)}. * * @hide */ public BroadcastOptions setDebugReason(@Nullable String debugReason) { mDebugReason = debugReason; return this; } /** * Get the reason for triggering the broadcast, that was previously set using * {@link #setDebugReason(String)}. * * @hide */ @Nullable public String getDebugReason() { return mDebugReason; } /** * Returns the created options as a Bundle, which can be passed to * {@link android.content.Context#sendBroadcast(android.content.Intent) Loading Loading @@ -1212,6 +1244,9 @@ public class BroadcastOptions extends ComponentOptions { if (!ArrayUtils.isEmpty(mIncludedPackages)) { b.putStringArray(KEY_INCLUDED_PACKAGES, mIncludedPackages); } if (mDebugReason != null) { b.putString(KEY_DEBUG_REASON, mDebugReason); } return b; } Loading
services/core/java/com/android/server/am/BroadcastController.java +4 −0 Original line number Diff line number Diff line Loading @@ -1032,6 +1032,10 @@ class BroadcastController { brOptions.setDebugLogEnabled(false); } } if (!UserHandle.isCore(callingUid)) { brOptions.setDebugReason(null); } } // Verify that protected broadcasts are only being sent by system code, Loading