Merge "Update profile api"
diff --git a/res/layout/wifi_dialog.xml b/res/layout/wifi_dialog.xml
index a3ad4207..18ad3b5 100644
--- a/res/layout/wifi_dialog.xml
+++ b/res/layout/wifi_dialog.xml
@@ -470,7 +470,7 @@
<EditText android:id="@+id/proxy_pac"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- style="@style/wifi_item_content"
+ style="@style/wifi_item_edit_content"
android:hint="@string/proxy_url_hint"
android:inputType="textNoSuggestions"
android:singleLine="true"/>
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 9c3a622..bfffce0 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -1175,6 +1175,19 @@
<item>zen_mode_from_none</item>
</string-array>
+ <string-array name="zen_mode_conversations_entries" translatable="false">
+ <item>@string/zen_mode_from_all_conversations</item>
+ <item>@string/zen_mode_from_important_conversations</item>
+ <item>@string/zen_mode_from_no_conversations</item>
+ </string-array>
+
+ <!-- these values correspond with ZenPolicy.ConversationSenders -->
+ <string-array name="zen_mode_conversations_values" translatable="false">
+ <item>1</item>
+ <item>2</item>
+ <item>3</item>
+ </string-array>
+
<!--String arrays for notification swipe direction -->
<string-array name="swipe_direction_titles">
<item>@string/swipe_direction_rtl</item>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 8d6ae56..c7a944a 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5079,9 +5079,12 @@
<!-- Label describing a high intensity vibration option. [CHAR LIMIT=15] -->
<string name="accessibility_vibration_intensity_high">High</string>
- <!-- Title for accessibility menu item to lauch a settings activity. [CHAR LIMIT=15] -->
+ <!-- Title for accessibility menu item to launch a settings activity. [CHAR LIMIT=15] -->
<string name="accessibility_menu_item_settings">Settings</string>
+ <!-- Title for accessibility menu item to launch a settings activity with app name. [CHAR LIMIT=30] -->
+ <string name="accessibility_service_menu_item_settings"><xliff:g example="TalkBack" id="accessibility_app_name">%1$s</xliff:g> settings</string>
+
<!-- Summary for the enabled state of an accessibility feature. [CHAR LIMIT=10] -->
<string name="accessibility_feature_state_on">On</string>
<!-- Summary for the disabled state of an accessibility feature. [CHAR LIMIT=10] -->
@@ -7790,7 +7793,7 @@
<!-- Do not disturb: what to block summary, all effects -->
<string name="zen_mode_block_effect_summary_all">Sound, vibration, and visual signs of notifications</string>
- <string name="zen_mode_blocked_effects_footer">Notifications needed for basic phone activity and status will never be hidden</string>
+ <string name="zen_mode_blocked_effects_footer">Notifications needed for basic phone activity and status will never be hidden.</string>
<!-- Do not disturb: Zen mode no sounds are exceptions to bypass do not disturb-->
<string name="zen_mode_no_exceptions">None</string>
@@ -8645,6 +8648,9 @@
</plurals>
<string name="zen_mode_conversations_title">Conversations</string>
+ <string name="zen_mode_from_all_conversations">From all conversations</string>
+ <string name="zen_mode_from_important_conversations">From important conversations</string>
+ <string name="zen_mode_from_no_conversations">Don\u2019t allow any conversations</string>
<!-- [CHAR LIMIT=40] Zen mode settings: Messages option -->
<string name="zen_mode_messages">Allow messages</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index a4c82b2..33a2022 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -141,7 +141,7 @@
<item name="android:textSize">14sp</item>
</style>
- <style name="wifi_item_edit_content">
+ <style name="wifi_item_edit_content" parent="@android:style/TextAppearance.Widget.EditText">
<item name="android:paddingStart">4dip</item>
<item name="android:layout_marginStart">4dip</item>
<item name="android:textSize">18sp</item>
diff --git a/res/xml/zen_mode_people_settings.xml b/res/xml/zen_mode_people_settings.xml
index 5456f6f..140d1cd 100644
--- a/res/xml/zen_mode_people_settings.xml
+++ b/res/xml/zen_mode_people_settings.xml
@@ -59,6 +59,13 @@
<PreferenceCategory
android:title="@string/zen_mode_conversations_title"
android:key="zen_mode_settings_category_conversations">
+
+ <!-- Conversations -->
+ <ListPreference
+ android:key="zen_mode_conversations"
+ android:title="@string/zen_mode_conversations_title"
+ android:entries="@array/zen_mode_conversations_entries"
+ android:entryValues="@array/zen_mode_conversations_values"/>
</PreferenceCategory>
<!-- Footer that shows if user is put into alarms only or total silence mode by an app -->
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 1722c99..6f51fd3 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -437,7 +437,8 @@
final String settingsClassName = info.getSettingsActivityName();
if (!TextUtils.isEmpty(settingsClassName)) {
extras.putString(EXTRA_SETTINGS_TITLE,
- getString(R.string.accessibility_menu_item_settings));
+ getString(R.string.accessibility_service_menu_item_settings,
+ resolveInfo.loadLabel(getPackageManager())));
extras.putString(EXTRA_SETTINGS_COMPONENT_NAME,
new ComponentName(packageName, settingsClassName).flattenToString());
}
diff --git a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java
index 159e609..2bcb5b3 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java
@@ -16,6 +16,8 @@
package com.android.settings.accessibility;
+import static com.android.settings.accessibility.AccessibilityUtil.AccessibilityServiceFragmentType.LEGACY;
+
import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.settings.SettingsEnums;
import android.content.ComponentName;
@@ -99,9 +101,11 @@
public void onResume() {
super.onResume();
updateAccessibilityServicePreference(mScreenReaderPreference,
- findService(SCREEN_READER_PACKAGE_NAME, SCREEN_READER_SERVICE_NAME));
+ SCREEN_READER_PACKAGE_NAME, SCREEN_READER_SERVICE_NAME,
+ LegacyToggleScreenReaderPreferenceFragmentForSetupWizard.class.getName());
updateAccessibilityServicePreference(mSelectToSpeakPreference,
- findService(SELECT_TO_SPEAK_PACKAGE_NAME, SELECT_TO_SPEAK_SERVICE_NAME));
+ SELECT_TO_SPEAK_PACKAGE_NAME, SELECT_TO_SPEAK_SERVICE_NAME,
+ LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard.class.getName());
configureMagnificationPreferenceIfNeeded(mDisplayMagnificationPreference);
}
@@ -143,7 +147,8 @@
}
private void updateAccessibilityServicePreference(Preference preference,
- AccessibilityServiceInfo info) {
+ String packageName, String serviceName, String targetLegacyFragment) {
+ final AccessibilityServiceInfo info = findService(packageName, serviceName);
if (info == null) {
getPreferenceScreen().removePreference(preference);
return;
@@ -154,6 +159,9 @@
preference.setTitle(title);
ComponentName componentName = new ComponentName(serviceInfo.packageName, serviceInfo.name);
preference.setKey(componentName.flattenToString());
+ if (AccessibilityUtil.getAccessibilityServiceFragmentType(info) == LEGACY) {
+ preference.setFragment(targetLegacyFragment);
+ }
// Update the extras.
Bundle extras = preference.getExtras();
diff --git a/src/com/android/settings/accessibility/LegacyToggleScreenReaderPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/LegacyToggleScreenReaderPreferenceFragmentForSetupWizard.java
new file mode 100644
index 0000000..c9257a9
--- /dev/null
+++ b/src/com/android/settings/accessibility/LegacyToggleScreenReaderPreferenceFragmentForSetupWizard.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import android.app.settings.SettingsEnums;
+import android.os.Bundle;
+
+/** For accessibility services that target SDK <= Q in setup wizard. */
+public class LegacyToggleScreenReaderPreferenceFragmentForSetupWizard
+ extends LegacyAccessibilityServicePreferenceFragment {
+
+ private boolean mToggleSwitchWasInitiallyChecked;
+
+ @Override
+ protected void onProcessArguments(Bundle arguments) {
+ super.onProcessArguments(arguments);
+ mToggleSwitchWasInitiallyChecked = mToggleSwitch.isChecked();
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SCREEN_READER;
+ }
+
+ @Override
+ public void onStop() {
+ // Log the final choice in value if it's different from the previous value.
+ if (mToggleSwitch.isChecked() != mToggleSwitchWasInitiallyChecked) {
+ mMetricsFeatureProvider.action(getContext(),
+ SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SCREEN_READER,
+ mToggleSwitch.isChecked());
+ }
+
+ super.onStop();
+ }
+}
diff --git a/src/com/android/settings/accessibility/LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
new file mode 100644
index 0000000..2c8485b
--- /dev/null
+++ b/src/com/android/settings/accessibility/LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import android.app.settings.SettingsEnums;
+import android.os.Bundle;
+
+/** For accessibility services that target SDK <= Q in setup wizard. */
+public class LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard
+ extends LegacyAccessibilityServicePreferenceFragment {
+
+ private boolean mToggleSwitchWasInitiallyChecked;
+
+ @Override
+ protected void onProcessArguments(Bundle arguments) {
+ super.onProcessArguments(arguments);
+ mToggleSwitchWasInitiallyChecked = mToggleSwitch.isChecked();
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SCREEN_READER;
+ }
+
+ @Override
+ public void onStop() {
+ // Log the final choice in value if it's different from the previous value.
+ if (mToggleSwitch.isChecked() != mToggleSwitchWasInitiallyChecked) {
+ mMetricsFeatureProvider.action(getContext(),
+ SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SELECT_TO_SPEAK,
+ mToggleSwitch.isChecked());
+ }
+
+ super.onStop();
+ }
+}
diff --git a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
index 36b2da1..6d64a23 100644
--- a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
@@ -89,10 +89,8 @@
@Override
public void onResume() {
super.onResume();
-
- mSettingsContentObserver.register(getContentResolver());
-
updateSwitchBarToggleSwitch();
+ mSettingsContentObserver.register(getContentResolver());
}
@Override
@@ -199,6 +197,9 @@
private void updateSwitchBarToggleSwitch() {
final boolean checked = AccessibilityUtils.getEnabledServicesFromSettings(getPrefContext())
.contains(mComponentName);
+ if (mSwitchBar.isChecked() == checked) {
+ return;
+ }
mSwitchBar.setCheckedInternal(checked);
}
diff --git a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
index 283fa90..d25be83 100644
--- a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
@@ -17,6 +17,8 @@
package com.android.settings.accessibility;
import static com.android.internal.accessibility.AccessibilityShortcutController.COLOR_INVERSION_COMPONENT_NAME;
+import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
+import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
import android.app.settings.SettingsEnums;
import android.net.Uri;
@@ -26,13 +28,11 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.Switch;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
-import com.android.settings.accessibility.AccessibilityUtil.State;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.widget.SwitchBar;
import com.android.settingslib.search.SearchIndexable;
@@ -42,8 +42,7 @@
/** Settings page for color inversion. */
@SearchIndexable
-public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePreferenceFragment
- implements SwitchBar.OnSwitchChangeListener {
+public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePreferenceFragment {
private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED;
private static final String CATEGORY_FOOTER_KEY = "color_inversion_footer_category";
@@ -58,7 +57,7 @@
@Override
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
- Settings.Secure.putInt(getContentResolver(), ENABLED, enabled ? State.OFF : State.ON);
+ Settings.Secure.putInt(getContentResolver(), ENABLED, enabled ? ON : OFF);
}
@Override
@@ -69,7 +68,7 @@
@Override
protected void onRemoveSwitchBarToggleSwitch() {
super.onRemoveSwitchBarToggleSwitch();
- mSwitchBar.removeOnSwitchChangeListener(this);
+ mToggleSwitch.setOnBeforeCheckedChangeListener(null);
}
@Override
@@ -79,16 +78,13 @@
}
@Override
- public void onSwitchChanged(Switch switchView, boolean isChecked) {
- Settings.Secure.putInt(getContentResolver(), ENABLED, isChecked ? State.ON : State.OFF);
- }
-
- @Override
protected void onInstallSwitchBarToggleSwitch() {
super.onInstallSwitchBarToggleSwitch();
- mSwitchBar.setCheckedInternal(
- Settings.Secure.getInt(getContentResolver(), ENABLED, State.OFF) == State.ON);
- mSwitchBar.addOnSwitchChangeListener(this);
+ updateSwitchBarToggleSwitch();
+ mToggleSwitch.setOnBeforeCheckedChangeListener((toggleSwitch, checked) -> {
+ onPreferenceToggled(mPreferenceKey, checked);
+ return false;
+ });
}
@Override
@@ -101,9 +97,7 @@
mSettingsContentObserver = new SettingsContentObserver(mHandler, enableServiceFeatureKeys) {
@Override
public void onChange(boolean selfChange, Uri uri) {
- mSwitchBar.setCheckedInternal(
- Settings.Secure.getInt(getContentResolver(), ENABLED, State.OFF)
- == State.ON);
+ updateSwitchBarToggleSwitch();
}
};
return super.onCreateView(inflater, container, savedInstanceState);
@@ -123,6 +117,7 @@
@Override
public void onResume() {
super.onResume();
+ updateSwitchBarToggleSwitch();
mSettingsContentObserver.register(getContentResolver());
}
@@ -138,6 +133,14 @@
showDialog(DIALOG_ID_EDIT_SHORTCUT);
}
+ private void updateSwitchBarToggleSwitch() {
+ final boolean checked = Settings.Secure.getInt(getContentResolver(), ENABLED, OFF) == ON;
+ if (mSwitchBar.isChecked() == checked) {
+ return;
+ }
+ mSwitchBar.setCheckedInternal(checked);
+ }
+
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.accessibility_color_inversion_settings);
}
diff --git a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
index 493140c..9a6aefd 100644
--- a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
@@ -17,6 +17,8 @@
package com.android.settings.accessibility;
import static com.android.internal.accessibility.AccessibilityShortcutController.DALTONIZER_COMPONENT_NAME;
+import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
+import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
import android.app.settings.SettingsEnums;
import android.content.Context;
@@ -28,14 +30,12 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.Switch;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
-import com.android.settings.accessibility.AccessibilityUtil.State;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.widget.SwitchBar;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -47,8 +47,7 @@
@SearchIndexable
public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePreferenceFragment
- implements DaltonizerRadioButtonPreferenceController.OnChangeListener,
- SwitchBar.OnSwitchChangeListener{
+ implements DaltonizerRadioButtonPreferenceController.OnChangeListener {
private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED;
private static final String CATEGORY_FOOTER_KEY = "daltonizer_footer_category";
@@ -88,9 +87,7 @@
mSettingsContentObserver = new SettingsContentObserver(mHandler, enableServiceFeatureKeys) {
@Override
public void onChange(boolean selfChange, Uri uri) {
- mSwitchBar.setCheckedInternal(
- Settings.Secure.getInt(getContentResolver(), ENABLED, State.OFF)
- == State.ON);
+ updateSwitchBarToggleSwitch();
}
};
return super.onCreateView(inflater, container, savedInstanceState);
@@ -109,7 +106,9 @@
@Override
public void onResume() {
super.onResume();
+ updateSwitchBarToggleSwitch();
mSettingsContentObserver.register(getContentResolver());
+
for (AbstractPreferenceController controller :
buildPreferenceControllers(getPrefContext(), getSettingsLifecycle())) {
((DaltonizerRadioButtonPreferenceController) controller).setOnChangeListener(this);
@@ -145,13 +144,13 @@
@Override
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
- Settings.Secure.putInt(getContentResolver(), ENABLED, enabled ? State.OFF : State.ON);
+ Settings.Secure.putInt(getContentResolver(), ENABLED, enabled ? ON : OFF);
}
@Override
protected void onRemoveSwitchBarToggleSwitch() {
super.onRemoveSwitchBarToggleSwitch();
- mSwitchBar.removeOnSwitchChangeListener(this);
+ mToggleSwitch.setOnBeforeCheckedChangeListener(null);
}
@Override
@@ -161,16 +160,13 @@
}
@Override
- public void onSwitchChanged(Switch switchView, boolean isChecked) {
- Settings.Secure.putInt(getContentResolver(), ENABLED, isChecked ? State.ON : State.OFF);
- }
-
- @Override
protected void onInstallSwitchBarToggleSwitch() {
super.onInstallSwitchBarToggleSwitch();
- mSwitchBar.setCheckedInternal(
- Settings.Secure.getInt(getContentResolver(), ENABLED, State.OFF) == State.ON);
- mSwitchBar.addOnSwitchChangeListener(this);
+ updateSwitchBarToggleSwitch();
+ mToggleSwitch.setOnBeforeCheckedChangeListener((toggleSwitch, checked) -> {
+ onPreferenceToggled(mPreferenceKey, checked);
+ return false;
+ });
}
@Override
@@ -179,6 +175,14 @@
showDialog(DialogEnums.EDIT_SHORTCUT);
}
+ private void updateSwitchBarToggleSwitch() {
+ final boolean checked = Settings.Secure.getInt(getContentResolver(), ENABLED, OFF) == ON;
+ if (mSwitchBar.isChecked() == checked) {
+ return;
+ }
+ mSwitchBar.setCheckedInternal(checked);
+ }
+
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.accessibility_daltonizer_settings);
}
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
index b82a344..401ca5e 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
@@ -188,12 +188,6 @@
initShortcutPreference();
- mSettingsPreference = new Preference(getPrefContext());
- mSettingsPreference.setTitle(R.string.accessibility_magnification_service_settings_title);
- mSettingsPreference.setKey(SETTINGS_KEY);
- mSettingsPreference.setFragment(MagnificationSettingsFragment.class.getName());
- mSettingsPreference.setPersistent(false);
-
super.onViewCreated(view, savedInstanceState);
mConfigWarningPreference = new Preference(getPrefContext());
diff --git a/src/com/android/settings/accessibility/ToggleScreenReaderPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/ToggleScreenReaderPreferenceFragmentForSetupWizard.java
index fc68e03..29c031d 100644
--- a/src/com/android/settings/accessibility/ToggleScreenReaderPreferenceFragmentForSetupWizard.java
+++ b/src/com/android/settings/accessibility/ToggleScreenReaderPreferenceFragmentForSetupWizard.java
@@ -46,4 +46,3 @@
super.onStop();
}
}
-
diff --git a/src/com/android/settings/accessibility/ToggleSelectToSpeakPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/ToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
index 5f01e4b..da94abc 100644
--- a/src/com/android/settings/accessibility/ToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
+++ b/src/com/android/settings/accessibility/ToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
@@ -47,4 +47,3 @@
super.onStop();
}
}
-
diff --git a/src/com/android/settings/biometrics/OWNERS b/src/com/android/settings/biometrics/OWNERS
index 6332a46..021e89d 100644
--- a/src/com/android/settings/biometrics/OWNERS
+++ b/src/com/android/settings/biometrics/OWNERS
@@ -1,6 +1,7 @@
# Default reviewers for this and subdirectories.
+curtislb@google.com
jaggies@google.com
kchyn@google.com
yukl@google.com
-# Emergency approvers in case the above are not available
\ No newline at end of file
+# Emergency approvers in case the above are not available
diff --git a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
index 4226720..86b72ec 100644
--- a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
+++ b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
@@ -60,10 +60,12 @@
@Retention(RetentionPolicy.SOURCE)
@IntDef({SortType.TYPE_DEFAULT,
- SortType.TYPE_FIFO})
+ SortType.TYPE_FIFO,
+ SortType.TYPE_NO_SORT})
public @interface SortType {
int TYPE_DEFAULT = 1;
int TYPE_FIFO = 2;
+ int TYPE_NO_SORT = 3;
}
private final CachedBluetoothDevice mCachedDevice;
diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
index e2715d3..3778862 100644
--- a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
@@ -232,12 +232,21 @@
* Add the {@link Preference} that represents the {@code cachedDevice}
*/
protected void addPreference(CachedBluetoothDevice cachedDevice) {
+ addPreference(cachedDevice, BluetoothDevicePreference.SortType.TYPE_DEFAULT);
+ }
+
+ /**
+ * Add the {@link Preference} with {@link BluetoothDevicePreference.SortType} that
+ * represents the {@code cachedDevice}
+ */
+ protected void addPreference(CachedBluetoothDevice cachedDevice,
+ @BluetoothDevicePreference.SortType int type) {
final BluetoothDevice device = cachedDevice.getDevice();
if (!mPreferenceMap.containsKey(device)) {
BluetoothDevicePreference btPreference =
new BluetoothDevicePreference(mPrefContext, cachedDevice,
true /* showDeviceWithoutNames */,
- BluetoothDevicePreference.SortType.TYPE_DEFAULT);
+ type);
btPreference.setKey(getPreferenceKey());
btPreference.setOnGearClickListener(mDeviceProfilesListener);
if (this instanceof Preference.OnPreferenceClickListener) {
diff --git a/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
index fdd7a1e..6893c25 100644
--- a/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
@@ -15,6 +15,7 @@
*/
package com.android.settings.bluetooth;
+import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.util.Log;
@@ -24,6 +25,7 @@
import com.android.settings.connecteddevice.DevicePreferenceCallback;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
+import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
/**
* Maintain and update saved bluetooth devices(bonded but not connected)
@@ -42,6 +44,26 @@
}
@Override
+ public void forceUpdate() {
+ if (BluetoothAdapter.getDefaultAdapter().isEnabled()) {
+ final CachedBluetoothDeviceManager cachedManager =
+ mLocalManager.getCachedDeviceManager();
+ for (BluetoothDevice device
+ : BluetoothAdapter.getDefaultAdapter().getMostRecentlyConnectedDevices()) {
+ final CachedBluetoothDevice cachedDevice = cachedManager.findDevice(device);
+ if (isFilterMatched(cachedDevice)) {
+ // Add the preference if it is new one
+ addPreference(cachedDevice, BluetoothDevicePreference.SortType.TYPE_NO_SORT);
+ } else {
+ removePreference(cachedDevice);
+ }
+ }
+ } else {
+ removeAllDevicesFromPreference();
+ }
+ }
+
+ @Override
public boolean isFilterMatched(CachedBluetoothDevice cachedDevice) {
final BluetoothDevice device = cachedDevice.getDevice();
if (DBG) {
diff --git a/src/com/android/settings/network/ims/ImsQueryController.java b/src/com/android/settings/network/ims/ImsQueryController.java
index 2d2a69f..5519ddd 100644
--- a/src/com/android/settings/network/ims/ImsQueryController.java
+++ b/src/com/android/settings/network/ims/ImsQueryController.java
@@ -39,9 +39,9 @@
/**
* Constructor for query IMS status
*
- * @param capability {@code MmTelFeature.MmTelCapabilities.MmTelCapability}
- * @param tech {@code @ImsRegistrationImplBase.ImsRegistrationTech}
- * @param transportType {@code @AccessNetworkConstants.TransportType}
+ * @param capability {@link MmTelFeature.MmTelCapabilities#MmTelCapability}
+ * @param tech {@link ImsRegistrationImplBase#ImsRegistrationTech}
+ * @param transportType {@link AccessNetworkConstants#TransportType}
*/
ImsQueryController(
@MmTelFeature.MmTelCapabilities.MmTelCapability int capability,
diff --git a/src/com/android/settings/network/ims/ImsQueryProvisioningStat.java b/src/com/android/settings/network/ims/ImsQueryProvisioningStat.java
index 68ffe8c..34f232d 100644
--- a/src/com/android/settings/network/ims/ImsQueryProvisioningStat.java
+++ b/src/com/android/settings/network/ims/ImsQueryProvisioningStat.java
@@ -22,7 +22,7 @@
/**
- * An {@code ImsQuery} for accessing IMS provision stat
+ * An {@link ImsQuery} for accessing IMS provision stat
*/
public class ImsQueryProvisioningStat implements ImsQuery {
@@ -33,8 +33,8 @@
/**
* Constructor
* @param subId subscription id
- * @param capability {@code MmTelFeature.MmTelCapabilities.MmTelCapability}
- * @param tech {@code @ImsRegistrationImplBase.ImsRegistrationTech}
+ * @param capability {@link MmTelFeature.MmTelCapabilities#MmTelCapability}
+ * @param tech {@link ImsRegistrationImplBase#ImsRegistrationTech}
*/
public ImsQueryProvisioningStat(int subId,
@MmTelFeature.MmTelCapabilities.MmTelCapability int capability,
@@ -45,7 +45,7 @@
}
/**
- * Implementation of interface {@code ImsQuery}
+ * Implementation of interface {@link ImsQuery}
*
* @return result of query
*/
diff --git a/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java b/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java
index 123e100..efbbbf8 100644
--- a/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java
+++ b/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java
@@ -23,9 +23,6 @@
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.ims.ImsMmTelManager;
-import android.telephony.ims.ProvisioningManager;
-import android.telephony.ims.feature.MmTelFeature;
-import android.telephony.ims.stub.ImsRegistrationImplBase;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
@@ -33,8 +30,6 @@
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
-import com.android.ims.ImsManager;
-import com.android.settings.network.SubscriptionUtil;
import com.android.settings.network.ims.VolteQueryImsState;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
@@ -55,8 +50,6 @@
Preference mPreference;
private CarrierConfigManager mCarrierConfigManager;
private PersistableBundle mCarrierConfig;
- @VisibleForTesting
- ImsManager mImsManager;
private PhoneCallStateListener mPhoneStateListener;
@VisibleForTesting
Integer mCallState;
@@ -81,10 +74,6 @@
}
mSubId = subId;
mCarrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
- if (SubscriptionManager.isValidSubscriptionId(mSubId)) {
- mImsManager = ImsManager.getInstance(mContext, SubscriptionUtil.getPhoneId(
- mContext, mSubId));
- }
final boolean show4GForLTE = mCarrierConfig.getBoolean(
CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL);
@@ -96,29 +85,26 @@
return this;
}
- @VisibleForTesting
- ProvisioningManager getProvisioningManager(int subId) {
- return ProvisioningManager.createForSubscriptionId(subId);
- }
-
@Override
public int getAvailabilityStatus(int subId) {
init(subId);
if (!isModeMatched()) {
return CONDITIONALLY_UNAVAILABLE;
}
+ if (!SubscriptionManager.isValidSubscriptionId(subId)) {
+ return CONDITIONALLY_UNAVAILABLE;
+ }
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
+ if ((carrierConfig == null)
+ || carrierConfig.getBoolean(CarrierConfigManager.KEY_HIDE_ENHANCED_4G_LTE_BOOL)) {
+ return CONDITIONALLY_UNAVAILABLE;
+ }
final VolteQueryImsState queryState = queryImsState(subId);
- final boolean isVisible = SubscriptionManager.isValidSubscriptionId(subId)
- && mImsManager != null && carrierConfig != null
- && mImsManager.isVolteEnabledByPlatform()
- && isVolteProvisionedOnDevice(mSubId)
- && MobileNetworkUtils.isImsServiceStateReady(mImsManager)
- && !carrierConfig.getBoolean(CarrierConfigManager.KEY_HIDE_ENHANCED_4G_LTE_BOOL);
- return isVisible
- ? (isUserControlAllowed() && queryState.isAllowUserControl()
- ? AVAILABLE : AVAILABLE_UNSEARCHABLE)
- : CONDITIONALLY_UNAVAILABLE;
+ if (!queryState.isReadyToVoLte()) {
+ return CONDITIONALLY_UNAVAILABLE;
+ }
+ return (isUserControlAllowed() && queryState.isAllowUserControl())
+ ? AVAILABLE : AVAILABLE_UNSEARCHABLE;
}
@Override
@@ -200,19 +186,6 @@
CarrierConfigManager.KEY_EDITABLE_ENHANCED_4G_LTE_BOOL);
}
- private boolean isVolteProvisionedOnDevice(int subId) {
- if (!SubscriptionManager.isValidSubscriptionId(subId)) {
- return true;
- }
- final ProvisioningManager provisioningMgr = getProvisioningManager(subId);
- if (provisioningMgr == null) {
- return true;
- }
- return provisioningMgr.getProvisioningStatusForCapability(
- MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
- ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
- }
-
private class PhoneCallStateListener extends PhoneStateListener {
PhoneCallStateListener() {
diff --git a/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java b/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java
index 3cad316..31e8239 100644
--- a/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java
+++ b/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java
@@ -28,9 +28,6 @@
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
import android.telephony.ims.ImsMmTelManager;
-import android.telephony.ims.ProvisioningManager;
-import android.telephony.ims.feature.MmTelFeature;
-import android.telephony.ims.stub.ImsRegistrationImplBase;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
@@ -40,10 +37,8 @@
import androidx.slice.builders.ListBuilder.RowBuilder;
import androidx.slice.builders.SliceAction;
-import com.android.ims.ImsManager;
import com.android.settings.R;
import com.android.settings.Utils;
-import com.android.settings.network.SubscriptionUtil;
import com.android.settings.network.ims.VolteQueryImsState;
import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.slices.SliceBroadcastReceiver;
@@ -112,14 +107,6 @@
return null;
}
- final ImsManager imsManager = getImsManager(subId);
-
- if (!imsManager.isVolteEnabledByPlatform()
- || !isVolteProvisionedOnDevice(subId)) {
- Log.d(TAG, "Setting is either not provisioned or not enabled by Platform");
- return null;
- }
-
if (isCarrierConfigManagerKeyEnabled(
CarrierConfigManager.KEY_HIDE_ENHANCED_4G_LTE_BOOL, subId, false)
|| !isCarrierConfigManagerKeyEnabled(
@@ -130,6 +117,11 @@
}
final VolteQueryImsState queryState = queryImsState(subId);
+ if (!queryState.isVoLteProvisioned()) {
+ Log.d(TAG, "Setting is either not provisioned or not enabled by Platform");
+ return null;
+ }
+
try {
return getEnhanced4gLteSlice(sliceUri,
queryState.isEnabledByUser(), subId);
@@ -164,15 +156,6 @@
.build();
}
- protected ImsManager getImsManager(int subId) {
- return ImsManager.getInstance(mContext, SubscriptionUtil.getPhoneId(mContext, subId));
- }
-
- @VisibleForTesting
- ProvisioningManager getProvisioningManager(int subId) {
- return ProvisioningManager.createForSubscriptionId(subId);
- }
-
/**
* Handles Enhanced 4G LTE mode setting change from Enhanced 4G LTE slice and posts
* notification. Should be called when intent action is ACTION_ENHANCED_4G_LTE_CHANGED
@@ -183,9 +166,8 @@
final int subId = getDefaultVoiceSubId();
if (SubscriptionManager.isValidSubscriptionId(subId)) {
- final ImsManager imsManager = getImsManager(subId);
- if (imsManager.isVolteEnabledByPlatform() && isVolteProvisionedOnDevice(subId)) {
- final VolteQueryImsState queryState = queryImsState(subId);
+ final VolteQueryImsState queryState = queryImsState(subId);
+ if (queryState.isVoLteProvisioned()) {
final boolean currentValue = queryState.isEnabledByUser()
&& queryState.isAllowUserControl();
final boolean newValue = intent.getBooleanExtra(EXTRA_TOGGLE_STATE,
@@ -285,16 +267,6 @@
return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent, 0 /* flags */);
}
- private boolean isVolteProvisionedOnDevice(int subId) {
- final ProvisioningManager provisioningMgr = getProvisioningManager(subId);
- if (provisioningMgr == null) {
- return true;
- }
- return provisioningMgr.getProvisioningStatusForCapability(
- MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
- ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
- }
-
@VisibleForTesting
VolteQueryImsState queryImsState(int subId) {
return new VolteQueryImsState(mContext, subId);
diff --git a/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java b/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java
index fa5deab..ab8327c 100644
--- a/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java
+++ b/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java
@@ -48,8 +48,6 @@
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settingslib.DeviceInfoUtils;
-import java.util.List;
-
/**
* A dialog allowing the display name of a mobile network subscription to be changed
*/
@@ -117,9 +115,9 @@
.setPositiveButton(R.string.mobile_network_sim_name_rename, (dialog, which) -> {
mSubscriptionManager.setDisplayName(mNameView.getText().toString(), mSubId,
SubscriptionManager.NAME_SOURCE_USER_INPUT);
- final Color color = (mColorSpinner == null) ? mColors[0]
- : mColors[mColorSpinner.getSelectedItemPosition()];
- mSubscriptionManager.setIconTint(color.getColor(), mSubId);
+ mSubscriptionManager.setIconTint(
+ mColors[mColorSpinner.getSelectedItemPosition()].getColor(),
+ mSubId);
})
.setNegativeButton(android.R.string.cancel, null);
return builder.create();
@@ -128,17 +126,7 @@
@VisibleForTesting
protected void populateView(View view) {
mNameView = view.findViewById(R.id.name_edittext);
- SubscriptionInfo info = null;
- final List<SubscriptionInfo> infoList = mSubscriptionManager
- .getAvailableSubscriptionInfoList();
- if (infoList != null) {
- for (SubscriptionInfo subInfo : infoList) {
- if (subInfo.getSubscriptionId() == mSubId) {
- info = subInfo;
- break;
- }
- }
- }
+ final SubscriptionInfo info = mSubscriptionManager.getActiveSubscriptionInfo(mSubId);
if (info == null) {
Log.w(TAG, "got null SubscriptionInfo for mSubId:" + mSubId);
return;
diff --git a/src/com/android/settings/notification/zen/ZenModeAllBypassingConversationsPreferenceController.java b/src/com/android/settings/notification/zen/ZenModeAllBypassingConversationsPreferenceController.java
deleted file mode 100644
index 309cd42..0000000
--- a/src/com/android/settings/notification/zen/ZenModeAllBypassingConversationsPreferenceController.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright (C) 2020 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.zen;
-
-import android.app.Application;
-import android.app.NotificationChannel;
-import android.app.settings.SettingsEnums;
-import android.content.Context;
-import android.os.Bundle;
-import android.provider.Settings;
-import android.text.TextUtils;
-
-import androidx.annotation.VisibleForTesting;
-import androidx.core.text.BidiFormatter;
-import androidx.fragment.app.Fragment;
-import androidx.preference.Preference;
-import androidx.preference.PreferenceCategory;
-import androidx.preference.PreferenceScreen;
-
-import com.android.settings.R;
-import com.android.settings.applications.AppInfoBase;
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settings.core.SubSettingLauncher;
-import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.ChannelNotificationSettings;
-import com.android.settingslib.applications.ApplicationsState;
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.widget.apppreference.AppPreference;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Adds a preference to the PreferenceScreen for each conversation notification channel that can
- * bypass DND.
- */
-public class ZenModeAllBypassingConversationsPreferenceController extends
- AbstractPreferenceController implements PreferenceControllerMixin {
-
- private final String KEY = "zen_mode_settings_category_conversations";
-
- @VisibleForTesting ApplicationsState mApplicationsState;
- @VisibleForTesting PreferenceCategory mCategory;
- @VisibleForTesting Context mPrefContext;
-
- private ApplicationsState.Session mAppSession;
- private NotificationBackend mNotificationBackend = new NotificationBackend();
- private Fragment mHostFragment;
-
- public ZenModeAllBypassingConversationsPreferenceController(Context context, Application app,
- Fragment host) {
-
- this(context, app == null ? null : ApplicationsState.getInstance(app), host);
- }
-
- private ZenModeAllBypassingConversationsPreferenceController(Context context,
- ApplicationsState appState, Fragment host) {
- super(context);
- mApplicationsState = appState;
- mHostFragment = host;
-
- if (mApplicationsState != null && host != null) {
- mAppSession = mApplicationsState.newSession(mAppSessionCallbacks, host.getLifecycle());
- }
- }
-
- @Override
- public void displayPreference(PreferenceScreen screen) {
- mCategory = screen.findPreference(KEY);
- mPrefContext = screen.getContext();
- updateNotificationChannelList();
- super.displayPreference(screen);
- }
-
- @Override
- public boolean isAvailable() {
- return true;
- }
-
- @Override
- public String getPreferenceKey() {
- return KEY;
- }
-
- /**
- * Call this method to trigger the notification channels list to refresh.
- */
- public void updateNotificationChannelList() {
- if (mAppSession == null) {
- return;
- }
-
- ApplicationsState.AppFilter filter = ApplicationsState.FILTER_ALL_ENABLED;
- List<ApplicationsState.AppEntry> apps = mAppSession.rebuild(filter,
- ApplicationsState.ALPHA_COMPARATOR);
- if (apps != null) {
- updateNotificationChannelList(apps);
- }
- }
-
- @VisibleForTesting
- void updateNotificationChannelList(List<ApplicationsState.AppEntry> apps) {
- if (mCategory == null || apps == null) {
- return;
- }
-
- List<Preference> channelsBypassingDnd = new ArrayList<>();
- for (ApplicationsState.AppEntry entry : apps) {
- String pkg = entry.info.packageName;
- mApplicationsState.ensureIcon(entry);
- for (NotificationChannel channel : mNotificationBackend
- .getNotificationChannelsBypassingDnd(pkg, entry.info.uid).getList()) {
- if (TextUtils.isEmpty(channel.getConversationId())) {
- // only conversation channels
- continue;
- }
- Preference pref = new AppPreference(mPrefContext);
- pref.setKey(pkg + "|" + channel.getId());
- pref.setTitle(BidiFormatter.getInstance().unicodeWrap(entry.label));
- // TODO: use badged shortcut icon instead of app icon
- pref.setIcon(entry.icon);
- pref.setSummary(BidiFormatter.getInstance().unicodeWrap(channel.getName()));
-
- pref.setOnPreferenceClickListener(preference -> {
- Bundle args = new Bundle();
- args.putString(AppInfoBase.ARG_PACKAGE_NAME, entry.info.packageName);
- args.putInt(AppInfoBase.ARG_PACKAGE_UID, entry.info.uid);
- args.putString(Settings.EXTRA_CHANNEL_ID, channel.getId());
- new SubSettingLauncher(mContext)
- .setDestination(ChannelNotificationSettings.class.getName())
- .setArguments(args)
- .setTitleRes(R.string.notification_channel_title)
- .setResultListener(mHostFragment, 0)
- .setSourceMetricsCategory(
- SettingsEnums.NOTIFICATION_ZEN_MODE_OVERRIDING_APP)
- .launch();
- return true;
- });
- channelsBypassingDnd.add(pref);
- }
-
- mCategory.removeAll();
- if (channelsBypassingDnd.size() > 0) {
- mCategory.setVisible(true);
- for (Preference prefToAdd : channelsBypassingDnd) {
- mCategory.addPreference(prefToAdd);
- }
- } else {
- mCategory.setVisible(false);
- }
- }
- }
-
- private final ApplicationsState.Callbacks mAppSessionCallbacks =
- new ApplicationsState.Callbacks() {
-
- @Override
- public void onRunningStateChanged(boolean running) {
- updateNotificationChannelList();
- }
-
- @Override
- public void onPackageListChanged() {
- updateNotificationChannelList();
- }
-
- @Override
- public void onRebuildComplete(ArrayList<ApplicationsState.AppEntry> apps) {
- updateNotificationChannelList(apps);
- }
-
- @Override
- public void onPackageIconChanged() {
- updateNotificationChannelList();
- }
-
- @Override
- public void onPackageSizeChanged(String packageName) {
- updateNotificationChannelList();
- }
-
- @Override
- public void onAllSizesComputed() { }
-
- @Override
- public void onLauncherInfoChanged() {
- updateNotificationChannelList();
- }
-
- @Override
- public void onLoadEntriesCompleted() {
- // Add shortcut info
- updateNotificationChannelList();
- }
- };
-}
diff --git a/src/com/android/settings/notification/zen/ZenModeBackend.java b/src/com/android/settings/notification/zen/ZenModeBackend.java
index ac49466..836f435 100644
--- a/src/com/android/settings/notification/zen/ZenModeBackend.java
+++ b/src/com/android/settings/notification/zen/ZenModeBackend.java
@@ -16,8 +16,12 @@
package com.android.settings.notification.zen;
+import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_ANYONE;
+import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_IMPORTANT;
+import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_CONVERSATIONS;
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_SCREEN_OFF;
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_SCREEN_ON;
+import static android.service.notification.ZenPolicy.CONVERSATION_SENDERS_NONE;
import android.app.ActivityManager;
import android.app.AutomaticZenRule;
@@ -147,25 +151,35 @@
return SOURCE_NONE;
}
+ protected int getPriorityConversationSenders() {
+ if (isPriorityCategoryEnabled(PRIORITY_CATEGORY_CONVERSATIONS)) {
+ return mPolicy.priorityConversationSenders;
+ }
+ return CONVERSATION_SENDERS_NONE;
+ }
+
protected void saveVisualEffectsPolicy(int category, boolean suppress) {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.ZEN_SETTINGS_UPDATED, 1);
int suppressedEffects = getNewSuppressedEffects(suppress, category);
savePolicy(mPolicy.priorityCategories, mPolicy.priorityCallSenders,
- mPolicy.priorityMessageSenders, suppressedEffects);
+ mPolicy.priorityMessageSenders, suppressedEffects,
+ mPolicy.priorityConversationSenders);
}
protected void saveSoundPolicy(int category, boolean allow) {
int priorityCategories = getNewDefaultPriorityCategories(allow, category);
savePolicy(priorityCategories, mPolicy.priorityCallSenders,
- mPolicy.priorityMessageSenders, mPolicy.suppressedVisualEffects);
+ mPolicy.priorityMessageSenders, mPolicy.suppressedVisualEffects,
+ mPolicy.priorityConversationSenders);
}
protected void savePolicy(int priorityCategories, int priorityCallSenders,
- int priorityMessageSenders, int suppressedVisualEffects) {
+ int priorityMessageSenders, int suppressedVisualEffects,
+ int priorityConversationSenders) {
mPolicy = new NotificationManager.Policy(priorityCategories, priorityCallSenders,
- priorityMessageSenders, suppressedVisualEffects);
+ priorityMessageSenders, suppressedVisualEffects, priorityConversationSenders);
mNotificationManager.setNotificationPolicy(mPolicy);
}
@@ -210,23 +224,21 @@
}
savePolicy(getNewDefaultPriorityCategories(allowSenders, category),
- priorityCallSenders, priorityMessagesSenders, mPolicy.suppressedVisualEffects);
+ priorityCallSenders, priorityMessagesSenders, mPolicy.suppressedVisualEffects,
+ mPolicy.priorityConversationSenders);
if (ZenModeSettingsBase.DEBUG) Log.d(TAG, "onPrefChange allow" +
stringCategory + "=" + allowSenders + " allow" + stringCategory + "From="
+ ZenModeConfig.sourceToString(allowSendersFrom));
}
- protected String getSendersKey(int category) {
- switch (getZenMode()) {
- case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
- case Settings.Global.ZEN_MODE_ALARMS:
- return getKeyFromSetting(SOURCE_NONE);
- default:
- int prioritySenders = getPrioritySenders(category);
- return getKeyFromSetting(isPriorityCategoryEnabled(category)
- ? prioritySenders : SOURCE_NONE);
- }
+ protected void saveConversationSenders(int val) {
+ final boolean allowSenders = val != CONVERSATION_SENDERS_NONE;
+
+ savePolicy(getNewDefaultPriorityCategories(allowSenders, PRIORITY_CATEGORY_CONVERSATIONS),
+ mPolicy.priorityCallSenders, mPolicy.priorityMessageSenders,
+ mPolicy.suppressedVisualEffects, val);
+
}
private int getPrioritySenders(int category) {
@@ -240,6 +252,10 @@
return getPriorityMessageSenders();
}
+ if (category == NotificationManager.Policy.PRIORITY_CATEGORY_CONVERSATIONS) {
+ return getPriorityConversationSenders();
+ }
+
return categorySenders;
}
@@ -271,11 +287,13 @@
}
}
- protected int getAlarmsTotalSilenceCallsMessagesSummary(int category) {
+ protected int getAlarmsTotalSilencePeopleSummary(int category) {
if (category == NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES) {
return R.string.zen_mode_from_none_messages;
} else if (category == NotificationManager.Policy.PRIORITY_CATEGORY_CALLS){
return R.string.zen_mode_from_none_calls;
+ } else if (category == NotificationManager.Policy.PRIORITY_CATEGORY_CONVERSATIONS) {
+ return R.string.zen_mode_from_no_conversations;
}
return R.string.zen_mode_from_none;
}
@@ -309,6 +327,21 @@
}
}
+ protected int getConversationSummary() {
+ int conversationType = getPriorityConversationSenders();
+
+ switch (conversationType) {
+ case NotificationManager.Policy.CONVERSATION_SENDERS_ANYONE:
+ return R.string.zen_mode_from_all_conversations;
+ case NotificationManager.Policy.CONVERSATION_SENDERS_IMPORTANT:
+ return R.string.zen_mode_from_important_conversations;
+ case NotificationManager.Policy.CONVERSATION_SENDERS_NONE:
+ return R.string.zen_mode_from_no_conversations;
+ default:
+ return R.string.zen_mode_from_no_conversations;
+ }
+ }
+
protected int getContactsCallsSummary(ZenPolicy policy) {
int peopleType = policy.getPriorityCallSenders();
switch (peopleType) {
@@ -398,12 +431,21 @@
messages = ZenPolicy.PEOPLE_TYPE_NONE;
}
+ int conversations;
+ if (mPolicy.allowConversations()) {
+ // unlike the above, no mapping is needed because the values are the same
+ conversations = mPolicy.allowConversationsFrom();
+ } else {
+ conversations = CONVERSATION_SENDERS_NONE;
+ }
+
return new ZenPolicy.Builder(zenPolicy)
.allowAlarms(mPolicy.allowAlarms())
.allowCalls(calls)
.allowEvents(mPolicy.allowEvents())
.allowMedia(mPolicy.allowMedia())
.allowMessages(messages)
+ .allowConversations(conversations)
.allowReminders(mPolicy.allowReminders())
.allowRepeatCallers(mPolicy.allowRepeatCallers())
.allowSystem(mPolicy.allowSystem())
diff --git a/src/com/android/settings/notification/zen/ZenModeCallsPreferenceController.java b/src/com/android/settings/notification/zen/ZenModeCallsPreferenceController.java
index 7b97fb1..0930db2 100644
--- a/src/com/android/settings/notification/zen/ZenModeCallsPreferenceController.java
+++ b/src/com/android/settings/notification/zen/ZenModeCallsPreferenceController.java
@@ -56,7 +56,7 @@
case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
case Settings.Global.ZEN_MODE_ALARMS:
preference.setEnabled(false);
- preference.setSummary(mBackend.getAlarmsTotalSilenceCallsMessagesSummary(
+ preference.setSummary(mBackend.getAlarmsTotalSilencePeopleSummary(
NotificationManager.Policy.PRIORITY_CATEGORY_CALLS));
break;
default:
diff --git a/src/com/android/settings/notification/zen/ZenModeMessagesPreferenceController.java b/src/com/android/settings/notification/zen/ZenModeMessagesPreferenceController.java
index ba91f56..de169ed 100644
--- a/src/com/android/settings/notification/zen/ZenModeMessagesPreferenceController.java
+++ b/src/com/android/settings/notification/zen/ZenModeMessagesPreferenceController.java
@@ -55,7 +55,7 @@
case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
case Settings.Global.ZEN_MODE_ALARMS:
preference.setEnabled(false);
- preference.setSummary(mBackend.getAlarmsTotalSilenceCallsMessagesSummary(
+ preference.setSummary(mBackend.getAlarmsTotalSilencePeopleSummary(
NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES));
break;
default:
diff --git a/src/com/android/settings/notification/zen/ZenModePeoplePreferenceController.java b/src/com/android/settings/notification/zen/ZenModePeoplePreferenceController.java
index a06f023..a48c93d 100644
--- a/src/com/android/settings/notification/zen/ZenModePeoplePreferenceController.java
+++ b/src/com/android/settings/notification/zen/ZenModePeoplePreferenceController.java
@@ -55,7 +55,7 @@
case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
case Settings.Global.ZEN_MODE_ALARMS:
preference.setEnabled(false);
- preference.setSummary(mBackend.getAlarmsTotalSilenceCallsMessagesSummary(
+ preference.setSummary(mBackend.getAlarmsTotalSilencePeopleSummary(
NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES));
break;
default:
diff --git a/src/com/android/settings/notification/zen/ZenModePeopleSettings.java b/src/com/android/settings/notification/zen/ZenModePeopleSettings.java
index af3c26b..ff768db 100644
--- a/src/com/android/settings/notification/zen/ZenModePeopleSettings.java
+++ b/src/com/android/settings/notification/zen/ZenModePeopleSettings.java
@@ -65,8 +65,7 @@
controllers.add(new ZenModeRepeatCallersPreferenceController(context, lifecycle,
context.getResources().getInteger(com.android.internal.R.integer
.config_zen_repeat_callers_threshold)));
- controllers.add(
- new ZenModeAllBypassingConversationsPreferenceController(context, app, host));
+ controllers.add(new ZenModePriorityConversationsPreferenceController(context, lifecycle));
controllers.add(new ZenModeSettingsFooterPreferenceController(context, lifecycle,
fragmentManager));
return controllers;
diff --git a/src/com/android/settings/notification/zen/ZenModePriorityCallsPreferenceController.java b/src/com/android/settings/notification/zen/ZenModePriorityCallsPreferenceController.java
index 780cf84..6b538dc 100644
--- a/src/com/android/settings/notification/zen/ZenModePriorityCallsPreferenceController.java
+++ b/src/com/android/settings/notification/zen/ZenModePriorityCallsPreferenceController.java
@@ -80,7 +80,7 @@
case Settings.Global.ZEN_MODE_ALARMS:
mPreference.setEnabled(false);
mPreference.setValue(ZenModeBackend.ZEN_MODE_FROM_NONE);
- mPreference.setSummary(mBackend.getAlarmsTotalSilenceCallsMessagesSummary(
+ mPreference.setSummary(mBackend.getAlarmsTotalSilencePeopleSummary(
NotificationManager.Policy.PRIORITY_CATEGORY_CALLS));
break;
default:
diff --git a/src/com/android/settings/notification/zen/ZenModePriorityConversationsPreferenceController.java b/src/com/android/settings/notification/zen/ZenModePriorityConversationsPreferenceController.java
new file mode 100644
index 0000000..afd17ad
--- /dev/null
+++ b/src/com/android/settings/notification/zen/ZenModePriorityConversationsPreferenceController.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2020 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.zen;
+
+import static android.service.notification.ZenPolicy.CONVERSATION_SENDERS_ANYONE;
+import static android.service.notification.ZenPolicy.CONVERSATION_SENDERS_IMPORTANT;
+import static android.service.notification.ZenPolicy.CONVERSATION_SENDERS_NONE;
+
+import android.app.NotificationManager;
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.preference.ListPreference;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+public class ZenModePriorityConversationsPreferenceController
+ extends AbstractZenModePreferenceController
+ implements Preference.OnPreferenceChangeListener {
+
+ protected static final String KEY = "zen_mode_conversations";
+ private final ZenModeBackend mBackend;
+ private ListPreference mPreference;
+
+ public ZenModePriorityConversationsPreferenceController(Context context, Lifecycle lifecycle) {
+ super(context, KEY, lifecycle);
+ mBackend = ZenModeBackend.getInstance(context);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return true;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreference = screen.findPreference(KEY);
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+ updateValue(preference);
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object selectedContactsFrom) {
+ mBackend.saveConversationSenders(Integer.parseInt(selectedContactsFrom.toString()));
+ updateValue(preference);
+ return true;
+ }
+
+ private void updateValue(Preference preference) {
+ mPreference = (ListPreference) preference;
+ switch (getZenMode()) {
+ case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
+ case Settings.Global.ZEN_MODE_ALARMS:
+ mPreference.setEnabled(false);
+ mPreference.setValue(String.valueOf(CONVERSATION_SENDERS_NONE));
+ mPreference.setSummary(mBackend.getAlarmsTotalSilencePeopleSummary(
+ NotificationManager.Policy.PRIORITY_CATEGORY_CONVERSATIONS));
+ break;
+ default:
+ preference.setEnabled(true);
+ preference.setSummary(mBackend.getConversationSummary());
+ int senders = mBackend.getPriorityConversationSenders();
+
+ switch (senders) {
+ case CONVERSATION_SENDERS_NONE:
+ mPreference.setValue(String.valueOf(CONVERSATION_SENDERS_NONE));
+ break;
+ case CONVERSATION_SENDERS_IMPORTANT:
+ mPreference.setValue(String.valueOf(CONVERSATION_SENDERS_IMPORTANT));
+ break;
+ default:
+ mPreference.setValue(String.valueOf(CONVERSATION_SENDERS_ANYONE));
+ break;
+ }
+ }
+ }
+}
diff --git a/src/com/android/settings/notification/zen/ZenModePriorityMessagesPreferenceController.java b/src/com/android/settings/notification/zen/ZenModePriorityMessagesPreferenceController.java
index f54179e..6476c63 100644
--- a/src/com/android/settings/notification/zen/ZenModePriorityMessagesPreferenceController.java
+++ b/src/com/android/settings/notification/zen/ZenModePriorityMessagesPreferenceController.java
@@ -80,7 +80,7 @@
case Settings.Global.ZEN_MODE_ALARMS:
mPreference.setEnabled(false);
mPreference.setValue(ZenModeBackend.ZEN_MODE_FROM_NONE);
- mPreference.setSummary(mBackend.getAlarmsTotalSilenceCallsMessagesSummary(
+ mPreference.setSummary(mBackend.getAlarmsTotalSilencePeopleSummary(
NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES));
break;
default:
diff --git a/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragment.java b/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragment.java
index b584ea1..05c7b4e 100644
--- a/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragment.java
+++ b/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragment.java
@@ -715,7 +715,7 @@
}
@VisibleForTesting
- void updateScanResults(List<AccessPoint> allAccessPoints) {
+ void updateScanResultsToUi(List<AccessPoint> allAccessPoints) {
if (mUiToRequestedList == null) {
// Nothing need to be updated.
return;
@@ -723,13 +723,16 @@
// Update the signal level of the UI networks.
for (UiConfigurationItem uiConfigurationItem : mUiToRequestedList) {
- final Optional<AccessPoint> matchedAccessPoint = allAccessPoints
- .stream()
- .filter(accesspoint -> accesspoint.matches(
- uiConfigurationItem.mWifiNetworkSuggestion.getWifiConfiguration()))
- .findFirst();
- uiConfigurationItem.mLevel =
- matchedAccessPoint.isPresent() ? matchedAccessPoint.get().getLevel() : 0;
+ uiConfigurationItem.mLevel = 0;
+ if (allAccessPoints != null) {
+ final Optional<AccessPoint> matchedAccessPoint = allAccessPoints
+ .stream()
+ .filter(accesspoint -> accesspoint.matches(
+ uiConfigurationItem.mWifiNetworkSuggestion.getWifiConfiguration()))
+ .findFirst();
+ uiConfigurationItem.mLevel =
+ matchedAccessPoint.isPresent() ? matchedAccessPoint.get().getLevel() : 0;
+ }
}
if (mIsSingleNetwork) {
@@ -742,7 +745,17 @@
}
@Override
+ public void onResume() {
+ super.onResume();
+ onAccessPointsChanged();
+ }
+
+ /**
+ * Update the results when data changes
+ */
+ @Override
public void onAccessPointsChanged() {
- updateScanResults(mWifiTracker.getAccessPoints());
+ updateScanResultsToUi(
+ mWifiTracker.getManager().isWifiEnabled() ? mWifiTracker.getAccessPoints() : null);
}
}
diff --git a/tests/robotests/src/com/android/settings/location/LocationForWorkPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/LocationForWorkPreferenceControllerTest.java
index 4b0df98..b4bda14 100644
--- a/tests/robotests/src/com/android/settings/location/LocationForWorkPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/location/LocationForWorkPreferenceControllerTest.java
@@ -38,7 +38,6 @@
import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -114,7 +113,6 @@
}
@Test
- @Ignore
public void onLocationModeChanged_disabledByAdmin_shouldDisablePreference() {
mController.displayPreference(mScreen);
final EnforcedAdmin admin = mock(EnforcedAdmin.class);
@@ -124,11 +122,9 @@
mController.onLocationModeChanged(Settings.Secure.LOCATION_MODE_BATTERY_SAVING, false);
verify(mPreference).setDisabledByAdmin(any());
- verify(mPreference).setChecked(false);
}
@Test
- @Ignore
public void onLocationModeChanged_locationOff_shouldDisablePreference() {
mController.displayPreference(mScreen);
doReturn(null).when(mEnabler).getShareLocationEnforcedAdmin(anyInt());
@@ -138,7 +134,7 @@
verify(mPreference).setEnabled(false);
verify(mPreference).setChecked(false);
- verify(mPreference).setSummary(R.string.switch_off_text);
+ verify(mPreference).setSummary(R.string.location_app_permission_summary_location_off);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java b/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
index a18e49d..4ae829f 100644
--- a/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
+++ b/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
@@ -16,9 +16,6 @@
package com.android.settings.network;
-import static android.telephony.UiccSlotInfo.CARD_STATE_INFO_ABSENT;
-import static android.telephony.UiccSlotInfo.CARD_STATE_INFO_PRESENT;
-
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.doReturn;
@@ -29,10 +26,8 @@
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
-import android.telephony.UiccSlotInfo;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -88,43 +83,6 @@
}
@Test
- @Ignore
- public void getAvailableSubscriptions_oneSelectableTwoDisabledPSimsOneAbsent_twoResults() {
- final SubscriptionInfo info1 = mock(SubscriptionInfo.class);
- final SubscriptionInfo info2 = mock(SubscriptionInfo.class);
- final SubscriptionInfo info3 = mock(SubscriptionInfo.class);
-
- when(info1.getSubscriptionId()).thenReturn(111);
- when(info1.getSimSlotIndex()).thenReturn(-1);
-
- when(info2.getSubscriptionId()).thenReturn(222);
- when(info2.getSimSlotIndex()).thenReturn(-1);
-
- when(info3.getSubscriptionId()).thenReturn(333);
- when(info3.getSimSlotIndex()).thenReturn(0);
-
- when(mSubMgr.getAvailableSubscriptionInfoList()).thenReturn(Arrays.asList(info1));
- when(mSubMgr.getAllSubscriptionInfoList()).thenReturn(Arrays.asList(info1, info2, info3));
-
- final UiccSlotInfo info2slot = mock(UiccSlotInfo.class);
- final UiccSlotInfo info3slot = mock(UiccSlotInfo.class);
-
- when(info2slot.getLogicalSlotIdx()).thenReturn(-1);
- when(info2slot.getCardStateInfo()).thenReturn(CARD_STATE_INFO_ABSENT);
-
- when(info3slot.getLogicalSlotIdx()).thenReturn(0);
- when(info3slot.getCardStateInfo()).thenReturn(CARD_STATE_INFO_PRESENT);
-
- final UiccSlotInfo[] slotInfos = {info2slot, info3slot};
- when(mTelMgr.getUiccSlotsInfo()).thenReturn(slotInfos);
-
- final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mContext);
- assertThat(subs).hasSize(2);
- assertThat(subs.get(0).getSubscriptionId()).isEqualTo(111);
- assertThat(subs.get(1).getSubscriptionId()).isEqualTo(333);
- }
-
- @Test
public void getActiveSubscriptions_nullInfoFromSubscriptionManager_nonNullResult() {
when(mSubMgr.getActiveSubscriptionInfoList()).thenReturn(null);
final List<SubscriptionInfo> subs = SubscriptionUtil.getActiveSubscriptions(mSubMgr);
diff --git a/tests/robotests/src/com/android/settings/network/ims/MockVolteQueryImsState.java b/tests/robotests/src/com/android/settings/network/ims/MockVolteQueryImsState.java
new file mode 100644
index 0000000..42ddd70
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/network/ims/MockVolteQueryImsState.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2020 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.network.ims;
+
+import android.content.Context;
+
+import com.android.ims.ImsManager;
+
+
+
+/**
+ * Controller class for mock VoLte status
+ */
+public class MockVolteQueryImsState extends VolteQueryImsState {
+
+ private ImsQuery mIsTtyOnVolteEnabled;
+ private ImsQuery mIsProvisionedOnDevice;
+ private ImsQuery mIsEnabledByUser;
+
+ /**
+ * Constructor
+ *
+ * @param context {@link Context}
+ * @param subId subscription's id
+ */
+ public MockVolteQueryImsState(Context context, int subId) {
+ super(context, subId);
+ }
+
+ public ImsManager getImsManager(int subId) {
+ return super.getImsManager(subId);
+ }
+
+ public void setIsTtyOnVolteEnabled(boolean enabled) {
+ mIsTtyOnVolteEnabled = new MockImsQueryResult.BooleanResult(enabled);
+ }
+
+ @Override
+ ImsQuery isTtyOnVolteEnabled(int subId) {
+ if (mIsTtyOnVolteEnabled != null) {
+ return mIsTtyOnVolteEnabled;
+ }
+ return super.isTtyOnVolteEnabled(subId);
+ }
+
+ public void setIsProvisionedOnDevice(boolean isProvisioned) {
+ mIsProvisionedOnDevice = new MockImsQueryResult.BooleanResult(isProvisioned);
+ }
+
+ @Override
+ ImsQuery isProvisionedOnDevice(int subId) {
+ if (mIsProvisionedOnDevice != null) {
+ return mIsProvisionedOnDevice;
+ }
+ return super.isProvisionedOnDevice(subId);
+ }
+
+ public void setIsEnabledByUser(boolean enabled) {
+ mIsEnabledByUser = new MockImsQueryResult.BooleanResult(enabled);
+ }
+
+ @Override
+ ImsQuery isEnabledByUser(int subId) {
+ if (mIsEnabledByUser != null) {
+ return mIsEnabledByUser;
+ }
+ return super.isEnabledByUser(subId);
+ }
+
+}
diff --git a/tests/robotests/src/com/android/settings/network/ims/MockVtQueryImsState.java b/tests/robotests/src/com/android/settings/network/ims/MockVtQueryImsState.java
index 877db79..b5971e9 100644
--- a/tests/robotests/src/com/android/settings/network/ims/MockVtQueryImsState.java
+++ b/tests/robotests/src/com/android/settings/network/ims/MockVtQueryImsState.java
@@ -33,7 +33,7 @@
/**
* Constructor
*
- * @param context {@code Context}
+ * @param context {@link Context}
* @param subId subscription's id
*/
public MockVtQueryImsState(Context context, int subId) {
diff --git a/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceControllerTest.java
index 3e0bfa3..d7db984 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceControllerTest.java
@@ -35,7 +35,7 @@
import com.android.ims.ImsManager;
import com.android.settings.core.BasePreferenceController;
-import com.android.settings.network.ims.VolteQueryImsState;
+import com.android.settings.network.ims.MockVolteQueryImsState;
import com.android.settingslib.RestrictedSwitchPreference;
import org.junit.Before;
@@ -63,7 +63,7 @@
@Mock
private ProvisioningManager mProvisioningManager;
- private VolteQueryImsState mQueryImsState;
+ private MockVolteQueryImsState mQueryImsState;
private Enhanced4gLtePreferenceController mController;
private SwitchPreference mPreference;
@@ -85,17 +85,13 @@
mCarrierConfig = new PersistableBundle();
doReturn(mCarrierConfig).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
- mQueryImsState = spy(new VolteQueryImsState(mContext, SUB_ID));
+ mQueryImsState = spy(new MockVolteQueryImsState(mContext, SUB_ID));
+ doReturn(mImsManager).when(mQueryImsState).getImsManager(anyInt());
+ mQueryImsState.setIsProvisionedOnDevice(true);
mPreference = new RestrictedSwitchPreference(mContext);
- mController = spy(new Enhanced4gLtePreferenceController(mContext, "roaming") {
- @Override
- ProvisioningManager getProvisioningManager(int subId) {
- return mProvisioningManager;
- }
- });
+ mController = spy(new Enhanced4gLtePreferenceController(mContext, "VoLTE"));
mController.init(SUB_ID);
- mController.mImsManager = mImsManager;
doReturn(mQueryImsState).when(mController).queryImsState(anyInt());
mPreference.setKey(mController.getPreferenceKey());
}
diff --git a/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelperTest.java b/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelperTest.java
index c9abe23..a89a7aa 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelperTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelperTest.java
@@ -34,8 +34,6 @@
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
import android.telephony.ims.ProvisioningManager;
-import android.telephony.ims.feature.MmTelFeature;
-import android.telephony.ims.stub.ImsRegistrationImplBase;
import androidx.slice.Slice;
import androidx.slice.SliceItem;
@@ -47,7 +45,7 @@
import com.android.ims.ImsManager;
import com.android.settings.R;
-import com.android.settings.network.ims.VolteQueryImsState;
+import com.android.settings.network.ims.MockVolteQueryImsState;
import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.slices.SettingsSliceProvider;
import com.android.settings.slices.SliceBroadcastReceiver;
@@ -81,7 +79,7 @@
private ProvisioningManager mProvisioningManager;
private ShadowSubscriptionManager mShadowSubscriptionManager;
- private VolteQueryImsState mQueryImsState;
+ private MockVolteQueryImsState mQueryImsState;
private Context mContext;
private FakeEnhanced4gLteSliceHelper mEnhanced4gLteSliceHelper;
@@ -110,7 +108,9 @@
//setup for SliceBroadcastReceiver test
mReceiver = spy(new SliceBroadcastReceiver());
- mQueryImsState = spy(new VolteQueryImsState(mContext, SUB_ID));
+ mQueryImsState = spy(new MockVolteQueryImsState(mContext, SUB_ID));
+ doReturn(mMockImsManager).when(mQueryImsState).getImsManager(anyInt());
+ mQueryImsState.setIsProvisionedOnDevice(true);
mEnhanced4gLteSliceHelper = spy(new FakeEnhanced4gLteSliceHelper(mContext));
doReturn(mQueryImsState).when(mEnhanced4gLteSliceHelper).queryImsState(anyInt());
@@ -143,9 +143,7 @@
@Test
public void test_CreateEnhanced4gLteSlice_success() {
when(mMockImsManager.isVolteEnabledByPlatform()).thenReturn(true);
- when(mProvisioningManager.getProvisioningStatusForCapability(
- MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
- ImsRegistrationImplBase.REGISTRATION_TECH_LTE)).thenReturn(true);
+ mQueryImsState.setIsProvisionedOnDevice(true);
doReturn(true).when(mQueryImsState).isEnabledByUser();
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
when(mMockCarrierConfigManager.getConfigForSubId(1)).thenReturn(null);
@@ -160,9 +158,7 @@
@Test
public void test_SettingSliceProvider_getsRightSliceEnhanced4gLte() {
when(mMockImsManager.isVolteEnabledByPlatform()).thenReturn(true);
- when(mProvisioningManager.getProvisioningStatusForCapability(
- MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
- ImsRegistrationImplBase.REGISTRATION_TECH_LTE)).thenReturn(true);
+ mQueryImsState.setIsProvisionedOnDevice(true);
doReturn(true).when(mQueryImsState).isEnabledByUser();
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
when(mMockCarrierConfigManager.getConfigForSubId(1)).thenReturn(null);
@@ -179,9 +175,7 @@
@Ignore
public void test_SliceBroadcastReceiver_toggleOffEnhanced4gLte() {
when(mMockImsManager.isVolteEnabledByPlatform()).thenReturn(true);
- when(mProvisioningManager.getProvisioningStatusForCapability(
- MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
- ImsRegistrationImplBase.REGISTRATION_TECH_LTE)).thenReturn(true);
+ mQueryImsState.setIsProvisionedOnDevice(true);
doReturn(false).when(mQueryImsState).isEnabledByUser();
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
when(mSlicesFeatureProvider.getNewEnhanced4gLteSliceHelper(mContext))
@@ -278,7 +272,7 @@
}
private class FakeEnhanced4gLteSliceHelper extends Enhanced4gLteSliceHelper {
- int mSubId = 1;
+ int mSubId = SUB_ID;
FakeEnhanced4gLteSliceHelper(Context context) {
super(context);
@@ -289,16 +283,6 @@
return mMockCarrierConfigManager;
}
- @Override
- protected ImsManager getImsManager(int subId) {
- return mMockImsManager;
- }
-
- @Override
- ProvisioningManager getProvisioningManager(int subId) {
- return mProvisioningManager;
- }
-
protected int getDefaultVoiceSubId() {
return mSubId;
}
diff --git a/tests/robotests/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragmentTest.java b/tests/robotests/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragmentTest.java
index b406986..2d5f47b 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragmentTest.java
@@ -23,12 +23,12 @@
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.telephony.ServiceState;
@@ -48,6 +48,7 @@
import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
@@ -55,13 +56,7 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
-import org.robolectric.shadow.api.Shadow;
-import org.robolectric.shadows.ShadowTelephonyManager;
-
-import java.util.ArrayList;
-import java.util.List;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = ShadowAlertDialogCompat.class)
@@ -70,8 +65,6 @@
@Mock
private TelephonyManager mTelephonyMgr;
@Mock
- private ServiceState mServiceState;
- @Mock
private SubscriptionManager mSubscriptionMgr;
@Mock
private SubscriptionInfo mSubscriptionInfo;
@@ -79,38 +72,27 @@
private FragmentActivity mActivity;
private RenameMobileNetworkDialogFragment mFragment;
private int mSubscriptionId = 1234;
- private List<SubscriptionInfo> mSubscriptionInfoList;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
-
- Context context = spy(RuntimeEnvironment.application);
-
- final ShadowTelephonyManager stm = Shadow.extract(context.getSystemService(
- TelephonyManager.class));
- stm.setTelephonyManagerForSubscriptionId(mSubscriptionId, mTelephonyMgr);
- when(mTelephonyMgr.createForSubscriptionId(anyInt())).thenReturn(mTelephonyMgr);
-
- when(mTelephonyMgr.getServiceState()).thenReturn(mServiceState);
- when(mServiceState.getOperatorAlphaLong()).thenReturn("fake carrier name");
+ mActivity = spy(Robolectric.buildActivity(FragmentActivity.class).setup().get());
when(mSubscriptionInfo.getSubscriptionId()).thenReturn(mSubscriptionId);
when(mSubscriptionInfo.getDisplayName()).thenReturn("test");
- when(mSubscriptionMgr.setDisplayName(any(), anyInt(), anyInt())).thenReturn(0);
-
- mActivity = spy(Robolectric.buildActivity(FragmentActivity.class).setup().get());
mFragment = spy(RenameMobileNetworkDialogFragment.newInstance(mSubscriptionId));
+ doReturn(mTelephonyMgr).when(mFragment).getTelephonyManager(any());
doReturn(mSubscriptionMgr).when(mFragment).getSubscriptionManager(any());
- mSubscriptionInfoList = new ArrayList<SubscriptionInfo>();
- mSubscriptionInfoList.add(mSubscriptionInfo);
- when(mSubscriptionMgr.getAvailableSubscriptionInfoList()).thenReturn(
- mSubscriptionInfoList);
+ final ServiceState serviceState = mock(ServiceState.class);
+ when(serviceState.getOperatorAlphaLong()).thenReturn("fake carrier name");
+ when(mTelephonyMgr.createForSubscriptionId(anyInt())).thenReturn(mTelephonyMgr);
+ when(mTelephonyMgr.getServiceState()).thenReturn(serviceState);
}
@Test
+ @Ignore
public void dialog_subscriptionMissing_noCrash() {
final AlertDialog dialog = startDialog();
final Button negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
@@ -119,7 +101,10 @@
}
@Test
+ @Ignore
public void dialog_cancelButtonClicked_setDisplayNameAndIconTintNotCalled() {
+ when(mSubscriptionMgr.getActiveSubscriptionInfo(mSubscriptionId)).thenReturn(
+ mSubscriptionInfo);
final AlertDialog dialog = startDialog();
final EditText nameView = mFragment.getNameView();
nameView.setText("test2");
@@ -132,7 +117,11 @@
}
@Test
+ @Ignore
public void dialog_saveButtonClicked_setDisplayNameAndIconTint() {
+ when(mSubscriptionMgr.getActiveSubscriptionInfo(mSubscriptionId)).thenReturn(
+ mSubscriptionInfo);
+
final AlertDialog dialog = startDialog();
final EditText nameView = mFragment.getNameView();
nameView.setText("test2");
@@ -152,9 +141,12 @@
}
@Test
+ @Ignore
public void populateView_infoIsOpportunistic_hideNumberLabel() {
final View view = LayoutInflater.from(mActivity).inflate(
R.layout.dialog_mobile_network_rename, null);
+ when(mSubscriptionMgr.getActiveSubscriptionInfo(mSubscriptionId)).thenReturn(
+ mSubscriptionInfo);
when(mSubscriptionInfo.isOpportunistic()).thenReturn(true);
startDialog();
diff --git a/tests/robotests/src/com/android/settings/notification/zen/ZenModeBackendTest.java b/tests/robotests/src/com/android/settings/notification/zen/ZenModeBackendTest.java
index c4ece5a..247d68e 100644
--- a/tests/robotests/src/com/android/settings/notification/zen/ZenModeBackendTest.java
+++ b/tests/robotests/src/com/android/settings/notification/zen/ZenModeBackendTest.java
@@ -1,25 +1,41 @@
package com.android.settings.notification.zen;
+import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_ANYONE;
+import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_IMPORTANT;
+import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_NONE;
+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_CONVERSATIONS;
+import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES;
+import static android.app.NotificationManager.Policy.PRIORITY_SENDERS_ANY;
+import static android.app.NotificationManager.Policy.PRIORITY_SENDERS_CONTACTS;
+import static android.app.NotificationManager.Policy.PRIORITY_SENDERS_STARRED;
+import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_AMBIENT;
+
import static com.google.common.truth.Truth.assertThat;
import static junit.framework.Assert.assertEquals;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.AutomaticZenRule;
import android.app.NotificationManager;
+import android.app.NotificationManager.Policy;
import android.content.Context;
import android.database.Cursor;
import android.provider.Settings;
import android.service.notification.ZenModeConfig;
-import com.android.settings.notification.zen.ZenModeBackend;
+import com.android.settings.R;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.invocation.InvocationOnMock;
@@ -55,60 +71,6 @@
mBackend = new ZenModeBackend(mContext);
}
- @Test
- public void updateState_checkRuleOrderingDescending() {
- final int NUM_RULES = 4;
- Map.Entry<String, AutomaticZenRule>[] rules = populateAutoZenRulesDescendingCreationTime(
- NUM_RULES, false);
- Arrays.sort(rules, ZenModeBackend.RULE_COMPARATOR);
-
- // check ordering, most recent should be at the end
- for (int i = 0; i < NUM_RULES; i++) {
- assertEquals(GENERIC_RULE_NAME + (NUM_RULES - 1 - i), rules[i].getKey());
- }
- }
-
- @Test
- public void updateState_checkRuleOrderingAscending() {
- final int NUM_RULES = 4;
- Map.Entry<String, AutomaticZenRule>[] rules = populateAutoZenRulesAscendingCreationTime(
- NUM_RULES, false);
- Arrays.sort(rules, ZenModeBackend.RULE_COMPARATOR);
-
- // check ordering, most recent should be at the end
- for (int i = 0; i < NUM_RULES; i++) {
- assertEquals(GENERIC_RULE_NAME + i, rules[i].getKey());
- }
- }
-
- @Test
- public void updateState_checkRuleOrderingDescending_withDefaultRules() {
- final int NUM_RULES = 4;
-
- Map.Entry<String, AutomaticZenRule>[] rules = populateAutoZenRulesDescendingCreationTime(NUM_RULES,
- true);
- Arrays.sort(rules, ZenModeBackend.RULE_COMPARATOR);
-
- assertEquals(rules[0].getKey(), DEFAULT_ID_1);
- assertEquals(rules[1].getKey(), DEFAULT_ID_2);
- // NON-DEFAULT RULES check ordering, most recent at the bottom/end
- for (int i = 0; i < NUM_RULES; i++) {
- assertEquals(GENERIC_RULE_NAME + (NUM_RULES - 1 - i), rules[i + 2].getKey());
- }
- }
-
- @Test
- public void updateSummary_nullCursorValues() {
- Cursor testCursorWithNullValues = createMockCursor(3);
- when(testCursorWithNullValues.getString(0)).thenReturn(null);
-
- // expected - no null values
- List<String> contacts = mBackend.getStarredContacts(testCursorWithNullValues);
- for (String contact : contacts) {
- assertThat(contact).isNotNull();
- }
- }
-
private Cursor createMockCursor(int size) {
Cursor mockCursor = mock(Cursor.class);
when(mockCursor.moveToFirst()).thenReturn(true);
@@ -173,4 +135,133 @@
ruleMap.entrySet().toArray(toReturn);
return toReturn;
}
+
+ @Test
+ public void updateState_checkRuleOrderingDescending() {
+ final int NUM_RULES = 4;
+ Map.Entry<String, AutomaticZenRule>[] rules = populateAutoZenRulesDescendingCreationTime(
+ NUM_RULES, false);
+ Arrays.sort(rules, ZenModeBackend.RULE_COMPARATOR);
+
+ // check ordering, most recent should be at the end
+ for (int i = 0; i < NUM_RULES; i++) {
+ assertEquals(GENERIC_RULE_NAME + (NUM_RULES - 1 - i), rules[i].getKey());
+ }
+ }
+
+ @Test
+ public void updateState_checkRuleOrderingAscending() {
+ final int NUM_RULES = 4;
+ Map.Entry<String, AutomaticZenRule>[] rules = populateAutoZenRulesAscendingCreationTime(
+ NUM_RULES, false);
+ Arrays.sort(rules, ZenModeBackend.RULE_COMPARATOR);
+
+ // check ordering, most recent should be at the end
+ for (int i = 0; i < NUM_RULES; i++) {
+ assertEquals(GENERIC_RULE_NAME + i, rules[i].getKey());
+ }
+ }
+
+ @Test
+ public void updateState_checkRuleOrderingDescending_withDefaultRules() {
+ final int NUM_RULES = 4;
+
+ Map.Entry<String, AutomaticZenRule>[] rules = populateAutoZenRulesDescendingCreationTime(NUM_RULES,
+ true);
+ Arrays.sort(rules, ZenModeBackend.RULE_COMPARATOR);
+
+ assertEquals(rules[0].getKey(), DEFAULT_ID_1);
+ assertEquals(rules[1].getKey(), DEFAULT_ID_2);
+ // NON-DEFAULT RULES check ordering, most recent at the bottom/end
+ for (int i = 0; i < NUM_RULES; i++) {
+ assertEquals(GENERIC_RULE_NAME + (NUM_RULES - 1 - i), rules[i + 2].getKey());
+ }
+ }
+
+ @Test
+ public void updateSummary_nullCursorValues() {
+ Cursor testCursorWithNullValues = createMockCursor(3);
+ when(testCursorWithNullValues.getString(0)).thenReturn(null);
+
+ // expected - no null values
+ List<String> contacts = mBackend.getStarredContacts(testCursorWithNullValues);
+ for (String contact : contacts) {
+ assertThat(contact).isNotNull();
+ }
+ }
+
+ @Test
+ public void saveConversationSenders_importantToNone() {
+ when(mNotificationManager.getNotificationPolicy()).thenReturn(
+ new Policy(PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_CONVERSATIONS
+ | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS,
+ PRIORITY_SENDERS_CONTACTS,
+ PRIORITY_SENDERS_STARRED,
+ SUPPRESSED_EFFECT_AMBIENT,
+ CONVERSATION_SENDERS_IMPORTANT));
+ mBackend = new ZenModeBackend(mContext);
+
+ mBackend.saveConversationSenders(CONVERSATION_SENDERS_NONE);
+
+ ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class);
+ verify(mNotificationManager, times(1)).setNotificationPolicy(captor.capture());
+
+ Policy expected = new Policy(
+ PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS,
+ PRIORITY_SENDERS_CONTACTS,
+ PRIORITY_SENDERS_STARRED,
+ SUPPRESSED_EFFECT_AMBIENT,
+ CONVERSATION_SENDERS_NONE);
+ assertEquals(expected, captor.getValue());
+ }
+
+ @Test
+ public void saveConversationSenders_noneToAll() {
+ when(mNotificationManager.getNotificationPolicy()).thenReturn(new Policy(
+ PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS,
+ PRIORITY_SENDERS_CONTACTS,
+ PRIORITY_SENDERS_STARRED,
+ SUPPRESSED_EFFECT_AMBIENT,
+ CONVERSATION_SENDERS_NONE));
+ mBackend = new ZenModeBackend(mContext);
+
+ mBackend.saveConversationSenders(CONVERSATION_SENDERS_ANYONE);
+
+ ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class);
+ verify(mNotificationManager, times(1)).setNotificationPolicy(captor.capture());
+
+ Policy expected = new Policy(PRIORITY_CATEGORY_CONVERSATIONS
+ | PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS,
+ PRIORITY_SENDERS_CONTACTS,
+ PRIORITY_SENDERS_STARRED,
+ SUPPRESSED_EFFECT_AMBIENT,
+ CONVERSATION_SENDERS_ANYONE);
+ assertEquals(expected, captor.getValue());
+ }
+
+ @Test
+ public void saveSenders_doesNotChangeConversations() {
+ when(mNotificationManager.getNotificationPolicy()).thenReturn(
+ new Policy(PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_CONVERSATIONS
+ | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS,
+ PRIORITY_SENDERS_CONTACTS,
+ PRIORITY_SENDERS_STARRED,
+ SUPPRESSED_EFFECT_AMBIENT,
+ CONVERSATION_SENDERS_ANYONE));
+ mBackend = new ZenModeBackend(mContext);
+
+ mBackend.saveSenders(PRIORITY_CATEGORY_CALLS, PRIORITY_SENDERS_ANY);
+
+ ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class);
+ verify(mNotificationManager, times(1)).setNotificationPolicy(captor.capture());
+
+ Policy expected = new Policy(PRIORITY_CATEGORY_CONVERSATIONS
+ | PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS,
+ PRIORITY_SENDERS_ANY,
+ PRIORITY_SENDERS_STARRED,
+ SUPPRESSED_EFFECT_AMBIENT,
+ CONVERSATION_SENDERS_ANYONE);
+ assertEquals(expected, captor.getValue());
+ }
+
}
diff --git a/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityCallsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityCallsPreferenceControllerTest.java
index e4490d5..d1f80b8 100644
--- a/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityCallsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityCallsPreferenceControllerTest.java
@@ -34,8 +34,6 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
-import com.android.settings.notification.zen.ZenModeBackend;
-import com.android.settings.notification.zen.ZenModePriorityCallsPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.Before;
@@ -88,7 +86,7 @@
when(mBackend.getPriorityCallSenders())
.thenReturn(NotificationManager.Policy.PRIORITY_SENDERS_STARRED);
- when(mBackend.getAlarmsTotalSilenceCallsMessagesSummary(
+ when(mBackend.getAlarmsTotalSilencePeopleSummary(
NotificationManager.Policy.PRIORITY_CATEGORY_CALLS)).thenCallRealMethod();
when(mBackend.getContactsSummary(NotificationManager.Policy.PRIORITY_CATEGORY_CALLS))
.thenCallRealMethod();
diff --git a/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityConversationsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityConversationsPreferenceControllerTest.java
new file mode 100644
index 0000000..1583b91
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityConversationsPreferenceControllerTest.java
@@ -0,0 +1,191 @@
+/*
+ * Copyright (C) 2020 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.zen;
+
+import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_ANYONE;
+import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_IMPORTANT;
+import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_NONE;
+import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_CONVERSATIONS;
+import static android.provider.Settings.Global.ZEN_MODE;
+import static android.provider.Settings.Global.ZEN_MODE_ALARMS;
+import static android.provider.Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
+import static android.provider.Settings.Global.ZEN_MODE_NO_INTERRUPTIONS;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.NotificationManager;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.preference.ListPreference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+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.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowApplication;
+import org.robolectric.util.ReflectionHelpers;
+
+@RunWith(RobolectricTestRunner.class)
+public class ZenModePriorityConversationsPreferenceControllerTest {
+
+ private ZenModePriorityConversationsPreferenceController mController;
+
+ @Mock
+ private ZenModeBackend mBackend;
+ @Mock
+ private NotificationManager mNotificationManager;
+ @Mock
+ private ListPreference mockPref;
+ @Mock
+ private NotificationManager.Policy mPolicy;
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
+ private ContentResolver mContentResolver;
+ private Context mContext;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ ShadowApplication shadowApplication = ShadowApplication.getInstance();
+ shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
+
+ mContext = RuntimeEnvironment.application;
+ mContentResolver = RuntimeEnvironment.application.getContentResolver();
+ when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
+
+ when(mBackend.getPriorityConversationSenders())
+ .thenReturn(CONVERSATION_SENDERS_IMPORTANT);
+ when(mBackend.getAlarmsTotalSilencePeopleSummary(PRIORITY_CATEGORY_CONVERSATIONS))
+ .thenCallRealMethod();
+ when(mBackend.getConversationSummary()).thenCallRealMethod();
+
+ mController = new ZenModePriorityConversationsPreferenceController(
+ mContext, mock(Lifecycle.class));
+ ReflectionHelpers.setField(mController, "mBackend", mBackend);
+
+ when(mPreferenceScreen.findPreference(mController.getPreferenceKey())).thenReturn(mockPref);
+ mController.displayPreference(mPreferenceScreen);
+ }
+
+ @Test
+ public void updateState_TotalSilence() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_NO_INTERRUPTIONS);
+
+ when(mBackend.isPriorityCategoryEnabled(PRIORITY_CATEGORY_CONVERSATIONS)).thenReturn(true);
+ final ListPreference mockPref = mock(ListPreference.class);
+ mController.updateState(mockPref);
+
+ verify(mockPref).setEnabled(false);
+ verify(mockPref).setSummary(R.string.zen_mode_from_no_conversations);
+ }
+
+ @Test
+ public void updateState_AlarmsOnly() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_ALARMS);
+
+ final ListPreference mockPref = mock(ListPreference.class);
+ mController.updateState(mockPref);
+
+ verify(mockPref).setEnabled(false);
+ verify(mockPref).setSummary(R.string.zen_mode_from_no_conversations);
+ }
+
+ @Test
+ public void updateState_Priority_important() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+ when(mBackend.isPriorityCategoryEnabled(PRIORITY_CATEGORY_CONVERSATIONS)).thenReturn(true);
+
+ mController.updateState(mockPref);
+
+ verify(mockPref).setEnabled(true);
+ verify(mockPref).setSummary(R.string.zen_mode_from_important_conversations);
+ verify(mockPref).setValue(String.valueOf(CONVERSATION_SENDERS_IMPORTANT));
+ }
+
+ @Test
+ public void updateState_Priority_all() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+ when(mBackend.getPriorityConversationSenders()).thenReturn(CONVERSATION_SENDERS_ANYONE);
+ when(mBackend.isPriorityCategoryEnabled(PRIORITY_CATEGORY_CONVERSATIONS)).thenReturn(true);
+
+
+ mController.updateState(mockPref);
+
+ verify(mockPref).setEnabled(true);
+ verify(mockPref).setSummary(R.string.zen_mode_from_all_conversations);
+ verify(mockPref).setValue(String.valueOf(CONVERSATION_SENDERS_ANYONE));
+ }
+
+ @Test
+ public void updateState_Priority_none() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+ when(mBackend.getPriorityConversationSenders()).thenReturn(CONVERSATION_SENDERS_NONE);
+ when(mBackend.isPriorityCategoryEnabled(PRIORITY_CATEGORY_CONVERSATIONS)).thenReturn(false);
+
+ mController.updateState(mockPref);
+
+ verify(mockPref).setEnabled(true);
+ verify(mockPref).setSummary(R.string.zen_mode_from_no_conversations);
+ verify(mockPref).setValue(String.valueOf(CONVERSATION_SENDERS_NONE));
+ }
+
+ @Test
+ public void onPreferenceChange_noneToImportant() {
+ // start with none
+
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+ when(mBackend.getPriorityConversationSenders()).thenReturn(CONVERSATION_SENDERS_NONE);
+ when(mBackend.isPriorityCategoryEnabled(PRIORITY_CATEGORY_CONVERSATIONS)).thenReturn(false);
+
+ mController.updateState(mockPref);
+ reset(mBackend);
+
+ mController.onPreferenceChange(mockPref, String.valueOf(CONVERSATION_SENDERS_IMPORTANT));
+
+ verify(mBackend).saveConversationSenders(CONVERSATION_SENDERS_IMPORTANT);
+ verify(mBackend).getPriorityConversationSenders();
+ }
+
+ @Test
+ public void onPreferenceChange_allToNone() {
+ // start with none
+
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+ when(mBackend.getPriorityConversationSenders()).thenReturn(CONVERSATION_SENDERS_ANYONE);
+ when(mBackend.isPriorityCategoryEnabled(PRIORITY_CATEGORY_CONVERSATIONS)).thenReturn(true);
+
+ mController.updateState(mockPref);
+ reset(mBackend);
+
+ mController.onPreferenceChange(mockPref, String.valueOf(CONVERSATION_SENDERS_NONE));
+
+ verify(mBackend).saveConversationSenders(CONVERSATION_SENDERS_NONE);
+ verify(mBackend).getPriorityConversationSenders();
+ }
+}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityMessagesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityMessagesPreferenceControllerTest.java
index 3ecd22a..7af2211 100644
--- a/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityMessagesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityMessagesPreferenceControllerTest.java
@@ -34,8 +34,6 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
-import com.android.settings.notification.zen.ZenModeBackend;
-import com.android.settings.notification.zen.ZenModePriorityMessagesPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.Before;
@@ -88,7 +86,7 @@
when(mBackend.getPriorityMessageSenders())
.thenReturn(NotificationManager.Policy.PRIORITY_SENDERS_STARRED);
- when(mBackend.getAlarmsTotalSilenceCallsMessagesSummary(
+ when(mBackend.getAlarmsTotalSilencePeopleSummary(
NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES)).thenCallRealMethod();
when(mBackend.getContactsSummary(NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES))
.thenCallRealMethod();
diff --git a/tests/robotests/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragmentTest.java b/tests/robotests/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragmentTest.java
index ae236bf..955b721 100644
--- a/tests/robotests/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragmentTest.java
@@ -26,6 +26,7 @@
import android.app.settings.SettingsEnums;
import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiManager;
import android.net.wifi.WifiNetworkSuggestion;
import android.os.Bundle;
import android.os.Parcelable;
@@ -59,7 +60,8 @@
private static final String FAKE_NEW_SAVED_WPA_SSID = "\"fake_new_wpa_ssid\"";
private static final String KEY_SSID = "key_ssid";
private static final String KEY_SECURITY = "key_security";
- private static final int SCANED_LEVEL = 4;
+ private static final int SCANED_LEVEL0 = 0;
+ private static final int SCANED_LEVEL4 = 4;
private AddAppNetworksFragment mAddAppNetworksFragment;
private List<WifiNetworkSuggestion> mFakedSpecifiedNetworksList;
@@ -76,6 +78,9 @@
@Mock
private WifiTracker mMockWifiTracker;
+ @Mock
+ private WifiManager mMockWifiManager;
+
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
@@ -86,10 +91,13 @@
WifiConfiguration.KeyMgmt.NONE, null);
mSavedWpaConfigurationEntry = generateRegularWifiConfiguration(FAKE_NEW_SAVED_WPA_SSID,
WifiConfiguration.KeyMgmt.WPA_PSK, "\"1234567890\"");
+ when(mMockWifiTracker.getManager()).thenReturn(mMockWifiManager);
+ when(mMockWifiManager.isWifiEnabled()).thenReturn(true);
+
mAddAppNetworksFragment.mWifiTracker = mMockWifiTracker;
WifiTrackerFactory.setTestingWifiTracker(mMockWifiTracker);
- setUpOneScannedNetworkWithScanedLevel();
+ setUpOneScannedNetworkWithScanedLevel4();
}
@Test
@@ -208,6 +216,7 @@
@Test
public void withOneSuggestion_whenScanResultChanged_uiListShouldHaveNewLevel() {
// Arrange
+ when(mAddAppNetworksFragment.mWifiTracker.getManager().isWifiEnabled()).thenReturn(true);
// Setup a fake saved network list and assign to fragment.
addOneSavedNetworkConfiguration(mSavedWpaConfigurationEntry);
// Setup one specified networks and its results and assign to fragment.
@@ -221,16 +230,36 @@
// Assert
assertThat(mAddAppNetworksFragment.mUiToRequestedList.get(0).mLevel).isEqualTo(
- SCANED_LEVEL);
+ SCANED_LEVEL4);
}
- private void setUpOneScannedNetworkWithScanedLevel() {
+ @Test
+ public void withOneSuggestion_whenScanResultChangedButWifiOff_uiListShouldHaveZeroLevel() {
+ // Arrange
+ when(mAddAppNetworksFragment.mWifiTracker.getManager().isWifiEnabled()).thenReturn(false);
+ // Setup a fake saved network list and assign to fragment.
+ addOneSavedNetworkConfiguration(mSavedWpaConfigurationEntry);
+ // Setup one specified networks and its results and assign to fragment.
+ addOneSpecifiedRegularNetworkSuggestion(mNewOpenSuggestionEntry);
+ mAddAppNetworksFragment.mAllSpecifiedNetworksList = mFakedSpecifiedNetworksList;
+ // Call filterSavedNetworks to generate necessary objects.
+ mAddAppNetworksFragment.filterSavedNetworks(mFakeSavedNetworksList);
+
+ // Act
+ mAddAppNetworksFragment.onAccessPointsChanged();
+
+ // Assert
+ assertThat(mAddAppNetworksFragment.mUiToRequestedList.get(0).mLevel).isEqualTo(
+ SCANED_LEVEL0);
+ }
+
+ private void setUpOneScannedNetworkWithScanedLevel4() {
final ArrayList list = new ArrayList<>();
list.add(mMockAccessPoint);
when(mMockWifiTracker.getAccessPoints()).thenReturn(list);
when(mMockAccessPoint.getSsidStr()).thenReturn(FAKE_NEW_OPEN_SSID);
when(mMockAccessPoint.matches(any(WifiConfiguration.class))).thenReturn(true);
- when(mMockAccessPoint.getLevel()).thenReturn(SCANED_LEVEL);
+ when(mMockAccessPoint.getLevel()).thenReturn(SCANED_LEVEL4);
}
private void addOneSavedNetworkConfiguration(@NonNull WifiConfiguration wifiConfiguration) {