Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e9671aff authored by Emma James's avatar Emma James
Browse files

Use target sdk for background check on Wear remote intents.

Update the Wear remote intent background check to only be enforced from
Android B target sdk.

We cannot break developers who are currently relying on this behaviour
without proper notice and guidance on how to update their apps.

Flag: EXEMPT bugfix
Bug: 419106561, 319101158
Test: locally build and flash device, tested KakaoTalk open on phone on Wear
Change-Id: I523c01bddf4f8b084c1f102dab2d8aca26222ec3
parent 9abc6419
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -148,6 +148,14 @@ class BroadcastController {
    @EnabledSince(targetSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
    private static final long DYNAMIC_RECEIVER_EXPLICIT_EXPORT_REQUIRED = 161145287L;

    /**
     * It is now required for apps to be in the foreground to send remote intent broadcasts on Wear
     * devices.
     */
    @ChangeId
    @EnabledSince(targetSdkVersion = Build.VERSION_CODES.BAKLAVA)
    private static final long WEAR_REMOTE_INTENT_BLOCKED_IN_BACKGROUND = 419106561L;

    // Maximum number of receivers an app can register.
    private static final int MAX_RECEIVERS_ALLOWED_PER_APP = 1000;

@@ -1088,10 +1096,14 @@ class BroadcastController {
                intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
            }

            // TODO: b/329211459 - Remove this after background remote intent is fixed.
            // TODO: b/329211459 - Remove this when the remote intent broadcast receiver is removed
            // from Wear.
            if (mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH)
                    && getWearRemoteIntentAction().equals(action)) {
                final int callerProcState = callerApp != null
                    && getWearRemoteIntentAction().equals(action)
                    && CompatChanges.isChangeEnabled(
                            WEAR_REMOTE_INTENT_BLOCKED_IN_BACKGROUND, callingUid)) {
                final int callerProcState =
                        callerApp != null
                                ? callerApp.getCurProcState()
                                : ActivityManager.PROCESS_STATE_NONEXISTENT;
                if (ActivityManager.RunningAppProcessInfo.procStateToImportance(callerProcState)