diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 521d709e318..b8bd424bfc1 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -1378,6 +1378,26 @@
- @string/wifi_calling_mode_cellular_preferred_summary
+
+
+
+ - @string/enhanced_4g_lte_mode_title
+
+ - @string/enhanced_4g_lte_mode_title_advanced_calling
+
+ - @string/enhanced_4g_lte_mode_title_4g_calling
+
+
+
+
+
+ - @string/enhanced_4g_lte_mode_summary
+
+ - @string/enhanced_4g_lte_mode_summary
+
+ - @string/enhanced_4g_lte_mode_summary_4g_calling
+
+
- @color/bt_color_icon_1
diff --git a/res/values/colors.xml b/res/values/colors.xml
index c333edb5a55..ff040ee2df4 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -100,7 +100,7 @@
#5E97F6
#1f000000
- @*android:color/material_grey_50
+ @*android:color/material_grey_100
@*android:color/background_device_default_light
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9b23ca9a1b1..e51734c464b 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2620,8 +2620,6 @@
Tap sounds
Screen lock sound
-
- Vibrate on tap
Noise cancellation
@@ -5661,12 +5659,6 @@
Set a schedule
-
- Keep battery saver on
-
-
- Battery saver will stay on even after device is fully charged
-
Turn off when fully charged
@@ -6781,6 +6773,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -6921,9 +6931,15 @@
Access point names
- Enhanced 4G LTE Mode
+ VoLTE
+
+ Advanced Calling
+
+ 4G Calling
- Use LTE data to enhance voice and communications (Recommended)
+ Use LTE services to improve voice and other communications (recommended)
+
+ Use 4G services to improve voice and other communications (recommended)
Preferred network type
@@ -7118,6 +7134,24 @@
wifi, wi-fi, network connection, internet, wireless, data, wi fi
+
+ Wi\u2011Fi notification, wifi notification
+
+ Auto brightness
+
+ Stop vibration, tap, keyboard
+
+ Use 24-hour format
+
+ Download
+
+ Open with
+
+ Applications
+
+ timezone
+
+ Chat head
wifi, wi-fi, toggle, control
text message, texting, messages, messaging, default
cellular, mobile, cell carrier, wireless, data, 4g,3g, 2g, lte
@@ -7128,7 +7162,8 @@
dim screen, night, tint, night shift, brightness, screen color, colour, color
background, personalize, customize display
text size
- project, cast
+
+ project, cast, Screen mirroring, Screen sharing, mirroring, share screen, screen casting
space, disk, hard drive, device usage
power usage, charge
spelling, dictionary, spellcheck, auto-correct
@@ -7181,7 +7216,7 @@
Ambient display, Lock screen display
- lock screen notification
+ lock screen notification, notifications
face
@@ -7368,6 +7403,12 @@
Power on sounds
+
+ Live Caption
+
+
+ Automatically caption media
+
Never
@@ -7387,7 +7428,7 @@
Exceptions
- Duration
+ Default duration
Allow sounds and vibrations from
@@ -10534,8 +10575,6 @@
No SIM card
-
- Advanced Calling
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index da103c57bf4..1efe2c255f0 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -132,6 +132,12 @@
android:key="audio_and_captions_category"
android:title="@string/audio_and_captions_category_title">
+
+
+ settings:controller="com.android.settings.applications.AllAppsInfoPreferenceController"
+ settings:keywords="@string/keywords_applications_settings"/>
+ android:title="@string/app_default_dashboard_title"
+ settings:keywords="@string/keywords_app_default">
diff --git a/res/xml/dark_ui_settings.xml b/res/xml/dark_ui_settings.xml
new file mode 100644
index 00000000000..1f11ebae94d
--- /dev/null
+++ b/res/xml/dark_ui_settings.xml
@@ -0,0 +1,24 @@
+
+
+
+
diff --git a/res/xml/date_time_prefs.xml b/res/xml/date_time_prefs.xml
index f98ce3d1099..2d5b24d387e 100644
--- a/res/xml/date_time_prefs.xml
+++ b/res/xml/date_time_prefs.xml
@@ -56,12 +56,14 @@
android:title="@string/date_time_set_timezone_title"
android:summary="@string/summary_placeholder"
android:fragment="com.android.settings.datetime.timezone.TimeZoneSettings"
- settings:userRestriction="no_config_date_time" />
+ settings:userRestriction="no_config_date_time"
+ settings:keywords="@string/keywords_time_zone"/>
+ android:title="@string/time_format_category_title"
+ settings:keywords="@string/keywords_time_format">
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index 91fe65647ed..940e6de81c6 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -44,7 +44,8 @@
android:title="@string/auto_brightness_title"
android:summary="@string/summary_placeholder"
android:fragment="com.android.settings.display.AutoBrightnessSettings"
- settings:controller="com.android.settings.display.AutoBrightnessPreferenceController" />
+ settings:controller="com.android.settings.display.AutoBrightnessPreferenceController"
+ settings:keywords="@string/keywords_auto_brightness"/>
-
+ settings:searchable="false"
+ settings:controller="com.android.settings.display.DarkUIPreferenceController"/>
+ android:order="-100"
+ settings:keywords="@string/sound_settings"/>
+ android:summary="@string/vibrate_on_touch_summary"
+ settings:keywords="@string/keywords_vibrate_on_touch"/>
+ android:order="7"
+ settings:keywords="@string/keywords_storage_files"/>
+ android:summary="@string/wifi_notify_open_networks_summary"
+ settings:keywords="@string/keywords_wifi_notify_open_networks"/>
+ android:title="@string/wifi_display_settings_title"
+ settings:keywords="@string/keywords_display_cast_screen">
diff --git a/res/xml/wifi_network_details_fragment.xml b/res/xml/wifi_network_details_fragment.xml
index 8979efc4b97..782a7cffed4 100644
--- a/res/xml/wifi_network_details_fragment.xml
+++ b/res/xml/wifi_network_details_fragment.xml
@@ -71,6 +71,15 @@
android:entryValues="@array/wifi_privacy_values"/>
+
+
+
+
+
resolved =
+ mPackageManager.queryIntentActivities(LIVE_CAPTION_INTENT, 0 /* flags */);
+ return resolved != null && !resolved.isEmpty()
+ ? AVAILABLE
+ : UNSUPPORTED_ON_DEVICE;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+ preference.setIntent(LIVE_CAPTION_INTENT);
+ }
+}
\ No newline at end of file
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index 98399340522..4faa158ddc1 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -625,12 +625,32 @@ public class ManageApplications extends InstrumentedFragment
@StringRes
int getHelpResource() {
- if (mListType == LIST_TYPE_MAIN) {
- return R.string.help_uri_apps;
- } else if (mListType == LIST_TYPE_USAGE_ACCESS) {
- return R.string.help_url_usage_access;
- } else {
- return R.string.help_uri_notifications;
+ switch (mListType) {
+ case LIST_TYPE_NOTIFICATION:
+ return R.string.help_uri_notifications;
+ case LIST_TYPE_USAGE_ACCESS:
+ return R.string.help_url_usage_access;
+ case LIST_TYPE_STORAGE:
+ return R.string.help_uri_apps_storage;
+ case LIST_TYPE_HIGH_POWER:
+ return R.string.help_uri_apps_high_power;
+ case LIST_TYPE_OVERLAY:
+ return R.string.help_uri_apps_overlay;
+ case LIST_TYPE_WRITE_SETTINGS:
+ return R.string.help_uri_apps_write_settings;
+ case LIST_TYPE_MANAGE_SOURCES:
+ return R.string.help_uri_apps_manage_sources;
+ case LIST_TYPE_GAMES:
+ return R.string.help_uri_apps_overlay;
+ case LIST_TYPE_MOVIES:
+ return R.string.help_uri_apps_movies;
+ case LIST_TYPE_PHOTOGRAPHY:
+ return R.string.help_uri_apps_photography;
+ case LIST_TYPE_WIFI_ACCESS:
+ return R.string.help_uri_apps_wifi_access;
+ default:
+ case LIST_TYPE_MAIN:
+ return R.string.help_uri_apps;
}
}
diff --git a/src/com/android/settings/core/HideNonSystemOverlayMixin.java b/src/com/android/settings/core/HideNonSystemOverlayMixin.java
index 59cef3bea17..4b8975db334 100644
--- a/src/com/android/settings/core/HideNonSystemOverlayMixin.java
+++ b/src/com/android/settings/core/HideNonSystemOverlayMixin.java
@@ -22,9 +22,11 @@ import static androidx.lifecycle.Lifecycle.Event.ON_START;
import static androidx.lifecycle.Lifecycle.Event.ON_STOP;
import android.app.Activity;
+import android.os.Build;
import android.view.Window;
import android.view.WindowManager;
+import androidx.annotation.VisibleForTesting;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;
@@ -41,9 +43,14 @@ public class HideNonSystemOverlayMixin implements LifecycleObserver {
mActivity = activity;
}
+ @VisibleForTesting
+ boolean isEnabled() {
+ return !Build.IS_DEBUGGABLE;
+ }
+
@OnLifecycleEvent(ON_START)
public void onStart() {
- if (mActivity == null) {
+ if (mActivity == null || !isEnabled()) {
return;
}
mActivity.getWindow().addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
@@ -53,7 +60,7 @@ public class HideNonSystemOverlayMixin implements LifecycleObserver {
@OnLifecycleEvent(ON_STOP)
public void onStop() {
- if (mActivity == null) {
+ if (mActivity == null || !isEnabled()) {
return;
}
final Window window = mActivity.getWindow();
diff --git a/src/com/android/settings/development/featureflags/FeatureFlagsPreferenceController.java b/src/com/android/settings/development/featureflags/FeatureFlagsPreferenceController.java
index 638c7c1f089..94636e9c712 100644
--- a/src/com/android/settings/development/featureflags/FeatureFlagsPreferenceController.java
+++ b/src/com/android/settings/development/featureflags/FeatureFlagsPreferenceController.java
@@ -17,6 +17,7 @@
package com.android.settings.development.featureflags;
import android.content.Context;
+import android.os.Build;
import android.util.FeatureFlagUtils;
import androidx.preference.PreferenceGroup;
@@ -39,7 +40,7 @@ public class FeatureFlagsPreferenceController extends BasePreferenceController
@Override
public int getAvailabilityStatus() {
- return AVAILABLE;
+ return Build.IS_DEBUGGABLE ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
@Override
diff --git a/src/com/android/settings/deviceinfo/firmwareversion/MainlineModuleVersionPreferenceController.java b/src/com/android/settings/deviceinfo/firmwareversion/MainlineModuleVersionPreferenceController.java
index e2f4fae14fc..174cb8cd050 100644
--- a/src/com/android/settings/deviceinfo/firmwareversion/MainlineModuleVersionPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/firmwareversion/MainlineModuleVersionPreferenceController.java
@@ -17,11 +17,16 @@
package com.android.settings.deviceinfo.firmwareversion;
import android.content.Context;
+import android.content.Intent;
import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.text.TextUtils;
import android.util.FeatureFlagUtils;
import android.util.Log;
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.FeatureFlags;
@@ -29,6 +34,9 @@ public class MainlineModuleVersionPreferenceController extends BasePreferenceCon
private static final String TAG = "MainlineModuleControl";
+ @VisibleForTesting
+ static final Intent MODULE_UPDATE_INTENT =
+ new Intent("android.settings.MODULE_UPDATE_SETTINGS");
private final PackageManager mPackageManager;
private String mModuleVersion;
@@ -65,6 +73,20 @@ public class MainlineModuleVersionPreferenceController extends BasePreferenceCon
}
}
+ @Override
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+
+ // Confirm MODULE_UPDATE_INTENT is handleable, and set it to Preference.
+ final ResolveInfo resolved =
+ mPackageManager.resolveActivity(MODULE_UPDATE_INTENT, 0 /* flags */);
+ if (resolved != null) {
+ preference.setIntent(MODULE_UPDATE_INTENT);
+ } else {
+ preference.setIntent(null);
+ }
+ }
+
@Override
public CharSequence getSummary() {
return mModuleVersion;
diff --git a/src/com/android/settings/display/DarkUIPreferenceController.java b/src/com/android/settings/display/DarkUIPreferenceController.java
index 21af60321eb..7d8fd56ae13 100644
--- a/src/com/android/settings/display/DarkUIPreferenceController.java
+++ b/src/com/android/settings/display/DarkUIPreferenceController.java
@@ -27,8 +27,7 @@ import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
-public class DarkUIPreferenceController extends BasePreferenceController
- implements Preference.OnPreferenceChangeListener {
+public class DarkUIPreferenceController extends BasePreferenceController {
private UiModeManager mUiModeManager;
@@ -47,59 +46,9 @@ public class DarkUIPreferenceController extends BasePreferenceController
return AVAILABLE;
}
- @Override
- public void displayPreference(PreferenceScreen screen) {
- super.displayPreference(screen);
- int value = mUiModeManager.getNightMode();
- ListPreference preference = screen.findPreference(getPreferenceKey());
- preference.setValue(modeToString(value));
- }
-
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- mUiModeManager.setNightMode(modeToInt((String) newValue));
- refreshSummary(preference);
- return true;
- }
-
@Override
public CharSequence getSummary() {
- return modeToDescription(mUiModeManager.getNightMode());
- }
-
- private String modeToDescription(int mode) {
- String[] values = mContext.getResources().getStringArray(R.array.dark_ui_mode_entries);
- switch (mode) {
- case UiModeManager.MODE_NIGHT_YES:
- return values[0];
- case UiModeManager.MODE_NIGHT_NO:
- case UiModeManager.MODE_NIGHT_AUTO:
- default:
- return values[1];
-
- }
- }
-
- private String modeToString(int mode) {
- switch (mode) {
- case UiModeManager.MODE_NIGHT_YES:
- return "yes";
- case UiModeManager.MODE_NIGHT_NO:
- case UiModeManager.MODE_NIGHT_AUTO:
- default:
- return "no";
-
- }
- }
-
- private int modeToInt(String mode) {
- switch (mode) {
- case "yes":
- return UiModeManager.MODE_NIGHT_YES;
- case "no":
- case "auto":
- default:
- return UiModeManager.MODE_NIGHT_NO;
- }
+ return DarkUISettingsRadioButtonsController.modeToDescription(
+ mContext, mUiModeManager.getNightMode());
}
}
diff --git a/src/com/android/settings/display/DarkUISettings.java b/src/com/android/settings/display/DarkUISettings.java
new file mode 100644
index 00000000000..50fd3868c93
--- /dev/null
+++ b/src/com/android/settings/display/DarkUISettings.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.display;
+
+import android.app.UiModeManager;
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.provider.SearchIndexableResource;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+import com.android.settings.R;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
+import com.android.settings.widget.RadioButtonPickerFragment;
+import com.android.settingslib.search.SearchIndexable;
+import com.android.settingslib.widget.CandidateInfo;
+import com.android.settingslib.widget.FooterPreference;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * The screen for selecting the dark theme preference for this device. Automatically updates
+ * the associated footer view with any needed information.
+ */
+@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
+public class DarkUISettings extends RadioButtonPickerFragment implements Indexable {
+
+ private DarkUISettingsRadioButtonsController mController;
+ private Preference mFooter;
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.dark_ui_settings;
+ }
+
+ @Override
+ public void onAttach(Context context) {
+ super.onAttach(context);
+ // TODO(b/128686189): add illustration once it is ready
+ setIllustration(0, 0);
+ mFooter = new FooterPreference(context);
+ mFooter.setIcon(android.R.color.transparent);
+ mController = new DarkUISettingsRadioButtonsController(context, mFooter);
+ }
+
+ @Override
+ protected List extends CandidateInfo> getCandidates() {
+ final Context context = getContext();
+ final List candidates = new ArrayList<>();
+ candidates.add(new DarkUISettingsCandidateInfo(
+ DarkUISettingsRadioButtonsController.modeToDescription(
+ context, UiModeManager.MODE_NIGHT_YES),
+ /* summary */ null,
+ DarkUISettingsRadioButtonsController.KEY_DARK,
+ /* enabled */ true));
+ candidates.add(new DarkUISettingsCandidateInfo(
+ DarkUISettingsRadioButtonsController.modeToDescription(
+ context, UiModeManager.MODE_NIGHT_NO),
+ /* summary */ null,
+ DarkUISettingsRadioButtonsController.KEY_LIGHT,
+ /* enabled */ true));
+ return candidates;
+ }
+
+ @Override
+ protected void addStaticPreferences(PreferenceScreen screen) {
+ screen.addPreference(mFooter);
+ }
+
+ @Override
+ protected String getDefaultKey() {
+ return mController.getDefaultKey();
+ }
+
+ @Override
+ protected boolean setDefaultKey(String key) {
+ return mController.setDefaultKey(key);
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.DARK_UI_SETTINGS;
+ }
+
+ static class DarkUISettingsCandidateInfo extends CandidateInfo {
+
+ private final CharSequence mLabel;
+ private final CharSequence mSummary;
+ private final String mKey;
+
+ DarkUISettingsCandidateInfo(CharSequence label, CharSequence summary, String key,
+ boolean enabled) {
+ super(enabled);
+ mLabel = label;
+ mKey = key;
+ mSummary = summary;
+ }
+
+ @Override
+ public CharSequence loadLabel() {
+ return mLabel;
+ }
+
+ @Override
+ public Drawable loadIcon() {
+ return null;
+ }
+
+ @Override
+ public String getKey() {
+ return mKey;
+ }
+
+ public CharSequence getSummary() {
+ return mSummary;
+ }
+ }
+
+ public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider() {
+ @Override
+ public List getXmlResourcesToIndex(
+ Context context, boolean enabled) {
+ final SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.dark_ui_settings;
+ return Arrays.asList(sir);
+ }
+ };
+}
diff --git a/src/com/android/settings/display/DarkUISettingsRadioButtonsController.java b/src/com/android/settings/display/DarkUISettingsRadioButtonsController.java
new file mode 100644
index 00000000000..0fca306338c
--- /dev/null
+++ b/src/com/android/settings/display/DarkUISettingsRadioButtonsController.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.display;
+
+import android.app.UiModeManager;
+import android.content.Context;
+import androidx.preference.Preference;
+import com.android.settings.R;
+import androidx.annotation.VisibleForTesting;
+
+public class DarkUISettingsRadioButtonsController {
+
+ public static final String KEY_DARK = "key_dark_ui_settings_dark";
+ public static final String KEY_LIGHT = "key_dark_ui_settings_light";
+
+ @VisibleForTesting
+ UiModeManager mManager;
+
+ private Preference mFooter;
+
+ public DarkUISettingsRadioButtonsController(Context context, Preference footer) {
+ mManager = context.getSystemService(UiModeManager.class);
+ mFooter = footer;
+ }
+
+ public String getDefaultKey() {
+ final int mode = mManager.getNightMode();
+ updateFooter();
+ return mode == UiModeManager.MODE_NIGHT_YES ? KEY_DARK : KEY_LIGHT;
+ }
+
+ public boolean setDefaultKey(String key) {
+ switch(key) {
+ case KEY_DARK:
+ mManager.setNightMode(UiModeManager.MODE_NIGHT_YES);
+ break;
+ case KEY_LIGHT:
+ mManager.setNightMode(UiModeManager.MODE_NIGHT_NO);
+ break;
+ default:
+ throw new IllegalStateException(
+ "Not a valid key for " + this.getClass().getSimpleName() + ": " + key);
+ }
+ updateFooter();
+ return true;
+ }
+
+ public void updateFooter() {
+ final int mode = mManager.getNightMode();
+ switch (mode) {
+ case UiModeManager.MODE_NIGHT_YES:
+ mFooter.setSummary(R.string.dark_ui_settings_dark_summary);
+ break;
+ case UiModeManager.MODE_NIGHT_NO:
+ case UiModeManager.MODE_NIGHT_AUTO:
+ default:
+ mFooter.setSummary(R.string.dark_ui_settings_light_summary);
+ }
+ }
+
+ public static String modeToDescription(Context context, int mode) {
+ final String[] values = context.getResources().getStringArray(R.array.dark_ui_mode_entries);
+ switch (mode) {
+ case UiModeManager.MODE_NIGHT_YES:
+ return values[0];
+ case UiModeManager.MODE_NIGHT_NO:
+ case UiModeManager.MODE_NIGHT_AUTO:
+ default:
+ return values[1];
+ }
+ }
+}
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java
index 7a1f7f5d6a1..7d4bdac074f 100644
--- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java
@@ -1,37 +1,58 @@
package com.android.settings.fuelgauge.batterysaver;
import android.content.Context;
+import android.icu.text.NumberFormat;
import android.provider.Settings;
+import android.provider.Settings.Global;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
-import com.android.settings.core.BasePreferenceController;
+import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.core.TogglePreferenceController;
-public class BatterySaverStickyPreferenceController extends BasePreferenceController implements
+public class BatterySaverStickyPreferenceController extends TogglePreferenceController implements
PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
- public static final String LOW_POWER_STICKY_AUTO_DISABLE_ENABLED =
- "low_power_sticky_auto_disable_enabled";
+ private Context mContext;
public BatterySaverStickyPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
+ mContext = context;
+ }
+
+ @Override
+ public boolean isChecked() {
+ return Settings.Global.getInt(mContext.getContentResolver(),
+ Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED, 1) == 1;
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED,
+ isChecked ? 1 : 0);
+ return true;
+ }
+
+ @Override
+ protected void refreshSummary(Preference preference) {
+ super.refreshSummary(preference);
+ final double stickyShutoffLevel = Settings.Global.getInt(
+ mContext.getContentResolver(), Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL, 90);
+ final String percentage = NumberFormat
+ .getPercentInstance()
+ .format(stickyShutoffLevel / 100.0);
+ preference.setSummary(
+ mContext.getString(R.string.battery_saver_sticky_description_new, percentage));
}
@Override
public void updateState(Preference preference) {
int setting = Settings.Global.getInt(mContext.getContentResolver(),
- LOW_POWER_STICKY_AUTO_DISABLE_ENABLED, 1);
+ Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED, 1);
- ((SwitchPreference) preference).setChecked(setting == 0);
- }
-
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- boolean keepActive = (Boolean) newValue;
- Settings.Global.putInt(mContext.getContentResolver(),
- LOW_POWER_STICKY_AUTO_DISABLE_ENABLED,
- keepActive ? 0 : 1);
- return true;
+ ((SwitchPreference) preference).setChecked(setting == 1);
+ refreshSummary(preference);
}
@Override
diff --git a/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionController.java b/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionController.java
index 664707def69..341e0612568 100644
--- a/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionController.java
+++ b/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionController.java
@@ -16,9 +16,12 @@
package com.android.settings.homepage.contextualcards.conditional;
+import android.Manifest;
import android.app.settings.SettingsEnums;
+import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
import android.hardware.display.ColorDisplayManager;
import android.util.Log;
@@ -32,10 +35,15 @@ public class GrayscaleConditionController implements ConditionalCardController {
static final int ID = Objects.hash("GrayscaleConditionController");
private static final String TAG = "GrayscaleCondition";
+ private static final String ACTION_GRAYSCALE_CHANGED =
+ "android.settings.action.GRAYSCALE_CHANGED";
+ private static final IntentFilter GRAYSCALE_CHANGED_FILTER = new IntentFilter(
+ ACTION_GRAYSCALE_CHANGED);
private final Context mAppContext;
private final ConditionManager mConditionManager;
private final ColorDisplayManager mColorDisplayManager;
+ private final Receiver mReceiver;
private Intent mIntent;
@@ -43,6 +51,7 @@ public class GrayscaleConditionController implements ConditionalCardController {
mAppContext = appContext;
mConditionManager = conditionManager;
mColorDisplayManager = mAppContext.getSystemService(ColorDisplayManager.class);
+ mReceiver = new Receiver();
}
@Override
@@ -72,6 +81,7 @@ public class GrayscaleConditionController implements ConditionalCardController {
public void onActionClick() {
// Turn off grayscale
mColorDisplayManager.setSaturationLevel(100 /* staturationLevel */);
+ sendBroadcast();
mConditionManager.onConditionChanged();
}
@@ -93,11 +103,27 @@ public class GrayscaleConditionController implements ConditionalCardController {
@Override
public void startMonitoringStateChange() {
-
+ mAppContext.registerReceiver(mReceiver, GRAYSCALE_CHANGED_FILTER,
+ Manifest.permission.CONTROL_DISPLAY_COLOR_TRANSFORMS, null /* scheduler */);
}
@Override
public void stopMonitoringStateChange() {
+ mAppContext.unregisterReceiver(mReceiver);
+ }
+ private void sendBroadcast() {
+ final Intent intent = new Intent();
+ intent.setAction(ACTION_GRAYSCALE_CHANGED);
+ mAppContext.sendBroadcast(intent, Manifest.permission.CONTROL_DISPLAY_COLOR_TRANSFORMS);
+ }
+
+ public class Receiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (ACTION_GRAYSCALE_CHANGED.equals(intent.getAction())) {
+ mConditionManager.onConditionChanged();
+ }
+ }
}
}
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java b/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
index b9170a92f2f..006734f2f8d 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
@@ -98,8 +98,6 @@ public class SliceContextualCardRenderer implements ContextualCardRenderer, Life
@Override
public void bindView(RecyclerView.ViewHolder holder, ContextualCard card) {
final Uri uri = card.getSliceUri();
- //TODO(b/120629936): Take this out once blank card issue is fixed.
- Log.d(TAG, "bindView - uri = " + uri);
if (!ContentResolver.SCHEME_CONTENT.equals(uri.getScheme())) {
Log.w(TAG, "Invalid uri, skipping slice: " + uri);
@@ -121,10 +119,8 @@ public class SliceContextualCardRenderer implements ContextualCardRenderer, Life
mContext.getContentResolver().notifyChange(CardContentProvider.REFRESH_CARD_URI,
null);
return;
- } else {
- //TODO(b/120629936): Take this out once blank card issue is fixed.
- Log.d(TAG, "Slice callback - uri = " + slice.getUri());
}
+
switch (holder.getItemViewType()) {
case VIEW_TYPE_DEFERRED_SETUP:
mDeferredSetupCardHelper.bindView(holder, card, slice);
diff --git a/src/com/android/settings/network/telephony/Enhanced4gLtePreferenceController.java b/src/com/android/settings/network/telephony/Enhanced4gLtePreferenceController.java
index c510294c5b6..161c2187a28 100644
--- a/src/com/android/settings/network/telephony/Enhanced4gLtePreferenceController.java
+++ b/src/com/android/settings/network/telephony/Enhanced4gLtePreferenceController.java
@@ -17,6 +17,7 @@
package com.android.settings.network.telephony;
import android.content.Context;
+import android.content.res.Resources;
import android.os.Looper;
import android.os.PersistableBundle;
import android.telephony.CarrierConfigManager;
@@ -52,12 +53,18 @@ public class Enhanced4gLtePreferenceController extends TelephonyTogglePreference
ImsManager mImsManager;
private PhoneCallStateListener mPhoneStateListener;
private final List m4gLteListeners;
+ private final CharSequence[] mVariantTitles;
+ private final CharSequence[] mVariantSumaries;
public Enhanced4gLtePreferenceController(Context context, String key) {
super(context, key);
mCarrierConfigManager = context.getSystemService(CarrierConfigManager.class);
m4gLteListeners = new ArrayList<>();
mPhoneStateListener = new PhoneCallStateListener(Looper.getMainLooper());
+ mVariantTitles = context.getResources()
+ .getTextArray(R.array.enhanced_4g_lte_mode_title_variant);
+ mVariantSumaries = context.getResources()
+ .getTextArray(R.array.enhanced_4g_lte_mode_sumary_variant);
}
@Override
@@ -94,12 +101,20 @@ public class Enhanced4gLtePreferenceController extends TelephonyTogglePreference
public void updateState(Preference preference) {
super.updateState(preference);
final SwitchPreference switchPreference = (SwitchPreference) preference;
- final boolean useVariant4glteTitle = mCarrierConfig.getInt(
- CarrierConfigManager.KEY_ENHANCED_4G_LTE_TITLE_VARIANT_INT) != 0;
- int enhanced4glteModeTitleId = useVariant4glteTitle ?
- R.string.enhanced_4g_lte_mode_title_variant :
- R.string.enhanced_4g_lte_mode_title;
- switchPreference.setTitle(enhanced4glteModeTitleId);
+ final int variant4glteTitleIndex = mCarrierConfig.getInt(
+ CarrierConfigManager.KEY_ENHANCED_4G_LTE_TITLE_VARIANT_INT);
+
+ // Default index 0 indicates the default title/sumary string
+ CharSequence enhanced4glteModeTitle = mVariantTitles[0];
+ CharSequence enhanced4glteModeSummary = mVariantSumaries[0];
+ if (variant4glteTitleIndex >= 0 && variant4glteTitleIndex < mVariantTitles.length) {
+ enhanced4glteModeTitle = mVariantTitles[variant4glteTitleIndex];
+ }
+ if (variant4glteTitleIndex >= 0 && variant4glteTitleIndex < mVariantSumaries.length) {
+ enhanced4glteModeSummary = mVariantSumaries[variant4glteTitleIndex];
+ }
+ switchPreference.setTitle(enhanced4glteModeTitle);
+ switchPreference.setSummary(enhanced4glteModeSummary);
switchPreference.setEnabled(is4gLtePrefEnabled());
switchPreference.setChecked(mImsManager.isEnhanced4gLteModeSettingEnabledByUser()
&& mImsManager.isNonTtyOrTtyOnVolteEnabled());
diff --git a/src/com/android/settings/sim/SimSelectNotification.java b/src/com/android/settings/sim/SimSelectNotification.java
index 891d1719e66..4f3b9bc3f79 100644
--- a/src/com/android/settings/sim/SimSelectNotification.java
+++ b/src/com/android/settings/sim/SimSelectNotification.java
@@ -16,11 +16,11 @@
package com.android.settings.sim;
-import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_ID;
-import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_FOR_ALL_TYPES;
import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE;
+import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_ALL;
import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DATA;
import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_NONE;
+import static android.telephony.TelephonyManager.EXTRA_SUBSCRIPTION_ID;
import android.app.NotificationChannel;
import android.app.NotificationManager;
@@ -52,8 +52,8 @@ public class SimSelectNotification extends BroadcastReceiver {
int dialogType = intent.getIntExtra(EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE,
EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_NONE);
- if (dialogType == EXTRA_DEFAULT_SUBSCRIPTION_SELECT_FOR_ALL_TYPES) {
- int subId = intent.getIntExtra(EXTRA_DEFAULT_SUBSCRIPTION_ID,
+ if (dialogType == EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_ALL) {
+ int subId = intent.getIntExtra(EXTRA_SUBSCRIPTION_ID,
SubscriptionManager.DEFAULT_SUBSCRIPTION_ID);
int slotIndex = SubscriptionManager.getSlotIndex(subId);
// If there is only one subscription, ask if user wants to use if for everything
diff --git a/src/com/android/settings/widget/RadioButtonPickerFragment.java b/src/com/android/settings/widget/RadioButtonPickerFragment.java
index 591cd218f84..8861c94a715 100644
--- a/src/com/android/settings/widget/RadioButtonPickerFragment.java
+++ b/src/com/android/settings/widget/RadioButtonPickerFragment.java
@@ -58,6 +58,9 @@ public abstract class RadioButtonPickerFragment extends InstrumentedPreferenceFr
protected UserManager mUserManager;
protected int mUserId;
+ private int mIllustrationId;
+ private int mIllustrationPreviewId;
+ private VideoPreference mVideoPreference;
@Override
public void onAttach(Context context) {
@@ -164,6 +167,9 @@ public abstract class RadioButtonPickerFragment extends InstrumentedPreferenceFr
final String systemDefaultKey = getSystemDefaultKey();
final PreferenceScreen screen = getPreferenceScreen();
screen.removeAll();
+ if (mIllustrationId != 0) {
+ addIllustration(screen);
+ }
if (!mAppendStaticPreferences) {
addStaticPreferences(screen);
}
@@ -241,6 +247,23 @@ public abstract class RadioButtonPickerFragment extends InstrumentedPreferenceFr
}
}
+ /**
+ * Allows you to set an illustration at the top of this screen. Set the illustration id to 0
+ * if you want to remove the illustration.
+ * @param illustrationId The res id for the raw of the illustration.
+ * @param previewId The res id for the drawable of the illustration
+ */
+ protected void setIllustration(int illustrationId, int previewId) {
+ mIllustrationId = illustrationId;
+ mIllustrationPreviewId = previewId;
+ }
+
+ private void addIllustration(PreferenceScreen screen) {
+ mVideoPreference = new VideoPreference(getContext());
+ mVideoPreference.setVideo(mIllustrationId, mIllustrationPreviewId);
+ screen.addPreference(mVideoPreference);
+ }
+
protected abstract List extends CandidateInfo> getCandidates();
protected abstract String getDefaultKey();
diff --git a/src/com/android/settings/widget/VideoPreference.java b/src/com/android/settings/widget/VideoPreference.java
index fd215d80e47..2d886732fa0 100644
--- a/src/com/android/settings/widget/VideoPreference.java
+++ b/src/com/android/settings/widget/VideoPreference.java
@@ -55,22 +55,41 @@ public class VideoPreference extends Preference {
private int mPreviewResource;
private boolean mViewVisible;
private Surface mSurface;
+ private int mAnimationId;
+
+ public VideoPreference(Context context) {
+ super(context);
+ mContext = context;
+ initialize(context, null);
+ }
public VideoPreference(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
+ initialize(context, attrs);
+ }
+
+ private void initialize(Context context, AttributeSet attrs) {
TypedArray attributes = context.getTheme().obtainStyledAttributes(
attrs,
- com.android.settings.R.styleable.VideoPreference,
+ R.styleable.VideoPreference,
0, 0);
try {
- int animation = attributes.getResourceId(R.styleable.VideoPreference_animation, 0);
+ // if these are already set that means they were set dynamically and don't need
+ // to be loaded from xml
+ mAnimationId = mAnimationId == 0
+ ? attributes.getResourceId(R.styleable.VideoPreference_animation, 0)
+ : mAnimationId;
mVideoPath = new Uri.Builder().scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
.authority(context.getPackageName())
- .appendPath(String.valueOf(animation))
+ .appendPath(String.valueOf(mAnimationId))
.build();
- mPreviewResource = attributes.getResourceId(
- R.styleable.VideoPreference_preview, 0);
+ mPreviewResource = mPreviewResource == 0
+ ? attributes.getResourceId(R.styleable.VideoPreference_preview, 0)
+ : mPreviewResource;
+ if (mPreviewResource == 0 && mAnimationId == 0) {
+ return;
+ }
initMediaPlayer();
if (mMediaPlayer != null && mMediaPlayer.getDuration() > 0) {
setVisible(true);
@@ -103,20 +122,9 @@ public class VideoPreference extends Preference {
imageView.setImageResource(mPreviewResource);
layout.setAspectRatio(mAspectRadio);
+ updateViewStates(imageView, playButton);
- video.setOnClickListener(v -> {
- if (mMediaPlayer != null) {
- if (mMediaPlayer.isPlaying()) {
- mMediaPlayer.pause();
- playButton.setVisibility(View.VISIBLE);
- mVideoPaused = true;
- } else {
- mMediaPlayer.start();
- playButton.setVisibility(View.GONE);
- mVideoPaused = false;
- }
- }
- });
+ video.setOnClickListener(v -> updateViewStates(imageView, playButton));
video.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() {
@Override
@@ -161,6 +169,23 @@ public class VideoPreference extends Preference {
});
}
+ @VisibleForTesting
+ void updateViewStates(ImageView imageView, ImageView playButton) {
+ if (mMediaPlayer != null) {
+ if (mMediaPlayer.isPlaying()) {
+ mMediaPlayer.pause();
+ playButton.setVisibility(View.VISIBLE);
+ imageView.setVisibility(View.VISIBLE);
+ mVideoPaused = true;
+ } else {
+ imageView.setVisibility(View.GONE);
+ playButton.setVisibility(View.GONE);
+ mMediaPlayer.start();
+ mVideoPaused = false;
+ }
+ }
+ }
+
@Override
public void onDetached() {
releaseMediaPlayer();
@@ -178,6 +203,20 @@ public class VideoPreference extends Preference {
releaseMediaPlayer();
}
+ /**
+ * Sets the video for this preference. If a previous video was set this one will override it
+ * and properly release any resources and re-initialize the preference to play the new video.
+ *
+ * @param videoId The raw res id of the video
+ * @param previewId The drawable res id of the preview image to use if the video fails to load.
+ */
+ public void setVideo(int videoId, int previewId) {
+ mAnimationId = videoId;
+ mPreviewResource = previewId;
+ releaseMediaPlayer();
+ initialize(mContext, null);
+ }
+
private void initMediaPlayer() {
if (mMediaPlayer == null) {
mMediaPlayer = MediaPlayer.create(mContext, mVideoPath);
diff --git a/src/com/android/settings/wifi/AddWifiNetworkPreference.java b/src/com/android/settings/wifi/AddWifiNetworkPreference.java
index cd2e4a8182a..e49f2ab2db2 100644
--- a/src/com/android/settings/wifi/AddWifiNetworkPreference.java
+++ b/src/com/android/settings/wifi/AddWifiNetworkPreference.java
@@ -20,7 +20,6 @@ import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.util.Log;
-import android.view.View;
import android.widget.ImageButton;
import androidx.annotation.DrawableRes;
@@ -63,10 +62,6 @@ public class AddWifiNetworkPreference extends Preference {
getContext().startActivity(
WifiDppUtils.getEnrolleeQrCodeScannerIntent(/* ssid */ null));
});
-
- final View divider = (View) holder.findViewById(
- com.android.settingslib.R.id.two_target_divider);
- divider.setVisibility(View.INVISIBLE);
}
}
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index 0adbd8d4faa..0887fc5532c 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -637,7 +637,7 @@ public class WifiConfigController implements TextWatcher,
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.GCMP_256);
config.allowedGroupManagementCiphers.set(WifiConfiguration.GroupMgmtCipher
.BIP_GMAC_256);
- config.allowedSuiteBCiphers.set(WifiConfiguration.SuiteBCipher.ECDHE_RSA);
+ // allowedSuiteBCiphers will be set according to certificate type
}
config.enterpriseConfig = new WifiEnterpriseConfig();
int eapMethod = mEapMethodSpinner.getSelectedItemPosition();
diff --git a/src/com/android/settings/wifi/WifiUtils.java b/src/com/android/settings/wifi/WifiUtils.java
index a22bdba868d..9b3c1b368c9 100644
--- a/src/com/android/settings/wifi/WifiUtils.java
+++ b/src/com/android/settings/wifi/WifiUtils.java
@@ -198,7 +198,7 @@ public class WifiUtils {
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.GCMP_256);
config.allowedGroupManagementCiphers.set(WifiConfiguration.GroupMgmtCipher
.BIP_GMAC_256);
- config.allowedSuiteBCiphers.set(WifiConfiguration.SuiteBCipher.ECDHE_RSA);
+ // allowedSuiteBCiphers will be set according to certificate type
}
if (!TextUtils.isEmpty(password)) {
diff --git a/src/com/android/settings/wifi/details/AddDevicePreferenceController.java b/src/com/android/settings/wifi/details/AddDevicePreferenceController.java
new file mode 100644
index 00000000000..61804a284dd
--- /dev/null
+++ b/src/com/android/settings/wifi/details/AddDevicePreferenceController.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.wifi.details;
+
+import android.content.Context;
+import android.content.Intent;
+import android.net.wifi.WifiManager;
+import android.util.Log;
+
+import androidx.preference.Preference;
+
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.wifi.dpp.WifiDppUtils;
+
+import com.android.settingslib.wifi.AccessPoint;
+
+/**
+ * {@link AbstractPreferenceController} that launches Wi-Fi Easy Connect configurator flow
+ */
+public class AddDevicePreferenceController extends BasePreferenceController {
+
+ private static final String TAG = "AddDevicePreferenceController";
+
+ private static final String KEY_ADD_DEVICE_CATEGORY = "add_device_category";
+ private static final String KEY_ADD_DEVICE = "add_device_to_network";
+
+ private AccessPoint mAccessPoint;
+ private WifiManager mWifiManager;
+
+ public AddDevicePreferenceController(Context context) {
+ super(context, KEY_ADD_DEVICE_CATEGORY);
+
+ mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+ }
+
+ public AddDevicePreferenceController init(AccessPoint accessPoint) {
+ mAccessPoint = accessPoint;
+
+ return this;
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ if (WifiDppUtils.isSupportConfiguratorQrCodeScanner(mContext, mAccessPoint)) {
+ return AVAILABLE;
+ } else {
+ return CONDITIONALLY_UNAVAILABLE;
+ }
+ }
+
+ @Override
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ if (KEY_ADD_DEVICE.equals(preference.getKey())) {
+ WifiDppUtils.showLockScreen(mContext, () -> launchWifiDppConfiguratorQrCodeScanner());
+ return true; /* click is handled */
+ }
+
+ return false; /* click is not handled */
+ }
+
+ private void launchWifiDppConfiguratorQrCodeScanner() {
+ final Intent intent = WifiDppUtils.getConfiguratorQrCodeScannerIntentOrNull(mContext,
+ mWifiManager, mAccessPoint);
+
+ if (intent == null) {
+ Log.e(TAG, "Launch Wi-Fi QR code scanner with a wrong Wi-Fi network!");
+ } else {
+ mContext.startActivity(intent);
+ }
+ }
+}
diff --git a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
index cf59dbd8774..5fc350bbc1d 100644
--- a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
@@ -342,7 +342,7 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
.setButton3Text(R.string.share)
.setButton3Icon(R.drawable.ic_qrcode_24dp)
.setButton3OnClickListener(view -> shareNetwork())
- .setButton3Visible(WifiDppUtils.isSuportConfigurator(mContext, mAccessPoint));
+ .setButton3Visible(WifiDppUtils.isSupportConfiguratorQrCodeGenerator(mAccessPoint));
mSignalStrengthPref = screen.findPreference(KEY_SIGNAL_STRENGTH_PREF);
mTxLinkSpeedPref = screen.findPreference(KEY_TX_LINK_SPEED);
@@ -757,11 +757,11 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
* Show QR code to share the network represented by this preference.
*/
public void launchWifiDppConfiguratorActivity() {
- final Intent intent = WifiDppUtils.getConfiguratorIntentOrNull(mContext, mWifiManager,
- mAccessPoint);
+ final Intent intent = WifiDppUtils.getConfiguratorQrCodeGeneratorIntentOrNull(mContext,
+ mWifiManager, mAccessPoint);
if (intent == null) {
- Log.e(TAG, "Launch Wi-Fi DPP configurator with a wrong Wi-Fi network!");
+ Log.e(TAG, "Launch Wi-Fi DPP QR code generator with a wrong Wi-Fi network!");
} else {
mContext.startActivity(intent);
}
diff --git a/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java b/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
index 66587edb54d..ee4cc2983c7 100644
--- a/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
+++ b/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
@@ -134,6 +134,7 @@ public class WifiNetworkDetailsFragment extends DashboardFragment {
mMetricsFeatureProvider);
controllers.add(mWifiDetailPreferenceController);
+ controllers.add(new AddDevicePreferenceController(context).init(mAccessPoint));
controllers.add(new WifiMeteredPreferenceController(context, mAccessPoint.getConfig()));
WifiPrivacyPreferenceController privacyController = new WifiPrivacyPreferenceController(
context);
diff --git a/src/com/android/settings/wifi/dpp/WifiDppQrCodeGeneratorFragment.java b/src/com/android/settings/wifi/dpp/WifiDppQrCodeGeneratorFragment.java
index 4e6a0d6879b..d388931407c 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppQrCodeGeneratorFragment.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppQrCodeGeneratorFragment.java
@@ -95,34 +95,14 @@ public class WifiDppQrCodeGeneratorFragment extends WifiDppQrCodeBaseFragment {
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- final WifiNetworkConfig wifiNetworkConfig = getWifiNetworkConfigFromHostActivity();
- MenuItem menuItem;
- if (!wifiNetworkConfig.isHotspot() &&
- wifiNetworkConfig.isSupportWifiDpp(getActivity())) {
- menuItem = menu.add(0, Menu.FIRST, 0, R.string.next_label);
- menuItem.setIcon(R.drawable.ic_scan_24dp);
- menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
- } else {
- menuItem = menu.findItem(Menu.FIRST);
- if (menuItem != null) {
- menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
- }
+ final MenuItem menuItem = menu.findItem(Menu.FIRST);
+ if (menuItem != null) {
+ menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
}
super.onCreateOptionsMenu(menu, inflater);
}
- @Override
- public boolean onOptionsItemSelected(MenuItem menuItem) {
- switch (menuItem.getItemId()) {
- case Menu.FIRST:
- mListener.onQrCodeGeneratorFragmentAddButtonClicked();
- return true;
- default:
- return super.onOptionsItemSelected(menuItem);
- }
- }
-
@Override
public final View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
diff --git a/src/com/android/settings/wifi/dpp/WifiDppUtils.java b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
index bf78b3f1a2f..6c6444c7d9d 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppUtils.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
@@ -165,9 +165,8 @@ public class WifiDppUtils {
}
/**
- * Returns an intent to launch QR code generator or scanner according to the Wi-Fi network
- * security. It may return null if the security is not supported by QR code generator nor
- * scanner.
+ * Returns an intent to launch QR code generator. It may return null if the security is not
+ * supported by QR code generator.
*
* Do not use this method for Wi-Fi hotspot network, use
* {@code getHotspotConfiguratorIntentOrNull} instead.
@@ -177,12 +176,34 @@ public class WifiDppUtils {
* @param accessPoint An instance of {@link AccessPoint}
* @return Intent for launching QR code generator
*/
- public static Intent getConfiguratorIntentOrNull(Context context,
+ public static Intent getConfiguratorQrCodeGeneratorIntentOrNull(Context context,
WifiManager wifiManager, AccessPoint accessPoint) {
final Intent intent = new Intent(context, WifiDppConfiguratorActivity.class);
if (isSupportConfiguratorQrCodeGenerator(accessPoint)) {
intent.setAction(WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_GENERATOR);
- } else if (isSupportConfiguratorQrCodeScanner(context, accessPoint)) {
+ } else {
+ return null;
+ }
+
+ final WifiConfiguration wifiConfiguration = accessPoint.getConfig();
+ setConfiguratorIntentExtra(intent, wifiManager, wifiConfiguration);
+
+ return intent;
+ }
+
+ /**
+ * Returns an intent to launch QR code scanner. It may return null if the security is not
+ * supported by QR code scanner.
+ *
+ * @param context The context to use for the content resolver
+ * @param wifiManager An instance of {@link WifiManager}
+ * @param accessPoint An instance of {@link AccessPoint}
+ * @return Intent for launching QR code scanner
+ */
+ public static Intent getConfiguratorQrCodeScannerIntentOrNull(Context context,
+ WifiManager wifiManager, AccessPoint accessPoint) {
+ final Intent intent = new Intent(context, WifiDppConfiguratorActivity.class);
+ if (isSupportConfiguratorQrCodeScanner(context, accessPoint)) {
intent.setAction(WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_SCANNER);
} else {
return null;
@@ -258,18 +279,6 @@ public class WifiDppUtils {
}
}
- /**
- * Android Q supports Wi-Fi configurator by:
- *
- * 1. QR code generator of ZXing's Wi-Fi network config format.
- * and
- * 2. QR code scanner of Wi-Fi DPP QR code format.
- */
- public static boolean isSuportConfigurator(Context context, AccessPoint accessPoint) {
- return isSupportConfiguratorQrCodeScanner(context, accessPoint) ||
- isSupportConfiguratorQrCodeGenerator(accessPoint);
- }
-
/**
* Shows authentication screen to confirm credentials (pin, pattern or password) for the current
* user of the device.
@@ -314,7 +323,7 @@ public class WifiDppUtils {
}
}
- private static boolean isSupportConfiguratorQrCodeScanner(Context context,
+ public static boolean isSupportConfiguratorQrCodeScanner(Context context,
AccessPoint accessPoint) {
if (!isWifiDppEnabled(context)) {
return false;
@@ -329,7 +338,7 @@ public class WifiDppUtils {
return false;
}
- private static boolean isSupportConfiguratorQrCodeGenerator(AccessPoint accessPoint) {
+ public static boolean isSupportConfiguratorQrCodeGenerator(AccessPoint accessPoint) {
// QR code generator produces QR code with ZXing's Wi-Fi network config format,
// it supports PSK and WEP and non security
final int security = accessPoint.getSecurity();
diff --git a/src/com/android/settings/wifi/tether/WifiTetherSsidPreference.java b/src/com/android/settings/wifi/tether/WifiTetherSsidPreference.java
index 64014d90325..7d4ebec9ac3 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherSsidPreference.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherSsidPreference.java
@@ -39,6 +39,7 @@ public class WifiTetherSsidPreference extends ValidatedEditTextPreference {
private ImageButton mImageButton;
private Drawable mButtonIcon;
+ private View mDivider;
private View.OnClickListener mClickListener;
private boolean mVisible;
@@ -68,6 +69,8 @@ public class WifiTetherSsidPreference extends ValidatedEditTextPreference {
}
private void initialize() {
+ // TODO(b/129019971): use methods of divider line in parent object
+ setLayoutResource(com.android.settingslib.R.layout.preference_two_target);
setWidgetLayoutResource(R.layout.wifi_button_preference_widget);
}
@@ -82,13 +85,17 @@ public class WifiTetherSsidPreference extends ValidatedEditTextPreference {
getContext().getString(R.string.wifi_dpp_share_hotspot));
setButtonIcon(R.drawable.ic_qrcode_24dp);
mImageButton.setImageDrawable(mButtonIcon);
+
+ mDivider = holder.findViewById(R.id.two_target_divider);
}
if (mVisible) {
mImageButton.setOnClickListener(mClickListener);
mImageButton.setVisibility(View.VISIBLE);
+ mDivider.setVisibility(View.VISIBLE);
} else {
mImageButton.setVisibility(View.GONE);
+ mDivider.setVisibility(View.GONE);
}
}
diff --git a/tests/robotests/assets/grandfather_invalid_base_preference_controller_constructor b/tests/robotests/assets/grandfather_invalid_base_preference_controller_constructor
index 675108d94ed..a72384291b0 100644
--- a/tests/robotests/assets/grandfather_invalid_base_preference_controller_constructor
+++ b/tests/robotests/assets/grandfather_invalid_base_preference_controller_constructor
@@ -10,5 +10,8 @@ com.android.settings.datausage.WifiDataUsageSummaryPreferenceController
com.android.settings.fuelgauge.RestrictAppPreferenceController
com.android.settings.fuelgauge.batterysaver.BatterySaverButtonPreferenceController
com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController
+com.android.settings.gestures.SystemNavigationEdgeToEdgePreferenceController
+com.android.settings.gestures.SystemNavigationLegacyPreferenceController
+com.android.settings.gestures.SystemNavigationSwipeUpPreferenceController
com.android.settings.security.VisiblePatternProfilePreferenceController
com.android.settings.wifi.details.WifiMeteredPreferenceController
\ No newline at end of file
diff --git a/tests/robotests/assets/grandfather_not_implementing_index_provider b/tests/robotests/assets/grandfather_not_implementing_index_provider
index 015502ba3dd..8ca65ffb084 100644
--- a/tests/robotests/assets/grandfather_not_implementing_index_provider
+++ b/tests/robotests/assets/grandfather_not_implementing_index_provider
@@ -19,6 +19,7 @@ com.android.settings.applications.ProcessStatsSummary
com.android.settings.applications.ProcessStatsUi
com.android.settings.applications.RunningServices
com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureDetails
+com.android.settings.applications.specialaccess.zenaccess.ZenAccessDetails
com.android.settings.applications.UsageAccessDetails
com.android.settings.backup.ToggleBackupSettingFragment
com.android.settings.biometrics.fingerprint.FingerprintSettings$FingerprintSettingsFragment
diff --git a/tests/robotests/src/com/android/settings/accessibility/LiveCaptionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/LiveCaptionPreferenceControllerTest.java
new file mode 100644
index 00000000000..9e0ce9c53bd
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/LiveCaptionPreferenceControllerTest.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.pm.ResolveInfo;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Shadows;
+import org.robolectric.shadows.ShadowPackageManager;
+
+import java.util.Collections;
+
+@RunWith(RobolectricTestRunner.class)
+public class LiveCaptionPreferenceControllerTest {
+
+ private LiveCaptionPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ mController = new LiveCaptionPreferenceController(RuntimeEnvironment.application,
+ "test_key");
+ }
+
+ @Test
+ public void getAvailabilityStatus_canResolveIntent_shouldReturnAvailable() {
+ final ShadowPackageManager pm = Shadows.shadowOf(
+ RuntimeEnvironment.application.getPackageManager());
+ pm.addResolveInfoForIntent(LiveCaptionPreferenceController.LIVE_CAPTION_INTENT,
+ new ResolveInfo());
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_noResolveIntent_shouldReturnUnavailable() {
+ final ShadowPackageManager pm = Shadows.shadowOf(
+ RuntimeEnvironment.application.getPackageManager());
+ pm.setResolveInfosForIntent(LiveCaptionPreferenceController.LIVE_CAPTION_INTENT,
+ Collections.emptyList());
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
+ }
+}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppButtonsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppButtonsPreferenceControllerTest.java
index f3d85d3993a..59aea3de99c 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/AppButtonsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppButtonsPreferenceControllerTest.java
@@ -324,7 +324,7 @@ public class AppButtonsPreferenceControllerTest {
final boolean controllable = mController.handleDisableable();
- verify(mButtonPrefs).setButton2Text(R.string.uninstall_text);
+ verify(mButtonPrefs).setButton2Text(R.string.disable_text);
assertThat(controllable).isFalse();
}
@@ -336,7 +336,7 @@ public class AppButtonsPreferenceControllerTest {
final boolean controllable = mController.handleDisableable();
- verify(mButtonPrefs).setButton2Text(R.string.uninstall_text);
+ verify(mButtonPrefs).setButton2Text(R.string.disable_text);
assertThat(controllable).isTrue();
}
@@ -348,7 +348,7 @@ public class AppButtonsPreferenceControllerTest {
final boolean controllable = mController.handleDisableable();
- verify(mButtonPrefs).setButton2Text(R.string.install_text);
+ verify(mButtonPrefs).setButton2Text(R.string.enable_text);
assertThat(controllable).isTrue();
}
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/DrawOverlayDetailsTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/DrawOverlayDetailsTest.java
index ca993612ac0..fdbf8b93319 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/DrawOverlayDetailsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/DrawOverlayDetailsTest.java
@@ -16,43 +16,26 @@
package com.android.settings.applications.appinfo;
-import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
-
-import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.settings.SettingsEnums;
-import android.view.Window;
import android.view.WindowManager.LayoutParams;
-import androidx.fragment.app.FragmentActivity;
-
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.testutils.FakeFeatureFactory;
-import com.android.settings.testutils.shadow.ShadowAppInfoBase;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
public class DrawOverlayDetailsTest {
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private FragmentActivity mActivity;
-
- @Mock
- private Window mWindow;
-
private LayoutParams layoutParams;
private FakeFeatureFactory mFeatureFactory;
@@ -82,23 +65,4 @@ public class DrawOverlayDetailsTest {
MetricsProto.MetricsEvent.APP_SPECIAL_PERMISSION_APPDRAW_DENY,
mFragment.getMetricsCategory(), "app", 0);
}
-
- @Test
- @Config(shadows = {ShadowAppInfoBase.class})
- public void hideNonSystemOverlaysWhenResumed() {
- when(mFragment.getActivity()).thenReturn(mActivity);
- when(mActivity.getWindow()).thenReturn(mWindow);
- when(mWindow.getAttributes()).thenReturn(layoutParams);
-
- mFragment.onResume();
- verify(mWindow).addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
-
- mFragment.onPause();
-
- // There's no Window.clearPrivateFlags() method, so the Window.attributes are updated.
- ArgumentCaptor paramCaptor = ArgumentCaptor.forClass(LayoutParams.class);
- verify(mWindow).setAttributes(paramCaptor.capture());
- assertEquals(0,
- paramCaptor.getValue().privateFlags & SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
- }
}
diff --git a/tests/robotests/src/com/android/settings/applications/managedomainurls/DomainAppPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/managedomainurls/DomainAppPreferenceControllerTest.java
index 5f2a51478cb..5e5239d6a88 100644
--- a/tests/robotests/src/com/android/settings/applications/managedomainurls/DomainAppPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/managedomainurls/DomainAppPreferenceControllerTest.java
@@ -18,17 +18,9 @@ package com.android.settings.applications.managedomainurls;
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.util.IconDrawableFactory;
-import android.view.View;
-import android.widget.ProgressBar;
-
-import androidx.preference.PreferenceViewHolder;
import com.android.settings.R;
import com.android.settingslib.applications.ApplicationsState;
@@ -64,21 +56,6 @@ public class DomainAppPreferenceControllerTest {
assertThat(pref.getLayoutResource()).isEqualTo(R.layout.preference_app);
}
- @Test
- public void onBindViewHolder_shouldSetAppendixViewToGone() {
- final DomainAppPreference pref = new DomainAppPreference(
- mContext, mIconDrawableFactory, mAppEntry);
- final View holderView = mock(View.class);
- final View appendixView = mock(View.class);
- when(holderView.findViewById(R.id.summary_container)).thenReturn(mock(View.class));
- when(holderView.findViewById(android.R.id.progress)).thenReturn(mock(ProgressBar.class));
- when(holderView.findViewById(R.id.appendix)).thenReturn(appendixView);
-
- pref.onBindViewHolder(PreferenceViewHolder.createInstanceForTests(holderView));
-
- verify(appendixView).setVisibility(View.GONE);
- }
-
private ApplicationInfo createApplicationInfo(String packageName) {
ApplicationInfo appInfo = new ApplicationInfo();
appInfo.sourceDir = "foo";
diff --git a/tests/robotests/src/com/android/settings/core/HideNonSystemOverlayMixinTest.java b/tests/robotests/src/com/android/settings/core/HideNonSystemOverlayMixinTest.java
index 579cba09c14..d4f43e2f5fa 100644
--- a/tests/robotests/src/com/android/settings/core/HideNonSystemOverlayMixinTest.java
+++ b/tests/robotests/src/com/android/settings/core/HideNonSystemOverlayMixinTest.java
@@ -20,6 +20,7 @@ import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTE
import static com.google.common.truth.Truth.assertThat;
+import android.os.Build;
import android.os.Bundle;
import android.view.WindowManager;
@@ -33,8 +34,8 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
import org.robolectric.android.controller.ActivityController;
+import org.robolectric.util.ReflectionHelpers;
@RunWith(RobolectricTestRunner.class)
public class HideNonSystemOverlayMixinTest {
@@ -43,7 +44,6 @@ public class HideNonSystemOverlayMixinTest {
@Before
public void setUp() {
- RuntimeEnvironment.application.setTheme(R.style.Theme_AppCompat);
mActivityController = Robolectric.buildActivity(TestActivity.class);
}
@@ -68,10 +68,25 @@ public class HideNonSystemOverlayMixinTest {
.isEqualTo(0);
}
+ @Test
+ public void isEnabled_debug_false() {
+ ReflectionHelpers.setStaticField(Build.class, "IS_DEBUGGABLE", true);
+
+ assertThat(new HideNonSystemOverlayMixin(null).isEnabled()).isFalse();
+ }
+
+ @Test
+ public void isEnabled_user_true() {
+ ReflectionHelpers.setStaticField(Build.class, "IS_DEBUGGABLE", false);
+
+ assertThat(new HideNonSystemOverlayMixin(null).isEnabled()).isTrue();
+ }
+
public static class TestActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ setTheme(R.style.Theme_AppCompat);
getLifecycle().addObserver(new HideNonSystemOverlayMixin(this));
}
}
diff --git a/tests/robotests/src/com/android/settings/development/featureflags/FeatureFlagPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/featureflags/FeatureFlagPreferenceControllerTest.java
index 2e15967d835..cf97544514a 100644
--- a/tests/robotests/src/com/android/settings/development/featureflags/FeatureFlagPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/featureflags/FeatureFlagPreferenceControllerTest.java
@@ -17,6 +17,7 @@
package com.android.settings.development.featureflags;
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
import static com.google.common.truth.Truth.assertThat;
@@ -26,6 +27,8 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
+import android.os.Build;
+import android.os.SystemProperties;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
@@ -37,6 +40,7 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import org.robolectric.util.ReflectionHelpers;
@RunWith(RobolectricTestRunner.class)
public class FeatureFlagPreferenceControllerTest {
@@ -59,10 +63,18 @@ public class FeatureFlagPreferenceControllerTest {
}
@Test
- public void getAvailability_available() {
+ public void getAvailability_debug_available() {
+ ReflectionHelpers.setStaticField(Build.class, "IS_DEBUGGABLE", true);
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
+
+ @Test
+ public void getAvailability_user_unavailable() {
+ ReflectionHelpers.setStaticField(Build.class, "IS_DEBUGGABLE", false);
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
+ }
+
@Test
public void onStart_shouldRefreshFeatureFlags() {
mController.onStart();
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/MainlineModuleVersionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/MainlineModuleVersionPreferenceControllerTest.java
index 2761b2fb42a..f391aac64a3 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/MainlineModuleVersionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/MainlineModuleVersionPreferenceControllerTest.java
@@ -18,6 +18,7 @@ package com.android.settings.deviceinfo.firmwareversion;
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
+import static com.android.settings.deviceinfo.firmwareversion.MainlineModuleVersionPreferenceController.MODULE_UPDATE_INTENT;
import static com.google.common.truth.Truth.assertThat;
@@ -29,8 +30,11 @@ import static org.mockito.Mockito.when;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.util.FeatureFlagUtils;
+import androidx.preference.Preference;
+
import com.android.settings.core.FeatureFlags;
import org.junit.Before;
@@ -48,11 +52,13 @@ public class MainlineModuleVersionPreferenceControllerTest {
private PackageManager mPackageManager;
private Context mContext;
+ private Preference mPreference;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
+ mPreference = new Preference(mContext);
when(mContext.getPackageManager()).thenReturn(mPackageManager);
FeatureFlagUtils.setEnabled(mContext, FeatureFlags.MAINLINE_MODULE, true);
@@ -82,7 +88,6 @@ public class MainlineModuleVersionPreferenceControllerTest {
@Test
public void getAvailabilityStatus_noMainlineModulePackageInfo_unavailable() throws Exception {
-
final String provider = "test.provider";
when(mContext.getString(
com.android.internal.R.string.config_defaultModuleMetadataProvider))
@@ -98,6 +103,43 @@ public class MainlineModuleVersionPreferenceControllerTest {
@Test
public void getAvailabilityStatus_hasMainlineModulePackageInfo_available() throws Exception {
+ setupModulePackage();
+
+ final MainlineModuleVersionPreferenceController controller =
+ new MainlineModuleVersionPreferenceController(mContext, "key");
+
+ assertThat(controller.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+ }
+
+ @Test
+ public void updateStates_canHandleIntent_setIntentToPreference() throws Exception {
+ setupModulePackage();
+ when(mPackageManager.resolveActivity(MODULE_UPDATE_INTENT, 0))
+ .thenReturn(new ResolveInfo());
+
+ final MainlineModuleVersionPreferenceController controller =
+ new MainlineModuleVersionPreferenceController(mContext, "key");
+
+ controller.updateState(mPreference);
+
+ assertThat(mPreference.getIntent()).isEqualTo(MODULE_UPDATE_INTENT);
+ }
+
+ @Test
+ public void updateStates_cannotHandleIntent_setNullToPreference() throws Exception {
+ setupModulePackage();
+ when(mPackageManager.resolveActivity(MODULE_UPDATE_INTENT, 0))
+ .thenReturn(null);
+
+ final MainlineModuleVersionPreferenceController controller =
+ new MainlineModuleVersionPreferenceController(mContext, "key");
+
+ controller.updateState(mPreference);
+
+ assertThat(mPreference.getIntent()).isNull();
+ }
+
+ private void setupModulePackage() throws Exception {
final String provider = "test.provider";
final String version = "test version 123";
final PackageInfo info = new PackageInfo();
@@ -106,11 +148,5 @@ public class MainlineModuleVersionPreferenceControllerTest {
com.android.internal.R.string.config_defaultModuleMetadataProvider))
.thenReturn(provider);
when(mPackageManager.getPackageInfo(eq(provider), anyInt())).thenReturn(info);
-
- final MainlineModuleVersionPreferenceController controller =
- new MainlineModuleVersionPreferenceController(mContext, "key");
-
- assertThat(controller.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
-
}
diff --git a/tests/robotests/src/com/android/settings/display/DarkUIPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/DarkUIPreferenceControllerTest.java
deleted file mode 100644
index c8f847b8872..00000000000
--- a/tests/robotests/src/com/android/settings/display/DarkUIPreferenceControllerTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.settings.display;
-
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.app.UiModeManager;
-import android.content.Context;
-
-import androidx.preference.ListPreference;
-import androidx.preference.PreferenceScreen;
-
-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;
-
-@RunWith(RobolectricTestRunner.class)
-public class DarkUIPreferenceControllerTest {
-
- private Context mContext;
- @Mock
- private ListPreference mPreference;
- @Mock
- private PreferenceScreen mPreferenceScreen;
- @Mock
- private UiModeManager mUiModeManager;
- private DarkUIPreferenceController mController;
-
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
- mContext = RuntimeEnvironment.application;
- mController = new DarkUIPreferenceController(mContext, "dark_ui_mode");
- mController.setUiModeManager(mUiModeManager);
- when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
- .thenReturn(mPreference);
- mController.displayPreference(mPreferenceScreen);
- }
-
- @Test
- public void onPreferenceChanged_setAuto() {
- // Auto was deprecated, it should default to NO.
- mController.onPreferenceChange(mPreference, "auto");
- verify(mUiModeManager).setNightMode(eq(UiModeManager.MODE_NIGHT_NO));
- }
-
- @Test
- public void onPreferenceChanged_setNightMode() {
- mController.onPreferenceChange(mPreference, "yes");
- verify(mUiModeManager).setNightMode(eq(UiModeManager.MODE_NIGHT_YES));
- }
-
- @Test
- public void onPreferenceChanged_setDayMode() {
- mController.onPreferenceChange(mPreference, "no");
- verify(mUiModeManager).setNightMode(eq(UiModeManager.MODE_NIGHT_NO));
- }
-
- public int getCurrentMode() {
- final UiModeManager uiModeManager = mContext.getSystemService(UiModeManager.class);
- return uiModeManager.getNightMode();
- }
-}
diff --git a/tests/robotests/src/com/android/settings/display/DarkUISettingsRadioButtonsControllerTest.java b/tests/robotests/src/com/android/settings/display/DarkUISettingsRadioButtonsControllerTest.java
new file mode 100644
index 00000000000..76142a42e60
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/display/DarkUISettingsRadioButtonsControllerTest.java
@@ -0,0 +1,52 @@
+package com.android.settings.display;
+
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+
+import android.app.UiModeManager;
+import android.content.Context;
+import androidx.preference.Preference;
+import com.android.settings.R;
+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;
+
+@RunWith(RobolectricTestRunner.class)
+public class DarkUISettingsRadioButtonsControllerTest {
+
+ @Mock
+ private UiModeManager mUiModeManager;
+ @Mock
+ private Preference mFooter;
+ private Context mContext;
+ private DarkUISettingsRadioButtonsController mController;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mController = new DarkUISettingsRadioButtonsController(mContext, mFooter);
+ mController.mManager = mUiModeManager;
+ }
+
+ @Test
+ public void footerUpdatesCorrectly() {
+ doReturn(UiModeManager.MODE_NIGHT_YES).when(mUiModeManager).getNightMode();
+ mController.updateFooter();
+ verify(mFooter).setSummary(eq(R.string.dark_ui_settings_dark_summary));
+
+ doReturn(UiModeManager.MODE_NIGHT_NO).when(mUiModeManager).getNightMode();
+ mController.updateFooter();
+ verify(mFooter).setSummary(eq(R.string.dark_ui_settings_light_summary));
+ }
+
+ public int getCurrentMode() {
+ final UiModeManager uiModeManager = mContext.getSystemService(UiModeManager.class);
+ return uiModeManager.getNightMode();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceControllerTest.java
index 0ee9cfc5ede..0e7c312eb18 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceControllerTest.java
@@ -16,11 +16,11 @@
package com.android.settings.fuelgauge.batterysaver;
-import static com.android.settings.fuelgauge.batterysaver.BatterySaverStickyPreferenceController.LOW_POWER_STICKY_AUTO_DISABLE_ENABLED;
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import android.provider.Settings;
+import android.provider.Settings.Global;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -43,21 +43,21 @@ public class BatterySaverStickyPreferenceControllerTest {
private int getAutoDisableSetting() {
return Settings.Global.getInt(mContext.getContentResolver(),
- LOW_POWER_STICKY_AUTO_DISABLE_ENABLED,
+ Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED,
1);
}
@Test
- public void testOnPreferenceChange_turnOnKeepActive_autoDisableOff() {
- mController.onPreferenceChange(null, true);
- final int isOn = getAutoDisableSetting();
- assertThat(isOn).isEqualTo(0);
- }
-
- @Test
- public void testOnPreferenceChange_TurnOffKeepActive_autoDisableOff() {
- mController.onPreferenceChange(null, false);
+ public void testOnPreferenceChange_turnOnAutoOff_autoDisableOn() {
+ mController.setChecked(true);
final int isOn = getAutoDisableSetting();
assertThat(isOn).isEqualTo(1);
}
+
+ @Test
+ public void testOnPreferenceChange_TurnOffAutoOff_autoDisableOff() {
+ mController.setChecked(false);
+ final int isOn = getAutoDisableSetting();
+ assertThat(isOn).isEqualTo(0);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionControllerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionControllerTest.java
index 8c24735c77a..2fe4697f099 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionControllerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionControllerTest.java
@@ -18,11 +18,13 @@ package com.android.settings.homepage.contextualcards.conditional;
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import android.content.Context;
+import android.content.Intent;
import android.hardware.display.ColorDisplayManager;
import org.junit.Before;
@@ -80,4 +82,11 @@ public class GrayscaleConditionControllerTest {
verify(mConditionManager).onConditionChanged();
}
+
+ @Test
+ public void onActionClick_shouldSendBroadcast() {
+ mController.onActionClick();
+
+ verify(mContext).sendBroadcast(any(Intent.class), any(String.class));
+ }
}
diff --git a/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorSliceTest.java b/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorSliceTest.java
index ab3f4de26f9..c5519601ae7 100644
--- a/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorSliceTest.java
+++ b/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorSliceTest.java
@@ -45,6 +45,7 @@ import com.android.settingslib.media.MediaDevice;
import com.android.settingslib.media.MediaOutputSliceConstants;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -59,6 +60,7 @@ import java.util.List;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {ShadowBluetoothAdapter.class})
+@Ignore("b/129292771")
public class MediaOutputIndicatorSliceTest {
private static final String TEST_DEVICE_NAME = "test_device_name";
diff --git a/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorWorkerTest.java b/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorWorkerTest.java
index 4a5662e53de..ed93258346b 100644
--- a/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorWorkerTest.java
+++ b/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorWorkerTest.java
@@ -37,6 +37,7 @@ import com.android.settingslib.bluetooth.LocalBluetoothManager;
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -52,6 +53,7 @@ import java.util.List;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {ShadowBluetoothUtils.class,
ShadowBluetoothDevice.class})
+@Ignore("b/129292771")
public class MediaOutputIndicatorWorkerTest {
private static final String TEST_A2DP_DEVICE_NAME = "Test_A2DP_BT_Device_NAME";
diff --git a/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLtePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLtePreferenceControllerTest.java
index 78ed4b596d3..9957cde89ed 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLtePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLtePreferenceControllerTest.java
@@ -102,13 +102,27 @@ public class Enhanced4gLtePreferenceControllerTest {
}
@Test
- public void updateState_variant4gLte_useVariantTitle() {
- mCarrierConfig.putInt(CarrierConfigManager.KEY_ENHANCED_4G_LTE_TITLE_VARIANT_INT, 1);
-
+ public void updateState_variant4gLte_useVariantTitleAndSummary() {
+ mCarrierConfig.putInt(CarrierConfigManager.KEY_ENHANCED_4G_LTE_TITLE_VARIANT_INT, 0);
mController.updateState(mPreference);
-
assertThat(mPreference.getTitle()).isEqualTo(
- mContext.getString(R.string.enhanced_4g_lte_mode_title_variant));
+ mContext.getString(R.string.enhanced_4g_lte_mode_title));
+ assertThat(mPreference.getSummary()).isEqualTo(
+ mContext.getString(R.string.enhanced_4g_lte_mode_summary));
+
+ mCarrierConfig.putInt(CarrierConfigManager.KEY_ENHANCED_4G_LTE_TITLE_VARIANT_INT, 1);
+ mController.updateState(mPreference);
+ assertThat(mPreference.getTitle()).isEqualTo(
+ mContext.getString(R.string.enhanced_4g_lte_mode_title_advanced_calling));
+ assertThat(mPreference.getSummary()).isEqualTo(
+ mContext.getString(R.string.enhanced_4g_lte_mode_summary));
+
+ mCarrierConfig.putInt(CarrierConfigManager.KEY_ENHANCED_4G_LTE_TITLE_VARIANT_INT, 2);
+ mController.updateState(mPreference);
+ assertThat(mPreference.getTitle()).isEqualTo(
+ mContext.getString(R.string.enhanced_4g_lte_mode_title_4g_calling));
+ assertThat(mPreference.getSummary()).isEqualTo(
+ mContext.getString(R.string.enhanced_4g_lte_mode_summary_4g_calling));
}
@Test
diff --git a/tests/robotests/src/com/android/settings/notification/AppNotificationSettingsTest.java b/tests/robotests/src/com/android/settings/notification/AppNotificationSettingsTest.java
deleted file mode 100644
index 9555a56e1ba..00000000000
--- a/tests/robotests/src/com/android/settings/notification/AppNotificationSettingsTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package com.android.settings.notification;
-
-import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.view.Window;
-import android.view.WindowManager;
-
-import androidx.fragment.app.FragmentActivity;
-import androidx.fragment.app.FragmentManager;
-
-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.robolectric.Robolectric;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.annotation.Config;
-import org.robolectric.annotation.Implementation;
-import org.robolectric.annotation.Implements;
-
-@RunWith(RobolectricTestRunner.class)
-public class AppNotificationSettingsTest {
-
- private WindowManager.LayoutParams mLayoutParams;
- private AppNotificationSettings mFragment;
- private FragmentActivity mActivity;
- @Mock
- private Window mWindow;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- mLayoutParams = new WindowManager.LayoutParams();
- mActivity = spy(Robolectric.setupActivity(FragmentActivity.class));
- mFragment = spy(new AppNotificationSettings());
- when(mFragment.getActivity()).thenReturn(mActivity);
- when(mFragment.getFragmentManager()).thenReturn(mock(FragmentManager.class));
- when(mActivity.getWindow()).thenReturn(mWindow);
- when(mWindow.getAttributes()).thenReturn(mLayoutParams);
- }
-
- @Test
- @Config(shadows = {ShadowNotificationSettingsBase.class})
- public void onResume_shouldHideSystemOverlay() {
- mFragment.onResume();
-
- verify(mWindow).addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
- }
-
- @Test
- @Config(shadows = {ShadowNotificationSettingsBase.class})
- public void onPause_shouldRemoveHideSystemOverlay() {
- mFragment.onResume();
-
- verify(mWindow).addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
-
- mFragment.onPause();
-
- // There's no Window.clearPrivateFlags() method, so the Window.attributes are updated.
- ArgumentCaptor paramCaptor = ArgumentCaptor.forClass(
- WindowManager.LayoutParams.class);
- verify(mWindow).setAttributes(paramCaptor.capture());
- assertEquals(0,
- paramCaptor.getValue().privateFlags
- & SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
- }
-
- @Implements(NotificationSettingsBase.class)
- public static class ShadowNotificationSettingsBase {
-
- protected void __constructor__() {
- // Do nothing
- }
-
- @Implementation
- protected void onResume() {
- // No-op.
- }
-
- @Implementation
- protected void onPause() {
- // No-op.
- }
- }
-}
diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
index 3509d75ab81..4bc83740575 100644
--- a/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
+++ b/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
@@ -32,6 +32,7 @@ import com.android.settingslib.testutils.DrawableTestHelper;
import com.google.android.setupdesign.GlifLayout;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
@@ -92,6 +93,7 @@ public class ChooseLockPatternTest {
@Config(qualifiers = "sw400dp")
@Test
+ @Ignore("b/129342100")
public void fingerprintExtraSet_shouldDisplayFingerprintIcon() {
ChooseLockPattern activity = createActivity(true);
ChooseLockPatternFragment fragment = (ChooseLockPatternFragment)
diff --git a/tests/robotests/src/com/android/settings/widget/AppCheckBoxPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/AppCheckBoxPreferenceTest.java
index 57c6e01749e..6340b164dd9 100644
--- a/tests/robotests/src/com/android/settings/widget/AppCheckBoxPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/widget/AppCheckBoxPreferenceTest.java
@@ -35,8 +35,6 @@ import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class)
public class AppCheckBoxPreferenceTest {
- private static final String SUMMARY = "summary info";
-
private Context mContext;
private AppCheckBoxPreference mPreference;
private AppCheckBoxPreference mAttrPreference;
@@ -57,26 +55,6 @@ public class AppCheckBoxPreferenceTest {
assertThat(mAttrPreference.getLayoutResource()).isEqualTo(R.layout.preference_app);
}
- @Test
- public void onBindViewHolder_noSummary_layoutGone() {
- mPreference.setSummary("");
-
- mPreference.onBindViewHolder(mPreferenceViewHolder);
-
- assertThat(mPreferenceViewHolder.findViewById(R.id.summary_container).getVisibility())
- .isEqualTo(View.GONE);
- }
-
- @Test
- public void onBindViewHolder_hasSummary_layoutVisible() {
- mPreference.setSummary(SUMMARY);
-
- mPreference.onBindViewHolder(mPreferenceViewHolder);
-
- assertThat(mPreferenceViewHolder.findViewById(R.id.summary_container).getVisibility())
- .isEqualTo(View.VISIBLE);
- }
-
@Test
public void onBindViewHolder_appendixGone() {
mPreference.onBindViewHolder(mPreferenceViewHolder);
diff --git a/tests/robotests/src/com/android/settings/widget/AppSwitchPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/AppSwitchPreferenceTest.java
deleted file mode 100644
index aa5e3e768a2..00000000000
--- a/tests/robotests/src/com/android/settings/widget/AppSwitchPreferenceTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.widget;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-import android.view.View;
-
-import androidx.preference.PreferenceViewHolder;
-
-import com.android.settings.R;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
-@RunWith(RobolectricTestRunner.class)
-public class AppSwitchPreferenceTest {
-
- private Context mContext;
- private View mRootView;
- private AppSwitchPreference mPref;
- private PreferenceViewHolder mHolder;
-
- @Before
- public void setUp() {
- mContext = RuntimeEnvironment.application;
- mRootView = View.inflate(mContext, R.layout.preference_app, null /* parent */);
- mHolder = PreferenceViewHolder.createInstanceForTests(mRootView);
- mPref = new AppSwitchPreference(mContext);
- }
-
- @Test
- public void setSummary_showSummaryContainer() {
- mPref.setSummary("test");
- mPref.onBindViewHolder(mHolder);
-
- assertThat(mHolder.findViewById(R.id.summary_container).getVisibility())
- .isEqualTo(View.VISIBLE);
- }
-
- @Test
- public void noSummary_hideSummaryContainer() {
- mPref.setSummary(null);
- mPref.onBindViewHolder(mHolder);
-
- assertThat(mHolder.findViewById(R.id.summary_container).getVisibility())
- .isEqualTo(View.GONE);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java
index 4cd6be4c15f..b53f3644575 100644
--- a/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java
@@ -18,6 +18,10 @@ package com.android.settings.widget;
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+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.verify;
@@ -29,6 +33,8 @@ import android.media.MediaPlayer;
import android.view.LayoutInflater;
import android.view.TextureView;
+import android.view.View;
+import android.widget.ImageView;
import androidx.preference.PreferenceViewHolder;
import com.android.settings.R;
@@ -45,8 +51,13 @@ import org.robolectric.RuntimeEnvironment;
public class VideoPreferenceTest {
private static final int VIDEO_WIDTH = 100;
private static final int VIDEO_HEIGHT = 150;
+
@Mock
private MediaPlayer mMediaPlayer;
+ @Mock
+ private ImageView fakePreview;
+ @Mock
+ private ImageView fakePlayButton;
private Context mContext;
private VideoPreference mVideoPreference;
private PreferenceViewHolder mPreferenceViewHolder;
@@ -83,8 +94,8 @@ public class VideoPreferenceTest {
(TextureView) mPreferenceViewHolder.findViewById(R.id.video_texture_view);
mVideoPreference.mAnimationAvailable = true;
mVideoPreference.mVideoReady = true;
- mVideoPreference.onBindViewHolder(mPreferenceViewHolder);
mVideoPreference.onViewInvisible();
+ mVideoPreference.onBindViewHolder(mPreferenceViewHolder);
when(mMediaPlayer.isPlaying()).thenReturn(false);
final TextureView.SurfaceTextureListener listener = video.getSurfaceTextureListener();
@@ -101,4 +112,30 @@ public class VideoPreferenceTest {
verify(mMediaPlayer).release();
}
+
+ @Test
+ public void updateViewStates_paused_updatesViews() {
+ when(mMediaPlayer.isPlaying()).thenReturn(true);
+ mVideoPreference.updateViewStates(fakePreview, fakePlayButton);
+ verify(fakePlayButton).setVisibility(eq(View.VISIBLE));
+ verify(fakePreview).setVisibility(eq(View.VISIBLE));
+ verify(mMediaPlayer).pause();
+ }
+
+ @Test
+ public void updateViewStates_playing_updatesViews() {
+ when(mMediaPlayer.isPlaying()).thenReturn(false);
+ mVideoPreference.updateViewStates(fakePreview, fakePlayButton);
+ verify(fakePlayButton).setVisibility(eq(View.GONE));
+ verify(fakePreview).setVisibility(eq(View.GONE));
+ verify(mMediaPlayer).start();
+ }
+
+ @Test
+ public void updateViewStates_noMediaPlayer_skips() {
+ mVideoPreference.mMediaPlayer = null;
+ mVideoPreference.updateViewStates(fakePreview, fakePlayButton);
+ verify(fakePlayButton, never()).setVisibility(anyInt());
+ verify(fakePreview, never()).setVisibility(anyInt());
+ }
}
diff --git a/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingDisclaimerFragmentTest.java b/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingDisclaimerFragmentTest.java
index 6c221e797f9..25fa737b591 100644
--- a/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingDisclaimerFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingDisclaimerFragmentTest.java
@@ -35,6 +35,7 @@ import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
+import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.OnScrollListener;
@@ -60,7 +61,7 @@ import org.robolectric.RobolectricTestRunner;
public class WifiCallingDisclaimerFragmentTest {
@Mock
- private Activity mActivity;
+ private FragmentActivity mActivity;
@Mock
private DisclaimerItem mDisclaimerItem;
@Mock
@@ -89,7 +90,7 @@ public class WifiCallingDisclaimerFragmentTest {
public void setUp() {
MockitoAnnotations.initMocks(this);
- mActivity = Robolectric.setupActivity(Activity.class);
+ mActivity = Robolectric.setupActivity(FragmentActivity.class);
mFragment = spy(new WifiCallingDisclaimerFragment());
doReturn(mActivity).when(mFragment).getActivity();
diff --git a/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
index 574d0d651cc..947d6187b28 100644
--- a/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
@@ -77,6 +77,7 @@ import com.android.settingslib.widget.LayoutPreference;
import com.android.settingslib.wifi.AccessPoint;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
@@ -98,6 +99,7 @@ import java.util.stream.Collectors;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {ShadowDevicePolicyManager.class, ShadowEntityHeaderController.class})
+@Ignore("b/129292549")
public class WifiDetailPreferenceControllerTest {
private static final int LEVEL = 1;
diff --git a/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java b/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java
index 75a9e117739..e9f35d8a31a 100644
--- a/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java
@@ -139,7 +139,7 @@ public class WifiSliceTest {
private AccessPoint createAccessPoint(String name, boolean active, boolean reachable) {
final AccessPoint accessPoint = mock(AccessPoint.class);
- doReturn(name).when(accessPoint).getConfigName();
+ doReturn(name).when(accessPoint).getTitle();
doReturn(active).when(accessPoint).isActive();
doReturn(reachable).when(accessPoint).isReachable();
if (active) {