Merge "Fix Wi-Fi QR code decode fail" into qt-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 3118403..f4ff282 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2680,6 +2680,7 @@
android:label=""
android:theme="@style/Transparent"
android:excludeFromRecents="true"
+ android:documentLaunchMode="always"
android:exported="true"
android:permission="android.permission.CHANGE_WIFI_STATE"
android:configChanges="orientation|keyboardHidden|screenSize">
@@ -3240,6 +3241,17 @@
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.fuelgauge.batterysaver.BatterySaverScheduleSettings" />
</activity>
+
+ <activity android:name="Settings$GlobalActionsPanelSettingsActivity"
+ android:label="@string/global_actions_panel_title">
+ <intent-filter>
+ <action android:name="com.android.settings.GLOBAL_ACTIONS_PANEL_SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.gestures.GlobalActionsPanelSettings" />
+ </activity>
+
<!-- This is the longest AndroidManifest.xml ever. -->
</application>
</manifest>
diff --git a/res/layout/profile_owner_add.xml b/res/layout/profile_owner_add.xml
index 84c51fd..2ee5dfc 100644
--- a/res/layout/profile_owner_add.xml
+++ b/res/layout/profile_owner_add.xml
@@ -27,12 +27,17 @@
android:layout_height="0dp"
android:layout_weight="1"
android:scrollbars = "vertical"
- android:padding="?dialogPreferredPadding"
+ android:paddingStart="24dp"
+ android:paddingEnd="24dp"
+ android:paddingTop="12dp"
+ android:paddingBottom="6dp"
android:gravity="center_vertical"/>
<TextView android:id="@+id/admin_warning_simplified"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingStart="?dialogPreferredPadding"
- android:paddingEnd="?dialogPreferredPadding"/>
+ android:paddingStart="24dp"
+ android:paddingEnd="24dp"
+ android:paddingTop="6dp"
+ android:paddingBottom="12dp"/>
</LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 8104498..5384cac 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -7974,6 +7974,32 @@
<!-- 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>
+
+ <!-- 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
shown in notifications shown on a secure lock screen
[CHAR LIMIT=50] -->
@@ -10223,8 +10249,6 @@
<string name="global_actions_panel_title" translatable="false">Show global actions</string>
<!-- Short title text for global actions panel [CHAR LIMIT=40] [DO NOT TRANSLATE]-->
<string name="global_actions_panel_short_title" translatable="false">Global actions</string>
- <!-- Footer text for global actions panel [CHAR LIMIT=NONE] [DO NOT TRANSLATE]-->
- <string name="global_actions_panel_footer" translatable="false">The global actions panel can be accessed even when the device is locked.</string>
<!-- Title text for swiping downwards on fingerprint sensor for notifications [CHAR LIMIT=80]-->
<string name="fingerprint_swipe_for_notifications_title">Swipe fingerprint for notifications</string>
diff --git a/res/xml/configure_notification_settings.xml b/res/xml/configure_notification_settings.xml
index 687fe83..224a910 100644
--- a/res/xml/configure_notification_settings.xml
+++ b/res/xml/configure_notification_settings.xml
@@ -26,27 +26,52 @@
settings:controller="com.android.settings.widget.VideoPreferenceController"
android:persistent="false" />
- <Preference
- android:key="gentle_notifications"
- android:title="@string/gentle_notifications_title"
- settings:controller="com.android.settings.notification.GentleNotificationsPreferenceController"
- android:fragment="com.android.settings.notification.GentleNotificationSettings"/>
+ <!-- Empty category to draw divider -->
+ <PreferenceCategory
+ android:key="all_notifications_divider"
+ android:order="2"/>
<PreferenceCategory
- android:key="configure_notifications_smart"
- android:title="@string/smart_notifications_title"
+ android:key="recent_notifications_category"
+ android:title="@string/recent_notifications"
+ settings:allowDividerAbove="false"
android:order="3">
- <SwitchPreference
- android:key="asst_capability_prioritizer"
- android:title="@string/asst_capability_prioritizer_title"
- android:summary="@string/asst_capability_prioritizer_summary"
- settings:controller="com.android.settings.notification.AssistantCapabilityPreferenceController" />
+ <!-- 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="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
- android:key="asst_capabilities_actions_replies"
- android:title="@string/asst_capabilities_actions_replies_title"
- android:summary="@string/asst_capabilities_actions_replies_summary"
- settings:controller="com.android.settings.notification.AssistantCapabilityPreferenceController" />
+ android:key="lock_screen_redact"
+ android:title="@string/lock_screen_notifs_redact"
+ android:summary="@string/lock_screen_notifs_redact_summary"
+ 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
@@ -54,19 +79,11 @@
android:order="15"
settings:initialExpandedChildrenCount="0">
- <com.android.settings.RestrictedListPreference
- android:key="swipe"
- android:title="@string/swipe_direction_title"
- android:entries="@array/swipe_direction_titles"
- android:entryValues="@array/swipe_direction_values"
- 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"/>
+ <SwitchPreference
+ android:key="asst_capabilities_actions_replies"
+ android:title="@string/asst_capabilities_actions_replies_title"
+ android:summary="@string/asst_capabilities_actions_replies_summary"
+ settings:controller="com.android.settings.notification.AssistantCapabilityPreferenceController" />
<!-- Notification badging -->
<SwitchPreference
@@ -102,45 +119,4 @@
settings:controller="com.android.settings.notification.ZenModePreferenceController"
settings:allowDividerAbove="false"/>
</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>
diff --git a/res/xml/global_actions_panel_settings.xml b/res/xml/global_actions_panel_settings.xml
index af155bc..2dc0fe9 100644
--- a/res/xml/global_actions_panel_settings.xml
+++ b/res/xml/global_actions_panel_settings.xml
@@ -33,8 +33,4 @@
app:controller="com.android.settings.gestures.GlobalActionsPanelPreferenceController"
app:allowDividerAbove="true" />
- <com.android.settingslib.widget.FooterPreference
- android:key="footer_preference"
- android:title="@string/global_actions_panel_footer" />
-
-</PreferenceScreen>
\ No newline at end of file
+</PreferenceScreen>
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index f6fe0c2..b4ebc57 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -165,6 +165,7 @@
public static class BluetoothDeviceDetailActivity extends SettingsActivity { /* empty */ }
public static class WifiCallingDisclaimerActivity extends SettingsActivity { /* empty */ }
public static class MobileNetworkListActivity extends SettingsActivity {}
+ public static class GlobalActionsPanelSettingsActivity extends SettingsActivity {}
// Top level categories for new IA
public static class NetworkDashboardActivity extends SettingsActivity {}
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 1dbae00..cb98892 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -36,6 +36,7 @@
import android.os.Handler;
import android.os.UserHandle;
import android.os.Vibrator;
+import android.provider.DeviceConfig;
import android.provider.SearchIndexableResource;
import android.provider.Settings;
import android.text.TextUtils;
@@ -168,6 +169,8 @@
private static final String ANIMATION_ON_VALUE = "1";
private static final String ANIMATION_OFF_VALUE = "0";
+ static final String RAMPING_RINGER_ENABLED = "ramping_ringer_enabled";
+
private final Map<String, String> mLongPressTimeoutValueToTitleMap = new HashMap<>();
private final Handler mHandler = new Handler();
@@ -389,6 +392,15 @@
: stateSummaryCombo;
}
+ @VisibleForTesting
+ static boolean isRampingRingerEnabled(final Context context) {
+ return (Settings.Global.getInt(
+ context.getContentResolver(),
+ Settings.Global.APPLY_RAMPING_RINGER, 0) == 1)
+ && DeviceConfig.getBoolean(
+ DeviceConfig.NAMESPACE_TELEPHONY, RAMPING_RINGER_ENABLED, false);
+ }
+
private void handleToggleTextContrastPreferenceClick() {
Settings.Secure.putInt(getContentResolver(),
Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED,
@@ -866,7 +878,7 @@
Settings.System.RING_VIBRATION_INTENSITY,
vibrator.getDefaultRingVibrationIntensity());
if (Settings.System.getInt(context.getContentResolver(),
- Settings.System.VIBRATE_WHEN_RINGING, 0) == 0) {
+ Settings.System.VIBRATE_WHEN_RINGING, 0) == 0 && !isRampingRingerEnabled(context)) {
ringIntensity = Vibrator.VIBRATION_INTENSITY_OFF;
}
CharSequence ringIntensityString =
diff --git a/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceController.java b/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceController.java
index 818c414..4dee348 100644
--- a/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceController.java
+++ b/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceController.java
@@ -29,7 +29,7 @@
public RingVibrationIntensityPreferenceController(Context context) {
super(context, PREF_KEY, Settings.System.RING_VIBRATION_INTENSITY,
- Settings.System.VIBRATE_WHEN_RINGING);
+ Settings.System.VIBRATE_WHEN_RINGING, /* supportRampingRinger= */ true);
}
@Override
diff --git a/src/com/android/settings/accessibility/RingVibrationPreferenceFragment.java b/src/com/android/settings/accessibility/RingVibrationPreferenceFragment.java
index 3e12011..babfb9a 100644
--- a/src/com/android/settings/accessibility/RingVibrationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/RingVibrationPreferenceFragment.java
@@ -46,7 +46,11 @@
@Override
protected String getVibrationEnabledSetting() {
- return Settings.System.VIBRATE_WHEN_RINGING;
+ if (AccessibilitySettings.isRampingRingerEnabled(getContext())) {
+ return Settings.Global.APPLY_RAMPING_RINGER;
+ } else {
+ return Settings.System.VIBRATE_WHEN_RINGING;
+ }
}
@Override
diff --git a/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java b/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java
index e52f92d..9d71176 100644
--- a/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java
+++ b/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java
@@ -40,15 +40,17 @@
private final SettingObserver mSettingsContentObserver;
private final String mSettingKey;
private final String mEnabledKey;
+ private final boolean mSupportRampingRinger;
private Preference mPreference;
public VibrationIntensityPreferenceController(Context context, String prefkey,
- String settingKey, String enabledKey) {
+ String settingKey, String enabledKey, boolean supportRampingRinger) {
super(context, prefkey);
mVibrator = mContext.getSystemService(Vibrator.class);
mSettingKey = settingKey;
mEnabledKey = enabledKey;
+ mSupportRampingRinger= supportRampingRinger;
mSettingsContentObserver = new SettingObserver(settingKey) {
@Override
public void onChange(boolean selfChange, Uri uri) {
@@ -57,6 +59,11 @@
};
}
+ public VibrationIntensityPreferenceController(Context context, String prefkey,
+ String settingKey, String enabledKey) {
+ this(context, prefkey, settingKey, enabledKey, /* supportRampingRinger= */ false);
+ }
+
@Override
public void onStart() {
mContext.getContentResolver().registerContentObserver(
@@ -80,10 +87,11 @@
public CharSequence getSummary() {
final int intensity = Settings.System.getInt(mContext.getContentResolver(),
mSettingKey, getDefaultIntensity());
- final boolean enabled = Settings.System.getInt(mContext.getContentResolver(),
- mEnabledKey, 1) == 1;
+ final boolean enabled = (Settings.System.getInt(mContext.getContentResolver(),
+ mEnabledKey, 1) == 1) ||
+ (mSupportRampingRinger && AccessibilitySettings.isRampingRingerEnabled(mContext));
return getIntensityString(mContext, enabled ? intensity : Vibrator.VIBRATION_INTENSITY_OFF);
- }
+ }
public static CharSequence getIntensityString(Context context, int intensity) {
final boolean supportsMultipleIntensities = context.getResources().getBoolean(
diff --git a/src/com/android/settings/accessibility/VibrationPreferenceFragment.java b/src/com/android/settings/accessibility/VibrationPreferenceFragment.java
index c23a25a..480041a 100644
--- a/src/com/android/settings/accessibility/VibrationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/VibrationPreferenceFragment.java
@@ -114,11 +114,20 @@
boolean vibrationEnabled = candidate.getIntensity() != Vibrator.VIBRATION_INTENSITY_OFF;
if (hasVibrationEnabledSetting()) {
// Update vibration enabled setting
- boolean wasEnabled = Settings.System.getInt(getContext().getContentResolver(),
- getVibrationEnabledSetting(), 1) == 1;
+ final String vibrationEnabledSetting = getVibrationEnabledSetting();
+ final boolean wasEnabled = TextUtils.equals(
+ vibrationEnabledSetting, Settings.Global.APPLY_RAMPING_RINGER)
+ ? true
+ : (Settings.System.getInt(
+ getContext().getContentResolver(), vibrationEnabledSetting, 1) == 1);
if (vibrationEnabled != wasEnabled) {
- Settings.System.putInt(getContext().getContentResolver(),
- getVibrationEnabledSetting(), vibrationEnabled ? 1 : 0);
+ if (vibrationEnabledSetting.equals(Settings.Global.APPLY_RAMPING_RINGER)) {
+ Settings.Global.putInt(getContext().getContentResolver(),
+ vibrationEnabledSetting, 0);
+ } else {
+ Settings.System.putInt(getContext().getContentResolver(),
+ vibrationEnabledSetting, vibrationEnabled ? 1 : 0);
+ }
}
}
// There are two conditions that need to change the intensity.
@@ -129,6 +138,13 @@
Settings.System.putInt(getContext().getContentResolver(),
getVibrationIntensitySetting(), candidate.getIntensity());
} 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();
}
}
@@ -189,8 +205,12 @@
protected String getDefaultKey() {
int vibrationIntensity = Settings.System.getInt(getContext().getContentResolver(),
getVibrationIntensitySetting(), getDefaultVibrationIntensity());
- final boolean vibrationEnabled = Settings.System.getInt(getContext().getContentResolver(),
- getVibrationEnabledSetting(), 1) == 1;
+ final String vibrationEnabledSetting = getVibrationEnabledSetting();
+ final boolean vibrationEnabled = TextUtils.equals(
+ vibrationEnabledSetting, Settings.Global.APPLY_RAMPING_RINGER)
+ ? true
+ : (Settings.System.getInt(
+ getContext().getContentResolver(), vibrationEnabledSetting, 1) == 1);
if (!vibrationEnabled) {
vibrationIntensity = Vibrator.VIBRATION_INTENSITY_OFF;
}
diff --git a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java
index 0d0bd20..8b06975 100644
--- a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java
+++ b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java
@@ -312,7 +312,7 @@
addAndFinish();
}
})
- .setNeutralButton(R.string.cancel, null)
+ .setNegativeButton(R.string.cancel, null)
.setOnDismissListener(new DialogInterface.OnDismissListener() {
public void onDismiss(DialogInterface dialogInterface) {
finish();
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
index ce5c768..9b12309 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
@@ -49,6 +49,7 @@
import com.google.android.setupcompat.template.FooterBarMixin;
import com.google.android.setupcompat.template.FooterButton;
+import com.google.android.setupdesign.util.DescriptionStyler;
/**
* Activity which handles the actual enrolling for fingerprint.
@@ -137,6 +138,7 @@
mProgressBar = (ProgressBar) findViewById(R.id.fingerprint_progress_bar);
mVibrator = getSystemService(Vibrator.class);
+ DescriptionStyler.applyPartnerCustomizationStyle(mRepeatMessage);
mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
mFooterBarMixin.setSecondaryButton(
new FooterButton.Builder(this)
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index d073dbc..b35a974 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -83,6 +83,7 @@
import com.android.settings.gestures.DoubleTapPowerSettings;
import com.android.settings.gestures.DoubleTapScreenSettings;
import com.android.settings.gestures.DoubleTwistGestureSettings;
+import com.android.settings.gestures.GlobalActionsPanelSettings;
import com.android.settings.gestures.PickupGestureSettings;
import com.android.settings.gestures.SwipeToNotificationSettings;
import com.android.settings.gestures.SystemNavigationGestureSettings;
@@ -279,7 +280,8 @@
ToggleBackupSettingFragment.class.getName(),
PreviouslyConnectedDeviceDashboardFragment.class.getName(),
BatterySaverScheduleSettings.class.getName(),
- MobileNetworkListFragment.class.getName()
+ MobileNetworkListFragment.class.getName(),
+ GlobalActionsPanelSettings.class.getName()
};
public static final String[] SETTINGS_FOR_RESTRICTED = {
diff --git a/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceController.java b/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceController.java
index 4aaa490..81efaa6 100644
--- a/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceController.java
+++ b/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceController.java
@@ -82,10 +82,10 @@
private boolean isDefaultEnabled() {
// The default in the absence of user preference is settable via DeviceConfig.
- // Note that the default default is enabled.
+ // Note that the default default is disabled.
return DeviceConfig.getBoolean(
DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
KEY_DEFAULT_BACKGROUND_ACTIVITY_STARTS_ENABLED,
- /*defaultValue*/ true);
+ /*defaultValue*/ false);
}
}
diff --git a/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java b/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java
index ddc3ad6..537c705 100644
--- a/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java
@@ -120,7 +120,7 @@
private CharSequence getFirstPhoneNumber() {
final List<SubscriptionInfo> subscriptionInfoList =
mSubscriptionManager.getActiveSubscriptionInfoList(true);
- if (subscriptionInfoList == null) {
+ if (subscriptionInfoList == null || subscriptionInfoList.isEmpty()) {
return mContext.getText(R.string.device_info_default);
}
diff --git a/src/com/android/settings/network/telephony/MobileNetworkUtils.java b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
index 0c099ca..c0b4590 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkUtils.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
@@ -277,8 +277,7 @@
return true;
}
- if (settingsNetworkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA
- && !isTdscdmaSupported(context, telephonyManager)) {
+ if (shouldSpeciallyUpdateGsmCdma(context, subId)) {
return true;
}
}
@@ -296,16 +295,15 @@
if (isGsmBasicOptions(context, subId)) {
return true;
}
- final int settingsNetworkMode = android.provider.Settings.Global.getInt(
+ final int networkMode = android.provider.Settings.Global.getInt(
context.getContentResolver(),
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + subId,
Phone.PREFERRED_NT_MODE);
if (isWorldMode(context, subId)) {
- if (settingsNetworkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO
- || settingsNetworkMode == TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA) {
+ if (networkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO
+ || networkMode == TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA) {
return true;
- } else if (settingsNetworkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA
- && !MobileNetworkUtils.isTdscdmaSupported(context, subId)) {
+ } else if (shouldSpeciallyUpdateGsmCdma(context, subId)) {
return true;
}
}
@@ -362,16 +360,24 @@
return false;
}
+ final int networkMode = android.provider.Settings.Global.getInt(
+ context.getContentResolver(),
+ android.provider.Settings.Global.PREFERRED_NETWORK_MODE + subId,
+ Phone.PREFERRED_NT_MODE);
+ if (networkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO
+ && isWorldMode(context, subId)) {
+ return false;
+ }
+ if (shouldSpeciallyUpdateGsmCdma(context, subId)) {
+ return false;
+ }
+
if (isGsmBasicOptions(context, subId)) {
return true;
}
- final int settingsNetworkMode = android.provider.Settings.Global.getInt(
- context.getContentResolver(),
- android.provider.Settings.Global.PREFERRED_NETWORK_MODE + subId,
- Phone.PREFERRED_NT_MODE);
if (isWorldMode(context, subId)) {
- if (settingsNetworkMode == TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA) {
+ if (networkMode == TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA) {
return true;
}
}
@@ -414,7 +420,6 @@
return false;
}
-
/**
* Return subId that supported by search. If there are more than one, return first one,
* otherwise return {@link SubscriptionManager#INVALID_SUBSCRIPTION_ID}
@@ -461,4 +466,33 @@
}
}
}
+
+ /**
+ * This method is migrated from {@link com.android.phone.MobileNetworkSettings} and we should
+ * use it carefully. This code snippet doesn't have very clear meaning however we should
+ * update GSM or CDMA differently based on what it returns.
+ *
+ * 1. For all CDMA settings, make them visible if it return {@code true}
+ * 2. For GSM settings, make them visible if it return {@code true} unless 3
+ * 3. For network select settings, make it invisible if it return {@code true}
+ */
+ @VisibleForTesting
+ static boolean shouldSpeciallyUpdateGsmCdma(Context context, int subId) {
+ final int networkMode = android.provider.Settings.Global.getInt(
+ context.getContentResolver(),
+ android.provider.Settings.Global.PREFERRED_NETWORK_MODE + subId,
+ Phone.PREFERRED_NT_MODE);
+ if (networkMode == TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_GSM
+ || networkMode == TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA
+ || networkMode == TelephonyManager.NETWORK_MODE_LTE_TDSCDMA
+ || networkMode == TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_WCDMA
+ || networkMode == TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA
+ || networkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA) {
+ if (!isTdscdmaSupported(context, subId) && isWorldMode(context, subId)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
}
diff --git a/src/com/android/settings/notification/AppBubbleNotificationSettings.java b/src/com/android/settings/notification/AppBubbleNotificationSettings.java
index f55c262..2517573 100644
--- a/src/com/android/settings/notification/AppBubbleNotificationSettings.java
+++ b/src/com/android/settings/notification/AppBubbleNotificationSettings.java
@@ -61,7 +61,10 @@
Context context, AppBubbleNotificationSettings fragment) {
List<NotificationPreferenceController> controllers = new ArrayList<>();
controllers.add(new HeaderPreferenceController(context, fragment));
- controllers.add(new BubblePreferenceController(context, new NotificationBackend()));
+ controllers.add(new BubblePreferenceController(context, fragment != null
+ ? fragment.getChildFragmentManager()
+ : null,
+ new NotificationBackend(), true /* isAppPage */));
return controllers;
}
diff --git a/src/com/android/settings/notification/BubblePreferenceController.java b/src/com/android/settings/notification/BubblePreferenceController.java
index 200c4b2..b68f11d 100644
--- a/src/com/android/settings/notification/BubblePreferenceController.java
+++ b/src/com/android/settings/notification/BubblePreferenceController.java
@@ -18,6 +18,7 @@
import static android.provider.Settings.Secure.NOTIFICATION_BUBBLES;
+import android.annotation.Nullable;
import android.content.Context;
import android.provider.Settings;
@@ -40,15 +41,13 @@
static final int SYSTEM_WIDE_OFF = 0;
private FragmentManager mFragmentManager;
+ private boolean mIsAppPage;
- public BubblePreferenceController(Context context, NotificationBackend backend) {
- super(context, backend);
- }
-
- public BubblePreferenceController(Context context, FragmentManager fragmentManager,
- NotificationBackend backend) {
+ public BubblePreferenceController(Context context, @Nullable FragmentManager fragmentManager,
+ NotificationBackend backend, boolean isAppPage) {
super(context, backend);
mFragmentManager = fragmentManager;
+ mIsAppPage = isAppPage;
}
@Override
@@ -61,7 +60,7 @@
if (!super.isAvailable()) {
return false;
}
- if (!isGloballyEnabled()) {
+ if (!mIsAppPage && !isGloballyEnabled()) {
return false;
}
if (mChannel != null) {
@@ -96,7 +95,7 @@
mChannel.setAllowBubbles(value);
saveChannel();
return true;
- } else if (mAppRow != null) {
+ } else if (mAppRow != null && mFragmentManager != null) {
RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
// if the global setting is off, toggling app level permission requires extra
// confirmation
diff --git a/src/com/android/settings/notification/ChannelNotificationSettings.java b/src/com/android/settings/notification/ChannelNotificationSettings.java
index 9f9d438..8399a49 100644
--- a/src/com/android/settings/notification/ChannelNotificationSettings.java
+++ b/src/com/android/settings/notification/ChannelNotificationSettings.java
@@ -114,7 +114,8 @@
mControllers.add(new BadgePreferenceController(context, mBackend));
mControllers.add(new DndPreferenceController(context, mBackend));
mControllers.add(new NotificationsOffPreferenceController(context));
- mControllers.add(new BubblePreferenceController(context, mBackend));
+ mControllers.add(new BubblePreferenceController(context, getChildFragmentManager(),
+ mBackend, false /* isAppPage */));
return new ArrayList<>(mControllers);
}
}
diff --git a/src/com/android/settings/notification/ConfigureNotificationSettings.java b/src/com/android/settings/notification/ConfigureNotificationSettings.java
index 5f9cf5f..d21be16 100644
--- a/src/com/android/settings/notification/ConfigureNotificationSettings.java
+++ b/src/com/android/settings/notification/ConfigureNotificationSettings.java
@@ -58,16 +58,8 @@
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
static final String KEY_SWIPE_DOWN = "gesture_swipe_down_fingerprint_notifications";
- @VisibleForTesting
- static final String KEY_NOTIFICATION_ASSISTANT = "notification_assistant";
+ static final String KEY_LOCKSCREEN = "lock_screen_notifications";
private static final String KEY_NOTI_DEFAULT_RINGTONE = "notification_default_ringtone";
private static final int REQUEST_CODE = 200;
@@ -100,25 +92,18 @@
} else {
app = null;
}
- return buildPreferenceControllers(context, getSettingsLifecycle(), app, this);
+ return buildPreferenceControllers(context, app, this);
}
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
- Lifecycle lifecycle, Application app, Fragment host) {
+ Application app, Fragment host) {
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(
context, new NotificationBackend(), IUsageStatsManager.Stub.asInterface(
ServiceManager.getService(Context.USAGE_STATS_SERVICE)),
context.getSystemService(UserManager.class), app, host));
- controllers.add(lockScreenNotificationController);
+ controllers.add(new ShowOnLockScreenNotificationPreferenceController(
+ context, KEY_LOCKSCREEN));
controllers.add(new NotificationRingtonePreferenceController(context) {
@Override
public String getPreferenceKey() {
@@ -245,7 +230,7 @@
@Override
public List<AbstractPreferenceController> createPreferenceControllers(
Context context) {
- return buildPreferenceControllers(context, null, null, null);
+ return buildPreferenceControllers(context, null, null);
}
@Override
diff --git a/src/com/android/settings/notification/NotificationSettingsBase.java b/src/com/android/settings/notification/NotificationSettingsBase.java
index 32d8e91..fdd71e5 100644
--- a/src/com/android/settings/notification/NotificationSettingsBase.java
+++ b/src/com/android/settings/notification/NotificationSettingsBase.java
@@ -53,6 +53,7 @@
import com.android.settings.R;
import com.android.settings.SettingsActivity;
+import com.android.settings.Utils;
import com.android.settings.applications.AppInfoBase;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.dashboard.DashboardFragment;
@@ -279,6 +280,12 @@
return null;
}
+ private Drawable getAlertingIcon() {
+ Drawable icon = getContext().getDrawable(R.drawable.ic_notifications);
+ icon.setTintList(Utils.getColorAccent(getContext()));
+ return icon;
+ }
+
protected Preference populateSingleChannelPrefs(PreferenceGroup parent,
final NotificationChannel channel, final boolean groupBlocked) {
MasterSwitchPreference channelPref = new MasterSwitchPreference(getPrefContext());
@@ -286,8 +293,10 @@
&& isChannelBlockable(channel)
&& isChannelConfigurable(channel)
&& !groupBlocked);
- channelPref.setIcon(channel.getImportance() > IMPORTANCE_LOW
- ? R.drawable.ic_notification_alert : R.drawable.ic_notification_silence);
+ channelPref.setIcon(null);
+ if (channel.getImportance() > IMPORTANCE_LOW) {
+ channelPref.setIcon(getAlertingIcon());
+ }
channelPref.setIconSize(MasterSwitchPreference.ICON_SIZE_SMALL);
channelPref.setKey(channel.getId());
channelPref.setTitle(channel.getName());
@@ -314,9 +323,10 @@
channel.lockFields(
NotificationChannel.USER_LOCKED_IMPORTANCE);
MasterSwitchPreference channelPref1 = (MasterSwitchPreference) preference;
- channelPref1.setIcon(channel.getImportance() > IMPORTANCE_LOW
- ? R.drawable.ic_notification_alert
- : R.drawable.ic_notification_silence);
+ channelPref1.setIcon(null);
+ if (channel.getImportance() > IMPORTANCE_LOW) {
+ channelPref1.setIcon(getAlertingIcon());
+ }
toggleBehaviorIconState(channelPref1.getIcon(),
importance != IMPORTANCE_NONE);
mBackend.updateChannel(mPkg, mUid, channel);
@@ -330,9 +340,14 @@
}
private void toggleBehaviorIconState(Drawable icon, boolean enabled) {
+ if (icon == null) return;
+
LayerDrawable layerDrawable = (LayerDrawable) icon;
GradientDrawable background =
(GradientDrawable) layerDrawable.findDrawableByLayerId(R.id.back);
+
+ if (background == null) return;
+
if (enabled) {
background.clearColorFilter();
} else {
diff --git a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
index d5e1723..8b5b761 100644
--- a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
+++ b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
@@ -71,7 +71,7 @@
static final String KEY_DIVIDER = "all_notifications_divider";
@VisibleForTesting
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 Set<String> SKIP_SYSTEM_PACKAGES = new ArraySet<>();
diff --git a/src/com/android/settings/notification/RedactNotificationPreferenceController.java b/src/com/android/settings/notification/RedactNotificationPreferenceController.java
new file mode 100644
index 0000000..94d7fc1
--- /dev/null
+++ b/src/com/android/settings/notification/RedactNotificationPreferenceController.java
@@ -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;
+ }
+}
diff --git a/src/com/android/settings/notification/ShowOnLockScreenNotificationPreferenceController.java b/src/com/android/settings/notification/ShowOnLockScreenNotificationPreferenceController.java
new file mode 100644
index 0000000..5d08ac7
--- /dev/null
+++ b/src/com/android/settings/notification/ShowOnLockScreenNotificationPreferenceController.java
@@ -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;
+ }
+}
diff --git a/src/com/android/settings/panel/PanelFeatureProviderImpl.java b/src/com/android/settings/panel/PanelFeatureProviderImpl.java
index 67c300f..e6b0a23 100644
--- a/src/com/android/settings/panel/PanelFeatureProviderImpl.java
+++ b/src/com/android/settings/panel/PanelFeatureProviderImpl.java
@@ -25,6 +25,10 @@
@Override
public PanelContent getPanel(Context context, String panelType, String mediaPackageName) {
+ if (context == null) {
+ return null;
+ }
+
switch (panelType) {
case Settings.Panel.ACTION_INTERNET_CONNECTIVITY:
return InternetConnectivityPanel.create(context);
diff --git a/src/com/android/settings/panel/PanelFragment.java b/src/com/android/settings/panel/PanelFragment.java
index e9eeb8d..79d1ac5 100644
--- a/src/com/android/settings/panel/PanelFragment.java
+++ b/src/com/android/settings/panel/PanelFragment.java
@@ -170,6 +170,10 @@
.getPanelFeatureProvider()
.getPanel(activity, panelType, mediaPackageName);
+ if (mPanel == null) {
+ activity.finish();
+ }
+
mMetricsProvider = FeatureFactory.getFactory(activity).getMetricsFeatureProvider();
mPanelSlices.setLayoutManager(new LinearLayoutManager((activity)));
diff --git a/src/com/android/settings/slices/SliceBuilderUtils.java b/src/com/android/settings/slices/SliceBuilderUtils.java
index cf45d57..0e51032 100644
--- a/src/com/android/settings/slices/SliceBuilderUtils.java
+++ b/src/com/android/settings/slices/SliceBuilderUtils.java
@@ -300,6 +300,10 @@
private static Slice buildSliderSlice(Context context, SliceData sliceData,
BasePreferenceController controller) {
final SliderPreferenceController sliderController = (SliderPreferenceController) controller;
+ if (sliderController.getMax() <= sliderController.getMin()) {
+ Log.e(TAG, "Invalid sliderController: " + sliderController.getPreferenceKey());
+ return null;
+ }
final PendingIntent actionIntent = getSliderAction(context, sliceData);
final PendingIntent contentIntent = getContentPendingIntent(context, sliceData);
final IconCompat icon = getSafeIcon(context, sliceData);
diff --git a/src/com/android/settings/widget/VideoPreference.java b/src/com/android/settings/widget/VideoPreference.java
index ca3e5cc..1af9065 100644
--- a/src/com/android/settings/widget/VideoPreference.java
+++ b/src/com/android/settings/widget/VideoPreference.java
@@ -24,10 +24,12 @@
import android.net.Uri;
import android.util.AttributeSet;
import android.util.Log;
+import android.util.TypedValue;
import android.view.Surface;
import android.view.TextureView;
import android.view.View;
import android.widget.ImageView;
+import android.widget.LinearLayout;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
@@ -51,11 +53,12 @@
@VisibleForTesting
boolean mVideoReady;
private boolean mVideoPaused;
- private float mAspectRadio = 1.0f;
+ private float mAspectRatio = 1.0f;
private int mPreviewResource;
private boolean mViewVisible;
private Surface mSurface;
private int mAnimationId;
+ private int mHeight = LinearLayout.LayoutParams.MATCH_PARENT - 1; // video height in pixels
public VideoPreference(Context context) {
super(context);
@@ -121,7 +124,11 @@
R.id.video_container);
imageView.setImageResource(mPreviewResource);
- layout.setAspectRatio(mAspectRadio);
+ layout.setAspectRatio(mAspectRatio);
+ if (mHeight >= LinearLayout.LayoutParams.MATCH_PARENT) {
+ layout.setLayoutParams(new LinearLayout.LayoutParams(
+ LinearLayout.LayoutParams.MATCH_PARENT, mHeight));
+ }
updateViewStates(imageView, playButton);
video.setOnClickListener(v -> updateViewStates(imageView, playButton));
@@ -247,8 +254,17 @@
return mVideoPaused;
}
+ /**
+ * sets the height of the video preference
+ * @param height in dp
+ */
+ public void setHeight(float height) {
+ mHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, height,
+ mContext.getResources().getDisplayMetrics());
+ }
+
@VisibleForTesting
void updateAspectRatio() {
- mAspectRadio = mMediaPlayer.getVideoWidth() / (float) mMediaPlayer.getVideoHeight();
+ mAspectRatio = mMediaPlayer.getVideoWidth() / (float) mMediaPlayer.getVideoHeight();
}
}
diff --git a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
index 5f3cbb2..5e49b2e 100644
--- a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
@@ -54,7 +54,6 @@
import androidx.annotation.VisibleForTesting;
import androidx.core.text.BidiFormatter;
-import androidx.fragment.app.Fragment;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceFragmentCompat;
@@ -151,7 +150,7 @@
private AccessPoint mAccessPoint;
private final ConnectivityManager mConnectivityManager;
- private final Fragment mFragment;
+ private final PreferenceFragmentCompat mFragment;
private final Handler mHandler;
private LinkProperties mLinkProperties;
private Network mNetwork;
@@ -296,7 +295,7 @@
AccessPoint accessPoint,
ConnectivityManager connectivityManager,
Context context,
- Fragment fragment,
+ PreferenceFragmentCompat fragment,
Handler handler,
Lifecycle lifecycle,
WifiManager wifiManager,
@@ -311,7 +310,7 @@
AccessPoint accessPoint,
ConnectivityManager connectivityManager,
Context context,
- Fragment fragment,
+ PreferenceFragmentCompat fragment,
Handler handler,
Lifecycle lifecycle,
WifiManager wifiManager,
@@ -441,9 +440,11 @@
if (usingDataUsageHeader(mContext)) {
mSummaryHeaderController.updateState(mDataUsageSummaryPref);
} else {
- mEntityHeaderController.setSummary(
- mAccessPoint.getSettingsSummary(true /*convertSavedAsDisconnected*/))
- .done(mFragment.getActivity(), true /* rebind */);
+ mEntityHeaderController
+ .setSummary(
+ mAccessPoint.getSettingsSummary(true /*convertSavedAsDisconnected*/))
+ .setRecyclerView(mFragment.getListView(), mLifecycle)
+ .done(mFragment.getActivity(), true /* rebind */);
}
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java
index 43bdc30..5813bd8 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java
@@ -25,12 +25,14 @@
import android.content.ContentResolver;
import android.content.Context;
import android.os.Vibrator;
+import android.provider.DeviceConfig;
import android.provider.Settings;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.testutils.XmlTestUtils;
+import com.android.settings.testutils.shadow.ShadowDeviceConfig;
import org.junit.Before;
import org.junit.Test;
@@ -38,6 +40,7 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
import java.util.List;
@@ -135,6 +138,32 @@
}
}
+ @Test
+ @Config(shadows = {ShadowDeviceConfig.class})
+ public void testIsRampingRingerEnabled_bothFlagsOn_Enabled() {
+ Settings.Global.putInt(
+ mContext.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, 1 /* ON */);
+ DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TELEPHONY,
+ AccessibilitySettings.RAMPING_RINGER_ENABLED, "true", false /* makeDefault*/);
+ assertThat(AccessibilitySettings.isRampingRingerEnabled(mContext)).isTrue();
+ }
+
+ @Test
+ @Config(shadows = {ShadowDeviceConfig.class})
+ public void testIsRampingRingerEnabled_settingsFlagOff_Disabled() {
+ Settings.Global.putInt(
+ mContext.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, 0 /* OFF */);
+ assertThat(AccessibilitySettings.isRampingRingerEnabled(mContext)).isFalse();
+ }
+
+ @Test
+ @Config(shadows = {ShadowDeviceConfig.class})
+ public void testIsRampingRingerEnabled_deviceConfigFlagOff_Disabled() {
+ DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TELEPHONY,
+ AccessibilitySettings.RAMPING_RINGER_ENABLED, "false", false /* makeDefault*/);
+ assertThat(AccessibilitySettings.isRampingRingerEnabled(mContext)).isFalse();
+ }
+
private void verifyAccessibilityTimeoutSummary(String preferenceKey, int resId) {
final Preference preference = new Preference(mContext);
doReturn(preference).when(mSettings).findPreference(preferenceKey);
diff --git a/tests/robotests/src/com/android/settings/accessibility/RingVibrationPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/RingVibrationPreferenceFragmentTest.java
new file mode 100644
index 0000000..d23d2f0
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/RingVibrationPreferenceFragmentTest.java
@@ -0,0 +1,71 @@
+/*
+ * 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.accessibility;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.provider.DeviceConfig;
+import android.provider.Settings;
+
+import com.android.settings.testutils.shadow.ShadowDeviceConfig;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(RobolectricTestRunner.class)
+public class RingVibrationPreferenceFragmentTest {
+
+ private Context mContext;
+ private RingVibrationPreferenceFragment mFragment;
+
+ @Before
+ public void setUp() {
+ mContext = RuntimeEnvironment.application;
+ mFragment = spy(new RingVibrationPreferenceFragment());
+ doReturn(mContext).when(mFragment).getContext();
+ }
+
+ @Test
+ @Config(shadows = {ShadowDeviceConfig.class})
+ public void getVibrationEnabledSetting_rampingRingerEnabled_returnApplyRampingRinger() {
+ // Turn on both flags to enable ramping ringer.
+ Settings.Global.putInt(
+ mContext.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, 1 /* ON */);
+ DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TELEPHONY,
+ AccessibilitySettings.RAMPING_RINGER_ENABLED, "true", false /* makeDefault*/);
+ assertThat(mFragment.getVibrationEnabledSetting()).isEqualTo(
+ Settings.Global.APPLY_RAMPING_RINGER);
+ }
+
+ @Test
+ public void getVibrationEnabledSetting_rampingRingerDisabled_returnVibrationWhenRinging() {
+ // Turn off Settings.Global.APPLY_RAMPING_RINGER to disable ramping ringer.
+ Settings.Global.putInt(
+ mContext.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, 0 /* OFF */);
+ assertThat(mFragment.getVibrationEnabledSetting()).isEqualTo(
+ Settings.System.VIBRATE_WHEN_RINGING);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceControllerTest.java
index afe0848..8165862 100644
--- a/tests/robotests/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceControllerTest.java
@@ -115,7 +115,7 @@
public void onDeveloperOptionsSwitchDisabled_noDefault_shouldResetPreference() {
mController.onDeveloperOptionsSwitchDisabled();
- verify(mPreference).setChecked(true);
+ verify(mPreference).setChecked(false);
verify(mPreference).setEnabled(false);
assertThat(getModeFroMSettings()).isEqualTo(-1);
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java
index 023135d..3e6e436 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java
@@ -150,6 +150,16 @@
}
@Test
+ public void getSummary_getEmptySubscriptionInfo_shouldShowUnknown() {
+ List<SubscriptionInfo> infos = new ArrayList<>();
+ when(mSubscriptionManager.getActiveSubscriptionInfoList(eq(true))).thenReturn(infos);
+
+ CharSequence primaryNumber = mController.getSummary();
+
+ assertThat(primaryNumber).isEqualTo(mContext.getString(R.string.device_info_default));
+ }
+
+ @Test
public void isSliceable_shouldBeTrue() {
assertThat(mController.isSliceable()).isTrue();
}
diff --git a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java
index 61599e6..2bfaeca 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java
@@ -219,4 +219,86 @@
assertThat(MobileNetworkUtils.shouldDisplayNetworkSelectOptions(mContext, SUB_ID_1))
.isTrue();
}
+
+ @Test
+ public void shouldSpeciallyUpdateGsmCdma_notWorldMode_returnFalse() {
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, false);
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, false);
+
+ assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isFalse();
+ }
+
+ @Test
+ public void shouldSpeciallyUpdateGsmCdma_supportTdscdma_returnFalse() {
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, true);
+
+ assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isFalse();
+ }
+
+ @Test
+ public void shouldSpeciallyUpdateGsmCdma_ModeLteTdscdmaGsm_returnTrue() {
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, false);
+
+ Settings.Global.putInt(mContext.getContentResolver(),
+ android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
+ TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_GSM);
+ assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
+ }
+
+ @Test
+ public void shouldSpeciallyUpdateGsmCdma_ModeLteTdscdmaGsmWcdma_returnTrue() {
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, false);
+
+ Settings.Global.putInt(mContext.getContentResolver(),
+ android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
+ TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA);
+ assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
+ }
+
+ @Test
+ public void shouldSpeciallyUpdateGsmCdma_ModeLteTdscdma_returnTrue() {
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, false);
+
+ Settings.Global.putInt(mContext.getContentResolver(),
+ android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
+ TelephonyManager.NETWORK_MODE_LTE_TDSCDMA);
+ assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
+ }
+
+ @Test
+ public void shouldSpeciallyUpdateGsmCdma_ModeLteTdscdmaWcdma_returnTrue() {
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, false);
+
+ Settings.Global.putInt(mContext.getContentResolver(),
+ android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
+ TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_WCDMA);
+ assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
+ }
+
+ @Test
+ public void shouldSpeciallyUpdateGsmCdma_ModeLteTdscdmaCdmaEvdoGsmWcdma_returnTrue() {
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, false);
+
+ Settings.Global.putInt(mContext.getContentResolver(),
+ android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
+ TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA);
+ assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
+ }
+
+ @Test
+ public void shouldSpeciallyUpdateGsmCdma_ModeLteCdmaEvdoGsmWcdma_returnTrue() {
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, false);
+
+ Settings.Global.putInt(mContext.getContentResolver(),
+ android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
+ TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA);
+ assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/notification/BubblePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/BubblePreferenceControllerTest.java
index 67324e9..aafefb51 100644
--- a/tests/robotests/src/com/android/settings/notification/BubblePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/BubblePreferenceControllerTest.java
@@ -78,6 +78,7 @@
private FragmentManager mFragmentManager;
private BubblePreferenceController mController;
+ private BubblePreferenceController mAppPageController;
@Before
public void setUp() {
@@ -87,7 +88,10 @@
shadowApplication.setSystemService(Context.USER_SERVICE, mUm);
mContext = RuntimeEnvironment.application;
when(mFragmentManager.beginTransaction()).thenReturn(mock(FragmentTransaction.class));
- mController = spy(new BubblePreferenceController(mContext, mFragmentManager, mBackend));
+ mController = spy(new BubblePreferenceController(mContext, mFragmentManager, mBackend,
+ false /* isAppPage */));
+ mAppPageController = spy(new BubblePreferenceController(mContext, mFragmentManager,
+ mBackend, true /* isAppPage */));
}
@Test
@@ -151,6 +155,16 @@
}
@Test
+ public void testIsAvailable_app_evenIfOffGlobally() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ mAppPageController.onResume(appRow, null, null, null);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ NOTIFICATION_BUBBLES, SYSTEM_WIDE_OFF);
+
+ assertTrue(mAppPageController.isAvailable());
+ }
+
+ @Test
public void testIsAvailable_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
mController.onResume(appRow, null, null, null);
diff --git a/tests/robotests/src/com/android/settings/notification/ConfigureNotificationSettingsTest.java b/tests/robotests/src/com/android/settings/notification/ConfigureNotificationSettingsTest.java
index 6910297..523b496 100644
--- a/tests/robotests/src/com/android/settings/notification/ConfigureNotificationSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ConfigureNotificationSettingsTest.java
@@ -16,14 +16,7 @@
package com.android.settings.notification;
-import static com.android.settings.notification.ConfigureNotificationSettings.KEY_LOCKSCREEN;
-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.android.settings.notification.ConfigureNotificationSettings.SUMMARY_PROVIDER_FACTORY;
import static com.google.common.truth.Truth.assertThat;
@@ -37,8 +30,6 @@
import com.android.settings.dashboard.SummaryLoader;
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.Test;
@@ -46,10 +37,6 @@
import org.mockito.ArgumentCaptor;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-
-import java.util.List;
@RunWith(RobolectricTestRunner.class)
public class ConfigureNotificationSettingsTest {
@@ -62,20 +49,6 @@
}
@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
public void getSummary_noneBlocked() {
SummaryLoader loader = mock(SummaryLoader.class);
NotificationBackend backend = mock(NotificationBackend.class);
diff --git a/tests/robotests/src/com/android/settings/notification/RedactNotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/RedactNotificationPreferenceControllerTest.java
new file mode 100644
index 0000000..49f6bd6
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/RedactNotificationPreferenceControllerTest.java
@@ -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);
+ }
+}
+
diff --git a/tests/robotests/src/com/android/settings/notification/ShowOnLockscreenNotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ShowOnLockscreenNotificationPreferenceControllerTest.java
new file mode 100644
index 0000000..6907051
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/ShowOnLockscreenNotificationPreferenceControllerTest.java
@@ -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));
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java b/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
index 2e47930..1db7c8d 100644
--- a/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
@@ -43,6 +43,7 @@
import com.android.settings.core.BasePreferenceController;
import com.android.settings.testutils.FakeCopyableController;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.FakeInvalidSliderController;
import com.android.settings.testutils.FakeSliderController;
import com.android.settings.testutils.FakeToggleController;
import com.android.settings.testutils.FakeUnavailablePreferenceController;
@@ -67,6 +68,7 @@
private final Uri URI = Uri.parse("content://com.android.settings.slices/test");
private final Class TOGGLE_CONTROLLER = FakeToggleController.class;
private final Class SLIDER_CONTROLLER = FakeSliderController.class;
+ private final Class INVALID_SLIDER_CONTROLLER = FakeInvalidSliderController.class;
private final Class COPYABLE_CONTROLLER = FakeCopyableController.class;
private final Class CONTEXT_CONTROLLER = FakeContextOnlyPreferenceController.class;
@@ -471,6 +473,14 @@
}
@Test
+ public void buildSliderSlice_invalidSlider_returnNull() {
+ final SliceData data = getDummyData(INVALID_SLIDER_CONTROLLER, SliceData.SliceType.SLIDER,
+ 0x0 /* icon */);
+
+ assertThat(SliceBuilderUtils.buildSlice(mContext, data)).isNull();
+ }
+
+ @Test
public void getSafeIcon_replacesEmptyIconWithSettingsIcon() {
final int settingsIcon = R.drawable.ic_settings_accent;
final int zeroIcon = 0x0;
diff --git a/tests/robotests/src/com/android/settings/testutils/FakeInvalidSliderController.java b/tests/robotests/src/com/android/settings/testutils/FakeInvalidSliderController.java
new file mode 100644
index 0000000..cb49f65
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/testutils/FakeInvalidSliderController.java
@@ -0,0 +1,31 @@
+/*
+ * 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.testutils;
+
+import android.content.Context;
+
+public class FakeInvalidSliderController extends FakeSliderController {
+
+ public FakeInvalidSliderController(Context context, String key) {
+ super(context, key);
+ }
+
+ @Override
+ public int getMax() {
+ // Return 0 to make it invalid
+ return 0;
+ }
+}