Merge "Clear unused field mPowerUsageFeatureProvider in PowerUsageAdvanced."
diff --git a/res-export/drawable/ic_find_device_disabled.xml b/res-export/drawable/ic_find_device_disabled.xml
new file mode 100644
index 0000000..21e92c9
--- /dev/null
+++ b/res-export/drawable/ic_find_device_disabled.xml
@@ -0,0 +1,25 @@
+<!--
+ 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+
+ <path
+ android:fillColor="#FFF44336"
+ android:pathData="M12,2C8.13,2 5,5.13 5,9c0,5.25 7,13 7,13s7,-7.75 7,-13C19,5.13 15.87,2 12,2zM7,9c0,-2.76 2.24,-5 5,-5s5,2.24 5,5c0,2.88 -2.88,7.19 -5,9.88C9.92,16.21 7,11.85 7,9zM11,13h2v2h-2V13zM13,6h-2v5h2V6z"/>
+</vector>
diff --git a/res-export/drawable/ic_find_device_enabled.xml b/res-export/drawable/ic_find_device_enabled.xml
new file mode 100644
index 0000000..614ac6d
--- /dev/null
+++ b/res-export/drawable/ic_find_device_enabled.xml
@@ -0,0 +1,25 @@
+<!--
+ 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+
+ <path
+ android:fillColor="#FF43A047"
+ android:pathData="M12,2C8.13,2 5,5.13 5,9c0,5.25 7,13 7,13s7,-7.75 7,-13C19,5.13 15.87,2 12,2zM7,9c0,-2.76 2.24,-5 5,-5s5,2.24 5,5c0,2.88 -2.88,7.19 -5,9.88C9.92,16.21 7,11.85 7,9zM14.5,9c0,1.38 -1.12,2.5 -2.5,2.5S9.5,10.38 9.5,9s1.12,-2.5 2.5,-2.5S14.5,7.62 14.5,9z"/>
+</vector>
diff --git a/res-export/drawable/ic_package_verifier_disabled.xml b/res-export/drawable/ic_package_verifier_disabled.xml
new file mode 100644
index 0000000..49fe0d3
--- /dev/null
+++ b/res-export/drawable/ic_package_verifier_disabled.xml
@@ -0,0 +1,25 @@
+<!--
+ 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+
+ <path
+ android:fillColor="#FFEF6C00"
+ android:pathData="M12,4.24l6,3v4.1c0,3.9 -2.55,7.5 -6,8.59c-3.45,-1.09 -6,-4.7 -6,-8.59v-4.1L12,4.24M12,2L4,6v5.33c0,4.93 3.41,9.55 8,10.67c4.59,-1.12 8,-5.73 8,-10.67V6L12,2L12,2zM11,15h2v2h-2V15zM13,8h-2v5h2V8z"/>
+</vector>
diff --git a/res-export/drawable/ic_package_verifier_enabled.xml b/res-export/drawable/ic_package_verifier_enabled.xml
new file mode 100644
index 0000000..1e09eee
--- /dev/null
+++ b/res-export/drawable/ic_package_verifier_enabled.xml
@@ -0,0 +1,25 @@
+<!--
+ 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+
+ <path
+ android:fillColor="#FF43A047"
+ android:pathData="M11.14,16l-3.84,-3.84l1.41,-1.42l2.43,2.42l4.16,-4.16l1.42,1.41L11.14,16zM12,4.24l6,3v4.1c0,3.9 -2.55,7.5 -6,8.59c-3.45,-1.09 -6,-4.7 -6,-8.59v-4.1L12,4.24M12,2L4,6v5.33c0,4.93 3.41,9.55 8,10.67c4.59,-1.12 8,-5.73 8,-10.67V6L12,2L12,2z"/>
+</vector>
diff --git a/res/values/bools.xml b/res-export/values/bools.xml
similarity index 100%
rename from res/values/bools.xml
rename to res-export/values/bools.xml
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5494acf..fbae241 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -130,10 +130,30 @@
<string name="bluetooth_pair_other_ear_dialog_right_ear_positive_button">Pair right ear</string>
<!-- Connected devices settings. Positive button of the dialog to help user to pair left ear of the hearing aid device. Dialog shows when only one of the hearing aid device set is connected. [CHAR LIMIT=20] -->
<string name="bluetooth_pair_other_ear_dialog_left_ear_positive_button">Pair left ear</string>
-
+ <!-- Connected devices settings. Title of the preference to show the entrance of the hearing device controls page. [CHAR LIMIT=35] -->
+ <string name="bluetooth_device_controls_title">Hearing device controls</string>
+ <!-- Connected devices settings. Summary of the preference to show the entrance of the hearing device controls page. [CHAR LIMIT=NONE] -->
+ <string name="bluetooth_device_controls_summary">Hearing device shortcut, hearing aid compatibility</string>
+ <!-- Connected devices settings. Title of the preference to show the entrance of the audio output page. It can change different types of audio are played on phone or other bluetooth devices. [CHAR LIMIT=35] -->
+ <string name="bluetooth_audio_routing_title">Audio output</string>
+ <!-- Connected devices settings. Summary of the preference to show the entrance of the audio output page. [CHAR LIMIT=NONE] -->
+ <string name="bluetooth_audio_routing_summary">Choose whether different types of audio are played on your hearing device or phone speaker</string>
<!-- Title for related tools section. This section will list related tools below. [CHAR LIMIT=15] -->
<string name="bluetooth_screen_related">Related</string>
+ <!-- Bluetooth audio output settings. Title of the option managing ringtone audio path. [CHAR LIMIT=30] -->
+ <string name="bluetooth_ringtone_title">Ringtone</string>
+ <!-- Bluetooth audio output settings. Title of the option managing call audio path. [CHAR LIMIT=30] -->
+ <string name="bluetooth_call_title">Call</string>
+ <!-- Bluetooth audio output settings. Title of the option managing media audio path. [CHAR LIMIT=30] -->
+ <string name="bluetooth_media_title">Media</string>
+ <!-- Bluetooth audio output settings. Title of the option managing system sounds audio path. [CHAR LIMIT=30] -->
+ <string name="bluetooth_system_sounds_title">System sounds</string>
+ <!-- Bluetooth audio output settings. Title of the option to play audio on hearing aids. [CHAR LIMIT=40] -->
+ <string name="bluetooth_audio_path_hearing_device_title">Play on hearing device</string>
+ <!-- Bluetooth audio output settings. Title of the option to play audio on phone speaker. [CHAR LIMIT=40] -->
+ <string name="bluetooth_audio_path_phone_speaker_title">Play on phone speaker</string>
+
<!--Bluetooth settings screen, summary text for Bluetooth device with no name -->
<string name="bluetooth_device">Unnamed Bluetooth device</string>
<!--Bluetooth settings screen, text that appears in heading bar when scanning for devices -->
@@ -4221,8 +4241,8 @@
<!-- Button text for the accessibility dialog continue to the next screen for hearing aid. [CHAR LIMIT=32] -->
<string name="accessibility_hearingaid_instruction_continue_button">Continue</string>
- <!-- Title for the accessibility preference for hearing aid. [CHAR LIMIT=35] -->
- <string name="accessibility_hearingaid_title">Hearing aids</string>
+ <!-- Title for the accessibility preference for hearing devices. [CHAR LIMIT=35] -->
+ <string name="accessibility_hearingaid_title">Hearing devices</string>
<!-- Summary for the accessibility preference for hearing aid when not connected. [CHAR LIMIT=50] -->
<string name="accessibility_hearingaid_not_connected_summary">No hearing aids connected</string>
<!-- Summary for the accessibility preference for hearing aid when adding new devices. [CHAR LIMIT=50] -->
@@ -4241,6 +4261,29 @@
<string name="accessibility_hearingaid_left_and_right_side_device_summary"><xliff:g id="device_name" example="GN Hearing Aids">%1$s</xliff:g>, left and right</string>
<!-- Summary for the accessibility preference for hearing aid when there are more than one set of devices are active. [CHAR LIMIT=50] -->
<string name="accessibility_hearingaid_more_device_summary"><xliff:g id="device_name" example="GN Hearing Aids">%1$s</xliff:g> +1 more</string>
+ <!-- Title for the hearing device pairing preference. [CHAR LIMIT=20] -->
+ <string name="accessibility_hearing_device_pairing_title">Pair new device</string>
+ <!-- Title for the preference category containing the connected hearing device group. [CHAR LIMIT=20]-->
+ <string name="accessibility_hearing_device_saved_title">Saved devices</string>
+ <!-- Title for the preference category containing the controls of the hearing device. [CHAR LIMIT=35] -->
+ <string name="accessibility_hearing_device_control">Hearing device controls</string>
+ <!-- Title for the accessibility preference for hearing devices. [CHAR LIMIT=35] -->
+ <string name="accessibility_hearing_device_shortcut_title">Hearing device shortcut</string>
+ <!-- Title for the Hearing Aid Compatibility preference in the accessibility page. [CHAR LIMIT=35] -->
+ <string name="accessibility_hac_mode_title">Hearing aid compatibility</string>
+ <!--Summary for the Hearing Aid Compatibility preference in the accessibility page. [CHAR LIMIT=NONE] -->
+ <string name="accessibility_hac_mode_summary">Improve audio for some hearing devices</string>
+ <!-- Description for text in accessibility hearing aids footer. [CHAR LIMIT=NONE] -->
+ <string name="accessibility_hearing_device_footer_summary">Make sure your hearing devices are turned on and in pairing mode</string>
+ <!-- Title for the pair hearing device page. [CHAR LIMIT=25] -->
+ <string name="accessibility_hearing_device_pairing_page_title">Pair hearing device</string>
+ <!-- Title for the preference category containing the list of the available hearing during and after bluetooth scanning devices. [CHAR LIMIT=30] -->
+ <string name="accessibility_found_hearing_devices">Available devices</string>
+ <!-- Title for the preference category containing the all bluetooth devices during and after bluetooth scanning devices. Used when people can not find their hearing device in hearing device pairing list. [CHAR LIMIT=45] -->
+ <string name="accessibility_found_all_devices">Don\u2019t see your hearing device?</string>
+ <!-- Title for listing all bluetooth devices preference in the accessibility page. [CHAR LIMIT=40] -->
+ <string name="accessibility_list_all_devices_title">View all Bluetooth devices</string>
+
<!-- Title for the accessibility audio adjustment page. [CHAR LIMIT=50] -->
<string name="accessibility_audio_adjustment_title">Audio adjustment</string>
<!-- Title for control audio description preference. [CHAR LIMIT=50] -->
diff --git a/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java b/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
index e48d745..691cbd6 100644
--- a/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
+++ b/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
@@ -51,6 +51,8 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
@SearchIndexable
public class MyDeviceInfoFragment extends DashboardFragment
@@ -105,14 +107,9 @@
Context context, MyDeviceInfoFragment fragment, Lifecycle lifecycle) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
- final SlotSimStatus slotSimStatus = new SlotSimStatus(context);
- for (int slotIndex = 0; slotIndex < slotSimStatus.size(); slotIndex ++) {
- SimStatusPreferenceController slotRecord =
- new SimStatusPreferenceController(context,
- slotSimStatus.getPreferenceKey(slotIndex));
- slotRecord.init(fragment, slotSimStatus);
- controllers.add(slotRecord);
- }
+ final ExecutorService executor = (fragment == null) ? null :
+ Executors.newSingleThreadExecutor();
+ final SlotSimStatus slotSimStatus = new SlotSimStatus(context, executor);
controllers.add(new IpAddressPreferenceController(context, lifecycle));
controllers.add(new WifiMacAddressPreferenceController(context, lifecycle));
@@ -123,6 +120,17 @@
controllers.add(new FeedbackPreferenceController(fragment, context));
controllers.add(new FccEquipmentIdPreferenceController(context));
controllers.add(new UptimePreferenceController(context, lifecycle));
+
+ for (int slotIndex = 0; slotIndex < slotSimStatus.size(); slotIndex ++) {
+ SimStatusPreferenceController slotRecord =
+ new SimStatusPreferenceController(context,
+ slotSimStatus.getPreferenceKey(slotIndex));
+ slotRecord.init(fragment, slotSimStatus);
+ controllers.add(slotRecord);
+ }
+ if (executor != null) {
+ executor.shutdown();
+ }
return controllers;
}
diff --git a/src/com/android/settings/deviceinfo/simstatus/SlotSimStatus.java b/src/com/android/settings/deviceinfo/simstatus/SlotSimStatus.java
index 7056181..033222a 100644
--- a/src/com/android/settings/deviceinfo/simstatus/SlotSimStatus.java
+++ b/src/com/android/settings/deviceinfo/simstatus/SlotSimStatus.java
@@ -21,6 +21,10 @@
import android.telephony.SubscriptionManager;
import android.util.Log;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Phaser;
+import java.util.concurrent.atomic.AtomicInteger;
+
/**
* A class for showing a summary of status of sim slots.
*/
@@ -28,7 +32,8 @@
private static final String TAG = "SlotSimStatus";
- private int mNumberOfSlots;
+ private final AtomicInteger mNumberOfSlots = new AtomicInteger(0);
+ private final Phaser mBlocker = new Phaser(1);
private int mBasePreferenceOrdering;
private static final String KEY_SIM_STATUS = "sim_status";
@@ -38,11 +43,32 @@
* @param context Context
*/
public SlotSimStatus(Context context) {
- TelephonyManager telMgr = context.getSystemService(TelephonyManager.class);
- if (telMgr == null) {
- return;
+ this(context, null);
+ }
+
+ /**
+ * Construct of class.
+ * @param context Context
+ * @param executor executor for offload to thread
+ */
+ public SlotSimStatus(Context context, Executor executor) {
+ if (executor == null) {
+ queryRecords(context);
+ } else {
+ executor.execute(() -> queryRecords(context));
}
- mNumberOfSlots = telMgr.getPhoneCount();
+ }
+
+ protected void queryRecords(Context context) {
+ TelephonyManager telMgr = context.getSystemService(TelephonyManager.class);
+ if (telMgr != null) {
+ mNumberOfSlots.set(telMgr.getPhoneCount());
+ }
+ mBlocker.arrive();
+ }
+
+ protected void waitForResult() {
+ mBlocker.awaitAdvance(0);
}
/**
@@ -58,7 +84,8 @@
* @return number of slots
*/
public int size() {
- return mNumberOfSlots;
+ waitForResult();
+ return mNumberOfSlots.get();
}
/**
diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceController.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceController.java
index 707c5b2..c2eab57 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceController.java
@@ -319,7 +319,8 @@
}
- if (mOnBatteryUsageUpdatedListener != null) {
+ if (mOnBatteryUsageUpdatedListener != null && mBatteryUsageMap != null
+ && mBatteryUsageMap.get(mDailyChartIndex) != null) {
final BatteryDiffData slotUsageData =
mBatteryUsageMap.get(mDailyChartIndex).get(mHourlyChartIndex);
mOnBatteryUsageUpdatedListener.onBatteryUsageUpdated(
@@ -359,6 +360,9 @@
mDailyChartIndex = 0;
} else {
mDailyChartView.setVisibility(View.VISIBLE);
+ if (mDailyChartIndex >= mDailyViewModel.size()) {
+ mDailyChartIndex = BatteryChartViewModel.SELECTED_INDEX_ALL;
+ }
mDailyViewModel.setSelectedIndex(mDailyChartIndex);
mDailyChartView.setViewModel(mDailyViewModel);
}
@@ -370,6 +374,9 @@
animateBatteryHourlyChartView(/*visible=*/ true);
final BatteryChartViewModel hourlyViewModel =
mHourlyViewModels.get(mDailyChartIndex);
+ if (mHourlyChartIndex >= hourlyViewModel.size()) {
+ mHourlyChartIndex = BatteryChartViewModel.SELECTED_INDEX_ALL;
+ }
hourlyViewModel.setSelectedIndex(mHourlyChartIndex);
mHourlyChartView.setViewModel(hourlyViewModel);
}
diff --git a/src/com/android/settings/network/BluetoothWiFiResetPreferenceController.java b/src/com/android/settings/network/BluetoothWiFiResetPreferenceController.java
index c469304..6eb470b 100644
--- a/src/com/android/settings/network/BluetoothWiFiResetPreferenceController.java
+++ b/src/com/android/settings/network/BluetoothWiFiResetPreferenceController.java
@@ -125,7 +125,7 @@
final AtomicReference<Exception> exceptionDuringReset =
new AtomicReference<Exception>();
try {
- resetOperation();
+ resetOperation().run();
} catch (Exception exception) {
exceptionDuringReset.set(exception);
}
@@ -144,13 +144,28 @@
}
@VisibleForTesting
- protected void resetOperation() throws Exception {
- new ResetNetworkRequest(
+ protected Runnable resetOperation() throws Exception {
+ if (SubscriptionUtil.isSimHardwareVisible(mContext)) {
+ return new ResetNetworkRequest(
+ ResetNetworkRequest.RESET_WIFI_MANAGER |
+ ResetNetworkRequest.RESET_WIFI_P2P_MANAGER |
+ ResetNetworkRequest.RESET_BLUETOOTH_MANAGER)
+ .toResetNetworkOperationBuilder(mContext, Looper.getMainLooper())
+ .build();
+ }
+
+ /**
+ * For device without SIMs visible to the user
+ */
+ return new ResetNetworkRequest(
+ ResetNetworkRequest.RESET_CONNECTIVITY_MANAGER |
+ ResetNetworkRequest.RESET_VPN_MANAGER |
ResetNetworkRequest.RESET_WIFI_MANAGER |
ResetNetworkRequest.RESET_WIFI_P2P_MANAGER |
- ResetNetworkRequest.RESET_BLUETOOTH_MANAGER
- ).toResetNetworkOperationBuilder(mContext, Looper.getMainLooper())
- .build().run();
+ ResetNetworkRequest.RESET_BLUETOOTH_MANAGER)
+ .toResetNetworkOperationBuilder(mContext, Looper.getMainLooper())
+ .resetTelephonyAndNetworkPolicyManager(ResetNetworkRequest.ALL_SUBSCRIPTION_ID)
+ .build();
}
@VisibleForTesting
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index b66e2af..ac2b26b 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -590,6 +590,7 @@
}
private void onAddGuestClicked() {
+ Context context = getContext();
final UserCreatingDialog guestCreatingDialog =
new UserCreatingDialog(getActivity(), /* isGuest= */ true);
guestCreatingDialog.show();
@@ -597,18 +598,18 @@
ThreadUtils.postOnBackgroundThread(() -> {
mMetricsFeatureProvider.action(getActivity(), SettingsEnums.ACTION_USER_GUEST_ADD);
Trace.beginSection("UserSettings.addGuest");
- final UserInfo guest = mUserManager.createGuest(getContext());
+ final UserInfo guest = mUserManager.createGuest(context);
Trace.endSection();
ThreadUtils.postOnMainThread(() -> {
guestCreatingDialog.dismiss();
if (guest == null) {
- Toast.makeText(getContext(),
+ Toast.makeText(context,
com.android.settingslib.R.string.add_guest_failed,
Toast.LENGTH_SHORT).show();
return;
}
- openUserDetails(guest, true);
+ openUserDetails(guest, true, context);
});
});
}
@@ -622,14 +623,10 @@
}
}
- private void onUserCreated(UserInfo userInfo) {
+ private void onUserCreated(UserInfo userInfo, Context context) {
hideUserCreatingDialog();
- // prevent crash when config changes during user creation
- if (getContext() == null) {
- return;
- }
mAddingUser = false;
- openUserDetails(userInfo, true);
+ openUserDetails(userInfo, true, context);
}
private void hideUserCreatingDialog() {
@@ -646,11 +643,21 @@
}
private void openUserDetails(UserInfo userInfo, boolean newUser) {
+ openUserDetails(userInfo, newUser, getContext());
+ }
+
+ private void openUserDetails(UserInfo userInfo, boolean newUser, Context context) {
+ // to prevent a crash when config changes during user creation,
+ // we simply ignore this redirection step
+ if (context == null) {
+ return;
+ }
+
Bundle extras = new Bundle();
extras.putInt(UserDetailsSettings.EXTRA_USER_ID, userInfo.id);
extras.putBoolean(AppRestrictionsFragment.EXTRA_NEW_USER, newUser);
- SubSettingLauncher launcher = new SubSettingLauncher(getContext())
+ SubSettingLauncher launcher = new SubSettingLauncher(context)
.setDestination(UserDetailsSettings.class.getName())
.setArguments(extras)
.setTitleText(userInfo.name)
@@ -1013,6 +1020,9 @@
@VisibleForTesting
void createUser(final int userType, String userName) {
+ Context context = getContext();
+ Resources resources = getResources();
+ final Drawable selectedUserIcon = mPendingUserIcon;
Future<?> unusedCreateUserFuture = ThreadUtils.postOnBackgroundThread(() -> {
UserInfo user;
@@ -1035,19 +1045,19 @@
}
Future<?> unusedSettingIconFuture = ThreadUtils.postOnBackgroundThread(() -> {
- Drawable newUserIcon = mPendingUserIcon;
+ Drawable newUserIcon = selectedUserIcon;
if (newUserIcon == null) {
- newUserIcon = UserIcons.getDefaultUserIcon(getResources(), user.id, false);
+ newUserIcon = UserIcons.getDefaultUserIcon(resources, user.id, false);
}
mUserManager.setUserIcon(
user.id, UserIcons.convertToBitmapAtUserIconSize(
- getResources(), newUserIcon));
+ resources, newUserIcon));
});
mPendingUserIcon = null;
mPendingUserName = null;
- onUserCreated(user);
+ onUserCreated(user, context);
});
});
}
diff --git a/src/com/android/settings/wifi/NetworkRequestDialogFragment.java b/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
index 5fe156c..5639047 100644
--- a/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
+++ b/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
@@ -16,7 +16,7 @@
package com.android.settings.wifi;
-import static com.android.settings.wifi.WifiUtils.getWifiEntrySecurity;
+import static com.android.wifitrackerlib.Utils.getSecurityTypesFromScanResult;
import static java.util.stream.Collectors.toList;
@@ -77,8 +77,12 @@
private static final int MAX_NUMBER_LIST_ITEM = 5;
private boolean mShowLimitedItem = true;
+ private static class MatchWifi {
+ String mSsid;
+ List<Integer> mSecurityTypes;
+ }
+ private List<MatchWifi> mMatchWifis = new ArrayList<>();
@VisibleForTesting List<WifiEntry> mFilteredWifiEntries = new ArrayList<>();
- @VisibleForTesting List<ScanResult> mMatchedScanResults = new ArrayList<>();
private WifiEntryAdapter mDialogAdapter;
private NetworkRequestUserSelectionCallback mUserSelectionCallback;
@@ -237,7 +241,7 @@
/** Called when the state of Wifi has changed. */
@Override
public void onWifiStateChanged() {
- if (mMatchedScanResults.size() == 0) {
+ if (mMatchWifis.size() == 0) {
return;
}
updateWifiEntries();
@@ -249,7 +253,7 @@
*/
@Override
public void onWifiEntriesChanged() {
- if (mMatchedScanResults.size() == 0) {
+ if (mMatchWifis.size() == 0) {
return;
}
updateWifiEntries();
@@ -275,16 +279,24 @@
wifiEntries.addAll(mWifiPickerTracker.getWifiEntries());
mFilteredWifiEntries.clear();
- mFilteredWifiEntries.addAll(wifiEntries.stream().filter(entry -> {
- for (ScanResult matchedScanResult : mMatchedScanResults) {
- if (TextUtils.equals(entry.getSsid(), matchedScanResult.SSID)
- && entry.getSecurity() == getWifiEntrySecurity(matchedScanResult)) {
+ mFilteredWifiEntries.addAll(wifiEntries.stream()
+ .filter(entry -> isMatchedWifiEntry(entry))
+ .limit(mShowLimitedItem ? MAX_NUMBER_LIST_ITEM : Long.MAX_VALUE)
+ .collect(toList()));
+ }
+
+ private boolean isMatchedWifiEntry(WifiEntry entry) {
+ for (MatchWifi wifi : mMatchWifis) {
+ if (!TextUtils.equals(entry.getSsid(), wifi.mSsid)) {
+ continue;
+ }
+ for (Integer security : wifi.mSecurityTypes) {
+ if (entry.getSecurityTypes().contains(security)) {
return true;
}
}
- return false;
- }).limit(mShowLimitedItem ? MAX_NUMBER_LIST_ITEM : Long.MAX_VALUE)
- .collect(toList()));
+ }
+ return false;
}
private class WifiEntryAdapter extends ArrayAdapter<WifiEntry> {
@@ -350,7 +362,14 @@
@Override
public void onMatch(List<ScanResult> scanResults) {
- mMatchedScanResults = scanResults;
+ mMatchWifis.clear();
+ for (ScanResult scanResult : scanResults) {
+ MatchWifi matchWifi = new MatchWifi();
+ matchWifi.mSsid = scanResult.SSID;
+ matchWifi.mSecurityTypes = getSecurityTypesFromScanResult(scanResult);
+ mMatchWifis.add(matchWifi);
+ }
+
updateWifiEntries();
updateUi();
}
diff --git a/tests/robotests/src/com/android/settings/network/BluetoothWiFiResetPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/BluetoothWiFiResetPreferenceControllerTest.java
index 4714afe..3aea4a8 100644
--- a/tests/robotests/src/com/android/settings/network/BluetoothWiFiResetPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/BluetoothWiFiResetPreferenceControllerTest.java
@@ -17,15 +17,24 @@
package com.android.settings.network;
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import android.content.Context;
+import android.content.res.Resources;
+import android.net.ConnectivityManager;
+import android.os.UserManager;
+import android.telephony.TelephonyManager;
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;
@@ -36,23 +45,69 @@
private static final String PREFERENCE_KEY = "network_reset_bluetooth_wifi_pref";
+ @Mock
+ private UserManager mUserManager;
+ @Mock
+ private Resources mResources;
+ @Mock
+ private ConnectivityManager mConnectivityManager;
+ @Mock
+ private TelephonyManager mTelephonyManager;
+
private Context mContext;
- private BluetoothWiFiResetPreferenceController mTarget;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
+ when(mContext.getResources()).thenReturn(mResources);
- mTarget = spy(new BluetoothWiFiResetPreferenceController(mContext, PREFERENCE_KEY));
+ mockService(Context.CONNECTIVITY_SERVICE, ConnectivityManager.class,
+ mConnectivityManager);
+ mockService(Context.TELEPHONY_SERVICE, TelephonyManager.class, mTelephonyManager);
+ }
+
+ @Test
+ public void getAvailabilityStatus_returnAvailable_asOwnerUser() {
+ mockService(Context.USER_SERVICE, UserManager.class, mUserManager);
+ doReturn(true).when(mUserManager).isAdminUser();
+
+ BluetoothWiFiResetPreferenceController target =
+ new BluetoothWiFiResetPreferenceController(mContext, PREFERENCE_KEY);
+
+ assertThat(target.getAvailabilityStatus()).isEqualTo(
+ BluetoothWiFiResetPreferenceController.AVAILABLE);
+ }
+
+ @Test
+ public void resetOperation_notResetConnectivity_onDeviceWithSimVisible() {
+ mockService(Context.CONNECTIVITY_SERVICE, ConnectivityManager.class,
+ mConnectivityManager);
+ when(mResources.getBoolean(R.bool.config_show_sim_info)).thenReturn(true);
+
+ BluetoothWiFiResetPreferenceController target =
+ new BluetoothWiFiResetPreferenceController(mContext, PREFERENCE_KEY);
+
+ try {
+ target.resetOperation().run();
+ } catch (Exception exception) {}
+ verify(mConnectivityManager, never()).factoryReset();
}
@Test
public void endOfReset_toastMessage_whenSuccess() {
- mTarget.endOfReset(null);
+ String testText = "reset_bluetooth_wifi_complete_toast";
+ when(mResources.getString(R.string.reset_bluetooth_wifi_complete_toast)).thenReturn(testText);
+ BluetoothWiFiResetPreferenceController target =
+ new BluetoothWiFiResetPreferenceController(mContext, PREFERENCE_KEY);
- assertThat(ShadowToast.getTextOfLatestToast()).isEqualTo(
- mContext.getString(R.string.reset_bluetooth_wifi_complete_toast));
+ target.endOfReset(null);
+
+ assertThat(ShadowToast.getTextOfLatestToast()).isEqualTo(testText);
}
+ private <T> void mockService(String serviceName, Class<T> serviceClass, T service) {
+ when(mContext.getSystemServiceName(serviceClass)).thenReturn(serviceName);
+ when(mContext.getSystemService(serviceName)).thenReturn(service);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
index 6261db9..386f66d 100644
--- a/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
@@ -16,6 +16,9 @@
package com.android.settings.wifi;
+import static com.android.wifitrackerlib.WifiEntry.SECURITY_PSK;
+import static com.android.wifitrackerlib.WifiEntry.SECURITY_SAE;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
@@ -47,16 +50,20 @@
import org.junit.Before;
import org.junit.Ignore;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InOrder;
-import org.mockito.MockitoAnnotations;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
@RunWith(RobolectricTestRunner.class)
@@ -64,15 +71,34 @@
public class NetworkRequestDialogFragmentTest {
private static final String KEY_SSID = "key_ssid";
- private static final String KEY_SECURITY = "key_security";
+ private static final String TEST_CAPABILITIES_OPEN = "[ESS]";
+ private static final String TEST_CAPABILITIES_WPA2_PSK = "[WPA2-PSK-CCMP][ESS]";
+ private static final String TEST_CAPABILITIES_WPA3_SAE = "[RSN-PSK+SAE-CCMP][ESS]";
private static final String TEST_APP_NAME = "TestAppName";
+ @Rule
+ public final MockitoRule mMockitoRule = MockitoJUnit.rule();
+ @Mock
+ WifiPickerTracker mWifiPickerTracker;
+ @Mock
+ WifiEntry mWifiEntry;
+
private FragmentActivity mActivity;
private NetworkRequestDialogFragment networkRequestDialogFragment;
+ ScanResult mScanResult = new ScanResult();
+
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
+ when(mWifiEntry.getSsid()).thenReturn(KEY_SSID);
+ when(mWifiEntry.getSecurityTypes()).thenReturn(Arrays.asList(SECURITY_PSK, SECURITY_SAE));
+ when(mWifiEntry.getSecurity()).thenReturn(SECURITY_PSK);
+ when(mWifiPickerTracker.getConnectedWifiEntry()).thenReturn(null);
+ when(mWifiPickerTracker.getWifiEntries()).thenReturn(Arrays.asList(mWifiEntry));
+
+ mScanResult.SSID = KEY_SSID;
+ mScanResult.capabilities = TEST_CAPABILITIES_OPEN;
+
FakeFeatureFactory fakeFeatureFactory = FakeFeatureFactory.setupForTest();
when(fakeFeatureFactory.wifiTrackerLibProvider.createWifiPickerTracker(
any(), any(), any(), any(), any(), anyLong(), anyLong(), any()))
@@ -82,7 +108,7 @@
new Intent().putExtra(NetworkRequestDialogFragment.EXTRA_APP_NAME,
TEST_APP_NAME)).setup().get();
networkRequestDialogFragment = spy(NetworkRequestDialogFragment.newInstance());
- networkRequestDialogFragment.mWifiPickerTracker = mock(WifiPickerTracker.class);
+ networkRequestDialogFragment.mWifiPickerTracker = mWifiPickerTracker;
}
@Ignore
@@ -151,12 +177,10 @@
@Test
public void onWifiStateChanged_nonEmptyMatchedScanResults_shouldUpdateWifiEntries() {
final InOrder inOrder = inOrder(networkRequestDialogFragment);
+ mScanResult.capabilities = TEST_CAPABILITIES_OPEN;
+ networkRequestDialogFragment.onMatch(Arrays.asList(mScanResult));
- final List<ScanResult> scanResults = new ArrayList<>();
- networkRequestDialogFragment.mMatchedScanResults = scanResults;
- ScanResult scanResult = mock(ScanResult.class);
- networkRequestDialogFragment.mMatchedScanResults.add(scanResult);
- networkRequestDialogFragment.onMatch(scanResults);
+ networkRequestDialogFragment.onWifiStateChanged();
inOrder.verify(networkRequestDialogFragment).updateWifiEntries();
inOrder.verify(networkRequestDialogFragment).updateUi();
@@ -165,12 +189,10 @@
@Test
public void onWifiEntriesChanged_nonEmptyMatchedScanResults_shouldUpdateWifiEntries() {
final InOrder inOrder = inOrder(networkRequestDialogFragment);
+ mScanResult.capabilities = TEST_CAPABILITIES_OPEN;
+ networkRequestDialogFragment.onMatch(Arrays.asList(mScanResult));
- final List<ScanResult> scanResults = new ArrayList<>();
- networkRequestDialogFragment.mMatchedScanResults = scanResults;
- ScanResult scanResult = mock(ScanResult.class);
- networkRequestDialogFragment.mMatchedScanResults.add(scanResult);
- networkRequestDialogFragment.onMatch(scanResults);
+ networkRequestDialogFragment.onWifiEntriesChanged();
inOrder.verify(networkRequestDialogFragment).updateWifiEntries();
inOrder.verify(networkRequestDialogFragment).updateUi();
@@ -288,4 +310,34 @@
// Check
verify(selectionCallback, times(1)).reject();
}
+
+ @Test
+ public void updateWifiEntries_noMatchSecurityWifi_filteredWifiIsEmpty() {
+ mScanResult.capabilities = TEST_CAPABILITIES_OPEN;
+ networkRequestDialogFragment.onMatch(Arrays.asList(mScanResult));
+
+ networkRequestDialogFragment.updateWifiEntries();
+
+ assertThat(networkRequestDialogFragment.mFilteredWifiEntries.size()).isEqualTo(0);
+ }
+
+ @Test
+ public void updateWifiEntries_matchWpa2Wifi_filteredWifiNotEmpty() {
+ mScanResult.capabilities = TEST_CAPABILITIES_WPA2_PSK;
+ networkRequestDialogFragment.onMatch(Arrays.asList(mScanResult));
+
+ networkRequestDialogFragment.updateWifiEntries();
+
+ assertThat(networkRequestDialogFragment.mFilteredWifiEntries.size()).isNotEqualTo(0);
+ }
+
+ @Test
+ public void updateWifiEntries_matchWpa3Wifi_filteredWifiNotEmpty() {
+ mScanResult.capabilities = TEST_CAPABILITIES_WPA3_SAE;
+ networkRequestDialogFragment.onMatch(Arrays.asList(mScanResult));
+
+ networkRequestDialogFragment.updateWifiEntries();
+
+ assertThat(networkRequestDialogFragment.mFilteredWifiEntries.size()).isNotEqualTo(0);
+ }
}
diff --git a/tests/spa_unit/src/com/android/settings/spa/app/appinfo/AppLocalePreferenceTest.kt b/tests/spa_unit/src/com/android/settings/spa/app/appinfo/AppLocalePreferenceTest.kt
index b4545d4..82c9ee9 100644
--- a/tests/spa_unit/src/com/android/settings/spa/app/appinfo/AppLocalePreferenceTest.kt
+++ b/tests/spa_unit/src/com/android/settings/spa/app/appinfo/AppLocalePreferenceTest.kt
@@ -22,11 +22,9 @@
import android.content.pm.PackageManager
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.platform.LocalContext
-import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertIsNotDisplayed
import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.junit4.createComposeRule
-import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.onRoot
import androidx.compose.ui.test.performClick
import androidx.test.core.app.ApplicationProvider
@@ -47,7 +45,6 @@
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor
-import org.mockito.ArgumentMatchers
import org.mockito.Mock
import org.mockito.Mockito.any
import org.mockito.Mockito.doNothing
@@ -80,9 +77,8 @@
.strictness(Strictness.LENIENT)
.startMocking()
whenever(context.packageManager).thenReturn(packageManager)
- whenever(AppLocaleUtil.canDisplayLocaleUi(any(), ArgumentMatchers.eq(APP), any()))
- .thenReturn(true)
- whenever(AppLocaleDetails.getSummary(any(), ArgumentMatchers.eq(APP))).thenReturn(SUMMARY)
+ whenever(AppLocaleUtil.canDisplayLocaleUi(any(), eq(APP), any())).thenReturn(true)
+ whenever(AppLocaleDetails.getSummary(any(), eq(APP))).thenReturn(SUMMARY)
}
@After
@@ -92,8 +88,7 @@
@Test
fun whenCanNotDisplayLocalUi_notDisplayed() {
- whenever(AppLocaleUtil.canDisplayLocaleUi(any(), ArgumentMatchers.eq(APP), any()))
- .thenReturn(false)
+ whenever(AppLocaleUtil.canDisplayLocaleUi(any(), eq(APP), any())).thenReturn(false)
setContent()
@@ -104,8 +99,9 @@
fun whenCanDisplayLocalUi_displayed() {
setContent()
- composeTestRule.onNodeWithText(context.getString(R.string.app_locale_preference_title))
- .assertIsDisplayed()
+ composeTestRule.waitUntilExists(
+ hasText(context.getString(R.string.app_locale_preference_title))
+ )
composeTestRule.waitUntilExists(hasText(SUMMARY))
}
diff --git a/tests/unit/src/com/android/settings/deviceinfo/simstatus/SlotSimStatusTest.java b/tests/unit/src/com/android/settings/deviceinfo/simstatus/SlotSimStatusTest.java
index 1a4e740..71f0faf 100644
--- a/tests/unit/src/com/android/settings/deviceinfo/simstatus/SlotSimStatusTest.java
+++ b/tests/unit/src/com/android/settings/deviceinfo/simstatus/SlotSimStatusTest.java
@@ -33,6 +33,9 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
@RunWith(AndroidJUnit4.class)
public class SlotSimStatusTest {
@@ -59,6 +62,16 @@
}
@Test
+ public void size_returnNumberOfPhone_whenQueryInBackgroundThread() {
+ doReturn(2).when(mTelephonyManager).getPhoneCount();
+
+ ExecutorService executor = Executors.newSingleThreadExecutor();
+ SlotSimStatus target = new SlotSimStatus(mContext, executor);
+
+ assertEquals(new Integer(target.size()), new Integer(2));
+ }
+
+ @Test
public void getPreferenceOrdering_returnOrdering_whenQuery() {
doReturn(2).when(mTelephonyManager).getPhoneCount();