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

Commit 0d9f847f authored by Michael Groover's avatar Michael Groover
Browse files

Add unaudited exported flag to exposed runtime receivers

Android T allows apps to declare a runtime receiver as not exported
by invoking registerReceiver with a new RECEIVER_NOT_EXPORTED flag;
receivers registered with this flag will only receive broadcasts from
the platform and the app itself. However to ensure developers can
properly protect their receivers, all apps targeting U or later
registering a receiver for non-system broadcasts must specify either
the exported or not exported flag when invoking #registerReceiver;
if one of these flags is not provided, the platform will throw a
SecurityException. This commit updates all the exposed receivers
with a new RECEIVER_EXPORTED_UNAUDITED flag to maintain the existing
behavior of exporting the receiver while also flagging the receiver
for audit before the U release.

Bug: 234659204
Test: Build
Change-Id: I2b6962ece6410a4e86a22732d181a38302659b9e
parent a0667ba5
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -36,7 +36,8 @@ public class LocalReceiver extends BroadcastReceiver {
        if (BroadcastTest.BROADCAST_FAIL_REGISTER.equals(intent.getAction())) {
            resultString = "Successfully registered, but expected it to fail";
            try {
                context.registerReceiver(this, new IntentFilter("foo.bar"));
                context.registerReceiver(this, new IntentFilter("foo.bar"),
                        Context.RECEIVER_EXPORTED_UNAUDITED);
                context.unregisterReceiver(this);
            } catch (ReceiverCallNotAllowedException e) {
                //resultString = "This is the correct behavior but not yet implemented";
+1 −1
Original line number Diff line number Diff line
@@ -172,7 +172,7 @@ public class ServiceTest extends TestCase {
                pidResult.complete(intent.getIntExtra(EXTRA_PID, NOT_STARTED));
                mContext.unregisterReceiver(this);
            }
        }, new IntentFilter(ACTION_SERVICE_STARTED));
        }, new IntentFilter(ACTION_SERVICE_STARTED), Context.RECEIVER_EXPORTED_UNAUDITED);

        serviceTrigger.run();
        try {
+1 −1
Original line number Diff line number Diff line
@@ -692,7 +692,7 @@ public class BubbleController implements ConfigurationChangeListener {
        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
        filter.addAction(Intent.ACTION_SCREEN_OFF);
        mContext.registerReceiver(mBroadcastReceiver, filter);
        mContext.registerReceiver(mBroadcastReceiver, filter, Context.RECEIVER_EXPORTED_UNAUDITED);
    }

    private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
+2 −1
Original line number Diff line number Diff line
@@ -78,7 +78,8 @@ public class SafetyController implements
        synchronized (mListeners) {
            mListeners.add(listener);
            if (mListeners.size() == 1) {
                mContext.registerReceiver(mPermControllerChangeReceiver, PKG_CHANGE_INTENT_FILTER);
                mContext.registerReceiver(mPermControllerChangeReceiver, PKG_CHANGE_INTENT_FILTER,
                        Context.RECEIVER_EXPORTED_UNAUDITED);
                mBgHandler.post(() -> {
                    mSafetyCenterEnabled = mSafetyCenterManager.isSafetyCenterEnabled();
                    listener.onSafetyCenterEnableChanged(isSafetyCenterEnabled());