Adding broadcasts receiver flags.

Adding flags to a few files such that they specify if their unprotected
broadcasts are exported or nto exported. Marking a receiver as exported
is a no-op, and will maintain current behavior. All permission protected
broadcasts should be marked as exported. Marking a receiver as not
exported will prevent other apps from sending that receiver broadcasts.
ACTION_CLOSE_SYSTEM_DIALOG is exported since it's deprecated in S+ and
is only used during testing, otherwise the system drops it anyways.

Test: no-op
Bug: 161145287
Change-Id: Ifbae5de03e6dbaa36b66299a830de077d0a688e2
This commit is contained in:
Jacob Hobbie
2021-10-25 12:49:08 -07:00
parent c27e4cdfa3
commit 22669f5b76
4 changed files with 6 additions and 4 deletions

View File

@@ -147,7 +147,8 @@ final class WifiDisplayAdapter extends DisplayAdapter {
getContext(), getHandler(), mWifiDisplayListener);
getContext().registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL,
new IntentFilter(ACTION_DISCONNECT), null, mHandler);
new IntentFilter(ACTION_DISCONNECT), null, mHandler,
Context.RECEIVER_NOT_EXPORTED);
}
});
}

View File

@@ -138,7 +138,8 @@ class LegacyGlobalActions implements DialogInterface.OnDismissListener, DialogIn
// By default CLOSE_SYSTEM_DIALOGS broadcast is sent only for current user, which is user
// 10 on devices with headless system user enabled.
// In order to receive the broadcast, register the broadcast receiver with UserHandle.ALL.
context.registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, filter, null, null);
context.registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, filter, null, null,
Context.RECEIVER_EXPORTED);
mHasTelephony =
context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY);

View File

@@ -213,7 +213,7 @@ public final class ShutdownThread extends Thread {
CloseDialogReceiver(Context context) {
mContext = context;
IntentFilter filter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
context.registerReceiver(this, filter);
context.registerReceiver(this, filter, Context.RECEIVER_EXPORTED);
}
@Override

View File

@@ -177,7 +177,7 @@ class Vr2dDisplay {
}
}
}
}, intentFilter);
}, intentFilter, Context.RECEIVER_NOT_EXPORTED);
}
}