Update strings when work apps are paused
Test: Manually tested - screenshots in bug
Change-Id: I0b7b633f1eb71829752c991018e7c260f22d8cbb
Bug: 258628706
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 3eb08ba..d808977 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -419,10 +419,12 @@
<!--- heading shown when user opens work apps tab while work apps are paused -->
<string name="work_apps_paused_title">Work apps are paused</string>
- <!--- body shown when user opens work apps tab while work apps are paused -->
+ <!--- body shown when user opens work apps tab while work apps are paused.-->
+ <string name="work_apps_paused_info_body">You won’t receive notifications from your work apps</string>
+ <!--- body shown when user opens work apps tab while work apps are paused. -->
<string name="work_apps_paused_body">Your work apps can’t send you notifications, use your battery, or access your location</string>
- <!-- content description for paused work apps list -->
- <string name="work_apps_paused_content_description">Work apps are off. Your work apps can’t send you notifications, use your battery, or access your location</string>
+ <!--- body shown when user opens work apps tab while work apps are paused and calls and texts are unavailable-->
+ <string name="work_apps_paused_telephony_unavailable_body">You won’t receive phone calls, text messages, or notifications from your work apps</string>
<!-- string shown in educational banner about work profile -->
<string name="work_apps_paused_edu_banner">Work apps are badged and visible to your IT admin</string>
<!-- button string shown to dismiss work tab education -->
@@ -431,7 +433,7 @@
<!-- button string shown pause work profile -->
<string name="work_apps_pause_btn_text">Pause work apps</string>
<!-- button string shown enable work profile -->
- <string name="work_apps_enable_btn_text">Turn on work apps</string>
+ <string name="work_apps_enable_btn_text">Unpause</string>
<!-- A hint shown in launcher settings develop options filter box -->
<string name="developer_options_filter_hint">Filter</string>
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 02e18c5..219d1ff 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -126,6 +126,9 @@
@ChecksSdkIntAtLeast(api = VERSION_CODES.TIRAMISU, codename = "T")
public static final boolean ATLEAST_T = Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU;
+ @ChecksSdkIntAtLeast(api = VERSION_CODES.UPSIDE_DOWN_CAKE, codename = "U")
+ public static final boolean ATLEAST_U = Build.VERSION.SDK_INT >= VERSION_CODES.UPSIDE_DOWN_CAKE;
+
/**
* Set on a motion event dispatched from the nav bar. See {@link MotionEvent#setEdgeFlags(int)}.
*/
diff --git a/src/com/android/launcher3/model/StringCache.java b/src/com/android/launcher3/model/StringCache.java
index 9859ddc..8209043 100644
--- a/src/com/android/launcher3/model/StringCache.java
+++ b/src/com/android/launcher3/model/StringCache.java
@@ -18,6 +18,7 @@
import android.annotation.SuppressLint;
import android.app.admin.DevicePolicyManager;
+import android.app.admin.ManagedSubscriptionsPolicy;
import android.content.Context;
import android.os.Build;
@@ -26,6 +27,8 @@
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
+import java.util.function.Supplier;
+
/**
*
* Cache for the device policy strings used in Launcher.
@@ -192,7 +195,9 @@
workProfilePausedTitle = getEnterpriseString(
context, WORK_PROFILE_PAUSED_TITLE, R.string.work_apps_paused_title);
workProfilePausedDescription = getEnterpriseString(
- context, WORK_PROFILE_PAUSED_DESCRIPTION, R.string.work_apps_paused_body);
+ context,
+ WORK_PROFILE_PAUSED_DESCRIPTION,
+ () -> getDefaultWorkProfilePausedDescriptionString(context));
workProfilePauseButton = getEnterpriseString(
context, WORK_PROFILE_PAUSE_BUTTON, R.string.work_apps_pause_btn_text);
workProfileEnableButton = getEnterpriseString(
@@ -216,20 +221,41 @@
context, DISABLED_BY_ADMIN_MESSAGE, R.string.msg_disabled_by_admin);
}
+ private String getDefaultWorkProfilePausedDescriptionString(Context context) {
+ if (Utilities.ATLEAST_U) {
+ DevicePolicyManager dpm = context.getSystemService(DevicePolicyManager.class);
+ boolean telephonyIsUnavailable =
+ dpm.getManagedSubscriptionsPolicy().getPolicyType()
+ == ManagedSubscriptionsPolicy.TYPE_ALL_MANAGED_SUBSCRIPTIONS;
+ return telephonyIsUnavailable
+ ? context.getString(R.string.work_apps_paused_telephony_unavailable_body)
+ : context.getString(R.string.work_apps_paused_info_body);
+ }
+ return context.getString(R.string.work_apps_paused_body);
+ }
+
@SuppressLint("NewApi")
private String getEnterpriseString(
Context context, String updatableStringId, int defaultStringId) {
+ return getEnterpriseString(
+ context,
+ updatableStringId,
+ () -> context.getString(defaultStringId));
+ }
+
+ @SuppressLint("NewApi")
+ private String getEnterpriseString(
+ Context context, String updateableStringId, Supplier<String> defaultStringSupplier) {
return Utilities.ATLEAST_T
- ? getUpdatableEnterpriseSting(context, updatableStringId, defaultStringId)
- : context.getString(defaultStringId);
+ ? getUpdatableEnterpriseString(context, updateableStringId, defaultStringSupplier)
+ : defaultStringSupplier.get();
}
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
- private String getUpdatableEnterpriseSting(
- Context context, String updatableStringId, int defaultStringId) {
+ private String getUpdatableEnterpriseString(
+ Context context, String updatableStringId, Supplier<String> defaultStringSupplier) {
DevicePolicyManager dpm = context.getSystemService(DevicePolicyManager.class);
- return dpm.getResources().getString(
- updatableStringId, () -> context.getString(defaultStringId));
+ return dpm.getResources().getString(updatableStringId, defaultStringSupplier);
}
@Override