Snap for 5264762 from 04c37528f0 to qt-release

Change-Id: I9d6a304bb40993bd0e5a6069b37585c7a916db8a
This commit is contained in:
android-build-team Robot
2019-01-29 04:10:02 +00:00
34 changed files with 444 additions and 98 deletions

View File

@@ -1825,7 +1825,7 @@
<activity
android:name="Settings$PrintSettingsActivity"
android:label="@string/print_settings"
android:icon="@drawable/ic_settings_print"
android:icon="@*android:drawable/ic_settings_print"
android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.ACTION_PRINT_SETTINGS" />
@@ -3048,7 +3048,7 @@
<intent-filter>
<action android:name="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER"/>
<action android:name="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR"/>
<action android:name="android.settings.PROCESS_WIFI_DPP_QR_CODE"/>
<action android:name="android.settings.PROCESS_WIFI_EASY_CONNECT_QR_CODE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>

View File

@@ -19,6 +19,6 @@
<item android:state_checked="true" android:drawable="@drawable/ic_expand_less" />
<item android:drawable="@drawable/ic_expand_more" />
<item android:drawable="@*android:drawable/ic_expand_more" />
</selector>

View File

@@ -1,30 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?android:attr/colorControlNormal">
<path
android:fillColor="#000000"
android:pathData="M8.12 9.29L12 13.17l3.88-3.88a.996 .996 0 1 1 1.41 1.41l-4.59 4.59a.996 .996 0 0
1-1.41 0L6.7 10.7a.996 .996 0 0 1 0-1.41c.39-.38 1.03-.39 1.42 0z" />
</vector>

View File

@@ -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"

View File

@@ -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"/>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</com.google.android.material.card.MaterialCardView>

View File

@@ -2688,6 +2688,15 @@
<!-- Display settings screen, display white balance settings title [CHAR LIMIT=30] -->
<string name="display_white_balance_title">Display white balance</string>
<!-- Display settings screen, setting option name to enable adaptive sleep [CHAR LIMIT=30] -->
<string name="adaptive_sleep_title">Adaptive sleep</string>
<!-- Setting option summary when adaptive sleep is on [CHAR LIMIT=NONE] -->
<string name="adaptive_sleep_summary_on">On</string>
<!-- Setting option summary when adaptive sleep is off [CHAR LIMIT=NONE] -->
<string name="adaptive_sleep_summary_off">Off</string>
<!-- Description about the feature adaptive sleep [CHAR LIMIT=NONE]-->
<string name="adaptive_sleep_description">Your screen would not dim and go to sleep if the device detects your present attention.</string>
<!-- Night display screen, setting option name to enable night display (renamed "Night Light" with title caps). [CHAR LIMIT=30] -->
<string name="night_display_title">Night Light</string>
@@ -6707,6 +6716,8 @@
<string name="help_url_display_size" translatable="false"></string>
<!-- Help URL, Auto brightness [DO NOT TRANSLATE] -->
<string name="help_url_auto_brightness" translatable="false" />
<!-- Help URL, Adaptive sleep [DO NOT TRANSLATE] -->
<string name="help_url_adaptive_sleep" translatable="false" />
<!-- Help URL, Previously connected bluetooth devices [DO NOT TRANSLATE] -->
<string name="help_url_previously_connected_devices" translatable="false"></string>
<!-- Help URL, Top level privacy settings [DO NOT TRANSLATE] -->
@@ -7047,6 +7058,9 @@
<!-- Search keywords for adaptive brightness setting [CHAR LIMIT=NONE]-->
<string name="keywords_display_auto_brightness">dim screen, touchscreen, battery, smart brightness, dynamic brightness</string>
<!-- Search keywords for adaptive sleep setting [CHAR LIMIT=NONE]-->
<string name="keywords_display_adaptive_sleep">dim screen, sleep, battery, timeout, attention</string>
<!-- List of synonyms for the auto rotate (rotate the virtual display when the device rotates) setting, used to match in settings search [CHAR LIMIT=NONE] -->
<string name="keywords_auto_rotate">rotate, flip, rotation, portrait, landscape, orientation, vertical, horizontal</string>
@@ -7317,7 +7331,7 @@
<!-- Do not disturb: Hide notifications summary [CHAR LIMIT=NONE] -->
<string name="zen_mode_restrict_notifications_hide_summary">You won\u2019t see or hear notifications</string>
<!-- Do not disturb: Hide notifications footer [CHAR LIMIT=NONE] -->
<string name="zen_mode_restrict_notifications_hide_footer">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.</string>
<string name="zen_mode_restrict_notifications_hide_footer">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.</string>
<!-- Do not disturb: Custom settings option [CHAR LIMIT=60] -->
<string name="zen_mode_restrict_notifications_custom">Custom</string>
<!-- Do not disturb: restrict notifications page, menu option [CHAR LIMIT=60] -->
@@ -8044,7 +8058,7 @@
<string name="zen_mode_calls_title">Calls</string>
<!-- [CHAR LIMIT=NONE] Zen mode settings: Calls screen footer -->
<string name="zen_mode_calls_footer">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.</string>
<string name="zen_mode_calls_footer">To be sure allowed calls make sound, check whether your device is set to ring, vibrate, or silent.</string>
<!-- [CHAR LIMIT=NONE] Zen mode custom rule settings: Calls screen footer -->
<string name="zen_mode_custom_calls_footer">For \u2018<xliff:g id="schedule_name" example="Schedule 1">%1$s</xliff:g>\u2019 incoming calls are blocked. You can adjust settings to allow your friends, family, or other contacts to reach you.</string>
@@ -8062,13 +8076,13 @@
<string name="zen_mode_messages">Allow text messages</string>
<!-- Do not disturb settings, messages, events and reminders footer [CHAR LIMIT=NONE]-->
<string name="zen_mode_messages_footer">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.</string>
<string name="zen_mode_messages_footer">To be sure allowed messages make sound, check whether your device is set to ring, vibrate, or silent.</string>
<!-- [CHAR LIMIT=NONE] Zen mode custom rule settings: Messages screen footer -->
<string name="zen_mode_custom_messages_footer">For \u2018<xliff:g id="schedule_name" example="Schedule 1">%1$s</xliff:g>\u2019 incoming text messages are blocked. You can adjust settings to allow your friends, family, or other contacts to reach you.</string>
<!-- [CHAR LIMIT=40] Zen mode settings: Allow messages to bypass DND title -->
<string name="zen_mode_messages_title">Text messages</string>
<string name="zen_mode_messages_title">SMS, MMS, and messaging apps</string>
<!-- [CHAR LIMIT=40] Zen mode settings: Calls or messages option value: From anyone -->
<string name="zen_mode_from_anyone">From anyone</string>
@@ -8104,7 +8118,7 @@
<string name="zen_mode_alarms_list">alarms</string>
<!-- [CHAR LIMIT=80] Zen mode settings: Allow media (sound from video) to bypass dnd -->
<string name="zen_mode_media">Allow media sounds</string>
<string name="zen_mode_media">Play media sounds</string>
<!-- [CHAR LIMIT=50] Zen mode settings: Media (ie: sound from video) -->
<string name="zen_mode_media_list">media</string>

View File

@@ -284,14 +284,8 @@
<item name="android:textSize">@dimen/search_bar_text_size</item>
</style>
<style name="TextAppearance.SuggestionHeader"
parent="@*android:style/TextAppearance.DeviceDefault.Subhead">
<item name="android:textSize">14sp</item>
<item name="android:textColor">?android:attr/colorAccent</item>
</style>
<style name="TextAppearance.ConditionCardTitle"
parent="@*android:style/TextAppearance.DeviceDefault.Body2">
parent="@*android:style/TextAppearance.DeviceDefault.Subhead">
<item name="android:textSize">16sp</item>
</style>
@@ -304,7 +298,7 @@
<item name="android:fontFamily">sans-serif-medium</item>
<item name="android:textSize">14sp</item>
<item name="android:textColor">?android:attr/colorAccent</item>
<item name="android:background">@drawable/btn_borderless_rect</item>
<item name="android:background">@*android:drawable/btn_borderless_rect</item>
<item name="android:gravity">center</item>
<item name="android:focusable">true</item>
<item name="android:padding">8dp</item>

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="adaptive_sleep_detail"
android:title="@string/adaptive_sleep_title">
<!-- TODO(111939367): add correct animation -->
<com.android.settings.widget.VideoPreference
android:key="adaptive_sleep_video"
android:title="@string/summary_placeholder"
settings:animation="@raw/aab_brightness"
settings:preview="@drawable/aab_brightness"
settings:controller="com.android.settings.widget.VideoPreferenceController"/>
<com.android.settingslib.RestrictedSwitchPreference
android:key="adaptive_sleep"
android:title="@string/adaptive_sleep_title"
settings:keywords="@string/keywords_display_adaptive_sleep"
settings:controller="com.android.settings.display.AdaptiveSleepPreferenceController"
settings:useAdminDisabledSummary="true"
settings:allowDividerAbove="true" />
</PreferenceScreen>

View File

@@ -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"/>

View File

@@ -66,6 +66,13 @@
android:entryValues="@array/screen_timeout_values"
settings:keywords="@string/keywords_screen_timeout" />
<Preference
android:key="adaptive_sleep_entry"
android:title="@string/adaptive_sleep_title"
android:summary="@string/summary_placeholder"
android:fragment="com.android.settings.display.AdaptiveSleepSettings"
settings:controller="com.android.settings.display.AdaptiveSleepPreferenceController" />
<SwitchPreference
android:key="auto_rotate"
android:title="@string/accelerometer_title"

View File

@@ -137,7 +137,7 @@ public class BluetoothDeviceDetailsFragment extends RestrictedDashboardFragment
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
MenuItem item = menu.add(0, EDIT_DEVICE_NAME_ITEM_ID, 0, R.string.bluetooth_rename_button);
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);
}

View File

@@ -73,7 +73,7 @@ public class BluetoothSliceBuilder {
final boolean isBluetoothEnabled = isBluetoothEnabled();
final CharSequence title = context.getText(R.string.bluetooth_settings);
final IconCompat icon = IconCompat.createWithResource(context,
R.drawable.ic_settings_bluetooth);
com.android.internal.R.drawable.ic_settings_bluetooth);
@ColorInt final int color = com.android.settings.Utils.getColorAccent(
context).getDefaultColor();
final PendingIntent toggleAction = getBroadcastIntent(context);

View File

@@ -0,0 +1,68 @@
/*
* 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 android.content.Context;
import android.provider.Settings;
import android.text.TextUtils;
import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
public class AdaptiveSleepPreferenceController extends TogglePreferenceController {
private final String SYSTEM_KEY = ADAPTIVE_SLEEP;
private final int DEFAULT_VALUE = 0;
public AdaptiveSleepPreferenceController(Context context, String key) {
super(context, key);
}
@Override
public boolean isChecked() {
return Settings.System.getInt(mContext.getContentResolver(),
SYSTEM_KEY, DEFAULT_VALUE) != DEFAULT_VALUE;
}
@Override
public boolean setChecked(boolean isChecked) {
Settings.System.putInt(mContext.getContentResolver(), SYSTEM_KEY,
isChecked ? 1 : DEFAULT_VALUE);
return true;
}
@Override
@AvailabilityStatus
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(
com.android.internal.R.bool.config_adaptive_sleep_available)
? AVAILABLE
: UNSUPPORTED_ON_DEVICE;
}
@Override
public boolean isSliceable() {
return true;
}
@Override
public CharSequence getSummary() {
return mContext.getText(isChecked()
? R.string.adaptive_sleep_summary_on
: R.string.adaptive_sleep_summary_off);
}
}

View File

@@ -0,0 +1,74 @@
/*
* 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.settings.SettingsEnums;
import android.content.Context;
import android.os.Bundle;
import android.provider.SearchIndexableResource;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.search.SearchIndexable;
import java.util.Arrays;
import java.util.List;
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
public class AdaptiveSleepSettings extends DashboardFragment {
private static final String TAG = "AdaptiveSleepSettings";
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
mFooterPreferenceMixin.createFooterPreference()
.setTitle(R.string.adaptive_sleep_description);
}
@Override
protected int getPreferenceScreenResId() {
return R.xml.adaptive_sleep_detail;
}
@Override
protected String getLogTag() {
return TAG;
}
@Override
public int getMetricsCategory() {
return SettingsEnums.SETTINGS_ADAPTIVE_SLEEP;
}
@Override
public int getHelpResource() {
return R.string.help_url_adaptive_sleep;
}
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
@Override
public List<SearchIndexableResource> getXmlResourcesToIndex(
Context context, boolean enabled) {
final SearchIndexableResource sir = new SearchIndexableResource(context);
sir.xmlResId = R.xml.adaptive_sleep_detail;
return Arrays.asList(sir);
}
};
}

View File

@@ -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);

View File

@@ -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 */);
}
}
}

View File

@@ -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();

View File

@@ -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)

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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,

View File

@@ -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.

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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

View File

@@ -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());
}

View File

@@ -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();
}
}

View File

@@ -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);
}
}
}

View File

@@ -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());
}
}

View File

@@ -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());

View File

@@ -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);

View File

@@ -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(