Show toast to warn user when the call is treated as personal call
BUG:26579183
Change-Id: Ic6b681335f1868a9ce95b0cfa61e5471be048a14
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 42fb5b4..a85faf0 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -158,4 +158,6 @@
<!-- DO NOT TRANSLATE. Hardcoded number used for restricted incoming phone numbers. -->
<string name="handle_restricted">RESTRICTED</string>
+
+ <string name="toast_personal_call_msg">Using the personal dialer to make the call</string>
</resources>
diff --git a/src/com/android/server/telecom/CallIntentProcessor.java b/src/com/android/server/telecom/CallIntentProcessor.java
index 2172a81..3a327c8 100644
--- a/src/com/android/server/telecom/CallIntentProcessor.java
+++ b/src/com/android/server/telecom/CallIntentProcessor.java
@@ -125,7 +125,12 @@
final boolean isPrivilegedDialer = intent.getBooleanExtra(KEY_IS_PRIVILEGED_DIALER, false);
- fixInitiatingUserIfNecessary(context, intent);
+ boolean fixedInitiatingUser = fixInitiatingUserIfNecessary(context, intent);
+ // Show the toast to warn user that it is a personal call though initiated in work profile.
+ if (fixedInitiatingUser) {
+ Toast.makeText(context, R.string.toast_personal_call_msg, Toast.LENGTH_LONG).show();
+ }
+
UserHandle initiatingUser = intent.getParcelableExtra(KEY_INITIATING_USER);
// Send to CallsManager to ensure the InCallUI gets kicked off before the broadcast returns
@@ -153,8 +158,10 @@
/**
* If the call is initiated from managed profile but there is no work dialer installed, treat
* the call is initiated from its parent user.
+ *
+ * @return whether the initiating user is fixed.
*/
- static void fixInitiatingUserIfNecessary(Context context, Intent intent) {
+ static boolean fixInitiatingUserIfNecessary(Context context, Intent intent) {
final UserHandle initiatingUser = intent.getParcelableExtra(KEY_INITIATING_USER);
if (UserUtil.isManagedProfile(context, initiatingUser)) {
boolean noDialerInstalled = DefaultDialerManager.getInstalledDialerApplications(context,
@@ -165,8 +172,10 @@
userManager.getProfileParent(
initiatingUser.getIdentifier()).getUserHandle();
intent.putExtra(KEY_INITIATING_USER, parentUserHandle);
+ return true;
}
}
+ return false;
}
static void processIncomingCallIntent(CallsManager callsManager, Intent intent) {