Merge "Use mini-resolver instead of alert dialog for dialer work telephony" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
096bfe59f8
@@ -1864,9 +1864,54 @@ public final class DevicePolicyResources {
|
|||||||
public static final String WORK_PROFILE_TELEPHONY_PAUSED_TURN_ON_BUTTON =
|
public static final String WORK_PROFILE_TELEPHONY_PAUSED_TURN_ON_BUTTON =
|
||||||
PREFIX + "TURN_ON_WORK_PROFILE_BUTTON_TEXT";
|
PREFIX + "TURN_ON_WORK_PROFILE_BUTTON_TEXT";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Information section shown on a dialog when the user is unable to place a call in
|
||||||
|
* the personal profile due to admin restrictions, and must choose whether to place
|
||||||
|
* the call from the work profile or cancel.
|
||||||
|
*/
|
||||||
|
public static final String MINIRESOLVER_WORK_TELEPHONY_CALL_BLOCKED_INFORMATION =
|
||||||
|
PREFIX + "MINIRESOLVER_WORK_TELEPHONY_INFORMATION";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Information section shown on a dialog when the user is unable to send a text in
|
||||||
|
* the personal profile due to admin restrictions, and must choose whether to place
|
||||||
|
* the call from the work profile or cancel.
|
||||||
|
*/
|
||||||
|
public static final String MINIRESOLVER_WORK_TELEPHONY_TEXT_BLOCKED_INFORMATION =
|
||||||
|
PREFIX + "MINIRESOLVER_WORK_TELEPHONY_INFORMATION";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Button for a dialog shown when the user is unable to place a call in the personal
|
||||||
|
* profile due to admin restrictions, and must choose whether to place the call from
|
||||||
|
* the work profile or cancel.
|
||||||
|
*/
|
||||||
|
public static final String MINIRESOLVER_CALL_FROM_WORK =
|
||||||
|
PREFIX + "MINIRESOLVER_CALL_FROM_WORK";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Button for a dialog shown when the user has no apps capable of handling an intent
|
||||||
|
* in the personal profile, and must choose whether to open the intent in a
|
||||||
|
* cross-profile app in the work profile, or cancel.
|
||||||
|
*/
|
||||||
|
public static final String MINIRESOLVER_SWITCH_TO_WORK =
|
||||||
|
PREFIX + "MINIRESOLVER_SWITCH_TO_WORK";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Title for a dialog shown when the user has no apps capable of handling an intent
|
||||||
|
* in the personal profile, and must choose whether to open the intent in a
|
||||||
|
* cross-profile app in the work profile, or open in the same profile browser. Accepts
|
||||||
|
* the app name as a param.
|
||||||
|
*/
|
||||||
public static final String MINIRESOLVER_OPEN_IN_WORK =
|
public static final String MINIRESOLVER_OPEN_IN_WORK =
|
||||||
PREFIX + "MINIRESOLVER_OPEN_IN_WORK";
|
PREFIX + "MINIRESOLVER_OPEN_IN_WORK";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Title for a dialog shown when the user has no apps capable of handling an intent
|
||||||
|
* in the personal profile, and must choose whether to open the intent in a
|
||||||
|
* cross-profile app in the personal profile, or open in the same profile browser.
|
||||||
|
* Accepts the app name as a param.
|
||||||
|
*/
|
||||||
public static final String MINIRESOLVER_OPEN_IN_PERSONAL =
|
public static final String MINIRESOLVER_OPEN_IN_PERSONAL =
|
||||||
PREFIX + "MINIRESOLVER_OPEN_IN_PERSONAL";
|
PREFIX + "MINIRESOLVER_OPEN_IN_PERSONAL";
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,11 @@ package com.android.internal.app;
|
|||||||
import static android.Manifest.permission.INTERACT_ACROSS_USERS;
|
import static android.Manifest.permission.INTERACT_ACROSS_USERS;
|
||||||
import static android.app.admin.DevicePolicyResources.Strings.Core.FORWARD_INTENT_TO_PERSONAL;
|
import static android.app.admin.DevicePolicyResources.Strings.Core.FORWARD_INTENT_TO_PERSONAL;
|
||||||
import static android.app.admin.DevicePolicyResources.Strings.Core.FORWARD_INTENT_TO_WORK;
|
import static android.app.admin.DevicePolicyResources.Strings.Core.FORWARD_INTENT_TO_WORK;
|
||||||
|
import static android.app.admin.DevicePolicyResources.Strings.Core.MINIRESOLVER_CALL_FROM_WORK;
|
||||||
import static android.app.admin.DevicePolicyResources.Strings.Core.MINIRESOLVER_OPEN_WORK;
|
import static android.app.admin.DevicePolicyResources.Strings.Core.MINIRESOLVER_OPEN_WORK;
|
||||||
|
import static android.app.admin.DevicePolicyResources.Strings.Core.MINIRESOLVER_SWITCH_TO_WORK;
|
||||||
|
import static android.app.admin.DevicePolicyResources.Strings.Core.MINIRESOLVER_WORK_TELEPHONY_CALL_BLOCKED_INFORMATION;
|
||||||
|
import static android.app.admin.DevicePolicyResources.Strings.Core.MINIRESOLVER_WORK_TELEPHONY_TEXT_BLOCKED_INFORMATION;
|
||||||
import static android.content.pm.PackageManager.MATCH_DEFAULT_ONLY;
|
import static android.content.pm.PackageManager.MATCH_DEFAULT_ONLY;
|
||||||
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
||||||
|
|
||||||
@@ -32,6 +36,7 @@ import android.app.Activity;
|
|||||||
import android.app.ActivityThread;
|
import android.app.ActivityThread;
|
||||||
import android.app.AppGlobals;
|
import android.app.AppGlobals;
|
||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
|
import android.app.admin.ManagedSubscriptionsPolicy;
|
||||||
import android.compat.annotation.UnsupportedAppUsage;
|
import android.compat.annotation.UnsupportedAppUsage;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
@@ -41,6 +46,7 @@ import android.content.pm.IPackageManager;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.metrics.LogMaker;
|
import android.metrics.LogMaker;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -48,6 +54,7 @@ import android.os.RemoteException;
|
|||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.telecom.TelecomManager;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
@@ -203,35 +210,116 @@ public class IntentForwarderActivity extends Activity {
|
|||||||
|
|
||||||
findViewById(R.id.title_container).setElevation(0);
|
findViewById(R.id.title_container).setElevation(0);
|
||||||
|
|
||||||
ImageView icon = findViewById(R.id.icon);
|
|
||||||
PackageManager packageManagerForTargetUser =
|
PackageManager packageManagerForTargetUser =
|
||||||
createContextAsUser(UserHandle.of(targetUserId), /* flags= */ 0)
|
createContextAsUser(UserHandle.of(targetUserId), /* flags= */ 0)
|
||||||
.getPackageManager();
|
.getPackageManager();
|
||||||
icon.setImageDrawable(target.loadIcon(packageManagerForTargetUser));
|
|
||||||
|
ImageView icon = findViewById(R.id.icon);
|
||||||
|
icon.setImageDrawable(
|
||||||
|
getAppIcon(target, launchIntent, targetUserId, packageManagerForTargetUser));
|
||||||
|
|
||||||
View buttonContainer = findViewById(R.id.button_bar_container);
|
View buttonContainer = findViewById(R.id.button_bar_container);
|
||||||
buttonContainer.setPadding(0, 0, 0, buttonContainer.getPaddingBottom());
|
buttonContainer.setPadding(0, 0, 0, buttonContainer.getPaddingBottom());
|
||||||
|
|
||||||
((TextView) findViewById(R.id.open_cross_profile)).setText(
|
((TextView) findViewById(R.id.open_cross_profile)).setText(
|
||||||
getOpenInWorkMessage(target.loadLabel(packageManagerForTargetUser)));
|
getOpenInWorkMessage(launchIntent, target.loadLabel(packageManagerForTargetUser)));
|
||||||
|
|
||||||
// The mini-resolver's negative button is reused in this flow to cancel the intent
|
// The mini-resolver's negative button is reused in this flow to cancel the intent
|
||||||
((Button) findViewById(R.id.use_same_profile_browser)).setText(R.string.cancel);
|
((Button) findViewById(R.id.use_same_profile_browser)).setText(R.string.cancel);
|
||||||
findViewById(R.id.use_same_profile_browser).setOnClickListener(v -> finish());
|
findViewById(R.id.use_same_profile_browser).setOnClickListener(v -> finish());
|
||||||
|
|
||||||
|
((Button) findViewById(R.id.button_open)).setText(getOpenInWorkButtonString(launchIntent));
|
||||||
findViewById(R.id.button_open).setOnClickListener(v -> {
|
findViewById(R.id.button_open).setOnClickListener(v -> {
|
||||||
startActivityAsCaller(launchIntent, targetUserId);
|
startActivityAsCaller(launchIntent, targetUserId);
|
||||||
finish();
|
finish();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
View telephonyInfo = findViewById(R.id.miniresolver_info_section);
|
||||||
|
DevicePolicyManager devicePolicyManager =
|
||||||
|
getSystemService(DevicePolicyManager.class);
|
||||||
|
// Additional information section is work telephony specific. Therefore, it is only shown
|
||||||
|
// for telephony related intents, when all sim subscriptions are in the work profile.
|
||||||
|
if ((isDialerIntent(launchIntent) || isTextMessageIntent(launchIntent))
|
||||||
|
&& devicePolicyManager.getManagedSubscriptionsPolicy().getPolicyType()
|
||||||
|
== ManagedSubscriptionsPolicy.TYPE_ALL_MANAGED_SUBSCRIPTIONS) {
|
||||||
|
telephonyInfo.setVisibility(View.VISIBLE);
|
||||||
|
((TextView) findViewById(R.id.miniresolver_info_section_text))
|
||||||
|
.setText(getWorkTelephonyInfoSectionMessage(launchIntent));
|
||||||
|
} else {
|
||||||
|
telephonyInfo.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getOpenInWorkMessage(CharSequence targetLabel) {
|
private Drawable getAppIcon(
|
||||||
|
ResolveInfo target,
|
||||||
|
Intent launchIntent,
|
||||||
|
int targetUserId,
|
||||||
|
PackageManager packageManagerForTargetUser) {
|
||||||
|
if (isDialerIntent(launchIntent)) {
|
||||||
|
// The icon for the call intent will be a generic phone icon as the target will be
|
||||||
|
// the telecom call handler. From the user's perspective, they are being directed
|
||||||
|
// to the dialer app, so use the icon from that app instead.
|
||||||
|
TelecomManager telecomManager =
|
||||||
|
getApplicationContext().getSystemService(TelecomManager.class);
|
||||||
|
String defaultDialerPackageName =
|
||||||
|
telecomManager.getDefaultDialerPackage(UserHandle.of(targetUserId));
|
||||||
|
try {
|
||||||
|
return packageManagerForTargetUser
|
||||||
|
.getApplicationInfo(defaultDialerPackageName, /* flags= */ 0)
|
||||||
|
.loadIcon(packageManagerForTargetUser);
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
// Allow to fall-through to the icon from the target if we can't find the default
|
||||||
|
// dialer icon.
|
||||||
|
Slog.w(TAG, "Cannot load icon for default dialer package");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return target.loadIcon(packageManagerForTargetUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getOpenInWorkButtonString(Intent launchIntent) {
|
||||||
|
if (isDialerIntent(launchIntent)) {
|
||||||
|
return R.string.miniresolver_call;
|
||||||
|
}
|
||||||
|
if (isTextMessageIntent(launchIntent)) {
|
||||||
|
return R.string.miniresolver_switch;
|
||||||
|
}
|
||||||
|
return R.string.whichViewApplicationLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getOpenInWorkMessage(Intent launchIntent, CharSequence targetLabel) {
|
||||||
|
if (isDialerIntent(launchIntent)) {
|
||||||
|
return getSystemService(DevicePolicyManager.class).getResources().getString(
|
||||||
|
MINIRESOLVER_CALL_FROM_WORK,
|
||||||
|
() -> getString(R.string.miniresolver_call_in_work));
|
||||||
|
}
|
||||||
|
if (isTextMessageIntent(launchIntent)) {
|
||||||
|
return getSystemService(DevicePolicyManager.class).getResources().getString(
|
||||||
|
MINIRESOLVER_SWITCH_TO_WORK,
|
||||||
|
() -> getString(R.string.miniresolver_switch_to_work));
|
||||||
|
}
|
||||||
return getSystemService(DevicePolicyManager.class).getResources().getString(
|
return getSystemService(DevicePolicyManager.class).getResources().getString(
|
||||||
MINIRESOLVER_OPEN_WORK,
|
MINIRESOLVER_OPEN_WORK,
|
||||||
() -> getString(R.string.miniresolver_open_work, targetLabel),
|
() -> getString(R.string.miniresolver_open_work, targetLabel),
|
||||||
targetLabel);
|
targetLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getWorkTelephonyInfoSectionMessage(Intent launchIntent) {
|
||||||
|
if (isDialerIntent(launchIntent)) {
|
||||||
|
return getSystemService(DevicePolicyManager.class).getResources().getString(
|
||||||
|
MINIRESOLVER_WORK_TELEPHONY_CALL_BLOCKED_INFORMATION,
|
||||||
|
() -> getString(R.string.miniresolver_call_information));
|
||||||
|
}
|
||||||
|
if (isTextMessageIntent(launchIntent)) {
|
||||||
|
return getSystemService(DevicePolicyManager.class).getResources().getString(
|
||||||
|
MINIRESOLVER_WORK_TELEPHONY_TEXT_BLOCKED_INFORMATION,
|
||||||
|
() -> getString(R.string.miniresolver_sms_information));
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private String getForwardToPersonalMessage() {
|
private String getForwardToPersonalMessage() {
|
||||||
return getSystemService(DevicePolicyManager.class).getResources().getString(
|
return getSystemService(DevicePolicyManager.class).getResources().getString(
|
||||||
FORWARD_INTENT_TO_PERSONAL,
|
FORWARD_INTENT_TO_PERSONAL,
|
||||||
|
|||||||
@@ -63,6 +63,37 @@
|
|||||||
android:textColor="?android:textColorPrimary"
|
android:textColor="?android:textColorPrimary"
|
||||||
/>
|
/>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
<!-- Additional information section, currently only shown when redirecting to Telephony apps -->
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/miniresolver_info_section"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingHorizontal="24dp"
|
||||||
|
android:paddingBottom="48dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:background="?attr/colorBackground"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/miniresolver_info_section_icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingEnd="8dp"
|
||||||
|
android:src="@drawable/ic_info_outline_24"
|
||||||
|
android:tint="?android:textColorSecondary"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/miniresolver_info_section_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:paddingEnd="8dp"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textAllCaps="false"
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
|
/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/button_bar_container"
|
android:id="@+id/button_bar_container"
|
||||||
@@ -83,7 +114,7 @@
|
|||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layoutDirection="locale"
|
android:layoutDirection="locale"
|
||||||
android:measureWithLargestChild="true"
|
android:measureWithLargestChild="true"
|
||||||
android:paddingHorizontal="16dp"
|
android:layout_marginHorizontal="24dp"
|
||||||
android:paddingBottom="2dp"
|
android:paddingBottom="2dp"
|
||||||
android:elevation="@dimen/resolver_elevation">
|
android:elevation="@dimen/resolver_elevation">
|
||||||
|
|
||||||
|
|||||||
@@ -861,10 +861,10 @@
|
|||||||
<!-- "Switch" is a verb; it means to change user profile by tapping another user profile name. -->
|
<!-- "Switch" is a verb; it means to change user profile by tapping another user profile name. -->
|
||||||
<string name="managed_profile_label">Switch to work profile</string>
|
<string name="managed_profile_label">Switch to work profile</string>
|
||||||
|
|
||||||
<!-- "Switch" is a verb; it means to change user profile by tapping another user profile name. -->
|
<!-- "Switch" is a verb; it means to change user profile by switching to an app in the personal profile. -->
|
||||||
<string name="user_owner_app_label">Switch to personal <xliff:g id="app_name" example="Gmail">%1$s</xliff:g></string>
|
<string name="user_owner_app_label">Switch to personal <xliff:g id="app_name" example="Gmail">%1$s</xliff:g></string>
|
||||||
|
|
||||||
<!-- "Switch" is a verb; it means to change user profile by tapping another user profile name. -->
|
<!-- "Switch" is a verb; it means to change user profile by switching to an app in the work profile. -->
|
||||||
<string name="managed_profile_app_label">Switch to work <xliff:g id="app_name" example="Gmail">%1$s</xliff:g></string>
|
<string name="managed_profile_app_label">Switch to work <xliff:g id="app_name" example="Gmail">%1$s</xliff:g></string>
|
||||||
|
|
||||||
<!-- Title of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
|
<!-- Title of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
|
||||||
@@ -5907,10 +5907,24 @@
|
|||||||
<string name="miniresolver_open_in_personal">Open in personal <xliff:g id="app" example="YouTube">%s</xliff:g>?</string>
|
<string name="miniresolver_open_in_personal">Open in personal <xliff:g id="app" example="YouTube">%s</xliff:g>?</string>
|
||||||
<!-- Dialog title. User must choose between opening content in a cross-profile app or same-profile browser. [CHAR LIMIT=NONE] -->
|
<!-- Dialog title. User must choose between opening content in a cross-profile app or same-profile browser. [CHAR LIMIT=NONE] -->
|
||||||
<string name="miniresolver_open_in_work">Open in work <xliff:g id="app" example="YouTube">%s</xliff:g>?</string>
|
<string name="miniresolver_open_in_work">Open in work <xliff:g id="app" example="YouTube">%s</xliff:g>?</string>
|
||||||
|
<!-- Dialog title. User must place the phone call in the other profile, or cancel. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="miniresolver_call_in_work">Call from work app?</string>
|
||||||
|
<!-- Dialog title. User much choose between opening content in a cross-profile app or cancelling. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="miniresolver_switch_to_work">Switch to work app?</string>
|
||||||
|
<!-- Dialog text. Shown when the user is unable to make a phone call from a personal app due to restrictions set
|
||||||
|
by their organization, and so must switch to a work app or cancel. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="miniresolver_call_information">Your organization only allows you to make calls from work apps</string>
|
||||||
|
<!-- Dialog text. Shown when the user is unable to send a text message from a personal app due to restrictions set
|
||||||
|
by their organization, and so must switch to a work app or cancel. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="miniresolver_sms_information">Your organization only allows you to send messages from work apps</string>
|
||||||
<!-- Button option. Open the link in the personal browser. [CHAR LIMIT=NONE] -->
|
<!-- Button option. Open the link in the personal browser. [CHAR LIMIT=NONE] -->
|
||||||
<string name="miniresolver_use_personal_browser">Use personal browser</string>
|
<string name="miniresolver_use_personal_browser">Use personal browser</string>
|
||||||
<!-- Button option. Open the link in the work browser. [CHAR LIMIT=NONE] -->
|
<!-- Button option. Open the link in the work browser. [CHAR LIMIT=NONE] -->
|
||||||
<string name="miniresolver_use_work_browser">Use work browser</string>
|
<string name="miniresolver_use_work_browser">Use work browser</string>
|
||||||
|
<!-- Button option. Action to place a phone call. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="miniresolver_call">Call</string>
|
||||||
|
<!-- Button option. Action to open an app in the work profile. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="miniresolver_switch">Switch</string>
|
||||||
|
|
||||||
<!-- Icc depersonalization related strings -->
|
<!-- Icc depersonalization related strings -->
|
||||||
<!-- Label text for PIN entry widget on SIM Network Depersonalization panel [CHAR LIMIT=none] -->
|
<!-- Label text for PIN entry widget on SIM Network Depersonalization panel [CHAR LIMIT=none] -->
|
||||||
|
|||||||
@@ -1577,6 +1577,14 @@
|
|||||||
<java-symbol type="string" name="miniresolver_open_work" />
|
<java-symbol type="string" name="miniresolver_open_work" />
|
||||||
<java-symbol type="string" name="miniresolver_use_personal_browser" />
|
<java-symbol type="string" name="miniresolver_use_personal_browser" />
|
||||||
<java-symbol type="string" name="miniresolver_use_work_browser" />
|
<java-symbol type="string" name="miniresolver_use_work_browser" />
|
||||||
|
<java-symbol type="string" name="miniresolver_call_in_work" />
|
||||||
|
<java-symbol type="string" name="miniresolver_switch_to_work" />
|
||||||
|
<java-symbol type="string" name="miniresolver_call" />
|
||||||
|
<java-symbol type="string" name="miniresolver_switch" />
|
||||||
|
<java-symbol type="string" name="miniresolver_call_information" />
|
||||||
|
<java-symbol type="string" name="miniresolver_sms_information" />
|
||||||
|
<java-symbol type="id" name="miniresolver_info_section" />
|
||||||
|
<java-symbol type="id" name="miniresolver_info_section_text" />
|
||||||
<java-symbol type="id" name="button_open" />
|
<java-symbol type="id" name="button_open" />
|
||||||
<java-symbol type="id" name="use_same_profile_browser" />
|
<java-symbol type="id" name="use_same_profile_browser" />
|
||||||
|
|
||||||
|
|||||||
@@ -3101,17 +3101,20 @@
|
|||||||
<!-- Switch to work profile dialer app for placing a call dialog. -->
|
<!-- Switch to work profile dialer app for placing a call dialog. -->
|
||||||
<!-- Text for Switch to work profile dialog's Title. Switch to work profile dialog guide users to make call from work
|
<!-- Text for Switch to work profile dialog's Title. Switch to work profile dialog guide users to make call from work
|
||||||
profile dialer app as it's not possible to make call from current profile due to an admin policy. [CHAR LIMIT=60] -->
|
profile dialer app as it's not possible to make call from current profile due to an admin policy. [CHAR LIMIT=60] -->
|
||||||
<string name="call_from_work_profile_title">Can\'t call from this profile</string>
|
<string name="call_from_work_profile_title">Can\'t call from a personal app</string>
|
||||||
<!-- Text for switch to work profile for call dialog to guide users to make call from work
|
<!-- Text for switch to work profile for call dialog to guide users to make call from work
|
||||||
profile dialer app as it's not possible to make call from current profile due to an admin policy. [CHAR LIMIT=NONE]
|
profile dialer app as it's not possible to make call from current profile due to an admin policy. [CHAR LIMIT=NONE]
|
||||||
-->
|
-->
|
||||||
<string name="call_from_work_profile_text">Your work policy allows you to make phone calls only from the work profile</string>
|
<string name="call_from_work_profile_text">Your organization only allows you to make calls from work apps</string>
|
||||||
<!-- Label for the button to switch to work profile for placing call. Switch to work profile dialog guide users to make call from work
|
<!-- Label for the button to switch to work profile for placing call. Switch to work profile dialog guide users to make call from work
|
||||||
profile dialer app as it's not possible to make call from current profile due to an admin policy.[CHAR LIMIT=60] -->
|
profile dialer app as it's not possible to make call from current profile due to an admin policy.[CHAR LIMIT=60] -->
|
||||||
<string name="call_from_work_profile_action">Switch to work profile</string>
|
<string name="call_from_work_profile_action">Switch to work profile</string>
|
||||||
|
<!-- Label for the button to switch to work profile for placing call. Switch to work profile dialog guide users to make call from work
|
||||||
|
profile dialer app as it's not possible to make call from current profile due to an admin policy.[CHAR LIMIT=60] -->
|
||||||
|
<string name="install_dialer_on_work_profile_action">Install a work phone app</string>
|
||||||
<!-- Label for the close button on switch to work profile dialog. Switch to work profile dialog guide users to make call from work
|
<!-- Label for the close button on switch to work profile dialog. Switch to work profile dialog guide users to make call from work
|
||||||
profile dialer app as it's not possible to make call from current profile due to an admin policy.[CHAR LIMIT=60] -->
|
profile dialer app as it's not possible to make call from current profile due to an admin policy.[CHAR LIMIT=60] -->
|
||||||
<string name="call_from_work_profile_close">Close</string>
|
<string name="call_from_work_profile_close">Cancel</string>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Label for a menu item in a menu that is shown when the user wishes to customize the lock screen.
|
Label for a menu item in a menu that is shown when the user wishes to customize the lock screen.
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import com.android.systemui.sensorprivacy.television.TvSensorPrivacyChangedActiv
|
|||||||
import com.android.systemui.sensorprivacy.television.TvUnblockSensorActivity;
|
import com.android.systemui.sensorprivacy.television.TvUnblockSensorActivity;
|
||||||
import com.android.systemui.settings.brightness.BrightnessDialog;
|
import com.android.systemui.settings.brightness.BrightnessDialog;
|
||||||
import com.android.systemui.statusbar.tv.notifications.TvNotificationPanelActivity;
|
import com.android.systemui.statusbar.tv.notifications.TvNotificationPanelActivity;
|
||||||
|
import com.android.systemui.telephony.ui.activity.SwitchToManagedProfileForCallActivity;
|
||||||
import com.android.systemui.tuner.TunerActivity;
|
import com.android.systemui.tuner.TunerActivity;
|
||||||
import com.android.systemui.usb.UsbAccessoryUriActivity;
|
import com.android.systemui.usb.UsbAccessoryUriActivity;
|
||||||
import com.android.systemui.usb.UsbConfirmActivity;
|
import com.android.systemui.usb.UsbConfirmActivity;
|
||||||
@@ -178,4 +179,11 @@ public abstract class DefaultActivityBinder {
|
|||||||
@ClassKey(TvSensorPrivacyChangedActivity.class)
|
@ClassKey(TvSensorPrivacyChangedActivity.class)
|
||||||
public abstract Activity bindTvSensorPrivacyChangedActivity(
|
public abstract Activity bindTvSensorPrivacyChangedActivity(
|
||||||
TvSensorPrivacyChangedActivity activity);
|
TvSensorPrivacyChangedActivity activity);
|
||||||
|
|
||||||
|
/** Inject into SwitchToManagedProfileForCallActivity. */
|
||||||
|
@Binds
|
||||||
|
@IntoMap
|
||||||
|
@ClassKey(SwitchToManagedProfileForCallActivity.class)
|
||||||
|
public abstract Activity bindSwitchToManagedProfileForCallActivity(
|
||||||
|
SwitchToManagedProfileForCallActivity activity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,14 +22,21 @@ import android.content.Intent
|
|||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.UserHandle
|
import android.os.UserHandle
|
||||||
|
import android.telecom.TelecomManager
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import com.android.internal.app.AlertActivity
|
import com.android.internal.app.AlertActivity
|
||||||
import com.android.systemui.R
|
import com.android.systemui.R
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
/** Dialog shown to the user to switch to managed profile for making a call using work SIM. */
|
/** Dialog shown to the user to switch to managed profile for making a call using work SIM. */
|
||||||
class SwitchToManagedProfileForCallActivity : AlertActivity(), DialogInterface.OnClickListener {
|
class SwitchToManagedProfileForCallActivity
|
||||||
|
@Inject
|
||||||
|
constructor(
|
||||||
|
private val telecomManager: TelecomManager?,
|
||||||
|
) : AlertActivity(), DialogInterface.OnClickListener {
|
||||||
private lateinit var phoneNumber: Uri
|
private lateinit var phoneNumber: Uri
|
||||||
|
private lateinit var positiveActionIntent: Intent
|
||||||
private var managedProfileUserId = UserHandle.USER_NULL
|
private var managedProfileUserId = UserHandle.USER_NULL
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
@@ -37,8 +44,7 @@ class SwitchToManagedProfileForCallActivity : AlertActivity(), DialogInterface.O
|
|||||||
WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS
|
WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS
|
||||||
)
|
)
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
phoneNumber = intent.data ?: Uri.EMPTY
|
||||||
phoneNumber = intent.getData()
|
|
||||||
managedProfileUserId =
|
managedProfileUserId =
|
||||||
intent.getIntExtra(
|
intent.getIntExtra(
|
||||||
"android.telecom.extra.MANAGED_PROFILE_USER_ID",
|
"android.telecom.extra.MANAGED_PROFILE_USER_ID",
|
||||||
@@ -48,11 +54,31 @@ class SwitchToManagedProfileForCallActivity : AlertActivity(), DialogInterface.O
|
|||||||
mAlertParams.apply {
|
mAlertParams.apply {
|
||||||
mTitle = getString(R.string.call_from_work_profile_title)
|
mTitle = getString(R.string.call_from_work_profile_title)
|
||||||
mMessage = getString(R.string.call_from_work_profile_text)
|
mMessage = getString(R.string.call_from_work_profile_text)
|
||||||
mPositiveButtonText = getString(R.string.call_from_work_profile_action)
|
|
||||||
mNegativeButtonText = getString(R.string.call_from_work_profile_close)
|
mNegativeButtonText = getString(R.string.call_from_work_profile_close)
|
||||||
mPositiveButtonListener = this@SwitchToManagedProfileForCallActivity
|
mPositiveButtonListener = this@SwitchToManagedProfileForCallActivity
|
||||||
mNegativeButtonListener = this@SwitchToManagedProfileForCallActivity
|
mNegativeButtonListener = this@SwitchToManagedProfileForCallActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A dialer app may not be available in the managed profile. We try to handle that
|
||||||
|
// gracefully by redirecting the user to the app market to install a suitable app.
|
||||||
|
val defaultDialerPackageName: String? =
|
||||||
|
telecomManager?.getDefaultDialerPackage(UserHandle.of(managedProfileUserId))
|
||||||
|
|
||||||
|
val (intent, positiveButtonText) =
|
||||||
|
defaultDialerPackageName?.let {
|
||||||
|
Intent(
|
||||||
|
Intent.ACTION_CALL,
|
||||||
|
phoneNumber,
|
||||||
|
) to R.string.call_from_work_profile_action
|
||||||
|
}
|
||||||
|
?: Intent(
|
||||||
|
Intent.ACTION_VIEW,
|
||||||
|
Uri.parse(APP_STORE_DIALER_QUERY),
|
||||||
|
) to R.string.install_dialer_on_work_profile_action
|
||||||
|
|
||||||
|
positiveActionIntent = intent
|
||||||
|
mAlertParams.apply { mPositiveButtonText = getString(positiveButtonText) }
|
||||||
|
|
||||||
setupAlert()
|
setupAlert()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +92,7 @@ class SwitchToManagedProfileForCallActivity : AlertActivity(), DialogInterface.O
|
|||||||
private fun switchToManagedProfile() {
|
private fun switchToManagedProfile() {
|
||||||
try {
|
try {
|
||||||
applicationContext.startActivityAsUser(
|
applicationContext.startActivityAsUser(
|
||||||
Intent(Intent.ACTION_CALL, phoneNumber),
|
positiveActionIntent,
|
||||||
ActivityOptions.makeOpenCrossProfileAppsAnimation().toBundle(),
|
ActivityOptions.makeOpenCrossProfileAppsAnimation().toBundle(),
|
||||||
UserHandle.of(managedProfileUserId)
|
UserHandle.of(managedProfileUserId)
|
||||||
)
|
)
|
||||||
@@ -77,5 +103,6 @@ class SwitchToManagedProfileForCallActivity : AlertActivity(), DialogInterface.O
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val TAG = "SwitchToManagedProfileForCallActivity"
|
private const val TAG = "SwitchToManagedProfileForCallActivity"
|
||||||
|
private const val APP_STORE_DIALER_QUERY = "market://search?q=dialer"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -382,7 +382,11 @@ public class DefaultCrossProfileIntentFiltersUtils {
|
|||||||
return filters;
|
return filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Call intent with tel scheme exclusively handled my managed profile. */
|
/** Call intent with tel scheme exclusively handled my managed profile.
|
||||||
|
* Note that work profile telephony relies on this intent filter to redirect intents to
|
||||||
|
* the IntentForwarderActivity. Work profile telephony error handling must be updated in
|
||||||
|
* the Telecomm package CallsManager if this filter is changed.
|
||||||
|
*/
|
||||||
private static final DefaultCrossProfileIntentFilter CALL_MANAGED_PROFILE =
|
private static final DefaultCrossProfileIntentFilter CALL_MANAGED_PROFILE =
|
||||||
new DefaultCrossProfileIntentFilter.Builder(
|
new DefaultCrossProfileIntentFilter.Builder(
|
||||||
DefaultCrossProfileIntentFilter.Direction.TO_PROFILE,
|
DefaultCrossProfileIntentFilter.Direction.TO_PROFILE,
|
||||||
|
|||||||
Reference in New Issue
Block a user