Show mini-resolver for messages
If work profile is enabled, then show the mini-resolver UI instead
of the dialog. We keep the dialog for the case when the work profile
is turned off, or messages app is not installed.
Test: Manually tested
Test: btest CtsDevicePolicySimTestCases
Bug: 271819927
Change-Id: I50e6b5bb802734cc121e1f15527b8bcd4c562dfa
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 307411d..21862fb 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -39,6 +39,7 @@
import android.app.role.RoleManager;
import android.compat.annotation.ChangeId;
import android.compat.annotation.EnabledSince;
+import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
@@ -10220,11 +10221,21 @@
@Override
public void showSwitchToManagedProfileDialog() {
enforceModifyPermission();
-
- Intent intent = new Intent();
- intent.setClass(mApp, ErrorDialogActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- mApp.startActivity(intent);
+ try {
+ // Note: This intent is constructed to ensure that the IntentForwarderActivity is
+ // shown in accordance with the intent filters in DefaultCrossProfileIntentFilterUtils
+ // for work telephony.
+ Intent intent = new Intent(Intent.ACTION_SENDTO);
+ intent.setData(Uri.parse("smsto:"));
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ mApp.startActivity(intent);
+ } catch (ActivityNotFoundException e) {
+ Log.w(LOG_TAG, "Unable to show intent forwarder, try showing error dialog instead");
+ Intent intent = new Intent();
+ intent.setClass(mApp, ErrorDialogActivity.class);
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ mApp.startActivity(intent);
+ }
}
@Override