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

Commit 89cb7171 authored by Zhong Dong's avatar Zhong Dong
Browse files

Disallow wear remote intent from background process

Bug: 319101158
Test: locally build and flash device
Change-Id: If441953151d9729c6d1b5e265647a93bb7a1414c
parent 05ec7771
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -6986,4 +6986,7 @@
    <!-- Whether WM DisplayContent supports high performance transitions
         (lower-end devices may want to disable) -->
    <bool name="config_deviceSupportsHighPerfTransitions">true</bool>

    <!-- Wear devices: An intent action that is used for remote intent. -->
    <string name="config_wearRemoteIntentAction" translatable="false" />
</resources>
+2 −0
Original line number Diff line number Diff line
@@ -5379,4 +5379,6 @@

  <!-- Whether WM DisplayContent supports high performance transitions -->
  <java-symbol type="bool" name="config_deviceSupportsHighPerfTransitions" />

  <java-symbol type="string" name="config_wearRemoteIntentAction" />
</resources>
+17 −0
Original line number Diff line number Diff line
@@ -2656,6 +2656,11 @@ public class ActivityManagerService extends IActivityManager.Stub
        return mBackgroundLaunchBroadcasts;
    }
    private String getWearRemoteIntentAction() {
        return mContext.getResources().getString(
                    com.android.internal.R.string.config_wearRemoteIntentAction);
    }
    /**
     * Ensures that the given package name has an explicit set of allowed associations.
     * If it does not, give it an empty set.
@@ -15213,6 +15218,18 @@ public class ActivityManagerService extends IActivityManager.Stub
                intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
            }
            // TODO: b/329211459 - Remove this after background remote intent is fixed.
            if (mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH)
                    && getWearRemoteIntentAction().equals(action)) {
                final int callerProcState = callerApp != null
                        ? callerApp.getCurProcState()
                        : ActivityManager.PROCESS_STATE_NONEXISTENT;
                if (ActivityManager.RunningAppProcessInfo.procStateToImportance(callerProcState)
                        > ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
                    return ActivityManager.START_CANCELED;
                }
            }
            switch (action) {
                case Intent.ACTION_MEDIA_SCANNER_SCAN_FILE:
                    UserManagerInternal umInternal = LocalServices.getService(