Mark framework created intent as safe
Flag intent created by framework as LOCAL_FLAG_FROM_PROTECTED_COMPONENT by
calling intent.prepareToEnterProcess(true...). This is to fix false positives
of StrictMode.unsafeIntentLaunchViolation.
Bug: 181132616
Test: Manually verified a violation was not reported when a test app launched
Intents returned from TelecomManager.createManageBlockedNumbersIntent.
Methods marked as systemApi are not tested.
Change-Id: I7b00008dd894f1c637ab2f0a23e6cafb58bb73e5
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java
index 9fcf44e..ccec67e 100644
--- a/telecomm/java/android/telecom/TelecomManager.java
+++ b/telecomm/java/android/telecom/TelecomManager.java
@@ -15,6 +15,7 @@
package android.telecom;
import static android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE;
+import static android.content.Intent.LOCAL_FLAG_FROM_SYSTEM;
import android.Manifest;
import android.annotation.IntDef;
@@ -2417,6 +2418,10 @@
if (service != null) {
try {
result = service.createManageBlockedNumbersIntent(mContext.getPackageName());
+ if (result != null) {
+ result.prepareToEnterProcess(LOCAL_FLAG_FROM_SYSTEM,
+ mContext.getAttributionSource());
+ }
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelecomService#createManageBlockedNumbersIntent", e);
}
@@ -2438,7 +2443,12 @@
ITelecomService service = getTelecomService();
if (service != null) {
try {
- return service.createLaunchEmergencyDialerIntent(number);
+ Intent result = service.createLaunchEmergencyDialerIntent(number);
+ if (result != null) {
+ result.prepareToEnterProcess(LOCAL_FLAG_FROM_SYSTEM,
+ mContext.getAttributionSource());
+ }
+ return result;
} catch (RemoteException e) {
Log.e(TAG, "Error createLaunchEmergencyDialerIntent", e);
}