diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index a8101f1fe93..6acb6cd0a63 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1825,7 +1825,7 @@
@@ -3048,7 +3048,7 @@
-
+
diff --git a/res/drawable/ic_expand.xml b/res/drawable/ic_expand.xml
index 72da2b9e34c..f5b3f66981e 100644
--- a/res/drawable/ic_expand.xml
+++ b/res/drawable/ic_expand.xml
@@ -19,6 +19,6 @@
-
+
diff --git a/res/drawable/ic_expand_more.xml b/res/drawable/ic_expand_more.xml
deleted file mode 100644
index edffde399a0..00000000000
--- a/res/drawable/ic_expand_more.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/res/layout/crypt_keeper_switch_input_method.xml b/res/layout/crypt_keeper_switch_input_method.xml
index b55db22f340..3fae593bbf6 100644
--- a/res/layout/crypt_keeper_switch_input_method.xml
+++ b/res/layout/crypt_keeper_switch_input_method.xml
@@ -22,7 +22,7 @@
android:id="@+id/switch_ime_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:src="@drawable/ic_lockscreen_ime"
+ android:src="@*android:drawable/ic_lockscreen_ime"
android:clickable="true"
android:contentDescription="@string/crypt_keeper_switch_input_method"
android:padding="@dimen/crypt_keeper_edit_text_ime_padding"
diff --git a/res/layout/homepage_condition_header.xml b/res/layout/homepage_condition_header.xml
index 8f3a92ca501..a2796ec1c82 100644
--- a/res/layout/homepage_condition_header.xml
+++ b/res/layout/homepage_condition_header.xml
@@ -45,8 +45,8 @@
android:paddingTop="@dimen/homepage_condition_header_indicator_padding_top"
android:paddingStart="@dimen/homepage_condition_header_indicator_padding_start"
android:paddingEnd="@dimen/homepage_condition_header_indicator_padding_end"
- android:src="@drawable/ic_expand_more"/>
+ android:src="@*android:drawable/ic_expand_more"/>
-
\ No newline at end of file
+
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 35c89234eee..c41bb142056 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2688,6 +2688,15 @@
Display white balance
+
+ Adaptive sleep
+
+ On
+
+ Off
+
+ Your screen would not dim and go to sleep if the device detects your present attention.
+
Night Light
@@ -6707,6 +6716,8 @@
+
+
@@ -7047,6 +7058,9 @@
dim screen, touchscreen, battery, smart brightness, dynamic brightness
+
+ dim screen, sleep, battery, timeout, attention
+
rotate, flip, rotation, portrait, landscape, orientation, vertical, horizontal
@@ -7317,7 +7331,7 @@
You won\u2019t see or hear notifications
- Your phone won\u2019t show new or existing notifications, and won\u2019t make a sound or vibrate. Notifications won\u2019t appear when you swipe down from the top of your screen.\n\nKeep in mind, critical notifications for phone activity and status will still appear.
+ Your phone won\u2019t show, vibrate or make sound for new or existing notifications. Keep in mind, critical notifications for phone activity and status will still appear.\n\nWhen you turn off Do Not Disturb, find missed notifications by swiping down from the top of your screen.
Custom
@@ -8044,7 +8058,7 @@
Calls
- When Do Not Disturb is on, incoming calls are blocked. You can adjust settings to allow your friends, family, or other contacts to reach you.
+ To be sure allowed calls make sound, check whether your device is set to ring, vibrate, or silent.
For \u2018%1$s\u2019 incoming calls are blocked. You can adjust settings to allow your friends, family, or other contacts to reach you.
@@ -8062,13 +8076,13 @@
Allow text messages
- When Do Not Disturb is on, incoming text messages are blocked. You can adjust settings to allow your friends, family, or other contacts to reach you.
+ To be sure allowed messages make sound, check whether your device is set to ring, vibrate, or silent.
For \u2018%1$s\u2019 incoming text messages are blocked. You can adjust settings to allow your friends, family, or other contacts to reach you.
- Text messages
+ SMS, MMS, and messaging apps
From anyone
@@ -8104,7 +8118,7 @@
alarms
- Allow media sounds
+ Play media sounds
media
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 8e8e86fc8f6..718a712b53e 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -284,14 +284,8 @@
- @dimen/search_bar_text_size
-
-
@@ -304,7 +298,7 @@
- sans-serif-medium
- 14sp
- ?android:attr/colorAccent
- - @drawable/btn_borderless_rect
+ - @*android:drawable/btn_borderless_rect
- center
- true
- 8dp
diff --git a/res/xml/adaptive_sleep_detail.xml b/res/xml/adaptive_sleep_detail.xml
new file mode 100644
index 00000000000..b7dabbb1e45
--- /dev/null
+++ b/res/xml/adaptive_sleep_detail.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/xml/connected_devices_advanced.xml b/res/xml/connected_devices_advanced.xml
index b5d2a999e4b..28e9fdcfa27 100644
--- a/res/xml/connected_devices_advanced.xml
+++ b/res/xml/connected_devices_advanced.xml
@@ -24,7 +24,7 @@
android:fragment="com.android.settings.connecteddevice.BluetoothDashboardFragment"
android:key="bluetooth_settings"
android:title="@string/bluetooth_settings_title"
- android:icon="@drawable/ic_settings_bluetooth"
+ android:icon="@*android:drawable/ic_settings_bluetooth"
android:order="-9"
settings:searchable="false"/>
@@ -48,7 +48,7 @@
android:key="connected_device_printing"
android:title="@string/print_settings"
android:summary="@string/summary_placeholder"
- android:icon="@drawable/ic_settings_print"
+ android:icon="@*android:drawable/ic_settings_print"
android:fragment="com.android.settings.print.PrintSettingsFragment"
android:order="-3"
settings:searchable="false"/>
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index 76b3d2eefba..b110b46ce26 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -66,6 +66,13 @@
android:entryValues="@array/screen_timeout_values"
settings:keywords="@string/keywords_screen_timeout" />
+
+
getXmlResourcesToIndex(
+ Context context, boolean enabled) {
+ final SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.adaptive_sleep_detail;
+ return Arrays.asList(sir);
+ }
+ };
+}
diff --git a/src/com/android/settings/fuelgauge/BatteryEntry.java b/src/com/android/settings/fuelgauge/BatteryEntry.java
index a93d5223156..c91cc8ffd2c 100644
--- a/src/com/android/settings/fuelgauge/BatteryEntry.java
+++ b/src/com/android/settings/fuelgauge/BatteryEntry.java
@@ -157,7 +157,7 @@ public class BatteryEntry {
break;
case BLUETOOTH:
name = context.getResources().getString(R.string.power_bluetooth);
- iconId = R.drawable.ic_settings_bluetooth;
+ iconId = com.android.internal.R.drawable.ic_settings_bluetooth;
break;
case SCREEN:
name = context.getResources().getString(R.string.power_screen);
diff --git a/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java b/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
index 03868ee67e3..ea2a30865ea 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
@@ -103,7 +103,7 @@ public class BluetoothDevicesSlice implements CustomSliceable {
@Override
public Slice getSlice() {
final IconCompat icon = IconCompat.createWithResource(mContext,
- R.drawable.ic_settings_bluetooth);
+ com.android.internal.R.drawable.ic_settings_bluetooth);
final CharSequence title = mContext.getText(R.string.bluetooth_devices);
final CharSequence titleNoBluetoothDevices = mContext.getText(
R.string.no_bluetooth_devices);
@@ -236,7 +236,8 @@ public class BluetoothDevicesSlice implements CustomSliceable {
if (pair.first != null) {
return IconCompat.createWithBitmap(getBitmapFromVectorDrawable(pair.first));
} else {
- return IconCompat.createWithResource(mContext, R.drawable.ic_settings_bluetooth);
+ return IconCompat.createWithResource(mContext,
+ com.android.internal.R.drawable.ic_settings_bluetooth);
}
}
@@ -303,4 +304,4 @@ public class BluetoothDevicesSlice implements CustomSliceable {
return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent, 0 /* flags */);
}
-}
\ No newline at end of file
+}
diff --git a/src/com/android/settings/location/LocationSlice.java b/src/com/android/settings/location/LocationSlice.java
index e2078e3a13b..275969046ad 100644
--- a/src/com/android/settings/location/LocationSlice.java
+++ b/src/com/android/settings/location/LocationSlice.java
@@ -55,7 +55,7 @@ public class LocationSlice implements CustomSliceable {
@Override
public Slice getSlice() {
final IconCompat icon = IconCompat.createWithResource(mContext,
- R.drawable.ic_signal_location);
+ com.android.internal.R.drawable.ic_signal_location);
final CharSequence title = mContext.getText(R.string.location_settings_title);
@ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
final PendingIntent primaryAction = getPrimaryAction();
diff --git a/src/com/android/settings/notification/ZenRuleButtonsPreferenceController.java b/src/com/android/settings/notification/ZenRuleButtonsPreferenceController.java
index a773908607e..a014ec90683 100644
--- a/src/com/android/settings/notification/ZenRuleButtonsPreferenceController.java
+++ b/src/com/android/settings/notification/ZenRuleButtonsPreferenceController.java
@@ -62,7 +62,7 @@ public class ZenRuleButtonsPreferenceController extends AbstractZenModePreferenc
if (isAvailable()) {
mButtonsPref = ((ActionButtonsPreference) screen.findPreference(KEY))
.setButton1Text(R.string.zen_mode_rule_name_edit)
- .setButton1Icon(R.drawable.ic_mode_edit)
+ .setButton1Icon(com.android.internal.R.drawable.ic_mode_edit)
.setButton1OnClickListener(new EditRuleNameClickListener())
.setButton2Text(R.string.zen_mode_delete_rule_button)
.setButton2Icon(R.drawable.ic_settings_delete)
diff --git a/src/com/android/settings/widget/EntityHeaderController.java b/src/com/android/settings/widget/EntityHeaderController.java
index c1101079223..271485983d5 100644
--- a/src/com/android/settings/widget/EntityHeaderController.java
+++ b/src/com/android/settings/widget/EntityHeaderController.java
@@ -344,7 +344,7 @@ public class EntityHeaderController {
if (mEditOnClickListener == null) {
button.setVisibility(View.GONE);
} else {
- button.setImageResource(R.drawable.ic_mode_edit);
+ button.setImageResource(com.android.internal.R.drawable.ic_mode_edit);
button.setVisibility(View.VISIBLE);
button.setOnClickListener(mEditOnClickListener);
}
diff --git a/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java b/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
index 5ac0d284b46..ec43b0ffb24 100644
--- a/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
+++ b/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
@@ -101,7 +101,7 @@ public class WifiNetworkDetailsFragment extends DashboardFragment {
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
MenuItem item = menu.add(0, Menu.FIRST, 0, R.string.wifi_modify);
- item.setIcon(R.drawable.ic_mode_edit);
+ item.setIcon(com.android.internal.R.drawable.ic_mode_edit);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
super.onCreateOptionsMenu(menu, inflater);
}
diff --git a/src/com/android/settings/wifi/dpp/WifiDppAddDeviceFragment.java b/src/com/android/settings/wifi/dpp/WifiDppAddDeviceFragment.java
index 9864ea92f27..52243d4b7cf 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppAddDeviceFragment.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppAddDeviceFragment.java
@@ -133,7 +133,8 @@ public class WifiDppAddDeviceFragment extends WifiDppQrCodeBaseFragment {
mChooseDifferentNetwork = view.findViewById(R.id.choose_different_network);
mChooseDifferentNetwork.setOnClickListener(v ->
- mClickChooseDifferentNetworkListener.onClickChooseDifferentNetwork());
+ mClickChooseDifferentNetworkListener.onClickChooseDifferentNetwork()
+ );
mButtonLeft = view.findViewById(R.id.button_left);
mButtonLeft.setText(R.string.cancel);
diff --git a/src/com/android/settings/wifi/dpp/WifiDppChooseSavedWifiNetworkFragment.java b/src/com/android/settings/wifi/dpp/WifiDppChooseSavedWifiNetworkFragment.java
index 38176159f01..6a229a14468 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppChooseSavedWifiNetworkFragment.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppChooseSavedWifiNetworkFragment.java
@@ -61,6 +61,10 @@ public class WifiDppChooseSavedWifiNetworkFragment extends WifiDppQrCodeBaseFrag
* WifiDppChooseSavedWifiNetworkFragment. */
final FragmentManager fragmentManager = getChildFragmentManager();
final WifiNetworkListFragment fragment = new WifiNetworkListFragment();
+ final Bundle args = getArguments();
+ if (args != null) {
+ fragment.setArguments(args);
+ }
final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.wifi_network_list_container, fragment,
TAG_FRAGMENT_WIFI_NETWORK_LIST);
diff --git a/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java b/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java
index 3955456ced6..e5beea03760 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java
@@ -21,6 +21,7 @@ import android.app.Activity;
import android.app.settings.SettingsEnums;
import android.content.Intent;
import android.os.Bundle;
+import android.provider.Settings;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
@@ -45,7 +46,7 @@ import com.android.settings.core.InstrumentedActivity;
* {@code WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY}
* {@code WifiDppUtils.EXTRA_WIFI_HIDDEN_SSID}
*
- * For intent action {@code ACTION_PROCESS_WIFI_DPP_QR_CODE}, specify Wi-Fi (DPP)
+ * For intent action {@link Settings#ACTION_PROCESS_WIFI_EASY_CONNECT_QR_CODE}, specify Wi-Fi (DPP)
* QR code in {@code WifiDppUtils.EXTRA_QR_CODE}
*/
public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
@@ -62,8 +63,6 @@ public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
"android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER";
public static final String ACTION_CONFIGURATOR_QR_CODE_GENERATOR =
"android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR";
- public static final String ACTION_PROCESS_WIFI_DPP_QR_CODE =
- "android.settings.PROCESS_WIFI_DPP_QR_CODE";
// Key for Bundle usage
private static final String KEY_QR_CODE = "key_qr_code";
@@ -78,8 +77,10 @@ public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
/** The Wi-Fi network which will be configured */
private WifiNetworkConfig mWifiNetworkConfig;
- /** The Wi-Fi DPP QR code from intent ACTION_PROCESS_WIFI_DPP_QR_CODE */
+ /** The Wi-Fi DPP QR code from intent ACTION_PROCESS_WIFI_EASY_CONNECT_QR_CODE */
private WifiQrCode mWifiDppQrCode;
+ /** Secret extra that allows fake networks to show in UI for testing purposes */
+ private boolean mIsTest;
@Override
public int getMetricsCategory() {
@@ -139,8 +140,9 @@ public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
showQrCodeGeneratorFragment();
}
break;
- case ACTION_PROCESS_WIFI_DPP_QR_CODE:
- String qrCode = intent.getStringExtra(WifiDppUtils.EXTRA_QR_CODE);
+ case Settings.ACTION_PROCESS_WIFI_EASY_CONNECT_QR_CODE:
+ String qrCode = intent.getStringExtra(Settings.EXTRA_QR_CODE);
+ mIsTest = intent.getBooleanExtra(WifiDppUtils.EXTRA_TEST, false);
mWifiDppQrCode = getValidWifiDppQrCodeOrNull(qrCode);
final boolean isDppSupported = WifiDppUtils.isWifiDppEnabled(this);
if (!isDppSupported) {
@@ -164,12 +166,17 @@ public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
}
private void showQrCodeScannerFragment(boolean addToBackStack) {
+ WifiDppQrCodeScannerFragment fragment =
+ (WifiDppQrCodeScannerFragment) mFragmentManager.findFragmentByTag(
+ WifiDppUtils.TAG_FRAGMENT_QR_CODE_SCANNER);
// Avoid to replace the same fragment during configuration change
- if (mFragmentManager.findFragmentByTag(WifiDppUtils.TAG_FRAGMENT_QR_CODE_SCANNER) != null) {
+ if (fragment != null && fragment.isVisible()) {
return;
}
- final WifiDppQrCodeScannerFragment fragment = new WifiDppQrCodeScannerFragment();
+ if (fragment == null) {
+ fragment = new WifiDppQrCodeScannerFragment();
+ }
final FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment,
@@ -181,13 +188,15 @@ public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
}
private void showQrCodeGeneratorFragment() {
+ WifiDppQrCodeGeneratorFragment fragment =
+ (WifiDppQrCodeGeneratorFragment) mFragmentManager.findFragmentByTag(
+ WifiDppUtils.TAG_FRAGMENT_QR_CODE_GENERATOR);
// Avoid to replace the same fragment during configuration change
- if (mFragmentManager.findFragmentByTag(
- WifiDppUtils.TAG_FRAGMENT_QR_CODE_GENERATOR) != null) {
+ if (fragment != null && fragment.isVisible()) {
return;
}
- final WifiDppQrCodeGeneratorFragment fragment = new WifiDppQrCodeGeneratorFragment();
+ fragment = new WifiDppQrCodeGeneratorFragment();
final FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment,
@@ -196,14 +205,22 @@ public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
}
private void showChooseSavedWifiNetworkFragment(boolean addToBackStack) {
+ WifiDppChooseSavedWifiNetworkFragment fragment =
+ (WifiDppChooseSavedWifiNetworkFragment) mFragmentManager.findFragmentByTag(
+ WifiDppUtils.TAG_FRAGMENT_CHOOSE_SAVED_WIFI_NETWORK);
// Avoid to replace the same fragment during configuration change
- if (mFragmentManager.findFragmentByTag(
- WifiDppUtils.TAG_FRAGMENT_CHOOSE_SAVED_WIFI_NETWORK) != null) {
+ if (fragment != null && fragment.isVisible()) {
return;
}
- final WifiDppChooseSavedWifiNetworkFragment fragment =
- new WifiDppChooseSavedWifiNetworkFragment();
+ if (fragment == null) {
+ fragment = new WifiDppChooseSavedWifiNetworkFragment();
+ if (mIsTest) {
+ Bundle bundle = new Bundle();
+ bundle.putBoolean(WifiDppUtils.EXTRA_TEST, true);
+ fragment.setArguments(bundle);
+ }
+ }
final FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment,
@@ -215,14 +232,19 @@ public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
}
private void showAddDeviceFragment(boolean addToBackStack) {
+ WifiDppAddDeviceFragment fragment =
+ (WifiDppAddDeviceFragment) mFragmentManager.findFragmentByTag(
+ WifiDppUtils.TAG_FRAGMENT_ADD_DEVICE);
+
// Avoid to replace the same fragment during configuration change
if (mFragmentManager.findFragmentByTag(
WifiDppUtils.TAG_FRAGMENT_ADD_DEVICE) != null) {
return;
}
- final WifiDppAddDeviceFragment fragment =
- new WifiDppAddDeviceFragment();
+ if (fragment == null) {
+ fragment = new WifiDppAddDeviceFragment();
+ }
final FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment,
diff --git a/src/com/android/settings/wifi/dpp/WifiDppUtils.java b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
index e1b8ead321e..b43ee92f9a9 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppUtils.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
@@ -29,6 +29,8 @@ import java.util.List;
/**
* Here are the items shared by both WifiDppConfiguratorActivity & WifiDppEnrolleeActivity
+ *
+ * @see WifiQrCode
*/
public class WifiDppUtils {
/**
@@ -67,8 +69,9 @@ public class WifiDppUtils {
/** The data corresponding to {@code WifiConfiguration} networkId */
public static final String EXTRA_WIFI_NETWORK_ID = "networkId";
- /** @see WifiQrCode */
- public static final String EXTRA_QR_CODE = "qrCode";
+ /** Used by {@link android.provider.Settings#ACTION_PROCESS_WIFI_EASY_CONNECT_QR_CODE} to
+ * indicate test mode UI should be shown. Test UI does not make API calls. Value is a boolean.*/
+ public static final String EXTRA_TEST = "test";
/**
* Returns whether the user can share the network represented by this preference with QR code.
diff --git a/src/com/android/settings/wifi/dpp/WifiNetworkConfig.java b/src/com/android/settings/wifi/dpp/WifiNetworkConfig.java
index 08b54204f10..8e95b3e7c0a 100644
--- a/src/com/android/settings/wifi/dpp/WifiNetworkConfig.java
+++ b/src/com/android/settings/wifi/dpp/WifiNetworkConfig.java
@@ -42,6 +42,9 @@ import androidx.annotation.VisibleForTesting;
* EXTRA_QR_CODE
*/
public class WifiNetworkConfig {
+
+ static final String FAKE_SSID = "fake network";
+ static final String FAKE_PASSWORD = "password";
private static final String TAG = "WifiNetworkConfig";
private String mSecurity;
diff --git a/src/com/android/settings/wifi/dpp/WifiNetworkListFragment.java b/src/com/android/settings/wifi/dpp/WifiNetworkListFragment.java
index 0a7a08c8267..b078b01d083 100644
--- a/src/com/android/settings/wifi/dpp/WifiNetworkListFragment.java
+++ b/src/com/android/settings/wifi/dpp/WifiNetworkListFragment.java
@@ -55,11 +55,14 @@ public class WifiNetworkListFragment extends SettingsPreferenceFragment implemen
private PreferenceCategory mAccessPointsPreferenceCategory;
private AccessPointPreference.UserBadgeCache mUserBadgeCache;
private Preference mAddPreference;
+ // Only shows up if mIsTest == true
+ private Preference mFakeNetworkPreference;
private WifiManager mWifiManager;
private WifiTracker mWifiTracker;
private WifiManager.ActionListener mSaveListener;
+ private boolean mIsTest;
@VisibleForTesting
boolean mUseConnectedAccessPointDirectly;
@@ -99,6 +102,11 @@ public class WifiNetworkListFragment extends SettingsPreferenceFragment implemen
getSettingsLifecycle(), /* includeSaved */true, /* includeScans */ true);
mWifiManager = mWifiTracker.getManager();
+ final Bundle args = getArguments();
+ if (args != null) {
+ mIsTest = args.getBoolean(WifiDppUtils.EXTRA_TEST, false);
+ }
+
mSaveListener = new WifiManager.ActionListener() {
@Override
public void onSuccess() {
@@ -138,6 +146,11 @@ public class WifiNetworkListFragment extends SettingsPreferenceFragment implemen
mAccessPointsPreferenceCategory = (PreferenceCategory) findPreference(
PREF_KEY_ACCESS_POINTS);
+ mFakeNetworkPreference = new Preference(getPrefContext());
+ mFakeNetworkPreference.setIcon(R.drawable.ic_wifi_signal_0);
+ mFakeNetworkPreference.setKey("fake_key");
+ mFakeNetworkPreference.setTitle("fake network");
+
mAddPreference = new Preference(getPrefContext());
mAddPreference.setIcon(R.drawable.ic_menu_add);
mAddPreference.setTitle(R.string.wifi_add_network);
@@ -218,6 +231,16 @@ public class WifiNetworkListFragment extends SettingsPreferenceFragment implemen
}
} else if (preference == mAddPreference) {
launchAddNetworkFragment();
+ } else if (preference == mFakeNetworkPreference) {
+ if (mOnChooseNetworkListener != null) {
+ mOnChooseNetworkListener.onChooseNetwork(
+ new WifiNetworkConfig(
+ WifiQrCode.SECURITY_WPA,
+ /* ssid */ WifiNetworkConfig.FAKE_SSID,
+ /* preSharedKey */ WifiNetworkConfig.FAKE_PASSWORD,
+ /* hiddenSsid */ true,
+ /* networkId */ WifiConfiguration.INVALID_NETWORK_ID));
+ }
} else {
return super.onPreferenceTreeClick(preference);
}
@@ -314,6 +337,11 @@ public class WifiNetworkListFragment extends SettingsPreferenceFragment implemen
removeCachedPrefs(mAccessPointsPreferenceCategory);
mAddPreference.setOrder(index);
mAccessPointsPreferenceCategory.addPreference(mAddPreference);
+
+ if (mIsTest) {
+ mFakeNetworkPreference.setOrder(index + 1);
+ mAccessPointsPreferenceCategory.addPreference(mFakeNetworkPreference);
+ }
}
private AccessPointPreference createAccessPointPreference(AccessPoint accessPoint) {
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java
index 9e5b617634f..f6969ec8aef 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java
@@ -171,7 +171,8 @@ public class BluetoothDevicePreferenceTest {
.thenReturn(new BluetoothClass(BluetoothClass.Device.Major.IMAGING));
mPreference.onDeviceAttributesChanged();
- DrawableTestHelper.assertDrawableResId(mPreference.getIcon(), R.drawable.ic_settings_print);
+ DrawableTestHelper.assertDrawableResId(mPreference.getIcon(),
+ com.android.internal.R.drawable.ic_settings_print);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSliceBuilderTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSliceBuilderTest.java
index 4504d84fce0..f4a9d362d49 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSliceBuilderTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSliceBuilderTest.java
@@ -68,7 +68,7 @@ public class BluetoothSliceBuilderTest {
final SliceAction primaryAction = metadata.getPrimaryAction();
final IconCompat expectedToggleIcon = IconCompat.createWithResource(mContext,
- R.drawable.ic_settings_bluetooth);
+ com.android.internal.R.drawable.ic_settings_bluetooth);
assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedToggleIcon.toString());
}
diff --git a/tests/robotests/src/com/android/settings/display/AdaptiveSleepPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/AdaptiveSleepPreferenceControllerTest.java
new file mode 100644
index 00000000000..d426e7aa7ba
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/display/AdaptiveSleepPreferenceControllerTest.java
@@ -0,0 +1,117 @@
+/*
+ * 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 static android.provider.Settings.System.ADAPTIVE_SLEEP;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.provider.Settings;
+
+import com.android.settings.R;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class AdaptiveSleepPreferenceControllerTest {
+
+ private static final String PREFERENCE_KEY = "adaptive_sleep";
+
+ private Context mContext;
+ private AdaptiveSleepPreferenceController mController;
+ private ContentResolver mContentResolver;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ mContext = RuntimeEnvironment.application;
+ mContentResolver = mContext.getContentResolver();
+ mController = new AdaptiveSleepPreferenceController(mContext, PREFERENCE_KEY);
+ }
+
+ @Test
+ public void onPreferenceChange_turnOn_returnOn() {
+ mController.onPreferenceChange(null, true);
+
+ final int mode = Settings.System.getInt(mContentResolver, ADAPTIVE_SLEEP, 0);
+ assertThat(mode).isEqualTo(1);
+ }
+
+ @Test
+ public void onPreferenceChange_turnOff_returnOff() {
+ mController.onPreferenceChange(null, false);
+
+ final int mode = Settings.System.getInt(mContentResolver, ADAPTIVE_SLEEP, 1);
+ assertThat(mode).isEqualTo(0);
+ }
+
+ @Test
+ public void setChecked_updatesCorrectly() {
+ mController.setChecked(true);
+
+ assertThat(mController.isChecked()).isTrue();
+
+ mController.setChecked(false);
+
+ assertThat(mController.isChecked()).isFalse();
+ }
+
+ @Test
+ public void isChecked_no() {
+ Settings.System.putInt(mContentResolver, ADAPTIVE_SLEEP, 0);
+
+ assertThat(mController.isChecked()).isFalse();
+ }
+
+ @Test
+ public void isChecked_yes() {
+ Settings.System.putInt(mContentResolver, ADAPTIVE_SLEEP, 1);
+
+ assertThat(mController.isChecked()).isTrue();
+ }
+
+ @Test
+ public void getSummary_settingOn_shouldReturnOnSummary() {
+ mController.setChecked(true);
+
+ assertThat(mController.getSummary())
+ .isEqualTo(mContext.getText(R.string.adaptive_sleep_summary_on));
+ }
+
+ @Test
+ public void getSummary_settingOff_shouldReturnOffSummary() {
+ mController.setChecked(false);
+
+ assertThat(mController.getSummary())
+ .isEqualTo(mContext.getText(R.string.adaptive_sleep_summary_off));
+ }
+
+ @Test
+ public void isSliceable_returnsTrue() {
+ final AdaptiveSleepPreferenceController controller =
+ new AdaptiveSleepPreferenceController(mContext, "any_key");
+ assertThat(controller.isSliceable()).isTrue();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java
index bc34fd54f8b..02d7a9da679 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java
@@ -83,7 +83,8 @@ public class BluetoothDevicesSliceTest {
mBluetoothDevicesSlice = spy(new BluetoothDevicesSlice(mContext));
// Mock the icon and detail intent of Bluetooth.
- mIcon = IconCompat.createWithResource(mContext, R.drawable.ic_settings_bluetooth);
+ mIcon = IconCompat.createWithResource(mContext,
+ com.android.internal.R.drawable.ic_settings_bluetooth);
mDetailIntent = PendingIntent.getActivity(mContext, 0, new Intent("test action"), 0);
doReturn(mIcon).when(mBluetoothDevicesSlice).getBluetoothDeviceIcon(any());
doReturn(mDetailIntent).when(mBluetoothDevicesSlice).getBluetoothDetailIntent(any());
@@ -208,4 +209,4 @@ public class BluetoothDevicesSliceTest {
final CharSequence sliceTitle = metadata.getTitle();
return TextUtils.equals(sliceTitle, title);
}
-}
\ No newline at end of file
+}
diff --git a/tests/robotests/src/com/android/settings/location/LocationSliceTest.java b/tests/robotests/src/com/android/settings/location/LocationSliceTest.java
index 0618cd9bb93..a373b1f8a4e 100644
--- a/tests/robotests/src/com/android/settings/location/LocationSliceTest.java
+++ b/tests/robotests/src/com/android/settings/location/LocationSliceTest.java
@@ -47,7 +47,7 @@ public class LocationSliceTest {
final SliceAction primaryAction = metadata.getPrimaryAction();
final IconCompat expectedToggleIcon = IconCompat.createWithResource(mContext,
- R.drawable.ic_signal_location);
+ com.android.internal.R.drawable.ic_signal_location);
assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedToggleIcon.toString());
}
}
diff --git a/tests/unit/src/com/android/settings/wifi/dpp/WifiDppChooseSavedWifiNetworkFragmentTest.java b/tests/unit/src/com/android/settings/wifi/dpp/WifiDppChooseSavedWifiNetworkFragmentTest.java
index d2f6e6c5cb7..6ad6377d1ad 100644
--- a/tests/unit/src/com/android/settings/wifi/dpp/WifiDppChooseSavedWifiNetworkFragmentTest.java
+++ b/tests/unit/src/com/android/settings/wifi/dpp/WifiDppChooseSavedWifiNetworkFragmentTest.java
@@ -29,6 +29,7 @@ import android.app.Activity;
import android.content.Context;
import android.content.Intent;
+import android.provider.Settings;
import androidx.fragment.app.FragmentManager;
import androidx.test.InstrumentationRegistry;
import androidx.test.rule.ActivityTestRule;
@@ -88,9 +89,8 @@ public class WifiDppChooseSavedWifiNetworkFragmentTest {
@Test
public void clickCancelButton_processWifiDppQrCodeIntent_shouldFinish() {
- final Intent intent =
- new Intent(WifiDppConfiguratorActivity.ACTION_PROCESS_WIFI_DPP_QR_CODE);
- intent.putExtra(WifiDppUtils.EXTRA_QR_CODE, VALID_WIFI_DPP_QR_CODE);
+ final Intent intent = new Intent(Settings.ACTION_PROCESS_WIFI_EASY_CONNECT_QR_CODE);
+ intent.putExtra(Settings.EXTRA_QR_CODE, VALID_WIFI_DPP_QR_CODE);
final WifiDppConfiguratorActivity hostActivity = mActivityRule.launchActivity(intent);
onView(withText(resourceString(CANCEL))).perform(click());
diff --git a/tests/unit/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java b/tests/unit/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java
index 215b7e2dc31..02e8c9cc5f0 100644
--- a/tests/unit/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java
+++ b/tests/unit/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java
@@ -21,6 +21,7 @@ import static com.google.common.truth.Truth.assertThat;
import android.content.Intent;
import android.content.pm.ActivityInfo;
+import android.provider.Settings;
import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;
@@ -65,9 +66,8 @@ public class WifiDppConfiguratorActivityTest {
@Test
public void launchActivity_chooseSavedWifiNetwork_shouldNotAutoFinish() {
- Intent intent = new Intent(
- WifiDppConfiguratorActivity.ACTION_PROCESS_WIFI_DPP_QR_CODE);
- intent.putExtra(WifiDppUtils.EXTRA_QR_CODE, VALID_WIFI_DPP_QR_CODE);
+ Intent intent = new Intent(Settings.ACTION_PROCESS_WIFI_EASY_CONNECT_QR_CODE);
+ intent.putExtra(Settings.EXTRA_QR_CODE, VALID_WIFI_DPP_QR_CODE);
mActivityRule.launchActivity(intent);
@@ -138,9 +138,8 @@ public class WifiDppConfiguratorActivityTest {
public void rotateScreen_shouldGetCorrectWifiNetworkConfig() {
WifiNetworkConfig wifiNetworkConfig = new WifiNetworkConfig("WPA", "WifiSsid", "password",
/* hiddenSsid */ false, /* networkId */ 0);
- Intent intent = new Intent(
- WifiDppConfiguratorActivity.ACTION_PROCESS_WIFI_DPP_QR_CODE);
- intent.putExtra(WifiDppUtils.EXTRA_QR_CODE, VALID_WIFI_DPP_QR_CODE);
+ Intent intent = new Intent(Settings.ACTION_PROCESS_WIFI_EASY_CONNECT_QR_CODE);
+ intent.putExtra(Settings.EXTRA_QR_CODE, VALID_WIFI_DPP_QR_CODE);
// setWifiNetworkConfig and check if getWifiNetworkConfig correctly after rotation
mActivityRule.launchActivity(intent);
diff --git a/tests/unit/src/com/android/settings/wifi/dpp/WifiNetworkListFragmentTest.java b/tests/unit/src/com/android/settings/wifi/dpp/WifiNetworkListFragmentTest.java
index 8626dee6247..18d62c25a0b 100644
--- a/tests/unit/src/com/android/settings/wifi/dpp/WifiNetworkListFragmentTest.java
+++ b/tests/unit/src/com/android/settings/wifi/dpp/WifiNetworkListFragmentTest.java
@@ -103,8 +103,7 @@ public class WifiNetworkListFragmentTest {
/** Launch the activity via an Intent with a String extra. */
private void launchActivity(String extraName, String extraValue) {
- final Intent intent = new Intent(
- WifiDppConfiguratorActivity.ACTION_PROCESS_WIFI_DPP_QR_CODE);
+ final Intent intent = new Intent(Settings.ACTION_PROCESS_WIFI_EASY_CONNECT_QR_CODE);
if (extraName != null && extraValue != null) {
intent.putExtra(extraName, extraValue);
}
@@ -168,7 +167,7 @@ public class WifiNetworkListFragmentTest {
setupConnectedAccessPoint();
when(mWifiTracker.isConnected()).thenReturn(true);
- launchActivity(WifiDppUtils.EXTRA_QR_CODE, TEST_DPP_URL);
+ launchActivity(Settings.EXTRA_QR_CODE, TEST_DPP_URL);
callOnWifiStateChanged(WifiManager.WIFI_STATE_ENABLED);
onView(withText(resourceString(WIFI_DISPLAY_STATUS_CONNECTED))).check(