From 297676117569ba86b4c829724ae350db41e4e479 Mon Sep 17 00:00:00 2001 From: Michael Groover Date: Tue, 8 Nov 2022 16:39:58 -0600 Subject: [PATCH] Remove isInstrumenting workaround from receiver flag enforcement Android T added support to register a runtime receiver with a flag indicating the receiver should not be accessible to other apps on the device. To ensure developers could take advantage of this new flag, receivers registering for non-system broadcasts and targeting T+ were required to specify a flag indicating the exported state of the receiver. While flags were being updated in the platform, an isInstrumenting check was added that automatically flagged receivers as exported if they were under instrumentation. This was intended to allow additional time for these receivers to be flagged, but this workaround caused issues to be missed with WebView and potentially other components. Enforcement of this flag was punted from T and is now in plan for U, but before enforcement is enabled, this commit will remove the isInstrumenting workaround to ensure tests run with the same behavior as the platform and any potential issues can be caught earlier in the cycle. Bug: 234659204 Test: atest CtsWebkitTestCases Change-Id: Id24e15f951901b4d998f8301950d49bad53ca278 --- core/java/android/app/ContextImpl.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index 10cdf5315b556..042bdd7e2ed57 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -1814,12 +1814,6 @@ class ContextImpl extends Context { } } try { - ActivityThread thread = ActivityThread.currentActivityThread(); - Instrumentation instrumentation = thread.getInstrumentation(); - if (instrumentation.isInstrumenting() - && ((flags & Context.RECEIVER_NOT_EXPORTED) == 0)) { - flags = flags | Context.RECEIVER_EXPORTED; - } final Intent intent = ActivityManager.getService().registerReceiverWithFeature( mMainThread.getApplicationThread(), mBasePackageName, getAttributionTag(), AppOpsManager.toReceiverId(receiver), rd, filter, broadcastPermission, userId,