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

Commit a819a965 authored by Emma James's avatar Emma James Committed by Android Build Coastguard Worker
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
(cherry picked from commit e9671aff)
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:014bfed1befc6e3a659b178f376d2ed5f8174d97
Merged-In: I523c01bddf4f8b084c1f102dab2d8aca26222ec3
Change-Id: I523c01bddf4f8b084c1f102dab2d8aca26222ec3
parent c8391347
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -145,6 +145,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;

@@ -1106,10 +1114,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)