From 5e0eecc064fe605ce5804325709715568eda681f Mon Sep 17 00:00:00 2001 From: Michael Groover Date: Tue, 4 Oct 2022 17:15:36 -0500 Subject: [PATCH] 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: I6660cfb00244470edfb2411dadfca81afed42343 --- .../com/android/quickstep/OverviewComponentObserver.java | 5 +++-- .../com/android/launcher3/ui/AbstractLauncherUiTest.java | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/quickstep/OverviewComponentObserver.java b/quickstep/src/com/android/quickstep/OverviewComponentObserver.java index 9e3173c1f0..cfd6cbf567 100644 --- a/quickstep/src/com/android/quickstep/OverviewComponentObserver.java +++ b/quickstep/src/com/android/quickstep/OverviewComponentObserver.java @@ -100,7 +100,8 @@ public final class OverviewComponentObserver { } catch (PackageManager.NameNotFoundException ignored) { /* Impossible */ } mContext.registerReceiver(mUserPreferenceChangeReceiver, - new IntentFilter(ACTION_PREFERRED_ACTIVITY_CHANGED)); + new IntentFilter(ACTION_PREFERRED_ACTIVITY_CHANGED), + Context.RECEIVER_EXPORTED/*UNAUDITED*/); updateOverviewTargets(); } @@ -180,7 +181,7 @@ public final class OverviewComponentObserver { mUpdateRegisteredPackage = defaultHome.getPackageName(); mContext.registerReceiver(mOtherHomeAppUpdateReceiver, getPackageFilter( mUpdateRegisteredPackage, ACTION_PACKAGE_ADDED, ACTION_PACKAGE_CHANGED, - ACTION_PACKAGE_REMOVED)); + ACTION_PACKAGE_REMOVED), Context.RECEIVER_EXPORTED/*UNAUDITED*/); } } mOverviewChangeListener.accept(mIsHomeAndOverviewSame); diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java index a66b09a87d..36d670f2d8 100644 --- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java @@ -202,7 +202,8 @@ public abstract class AbstractLauncherUiTest { }; mTargetContext.registerReceiver(broadcastReceiver, PackageManagerHelper.getPackageFilter(pkg, - Intent.ACTION_PACKAGE_RESTARTED, Intent.ACTION_PACKAGE_DATA_CLEARED)); + Intent.ACTION_PACKAGE_RESTARTED, Intent.ACTION_PACKAGE_DATA_CLEARED), + Context.RECEIVER_EXPORTED/*UNAUDITED*/); mDevice.executeShellCommand("pm clear " + pkg); assertTrue(pkg + " didn't restart", count.await(10, TimeUnit.SECONDS)); @@ -437,7 +438,8 @@ public abstract class AbstractLauncherUiTest { private Intent mIntent; public BlockingBroadcastReceiver(String action) { - mTargetContext.registerReceiver(this, new IntentFilter(action)); + mTargetContext.registerReceiver(this, new IntentFilter(action), + Context.RECEIVER_EXPORTED/*UNAUDITED*/); } @Override