diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 2884162d74d..92819d86ccd 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -727,6 +727,10 @@
+
+
+
+
@@ -752,23 +756,6 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
diff --git a/res/layout/gesture_preference.xml b/res/layout/gesture_preference.xml
deleted file mode 100644
index ccbc42ad256..00000000000
--- a/res/layout/gesture_preference.xml
+++ /dev/null
@@ -1,104 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/res/layout/preference_volume_slider.xml b/res/layout/preference_volume_slider.xml
index 89ecec02c5b..5e5d595108a 100644
--- a/res/layout/preference_volume_slider.xml
+++ b/res/layout/preference_volume_slider.xml
@@ -45,8 +45,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
- android:layout_marginTop="8dip"
- android:layout_marginBottom="8dip">
+ android:layout_marginTop="16dip"
+ android:layout_marginBottom="16dip">
+ android:layout_height="240dp">
160dp
-
- 35dp
-
diff --git a/res/values/bools.xml b/res/values/bools.xml
index 61a3c75b77e..29de06bceae 100644
--- a/res/values/bools.xml
+++ b/res/values/bools.xml
@@ -78,6 +78,9 @@
true
+
+ true
+
true
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index f95de27f525..e0b8c48d47f 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -288,7 +288,6 @@
20dp
36dp
- 0dp
14sp
diff --git a/res/values/strings.xml b/res/values/strings.xml
index b10df976544..252a601c794 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -388,6 +388,8 @@
Visible as \u201C^1\u201D to other devices
+
+ Turn on Bluetooth to connect to other devices.
Your devices
@@ -413,8 +415,8 @@
Currently connected
Saved devices
-
- Pair new device
+
+ Add device
Bluetooth will turn on to pair
@@ -847,9 +849,10 @@
Device encrypted
Device not encrypted
-
- Lock screen preferences
-
+
+ Lock screen display
+
+ What to show
Set My Location, screen unlock, SIM card lock, credential storage lock
@@ -2643,6 +2646,7 @@
Always on / Increased battery usage
New notifications
+
When to show
@@ -4633,6 +4637,9 @@
- Very long delay (%1$d ms)
+
+ Ring %1$s, touch %2$s
+
Ring & notification set to off
@@ -7227,24 +7234,23 @@
Allow visual signals
-
- Restrict notifications
+
+ When Do Not Disturb is turned on
+
Notifications
-
- When Do Not Disturb is turned on
- Mute notifications
+ Show notifications silently
- Show notifications but mute sounds & vibrations
+ Notifications will be muted
- When new notifications arrive your phone won\u2019t make a sound or vibration
+ When notifications arrive, your phone won\u2019t make a sound or vibrate.
- Hide & mute notifications
+ Hide notifications
- Notifications will not appear at all
+ You won\u2019t see new or existing notifications
- You won\u2019t see new or existing notifications when Do Not Disturb is on. However, notifications needed for basic phone activity and status will still appear.
+ Your phone won\u2019t show new or existing notifications, and won\u2019t make a sound or vibrate. Notifications won\u2019t appear when you swipe down from the top of your screen.\n\nKeep in mind, critical notifications for phone activity and status will still appear.
Custom
@@ -7364,6 +7370,35 @@
- %d rules can turn on automatically
+
+ Behavior
+
+ Exceptions
+
+ Schedule
+
+
+ Sound & vibration
+
+ When Do Not Disturb is on, sound and vibration will be muted, except for the items you allow above.
+
+ Mute all except
+
+ Muted
+
+ Not muted
+
+ Muted, but allow %1$s
+
+ Muted, but allow %1$s and %2$s
+
+ Muted, but allow %1$s, %2$s, and %3$s
+
+
+ Messages, events & reminders
+
+ When Do Not Disturb is on, messages, reminders, and events will muted, except for the items you allow above. You can adjust messages settings to allow your friends, family, or other contacts to reach you.
+
Update
@@ -7895,14 +7930,26 @@
Calls
+
+ When Do Not Disturb is on, incoming calls are blocked. You can adjust settings to allow your friends, family, or other contacts to reach you.
+
+
+ Starred contacts
+
+
+
+ - and 1 other
+ - and %d others
+
+
Messages
- All messages
+ Messages
- Selected messages
+ Some messages
From anyone
@@ -7913,6 +7960,15 @@
From starred contacts only
+
+ From starred contacts and repeat callers
+
+
+ From contacts and repeat callers
+
+
+ From repeat callers only
+
None
@@ -7932,14 +7988,23 @@
Events
- All callers
+ anyone
- Selected callers
+ contacts
+
+
+ starred contacts
Repeat callers
+
+ From %1$s only
+
+
+ From %1$s and %2$s
+
If the same person calls a second time within a %d minute period
@@ -8653,7 +8718,7 @@
Optimize
- May drain your battery more quickly
+ May drain your battery more quickly. App will no longer be restricted from using background battery.
Recommended for better battery life
@@ -9808,6 +9873,9 @@
+
+
+
diff --git a/res/xml/app_and_notification.xml b/res/xml/app_and_notification.xml
index e3319e9b235..53e575f6f9a 100644
--- a/res/xml/app_and_notification.xml
+++ b/res/xml/app_and_notification.xml
@@ -20,7 +20,8 @@
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="apps_and_notification_screen"
android:title="@string/app_and_notification_dashboard_title"
- settings:initialExpandedChildrenCount="7">
+ settings:initialExpandedChildrenCount="8">
+
+
+
+
+
+
+
@@ -51,15 +68,7 @@
-
-
-
+ android:order="-155"/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/res/xml/zen_mode_calls_settings.xml b/res/xml/zen_mode_calls_settings.xml
new file mode 100644
index 00000000000..dd6fcc50c0b
--- /dev/null
+++ b/res/xml/zen_mode_calls_settings.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/xml/zen_mode_msg_event_reminder_settings.xml b/res/xml/zen_mode_msg_event_reminder_settings.xml
new file mode 100644
index 00000000000..d12fc624461
--- /dev/null
+++ b/res/xml/zen_mode_msg_event_reminder_settings.xml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/xml/zen_mode_restrict_notifications_settings.xml b/res/xml/zen_mode_restrict_notifications_settings.xml
index d5243f62943..e024ab9d974 100644
--- a/res/xml/zen_mode_restrict_notifications_settings.xml
+++ b/res/xml/zen_mode_restrict_notifications_settings.xml
@@ -18,11 +18,11 @@
+ android:title="@string/zen_mode_restrict_notifications_title">
+ android:title="@string/zen_mode_settings_category">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:key="zen_mode_settings_category_behavior"
+ android:title="@string/zen_category_behavior">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/xml/zen_mode_sound_vibration_settings.xml b/res/xml/zen_mode_sound_vibration_settings.xml
new file mode 100644
index 00000000000..b3b81395ed9
--- /dev/null
+++ b/res/xml/zen_mode_sound_vibration_settings.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/com/android/settings/CredentialStorage.java b/src/com/android/settings/CredentialStorage.java
index ffbd2ce409b..c037c9f0a2c 100644
--- a/src/com/android/settings/CredentialStorage.java
+++ b/src/com/android/settings/CredentialStorage.java
@@ -127,9 +127,9 @@ public final class CredentialStorage extends Activity {
protected void onResume() {
super.onResume();
- Intent intent = getIntent();
- String action = intent.getAction();
- UserManager userManager = (UserManager) getSystemService(Context.USER_SERVICE);
+ final Intent intent = getIntent();
+ final String action = intent.getAction();
+ final UserManager userManager = (UserManager) getSystemService(Context.USER_SERVICE);
if (!userManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_CREDENTIALS)) {
if (ACTION_RESET.equals(action)) {
new ResetDialog();
@@ -208,18 +208,18 @@ public final class CredentialStorage extends Activity {
* Returns true if the currently set key guard matches our minimum quality requirements.
*/
private boolean checkKeyGuardQuality() {
- int credentialOwner =
+ final int credentialOwner =
UserManager.get(this).getCredentialOwnerProfile(UserHandle.myUserId());
- int quality = new LockPatternUtils(this).getActivePasswordQuality(credentialOwner);
+ final int quality = new LockPatternUtils(this).getActivePasswordQuality(credentialOwner);
return (quality >= MIN_PASSWORD_QUALITY);
}
private boolean isHardwareBackedKey(byte[] keyData) {
try {
- ASN1InputStream bIn = new ASN1InputStream(new ByteArrayInputStream(keyData));
- PrivateKeyInfo pki = PrivateKeyInfo.getInstance(bIn.readObject());
- String algOid = pki.getAlgorithmId().getAlgorithm().getId();
- String algName = new AlgorithmId(new ObjectIdentifier(algOid)).getName();
+ final ASN1InputStream bIn = new ASN1InputStream(new ByteArrayInputStream(keyData));
+ final PrivateKeyInfo pki = PrivateKeyInfo.getInstance(bIn.readObject());
+ final String algOid = pki.getAlgorithmId().getAlgorithm().getId();
+ final String algName = new AlgorithmId(new ObjectIdentifier(algOid)).getName();
return KeyChain.isBoundKeyAlgorithm(algName);
} catch (IOException e) {
@@ -236,14 +236,13 @@ public final class CredentialStorage extends Activity {
return;
}
- Bundle bundle = mInstallBundle;
+ final Bundle bundle = mInstallBundle;
mInstallBundle = null;
final int uid = bundle.getInt(Credentials.EXTRA_INSTALL_AS_UID, KeyStore.UID_SELF);
if (uid != KeyStore.UID_SELF && !UserHandle.isSameUser(uid, Process.myUid())) {
- int dstUserId = UserHandle.getUserId(uid);
- int myUserId = UserHandle.myUserId();
+ final int dstUserId = UserHandle.getUserId(uid);
// Restrict install target to the wifi uid.
if (uid != Process.WIFI_UID) {
@@ -252,7 +251,7 @@ public final class CredentialStorage extends Activity {
return;
}
- Intent installIntent = new Intent(ACTION_INSTALL)
+ final Intent installIntent = new Intent(ACTION_INSTALL)
.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT)
.putExtras(bundle);
startActivityAsUser(installIntent, new UserHandle(dstUserId));
@@ -260,8 +259,8 @@ public final class CredentialStorage extends Activity {
}
if (bundle.containsKey(Credentials.EXTRA_USER_PRIVATE_KEY_NAME)) {
- String key = bundle.getString(Credentials.EXTRA_USER_PRIVATE_KEY_NAME);
- byte[] value = bundle.getByteArray(Credentials.EXTRA_USER_PRIVATE_KEY_DATA);
+ final String key = bundle.getString(Credentials.EXTRA_USER_PRIVATE_KEY_NAME);
+ final byte[] value = bundle.getByteArray(Credentials.EXTRA_USER_PRIVATE_KEY_DATA);
int flags = KeyStore.FLAG_ENCRYPTED;
if (uid == Process.WIFI_UID && isHardwareBackedKey(value)) {
@@ -287,11 +286,11 @@ public final class CredentialStorage extends Activity {
}
}
- int flags = KeyStore.FLAG_NONE;
+ final int flags = KeyStore.FLAG_NONE;
if (bundle.containsKey(Credentials.EXTRA_USER_CERTIFICATE_NAME)) {
- String certName = bundle.getString(Credentials.EXTRA_USER_CERTIFICATE_NAME);
- byte[] certData = bundle.getByteArray(Credentials.EXTRA_USER_CERTIFICATE_DATA);
+ final String certName = bundle.getString(Credentials.EXTRA_USER_CERTIFICATE_NAME);
+ final byte[] certData = bundle.getByteArray(Credentials.EXTRA_USER_CERTIFICATE_DATA);
if (!mKeyStore.put(certName, certData, uid, flags)) {
Log.e(TAG, "Failed to install " + certName + " as uid " + uid);
@@ -300,8 +299,8 @@ public final class CredentialStorage extends Activity {
}
if (bundle.containsKey(Credentials.EXTRA_CA_CERTIFICATES_NAME)) {
- String caListName = bundle.getString(Credentials.EXTRA_CA_CERTIFICATES_NAME);
- byte[] caListData = bundle.getByteArray(Credentials.EXTRA_CA_CERTIFICATES_DATA);
+ final String caListName = bundle.getString(Credentials.EXTRA_CA_CERTIFICATES_NAME);
+ final byte[] caListData = bundle.getByteArray(Credentials.EXTRA_CA_CERTIFICATES_DATA);
if (!mKeyStore.put(caListName, caListData, uid, flags)) {
Log.e(TAG, "Failed to install " + caListName + " as uid " + uid);
@@ -310,7 +309,7 @@ public final class CredentialStorage extends Activity {
}
// Send the broadcast.
- Intent broadcast = new Intent(KeyChain.ACTION_KEYCHAIN_CHANGED);
+ final Intent broadcast = new Intent(KeyChain.ACTION_KEYCHAIN_CHANGED);
sendBroadcast(broadcast);
setResult(RESULT_OK);
@@ -324,7 +323,7 @@ public final class CredentialStorage extends Activity {
private boolean mResetConfirmed;
private ResetDialog() {
- AlertDialog dialog = new AlertDialog.Builder(CredentialStorage.this)
+ final AlertDialog dialog = new AlertDialog.Builder(CredentialStorage.this)
.setTitle(android.R.string.dialog_alert_title)
.setMessage(R.string.credentials_reset_hint)
.setPositiveButton(android.R.string.ok, this)
@@ -364,7 +363,7 @@ public final class CredentialStorage extends Activity {
new LockPatternUtils(CredentialStorage.this).resetKeyStore(UserHandle.myUserId());
try {
- KeyChainConnection keyChainConnection = KeyChain.bind(CredentialStorage.this);
+ final KeyChainConnection keyChainConnection = KeyChain.bind(CredentialStorage.this);
try {
return keyChainConnection.getService().reset();
} catch (RemoteException e) {
@@ -393,7 +392,7 @@ public final class CredentialStorage extends Activity {
}
private void clearLegacyVpnIfEstablished() {
- boolean isDone = VpnUtils.disconnectLegacyVpn(getApplicationContext());
+ final boolean isDone = VpnUtils.disconnectLegacyVpn(getApplicationContext());
if (isDone) {
Toast.makeText(CredentialStorage.this, R.string.vpn_disconnected,
Toast.LENGTH_SHORT).show();
@@ -407,7 +406,7 @@ public final class CredentialStorage extends Activity {
private class MarkKeyAsUserSelectable extends AsyncTask {
final String mAlias;
- public MarkKeyAsUserSelectable(String alias) {
+ MarkKeyAsUserSelectable(String alias) {
mAlias = alias;
}
@@ -440,7 +439,7 @@ public final class CredentialStorage extends Activity {
final int launchedFromUserId;
try {
- int launchedFromUid = android.app.ActivityManager.getService()
+ final int launchedFromUid = android.app.ActivityManager.getService()
.getLaunchedFromUid(getActivityToken());
if (launchedFromUid == -1) {
Log.e(TAG, ACTION_INSTALL + " must be started with startActivityForResult");
@@ -456,8 +455,8 @@ public final class CredentialStorage extends Activity {
return false;
}
- UserManager userManager = (UserManager) getSystemService(Context.USER_SERVICE);
- UserInfo parentInfo = userManager.getProfileParent(launchedFromUserId);
+ final UserManager userManager = (UserManager) getSystemService(Context.USER_SERVICE);
+ final UserInfo parentInfo = userManager.getProfileParent(launchedFromUserId);
if (parentInfo == null || parentInfo.id != UserHandle.myUserId()) {
// Caller is not running in a profile of this user
return false;
@@ -469,7 +468,7 @@ public final class CredentialStorage extends Activity {
* Confirm existing key guard, returning password via onActivityResult.
*/
private boolean confirmKeyGuard(int requestCode) {
- Resources res = getResources();
+ final Resources res = getResources();
boolean launched = new ChooseLockSettingsHelper(this)
.launchConfirmationActivity(requestCode,
res.getText(R.string.credentials_title), true);
@@ -485,7 +484,7 @@ public final class CredentialStorage extends Activity {
*/
if (requestCode == CONFIRM_KEY_GUARD_REQUEST) {
if (resultCode == Activity.RESULT_OK) {
- String password = data.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
+ final String password = data.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
if (!TextUtils.isEmpty(password)) {
// success
mKeyStore.unlock(password);
@@ -520,9 +519,10 @@ public final class CredentialStorage extends Activity {
private final TextView mError;
private UnlockDialog() {
- View view = View.inflate(CredentialStorage.this, R.layout.credentials_dialog, null);
+ final View view = View.inflate(
+ CredentialStorage.this, R.layout.credentials_dialog, null);
- CharSequence text;
+ final CharSequence text;
if (mRetriesRemaining == -1) {
text = getResources().getText(R.string.credentials_unlock_hint);
} else if (mRetriesRemaining > 3) {
@@ -539,7 +539,7 @@ public final class CredentialStorage extends Activity {
mOldPassword.addTextChangedListener(this);
mError = (TextView) view.findViewById(R.id.error);
- AlertDialog dialog = new AlertDialog.Builder(CredentialStorage.this)
+ final AlertDialog dialog = new AlertDialog.Builder(CredentialStorage.this)
.setView(view)
.setTitle(R.string.credentials_unlock)
.setPositiveButton(android.R.string.ok, this)
@@ -575,7 +575,7 @@ public final class CredentialStorage extends Activity {
mUnlockConfirmed = false;
mError.setVisibility(View.VISIBLE);
mKeyStore.unlock(mOldPassword.getText().toString());
- int error = mKeyStore.getLastError();
+ final int error = mKeyStore.getLastError();
if (error == KeyStore.NO_ERROR) {
mRetriesRemaining = -1;
Toast.makeText(CredentialStorage.this,
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index de1732c9600..cd92a9587f9 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -33,6 +33,7 @@ import android.os.UserHandle;
import android.os.Vibrator;
import android.provider.SearchIndexableResource;
import android.provider.Settings;
+import androidx.annotation.VisibleForTesting;
import androidx.preference.SwitchPreference;
import androidx.core.content.ContextCompat;
import androidx.preference.ListPreference;
@@ -749,12 +750,34 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
pref.setSummary(entries[index]);
}
- private void updateVibrationSummary(Preference pref) {
- Vibrator vibrator = getContext().getSystemService(Vibrator.class);
- final int intensity = Settings.System.getInt(getContext().getContentResolver(),
+ @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
+ void updateVibrationSummary(Preference pref) {
+ final Context context = getContext();
+ final Vibrator vibrator = context.getSystemService(Vibrator.class);
+
+ final int ringIntensity = Settings.System.getInt(context.getContentResolver(),
Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
vibrator.getDefaultNotificationVibrationIntensity());
- mVibrationPreferenceScreen.setSummary(getVibrationSummary(getContext(), intensity));
+ CharSequence ringIntensityString =
+ VibrationIntensityPreferenceController.getIntensityString(context, ringIntensity);
+
+ final int touchIntensity = Settings.System.getInt(context.getContentResolver(),
+ Settings.System.HAPTIC_FEEDBACK_INTENSITY,
+ vibrator.getDefaultHapticFeedbackIntensity());
+ CharSequence touchIntensityString =
+ VibrationIntensityPreferenceController.getIntensityString(context, touchIntensity);
+
+ if (mVibrationPreferenceScreen == null) {
+ mVibrationPreferenceScreen = findPreference(VIBRATION_PREFERENCE_SCREEN);
+ }
+
+ if (ringIntensity == touchIntensity) {
+ mVibrationPreferenceScreen.setSummary(ringIntensityString);
+ } else {
+ mVibrationPreferenceScreen.setSummary(
+ getString(R.string.accessibility_vibration_summary,
+ ringIntensityString, touchIntensityString));
+ }
}
private String getVibrationSummary(Context context, @VibrationIntensity int intensity) {
diff --git a/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java b/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java
index 34516b412cf..e99e32fe656 100644
--- a/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java
+++ b/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java
@@ -77,16 +77,19 @@ public abstract class VibrationIntensityPreferenceController extends BasePrefere
public CharSequence getSummary() {
final int intensity = Settings.System.getInt(mContext.getContentResolver(),
mSettingKey, getDefaultIntensity());
+ return getIntensityString(mContext, intensity);
+ }
+ public static CharSequence getIntensityString(Context context, int intensity) {
switch (intensity) {
case Vibrator.VIBRATION_INTENSITY_OFF:
- return mContext.getText(R.string.accessibility_vibration_intensity_off);
+ return context.getText(R.string.accessibility_vibration_intensity_off);
case Vibrator.VIBRATION_INTENSITY_LOW:
- return mContext.getText(R.string.accessibility_vibration_intensity_low);
+ return context.getText(R.string.accessibility_vibration_intensity_low);
case Vibrator.VIBRATION_INTENSITY_MEDIUM:
- return mContext.getText(R.string.accessibility_vibration_intensity_medium);
+ return context.getText(R.string.accessibility_vibration_intensity_medium);
case Vibrator.VIBRATION_INTENSITY_HIGH:
- return mContext.getText(R.string.accessibility_vibration_intensity_high);
+ return context.getText(R.string.accessibility_vibration_intensity_high);
default:
return "";
}
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index eb74b2e3f99..68ed42a4cac 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -549,7 +549,7 @@ public class ManageApplications extends InstrumentedFragment
startAppInfoFragment(AppStorageSettings.class, R.string.storage_settings);
break;
case LIST_TYPE_HIGH_POWER:
- HighPowerDetail.show(this, mCurrentPkgName, INSTALLED_APP_DETAILS);
+ HighPowerDetail.show(this, mCurrentUid, mCurrentPkgName, INSTALLED_APP_DETAILS);
break;
case LIST_TYPE_OVERLAY:
startAppInfoFragment(DrawOverlayDetails.class, R.string.overlay_settings);
diff --git a/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdater.java
index ee9d15f261d..856410e884a 100644
--- a/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdater.java
@@ -16,11 +16,11 @@
package com.android.settings.bluetooth;
import android.bluetooth.BluetoothProfile;
-import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.media.AudioManager;
import androidx.annotation.VisibleForTesting;
import android.util.Log;
+
import com.android.settings.connecteddevice.DevicePreferenceCallback;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
@@ -57,18 +57,20 @@ public class AvailableMediaBluetoothDeviceUpdater extends BluetoothDeviceUpdater
}
@Override
- public void onConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state) {
+ public void onProfileConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state,
+ int bluetoothProfile) {
if (DBG) {
- Log.d(TAG,"onConnectionStateChanged() device : " +
- cachedDevice.getName() + ", state : " + state);
+ Log.d(TAG, "onProfileConnectionStateChanged() device: " +
+ cachedDevice.getName() + ", state: " + state + ", bluetoothProfile: "
+ + bluetoothProfile);
}
- if (state == BluetoothAdapter.STATE_CONNECTED) {
+ if (state == BluetoothProfile.STATE_CONNECTED) {
if (isFilterMatched(cachedDevice)) {
addPreference(cachedDevice);
} else {
removePreference(cachedDevice);
}
- } else if (state == BluetoothAdapter.STATE_DISCONNECTED) {
+ } else if (state == BluetoothProfile.STATE_DISCONNECTED) {
removePreference(cachedDevice);
}
}
diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
index 2ebaafc8109..4dc6a245ced 100644
--- a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
@@ -161,6 +161,11 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback,
public void onAudioModeChanged() {
}
+ @Override
+ public void onProfileConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state,
+ int bluetoothProfile) {
+ }
+
@Override
public void onServiceConnected() {
// When bluetooth service connected update the UI
diff --git a/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdater.java
index 7559b30fe1e..0ac3e6d850b 100644
--- a/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdater.java
@@ -15,7 +15,6 @@
*/
package com.android.settings.bluetooth;
-import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
@@ -64,19 +63,20 @@ public class ConnectedBluetoothDeviceUpdater extends BluetoothDeviceUpdater {
}
@Override
- public void onConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state) {
+ public void onProfileConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state,
+ int bluetoothProfile) {
if (DBG) {
- Log.d(TAG,"onConnectionStateChanged() device : " +
- cachedDevice.getName() + ", state : " + state);
+ Log.d(TAG, "onProfileConnectionStateChanged() device: " +
+ cachedDevice.getName() + ", state: " + state + ", bluetoothProfile: "
+ + bluetoothProfile);
}
-
- if (state == BluetoothAdapter.STATE_CONNECTED) {
+ if (state == BluetoothProfile.STATE_CONNECTED) {
if (isFilterMatched(cachedDevice)) {
addPreference(cachedDevice);
} else {
removePreference(cachedDevice);
}
- } else if (state == BluetoothAdapter.STATE_DISCONNECTED) {
+ } else if (state == BluetoothProfile.STATE_DISCONNECTED) {
removePreference(cachedDevice);
}
}
diff --git a/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
index 9836d29591c..1cefea107c9 100644
--- a/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
@@ -15,8 +15,8 @@
*/
package com.android.settings.bluetooth;
-import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothProfile;
import android.content.Context;
import androidx.annotation.VisibleForTesting;
@@ -43,10 +43,11 @@ public class SavedBluetoothDeviceUpdater extends BluetoothDeviceUpdater {
}
@Override
- public void onConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state) {
- if (state == BluetoothAdapter.STATE_CONNECTED) {
+ public void onProfileConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state,
+ int bluetoothProfile) {
+ if (state == BluetoothProfile.STATE_CONNECTED) {
removePreference(cachedDevice);
- } else if (state == BluetoothAdapter.STATE_DISCONNECTED) {
+ } else if (state == BluetoothProfile.STATE_DISCONNECTED) {
addPreference(cachedDevice);
}
}
diff --git a/src/com/android/settings/core/BasePreferenceController.java b/src/com/android/settings/core/BasePreferenceController.java
index ec934917596..88ba32952a7 100644
--- a/src/com/android/settings/core/BasePreferenceController.java
+++ b/src/com/android/settings/core/BasePreferenceController.java
@@ -187,6 +187,7 @@ public abstract class BasePreferenceController extends AbstractPreferenceControl
public final boolean isAvailable() {
final int availabilityStatus = getAvailabilityStatus();
return (availabilityStatus == AVAILABLE
+ || availabilityStatus == AVAILABLE_UNSEARCHABLE
|| availabilityStatus == DISABLED_DEPENDENT_SETTING);
}
@@ -230,16 +231,15 @@ public abstract class BasePreferenceController extends AbstractPreferenceControl
* Called by SearchIndexProvider#getNonIndexableKeys
*/
public void updateNonIndexableKeys(List keys) {
- if (this instanceof AbstractPreferenceController) {
- if (!isAvailable()) {
- final String key = getPreferenceKey();
- if (TextUtils.isEmpty(key)) {
- Log.w(TAG,
- "Skipping updateNonIndexableKeys due to empty key " + this.toString());
- return;
- }
- keys.add(key);
+ final boolean shouldSuppressFromSearch = !isAvailable()
+ || getAvailabilityStatus() == AVAILABLE_UNSEARCHABLE;
+ if (shouldSuppressFromSearch) {
+ final String key = getPreferenceKey();
+ if (TextUtils.isEmpty(key)) {
+ Log.w(TAG, "Skipping updateNonIndexableKeys due to empty key " + toString());
+ return;
}
+ keys.add(key);
}
}
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index ced158eb3e0..aab3512cf15 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -106,9 +106,10 @@ import com.android.settings.notification.NotificationStation;
import com.android.settings.notification.SoundSettings;
import com.android.settings.notification.ZenAccessSettings;
import com.android.settings.notification.ZenModeAutomationSettings;
-import com.android.settings.notification.ZenModeBehaviorSettings;
+import com.android.settings.notification.ZenModeMsgEventReminderSettings;
import com.android.settings.notification.ZenModeBlockedEffectsSettings;
import com.android.settings.notification.ZenModeEventRuleSettings;
+import com.android.settings.notification.ZenModeRestrictNotificationsSettings;
import com.android.settings.notification.ZenModeScheduleRuleSettings;
import com.android.settings.notification.ZenModeSettings;
import com.android.settings.password.ChooseLockPassword;
@@ -220,7 +221,6 @@ public class SettingsGateway {
ApnSettings.class.getName(),
ApnEditor.class.getName(),
WifiCallingSettings.class.getName(),
- ZenModeBehaviorSettings.class.getName(),
ZenModeScheduleRuleSettings.class.getName(),
ZenModeEventRuleSettings.class.getName(),
ZenModeBlockedEffectsSettings.class.getName(),
diff --git a/src/com/android/settings/dashboard/DashboardFragmentRegistry.java b/src/com/android/settings/dashboard/DashboardFragmentRegistry.java
index 5e45c43dfbb..cd478fc43ad 100644
--- a/src/com/android/settings/dashboard/DashboardFragmentRegistry.java
+++ b/src/com/android/settings/dashboard/DashboardFragmentRegistry.java
@@ -100,7 +100,7 @@ public class DashboardFragmentRegistry {
PARENT_TO_CATEGORY_KEY_MAP.put(GestureSettings.class.getName(),
CategoryKey.CATEGORY_GESTURES);
PARENT_TO_CATEGORY_KEY_MAP.put(NightDisplaySettings.class.getName(),
- CategoryKey.CATEGORY_NIGHT_LIGHT);
+ CategoryKey.CATEGORY_NIGHT_DISPLAY);
CATEGORY_KEY_TO_PARENT_MAP = new ArrayMap<>(PARENT_TO_CATEGORY_KEY_MAP.size());
diff --git a/src/com/android/settings/fuelgauge/BatteryBroadcastReceiver.java b/src/com/android/settings/fuelgauge/BatteryBroadcastReceiver.java
index c051604d113..bd64dd3d4c7 100644
--- a/src/com/android/settings/fuelgauge/BatteryBroadcastReceiver.java
+++ b/src/com/android/settings/fuelgauge/BatteryBroadcastReceiver.java
@@ -21,9 +21,15 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.PowerManager;
+
+import androidx.annotation.IntDef;
import androidx.annotation.VisibleForTesting;
import com.android.settings.Utils;
+import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
/**
* Use this broadcastReceiver to listen to the battery change, and it will invoke
@@ -43,7 +49,19 @@ public class BatteryBroadcastReceiver extends BroadcastReceiver {
* Battery saver(e.g. off->on)
*/
public interface OnBatteryChangedListener {
- void onBatteryChanged();
+ void onBatteryChanged(@BatteryUpdateType int type);
+ }
+
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef({BatteryUpdateType.MANUAL,
+ BatteryUpdateType.BATTERY_LEVEL,
+ BatteryUpdateType.BATTERY_SAVER,
+ BatteryUpdateType.BATTERY_STATUS})
+ public @interface BatteryUpdateType {
+ int MANUAL = 0;
+ int BATTERY_LEVEL = 1;
+ int BATTERY_SAVER = 2;
+ int BATTERY_STATUS = 3;
}
@VisibleForTesting
@@ -85,14 +103,17 @@ public class BatteryBroadcastReceiver extends BroadcastReceiver {
final String batteryLevel = Utils.getBatteryPercentage(intent);
final String batteryStatus = Utils.getBatteryStatus(
mContext.getResources(), intent);
- if (forceUpdate || !batteryLevel.equals(mBatteryLevel) || !batteryStatus.equals(
- mBatteryStatus)) {
- mBatteryLevel = batteryLevel;
- mBatteryStatus = batteryStatus;
- mBatteryListener.onBatteryChanged();
+ if (forceUpdate) {
+ mBatteryListener.onBatteryChanged(BatteryUpdateType.MANUAL);
+ } else if(!batteryLevel.equals(mBatteryLevel)) {
+ mBatteryListener.onBatteryChanged(BatteryUpdateType.BATTERY_LEVEL);
+ } else if (!batteryStatus.equals(mBatteryStatus)) {
+ mBatteryListener.onBatteryChanged(BatteryUpdateType.BATTERY_STATUS);
}
+ mBatteryLevel = batteryLevel;
+ mBatteryStatus = batteryStatus;
} else if (PowerManager.ACTION_POWER_SAVE_MODE_CHANGED.equals(intent.getAction())) {
- mBatteryListener.onBatteryChanged();
+ mBatteryListener.onBatteryChanged(BatteryUpdateType.BATTERY_SAVER);
}
}
}
diff --git a/src/com/android/settings/fuelgauge/HighPowerDetail.java b/src/com/android/settings/fuelgauge/HighPowerDetail.java
index 9cafbcba491..4f707008953 100644
--- a/src/com/android/settings/fuelgauge/HighPowerDetail.java
+++ b/src/com/android/settings/fuelgauge/HighPowerDetail.java
@@ -17,6 +17,7 @@
package com.android.settings.fuelgauge;
import android.app.AlertDialog;
+import android.app.AppOpsManager;
import android.app.Dialog;
import android.app.Fragment;
import android.content.Context;
@@ -43,12 +44,18 @@ public class HighPowerDetail extends InstrumentedDialogFragment implements OnCli
private static final String ARG_DEFAULT_ON = "default_on";
- private final PowerWhitelistBackend mBackend = PowerWhitelistBackend.getInstance();
-
- private String mPackageName;
+ @VisibleForTesting
+ PowerWhitelistBackend mBackend;
+ @VisibleForTesting
+ BatteryUtils mBatteryUtils;
+ @VisibleForTesting
+ String mPackageName;
+ @VisibleForTesting
+ int mPackageUid;
private CharSequence mLabel;
private boolean mDefaultOn;
- private boolean mIsEnabled;
+ @VisibleForTesting
+ boolean mIsEnabled;
private Checkable mOptionOn;
private Checkable mOptionOff;
@@ -60,8 +67,11 @@ public class HighPowerDetail extends InstrumentedDialogFragment implements OnCli
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ mBatteryUtils = BatteryUtils.getInstance(getContext());
+ mBackend = PowerWhitelistBackend.getInstance();
mPackageName = getArguments().getString(AppInfoBase.ARG_PACKAGE_NAME);
+ mPackageUid = getArguments().getInt(AppInfoBase.ARG_PACKAGE_UID);
PackageManager pm = getContext().getPackageManager();
try {
mLabel = pm.getApplicationInfo(mPackageName, 0).loadLabel(pm);
@@ -129,6 +139,8 @@ public class HighPowerDetail extends InstrumentedDialogFragment implements OnCli
if (newValue != oldValue) {
logSpecialPermissionChange(newValue, mPackageName, getContext());
if (newValue) {
+ mBatteryUtils.setForceAppStandby(mPackageUid, mPackageName,
+ AppOpsManager.MODE_ALLOWED);
mBackend.addApp(mPackageName);
} else {
mBackend.removeApp(mPackageName);
@@ -165,10 +177,11 @@ public class HighPowerDetail extends InstrumentedDialogFragment implements OnCli
: R.string.high_power_off);
}
- public static void show(Fragment caller, String packageName, int requestCode) {
+ public static void show(Fragment caller, int uid, String packageName, int requestCode) {
HighPowerDetail fragment = new HighPowerDetail();
Bundle args = new Bundle();
args.putString(AppInfoBase.ARG_PACKAGE_NAME, packageName);
+ args.putInt(AppInfoBase.ARG_PACKAGE_UID, uid);
fragment.setArguments(args);
fragment.setTargetFragment(caller, requestCode);
fragment.show(caller.getFragmentManager(), HighPowerDetail.class.getSimpleName());
diff --git a/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java b/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java
index a318e160918..74098ffb9a0 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java
@@ -13,6 +13,8 @@
*/
package com.android.settings.fuelgauge;
+import static com.android.settings.fuelgauge.BatteryBroadcastReceiver.BatteryUpdateType;
+
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@@ -33,6 +35,7 @@ import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.search.SearchIndexable;
import com.android.settingslib.utils.StringUtil;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -108,7 +111,7 @@ public class PowerUsageAdvanced extends PowerUsageBase {
mMetricsFeatureProvider.action(getContext(),
MetricsProto.MetricsEvent.ACTION_SETTINGS_MENU_BATTERY_APPS_TOGGLE,
mShowAllApps);
- restartBatteryStatsLoader();
+ restartBatteryStatsLoader(BatteryUpdateType.MANUAL);
return true;
default:
return super.onOptionsItemSelected(item);
@@ -140,7 +143,7 @@ public class PowerUsageAdvanced extends PowerUsageBase {
}
@Override
- protected void refreshUi() {
+ protected void refreshUi(@BatteryUpdateType int refreshType) {
final Context context = getContext();
if (context == null) {
return;
diff --git a/src/com/android/settings/fuelgauge/PowerUsageBase.java b/src/com/android/settings/fuelgauge/PowerUsageBase.java
index f924e46b0f3..aa029191a86 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageBase.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageBase.java
@@ -15,6 +15,8 @@
*/
package com.android.settings.fuelgauge;
+import static com.android.settings.fuelgauge.BatteryBroadcastReceiver.*;
+
import android.app.Activity;
import android.app.LoaderManager;
import android.content.Context;
@@ -26,18 +28,17 @@ import android.view.Menu;
import com.android.internal.os.BatteryStatsHelper;
import com.android.settings.dashboard.DashboardFragment;
-import com.android.settingslib.utils.AsyncLoader;
/**
* Common base class for things that need to show the battery usage graph.
*/
-public abstract class PowerUsageBase extends DashboardFragment
- implements LoaderManager.LoaderCallbacks {
+public abstract class PowerUsageBase extends DashboardFragment {
// +1 to allow ordering for PowerUsageSummary.
@VisibleForTesting
static final int MENU_STATS_REFRESH = Menu.FIRST + 1;
private static final String TAG = "PowerUsageBase";
+ private static final String KEY_REFRESH_TYPE = "refresh_type";
protected BatteryStatsHelper mStatsHelper;
protected UserManager mUm;
@@ -57,8 +58,8 @@ public abstract class PowerUsageBase extends DashboardFragment
setHasOptionsMenu(true);
mBatteryBroadcastReceiver = new BatteryBroadcastReceiver(getContext());
- mBatteryBroadcastReceiver.setBatteryChangedListener(() -> {
- restartBatteryStatsLoader();
+ mBatteryBroadcastReceiver.setBatteryChangedListener(type -> {
+ restartBatteryStatsLoader(type);
});
}
@@ -81,11 +82,14 @@ public abstract class PowerUsageBase extends DashboardFragment
mBatteryBroadcastReceiver.unRegister();
}
- protected void restartBatteryStatsLoader() {
- getLoaderManager().restartLoader(0, Bundle.EMPTY, this);
+ protected void restartBatteryStatsLoader(int refreshType) {
+ final Bundle bundle = new Bundle();
+ bundle.putInt(KEY_REFRESH_TYPE, refreshType);
+
+ getLoaderManager().restartLoader(0, bundle, new PowerLoaderCallback());
}
- protected abstract void refreshUi();
+ protected abstract void refreshUi(@BatteryUpdateType int refreshType);
protected void updatePreference(BatteryHistoryPreference historyPref) {
final long startTime = System.currentTimeMillis();
@@ -93,21 +97,30 @@ public abstract class PowerUsageBase extends DashboardFragment
BatteryUtils.logRuntime(TAG, "updatePreference", startTime);
}
- @Override
- public Loader onCreateLoader(int id,
- Bundle args) {
- return new BatteryStatsHelperLoader(getContext());
- }
+ /**
+ * {@link android.app.LoaderManager.LoaderCallbacks} for {@link PowerUsageBase} to load
+ * the {@link BatteryStatsHelper}
+ */
+ public class PowerLoaderCallback implements LoaderManager.LoaderCallbacks {
+ private int mRefreshType;
- @Override
- public void onLoadFinished(Loader loader,
- BatteryStatsHelper statsHelper) {
- mStatsHelper = statsHelper;
- refreshUi();
- }
+ @Override
+ public Loader onCreateLoader(int id,
+ Bundle args) {
+ mRefreshType = args.getInt(KEY_REFRESH_TYPE);
+ return new BatteryStatsHelperLoader(getContext());
+ }
- @Override
- public void onLoaderReset(Loader loader) {
+ @Override
+ public void onLoadFinished(Loader loader,
+ BatteryStatsHelper statsHelper) {
+ mStatsHelper = statsHelper;
+ refreshUi(mRefreshType);
+ }
+ @Override
+ public void onLoaderReset(Loader loader) {
+
+ }
}
}
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index af69cee2d0f..82cd16a796b 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -16,6 +16,8 @@
package com.android.settings.fuelgauge;
+import static com.android.settings.fuelgauge.BatteryBroadcastReceiver.BatteryUpdateType;
+
import android.app.Activity;
import android.app.LoaderManager;
import android.app.LoaderManager.LoaderCallbacks;
@@ -279,7 +281,7 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
} else {
mStatsType = BatteryStats.STATS_SINCE_CHARGED;
}
- refreshUi();
+ refreshUi(BatteryUpdateType.MANUAL);
return true;
case MENU_ADVANCED_BATTERY:
new SubSettingLauncher(getContext())
@@ -293,14 +295,15 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
}
}
- protected void refreshUi() {
+ protected void refreshUi(@BatteryUpdateType int refreshType) {
final Context context = getContext();
if (context == null) {
return;
}
- // Only skip BatteryTipLoader for the first time when device is rotated
- if (mNeedUpdateBatteryTip) {
+ // Skip BatteryTipLoader if device is rotated or only battery level change
+ if (mNeedUpdateBatteryTip
+ && refreshType != BatteryUpdateType.BATTERY_LEVEL) {
restartBatteryTipLoader();
} else {
mNeedUpdateBatteryTip = true;
@@ -399,8 +402,9 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
}
@Override
- protected void restartBatteryStatsLoader() {
- restartBatteryStatsLoader(true /* clearHeader */);
+ protected void restartBatteryStatsLoader(@BatteryUpdateType int refreshType) {
+ super.restartBatteryStatsLoader(refreshType);
+ mBatteryHeaderPreferenceController.quickUpdateHeaderPreference();
}
@Override
@@ -409,13 +413,6 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
mBatteryTipPreferenceController.saveInstanceState(outState);
}
- void restartBatteryStatsLoader(boolean clearHeader) {
- super.restartBatteryStatsLoader();
- if (clearHeader) {
- mBatteryHeaderPreferenceController.quickUpdateHeaderPreference();
- }
- }
-
@Override
public void onBatteryTipHandled(BatteryTip batteryTip) {
restartBatteryTipLoader();
@@ -430,7 +427,7 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
mContext = context;
mLoader = loader;
mBatteryBroadcastReceiver = new BatteryBroadcastReceiver(mContext);
- mBatteryBroadcastReceiver.setBatteryChangedListener(() -> {
+ mBatteryBroadcastReceiver.setBatteryChangedListener(type -> {
BatteryInfo.getBatteryInfo(mContext, new BatteryInfo.Callback() {
@Override
public void onBatteryInfoLoaded(BatteryInfo info) {
diff --git a/src/com/android/settings/fuelgauge/RestrictedAppDetails.java b/src/com/android/settings/fuelgauge/RestrictedAppDetails.java
index ba1db341fd6..18cb476269c 100644
--- a/src/com/android/settings/fuelgauge/RestrictedAppDetails.java
+++ b/src/com/android/settings/fuelgauge/RestrictedAppDetails.java
@@ -120,6 +120,11 @@ public class RestrictedAppDetails extends DashboardFragment {
return MetricsProto.MetricsEvent.FUELGAUGE_RESTRICTED_APP_DETAILS;
}
+ @Override
+ public int getHelpResource() {
+ return R.string.help_uri_restricted_apps;
+ }
+
@VisibleForTesting
void refreshUi() {
mRestrictedAppListGroup.removeAll();
diff --git a/src/com/android/settings/notification/CallVolumePreferenceController.java b/src/com/android/settings/notification/CallVolumePreferenceController.java
new file mode 100644
index 00000000000..c0e16331f4c
--- /dev/null
+++ b/src/com/android/settings/notification/CallVolumePreferenceController.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2018 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 android.content.Context;
+import android.media.AudioManager;
+
+import com.android.settings.R;
+
+
+public class CallVolumePreferenceController extends VolumeSeekBarPreferenceController {
+
+ private AudioManager mAudioManager;
+
+ public CallVolumePreferenceController(Context context, String key) {
+ super(context, key);
+ mAudioManager = context.getSystemService(AudioManager.class);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return mContext.getResources().getBoolean(R.bool.config_show_call_volume)
+ && !mHelper.isSingleVolume() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
+ }
+
+ @Override
+ public int getAudioStream() {
+ if (mAudioManager.isBluetoothScoOn()) {
+ return AudioManager.STREAM_BLUETOOTH_SCO;
+ }
+ return AudioManager.STREAM_VOICE_CALL;
+ }
+
+ @Override
+ public int getMuteIcon() {
+ // User will not be allowed to fully mute the call volume, use original
+ // icon for mute icon.
+ return R.drawable.ic_local_phone_24_lib;
+ }
+
+}
diff --git a/src/com/android/settings/notification/SoundSettings.java b/src/com/android/settings/notification/SoundSettings.java
index 228ced12cdd..33818e05eb9 100644
--- a/src/com/android/settings/notification/SoundSettings.java
+++ b/src/com/android/settings/notification/SoundSettings.java
@@ -153,6 +153,7 @@ public class SoundSettings extends DashboardFragment {
volumeControllers.add(use(MediaVolumePreferenceController.class));
volumeControllers.add(use(RingVolumePreferenceController.class));
volumeControllers.add(use(NotificationVolumePreferenceController.class));
+ volumeControllers.add(use(CallVolumePreferenceController.class));
for (VolumeSeekBarPreferenceController controller : volumeControllers) {
controller.setCallback(mVolumeCallback);
diff --git a/src/com/android/settings/notification/VolumeSeekBarPreference.java b/src/com/android/settings/notification/VolumeSeekBarPreference.java
index 28d60f7f3c2..ee02b628b08 100644
--- a/src/com/android/settings/notification/VolumeSeekBarPreference.java
+++ b/src/com/android/settings/notification/VolumeSeekBarPreference.java
@@ -83,7 +83,9 @@ public class VolumeSeekBarPreference extends SeekBarPreference {
public void setStream(int stream) {
mStream = stream;
setMax(mAudioManager.getStreamMaxVolume(mStream));
- setMin(mAudioManager.getStreamMinVolume(mStream));
+ // Use getStreamMinVolumeInt for non-public stream type
+ // eg: AudioManager.STREAM_BLUETOOTH_SCO
+ setMin(mAudioManager.getStreamMinVolumeInt(mStream));
setProgress(mAudioManager.getStreamVolume(mStream));
}
@@ -108,10 +110,6 @@ public class VolumeSeekBarPreference extends SeekBarPreference {
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
super.onBindViewHolder(view);
- if (mStream == 0) {
- Log.w(TAG, "No stream found, not binding volumizer");
- return;
- }
mSeekBar = (SeekBar) view.findViewById(com.android.internal.R.id.seekbar);
mIconView = (ImageView) view.findViewById(com.android.internal.R.id.icon);
mSuppressionTextView = (TextView) view.findViewById(R.id.suppression_text);
diff --git a/src/com/android/settings/notification/ZenModeBackend.java b/src/com/android/settings/notification/ZenModeBackend.java
index ece2a9e666c..cb8a048c90c 100644
--- a/src/com/android/settings/notification/ZenModeBackend.java
+++ b/src/com/android/settings/notification/ZenModeBackend.java
@@ -16,6 +16,9 @@
package com.android.settings.notification;
+import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_SCREEN_OFF;
+import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_SCREEN_ON;
+
import android.app.ActivityManager;
import android.app.AutomaticZenRule;
import android.app.NotificationManager;
@@ -146,19 +149,24 @@ public class ZenModeBackend {
protected void savePolicy(int priorityCategories, int priorityCallSenders,
int priorityMessageSenders, int suppressedVisualEffects) {
mPolicy = new NotificationManager.Policy(priorityCategories, priorityCallSenders,
- priorityMessageSenders,
- suppressedVisualEffects);
+ priorityMessageSenders, suppressedVisualEffects);
mNotificationManager.setNotificationPolicy(mPolicy);
}
- protected int getNewSuppressedEffects(boolean suppress, int effectType) {
+ private int getNewSuppressedEffects(boolean suppress, int effectType) {
int effects = mPolicy.suppressedVisualEffects;
+
if (suppress) {
effects |= effectType;
} else {
effects &= ~effectType;
}
- return effects;
+
+ return clearDeprecatedEffects(effects);
+ }
+
+ private int clearDeprecatedEffects(int effects) {
+ return effects & ~(SUPPRESSED_EFFECT_SCREEN_ON | SUPPRESSED_EFFECT_SCREEN_OFF);
}
protected boolean isEffectAllowed(int effect) {
diff --git a/src/com/android/settings/notification/ZenModeBehaviorPreferenceController.java b/src/com/android/settings/notification/ZenModeBehaviorCallsPreferenceController.java
similarity index 83%
rename from src/com/android/settings/notification/ZenModeBehaviorPreferenceController.java
rename to src/com/android/settings/notification/ZenModeBehaviorCallsPreferenceController.java
index 908ec04ad74..4ab14379e92 100644
--- a/src/com/android/settings/notification/ZenModeBehaviorPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModeBehaviorCallsPreferenceController.java
@@ -22,13 +22,13 @@ import androidx.preference.Preference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.core.lifecycle.Lifecycle;
-public class ZenModeBehaviorPreferenceController extends
+public class ZenModeBehaviorCallsPreferenceController extends
AbstractZenModePreferenceController implements PreferenceControllerMixin {
- protected static final String KEY_BEHAVIOR_SETTINGS = "zen_mode_behavior_settings";
+ protected static final String KEY_BEHAVIOR_SETTINGS = "zen_mode_calls_settings";
private final ZenModeSettings.SummaryBuilder mSummaryBuilder;
- public ZenModeBehaviorPreferenceController(Context context, Lifecycle lifecycle) {
+ public ZenModeBehaviorCallsPreferenceController(Context context, Lifecycle lifecycle) {
super(context, KEY_BEHAVIOR_SETTINGS, lifecycle);
mSummaryBuilder = new ZenModeSettings.SummaryBuilder(context);
}
@@ -47,7 +47,6 @@ public class ZenModeBehaviorPreferenceController extends
public void updateState(Preference preference) {
super.updateState(preference);
- preference.setSummary(mSummaryBuilder.getBehaviorSettingSummary(getPolicy(),
- getZenMode()));
+ preference.setSummary(mSummaryBuilder.getCallsSettingSummary(getPolicy()));
}
}
diff --git a/src/com/android/settings/notification/ZenModeBehaviorFooterPreferenceController.java b/src/com/android/settings/notification/ZenModeBehaviorFooterPreferenceController.java
index a36c2661b86..1a6a3b4357c 100644
--- a/src/com/android/settings/notification/ZenModeBehaviorFooterPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModeBehaviorFooterPreferenceController.java
@@ -16,8 +16,8 @@
package com.android.settings.notification;
-import android.content.Context;
import android.content.ComponentName;
+import android.content.Context;
import android.net.Uri;
import android.provider.Settings;
import android.service.notification.ZenModeConfig;
@@ -30,14 +30,17 @@ import com.android.settingslib.core.lifecycle.Lifecycle;
public class ZenModeBehaviorFooterPreferenceController extends AbstractZenModePreferenceController {
protected static final String KEY = "footer_preference";
+ private final int mTitleRes;
- public ZenModeBehaviorFooterPreferenceController(Context context, Lifecycle lifecycle) {
+ public ZenModeBehaviorFooterPreferenceController(Context context, Lifecycle lifecycle,
+ int titleRes) {
super(context, KEY, lifecycle);
+ mTitleRes = titleRes;
}
@Override
public boolean isAvailable() {
- return isDeprecatedZenMode(getZenMode());
+ return true;
}
@Override
@@ -48,45 +51,45 @@ public class ZenModeBehaviorFooterPreferenceController extends AbstractZenModePr
@Override
public void updateState(Preference preference) {
super.updateState(preference);
-
- boolean isAvailable = isAvailable();
- preference.setVisible(isAvailable);
- if (isAvailable) {
- preference.setTitle(getFooterText());
- }
-
+ preference.setTitle(getFooterText());
}
protected String getFooterText() {
- ZenModeConfig config = getZenModeConfig();
+ if (isDeprecatedZenMode(getZenMode())) {
+ ZenModeConfig config = getZenModeConfig();
- // DND turned on by manual rule with deprecated zen mode
- if (config.manualRule != null &&
- isDeprecatedZenMode(config.manualRule.zenMode)) {
- final Uri id = config.manualRule.conditionId;
- if (config.manualRule.enabler != null) {
- // app triggered manual rule
- String appOwner = mZenModeConfigWrapper.getOwnerCaption(config.manualRule.enabler);
- if (!appOwner.isEmpty()) {
- return mContext.getString(R.string.zen_mode_app_set_behavior, appOwner);
- }
- } else {
- return mContext.getString(R.string.zen_mode_qs_set_behavior);
- }
- }
-
- // DND turned on by an automatic rule with deprecated zen mode
- for (ZenModeConfig.ZenRule automaticRule : config.automaticRules.values()) {
- if (automaticRule.isAutomaticActive() && isDeprecatedZenMode(automaticRule.zenMode)) {
- ComponentName component = automaticRule.component;
- if (component != null) {
- return mContext.getString(R.string.zen_mode_app_set_behavior,
- component.getPackageName());
+ // DND turned on by manual rule with deprecated zen mode
+ if (config.manualRule != null &&
+ isDeprecatedZenMode(config.manualRule.zenMode)) {
+ final Uri id = config.manualRule.conditionId;
+ if (config.manualRule.enabler != null) {
+ // app triggered manual rule
+ String appOwner = mZenModeConfigWrapper.getOwnerCaption(
+ config.manualRule.enabler);
+ if (!appOwner.isEmpty()) {
+ return mContext.getString(R.string.zen_mode_app_set_behavior, appOwner);
+ }
+ } else {
+ return mContext.getString(R.string.zen_mode_qs_set_behavior);
}
}
- }
- return mContext.getString(R.string.zen_mode_unknown_app_set_behavior);
+ // DND turned on by an automatic rule with deprecated zen mode
+ for (ZenModeConfig.ZenRule automaticRule : config.automaticRules.values()) {
+ if (automaticRule.isAutomaticActive() && isDeprecatedZenMode(
+ automaticRule.zenMode)) {
+ ComponentName component = automaticRule.component;
+ if (component != null) {
+ return mContext.getString(R.string.zen_mode_app_set_behavior,
+ component.getPackageName());
+ }
+ }
+ }
+
+ return mContext.getString(R.string.zen_mode_unknown_app_set_behavior);
+ } else {
+ return mContext.getString(mTitleRes);
+ }
}
private boolean isDeprecatedZenMode(int zenMode) {
diff --git a/src/com/android/settings/notification/ZenModeBehaviorMsgEventReminderPreferenceController.java b/src/com/android/settings/notification/ZenModeBehaviorMsgEventReminderPreferenceController.java
new file mode 100644
index 00000000000..d11baee8e8b
--- /dev/null
+++ b/src/com/android/settings/notification/ZenModeBehaviorMsgEventReminderPreferenceController.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2017 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 android.content.Context;
+import androidx.preference.Preference;
+
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+public class ZenModeBehaviorMsgEventReminderPreferenceController extends
+ AbstractZenModePreferenceController implements PreferenceControllerMixin {
+
+ protected static final String KEY_BEHAVIOR_SETTINGS = "zen_mode_msg_event_reminder_settings";
+ private final ZenModeSettings.SummaryBuilder mSummaryBuilder;
+
+ public ZenModeBehaviorMsgEventReminderPreferenceController(Context context,
+ Lifecycle lifecycle) {
+ super(context, KEY_BEHAVIOR_SETTINGS, lifecycle);
+ mSummaryBuilder = new ZenModeSettings.SummaryBuilder(context);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_BEHAVIOR_SETTINGS;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return true;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+
+ preference.setSummary(mSummaryBuilder.getMsgEventReminderSettingSummary(getPolicy()));
+ }
+}
diff --git a/src/com/android/settings/notification/ZenModeBehaviorSoundPreferenceController.java b/src/com/android/settings/notification/ZenModeBehaviorSoundPreferenceController.java
new file mode 100644
index 00000000000..3d250639e18
--- /dev/null
+++ b/src/com/android/settings/notification/ZenModeBehaviorSoundPreferenceController.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2018 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 android.content.Context;
+import androidx.preference.Preference;
+
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+public class ZenModeBehaviorSoundPreferenceController extends
+ AbstractZenModePreferenceController implements PreferenceControllerMixin {
+
+ protected static final String KEY_BEHAVIOR_SETTINGS = "zen_sound_vibration_settings";
+ private final ZenModeSettings.SummaryBuilder mSummaryBuilder;
+
+ public ZenModeBehaviorSoundPreferenceController(Context context, Lifecycle lifecycle) {
+ super(context, KEY_BEHAVIOR_SETTINGS, lifecycle);
+ mSummaryBuilder = new ZenModeSettings.SummaryBuilder(context);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_BEHAVIOR_SETTINGS;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return true;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+
+ preference.setSummary(mSummaryBuilder.getSoundSettingSummary(getPolicy()));
+ }
+}
diff --git a/src/com/android/settings/notification/ZenModeCallsSettings.java b/src/com/android/settings/notification/ZenModeCallsSettings.java
new file mode 100644
index 00000000000..d771ef27344
--- /dev/null
+++ b/src/com/android/settings/notification/ZenModeCallsSettings.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2018 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.NotificationManager.Policy.PRIORITY_CATEGORY_CALLS;
+
+import android.content.Context;
+import android.provider.SearchIndexableResource;
+
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.R;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
+import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.search.SearchIndexable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@SearchIndexable
+public class ZenModeCallsSettings extends ZenModeSettingsBase implements Indexable {
+
+ @Override
+ protected List createPreferenceControllers(Context context) {
+ return buildPreferenceControllers(context, getLifecycle());
+ }
+
+ private static List buildPreferenceControllers(Context context,
+ Lifecycle lifecycle) {
+ List controllers = new ArrayList<>();
+ controllers.add(new ZenModeCallsPreferenceController(context, lifecycle));
+ controllers.add(new ZenModeStarredContactsPreferenceController(context, lifecycle,
+ PRIORITY_CATEGORY_CALLS, "zen_mode_starred_contacts_callers"));
+ controllers.add(new ZenModeRepeatCallersPreferenceController(context, lifecycle,
+ context.getResources().getInteger(com.android.internal.R.integer
+ .config_zen_repeat_callers_threshold)));
+ controllers.add(new ZenModeBehaviorFooterPreferenceController(
+ context, lifecycle, R.string.zen_mode_calls_footer));
+ return controllers;
+ }
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.zen_mode_calls_settings;
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return MetricsEvent.NOTIFICATION_ZEN_MODE_PRIORITY;
+ }
+
+ /**
+ * For Search.
+ */
+ public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider() {
+
+ @Override
+ public List getXmlResourcesToIndex(Context context,
+ boolean enabled) {
+ final ArrayList result = new ArrayList<>();
+
+ final SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.zen_mode_calls_settings;
+ result.add(sir);
+ return result;
+ }
+
+ @Override
+ public List getNonIndexableKeys(Context context) {
+ final List keys = super.getNonIndexableKeys(context);
+ return keys;
+ }
+
+ @Override
+ public List createPreferenceControllers(Context context) {
+ return buildPreferenceControllers(context, null);
+ }
+ };
+}
diff --git a/src/com/android/settings/notification/ZenModeBehaviorSettings.java b/src/com/android/settings/notification/ZenModeMsgEventReminderSettings.java
similarity index 78%
rename from src/com/android/settings/notification/ZenModeBehaviorSettings.java
rename to src/com/android/settings/notification/ZenModeMsgEventReminderSettings.java
index 5a084e88e2d..e3a721f11fb 100644
--- a/src/com/android/settings/notification/ZenModeBehaviorSettings.java
+++ b/src/com/android/settings/notification/ZenModeMsgEventReminderSettings.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -16,6 +16,8 @@
package com.android.settings.notification;
+import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES;
+
import android.content.Context;
import android.provider.SearchIndexableResource;
@@ -31,7 +33,7 @@ import java.util.ArrayList;
import java.util.List;
@SearchIndexable
-public class ZenModeBehaviorSettings extends ZenModeSettingsBase implements Indexable {
+public class ZenModeMsgEventReminderSettings extends ZenModeSettingsBase implements Indexable {
@Override
protected List createPreferenceControllers(Context context) {
@@ -41,23 +43,19 @@ public class ZenModeBehaviorSettings extends ZenModeSettingsBase implements Inde
private static List buildPreferenceControllers(Context context,
Lifecycle lifecycle) {
List controllers = new ArrayList<>();
- controllers.add(new ZenModeAlarmsPreferenceController(context, lifecycle));
- controllers.add(new ZenModeMediaPreferenceController(context, lifecycle));
- controllers.add(new ZenModeSystemPreferenceController(context, lifecycle));
controllers.add(new ZenModeEventsPreferenceController(context, lifecycle));
controllers.add(new ZenModeRemindersPreferenceController(context, lifecycle));
controllers.add(new ZenModeMessagesPreferenceController(context, lifecycle));
- controllers.add(new ZenModeCallsPreferenceController(context, lifecycle));
- controllers.add(new ZenModeRepeatCallersPreferenceController(context, lifecycle,
- context.getResources().getInteger(com.android.internal.R.integer
- .config_zen_repeat_callers_threshold)));
- controllers.add(new ZenModeBehaviorFooterPreferenceController(context, lifecycle));
+ controllers.add(new ZenModeStarredContactsPreferenceController(context, lifecycle,
+ PRIORITY_CATEGORY_MESSAGES, "zen_mode_starred_contacts_messages"));
+ controllers.add(new ZenModeBehaviorFooterPreferenceController(context, lifecycle,
+ R.string.zen_msg_event_reminder_footer));
return controllers;
}
@Override
protected int getPreferenceScreenResId() {
- return R.xml.zen_mode_behavior_settings;
+ return R.xml.zen_mode_msg_event_reminder_settings;
}
@Override
@@ -77,7 +75,7 @@ public class ZenModeBehaviorSettings extends ZenModeSettingsBase implements Inde
final ArrayList result = new ArrayList<>();
final SearchIndexableResource sir = new SearchIndexableResource(context);
- sir.xmlResId = R.xml.zen_mode_behavior_settings;
+ sir.xmlResId = R.xml.zen_mode_msg_event_reminder_settings;
result.add(sir);
return result;
}
diff --git a/src/com/android/settings/notification/ZenModeRestrictNotificationsSettings.java b/src/com/android/settings/notification/ZenModeRestrictNotificationsSettings.java
index 966e932d144..a2a0ba7f008 100644
--- a/src/com/android/settings/notification/ZenModeRestrictNotificationsSettings.java
+++ b/src/com/android/settings/notification/ZenModeRestrictNotificationsSettings.java
@@ -70,7 +70,6 @@ public class ZenModeRestrictNotificationsSettings extends ZenModeSettingsBase im
custom.displayPreference(getPreferenceScreen());
if (mShowMenuSelected) {
- custom.select();
metrics.action(mContext, ACTION_ZEN_SHOW_CUSTOM, true);
} else {
metrics.action(mContext, ACTION_ZEN_SHOW_CUSTOM, false);
diff --git a/src/com/android/settings/notification/ZenModeSettings.java b/src/com/android/settings/notification/ZenModeSettings.java
index ddbfcb64879..3fb5a4b9be6 100644
--- a/src/com/android/settings/notification/ZenModeSettings.java
+++ b/src/com/android/settings/notification/ZenModeSettings.java
@@ -16,6 +16,15 @@
package com.android.settings.notification;
+import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_ALARMS;
+import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_CALLS;
+import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_EVENTS;
+import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_MEDIA;
+import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES;
+import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_REMINDERS;
+import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_REPEAT_CALLERS;
+import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_SYSTEM;
+
import android.app.AutomaticZenRule;
import android.app.FragmentManager;
import android.app.NotificationManager;
@@ -42,19 +51,13 @@ import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.function.Predicate;
@SearchIndexable
public class ZenModeSettings extends ZenModeSettingsBase {
- private static final String KEY_SOUND = "zen_effect_sound";
-
@Override
public void onResume() {
super.onResume();
- CheckBoxPreference soundPreference =
- (CheckBoxPreference) getPreferenceScreen().findPreference(KEY_SOUND);
- if (soundPreference != null) {
- soundPreference.setChecked(true);
- }
}
@Override
@@ -80,7 +83,9 @@ public class ZenModeSettings extends ZenModeSettingsBase {
private static List buildPreferenceControllers(Context context,
Lifecycle lifecycle, FragmentManager fragmentManager) {
List controllers = new ArrayList<>();
- controllers.add(new ZenModeBehaviorPreferenceController(context, lifecycle));
+ controllers.add(new ZenModeBehaviorMsgEventReminderPreferenceController(context, lifecycle));
+ controllers.add(new ZenModeBehaviorSoundPreferenceController(context, lifecycle));
+ controllers.add(new ZenModeBehaviorCallsPreferenceController(context, lifecycle));
controllers.add(new ZenModeBlockedEffectsPreferenceController(context, lifecycle));
controllers.add(new ZenModeDurationPreferenceController(context, lifecycle,
fragmentManager));
@@ -100,19 +105,63 @@ public class ZenModeSettings extends ZenModeSettingsBase {
// these should match NotificationManager.Policy#ALL_PRIORITY_CATEGORIES
private static final int[] ALL_PRIORITY_CATEGORIES = {
- Policy.PRIORITY_CATEGORY_ALARMS,
- Policy.PRIORITY_CATEGORY_MEDIA,
- Policy.PRIORITY_CATEGORY_SYSTEM,
- Policy.PRIORITY_CATEGORY_REMINDERS,
- Policy.PRIORITY_CATEGORY_EVENTS,
- Policy.PRIORITY_CATEGORY_MESSAGES,
- Policy.PRIORITY_CATEGORY_CALLS,
- Policy.PRIORITY_CATEGORY_REPEAT_CALLERS,
+ PRIORITY_CATEGORY_ALARMS,
+ PRIORITY_CATEGORY_MEDIA,
+ PRIORITY_CATEGORY_SYSTEM,
+ PRIORITY_CATEGORY_MESSAGES,
+ PRIORITY_CATEGORY_EVENTS,
+ PRIORITY_CATEGORY_REMINDERS,
+ PRIORITY_CATEGORY_CALLS,
+ PRIORITY_CATEGORY_REPEAT_CALLERS,
};
- String getBehaviorSettingSummary(Policy policy, int zenMode) {
- List enabledCategories = getEnabledCategories(policy);
+ String getSoundSettingSummary(Policy policy) {
+ List enabledCategories = getEnabledCategories(policy,
+ category -> PRIORITY_CATEGORY_ALARMS == category
+ || PRIORITY_CATEGORY_MEDIA == category
+ || PRIORITY_CATEGORY_SYSTEM == category);
+ int numCategories = enabledCategories.size();
+ if (numCategories == 0) {
+ return mContext.getString(R.string.zen_sound_all_muted);
+ } else if (numCategories == 1) {
+ return mContext.getString(R.string.zen_sound_one_allowed,
+ enabledCategories.get(0).toLowerCase());
+ } else if (numCategories == 2) {
+ return mContext.getString(R.string.zen_sound_two_allowed,
+ enabledCategories.get(0).toLowerCase(),
+ enabledCategories.get(1).toLowerCase());
+ } else if (numCategories == 3) {
+ return mContext.getString(R.string.zen_sound_three_allowed,
+ enabledCategories.get(0).toLowerCase(),
+ enabledCategories.get(1).toLowerCase(),
+ enabledCategories.get(2).toLowerCase());
+ } else {
+ return mContext.getString(R.string.zen_sound_none_muted);
+ }
+ }
+ String getCallsSettingSummary(Policy policy) {
+ List enabledCategories = getEnabledCategories(policy,
+ category -> PRIORITY_CATEGORY_CALLS == category
+ || PRIORITY_CATEGORY_REPEAT_CALLERS == category);
+ int numCategories = enabledCategories.size();
+ if (numCategories == 0) {
+ return mContext.getString(R.string.zen_mode_no_exceptions);
+ } else if (numCategories == 1) {
+ return mContext.getString(R.string.zen_mode_calls_summary_one,
+ enabledCategories.get(0).toLowerCase());
+ } else {
+ return mContext.getString(R.string.zen_mode_calls_summary_two,
+ enabledCategories.get(0).toLowerCase(),
+ enabledCategories.get(1).toLowerCase());
+ }
+ }
+
+ String getMsgEventReminderSettingSummary(Policy policy) {
+ List enabledCategories = getEnabledCategories(policy,
+ category -> PRIORITY_CATEGORY_EVENTS == category
+ || PRIORITY_CATEGORY_REMINDERS == category
+ || PRIORITY_CATEGORY_MESSAGES == category);
int numCategories = enabledCategories.size();
if (numCategories == 0) {
return mContext.getString(R.string.zen_mode_no_exceptions);
@@ -201,22 +250,19 @@ public class ZenModeSettings extends ZenModeSettingsBase {
return count;
}
- private List getEnabledCategories(Policy policy) {
+ private List getEnabledCategories(Policy policy,
+ Predicate filteredCategories) {
List enabledCategories = new ArrayList<>();
for (int category : ALL_PRIORITY_CATEGORIES) {
- if (isCategoryEnabled(policy, category)) {
- if (category == Policy.PRIORITY_CATEGORY_ALARMS) {
+ if (filteredCategories.test(category) && isCategoryEnabled(policy, category)) {
+ if (category == PRIORITY_CATEGORY_ALARMS) {
enabledCategories.add(mContext.getString(R.string.zen_mode_alarms));
- } else if (category == Policy.PRIORITY_CATEGORY_MEDIA) {
+ } else if (category == PRIORITY_CATEGORY_MEDIA) {
enabledCategories.add(mContext.getString(
R.string.zen_mode_media));
- } else if (category == Policy.PRIORITY_CATEGORY_SYSTEM) {
+ } else if (category == PRIORITY_CATEGORY_SYSTEM) {
enabledCategories.add(mContext.getString(
R.string.zen_mode_system));
- } else if (category == Policy.PRIORITY_CATEGORY_REMINDERS) {
- enabledCategories.add(mContext.getString(R.string.zen_mode_reminders));
- } else if (category == Policy.PRIORITY_CATEGORY_EVENTS) {
- enabledCategories.add(mContext.getString(R.string.zen_mode_events));
} else if (category == Policy.PRIORITY_CATEGORY_MESSAGES) {
if (policy.priorityMessageSenders == Policy.PRIORITY_SENDERS_ANY) {
enabledCategories.add(mContext.getString(
@@ -225,13 +271,20 @@ public class ZenModeSettings extends ZenModeSettingsBase {
enabledCategories.add(mContext.getString(
R.string.zen_mode_selected_messages));
}
+ } else if (category == Policy.PRIORITY_CATEGORY_EVENTS) {
+ enabledCategories.add(mContext.getString(R.string.zen_mode_events));
+ } else if (category == Policy.PRIORITY_CATEGORY_REMINDERS) {
+ enabledCategories.add(mContext.getString(R.string.zen_mode_reminders));
} else if (category == Policy.PRIORITY_CATEGORY_CALLS) {
if (policy.priorityCallSenders == Policy.PRIORITY_SENDERS_ANY) {
enabledCategories.add(mContext.getString(
R.string.zen_mode_all_callers));
+ } else if (policy.priorityCallSenders == Policy.PRIORITY_SENDERS_CONTACTS){
+ enabledCategories.add(mContext.getString(
+ R.string.zen_mode_contacts_callers));
} else {
enabledCategories.add(mContext.getString(
- R.string.zen_mode_selected_callers));
+ R.string.zen_mode_starred_callers));
}
} else if (category == Policy.PRIORITY_CATEGORY_REPEAT_CALLERS) {
if (!enabledCategories.contains(mContext.getString(
@@ -248,10 +301,6 @@ public class ZenModeSettings extends ZenModeSettingsBase {
private boolean isCategoryEnabled(Policy policy, int categoryType) {
return (policy.priorityCategories & categoryType) != 0;
}
-
- private boolean isEffectSuppressed(Policy policy, int effect) {
- return (policy.suppressedVisualEffects & effect) != 0;
- }
}
/**
diff --git a/src/com/android/settings/notification/ZenModeSoundVibrationSettings.java b/src/com/android/settings/notification/ZenModeSoundVibrationSettings.java
new file mode 100644
index 00000000000..b72460c8a34
--- /dev/null
+++ b/src/com/android/settings/notification/ZenModeSoundVibrationSettings.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2018 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 android.content.Context;
+import android.provider.SearchIndexableResource;
+
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.R;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
+import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.search.SearchIndexable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@SearchIndexable
+public class ZenModeSoundVibrationSettings extends ZenModeSettingsBase implements Indexable {
+
+ @Override
+ protected List createPreferenceControllers(Context context) {
+ return buildPreferenceControllers(context, getLifecycle());
+ }
+
+ private static List buildPreferenceControllers(Context context,
+ Lifecycle lifecycle) {
+ List controllers = new ArrayList<>();
+ controllers.add(new ZenModeAlarmsPreferenceController(context, lifecycle));
+ controllers.add(new ZenModeMediaPreferenceController(context, lifecycle));
+ controllers.add(new ZenModeSystemPreferenceController(context, lifecycle));
+ controllers.add(new ZenModeBehaviorFooterPreferenceController(context, lifecycle,
+ R.string.zen_sound_footer));
+ return controllers;
+ }
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.zen_mode_sound_vibration_settings;
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return MetricsEvent.NOTIFICATION_ZEN_MODE_PRIORITY;
+ }
+
+ /**
+ * For Search.
+ */
+ public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider() {
+
+ @Override
+ public List getXmlResourcesToIndex(Context context,
+ boolean enabled) {
+ final ArrayList result = new ArrayList<>();
+
+ final SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.zen_mode_sound_vibration_settings;
+ result.add(sir);
+ return result;
+ }
+
+ @Override
+ public List getNonIndexableKeys(Context context) {
+ final List keys = super.getNonIndexableKeys(context);
+ return keys;
+ }
+
+ @Override
+ public List createPreferenceControllers(Context context) {
+ return buildPreferenceControllers(context, null);
+ }
+ };
+}
diff --git a/src/com/android/settings/notification/ZenModeStarredContactsPreferenceController.java b/src/com/android/settings/notification/ZenModeStarredContactsPreferenceController.java
new file mode 100644
index 00000000000..0996534b9d9
--- /dev/null
+++ b/src/com/android/settings/notification/ZenModeStarredContactsPreferenceController.java
@@ -0,0 +1,153 @@
+/*
+ * Copyright (C) 2018 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.NotificationManager.Policy.PRIORITY_CATEGORY_CALLS;
+import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES;
+import static android.app.NotificationManager.Policy.PRIORITY_SENDERS_STARRED;
+
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.database.Cursor;
+import android.icu.text.ListFormatter;
+import android.provider.Contacts;
+import android.provider.ContactsContract;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.internal.annotations.VisibleForTesting;
+import com.android.settings.R;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ZenModeStarredContactsPreferenceController extends
+ AbstractZenModePreferenceController implements Preference.OnPreferenceClickListener {
+
+ protected static String KEY;
+ private Preference mPreference;
+ private final int mPriorityCategory;
+ private final PackageManager mPackageManager;
+
+ @VisibleForTesting
+ Intent mStarredContactsIntent;
+ @VisibleForTesting
+ Intent mFallbackIntent;
+
+ public ZenModeStarredContactsPreferenceController(Context context, Lifecycle lifecycle, int
+ priorityCategory, String key) {
+ super(context, key, lifecycle);
+ KEY = key;
+
+ mPriorityCategory = priorityCategory;
+ mPackageManager = mContext.getPackageManager();
+
+ mStarredContactsIntent = new Intent(Contacts.Intents.UI.LIST_STARRED_ACTION);
+
+ mFallbackIntent = new Intent(Intent.ACTION_MAIN);
+ mFallbackIntent.addCategory(Intent.CATEGORY_APP_CONTACTS);
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreference = screen.findPreference(KEY);
+ mPreference.setOnPreferenceClickListener(this);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ if (mPriorityCategory == PRIORITY_CATEGORY_CALLS) {
+ return mBackend.isPriorityCategoryEnabled(PRIORITY_CATEGORY_CALLS)
+ && mBackend.getPriorityCallSenders() == PRIORITY_SENDERS_STARRED
+ && isIntentValid();
+ } else if (mPriorityCategory == PRIORITY_CATEGORY_MESSAGES) {
+ return mBackend.isPriorityCategoryEnabled(PRIORITY_CATEGORY_MESSAGES)
+ && mBackend.getPriorityMessageSenders() == PRIORITY_SENDERS_STARRED
+ && isIntentValid();
+ } else {
+ // invalid category
+ return false;
+ }
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+
+ List starredContacts = getStarredContacts();
+ int numStarredContacts = starredContacts.size();
+
+ List displayContacts = new ArrayList<>();
+
+ if (numStarredContacts == 0) {
+ displayContacts.add(mContext.getString(R.string.zen_mode_from_none));
+ } else {
+ for (int i = 0; i < 2 && i < numStarredContacts; i++) {
+ displayContacts.add(starredContacts.get(i));
+ }
+
+ if (numStarredContacts == 3) {
+ displayContacts.add(starredContacts.get(2));
+ } else if (numStarredContacts > 2) {
+ displayContacts.add(mContext.getResources().getQuantityString(
+ R.plurals.zen_mode_starred_contacts_summary_additional_contacts,
+ numStarredContacts - 2, numStarredContacts - 2));
+ }
+ }
+
+ mPreference.setSummary(ListFormatter.getInstance().format(displayContacts));
+ }
+
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ if (mStarredContactsIntent.resolveActivity(mPackageManager) != null) {
+ mContext.startActivity(mStarredContactsIntent);
+ } else {
+ mContext.startActivity(mFallbackIntent);
+ }
+ return true;
+ }
+
+ private List getStarredContacts() {
+ List starredContacts = new ArrayList<>();
+
+ Cursor cursor = mContext.getContentResolver().query(ContactsContract.Contacts.CONTENT_URI,
+ new String[]{ContactsContract.Contacts.DISPLAY_NAME_PRIMARY},
+ ContactsContract.Data.STARRED + "=1", null,
+ ContactsContract.Data.TIMES_CONTACTED);
+
+ if (cursor.moveToFirst()) {
+ do {
+ starredContacts.add(cursor.getString(0));
+ } while (cursor.moveToNext());
+ }
+ return starredContacts;
+ }
+
+ private boolean isIntentValid() {
+ return mStarredContactsIntent.resolveActivity(mPackageManager) != null
+ || mFallbackIntent.resolveActivity(mPackageManager) != null;
+ }
+}
diff --git a/src/com/android/settings/notification/ZenModeVisEffectsCustomPreferenceController.java b/src/com/android/settings/notification/ZenModeVisEffectsCustomPreferenceController.java
index 550fda4c40a..5baf0fac11d 100644
--- a/src/com/android/settings/notification/ZenModeVisEffectsCustomPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModeVisEffectsCustomPreferenceController.java
@@ -18,6 +18,7 @@ package com.android.settings.notification;
import android.app.NotificationManager.Policy;
import android.content.Context;
+
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
@@ -57,15 +58,12 @@ public class ZenModeVisEffectsCustomPreferenceController
pref.setChecked(areCustomOptionsSelected());
pref.setOnGearClickListener(p -> {
- new SubSettingLauncher(mContext)
- .setDestination(ZenModeBlockedEffectsSettings.class.getName())
- .setTitleRes(R.string.zen_mode_what_to_block_title)
- .setSourceMetricsCategory(MetricsProto.MetricsEvent.SETTINGS_ZEN_NOTIFICATIONS)
- .launch();
+ launchCustomSettings();
+
});
pref.setOnRadioButtonClickListener(p -> {
- select();
+ launchCustomSettings();
});
}
@@ -84,9 +82,14 @@ public class ZenModeVisEffectsCustomPreferenceController
protected void select() {
mMetricsFeatureProvider.action(mContext,
MetricsProto.MetricsEvent.ACTION_ZEN_CUSTOM, true);
- mBackend.savePolicy(mBackend.mPolicy.priorityCategories,
- mBackend.mPolicy.priorityCallSenders,
- mBackend.mPolicy.priorityMessageSenders,
- INTERRUPTIVE_EFFECTS);
+ }
+
+ private void launchCustomSettings() {
+ select();
+ new SubSettingLauncher(mContext)
+ .setDestination(ZenModeBlockedEffectsSettings.class.getName())
+ .setTitleRes(R.string.zen_mode_what_to_block_title)
+ .setSourceMetricsCategory(MetricsProto.MetricsEvent.SETTINGS_ZEN_NOTIFICATIONS)
+ .launch();
}
}
\ No newline at end of file
diff --git a/src/com/android/settings/security/LockdownButtonPreferenceController.java b/src/com/android/settings/security/LockdownButtonPreferenceController.java
index dd6e0d0f7c2..5b29868f06d 100644
--- a/src/com/android/settings/security/LockdownButtonPreferenceController.java
+++ b/src/com/android/settings/security/LockdownButtonPreferenceController.java
@@ -21,7 +21,6 @@ import android.os.UserHandle;
import android.provider.Settings;
import com.android.internal.widget.LockPatternUtils;
-import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.TogglePreferenceController;
public class LockdownButtonPreferenceController extends TogglePreferenceController {
@@ -36,9 +35,9 @@ public class LockdownButtonPreferenceController extends TogglePreferenceControll
@Override
public int getAvailabilityStatus() {
if (mLockPatternUtils.isSecure(UserHandle.myUserId())) {
- return BasePreferenceController.AVAILABLE;
+ return AVAILABLE;
} else {
- return BasePreferenceController.DISABLED_FOR_USER;
+ return DISABLED_FOR_USER;
}
}
diff --git a/src/com/android/settings/security/LockscreenDashboardFragment.java b/src/com/android/settings/security/LockscreenDashboardFragment.java
index c9ed2c2af77..1cabb92ae19 100644
--- a/src/com/android/settings/security/LockscreenDashboardFragment.java
+++ b/src/com/android/settings/security/LockscreenDashboardFragment.java
@@ -18,7 +18,6 @@ package com.android.settings.security;
import android.content.Context;
import android.provider.SearchIndexableResource;
-import androidx.annotation.VisibleForTesting;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
@@ -34,6 +33,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import androidx.annotation.VisibleForTesting;
+
/**
* Settings screen for lock screen preference
*/
diff --git a/src/com/android/settings/slices/SettingsSliceProvider.java b/src/com/android/settings/slices/SettingsSliceProvider.java
index 179af6e815d..edeb2b5f28c 100644
--- a/src/com/android/settings/slices/SettingsSliceProvider.java
+++ b/src/com/android/settings/slices/SettingsSliceProvider.java
@@ -27,9 +27,7 @@ import android.graphics.drawable.Icon;
import android.net.Uri;
import android.net.wifi.WifiManager;
import android.provider.Settings;
-import androidx.annotation.VisibleForTesting;
import android.provider.SettingsSlicesContract;
-import androidx.core.graphics.drawable.IconCompat;
import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;
@@ -45,6 +43,8 @@ import java.util.Map;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
+import androidx.annotation.VisibleForTesting;
+import androidx.core.graphics.drawable.IconCompat;
import androidx.slice.Slice;
import androidx.slice.SliceProvider;
import androidx.slice.builders.ListBuilder;
diff --git a/src/com/android/settings/sound/AudioSwitchPreferenceController.java b/src/com/android/settings/sound/AudioSwitchPreferenceController.java
index d9473d81707..265564e5d5a 100644
--- a/src/com/android/settings/sound/AudioSwitchPreferenceController.java
+++ b/src/com/android/settings/sound/AudioSwitchPreferenceController.java
@@ -161,7 +161,6 @@ public abstract class AudioSwitchPreferenceController extends BasePreferenceCont
*/
@Override
public void onConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state) {
- updateState(mPreference);
}
@Override
@@ -174,6 +173,12 @@ public abstract class AudioSwitchPreferenceController extends BasePreferenceCont
updateState(mPreference);
}
+ @Override
+ public void onProfileConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state,
+ int bluetoothProfile) {
+ updateState(mPreference);
+ }
+
@Override
public void onBluetoothStateChanged(int bluetoothState) {
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java
index f257f549436..a4907dadac1 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java
@@ -18,7 +18,15 @@ package com.android.settings.accessibility;
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
import android.content.Context;
+import android.os.Vibrator;
+import android.provider.Settings;
+import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
@@ -26,6 +34,8 @@ import com.android.settings.testutils.XmlTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import java.util.ArrayList;
@@ -45,4 +55,31 @@ public class AccessibilitySettingsTest {
assertThat(keys).containsAllIn(niks);
}
-}
\ No newline at end of file
+
+ @Test
+ public void testUpdateVibrationSummary_shouldUpdateSummary() {
+ MockitoAnnotations.initMocks(this);
+ final Context mContext = RuntimeEnvironment.application;
+ final AccessibilitySettings mSettings = spy(new AccessibilitySettings());
+
+ final Preference mVibrationPreferenceScreen = new Preference(mContext);
+ doReturn(mVibrationPreferenceScreen).when(mSettings).findPreference(anyString());
+
+ doReturn(mContext).when(mSettings).getContext();
+
+ mVibrationPreferenceScreen.setKey("vibration_preference_screen");
+
+ Settings.System.putInt(mContext.getContentResolver(),
+ Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
+ Vibrator.VIBRATION_INTENSITY_OFF);
+
+ Settings.System.putInt(mContext.getContentResolver(),
+ Settings.System.HAPTIC_FEEDBACK_INTENSITY,
+ Vibrator.VIBRATION_INTENSITY_OFF);
+
+ mSettings.updateVibrationSummary(mVibrationPreferenceScreen);
+ assertThat(mVibrationPreferenceScreen.getSummary()).isEqualTo(
+ VibrationIntensityPreferenceController.getIntensityString(mContext,
+ Vibrator.VIBRATION_INTENSITY_OFF));
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java
index fbc698c548b..ed9501554eb 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java
@@ -15,11 +15,11 @@
*/
package com.android.settings.bluetooth;
-import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
-
import android.media.AudioManager;
+
import com.android.settings.connecteddevice.DevicePreferenceCallback;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
@@ -150,60 +150,61 @@ public class AvailableMediaBluetoothDeviceUpdaterTest {
}
@Test
- public void onConnectionStateChanged_a2dpDeviceConnected_notInCall_addPreference() {
+ public void onProfileConnectionStateChanged_a2dpDeviceConnected_notInCall_addPreference() {
mShadowAudioManager.setMode(AudioManager.MODE_NORMAL);
when(mBluetoothDeviceUpdater.
isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
when(mCachedBluetoothDevice.isA2dpDevice()).thenReturn(true);
- mBluetoothDeviceUpdater.onConnectionStateChanged(mCachedBluetoothDevice,
- BluetoothAdapter.STATE_CONNECTED);
+ mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED, BluetoothProfile.A2DP);
verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
}
@Test
- public void onConnectionStateChanged_a2dpDeviceConnected_inCall_removePreference() {
+ public void onProfileConnectionStateChanged_a2dpDeviceConnected_inCall_removePreference() {
mShadowAudioManager.setMode(AudioManager.MODE_IN_CALL);
when(mBluetoothDeviceUpdater.
isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
when(mCachedBluetoothDevice.isA2dpDevice()).thenReturn(true);
- mBluetoothDeviceUpdater.onConnectionStateChanged(mCachedBluetoothDevice,
- BluetoothAdapter.STATE_CONNECTED);
+ mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED, BluetoothProfile.A2DP);
verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
}
+
@Test
- public void onConnectionStateChanged_hfpDeviceConnected_notInCall_removePreference() {
+ public void onProfileConnectionStateChanged_hfpDeviceConnected_notInCall_removePreference() {
mShadowAudioManager.setMode(AudioManager.MODE_NORMAL);
when(mBluetoothDeviceUpdater.
isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
when(mCachedBluetoothDevice.isHfpDevice()).thenReturn(true);
- mBluetoothDeviceUpdater.onConnectionStateChanged(mCachedBluetoothDevice,
- BluetoothAdapter.STATE_CONNECTED);
+ mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED, BluetoothProfile.A2DP);
verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
}
@Test
- public void onConnectionStateChanged_hfpDeviceConnected_inCall_addPreference() {
+ public void onProfileConnectionStateChanged_hfpDeviceConnected_inCall_addPreference() {
mShadowAudioManager.setMode(AudioManager.MODE_IN_CALL);
when(mBluetoothDeviceUpdater.
isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
when(mCachedBluetoothDevice.isHfpDevice()).thenReturn(true);
- mBluetoothDeviceUpdater.onConnectionStateChanged(mCachedBluetoothDevice,
- BluetoothAdapter.STATE_CONNECTED);
+ mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED, BluetoothProfile.A2DP);
verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
}
@Test
- public void onConnectionStateChanged_deviceDisconnected_removePreference() {
- mBluetoothDeviceUpdater.onConnectionStateChanged(mCachedBluetoothDevice,
- BluetoothAdapter.STATE_DISCONNECTED);
+ public void onProfileConnectionStateChanged_deviceDisconnected_removePreference() {
+ mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
+ BluetoothProfile.STATE_DISCONNECTED, BluetoothProfile.A2DP);
verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
}
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsProfilesControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsProfilesControllerTest.java
index fc99744bbc7..74499483ac0 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsProfilesControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsProfilesControllerTest.java
@@ -155,6 +155,11 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
return true;
}
+ @Override
+ public int getProfileId() {
+ return 0;
+ }
+
@Override
public int getOrdinal() {
return 0;
diff --git a/tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java
index 56e638a9ed1..483df01a6b8 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java
@@ -16,6 +16,7 @@
package com.android.settings.bluetooth;
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
@@ -23,11 +24,11 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
-
import android.media.AudioManager;
+
import com.android.settings.connecteddevice.DevicePreferenceCallback;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
@@ -75,6 +76,7 @@ public class ConnectedBluetoothDeviceUpdaterTest {
private Collection cachedDevices;
private ShadowAudioManager mShadowAudioManager;
+
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
@@ -151,60 +153,61 @@ public class ConnectedBluetoothDeviceUpdaterTest {
}
@Test
- public void onConnectionStateChanged_a2dpDeviceConnected_inCall_addPreference() {
+ public void onProfileConnectionStateChanged_a2dpDeviceConnected_inCall_addPreference() {
mShadowAudioManager.setMode(AudioManager.MODE_IN_CALL);
when(mBluetoothDeviceUpdater.
isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
when(mCachedBluetoothDevice.isA2dpDevice()).thenReturn(true);
- mBluetoothDeviceUpdater.onConnectionStateChanged(mCachedBluetoothDevice,
- BluetoothAdapter.STATE_CONNECTED);
+ mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED, BluetoothProfile.A2DP);
verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
}
@Test
- public void onConnectionStateChanged_a2dpDeviceConnected_notInCall_removePreference() {
+ public void onProfileConnectionStateChanged_a2dpDeviceConnected_notInCall_removePreference() {
mShadowAudioManager.setMode(AudioManager.MODE_NORMAL);
when(mBluetoothDeviceUpdater.
isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
when(mCachedBluetoothDevice.isA2dpDevice()).thenReturn(true);
- mBluetoothDeviceUpdater.onConnectionStateChanged(mCachedBluetoothDevice,
- BluetoothAdapter.STATE_CONNECTED);
+ mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED, BluetoothProfile.A2DP);
verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
}
+
@Test
- public void onConnectionStateChanged_hfpDeviceConnected_inCall_removePreference() {
+ public void onProfileConnectionStateChanged_hfpDeviceConnected_inCall_removePreference() {
mShadowAudioManager.setMode(AudioManager.MODE_IN_CALL);
when(mBluetoothDeviceUpdater.
isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
when(mCachedBluetoothDevice.isHfpDevice()).thenReturn(true);
- mBluetoothDeviceUpdater.onConnectionStateChanged(mCachedBluetoothDevice,
- BluetoothAdapter.STATE_CONNECTED);
+ mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED, BluetoothProfile.A2DP);
verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
}
@Test
- public void onConnectionStateChanged_hfpDeviceConnected_notInCall_addPreference() {
+ public void onProfileConnectionStateChanged_hfpDeviceConnected_notInCall_addPreference() {
mShadowAudioManager.setMode(AudioManager.MODE_NORMAL);
when(mBluetoothDeviceUpdater.
isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
when(mCachedBluetoothDevice.isHfpDevice()).thenReturn(true);
- mBluetoothDeviceUpdater.onConnectionStateChanged(mCachedBluetoothDevice,
- BluetoothAdapter.STATE_CONNECTED);
+ mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED, BluetoothProfile.A2DP);
verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
}
@Test
- public void onConnectionStateChanged_deviceDisconnected_removePreference() {
- mBluetoothDeviceUpdater.onConnectionStateChanged(mCachedBluetoothDevice,
- BluetoothAdapter.STATE_DISCONNECTED);
+ public void onProfileConnectionStateChanged_deviceDisconnected_removePreference() {
+ mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
+ BluetoothProfile.STATE_DISCONNECTED, BluetoothProfile.A2DP);
verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
}
diff --git a/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
index e0ba82916b3..fae014f7b10 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
@@ -22,7 +22,7 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
@@ -76,7 +76,7 @@ public class SavedBluetoothDeviceUpdaterTest {
}
@Test
- public void testUpdate_filterMatch_addPreference() {
+ public void update_filterMatch_addPreference() {
doReturn(BluetoothDevice.BOND_BONDED).when(mBluetoothDevice).getBondState();
doReturn(false).when(mBluetoothDevice).isConnected();
@@ -86,7 +86,7 @@ public class SavedBluetoothDeviceUpdaterTest {
}
@Test
- public void testUpdate_filterNotMatch_removePreference() {
+ public void update_filterNotMatch_removePreference() {
doReturn(BluetoothDevice.BOND_NONE).when(mBluetoothDevice).getBondState();
doReturn(true).when(mBluetoothDevice).isConnected();
@@ -96,17 +96,17 @@ public class SavedBluetoothDeviceUpdaterTest {
}
@Test
- public void testOnConnectionStateChanged_deviceConnected_removePreference() {
- mBluetoothDeviceUpdater
- .onConnectionStateChanged(mCachedBluetoothDevice, BluetoothAdapter.STATE_CONNECTED);
+ public void onProfileConnectionStateChanged_deviceConnected_removePreference() {
+ mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED, BluetoothProfile.A2DP);
verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
}
@Test
- public void testOnConnectionStateChanged_deviceDisconnected_addPreference() {
- mBluetoothDeviceUpdater
- .onConnectionStateChanged(mCachedBluetoothDevice, BluetoothAdapter.STATE_DISCONNECTED);
+ public void onProfileConnectionStateChanged_deviceDisconnected_addPreference() {
+ mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
+ BluetoothProfile.STATE_DISCONNECTED, BluetoothProfile.A2DP);
verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
}
diff --git a/tests/robotests/src/com/android/settings/core/BasePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/core/BasePreferenceControllerTest.java
index 611c1b5fb46..d5e8e15cfa2 100644
--- a/tests/robotests/src/com/android/settings/core/BasePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/core/BasePreferenceControllerTest.java
@@ -16,12 +16,12 @@
package com.android.settings.core;
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
import static com.android.settings.core.BasePreferenceController.DISABLED_DEPENDENT_SETTING;
import static com.android.settings.core.BasePreferenceController.DISABLED_FOR_USER;
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -36,8 +36,10 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RuntimeEnvironment;
+import java.util.ArrayList;
+import java.util.List;
+
import androidx.preference.Preference;
-import androidx.preference.PreferenceGroup;
import androidx.preference.PreferenceScreen;
@RunWith(SettingsRobolectricTestRunner.class)
@@ -72,6 +74,13 @@ public class BasePreferenceControllerTest {
assertThat(mPreferenceController.isAvailable()).isTrue();
}
+ @Test
+ public void isAvailable_availableStatusUnSearchable_returnsTrue() {
+ mPreferenceController.setAvailability(AVAILABLE_UNSEARCHABLE);
+
+ assertThat(mPreferenceController.isAvailable()).isTrue();
+ }
+
@Test
public void isAvailable_availableStatusUnsupportedOnDevice_returnsFalse() {
mPreferenceController.setAvailability(UNSUPPORTED_ON_DEVICE);
@@ -159,6 +168,36 @@ public class BasePreferenceControllerTest {
assertThat(preference.isEnabled()).isFalse();
}
+ @Test
+ public void updateNonIndexableKeys_controllerUnavailable_shouldAddKey() {
+ final List keys = new ArrayList<>();
+ mPreferenceController.setAvailability(UNSUPPORTED_ON_DEVICE);
+
+ mPreferenceController.updateNonIndexableKeys(keys);
+
+ assertThat(keys).containsExactly(mPreferenceController.getPreferenceKey());
+ }
+
+ @Test
+ public void updateNonIndexableKeys_controllerUnsearchable_shouldAddKey() {
+ final List keys = new ArrayList<>();
+ mPreferenceController.setAvailability(AVAILABLE_UNSEARCHABLE);
+
+ mPreferenceController.updateNonIndexableKeys(keys);
+
+ assertThat(keys).containsExactly(mPreferenceController.getPreferenceKey());
+ }
+
+ @Test
+ public void updateNonIndexableKeys_controllerAvailable_shouldNotAddKey() {
+ final List keys = new ArrayList<>();
+ mPreferenceController.setAvailability(AVAILABLE);
+
+ mPreferenceController.updateNonIndexableKeys(keys);
+
+ assertThat(keys).isEmpty();
+ }
+
private class FakeBasePreferenceController extends BasePreferenceController {
public int mAvailable;
diff --git a/tests/robotests/src/com/android/settings/display/NightDisplaySettingsTest.java b/tests/robotests/src/com/android/settings/display/NightDisplaySettingsTest.java
index e3f90929d2d..6942fd84d6c 100644
--- a/tests/robotests/src/com/android/settings/display/NightDisplaySettingsTest.java
+++ b/tests/robotests/src/com/android/settings/display/NightDisplaySettingsTest.java
@@ -48,8 +48,8 @@ public class NightDisplaySettingsTest {
}
@Test
- public void getCategoryKey_isCategoryNightLight() {
+ public void getCategoryKey_isCategoryNightDisplay() {
NightDisplaySettings settings = new NightDisplaySettings();
- assertThat(settings.getCategoryKey()).isEqualTo(CategoryKey.CATEGORY_NIGHT_LIGHT);
+ assertThat(settings.getCategoryKey()).isEqualTo(CategoryKey.CATEGORY_NIGHT_DISPLAY);
}
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryBroadcastReceiverTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryBroadcastReceiverTest.java
index 3fdbe837425..4583dd1b3b4 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryBroadcastReceiverTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryBroadcastReceiverTest.java
@@ -15,8 +15,11 @@
*/
package com.android.settings.fuelgauge;
+import static com.android.settings.fuelgauge.BatteryBroadcastReceiver.BatteryUpdateType;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
@@ -70,14 +73,14 @@ public class BatteryBroadcastReceiverTest {
}
@Test
- public void testOnReceive_batteryDataChanged_dataUpdated() {
+ public void testOnReceive_batteryLevelChanged_dataUpdated() {
mBatteryBroadcastReceiver.onReceive(mContext, mChargingIntent);
assertThat(mBatteryBroadcastReceiver.mBatteryLevel)
.isEqualTo(Utils.getBatteryPercentage(mChargingIntent));
assertThat(mBatteryBroadcastReceiver.mBatteryStatus)
.isEqualTo(Utils.getBatteryStatus(mContext.getResources(), mChargingIntent));
- verify(mBatteryListener).onBatteryChanged();
+ verify(mBatteryListener).onBatteryChanged(BatteryUpdateType.BATTERY_LEVEL);
}
@Test
@@ -85,7 +88,7 @@ public class BatteryBroadcastReceiverTest {
mBatteryBroadcastReceiver.onReceive(mContext,
new Intent(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED));
- verify(mBatteryListener).onBatteryChanged();
+ verify(mBatteryListener).onBatteryChanged(BatteryUpdateType.BATTERY_SAVER);
}
@Test
@@ -100,7 +103,7 @@ public class BatteryBroadcastReceiverTest {
assertThat(mBatteryBroadcastReceiver.mBatteryLevel).isEqualTo(batteryLevel);
assertThat(mBatteryBroadcastReceiver.mBatteryStatus).isEqualTo(batteryStatus);
- verify(mBatteryListener, never()).onBatteryChanged();
+ verify(mBatteryListener, never()).onBatteryChanged(anyInt());
}
@Test
@@ -115,6 +118,6 @@ public class BatteryBroadcastReceiverTest {
assertThat(mBatteryBroadcastReceiver.mBatteryStatus)
.isEqualTo(Utils.getBatteryStatus(mContext.getResources(), mChargingIntent));
// 2 times because register will force update the battery
- verify(mBatteryListener, times(2)).onBatteryChanged();
+ verify(mBatteryListener, times(2)).onBatteryChanged(BatteryUpdateType.MANUAL);
}
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/HighPowerDetailTest.java b/tests/robotests/src/com/android/settings/fuelgauge/HighPowerDetailTest.java
index 8029c5539ef..1817325e15a 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/HighPowerDetailTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/HighPowerDetailTest.java
@@ -18,27 +18,49 @@ package com.android.settings.fuelgauge;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import android.app.AppOpsManager;
import android.content.Context;
+import android.content.DialogInterface;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.fuelgauge.PowerWhitelistBackend;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
@RunWith(SettingsRobolectricTestRunner.class)
public class HighPowerDetailTest {
+ private static final int TEST_UID = 12000;
+ private static final String TEST_PACKAGE = "com.test.package";
private FakeFeatureFactory mFeatureFactory;
+ private HighPowerDetail mFragment;
+
+ @Mock
+ private PowerWhitelistBackend mPowerWhitelistBackend;
+ @Mock
+ private BatteryUtils mBatteryUtils;
@Before
public void setUp() {
mFeatureFactory = FakeFeatureFactory.setupForTest();
+
+ MockitoAnnotations.initMocks(this);
+ mFragment = spy(new HighPowerDetail());
+ mFragment.mBackend = mPowerWhitelistBackend;
+ mFragment.mBatteryUtils = mBatteryUtils;
+ mFragment.mPackageUid = TEST_UID;
+ mFragment.mPackageName = TEST_PACKAGE;
}
@Test
@@ -53,4 +75,13 @@ public class HighPowerDetailTest {
verify(mFeatureFactory.metricsFeatureProvider).action(any(Context.class),
eq(MetricsProto.MetricsEvent.APP_SPECIAL_PERMISSION_BATTERY_ALLOW), eq("app"));
}
+
+ @Test
+ public void onClick_appAddedToDozeWhitelist_getsUnrestricted() {
+ mFragment.mIsEnabled = true;
+ when(mPowerWhitelistBackend.isWhitelisted(TEST_PACKAGE)).thenReturn(false);
+ mFragment.onClick(null, DialogInterface.BUTTON_POSITIVE);
+ verify(mBatteryUtils).setForceAppStandby(TEST_UID, TEST_PACKAGE,
+ AppOpsManager.MODE_ALLOWED);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java
index 8a7e7a04687..ffa49d4f253 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java
@@ -18,6 +18,7 @@ package com.android.settings.fuelgauge;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.nullable;
+import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
@@ -86,7 +87,7 @@ public class PowerUsageAdvancedTest {
@Test
public void testOptionsMenu_menuAppToggle_metricEventInvoked() {
mFragment.mShowAllApps = false;
- doNothing().when(mFragment).restartBatteryStatsLoader();
+ doNothing().when(mFragment).restartBatteryStatsLoader(anyInt());
mFragment.onOptionsItemSelected(mToggleAppsMenu);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageBaseTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageBaseTest.java
index d9f572deefa..eb683c072e0 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageBaseTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageBaseTest.java
@@ -74,7 +74,7 @@ public class PowerUsageBaseTest {
}
@Override
- protected void refreshUi() {
+ protected void refreshUi(int refreshType) {
// Do nothing
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
index b48f00e295b..07341a14656 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
@@ -149,7 +149,7 @@ public class PowerUsageSummaryTest {
mFragment.initFeatureProvider();
mBatteryMeterView = new BatteryMeterView(mRealContext);
mBatteryMeterView.mDrawable = new BatteryMeterView.BatteryMeterDrawable(mRealContext, 0);
- doNothing().when(mFragment).restartBatteryStatsLoader();
+ doNothing().when(mFragment).restartBatteryStatsLoader(anyInt());
doReturn(mock(LoaderManager.class)).when(mFragment).getLoaderManager();
doReturn(MENU_ADVANCED_BATTERY).when(mAdvancedPageMenu).getItemId();
@@ -316,15 +316,6 @@ public class PowerUsageSummaryTest {
verify(mSummary1, times(2)).setOnLongClickListener(any(View.OnLongClickListener.class));
}
- @Test
- public void restartBatteryStatsLoader_notClearHeader_quickUpdateNotInvoked() {
- mFragment.mBatteryHeaderPreferenceController = mBatteryHeaderPreferenceController;
-
- mFragment.restartBatteryStatsLoader(false /* clearHeader */);
-
- verify(mBatteryHeaderPreferenceController, never()).quickUpdateHeaderPreference();
- }
-
@Test
public void optionsMenu_advancedPageEnabled() {
when(mFeatureFactory.powerUsageFeatureProvider.isPowerAccountingToggleEnabled())
@@ -360,7 +351,18 @@ public class PowerUsageSummaryTest {
when(mFragment.mBatteryTipPreferenceController.needUpdate()).thenReturn(false);
mFragment.updateBatteryTipFlag(new Bundle());
- mFragment.refreshUi();
+ mFragment.refreshUi(BatteryBroadcastReceiver.BatteryUpdateType.MANUAL);
+
+ verify(mFragment, never()).restartBatteryTipLoader();
+ }
+
+ @Test
+ public void refreshUi_batteryLevelChanged_doNotUpdateBatteryTip() {
+ mFragment.mBatteryTipPreferenceController = mock(BatteryTipPreferenceController.class);
+ when(mFragment.mBatteryTipPreferenceController.needUpdate()).thenReturn(true);
+ mFragment.updateBatteryTipFlag(new Bundle());
+
+ mFragment.refreshUi(BatteryBroadcastReceiver.BatteryUpdateType.BATTERY_LEVEL);
verify(mFragment, never()).restartBatteryTipLoader();
}
@@ -371,7 +373,7 @@ public class PowerUsageSummaryTest {
when(mFragment.mBatteryTipPreferenceController.needUpdate()).thenReturn(true);
mFragment.updateBatteryTipFlag(new Bundle());
- mFragment.refreshUi();
+ mFragment.refreshUi(BatteryBroadcastReceiver.BatteryUpdateType.MANUAL);
verify(mFragment).restartBatteryTipLoader();
}
diff --git a/tests/robotests/src/com/android/settings/notification/CallVolumePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/CallVolumePreferenceControllerTest.java
new file mode 100644
index 00000000000..bed45e5081b
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/CallVolumePreferenceControllerTest.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2018 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 com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.media.AudioManager;
+
+import com.android.settings.R;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.ShadowAudioManager;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = {ShadowAudioManager.class})
+public class CallVolumePreferenceControllerTest {
+ private static final String TEST_KEY = "Test_Key";
+
+ @Mock
+ private AudioHelper mHelper;
+
+ private Context mContext;
+ private CallVolumePreferenceController mController;
+ private ShadowAudioManager mShadowAudioManager;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mController = new CallVolumePreferenceController(mContext, TEST_KEY);
+ mController.setAudioHelper(mHelper);
+ mShadowAudioManager = ShadowAudioManager.getShadow();
+ }
+
+ @Test
+ public void getAvailabilityStatus_singleVolume_shouldReturnDisable() {
+ when(mHelper.isSingleVolume()).thenReturn(true);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_notSingleVolume_shouldReturnAvailable() {
+ when(mHelper.isSingleVolume()).thenReturn(false);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+ }
+
+ @Test
+ public void getMuteIcon_shouldEqualToOriginalIcon() {
+ assertThat(mController.getMuteIcon()).isEqualTo(R.drawable.ic_local_phone_24_lib);
+ }
+
+ @Test
+ public void getAudioStream_onBluetoothScoOff_shouldEqualToStreamVoiceCall() {
+ mShadowAudioManager.setBluetoothScoOn(false);
+
+ assertThat(mController.getAudioStream()).isEqualTo(AudioManager.STREAM_VOICE_CALL);
+ }
+
+ @Test
+ public void getAudioStream_onBluetoothScoOn_shouldEqualToStreamBtSco() {
+ mShadowAudioManager.setBluetoothScoOn(true);
+
+ assertThat(mController.getAudioStream()).isEqualTo(AudioManager.STREAM_BLUETOOTH_SCO);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/notification/VolumeSeekBarPreferenceTest.java b/tests/robotests/src/com/android/settings/notification/VolumeSeekBarPreferenceTest.java
index c32f96a077f..5955aa8521d 100644
--- a/tests/robotests/src/com/android/settings/notification/VolumeSeekBarPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/notification/VolumeSeekBarPreferenceTest.java
@@ -50,17 +50,20 @@ public class VolumeSeekBarPreferenceTest {
}
@Test
- public void setStream_shouldSetMaxAndProgress() {
+ public void setStream_shouldSetMinMaxAndProgress() {
final int stream = 5;
final int max = 17;
+ final int min = 1;
final int progress = 4;
when(mAudioManager.getStreamMaxVolume(stream)).thenReturn(max);
+ when(mAudioManager.getStreamMinVolumeInt(stream)).thenReturn(min);
when(mAudioManager.getStreamVolume(stream)).thenReturn(progress);
doCallRealMethod().when(mPreference).setStream(anyInt());
mPreference.setStream(stream);
verify(mPreference).setMax(max);
+ verify(mPreference).setMin(min);
verify(mPreference).setProgress(progress);
}
}
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorCallsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorCallsPreferenceControllerTest.java
new file mode 100644
index 00000000000..b3a4b90b098
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorCallsPreferenceControllerTest.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2018 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 org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.NotificationManager;
+import android.content.Context;
+import androidx.preference.Preference;
+
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowApplication;
+import org.robolectric.util.ReflectionHelpers;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public final class ZenModeBehaviorCallsPreferenceControllerTest {
+
+ private ZenModeBehaviorCallsPreferenceController mController;
+ @Mock
+ private NotificationManager mNotificationManager;
+ @Mock
+ private NotificationManager.Policy mPolicy;
+
+ private Context mContext;
+ @Mock
+ private ZenModeBackend mBackend;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ ShadowApplication shadowApplication = ShadowApplication.getInstance();
+ shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
+
+ mContext = RuntimeEnvironment.application;
+ when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
+
+ mController = new ZenModeBehaviorCallsPreferenceController(
+ mContext, mock(Lifecycle.class));
+ ReflectionHelpers.setField(mController, "mBackend", mBackend);
+ }
+
+ @Test
+ public void testIsAvailable() {
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testHasSummary() {
+ Preference pref = mock(Preference.class);
+ mController.updateState(pref);
+ verify(pref).setSummary(any());
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorFooterPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorFooterPreferenceControllerTest.java
index 760efb281c5..0bf82144260 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorFooterPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorFooterPreferenceControllerTest.java
@@ -41,6 +41,7 @@ import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import android.util.ArrayMap;
+import com.android.settings.R;
import com.android.settings.notification.AbstractZenModePreferenceController.ZenModeConfigWrapper;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -77,6 +78,7 @@ public class ZenModeBehaviorFooterPreferenceControllerTest {
private Context mContext;
private ContentResolver mContentResolver;
+ private int mTitleResId = R.string.zen_sound_title;
@Before
public void setup() {
@@ -88,8 +90,8 @@ public class ZenModeBehaviorFooterPreferenceControllerTest {
mContentResolver = RuntimeEnvironment.application.getContentResolver();
when(mNotificationManager.getZenModeConfig()).thenReturn(mZenModeConfig);
- mController =
- new ZenModeBehaviorFooterPreferenceController(mContext, mock(Lifecycle.class));
+ mController = new ZenModeBehaviorFooterPreferenceController(
+ mContext, mock(Lifecycle.class), mTitleResId);
ReflectionHelpers.setField(mController, "mZenModeConfigWrapper", mConfigWrapper);
when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
@@ -112,13 +114,13 @@ public class ZenModeBehaviorFooterPreferenceControllerTest {
@Test
public void priorityOnly_footerIsAvailable() {
Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
- assertFalse(mController.isAvailable());
+ assertTrue(mController.isAvailable());
}
@Test
- public void zenModeOff_footerIsNotAvailable() {
+ public void zenModeOff_footerIsAvailable() {
Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_OFF);
- assertFalse(mController.isAvailable());
+ assertTrue(mController.isAvailable());
}
@Test
@@ -126,7 +128,7 @@ public class ZenModeBehaviorFooterPreferenceControllerTest {
Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_OFF);
mController.updateState(mockPref);
- verify(mockPref, never()).setTitle(any(String.class));
+ verify(mockPref).setTitle(mContext.getString(mTitleResId));
}
@Test
@@ -134,7 +136,7 @@ public class ZenModeBehaviorFooterPreferenceControllerTest {
Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
mController.updateState(mockPref);
- verify(mockPref, never()).setTitle(any(String.class));
+ verify(mockPref).setTitle(mContext.getString(mTitleResId));
}
@Test
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorMsgEventReminderPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorMsgEventReminderPreferenceControllerTest.java
new file mode 100644
index 00000000000..e30fc71eff1
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorMsgEventReminderPreferenceControllerTest.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2018 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 org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.NotificationManager;
+import android.content.Context;
+import androidx.preference.Preference;
+
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowApplication;
+import org.robolectric.util.ReflectionHelpers;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public final class ZenModeBehaviorMsgEventReminderPreferenceControllerTest {
+
+ private ZenModeBehaviorMsgEventReminderPreferenceController mController;
+ @Mock
+ private NotificationManager mNotificationManager;
+ @Mock
+ private NotificationManager.Policy mPolicy;
+
+ private Context mContext;
+ @Mock
+ private ZenModeBackend mBackend;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ ShadowApplication shadowApplication = ShadowApplication.getInstance();
+ shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
+
+ mContext = RuntimeEnvironment.application;
+ when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
+
+ mController = new ZenModeBehaviorMsgEventReminderPreferenceController(
+ mContext, mock(Lifecycle.class));
+ ReflectionHelpers.setField(mController, "mBackend", mBackend);
+ }
+
+ @Test
+ public void testIsAvailable() {
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testHasSummary() {
+ Preference pref = mock(Preference.class);
+ mController.updateState(pref);
+ verify(pref).setSummary(any());
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorSoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorSoundPreferenceControllerTest.java
new file mode 100644
index 00000000000..d3fab8fdf26
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorSoundPreferenceControllerTest.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2018 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 org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.NotificationManager;
+import android.content.Context;
+import androidx.preference.Preference;
+
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowApplication;
+import org.robolectric.util.ReflectionHelpers;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public final class ZenModeBehaviorSoundPreferenceControllerTest {
+
+ private ZenModeBehaviorSoundPreferenceController mController;
+ @Mock
+ private NotificationManager mNotificationManager;
+ @Mock
+ private NotificationManager.Policy mPolicy;
+
+ private Context mContext;
+ @Mock
+ private ZenModeBackend mBackend;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ ShadowApplication shadowApplication = ShadowApplication.getInstance();
+ shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
+
+ mContext = RuntimeEnvironment.application;
+ when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
+
+ mController = new ZenModeBehaviorSoundPreferenceController(
+ mContext, mock(Lifecycle.class));
+ ReflectionHelpers.setField(mController, "mBackend", mBackend);
+ }
+
+ @Test
+ public void testIsAvailable() {
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testHasSummary() {
+ Preference pref = mock(Preference.class);
+ mController.updateState(pref);
+ verify(pref).setSummary(any());
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java
index b26989d3475..5b2782fb6b7 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java
@@ -20,9 +20,9 @@ import static com.google.common.truth.Truth.assertThat;
import static junit.framework.Assert.assertEquals;
import android.app.NotificationManager;
+import android.app.NotificationManager.Policy;
import android.content.Context;
import android.provider.SearchIndexableResource;
-import android.provider.Settings;
import com.android.settings.R;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
@@ -46,54 +46,140 @@ public class ZenModeSettingsTest {
mBuilder = new ZenModeSettings.SummaryBuilder(mContext);
}
- @Test
- public void testGetBehaviorSettingSummary_noSoundsCanBypass() {
- NotificationManager.Policy policy = new NotificationManager.Policy(0, 0, 0);
- final String result = mBuilder.getBehaviorSettingSummary(policy,
- Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
-
- String totalSilence = mContext.getString(R.string.zen_mode_no_exceptions);
- assertEquals(totalSilence, result);
- }
-
- @Test
- public void testGetBehaviorSettingSummary_alarmsAndMedia() {
- NotificationManager.Policy policy = new NotificationManager.Policy(
- NotificationManager.Policy.PRIORITY_CATEGORY_ALARMS
- | NotificationManager.Policy.PRIORITY_CATEGORY_MEDIA,
- 0, 0);
- final String result = mBuilder.getBehaviorSettingSummary(policy,
- Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
-
- String alarmsAndMedia = mContext.getString(R.string.join_two_items,
- mContext.getString(R.string.zen_mode_alarms),
- mContext.getString(R.string.zen_mode_media).toLowerCase());
- assertEquals(alarmsAndMedia, result);
- }
-
@Test
public void testBlockedEffectsSummary_none() {
- NotificationManager.Policy policy = new NotificationManager.Policy(0, 0, 0, 0);
+ Policy policy = new Policy(0, 0, 0, 0);
assertEquals(mContext.getString(R.string.zen_mode_restrict_notifications_summary_muted),
mBuilder.getBlockedEffectsSummary(policy));
}
@Test
public void testBlockedEffectsSummary_some() {
- NotificationManager.Policy policy = new NotificationManager.Policy(
- 0, 0, 0, NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK);
+ Policy policy = new Policy(0, 0, 0, NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK);
assertEquals(mContext.getString(R.string.zen_mode_restrict_notifications_summary_custom),
mBuilder.getBlockedEffectsSummary(policy));
}
@Test
public void testBlockedEffectsSummary_all() {
- NotificationManager.Policy policy = new NotificationManager.Policy(
- 0, 0, 0, 511);
+ Policy policy = new Policy(0, 0, 0, 511);
assertEquals(mContext.getString(R.string.zen_mode_restrict_notifications_summary_hidden),
mBuilder.getBlockedEffectsSummary(policy));
}
+ @Test
+ public void testGetMsgEventReminderSettingSummary_none() {
+ Policy policy = new Policy(0, 0, 0, 0);
+ assertThat(mBuilder.getMsgEventReminderSettingSummary(policy)).isEqualTo("None");
+ }
+
+ @Test
+ public void testGetMsgEventReminderSettingSummary_single() {
+ Policy policy = new Policy(
+ Policy.PRIORITY_CATEGORY_ALARMS | Policy.PRIORITY_CATEGORY_EVENTS, 0 , 0 , 0);
+ assertThat(mBuilder.getMsgEventReminderSettingSummary(policy)).isEqualTo("Events");
+ }
+
+ @Test
+ public void testGetMsgEventReminderSettingSummary_someMsgs() {
+ Policy policy = new Policy(Policy.PRIORITY_CATEGORY_MESSAGES, 0,
+ Policy.PRIORITY_SENDERS_CONTACTS , 0);
+ assertThat(mBuilder.getMsgEventReminderSettingSummary(policy)).isEqualTo("Some messages");
+
+ policy = new Policy(Policy.PRIORITY_CATEGORY_MESSAGES, 0,
+ Policy.PRIORITY_SENDERS_STARRED , 0);
+ assertThat(mBuilder.getMsgEventReminderSettingSummary(policy)).isEqualTo("Some messages");
+ }
+
+ @Test
+ public void testGetMsgEventReminderSettingSummary_msgs() {
+ Policy policy = new Policy(Policy.PRIORITY_CATEGORY_MESSAGES, 0, 0, 0);
+ assertThat(mBuilder.getMsgEventReminderSettingSummary(policy)).isEqualTo("Messages");
+ }
+
+ @Test
+ public void testGetMsgEventReminderSettingSummary_someMsgsAndOther() {
+ Policy policy = new Policy(
+ Policy.PRIORITY_CATEGORY_MESSAGES | Policy.PRIORITY_CATEGORY_REMINDERS,
+ 0, Policy.PRIORITY_SENDERS_CONTACTS , 0);
+ assertThat(mBuilder.getMsgEventReminderSettingSummary(policy))
+ .isEqualTo("Some messages and reminders");
+ }
+
+ @Test
+ public void testGetMsgEventReminderSettingSummary_someMsgsAndAllOthers() {
+ Policy policy = new Policy(Policy.PRIORITY_CATEGORY_EVENTS
+ | Policy.PRIORITY_CATEGORY_MESSAGES | Policy.PRIORITY_CATEGORY_REMINDERS,
+ 0, Policy.PRIORITY_SENDERS_CONTACTS , 0);
+ assertThat(mBuilder.getMsgEventReminderSettingSummary(policy))
+ .isEqualTo("Some messages, events, and reminders");
+ }
+
+ @Test
+ public void testGetMsgEventReminderSettingSummary_noMsgsAndOther() {
+ Policy policy = new Policy(
+ Policy.PRIORITY_CATEGORY_EVENTS | Policy.PRIORITY_CATEGORY_REMINDERS,
+ 0,0, 0);
+ assertThat(mBuilder.getMsgEventReminderSettingSummary(policy))
+ .isEqualTo("Events and reminders");
+ }
+
+ @Test
+ public void testGetCallsSettingSummary_none() {
+ Policy policy = new Policy(0, 0, 0, 0);
+ assertThat(mBuilder.getCallsSettingSummary(policy)).isEqualTo("None");
+ }
+
+ @Test
+ public void testGetCallsSettingSummary_contacts() {
+ Policy policy = new Policy(Policy.PRIORITY_CATEGORY_ALARMS | Policy.PRIORITY_CATEGORY_CALLS,
+ Policy.PRIORITY_SENDERS_CONTACTS, 0, 0);
+ assertThat(mBuilder.getCallsSettingSummary(policy)).isEqualTo("From contacts only");
+ }
+
+ @Test
+ public void testGetCallsSettingSummary_repeatCallers() {
+ Policy policy = new Policy(Policy.PRIORITY_CATEGORY_REPEAT_CALLERS, 0, 0, 0);
+ assertThat(mBuilder.getCallsSettingSummary(policy)).isEqualTo("From repeat callers only");
+ }
+
+ @Test
+ public void testGetCallsSettingSummary_starredRepeatCallers() {
+ Policy policy = new Policy(
+ Policy.PRIORITY_CATEGORY_REPEAT_CALLERS | Policy.PRIORITY_CATEGORY_CALLS,
+ Policy.PRIORITY_SENDERS_STARRED, 0, 0);
+ assertThat(mBuilder.getCallsSettingSummary(policy))
+ .isEqualTo("From starred contacts and repeat callers");
+ }
+
+ @Test
+ public void testGetSoundSettingSummary_allOff() {
+ Policy policy = new Policy(0, 0, 0, 0);
+ assertThat(mBuilder.getSoundSettingSummary(policy)).isEqualTo("Muted");
+ }
+
+ @Test
+ public void testGetSoundSettingSummary_allOn() {
+ Policy policy = new Policy(Policy.PRIORITY_CATEGORY_ALARMS | Policy.PRIORITY_CATEGORY_SYSTEM
+ | Policy.PRIORITY_CATEGORY_MEDIA, 0, 0, 0);
+ assertThat(mBuilder.getSoundSettingSummary(policy))
+ .isEqualTo("Muted, but allow alarms, media, and touch sounds");
+ }
+
+ @Test
+ public void testGetSoundSettingSummary_allOffButOne() {
+ Policy policy = new Policy(Policy.PRIORITY_CATEGORY_MEDIA, 0, 0, 0);
+ assertThat(mBuilder.getSoundSettingSummary(policy)).isEqualTo("Muted, but allow media");
+ }
+
+ @Test
+ public void testGetSoundSettingSummary_allOffButTwo() {
+ Policy policy = new Policy(Policy.PRIORITY_CATEGORY_SYSTEM
+ | Policy.PRIORITY_CATEGORY_MEDIA, 0, 0, 0);
+ assertThat(mBuilder.getSoundSettingSummary(policy))
+ .isEqualTo("Muted, but allow media and touch sounds");
+ }
+
@Test
public void searchProvider_shouldIndexDefaultXml() {
final List sir = ZenModeSettings.SEARCH_INDEX_DATA_PROVIDER
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeStarredContactsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeStarredContactsPreferenceControllerTest.java
new file mode 100644
index 00000000000..9a2bccd6b15
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeStarredContactsPreferenceControllerTest.java
@@ -0,0 +1,151 @@
+/*
+ * Copyright (C) 2018 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.NotificationManager.Policy.PRIORITY_CATEGORY_CALLS;
+import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import android.app.NotificationManager;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.shadows.ShadowApplication;
+import org.robolectric.util.ReflectionHelpers;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class ZenModeStarredContactsPreferenceControllerTest {
+
+ private ZenModeStarredContactsPreferenceController mCallsController;
+ private ZenModeStarredContactsPreferenceController mMessagesController;
+
+ @Mock
+ private ZenModeBackend mBackend;
+ @Mock
+ private NotificationManager mNotificationManager;
+ @Mock
+ private Preference mockPref;
+ @Mock
+ private NotificationManager.Policy mPolicy;
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
+ @Mock
+ private Intent testIntent;
+ @Mock
+ private ComponentName mComponentName;
+ private Context mContext;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ ShadowApplication shadowApplication = ShadowApplication.getInstance();
+ shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
+
+ mContext = shadowApplication.getApplicationContext();
+ when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
+ when(testIntent.resolveActivity(any())).thenReturn(mComponentName);
+
+ mCallsController = new ZenModeStarredContactsPreferenceController(
+ mContext, mock(Lifecycle.class), PRIORITY_CATEGORY_CALLS,
+ "zen_mode_starred_contacts_callers");
+ ReflectionHelpers.setField(mCallsController, "mBackend", mBackend);
+ ReflectionHelpers.setField(mCallsController, "mStarredContactsIntent", testIntent);
+ when(mPreferenceScreen.findPreference(mCallsController.getPreferenceKey()))
+ .thenReturn(mockPref);
+ mCallsController.displayPreference(mPreferenceScreen);
+
+ mMessagesController = new ZenModeStarredContactsPreferenceController(
+ mContext, mock(Lifecycle.class), PRIORITY_CATEGORY_MESSAGES,
+ "zen_mode_starred_contacts_messages");
+ ReflectionHelpers.setField(mMessagesController, "mBackend", mBackend);
+ ReflectionHelpers.setField(mMessagesController, "mStarredContactsIntent", testIntent);
+ when(mPreferenceScreen.findPreference(mMessagesController.getPreferenceKey()))
+ .thenReturn(mockPref);
+ mMessagesController.displayPreference(mPreferenceScreen);
+ }
+
+ @Test
+ public void isAvailable_noCallers() {
+ when(mBackend.isPriorityCategoryEnabled(NotificationManager.Policy.PRIORITY_CATEGORY_CALLS))
+ .thenReturn(false);
+ assertThat(mCallsController.isAvailable()).isFalse();
+ }
+
+ @Test
+ public void isAvailable_anyCallers() {
+ when(mBackend.isPriorityCategoryEnabled(NotificationManager.Policy.PRIORITY_CATEGORY_CALLS))
+ .thenReturn(true);
+ when(mBackend.getPriorityCallSenders())
+ .thenReturn(NotificationManager.Policy.PRIORITY_SENDERS_ANY);
+
+
+ assertThat(mCallsController.isAvailable()).isFalse();
+ }
+
+ @Test
+ public void isAvailable_starredCallers() {
+ when(mBackend.isPriorityCategoryEnabled(NotificationManager.Policy.PRIORITY_CATEGORY_CALLS))
+ .thenReturn(true);
+ when(mBackend.getPriorityCallSenders())
+ .thenReturn(NotificationManager.Policy.PRIORITY_SENDERS_STARRED);
+
+ assertThat(mCallsController.isAvailable()).isTrue();
+ }
+
+ @Test
+ public void isAvailable_noMessages() {
+ when(mBackend.isPriorityCategoryEnabled(
+ NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES)).thenReturn(false);
+ assertThat(mMessagesController.isAvailable()).isFalse();
+ }
+
+ @Test
+ public void isAvailable_anyMessages() {
+ when(mBackend.isPriorityCategoryEnabled(
+ NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES)).thenReturn(true);
+ when(mBackend.getPriorityMessageSenders())
+ .thenReturn(NotificationManager.Policy.PRIORITY_SENDERS_ANY);
+
+ assertThat(mMessagesController.isAvailable()).isFalse();
+ }
+
+ @Test
+ public void isAvailable_starredMessageContacts() {
+ when(mBackend.isPriorityCategoryEnabled(
+ NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES)).thenReturn(true);
+ when(mBackend.getPriorityMessageSenders())
+ .thenReturn(NotificationManager.Policy.PRIORITY_SENDERS_STARRED);
+
+ assertThat(mMessagesController.isAvailable()).isTrue();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeVisEffectsCustomPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeVisEffectsCustomPreferenceControllerTest.java
index 5de7697d1af..f3d92d17d21 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeVisEffectsCustomPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeVisEffectsCustomPreferenceControllerTest.java
@@ -150,18 +150,4 @@ public class ZenModeVisEffectsCustomPreferenceControllerTest {
verify(mockPref).setOnGearClickListener(any());
verify(mockPref).setOnRadioButtonClickListener(any());
}
-
- @Test
- public void select() {
- int interruptiveSuppressed = SUPPRESSED_EFFECT_FULL_SCREEN_INTENT
- | SUPPRESSED_EFFECT_AMBIENT
- | SUPPRESSED_EFFECT_LIGHTS
- | SUPPRESSED_EFFECT_PEEK;
- mBackend.mPolicy = new NotificationManager.Policy(0, 0, 0, 1);
- mController.select();
- verify(mBackend).savePolicy(anyInt(), anyInt(), anyInt(), eq(interruptiveSuppressed));
- verify(mFeatureFactory.metricsFeatureProvider).action(eq(mContext),
- eq(ACTION_ZEN_CUSTOM),
- eq(true));
- }
}
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAudioManager.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAudioManager.java
index 88a0fb649b5..3c3714547dd 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAudioManager.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAudioManager.java
@@ -42,7 +42,8 @@ import java.util.ArrayList;
public class ShadowAudioManager extends org.robolectric.shadows.ShadowAudioManager {
private int mRingerMode;
private int mDeviceCodes;
- private boolean mMusicActiveRemotely = false;
+ private boolean mMusicActiveRemotely;
+ private boolean mBluetoothScoOn;
private ArrayList mDeviceCallbacks = new ArrayList();
@Implementation
@@ -104,4 +105,11 @@ public class ShadowAudioManager extends org.robolectric.shadows.ShadowAudioManag
public void reset() {
mDeviceCallbacks.clear();
}
+
+ public void setBluetoothScoOn(boolean bluetoothScoOn) {
+ mBluetoothScoOn = bluetoothScoOn;
+ }
+
+ @Implementation
+ public boolean isBluetoothScoOn() { return mBluetoothScoOn; }
}
diff --git a/tests/unit/src/com/android/settings/display/ThemePreferenceControllerTest.java b/tests/unit/src/com/android/settings/display/ThemePreferenceControllerTest.java
index f42dbd1f342..56552132515 100644
--- a/tests/unit/src/com/android/settings/display/ThemePreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/display/ThemePreferenceControllerTest.java
@@ -69,9 +69,9 @@ public class ThemePreferenceControllerTest {
@Test
public void testUpdateState() throws Exception {
OverlayInfo info1 = new OverlayInfo("com.android.Theme1", "android",
- "", "", OverlayInfo.STATE_ENABLED, 0);
+ "", "", OverlayInfo.STATE_ENABLED, 0, 0, true);
OverlayInfo info2 = new OverlayInfo("com.android.Theme2", "android",
- "", "", 0, 0);
+ "", "", 0, 0, 0, true);
when(mMockPackageManager.getApplicationInfo(any(), anyInt())).thenAnswer(inv -> {
ApplicationInfo info = mock(ApplicationInfo.class);
if ("com.android.Theme1".equals(inv.getArguments()[0])) {
@@ -105,9 +105,9 @@ public class ThemePreferenceControllerTest {
@Test
public void testUpdateState_withStaticOverlay() throws Exception {
OverlayInfo info1 = new OverlayInfo("com.android.Theme1", "android",
- "", "", OverlayInfo.STATE_ENABLED, 0);
+ "", "", OverlayInfo.STATE_ENABLED, 0, 0, true);
OverlayInfo info2 = new OverlayInfo("com.android.Theme2", "android",
- "", "", OverlayInfo.STATE_ENABLED, 0);
+ "", "", OverlayInfo.STATE_ENABLED, 0, 0, true);
when(mMockPackageManager.getApplicationInfo(any(), anyInt())).thenAnswer(inv -> {
ApplicationInfo info = mock(ApplicationInfo.class);
if ("com.android.Theme1".equals(inv.getArguments()[0])) {
@@ -145,7 +145,7 @@ public class ThemePreferenceControllerTest {
when(mMockPackageManager.getPackageInfo(anyString(), anyInt())).thenReturn(
new PackageInfo());
when(mMockOverlayManager.getOverlayInfosForTarget(any(), anyInt()))
- .thenReturn(list(new OverlayInfo("", "", "", "", 0, 0)));
+ .thenReturn(list(new OverlayInfo("", "", "", "", 0, 0, 0, false)));
assertThat(mPreferenceController.isAvailable()).isFalse();
}
@@ -154,8 +154,8 @@ public class ThemePreferenceControllerTest {
when(mMockPackageManager.getPackageInfo(anyString(), anyInt())).thenReturn(
new PackageInfo());
when(mMockOverlayManager.getOverlayInfosForTarget(any(), anyInt()))
- .thenReturn(list(new OverlayInfo("", "", "", "", 0, 0),
- new OverlayInfo("", "", "", "", 0, 0)));
+ .thenReturn(list(new OverlayInfo("", "", "", "", 0, 0, 0, true),
+ new OverlayInfo("", "", "", "", 0, 0, 0, true)));
assertThat(mPreferenceController.isAvailable()).isTrue();
}