Snap for 5595178 from bbdf816d5f to qt-c2f2-release
Change-Id: Ida3c7afade1d73a149d266be67d4a06b5ce6af88
This commit is contained in:
@@ -2680,6 +2680,7 @@
|
|||||||
android:label=""
|
android:label=""
|
||||||
android:theme="@style/Transparent"
|
android:theme="@style/Transparent"
|
||||||
android:excludeFromRecents="true"
|
android:excludeFromRecents="true"
|
||||||
|
android:documentLaunchMode="always"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:permission="android.permission.CHANGE_WIFI_STATE"
|
android:permission="android.permission.CHANGE_WIFI_STATE"
|
||||||
android:configChanges="orientation|keyboardHidden|screenSize">
|
android:configChanges="orientation|keyboardHidden|screenSize">
|
||||||
|
|||||||
@@ -16,9 +16,12 @@ Copyright (C) 2019 The Android Open Source Project
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:width="24dp"
|
android:width="24dp"
|
||||||
android:height="24dp"
|
android:height="24dp"
|
||||||
android:viewportWidth="20.0"
|
android:viewportWidth="24.0"
|
||||||
android:viewportHeight="22.0">
|
android:viewportHeight="24.0">
|
||||||
<path
|
<path
|
||||||
android:fillColor="#FF1E8E3E"
|
android:fillColor="#FF1E8E3E"
|
||||||
android:pathData="M15,17L5,17L5,14.33l1.59,1.58L8,14.5l-3,-3 -1,-1 -4,4 1.41,1.42L3,14.33L3,20a2.006,2.006 0,0 0,2 2L15,22a2.006,2.006 0,0 0,2 -2L17,13L15,13ZM15,20L5,20L5,19L15,19ZM5,5L15,5L15,7.67L13.41,6.09 12,7.5l4,4 4,-4L18.59,6.08 17,7.67L17,2a1.997,1.997 0,0 0,-2 -1.99L5,0A2.006,2.006 0,0 0,3 2v7L5,9ZM5,2L15,2L15,3L5,3Z"/>
|
android:pathData="M17,18H7v-2.67l1.59,1.58L10,15.5l-3,-3l-1,-1l-4,4l1.41,1.42L5,15.33v4.17V20v1c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2v-7h-2V18zM17,21H7v-1h10V21z"/>
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF1E8E3E"
|
||||||
|
android:pathData="M7,6h10v2.67l-1.59,-1.58L14,8.5l4,4l4,-4l-1.41,-1.42L19,8.67V4.5V4V3c0,-1.1 -0.9,-1.99 -2,-1.99L7,1C5.9,1 5,1.9 5,3v7h2V6zM7,3h10v1H7V3z"/>
|
||||||
</vector>
|
</vector>
|
||||||
|
|||||||
@@ -16,9 +16,12 @@ Copyright (C) 2019 The Android Open Source Project
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:width="24dp"
|
android:width="24dp"
|
||||||
android:height="24dp"
|
android:height="24dp"
|
||||||
android:viewportWidth="20.0"
|
android:viewportWidth="24.0"
|
||||||
android:viewportHeight="22.0">
|
android:viewportHeight="24.0">
|
||||||
<path
|
<path
|
||||||
android:fillColor="#FFD93025"
|
android:fillColor="#FFD93025"
|
||||||
android:pathData="M15,17L5,17L5,14.33l1.59,1.58L8,14.5l-3,-3 -1,-1 -4,4 1.41,1.42L3,14.33L3,20a2.006,2.006 0,0 0,2 2L15,22a2.006,2.006 0,0 0,2 -2L17,13L15,13ZM15,20L5,20L5,19L15,19ZM5,5L15,5L15,7.67L13.41,6.09 12,7.5l4,4 4,-4L18.59,6.08 17,7.67L17,2a1.997,1.997 0,0 0,-2 -1.99L5,0A2.006,2.006 0,0 0,3 2v7L5,9ZM5,2L15,2L15,3L5,3Z"/>
|
android:pathData="M17,18H7v-2.67l1.59,1.58L10,15.5l-3,-3l-1,-1l-4,4l1.41,1.42L5,15.33v4.17V20v1c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2v-7h-2V18zM17,21H7v-1h10V21z"/>
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFD93025"
|
||||||
|
android:pathData="M7,6h10v2.67l-1.59,-1.58L14,8.5l4,4l4,-4l-1.41,-1.42L19,8.67V4.5V4V3c0,-1.1 -0.9,-1.99 -2,-1.99L7,1C5.9,1 5,1.9 5,3v7h2V6zM7,3h10v1H7V3z"/>
|
||||||
</vector>
|
</vector>
|
||||||
|
|||||||
@@ -65,7 +65,8 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_gravity="center_horizontal|bottom">
|
android:layout_gravity="center_horizontal|bottom"
|
||||||
|
android:paddingTop="12dp">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
<style name="Theme.AlertDialog.Base" parent="@style/Theme.AppCompat.DayNight.Dialog.Alert">
|
<style name="Theme.AlertDialog.Base" parent="@style/Theme.AppCompat.DayNight.Dialog.Alert">
|
||||||
<item name="colorAccent">@*android:color/accent_device_default_dark</item>
|
<item name="colorAccent">@*android:color/accent_device_default_dark</item>
|
||||||
<item name="android:background">@color/dialog_background</item>
|
<item name="android:colorBackground">@color/dialog_background</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -7976,6 +7976,32 @@
|
|||||||
<!-- Configure Notifications: Title for the option controlling notifications for work profile. [CHAR LIMIT=30] -->
|
<!-- Configure Notifications: Title for the option controlling notifications for work profile. [CHAR LIMIT=30] -->
|
||||||
<string name="locked_work_profile_notification_title">When work profile is locked</string>
|
<string name="locked_work_profile_notification_title">When work profile is locked</string>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Configure notifications: Title for determining which notifications appear on the lock screen [CHAR LIMIT=60] -->
|
||||||
|
<string name="lock_screen_notifs_title">Notifications on lockscreen</string>
|
||||||
|
|
||||||
|
<!-- Configure notifications: Value for lockscreen notifications: all notifications shown
|
||||||
|
regardless of noisiness [CHAR LIMIT=60] -->
|
||||||
|
<string name="lock_screen_notifs_show_all">Show alerting and silent notifications</string>
|
||||||
|
|
||||||
|
<!-- Configure notifications: Value for lockscreen notifications: show alerting notifications [CHAR LIMIT=60] -->
|
||||||
|
<string name="lock_screen_notifs_show_alerting">Show alerting notifications only</string>
|
||||||
|
|
||||||
|
<!-- Configure notifications: Value for lockscreen notifications: don't show notifications [CHAR LIMIT=60] -->
|
||||||
|
<string name="lock_screen_notifs_show_none">Don\u2019t show notifications</string>
|
||||||
|
|
||||||
|
<!-- Configure notifications: Title for redacting sensitive content on lockscreen [CHAR LIMIT=60] -->
|
||||||
|
<string name="lock_screen_notifs_redact">Sensitive notifications</string>
|
||||||
|
|
||||||
|
<!-- Configure notifications: Summary for redacting sensitive content on lockscreen [CHAR LIMIT=120] -->
|
||||||
|
<string name="lock_screen_notifs_redact_summary">Show sensitive content when locked</string>
|
||||||
|
|
||||||
|
<!-- Configure notifications: Title for redacting sensitive content on lockscreen, work profile [CHAR LIMIT=60] -->
|
||||||
|
<string name="lock_screen_notifs_redact_work">Sensitive work profile notifications</string>
|
||||||
|
|
||||||
|
<!-- Configure notifications: Summary for redacting sensitive content on lockscreen, work profile [CHAR LIMIT=120] -->
|
||||||
|
<string name="lock_screen_notifs_redact_work_summary">Show sensitive work profile content when locked</string>
|
||||||
|
|
||||||
<!-- Configure Notifications: Value for lockscreen notifications: all information will be
|
<!-- Configure Notifications: Value for lockscreen notifications: all information will be
|
||||||
shown in notifications shown on a secure lock screen
|
shown in notifications shown on a secure lock screen
|
||||||
[CHAR LIMIT=50] -->
|
[CHAR LIMIT=50] -->
|
||||||
|
|||||||
@@ -121,7 +121,7 @@
|
|||||||
|
|
||||||
<style name="Theme.AlertDialog.Base" parent="@style/Theme.AppCompat.DayNight.Dialog.Alert">
|
<style name="Theme.AlertDialog.Base" parent="@style/Theme.AppCompat.DayNight.Dialog.Alert">
|
||||||
<item name="colorAccent">@*android:color/accent_device_default_light</item>
|
<item name="colorAccent">@*android:color/accent_device_default_light</item>
|
||||||
<item name="android:background">@color/dialog_background</item>
|
<item name="android:colorBackground">@color/dialog_background</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Theme.AlertDialog" parent="Theme.AlertDialog.Base">
|
<style name="Theme.AlertDialog" parent="Theme.AlertDialog.Base">
|
||||||
|
|||||||
@@ -26,27 +26,52 @@
|
|||||||
settings:controller="com.android.settings.widget.VideoPreferenceController"
|
settings:controller="com.android.settings.widget.VideoPreferenceController"
|
||||||
android:persistent="false" />
|
android:persistent="false" />
|
||||||
|
|
||||||
<Preference
|
<!-- Empty category to draw divider -->
|
||||||
android:key="gentle_notifications"
|
<PreferenceCategory
|
||||||
android:title="@string/gentle_notifications_title"
|
android:key="all_notifications_divider"
|
||||||
settings:controller="com.android.settings.notification.GentleNotificationsPreferenceController"
|
android:order="2"/>
|
||||||
android:fragment="com.android.settings.notification.GentleNotificationSettings"/>
|
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="configure_notifications_smart"
|
android:key="recent_notifications_category"
|
||||||
android:title="@string/smart_notifications_title"
|
android:title="@string/recent_notifications"
|
||||||
|
settings:allowDividerAbove="false"
|
||||||
android:order="3">
|
android:order="3">
|
||||||
<SwitchPreference
|
<!-- Placeholder for a list of recent apps -->
|
||||||
android:key="asst_capability_prioritizer"
|
|
||||||
android:title="@string/asst_capability_prioritizer_title"
|
<!-- See all apps button -->
|
||||||
android:summary="@string/asst_capability_prioritizer_summary"
|
<Preference
|
||||||
settings:controller="com.android.settings.notification.AssistantCapabilityPreferenceController" />
|
android:key="all_notifications"
|
||||||
|
android:title="@string/notifications_title"
|
||||||
|
android:fragment="com.android.settings.applications.manageapplications.ManageApplications"
|
||||||
|
android:order="4">
|
||||||
|
<extra
|
||||||
|
android:name="classname"
|
||||||
|
android:value="com.android.settings.Settings$NotificationAppListActivity"/>
|
||||||
|
</Preference>
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="configure_notifications_lock"
|
||||||
|
android:title="@string/lock_screen_notifications_title"
|
||||||
|
android:order="10">
|
||||||
|
<!-- When device is locked -->
|
||||||
|
<com.android.settings.RestrictedListPreference
|
||||||
|
android:key="lock_screen_notifications"
|
||||||
|
android:title="@string/lock_screen_notifs_title"
|
||||||
|
android:summary="@string/summary_placeholder" />
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="asst_capabilities_actions_replies"
|
android:key="lock_screen_redact"
|
||||||
android:title="@string/asst_capabilities_actions_replies_title"
|
android:title="@string/lock_screen_notifs_redact"
|
||||||
android:summary="@string/asst_capabilities_actions_replies_summary"
|
android:summary="@string/lock_screen_notifs_redact_summary"
|
||||||
settings:controller="com.android.settings.notification.AssistantCapabilityPreferenceController" />
|
settings:controller="com.android.settings.notification.RedactNotificationPreferenceController" />
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:key="lock_screen_work_redact"
|
||||||
|
android:title="@string/lock_screen_notifs_redact_work"
|
||||||
|
android:summary="@string/lock_screen_notifs_redact_work_summary"
|
||||||
|
settings:controller="com.android.settings.notification.RedactNotificationPreferenceController" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
@@ -54,19 +79,11 @@
|
|||||||
android:order="15"
|
android:order="15"
|
||||||
settings:initialExpandedChildrenCount="0">
|
settings:initialExpandedChildrenCount="0">
|
||||||
|
|
||||||
<com.android.settings.RestrictedListPreference
|
<SwitchPreference
|
||||||
android:key="swipe"
|
android:key="asst_capabilities_actions_replies"
|
||||||
android:title="@string/swipe_direction_title"
|
android:title="@string/asst_capabilities_actions_replies_title"
|
||||||
android:entries="@array/swipe_direction_titles"
|
android:summary="@string/asst_capabilities_actions_replies_summary"
|
||||||
android:entryValues="@array/swipe_direction_values"
|
settings:controller="com.android.settings.notification.AssistantCapabilityPreferenceController" />
|
||||||
settings:controller="com.android.settings.notification.SwipeDirectionPreferenceController"/>
|
|
||||||
|
|
||||||
<!-- When device is locked -->
|
|
||||||
<com.android.settings.RestrictedListPreference
|
|
||||||
android:key="lock_screen_notifications"
|
|
||||||
android:title="@string/lock_screen_notifications_title"
|
|
||||||
android:summary="@string/summary_placeholder"
|
|
||||||
settings:searchable="false"/>
|
|
||||||
|
|
||||||
<!-- Notification badging -->
|
<!-- Notification badging -->
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
@@ -102,45 +119,4 @@
|
|||||||
settings:controller="com.android.settings.notification.ZenModePreferenceController"
|
settings:controller="com.android.settings.notification.ZenModePreferenceController"
|
||||||
settings:allowDividerAbove="false"/>
|
settings:allowDividerAbove="false"/>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<!-- Empty category to draw divider -->
|
|
||||||
<PreferenceCategory
|
|
||||||
android:key="all_notifications_divider"
|
|
||||||
android:order="20"/>
|
|
||||||
|
|
||||||
<PreferenceCategory
|
|
||||||
android:key="recent_notifications_category"
|
|
||||||
android:title="@string/recent_notifications"
|
|
||||||
settings:allowDividerAbove="false"
|
|
||||||
android:order="21">
|
|
||||||
<!-- Placeholder for a list of recent apps -->
|
|
||||||
|
|
||||||
<!-- See all apps button -->
|
|
||||||
<Preference
|
|
||||||
android:key="all_notifications"
|
|
||||||
android:title="@string/notifications_title"
|
|
||||||
android:fragment="com.android.settings.applications.manageapplications.ManageApplications"
|
|
||||||
android:order="22">
|
|
||||||
<extra
|
|
||||||
android:name="classname"
|
|
||||||
android:value="com.android.settings.Settings$NotificationAppListActivity"/>
|
|
||||||
</Preference>
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
<!-- Place work profile section at the bottom to avoid users thinking that any of the
|
|
||||||
above settings are specific to the work profile -->
|
|
||||||
<PreferenceCategory
|
|
||||||
android:key="lock_screen_notifications_profile_header"
|
|
||||||
android:title="@string/profile_section_header"
|
|
||||||
android:order="23"
|
|
||||||
settings:searchable="false">
|
|
||||||
|
|
||||||
<com.android.settings.RestrictedListPreference
|
|
||||||
android:key="lock_screen_notifications_profile"
|
|
||||||
android:title="@string/locked_work_profile_notification_title"
|
|
||||||
android:summary="@string/summary_placeholder"
|
|
||||||
android:order="24"
|
|
||||||
settings:searchable="false"/>
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|||||||
@@ -16,12 +16,13 @@
|
|||||||
|
|
||||||
package com.android.settings.accessibility;
|
package com.android.settings.accessibility;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.bluetooth.BluetoothPairingDetail;
|
import com.android.settings.bluetooth.BluetoothPairingDetail;
|
||||||
import com.android.settings.core.SubSettingLauncher;
|
import com.android.settings.core.SubSettingLauncher;
|
||||||
|
|||||||
@@ -129,6 +129,13 @@ public abstract class VibrationPreferenceFragment extends RadioButtonPickerFragm
|
|||||||
Settings.System.putInt(getContext().getContentResolver(),
|
Settings.System.putInt(getContext().getContentResolver(),
|
||||||
getVibrationIntensitySetting(), candidate.getIntensity());
|
getVibrationIntensitySetting(), candidate.getIntensity());
|
||||||
} else {
|
} else {
|
||||||
|
// We can't play preview effect here for all cases because that causes a data race
|
||||||
|
// (VibratorService may access intensity settings before these settings are updated).
|
||||||
|
// But we can't just play it in intensity settings update observer, because the
|
||||||
|
// intensity settings are not changed if we turn the vibration off, then on.
|
||||||
|
//
|
||||||
|
// In this case we sould play the preview here.
|
||||||
|
// To be refactored in b/132952771
|
||||||
playVibrationPreview();
|
playVibrationPreview();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -297,6 +297,9 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateSignalStrength(SignalStrength signalStrength) {
|
private void updateSignalStrength(SignalStrength signalStrength) {
|
||||||
|
if (signalStrength == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final int subscriptionId = mSubscriptionInfo.getSubscriptionId();
|
final int subscriptionId = mSubscriptionInfo.getSubscriptionId();
|
||||||
final PersistableBundle carrierConfig =
|
final PersistableBundle carrierConfig =
|
||||||
mCarrierConfigManager.getConfigForSubId(subscriptionId);
|
mCarrierConfigManager.getConfigForSubId(subscriptionId);
|
||||||
@@ -430,13 +433,11 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
|
|||||||
mSubscriptionInfo.getSubscriptionId());
|
mSubscriptionInfo.getSubscriptionId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
private int getDbm(SignalStrength signalStrength) {
|
||||||
int getDbm(SignalStrength signalStrength) {
|
|
||||||
return signalStrength.getDbm();
|
return signalStrength.getDbm();
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
private int getAsuLevel(SignalStrength signalStrength) {
|
||||||
int getAsuLevel(SignalStrength signalStrength) {
|
|
||||||
return signalStrength.getAsuLevel();
|
return signalStrength.getAsuLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package com.android.settings.display;
|
|||||||
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.UiModeManager;
|
import android.app.UiModeManager;
|
||||||
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -39,9 +40,7 @@ public class DarkUIInfoDialogFragment extends InstrumentedDialogFragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
// TODO(b/130251804): Add metrics constant in followup change to avoid merge conflict in
|
return SettingsEnums.DIALOG_DARK_UI_INFO;
|
||||||
// beta cherrypick
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
|||||||
@@ -57,17 +57,9 @@ public class ConfigureNotificationSettings extends DashboardFragment implements
|
|||||||
OnActivityResultListener {
|
OnActivityResultListener {
|
||||||
private static final String TAG = "ConfigNotiSettings";
|
private static final String TAG = "ConfigNotiSettings";
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
static final String KEY_LOCKSCREEN = "lock_screen_notifications";
|
|
||||||
@VisibleForTesting
|
|
||||||
static final String KEY_LOCKSCREEN_WORK_PROFILE_HEADER =
|
|
||||||
"lock_screen_notifications_profile_header";
|
|
||||||
@VisibleForTesting
|
|
||||||
static final String KEY_LOCKSCREEN_WORK_PROFILE = "lock_screen_notifications_profile";
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final String KEY_SWIPE_DOWN = "gesture_swipe_down_fingerprint_notifications";
|
static final String KEY_SWIPE_DOWN = "gesture_swipe_down_fingerprint_notifications";
|
||||||
@VisibleForTesting
|
static final String KEY_LOCKSCREEN = "lock_screen_notifications";
|
||||||
static final String KEY_NOTIFICATION_ASSISTANT = "notification_assistant";
|
|
||||||
|
|
||||||
private static final String KEY_NOTI_DEFAULT_RINGTONE = "notification_default_ringtone";
|
private static final String KEY_NOTI_DEFAULT_RINGTONE = "notification_default_ringtone";
|
||||||
private static final int REQUEST_CODE = 200;
|
private static final int REQUEST_CODE = 200;
|
||||||
@@ -100,25 +92,18 @@ public class ConfigureNotificationSettings extends DashboardFragment implements
|
|||||||
} else {
|
} else {
|
||||||
app = null;
|
app = null;
|
||||||
}
|
}
|
||||||
return buildPreferenceControllers(context, getSettingsLifecycle(), app, this);
|
return buildPreferenceControllers(context, app, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
|
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
|
||||||
Lifecycle lifecycle, Application app, Fragment host) {
|
Application app, Fragment host) {
|
||||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||||
final LockScreenNotificationPreferenceController lockScreenNotificationController =
|
|
||||||
new LockScreenNotificationPreferenceController(context,
|
|
||||||
KEY_LOCKSCREEN,
|
|
||||||
KEY_LOCKSCREEN_WORK_PROFILE_HEADER,
|
|
||||||
KEY_LOCKSCREEN_WORK_PROFILE);
|
|
||||||
if (lifecycle != null) {
|
|
||||||
lifecycle.addObserver(lockScreenNotificationController);
|
|
||||||
}
|
|
||||||
controllers.add(new RecentNotifyingAppsPreferenceController(
|
controllers.add(new RecentNotifyingAppsPreferenceController(
|
||||||
context, new NotificationBackend(), IUsageStatsManager.Stub.asInterface(
|
context, new NotificationBackend(), IUsageStatsManager.Stub.asInterface(
|
||||||
ServiceManager.getService(Context.USAGE_STATS_SERVICE)),
|
ServiceManager.getService(Context.USAGE_STATS_SERVICE)),
|
||||||
context.getSystemService(UserManager.class), app, host));
|
context.getSystemService(UserManager.class), app, host));
|
||||||
controllers.add(lockScreenNotificationController);
|
controllers.add(new ShowOnLockScreenNotificationPreferenceController(
|
||||||
|
context, KEY_LOCKSCREEN));
|
||||||
controllers.add(new NotificationRingtonePreferenceController(context) {
|
controllers.add(new NotificationRingtonePreferenceController(context) {
|
||||||
@Override
|
@Override
|
||||||
public String getPreferenceKey() {
|
public String getPreferenceKey() {
|
||||||
@@ -245,7 +230,7 @@ public class ConfigureNotificationSettings extends DashboardFragment implements
|
|||||||
@Override
|
@Override
|
||||||
public List<AbstractPreferenceController> createPreferenceControllers(
|
public List<AbstractPreferenceController> createPreferenceControllers(
|
||||||
Context context) {
|
Context context) {
|
||||||
return buildPreferenceControllers(context, null, null, null);
|
return buildPreferenceControllers(context, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public class RecentNotifyingAppsPreferenceController extends AbstractPreferenceC
|
|||||||
static final String KEY_DIVIDER = "all_notifications_divider";
|
static final String KEY_DIVIDER = "all_notifications_divider";
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final String KEY_SEE_ALL = "all_notifications";
|
static final String KEY_SEE_ALL = "all_notifications";
|
||||||
private static final int SHOW_RECENT_APP_COUNT = 5;
|
private static final int SHOW_RECENT_APP_COUNT = 3;
|
||||||
private static final int DAYS = 3;
|
private static final int DAYS = 3;
|
||||||
private static final Set<String> SKIP_SYSTEM_PACKAGES = new ArraySet<>();
|
private static final Set<String> SKIP_SYSTEM_PACKAGES = new ArraySet<>();
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,130 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.notification;
|
||||||
|
|
||||||
|
import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS;
|
||||||
|
import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS;
|
||||||
|
import static android.provider.Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS;
|
||||||
|
|
||||||
|
import android.app.KeyguardManager;
|
||||||
|
import android.app.admin.DevicePolicyManager;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.UserHandle;
|
||||||
|
import android.os.UserManager;
|
||||||
|
import android.provider.Settings;
|
||||||
|
|
||||||
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
|
import com.android.settings.Utils;
|
||||||
|
import com.android.settings.core.TogglePreferenceController;
|
||||||
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
|
|
||||||
|
public class RedactNotificationPreferenceController extends TogglePreferenceController {
|
||||||
|
|
||||||
|
private static final String TAG = "LockScreenNotifPref";
|
||||||
|
|
||||||
|
static final String KEY_LOCKSCREEN_REDACT = "lock_screen_redact";
|
||||||
|
static final String KEY_LOCKSCREEN_WORK_PROFILE_REDACT = "lock_screen_work_redact";
|
||||||
|
|
||||||
|
private DevicePolicyManager mDpm;
|
||||||
|
private UserManager mUm;
|
||||||
|
private KeyguardManager mKm;
|
||||||
|
private final int mProfileUserId;
|
||||||
|
|
||||||
|
public RedactNotificationPreferenceController(Context context, String settingKey) {
|
||||||
|
super(context, settingKey);
|
||||||
|
|
||||||
|
mUm = context.getSystemService(UserManager.class);
|
||||||
|
mDpm = context.getSystemService(DevicePolicyManager.class);
|
||||||
|
mKm = context.getSystemService(KeyguardManager.class);
|
||||||
|
|
||||||
|
mProfileUserId = Utils.getManagedProfileId(mUm, UserHandle.myUserId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isChecked() {
|
||||||
|
int userId = KEY_LOCKSCREEN_REDACT.equals(getPreferenceKey())
|
||||||
|
? UserHandle.myUserId() : mProfileUserId;
|
||||||
|
|
||||||
|
return getAllowPrivateNotifications(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setChecked(boolean isChecked) {
|
||||||
|
int userId = KEY_LOCKSCREEN_REDACT.equals(getPreferenceKey())
|
||||||
|
? UserHandle.myUserId() : mProfileUserId;
|
||||||
|
|
||||||
|
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, isChecked ? 1 : 0, userId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAvailabilityStatus() {
|
||||||
|
// hide work profile setting if no work profile
|
||||||
|
if (KEY_LOCKSCREEN_WORK_PROFILE_REDACT.equals(getPreferenceKey())
|
||||||
|
&& mProfileUserId == UserHandle.USER_NULL) {
|
||||||
|
return CONDITIONALLY_UNAVAILABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int userId = KEY_LOCKSCREEN_REDACT.equals(getPreferenceKey())
|
||||||
|
? UserHandle.myUserId() : mProfileUserId;
|
||||||
|
|
||||||
|
// hide if lockscreen isn't secure for this user
|
||||||
|
final LockPatternUtils utils = FeatureFactory.getFactory(mContext)
|
||||||
|
.getSecurityFeatureProvider()
|
||||||
|
.getLockPatternUtils(mContext);
|
||||||
|
if (!utils.isSecure(userId)) {
|
||||||
|
return CONDITIONALLY_UNAVAILABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// all notifs hidden? admin doesn't allow notifs or redacted notifs? disabled
|
||||||
|
if (!getLockscreenNotificationsEnabled(userId)
|
||||||
|
|| !adminAllowsNotifications(userId)
|
||||||
|
|| !adminAllowsUnredactedNotifications(userId)) {
|
||||||
|
return DISABLED_DEPENDENT_SETTING;
|
||||||
|
}
|
||||||
|
|
||||||
|
// specifically the work profile setting requires the work profile to be unlocked
|
||||||
|
if (KEY_LOCKSCREEN_WORK_PROFILE_REDACT.equals(getPreferenceKey())) {
|
||||||
|
if (mKm.isDeviceLocked(mProfileUserId)) {
|
||||||
|
return DISABLED_DEPENDENT_SETTING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return AVAILABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean adminAllowsNotifications(int userId) {
|
||||||
|
final int dpmFlags = mDpm.getKeyguardDisabledFeatures(null/* admin */, userId);
|
||||||
|
return (dpmFlags & KEYGUARD_DISABLE_SECURE_NOTIFICATIONS) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean adminAllowsUnredactedNotifications(int userId) {
|
||||||
|
final int dpmFlags = mDpm.getKeyguardDisabledFeatures(null/* admin */, userId);
|
||||||
|
return (dpmFlags & KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean getAllowPrivateNotifications(int userId) {
|
||||||
|
return Settings.Secure.getIntForUser(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1, userId) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean getLockscreenNotificationsEnabled(int userId) {
|
||||||
|
return Settings.Secure.getIntForUser(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 1, userId) != 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,160 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.notification;
|
||||||
|
|
||||||
|
import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS;
|
||||||
|
|
||||||
|
import android.app.admin.DevicePolicyManager;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.UserHandle;
|
||||||
|
import android.provider.Settings;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.RestrictedListPreference;
|
||||||
|
import com.android.settings.core.PreferenceControllerMixin;
|
||||||
|
import com.android.settingslib.RestrictedLockUtils;
|
||||||
|
import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||||
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
|
|
||||||
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
|
public class ShowOnLockScreenNotificationPreferenceController extends AbstractPreferenceController
|
||||||
|
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
|
||||||
|
|
||||||
|
private static final String TAG = "LockScreenNotifPref";
|
||||||
|
|
||||||
|
private final String mSettingKey;
|
||||||
|
private DevicePolicyManager mDpm;
|
||||||
|
|
||||||
|
public ShowOnLockScreenNotificationPreferenceController(Context context, String settingKey) {
|
||||||
|
super(context);
|
||||||
|
mSettingKey = settingKey;
|
||||||
|
mDpm = context.getSystemService(DevicePolicyManager.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
void setDpm(DevicePolicyManager dpm) {
|
||||||
|
mDpm = dpm;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPreferenceKey() {
|
||||||
|
return mSettingKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAvailable() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateState(Preference preference) {
|
||||||
|
RestrictedListPreference pref = (RestrictedListPreference) preference;
|
||||||
|
pref.clearRestrictedItems();
|
||||||
|
ArrayList<CharSequence> entries = new ArrayList<>();
|
||||||
|
ArrayList<CharSequence> values = new ArrayList<>();
|
||||||
|
|
||||||
|
String showAllEntry =
|
||||||
|
mContext.getString(R.string.lock_screen_notifs_show_all);
|
||||||
|
String showAllEntryValue =
|
||||||
|
Integer.toString(R.string.lock_screen_notifs_show_all);
|
||||||
|
entries.add(showAllEntry);
|
||||||
|
values.add(showAllEntryValue);
|
||||||
|
setRestrictedIfNotificationFeaturesDisabled(pref, showAllEntry, showAllEntryValue,
|
||||||
|
KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
|
||||||
|
|
||||||
|
String alertingEntry = mContext.getString(R.string.lock_screen_notifs_show_alerting);
|
||||||
|
String alertingEntryValue = Integer.toString(R.string.lock_screen_notifs_show_alerting);
|
||||||
|
entries.add(alertingEntry);
|
||||||
|
values.add(alertingEntryValue);
|
||||||
|
setRestrictedIfNotificationFeaturesDisabled(pref, alertingEntry, alertingEntryValue,
|
||||||
|
KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
|
||||||
|
|
||||||
|
entries.add(mContext.getString(R.string.lock_screen_notifs_show_none));
|
||||||
|
values.add(Integer.toString(R.string.lock_screen_notifs_show_none));
|
||||||
|
|
||||||
|
pref.setEntries(entries.toArray(new CharSequence[entries.size()]));
|
||||||
|
pref.setEntryValues(values.toArray(new CharSequence[values.size()]));
|
||||||
|
|
||||||
|
if (!adminAllowsNotifications() || !getLockscreenNotificationsEnabled()) {
|
||||||
|
pref.setValue(Integer.toString(R.string.lock_screen_notifs_show_none));
|
||||||
|
} else if (!getLockscreenSilentNotificationsEnabled()) {
|
||||||
|
pref.setValue(Integer.toString(R.string.lock_screen_notifs_show_alerting));
|
||||||
|
} else {
|
||||||
|
pref.setValue(Integer.toString(R.string.lock_screen_notifs_show_all));
|
||||||
|
}
|
||||||
|
|
||||||
|
pref.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
|
refreshSummary(preference);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CharSequence getSummary() {
|
||||||
|
if (!adminAllowsNotifications() || !getLockscreenNotificationsEnabled()) {
|
||||||
|
return mContext.getString(R.string.lock_screen_notifs_show_none);
|
||||||
|
} else if (!getLockscreenSilentNotificationsEnabled()) {
|
||||||
|
return mContext.getString(R.string.lock_screen_notifs_show_alerting);
|
||||||
|
} else {
|
||||||
|
return mContext.getString(R.string.lock_screen_notifs_show_all);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
final int val = Integer.parseInt((String) newValue);
|
||||||
|
final boolean enabled = val != R.string.lock_screen_notifs_show_none;
|
||||||
|
final boolean show = val == R.string.lock_screen_notifs_show_all;
|
||||||
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, show ? 1 : 0);
|
||||||
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, enabled ? 1 : 0);
|
||||||
|
refreshSummary(preference);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setRestrictedIfNotificationFeaturesDisabled(RestrictedListPreference pref,
|
||||||
|
CharSequence entry, CharSequence entryValue, int keyguardNotificationFeatures) {
|
||||||
|
RestrictedLockUtils.EnforcedAdmin admin =
|
||||||
|
RestrictedLockUtilsInternal.checkIfKeyguardFeaturesDisabled(
|
||||||
|
mContext, keyguardNotificationFeatures, UserHandle.myUserId());
|
||||||
|
if (admin != null && pref != null) {
|
||||||
|
RestrictedListPreference.RestrictedItem item =
|
||||||
|
new RestrictedListPreference.RestrictedItem(entry, entryValue, admin);
|
||||||
|
pref.addRestrictedItem(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean adminAllowsNotifications() {
|
||||||
|
final int dpmFlags = mDpm.getKeyguardDisabledFeatures(null/* admin */);
|
||||||
|
return (dpmFlags & KEYGUARD_DISABLE_SECURE_NOTIFICATIONS) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean getLockscreenNotificationsEnabled() {
|
||||||
|
return Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean getLockscreenSilentNotificationsEnabled() {
|
||||||
|
return Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0) != 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,6 +25,10 @@ public class PanelFeatureProviderImpl implements PanelFeatureProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PanelContent getPanel(Context context, String panelType, String mediaPackageName) {
|
public PanelContent getPanel(Context context, String panelType, String mediaPackageName) {
|
||||||
|
if (context == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
switch (panelType) {
|
switch (panelType) {
|
||||||
case Settings.Panel.ACTION_INTERNET_CONNECTIVITY:
|
case Settings.Panel.ACTION_INTERNET_CONNECTIVITY:
|
||||||
return InternetConnectivityPanel.create(context);
|
return InternetConnectivityPanel.create(context);
|
||||||
|
|||||||
@@ -170,6 +170,10 @@ public class PanelFragment extends Fragment {
|
|||||||
.getPanelFeatureProvider()
|
.getPanelFeatureProvider()
|
||||||
.getPanel(activity, panelType, mediaPackageName);
|
.getPanel(activity, panelType, mediaPackageName);
|
||||||
|
|
||||||
|
if (mPanel == null) {
|
||||||
|
activity.finish();
|
||||||
|
}
|
||||||
|
|
||||||
mMetricsProvider = FeatureFactory.getFactory(activity).getMetricsFeatureProvider();
|
mMetricsProvider = FeatureFactory.getFactory(activity).getMetricsFeatureProvider();
|
||||||
|
|
||||||
mPanelSlices.setLayoutManager(new LinearLayoutManager((activity)));
|
mPanelSlices.setLayoutManager(new LinearLayoutManager((activity)));
|
||||||
|
|||||||
@@ -164,7 +164,8 @@ public class SimSelectNotification extends BroadcastReceiver {
|
|||||||
.setSmallIcon(R.drawable.ic_sim_card_alert_white_48dp)
|
.setSmallIcon(R.drawable.ic_sim_card_alert_white_48dp)
|
||||||
.setColor(context.getColor(R.color.sim_noitification))
|
.setColor(context.getColor(R.color.sim_noitification))
|
||||||
.setContentTitle(resources.getText(R.string.sim_notification_title))
|
.setContentTitle(resources.getText(R.string.sim_notification_title))
|
||||||
.setContentText(resources.getText(R.string.sim_notification_summary));
|
.setContentText(resources.getText(R.string.sim_notification_summary))
|
||||||
|
.setAutoCancel(true);
|
||||||
Intent resultIntent = new Intent(Settings.ACTION_WIRELESS_SETTINGS);
|
Intent resultIntent = new Intent(Settings.ACTION_WIRELESS_SETTINGS);
|
||||||
resultIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
resultIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent,
|
PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent,
|
||||||
@@ -197,7 +198,8 @@ public class SimSelectNotification extends BroadcastReceiver {
|
|||||||
.setColor(context.getColor(R.color.sim_noitification))
|
.setColor(context.getColor(R.color.sim_noitification))
|
||||||
.setContentTitle(titleString)
|
.setContentTitle(titleString)
|
||||||
.setContentText(notificationSummary)
|
.setContentText(notificationSummary)
|
||||||
.setStyle(new Notification.BigTextStyle().bigText(notificationSummary));
|
.setStyle(new Notification.BigTextStyle().bigText(notificationSummary))
|
||||||
|
.setAutoCancel(true);
|
||||||
|
|
||||||
// Create the pending intent that will lead to the subscription setting page.
|
// Create the pending intent that will lead to the subscription setting page.
|
||||||
Intent resultIntent = new Intent(Settings.ACTION_MMS_MESSAGE_SETTING);
|
Intent resultIntent = new Intent(Settings.ACTION_MMS_MESSAGE_SETTING);
|
||||||
|
|||||||
@@ -121,8 +121,8 @@ public class SimStatusDialogControllerTest {
|
|||||||
mLifecycle = new Lifecycle(mLifecycleOwner);
|
mLifecycle = new Lifecycle(mLifecycleOwner);
|
||||||
mController = spy(new SimStatusDialogController(mDialog, mLifecycle, 0 /* phone id */));
|
mController = spy(new SimStatusDialogController(mDialog, mLifecycle, 0 /* phone id */));
|
||||||
doReturn(mServiceState).when(mController).getCurrentServiceState();
|
doReturn(mServiceState).when(mController).getCurrentServiceState();
|
||||||
doReturn(0).when(mController).getDbm(any());
|
doReturn(0).when(mSignalStrength).getDbm();
|
||||||
doReturn(0).when(mController).getAsuLevel(any());
|
doReturn(0).when(mSignalStrength).getAsuLevel();
|
||||||
doReturn(mPhoneStateListener).when(mController).getPhoneStateListener();
|
doReturn(mPhoneStateListener).when(mController).getPhoneStateListener();
|
||||||
doReturn("").when(mController).getPhoneNumber();
|
doReturn("").when(mController).getPhoneNumber();
|
||||||
doReturn(mSignalStrength).when(mController).getSignalStrength();
|
doReturn(mSignalStrength).when(mController).getSignalStrength();
|
||||||
@@ -136,6 +136,9 @@ public class SimStatusDialogControllerTest {
|
|||||||
ReflectionHelpers.setField(mController, "mEuiccManager", mEuiccManager);
|
ReflectionHelpers.setField(mController, "mEuiccManager", mEuiccManager);
|
||||||
ReflectionHelpers.setField(mController, "mSubscriptionManager", mSubscriptionManager);
|
ReflectionHelpers.setField(mController, "mSubscriptionManager", mSubscriptionManager);
|
||||||
when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(mPersistableBundle);
|
when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(mPersistableBundle);
|
||||||
|
when(mPersistableBundle.getBoolean(
|
||||||
|
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL))
|
||||||
|
.thenReturn(true);
|
||||||
|
|
||||||
final ShadowPackageManager shadowPackageManager =
|
final ShadowPackageManager shadowPackageManager =
|
||||||
Shadows.shadowOf(RuntimeEnvironment.application.getPackageManager());
|
Shadows.shadowOf(RuntimeEnvironment.application.getPackageManager());
|
||||||
@@ -228,8 +231,8 @@ public class SimStatusDialogControllerTest {
|
|||||||
public void initialize_updateSignalStrengthWith50_shouldUpdateSignalStrengthTo50() {
|
public void initialize_updateSignalStrengthWith50_shouldUpdateSignalStrengthTo50() {
|
||||||
final int signalDbm = 50;
|
final int signalDbm = 50;
|
||||||
final int signalAsu = 50;
|
final int signalAsu = 50;
|
||||||
doReturn(signalDbm).when(mController).getDbm(mSignalStrength);
|
doReturn(signalDbm).when(mSignalStrength).getDbm();
|
||||||
doReturn(signalAsu).when(mController).getAsuLevel(mSignalStrength);
|
doReturn(signalAsu).when(mSignalStrength).getAsuLevel();
|
||||||
when(mPersistableBundle.getBoolean(
|
when(mPersistableBundle.getBoolean(
|
||||||
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL)).thenReturn(true);
|
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL)).thenReturn(true);
|
||||||
|
|
||||||
@@ -249,8 +252,8 @@ public class SimStatusDialogControllerTest {
|
|||||||
|
|
||||||
final int signalDbm = 50;
|
final int signalDbm = 50;
|
||||||
final int signalAsu = 50;
|
final int signalAsu = 50;
|
||||||
doReturn(signalDbm).when(mController).getDbm(mSignalStrength);
|
doReturn(signalDbm).when(mSignalStrength).getDbm();
|
||||||
doReturn(signalAsu).when(mController).getAsuLevel(mSignalStrength);
|
doReturn(signalAsu).when(mSignalStrength).getAsuLevel();
|
||||||
when(mPersistableBundle.getBoolean(
|
when(mPersistableBundle.getBoolean(
|
||||||
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL)).thenReturn(true);
|
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL)).thenReturn(true);
|
||||||
|
|
||||||
@@ -415,4 +418,11 @@ public class SimStatusDialogControllerTest {
|
|||||||
verify(mDialog).removeSettingFromScreen(IMS_REGISTRATION_STATE_LABEL_ID);
|
verify(mDialog).removeSettingFromScreen(IMS_REGISTRATION_STATE_LABEL_ID);
|
||||||
verify(mDialog).removeSettingFromScreen(IMS_REGISTRATION_STATE_VALUE_ID);
|
verify(mDialog).removeSettingFromScreen(IMS_REGISTRATION_STATE_VALUE_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void initialize_nullSignalStrength_noCrash() {
|
||||||
|
doReturn(null).when(mController).getSignalStrength();
|
||||||
|
// we should not crash when running the following line
|
||||||
|
mController.initialize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,14 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.notification;
|
package com.android.settings.notification;
|
||||||
|
|
||||||
import static com.android.settings.notification.ConfigureNotificationSettings.KEY_LOCKSCREEN;
|
import static com.android.settings.notification.ConfigureNotificationSettings.SUMMARY_PROVIDER_FACTORY;
|
||||||
import static com.android.settings.notification.ConfigureNotificationSettings
|
|
||||||
.KEY_LOCKSCREEN_WORK_PROFILE;
|
|
||||||
import static com.android.settings.notification.ConfigureNotificationSettings
|
|
||||||
.KEY_LOCKSCREEN_WORK_PROFILE_HEADER;
|
|
||||||
import static com.android.settings.notification.ConfigureNotificationSettings.KEY_SWIPE_DOWN;
|
|
||||||
import static com.android.settings.notification.ConfigureNotificationSettings
|
|
||||||
.SUMMARY_PROVIDER_FACTORY;
|
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
@@ -37,8 +30,6 @@ import android.app.Activity;
|
|||||||
|
|
||||||
import com.android.settings.dashboard.SummaryLoader;
|
import com.android.settings.dashboard.SummaryLoader;
|
||||||
import com.android.settings.notification.ConfigureNotificationSettings.SummaryProvider;
|
import com.android.settings.notification.ConfigureNotificationSettings.SummaryProvider;
|
||||||
import com.android.settings.testutils.shadow.ShadowLockPatternUtils;
|
|
||||||
import com.android.settings.testutils.shadow.ShadowUtils;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -46,10 +37,6 @@ import org.junit.runner.RunWith;
|
|||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.robolectric.Robolectric;
|
import org.robolectric.Robolectric;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
|
||||||
import org.robolectric.annotation.Config;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
public class ConfigureNotificationSettingsTest {
|
public class ConfigureNotificationSettingsTest {
|
||||||
@@ -61,20 +48,6 @@ public class ConfigureNotificationSettingsTest {
|
|||||||
mActivity = spy(Robolectric.buildActivity(Activity.class).get());
|
mActivity = spy(Robolectric.buildActivity(Activity.class).get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@Config(shadows = {
|
|
||||||
ShadowUtils.class,
|
|
||||||
ShadowLockPatternUtils.class
|
|
||||||
})
|
|
||||||
public void getNonIndexableKeys_shouldContainLockScreenPrefs() {
|
|
||||||
final List<String> keys = ConfigureNotificationSettings.SEARCH_INDEX_DATA_PROVIDER
|
|
||||||
.getNonIndexableKeys(RuntimeEnvironment.application);
|
|
||||||
|
|
||||||
assertThat(keys).containsAllOf(
|
|
||||||
KEY_SWIPE_DOWN, KEY_LOCKSCREEN, KEY_LOCKSCREEN_WORK_PROFILE,
|
|
||||||
KEY_LOCKSCREEN_WORK_PROFILE_HEADER);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSummary_noneBlocked() {
|
public void getSummary_noneBlocked() {
|
||||||
SummaryLoader loader = mock(SummaryLoader.class);
|
SummaryLoader loader = mock(SummaryLoader.class);
|
||||||
|
|||||||
@@ -0,0 +1,301 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.notification;
|
||||||
|
|
||||||
|
import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS;
|
||||||
|
import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS;
|
||||||
|
import static android.provider.Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS;
|
||||||
|
import static android.provider.Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS;
|
||||||
|
|
||||||
|
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||||
|
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
|
||||||
|
import static com.android.settings.core.BasePreferenceController.DISABLED_DEPENDENT_SETTING;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.app.KeyguardManager;
|
||||||
|
import android.app.admin.DevicePolicyManager;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.UserHandle;
|
||||||
|
import android.os.UserManager;
|
||||||
|
import android.provider.Settings;
|
||||||
|
import android.service.notification.Adjustment;
|
||||||
|
|
||||||
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
|
import com.android.settings.testutils.FakeFeatureFactory;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import androidx.preference.Preference;
|
||||||
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
public class RedactNotificationPreferenceControllerTest {
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private DevicePolicyManager mDpm;
|
||||||
|
@Mock
|
||||||
|
UserManager mUm;
|
||||||
|
@Mock
|
||||||
|
KeyguardManager mKm;
|
||||||
|
@Mock
|
||||||
|
private PreferenceScreen mScreen;
|
||||||
|
@Mock
|
||||||
|
private LockPatternUtils mLockPatternUtils;
|
||||||
|
@Mock
|
||||||
|
private Context mMockContext;
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
private RedactNotificationPreferenceController mController;
|
||||||
|
private RedactNotificationPreferenceController mWorkController;
|
||||||
|
private Preference mPreference;
|
||||||
|
private Preference mWorkPreference;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
mContext = RuntimeEnvironment.application;
|
||||||
|
|
||||||
|
FakeFeatureFactory featureFactory = FakeFeatureFactory.setupForTest();
|
||||||
|
when(featureFactory.securityFeatureProvider.getLockPatternUtils(mMockContext))
|
||||||
|
.thenReturn(mLockPatternUtils);
|
||||||
|
when(mMockContext.getContentResolver()).thenReturn(mContext.getContentResolver());
|
||||||
|
when(mMockContext.getSystemService(UserManager.class)).thenReturn(mUm);
|
||||||
|
when(mMockContext.getSystemService(DevicePolicyManager.class)).thenReturn(mDpm);
|
||||||
|
when(mMockContext.getSystemService(KeyguardManager.class)).thenReturn(mKm);
|
||||||
|
when(mUm.getProfileIdsWithDisabled(anyInt())).thenReturn(new int[] {10});
|
||||||
|
|
||||||
|
mController = new RedactNotificationPreferenceController(
|
||||||
|
mMockContext, RedactNotificationPreferenceController.KEY_LOCKSCREEN_REDACT);
|
||||||
|
mPreference = new Preference(mContext);
|
||||||
|
mPreference.setKey(mController.getPreferenceKey());
|
||||||
|
when(mScreen.findPreference(
|
||||||
|
mController.getPreferenceKey())).thenReturn(mPreference);
|
||||||
|
|
||||||
|
mWorkController = new RedactNotificationPreferenceController(mMockContext,
|
||||||
|
RedactNotificationPreferenceController.KEY_LOCKSCREEN_WORK_PROFILE_REDACT);
|
||||||
|
mWorkPreference = new Preference(mContext);
|
||||||
|
mWorkPreference.setKey(mWorkController.getPreferenceKey());
|
||||||
|
when(mScreen.findPreference(
|
||||||
|
mWorkController.getPreferenceKey())).thenReturn(mWorkPreference);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAvailabilityStatus_noSecureLockscreen() {
|
||||||
|
when(mLockPatternUtils.isSecure(anyInt())).thenReturn(false);
|
||||||
|
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_NOTIFICATIONS,
|
||||||
|
1, 0);
|
||||||
|
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_NOTIFICATIONS,
|
||||||
|
1, 10);
|
||||||
|
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
|
||||||
|
assertThat(mWorkController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAvailabilityStatus_noWorkProfile() {
|
||||||
|
// reset controllers with no work profile
|
||||||
|
when(mUm.getProfileIdsWithDisabled(anyInt())).thenReturn(new int[] {UserHandle.USER_NULL});
|
||||||
|
mWorkController = new RedactNotificationPreferenceController(mMockContext,
|
||||||
|
RedactNotificationPreferenceController.KEY_LOCKSCREEN_WORK_PROFILE_REDACT);
|
||||||
|
mController = new RedactNotificationPreferenceController(mMockContext,
|
||||||
|
RedactNotificationPreferenceController.KEY_LOCKSCREEN_REDACT);
|
||||||
|
|
||||||
|
// should otherwise show
|
||||||
|
when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
|
||||||
|
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_NOTIFICATIONS,
|
||||||
|
1, 0);
|
||||||
|
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||||
|
assertThat(mWorkController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAvailabilityStatus_adminSaysNoRedaction() {
|
||||||
|
when(mDpm.getKeyguardDisabledFeatures(eq(null), anyInt())).thenReturn(
|
||||||
|
KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS);
|
||||||
|
|
||||||
|
// should otherwise show
|
||||||
|
when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
|
||||||
|
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_NOTIFICATIONS,
|
||||||
|
1, 0);
|
||||||
|
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_NOTIFICATIONS,
|
||||||
|
1, 10);
|
||||||
|
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_DEPENDENT_SETTING);
|
||||||
|
assertThat(mWorkController.getAvailabilityStatus()).isEqualTo(DISABLED_DEPENDENT_SETTING);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAvailabilityStatus_adminSaysNoNotifications() {
|
||||||
|
when(mDpm.getKeyguardDisabledFeatures(eq(null), anyInt())).thenReturn(
|
||||||
|
KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
|
||||||
|
|
||||||
|
// should otherwise show
|
||||||
|
when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
|
||||||
|
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_NOTIFICATIONS,
|
||||||
|
1, 0);
|
||||||
|
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_NOTIFICATIONS,
|
||||||
|
1, 10);
|
||||||
|
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_DEPENDENT_SETTING);
|
||||||
|
assertThat(mWorkController.getAvailabilityStatus()).isEqualTo(DISABLED_DEPENDENT_SETTING);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAvailabilityStatus_noNotifications() {
|
||||||
|
when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
|
||||||
|
|
||||||
|
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_NOTIFICATIONS,
|
||||||
|
0, 0);
|
||||||
|
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_NOTIFICATIONS,
|
||||||
|
0, 10);
|
||||||
|
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_DEPENDENT_SETTING);
|
||||||
|
assertThat(mWorkController.getAvailabilityStatus()).isEqualTo(DISABLED_DEPENDENT_SETTING);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAvailabilityStatus_workProfileLocked() {
|
||||||
|
// should otherwise show
|
||||||
|
when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
|
||||||
|
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_NOTIFICATIONS,
|
||||||
|
1, 0);
|
||||||
|
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_NOTIFICATIONS,
|
||||||
|
1, 10);
|
||||||
|
|
||||||
|
when(mKm.isDeviceLocked(10)).thenReturn(true);
|
||||||
|
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||||
|
assertThat(mWorkController.getAvailabilityStatus()).isEqualTo(DISABLED_DEPENDENT_SETTING);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAvailabilityStatus_show() {
|
||||||
|
// should otherwise show
|
||||||
|
when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
|
||||||
|
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_NOTIFICATIONS,
|
||||||
|
1, 0);
|
||||||
|
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_NOTIFICATIONS,
|
||||||
|
1, 10);
|
||||||
|
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||||
|
assertThat(mWorkController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isChecked() {
|
||||||
|
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
|
||||||
|
1, 0);
|
||||||
|
|
||||||
|
assertThat(mController.isChecked()).isTrue();
|
||||||
|
|
||||||
|
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
|
||||||
|
0, 0);
|
||||||
|
|
||||||
|
assertThat(mController.isChecked()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isChecked_work() {
|
||||||
|
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
|
||||||
|
1, 10);
|
||||||
|
|
||||||
|
assertThat(mWorkController.isChecked()).isTrue();
|
||||||
|
|
||||||
|
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
|
||||||
|
0, 10);
|
||||||
|
|
||||||
|
assertThat(mWorkController.isChecked()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setChecked_false() throws Exception {
|
||||||
|
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
|
||||||
|
1, 0);
|
||||||
|
|
||||||
|
mController.setChecked(false);
|
||||||
|
assertThat(Settings.Secure.getIntForUser(
|
||||||
|
mContext.getContentResolver(), LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0))
|
||||||
|
.isEqualTo(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setChecked_workProfile_false() throws Exception {
|
||||||
|
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
|
||||||
|
1, 10);
|
||||||
|
|
||||||
|
mWorkController.setChecked(false);
|
||||||
|
assertThat(Settings.Secure.getIntForUser(
|
||||||
|
mContext.getContentResolver(), LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 10))
|
||||||
|
.isEqualTo(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setChecked_true() throws Exception {
|
||||||
|
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
|
||||||
|
0, 0);
|
||||||
|
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
|
||||||
|
0, 10);
|
||||||
|
|
||||||
|
mController.setChecked(true);
|
||||||
|
mWorkController.setChecked(true);
|
||||||
|
assertThat(Settings.Secure.getIntForUser(
|
||||||
|
mContext.getContentResolver(), LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 10))
|
||||||
|
.isEqualTo(1);
|
||||||
|
assertThat(Settings.Secure.getIntForUser(
|
||||||
|
mContext.getContentResolver(), LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0))
|
||||||
|
.isEqualTo(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,224 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.notification;
|
||||||
|
|
||||||
|
import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS;
|
||||||
|
import static android.provider.Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS;
|
||||||
|
import static android.provider.Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.app.admin.DevicePolicyManager;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.provider.Settings;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.RestrictedListPreference;
|
||||||
|
import com.android.settings.testutils.shadow.ShadowRestrictedLockUtilsInternal;
|
||||||
|
import com.android.settings.testutils.shadow.ShadowUserManager;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Answers;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
import org.robolectric.Robolectric;
|
||||||
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
import org.robolectric.Shadows;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
@Config(shadows = {ShadowUserManager.class, ShadowRestrictedLockUtilsInternal.class})
|
||||||
|
public class ShowOnLockscreenNotificationPreferenceControllerTest {
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||||
|
private PreferenceScreen mScreen;
|
||||||
|
@Mock
|
||||||
|
DevicePolicyManager mDpm;
|
||||||
|
|
||||||
|
private ShowOnLockScreenNotificationPreferenceController mController;
|
||||||
|
private RestrictedListPreference mPreference;
|
||||||
|
|
||||||
|
private static final String KEY = "key";
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
mContext = RuntimeEnvironment.application;
|
||||||
|
mController = new ShowOnLockScreenNotificationPreferenceController(mContext, KEY);
|
||||||
|
mPreference = new RestrictedListPreference(
|
||||||
|
mContext, Robolectric.buildAttributeSet().build());
|
||||||
|
mPreference.setKey(mController.getPreferenceKey());
|
||||||
|
when(mScreen.findPreference(mPreference.getKey())).thenReturn(mPreference);
|
||||||
|
mController.setDpm(mDpm);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void display_shouldDisplay() {
|
||||||
|
assertThat(mPreference.isVisible()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateState_noNotifsOnLockscreen() {
|
||||||
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_NOTIFICATIONS,
|
||||||
|
0);
|
||||||
|
// should be ignored
|
||||||
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS,
|
||||||
|
1);
|
||||||
|
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
|
assertThat(mPreference.getValue()).isEqualTo(
|
||||||
|
String.valueOf(R.string.lock_screen_notifs_show_none));
|
||||||
|
|
||||||
|
assertThat(mPreference.getSummary())
|
||||||
|
.isEqualTo(mContext.getString(R.string.lock_screen_notifs_show_none));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateState_alertingNotifsOnLockscreen() {
|
||||||
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_NOTIFICATIONS,
|
||||||
|
1);
|
||||||
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS,
|
||||||
|
0);
|
||||||
|
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
|
assertThat(mPreference.getValue()).isEqualTo(
|
||||||
|
String.valueOf(R.string.lock_screen_notifs_show_alerting));
|
||||||
|
assertThat(mPreference.getSummary())
|
||||||
|
.isEqualTo(mContext.getString(R.string.lock_screen_notifs_show_alerting));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateState_allNotifsOnLockscreen() {
|
||||||
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_NOTIFICATIONS,
|
||||||
|
1);
|
||||||
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS,
|
||||||
|
1);
|
||||||
|
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
|
assertThat(mPreference.getValue()).isEqualTo(
|
||||||
|
String.valueOf(R.string.lock_screen_notifs_show_all));
|
||||||
|
assertThat(mPreference.getSummary())
|
||||||
|
.isEqualTo(mContext.getString(R.string.lock_screen_notifs_show_all));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateState_dpmSaysNo() {
|
||||||
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_NOTIFICATIONS,
|
||||||
|
1);
|
||||||
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS,
|
||||||
|
1);
|
||||||
|
|
||||||
|
when(mDpm.getKeyguardDisabledFeatures(null))
|
||||||
|
.thenReturn(KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
|
||||||
|
ShadowRestrictedLockUtilsInternal.setKeyguardDisabledFeatures(
|
||||||
|
KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
|
||||||
|
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
|
assertThat(mPreference.getValue()).isEqualTo(
|
||||||
|
String.valueOf(R.string.lock_screen_notifs_show_none));
|
||||||
|
assertThat(mPreference.getSummary())
|
||||||
|
.isEqualTo(mContext.getString(R.string.lock_screen_notifs_show_none));
|
||||||
|
|
||||||
|
assertThat(mPreference.isRestrictedForEntry(
|
||||||
|
mContext.getString(R.string.lock_screen_notifs_show_all))).isTrue();
|
||||||
|
assertThat(mPreference.isRestrictedForEntry(
|
||||||
|
mContext.getString(R.string.lock_screen_notifs_show_alerting))).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onPreferenceChange_allToAlerting() {
|
||||||
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_NOTIFICATIONS,
|
||||||
|
1);
|
||||||
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS,
|
||||||
|
1);
|
||||||
|
|
||||||
|
mController.onPreferenceChange(mPreference,
|
||||||
|
Integer.toString(R.string.lock_screen_notifs_show_alerting));
|
||||||
|
|
||||||
|
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_NOTIFICATIONS, 1)).isEqualTo(1);
|
||||||
|
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 1)).isEqualTo(0);
|
||||||
|
|
||||||
|
assertThat(mPreference.getSummary())
|
||||||
|
.isEqualTo(mContext.getString(R.string.lock_screen_notifs_show_alerting));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onPreferenceChange_noneToAll() {
|
||||||
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_NOTIFICATIONS,
|
||||||
|
0);
|
||||||
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS,
|
||||||
|
0);
|
||||||
|
|
||||||
|
mController.onPreferenceChange(mPreference,
|
||||||
|
Integer.toString(R.string.lock_screen_notifs_show_all));
|
||||||
|
|
||||||
|
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_NOTIFICATIONS, 1)).isEqualTo(1);
|
||||||
|
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 1)).isEqualTo(1);
|
||||||
|
|
||||||
|
assertThat(mPreference.getSummary())
|
||||||
|
.isEqualTo(mContext.getString(R.string.lock_screen_notifs_show_all));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onPreferenceChange_alertingToNone() {
|
||||||
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_NOTIFICATIONS,
|
||||||
|
1);
|
||||||
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS,
|
||||||
|
0);
|
||||||
|
|
||||||
|
mController.onPreferenceChange(mPreference,
|
||||||
|
Integer.toString(R.string.lock_screen_notifs_show_none));
|
||||||
|
|
||||||
|
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_NOTIFICATIONS, 1)).isEqualTo(0);
|
||||||
|
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 1)).isEqualTo(0);
|
||||||
|
|
||||||
|
assertThat(mPreference.getSummary())
|
||||||
|
.isEqualTo(mContext.getString(R.string.lock_screen_notifs_show_none));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user