Merge "Support accessibility shortcut secondary action (6/n)"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index fca80b4..74f4621 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -490,8 +490,6 @@
<string name="activity_picker_label">Choose activity</string>
<!-- Do not translate. -->
<string name="debug_intent_sender_label">Debug intent sender</string>
- <!-- The title of the activity to see random device info. -->
- <string name="device_info_label">Device info</string>
<!-- The title of the activity to adjust display settings -->
<string name="display_label">Screen</string>
<!-- The title of the activity to adjust SD card settings [CHAR LIMIT=25] -->
@@ -1765,7 +1763,8 @@
<string name="tx_link_speed"><xliff:g id="Transmit link speed" example="150 Mbps">%1$d</xliff:g> Mbps</string>
<!-- Receive Link speed on Wifi Status screen [CHAR LIMIT=32] -->
<string name="rx_link_speed"><xliff:g id="Receive link speed" example="54 Mbps">%1$d</xliff:g> Mbps</string>
-
+ <!-- Link speed on Wifi Status screen [CHAR LIMIT=32] -->
+ <string name="link_speed"><xliff:g id="Link speed" example="54 Mbps">%1$d</xliff:g> Mbps</string>
<!-- This string asks the user whether or not to allow an app to enable WiFi. [CHAR LIMIT=NONE] -->
<string name="wifi_ask_enable"><xliff:g id="requester" example="FancyApp">%s</xliff:g> wants to turn on Wi-Fi</string>
<!-- This string asks the user whether or not to allow an app to disable WiFi. [CHAR LIMIT=NONE] -->
@@ -1956,8 +1955,6 @@
<string name="wifi_show_advanced">Advanced options</string>
<!-- Message for talkback to say when focus on Advanced Options[CHAR LIMIT=NONE] -->
<string name="wifi_advanced_toggle_description">Drop down list Advanced Options</string>
- <!-- Extended message for talkback to say when Advanced Options is expanded. (e.g., Double-tap to collapse) [CHAR LIMIT=NONE] -->
- <string name="wifi_advanced_toggle_description_expanded">collapse</string>
<!-- Extended message for talkback to say when Advanced Options is collapsed. (e.g., Double-tap to expand) [CHAR LIMIT=NONE] -->
<string name="wifi_advanced_toggle_description_collapsed">expand</string>
<!-- Label for the SSID of the network -->
@@ -1978,6 +1975,8 @@
<string name="tx_wifi_speed">Transmit link speed</string>
<!-- Label for the receive link speed of the connection. [CHAR LIMIT=32] -->
<string name="rx_wifi_speed">Receive link speed</string>
+ <!-- Label for the link speed of the connection. [CHAR LIMIT=32] -->
+ <string name="wifi_speed">Link speed</string>
<!-- Label for the frequency band of the connection -->
<string name="wifi_frequency">Frequency</string>
<!-- Label for the IP address of the connection -->
@@ -7319,6 +7318,8 @@
<string name="keywords_wifi">wifi, wi-fi, network connection, internet, wireless, data, wi fi</string>
<!-- Search keyword for "Open Network Notification" settings. [CHAR_LIMIT=NONE]-->
<string name="keywords_wifi_notify_open_networks">Wi\u2011Fi notification, wifi notification</string>
+ <!-- Search keyword for "Wi-fi data usage" settings. [CHAR_LIMIT=NONE]-->
+ <string name="keywords_wifi_data_usage">data usage</string>
<!-- Search keyword for "Vibrate on touch" settings. [CHAR_LIMIT=NONE]-->
<string name="keywords_vibrate_on_touch">Stop vibration, tap, keyboard</string>
<!-- Search keyword for "Time format" settings. [CHAR_LIMIT=NONE]-->
@@ -11215,9 +11216,6 @@
<!-- Available networks screen, summary when button disallowed due to permanent automatic mode [CHAR LIMIT=NONE] -->
<string name="manual_mode_disallowed_summary">Unavailable when connected to <xliff:g id="carrier" example="verizon">%1$s</xliff:g></string>
- <!-- Used for EmergencyInfoSlice slice helper class [CHAR LIMIT=NONE]-->
- <string name="emergency_info_contextual_card_summary">Medical info, emergency contacts</string>
-
<!-- See more items in contextual homepage [CHAR LIMIT=30]-->
<string name="see_more">See more</string>
<!-- See less items in contextual homepage [CHAR LIMIT=30]-->
diff --git a/res/xml/security_settings_face.xml b/res/xml/security_settings_face.xml
index cd05512..cc45a96 100644
--- a/res/xml/security_settings_face.xml
+++ b/res/xml/security_settings_face.xml
@@ -71,17 +71,19 @@
android:title="@string/security_settings_face_preference_title">
<com.android.settingslib.widget.LayoutPreference
android:key="security_settings_face_delete_faces_container"
+ android:title="@string/security_settings_face_settings_remove_face_data"
android:selectable="false"
android:layout="@layout/face_remove_button"
settings:allowDividerBelow="true"/>
<com.android.settingslib.widget.LayoutPreference
android:key="security_settings_face_enroll_faces_container"
+ android:title="@string/security_settings_face_settings_enroll"
android:selectable="false"
- android:layout="@layout/face_enroll_button "
+ android:layout="@layout/face_enroll_button"
settings:allowDividerBelow="true"/>
</PreferenceCategory>
<com.android.settingslib.widget.FooterPreference
settings:allowDividerAbove="true"/>
-</PreferenceScreen>
\ No newline at end of file
+</PreferenceScreen>
diff --git a/res/xml/wifi_settings.xml b/res/xml/wifi_settings.xml
index d7c299e..5fac85a 100644
--- a/res/xml/wifi_settings.xml
+++ b/res/xml/wifi_settings.xml
@@ -17,19 +17,21 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:title="@string/wifi_settings"
- settings:keywords="@string/keywords_wifi">
+ android:title="@string/wifi_settings">
<com.android.settings.wifi.LinkablePreference
- android:key="wifi_status_message"/>
+ android:key="wifi_status_message"
+ settings:searchable="false"/>
<PreferenceCategory
android:key="connected_access_point"
- android:layout="@layout/preference_category_no_label"/>
+ android:layout="@layout/preference_category_no_label"
+ settings:searchable="false"/>
<PreferenceCategory
android:key="access_points"
- android:layout="@layout/preference_category_no_label"/>
+ android:layout="@layout/preference_category_no_label"
+ settings:searchable="false"/>
<Preference
android:key="configure_settings"
@@ -44,5 +46,6 @@
<com.android.settings.datausage.DataUsagePreference
android:key="wifi_data_usage"
- android:title="@string/wifi_data_usage"/>
+ android:title="@string/wifi_data_usage"
+ settings:keywords="@string/keywords_wifi_data_usage"/>
</PreferenceScreen>
diff --git a/src/com/android/settings/AirplaneModeEnabler.java b/src/com/android/settings/AirplaneModeEnabler.java
index 64ad17d..f1d36f2 100644
--- a/src/com/android/settings/AirplaneModeEnabler.java
+++ b/src/com/android/settings/AirplaneModeEnabler.java
@@ -22,9 +22,7 @@
import android.os.UserHandle;
import android.provider.Settings;
import android.telephony.PhoneStateListener;
-import android.telephony.ServiceState;
import android.telephony.SubscriptionInfo;
-import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.util.Log;
@@ -34,7 +32,6 @@
import com.android.settingslib.WirelessUtils;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
-import java.util.ArrayList;
import java.util.List;
/**
@@ -61,12 +58,11 @@
private TelephonyManager mTelephonyManager;
private ProxySubscriptionManager mProxySubscriptionMgr;
- private List<ServiceStateListener> mServiceStateListeners;
+ private PhoneStateListener mPhoneStateListener;
private GlobalSettingsChangeListener mAirplaneModeObserver;
- public AirplaneModeEnabler(Context context,
- OnAirplaneModeChangedListener listener) {
+ public AirplaneModeEnabler(Context context, OnAirplaneModeChangedListener listener) {
super(context, Settings.Global.AIRPLANE_MODE_ON);
mContext = context;
@@ -75,6 +71,16 @@
mTelephonyManager = context.getSystemService(TelephonyManager.class);
mProxySubscriptionMgr = ProxySubscriptionManager.getInstance(context);
+
+ mPhoneStateListener = new PhoneStateListener() {
+ @Override
+ public void onRadioPowerStateChanged(int state) {
+ if (DEBUG) {
+ Log.d(LOG_TAG, "RadioPower: " + state);
+ }
+ onAirplaneModeChanged();
+ }
+ };
}
/**
@@ -88,35 +94,13 @@
}
public void resume() {
- final List<SubscriptionInfo> subInfoList =
- mProxySubscriptionMgr.getActiveSubscriptionsInfo();
-
- mServiceStateListeners = new ArrayList<ServiceStateListener>();
-
- // add default listener
- mServiceStateListeners.add(new ServiceStateListener(mTelephonyManager,
- SubscriptionManager.INVALID_SUBSCRIPTION_ID, this));
-
- if (subInfoList != null) {
- for (SubscriptionInfo subInfo : subInfoList) {
- mServiceStateListeners.add(new ServiceStateListener(mTelephonyManager,
- subInfo.getSubscriptionId(), this));
- }
- }
-
- for (ServiceStateListener ssListener : mServiceStateListeners) {
- ssListener.start();
- }
+ mTelephonyManager.listen(mPhoneStateListener,
+ PhoneStateListener.LISTEN_RADIO_POWER_STATE_CHANGED);
}
public void pause() {
- if (mServiceStateListeners == null) {
- return;
- }
- for (ServiceStateListener ssListener : mServiceStateListeners) {
- ssListener.stop();
- }
- mServiceStateListeners = null;
+ mTelephonyManager.listen(mPhoneStateListener,
+ PhoneStateListener.LISTEN_NONE);
}
private void setAirplaneModeOn(boolean enabling) {
@@ -200,51 +184,4 @@
public boolean isAirplaneModeOn() {
return WirelessUtils.isAirplaneModeOn(mContext);
}
-
- private static class ServiceStateListener extends PhoneStateListener {
- private ServiceStateListener(TelephonyManager telephonyManager, int subscriptionId,
- AirplaneModeEnabler enabler) {
- super();
- mSubId = subscriptionId;
- mTelephonyManager = getSubIdSpecificTelephonyManager(telephonyManager);
- mEnabler = enabler;
- }
-
- private int mSubId;
- private TelephonyManager mTelephonyManager;
- private AirplaneModeEnabler mEnabler;
-
- int getSubscriptionId() {
- return mSubId;
- }
-
- void start() {
- if (mTelephonyManager != null) {
- mTelephonyManager.listen(this, PhoneStateListener.LISTEN_SERVICE_STATE);
- }
- }
-
- void stop() {
- if (mTelephonyManager != null) {
- mTelephonyManager.listen(this, PhoneStateListener.LISTEN_NONE);
- }
- }
-
- @Override
- public void onServiceStateChanged(ServiceState serviceState) {
- if (DEBUG) {
- Log.d(LOG_TAG, "ServiceState in sub" + mSubId + ": " + serviceState);
- }
- mEnabler.onAirplaneModeChanged();
- }
-
- private TelephonyManager getSubIdSpecificTelephonyManager(
- TelephonyManager telephonyManager) {
- if (mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
- return telephonyManager;
- }
- return telephonyManager.createForSubscriptionId(mSubId);
- }
- }
-
}
diff --git a/src/com/android/settings/biometrics/face/FaceSettings.java b/src/com/android/settings/biometrics/face/FaceSettings.java
index ca51f18..5795e65 100644
--- a/src/com/android/settings/biometrics/face/FaceSettings.java
+++ b/src/com/android/settings/biometrics/face/FaceSettings.java
@@ -56,6 +56,11 @@
private static final String TAG = "FaceSettings";
private static final String KEY_TOKEN = "hw_auth_token";
+ private static final String PREF_KEY_DELETE_FACE_DATA =
+ "security_settings_face_delete_faces_container";
+ private static final String PREF_KEY_ENROLL_FACE_UNLOCK =
+ "security_settings_face_enroll_faces_container";
+
private UserManager mUserManager;
private FaceManager mFaceManager;
private int mUserId;
@@ -309,6 +314,15 @@
protected boolean isPageSearchEnabled(Context context) {
return isAvailable(context);
}
- };
+ @Override
+ public List<String> getNonIndexableKeys(Context context) {
+ final List<String> keys = super.getNonIndexableKeys(context);
+ final FaceManager faceManager = context.getSystemService(FaceManager.class);
+ final boolean hasEnrolled = faceManager.hasEnrolledTemplates(
+ UserHandle.myUserId());
+ keys.add(hasEnrolled ? PREF_KEY_ENROLL_FACE_UNLOCK : PREF_KEY_DELETE_FACE_DATA);
+ return keys;
+ }
+ };
}
diff --git a/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java b/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
index 292b203..bee93fb 100644
--- a/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
+++ b/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
@@ -73,6 +73,8 @@
@VisibleForTesting
Handler mHandler = new Handler(Looper.getMainLooper());
@VisibleForTesting
+ boolean mIsRegisterCallback = false;
+ @VisibleForTesting
final BluetoothAdapter.OnMetadataChangedListener mMetadataListener =
new BluetoothAdapter.OnMetadataChangedListener() {
@Override
@@ -96,6 +98,7 @@
final boolean untetheredHeadset = mCachedDevice != null
&& BluetoothUtils.getBooleanMetaData(
mCachedDevice.getDevice(), BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET);
+ Log.d(TAG, "getAvailabilityStatus() is untethered : " + untetheredHeadset);
return advancedEnabled && untetheredHeadset ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
@@ -113,6 +116,7 @@
if (!isAvailable()) {
return;
}
+ mIsRegisterCallback = true;
mCachedDevice.registerCallback(this);
mBluetoothAdapter.addOnMetadataChangedListener(mCachedDevice.getDevice(),
mContext.getMainExecutor(), mMetadataListener);
@@ -120,19 +124,17 @@
@Override
public void onStop() {
- if (!isAvailable()) {
+ if (!mIsRegisterCallback) {
return;
}
mCachedDevice.unregisterCallback(this);
mBluetoothAdapter.removeOnMetadataChangedListener(mCachedDevice.getDevice(),
mMetadataListener);
+ mIsRegisterCallback = false;
}
@Override
public void onDestroy() {
- if (!isAvailable()) {
- return;
- }
// Destroy icon bitmap associated with this header
for (Bitmap bitmap : mIconCache.values()) {
if (bitmap != null) {
diff --git a/src/com/android/settings/datetime/timezone/TimeZoneSettings.java b/src/com/android/settings/datetime/timezone/TimeZoneSettings.java
index 8226a6c..60cd636 100644
--- a/src/com/android/settings/datetime/timezone/TimeZoneSettings.java
+++ b/src/com/android/settings/datetime/timezone/TimeZoneSettings.java
@@ -25,6 +25,7 @@
import android.content.SharedPreferences;
import android.icu.util.TimeZone;
import android.os.Bundle;
+import android.provider.Settings;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
@@ -123,9 +124,9 @@
super.onCreate(icicle);
// Hide all interactive preferences
setPreferenceCategoryVisible((PreferenceCategory) findPreference(
- PREF_KEY_REGION_CATEGORY), false);
+ PREF_KEY_REGION_CATEGORY), false);
setPreferenceCategoryVisible((PreferenceCategory) findPreference(
- PREF_KEY_FIXED_OFFSET_CATEGORY), false);
+ PREF_KEY_FIXED_OFFSET_CATEGORY), false);
// Start loading TimeZoneData
getLoaderManager().initLoader(0, null, new TimeZoneDataLoader.LoaderCreator(
@@ -237,7 +238,7 @@
String tzId = data.getStringExtra(RegionZonePicker.EXTRA_RESULT_TIME_ZONE_ID);
// Ignore the result if user didn't change the region or time zone.
if (Objects.equals(regionId, use(RegionPreferenceController.class).getRegionId())
- && Objects.equals(tzId, mSelectedTimeZoneId)) {
+ && Objects.equals(tzId, mSelectedTimeZoneId)) {
return;
}
@@ -327,9 +328,9 @@
private void setSelectByRegion(boolean selectByRegion) {
mSelectByRegion = selectByRegion;
setPreferenceCategoryVisible((PreferenceCategory) findPreference(
- PREF_KEY_REGION_CATEGORY), selectByRegion);
+ PREF_KEY_REGION_CATEGORY), selectByRegion);
setPreferenceCategoryVisible((PreferenceCategory) findPreference(
- PREF_KEY_FIXED_OFFSET_CATEGORY), !selectByRegion);
+ PREF_KEY_FIXED_OFFSET_CATEGORY), !selectByRegion);
final String localeRegionId = getLocaleRegionId();
final Set<String> allCountryIsoCodes = mTimeZoneData.getRegionIds();
@@ -353,6 +354,7 @@
* Find the a region associated with the specified time zone, based on the time zone data.
* If there are multiple regions associated with the given time zone, the priority will be given
* to the region the user last picked and the country in user's locale.
+ *
* @return null if no region associated with the time zone
*/
private String findRegionIdForTzId(String tzId) {
@@ -378,7 +380,7 @@
}
private void setPreferenceCategoryVisible(PreferenceCategory category,
- boolean isVisible) {
+ boolean isVisible) {
// Hiding category doesn't hide all the children preference. Set visibility of its children.
// Do not care grandchildren as time_zone_pref.xml has only 2 levels.
category.setVisible(isVisible);
@@ -392,5 +394,13 @@
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider(R.xml.time_zone_prefs);
+ new BaseSearchIndexProvider(R.xml.time_zone_prefs) {
+ @Override
+ protected boolean isPageSearchEnabled(Context context) {
+ // We can't enter this page if the auto time zone is enabled.
+ final int autoTimeZone = Settings.Global.getInt(context.getContentResolver(),
+ Settings.Global.AUTO_TIME_ZONE, 1);
+ return autoTimeZone == 1 ? false : true;
+ }
+ };
}
diff --git a/src/com/android/settings/deviceinfo/BrandedAccountPreferenceController.java b/src/com/android/settings/deviceinfo/BrandedAccountPreferenceController.java
index bdd76fc..3543832 100644
--- a/src/com/android/settings/deviceinfo/BrandedAccountPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/BrandedAccountPreferenceController.java
@@ -32,13 +32,13 @@
import com.android.settings.overlay.FeatureFactory;
public class BrandedAccountPreferenceController extends BasePreferenceController {
- private final Account[] mAccounts;
+ private final AccountFeatureProvider mAccountFeatureProvider;
+ private Account[] mAccounts;
public BrandedAccountPreferenceController(Context context, String key) {
super(context, key);
- final AccountFeatureProvider accountFeatureProvider = FeatureFactory.getFactory(
- mContext).getAccountFeatureProvider();
- mAccounts = accountFeatureProvider.getAccounts(mContext);
+ mAccountFeatureProvider = FeatureFactory.getFactory(mContext).getAccountFeatureProvider();
+ mAccounts = mAccountFeatureProvider.getAccounts(mContext);
}
@Override
@@ -56,8 +56,6 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- final AccountFeatureProvider accountFeatureProvider = FeatureFactory.getFactory(
- mContext).getAccountFeatureProvider();
final Preference accountPreference = screen.findPreference(getPreferenceKey());
if (accountPreference != null && (mAccounts == null || mAccounts.length == 0)) {
screen.removePreference(accountPreference);
@@ -72,7 +70,7 @@
args.putParcelable(AccountDetailDashboardFragment.KEY_USER_HANDLE,
android.os.Process.myUserHandle());
args.putString(AccountDetailDashboardFragment.KEY_ACCOUNT_TYPE,
- accountFeatureProvider.getAccountType());
+ mAccountFeatureProvider.getAccountType());
new SubSettingLauncher(mContext)
.setDestination(AccountDetailDashboardFragment.class.getName())
@@ -83,4 +81,13 @@
return true;
});
}
+
+ @Override
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+ mAccounts = mAccountFeatureProvider.getAccounts(mContext);
+ if (mAccounts == null || mAccounts.length == 0) {
+ preference.setVisible(false);
+ }
+ }
}
diff --git a/src/com/android/settings/deviceinfo/MigrateEstimateTask.java b/src/com/android/settings/deviceinfo/MigrateEstimateTask.java
index c41ebe0..a5790b3 100644
--- a/src/com/android/settings/deviceinfo/MigrateEstimateTask.java
+++ b/src/com/android/settings/deviceinfo/MigrateEstimateTask.java
@@ -29,7 +29,7 @@
import android.os.UserManager;
import android.os.storage.StorageManager;
import android.os.storage.VolumeInfo;
-import android.telecom.Log;
+import android.util.Log;
import android.text.format.DateUtils;
import android.text.format.Formatter;
diff --git a/src/com/android/settings/homepage/contextualcards/deviceinfo/DataUsageSlice.java b/src/com/android/settings/homepage/contextualcards/deviceinfo/DataUsageSlice.java
deleted file mode 100644
index 419b770..0000000
--- a/src/com/android/settings/homepage/contextualcards/deviceinfo/DataUsageSlice.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.homepage.contextualcards.deviceinfo;
-
-import android.app.PendingIntent;
-import android.app.settings.SettingsEnums;
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-import android.text.Spannable;
-import android.text.SpannableString;
-import android.text.TextUtils;
-import android.text.format.Formatter;
-import android.text.style.TextAppearanceSpan;
-
-import androidx.core.graphics.drawable.IconCompat;
-import androidx.slice.Slice;
-import androidx.slice.builders.ListBuilder;
-import androidx.slice.builders.SliceAction;
-
-import com.android.internal.annotations.VisibleForTesting;
-import com.android.settings.R;
-import com.android.settings.SubSettings;
-import com.android.settings.Utils;
-import com.android.settings.datausage.DataUsageSummary;
-import com.android.settings.datausage.DataUsageUtils;
-import com.android.settings.slices.CustomSliceRegistry;
-import com.android.settings.slices.CustomSliceable;
-import com.android.settings.slices.SliceBuilderUtils;
-import com.android.settingslib.net.DataUsageController;
-
-import java.util.concurrent.TimeUnit;
-
-public class DataUsageSlice implements CustomSliceable {
- private static final String TAG = "DataUsageSlice";
- private static final long MILLIS_IN_A_DAY = TimeUnit.DAYS.toMillis(1);
-
-
- private final Context mContext;
-
- public DataUsageSlice(Context context) {
- mContext = context;
- }
-
- @Override
- public Uri getUri() {
- return CustomSliceRegistry.DATA_USAGE_SLICE_URI;
- }
-
- @Override
- public Slice getSlice() {
- final IconCompat icon = IconCompat.createWithResource(mContext,
- R.drawable.ic_settings_data_usage);
- final String title = mContext.getString(R.string.data_usage_summary_title);
- final SliceAction primaryAction = SliceAction.createDeeplink(getPrimaryAction(), icon,
- ListBuilder.ICON_IMAGE, title);
- final DataUsageController dataUsageController = new DataUsageController(mContext);
- final DataUsageController.DataUsageInfo info = dataUsageController.getDataUsageInfo();
- final ListBuilder listBuilder =
- new ListBuilder(mContext, CustomSliceRegistry.DATA_USAGE_SLICE_URI,
- ListBuilder.INFINITY)
- .setAccentColor(Utils.getColorAccentDefaultColor(mContext))
- .setHeader(new ListBuilder.HeaderBuilder().setTitle(title));
- if (DataUsageUtils.hasSim(mContext)) {
- listBuilder.addRow(new ListBuilder.RowBuilder()
- .setTitle(getDataUsageText(info))
- .setSubtitle(getCycleTime(info))
- .setPrimaryAction(primaryAction));
- } else {
- listBuilder.addRow(new ListBuilder.RowBuilder()
- .setTitle(mContext.getText(R.string.no_sim_card))
- .setPrimaryAction(primaryAction));
- }
- return listBuilder.build();
- }
-
- @Override
- public Intent getIntent() {
- final String screenTitle = mContext.getText(R.string.data_usage_wifi_title).toString();
- return SliceBuilderUtils.buildSearchResultPageIntent(mContext,
- DataUsageSummary.class.getName(), "" /* key */, screenTitle,
- SettingsEnums.SLICE)
- .setClassName(mContext.getPackageName(), SubSettings.class.getName())
- .setData(CustomSliceRegistry.DATA_USAGE_SLICE_URI);
- }
-
- private PendingIntent getPrimaryAction() {
- final Intent intent = getIntent();
- return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent, 0 /* flags */);
- }
-
- @VisibleForTesting
- CharSequence getDataUsageText(DataUsageController.DataUsageInfo info) {
- final Formatter.BytesResult usedResult = Formatter.formatBytes(mContext.getResources(),
- info.usageLevel, Formatter.FLAG_CALCULATE_ROUNDED | Formatter.FLAG_IEC_UNITS);
- final SpannableString usageNumberText = new SpannableString(usedResult.value);
- usageNumberText.setSpan(
- new TextAppearanceSpan(mContext, android.R.style.TextAppearance_Large), 0,
- usageNumberText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
- return TextUtils.expandTemplate(mContext.getText(R.string.data_used_formatted),
- usageNumberText, usedResult.units);
- }
-
- @VisibleForTesting
- CharSequence getCycleTime(DataUsageController.DataUsageInfo info) {
- final long millisLeft = info.cycleEnd - System.currentTimeMillis();
- if (millisLeft <= 0) {
- return mContext.getString(R.string.billing_cycle_none_left);
- } else {
- final int daysLeft = (int) (millisLeft / MILLIS_IN_A_DAY);
- return daysLeft < 1 ? mContext.getString(R.string.billing_cycle_less_than_one_day_left)
- : mContext.getResources().getQuantityString(R.plurals.billing_cycle_days_left,
- daysLeft, daysLeft);
- }
- }
-
- @Override
- public void onNotifyChange(Intent intent) {
-
- }
-}
diff --git a/src/com/android/settings/homepage/contextualcards/deviceinfo/DeviceInfoSlice.java b/src/com/android/settings/homepage/contextualcards/deviceinfo/DeviceInfoSlice.java
deleted file mode 100644
index 4a028b0..0000000
--- a/src/com/android/settings/homepage/contextualcards/deviceinfo/DeviceInfoSlice.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.homepage.contextualcards.deviceinfo;
-
-import android.app.PendingIntent;
-import android.app.settings.SettingsEnums;
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-import android.telephony.SubscriptionInfo;
-import android.telephony.SubscriptionManager;
-import android.text.TextUtils;
-
-import androidx.annotation.VisibleForTesting;
-import androidx.core.graphics.drawable.IconCompat;
-import androidx.slice.Slice;
-import androidx.slice.builders.ListBuilder;
-import androidx.slice.builders.SliceAction;
-
-import com.android.settings.R;
-import com.android.settings.SubSettings;
-import com.android.settings.Utils;
-import com.android.settings.deviceinfo.HardwareInfoPreferenceController;
-import com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment;
-import com.android.settings.slices.CustomSliceRegistry;
-import com.android.settings.slices.CustomSliceable;
-import com.android.settings.slices.SliceBuilderUtils;
-import com.android.settingslib.DeviceInfoUtils;
-
-import java.util.List;
-
-public class DeviceInfoSlice implements CustomSliceable {
- private static final String TAG = "DeviceInfoSlice";
-
- private final Context mContext;
- private final SubscriptionManager mSubscriptionManager;
-
- public DeviceInfoSlice(Context context) {
- mContext = context;
- mSubscriptionManager = mContext.getSystemService(SubscriptionManager.class);
- }
-
- @Override
- public Slice getSlice() {
- final IconCompat icon = IconCompat.createWithResource(mContext,
- R.drawable.ic_info_outline_24dp);
- final String title = mContext.getString(R.string.device_info_label);
- final SliceAction primaryAction = SliceAction.createDeeplink(getPrimaryAction(), icon,
- ListBuilder.ICON_IMAGE, title);
- return new ListBuilder(mContext, CustomSliceRegistry.DEVICE_INFO_SLICE_URI,
- ListBuilder.INFINITY)
- .setAccentColor((Utils.getColorAccentDefaultColor(mContext)))
- .setHeader(new ListBuilder.HeaderBuilder().setTitle(title))
- .addRow(new ListBuilder.RowBuilder()
- .setTitle(getPhoneNumber())
- .setSubtitle(getDeviceModel())
- .setPrimaryAction(primaryAction))
- .build();
- }
-
- @Override
- public Uri getUri() {
- return CustomSliceRegistry.DEVICE_INFO_SLICE_URI;
- }
-
- @Override
- public Intent getIntent() {
- final String screenTitle = mContext.getText(R.string.device_info_label).toString();
- return SliceBuilderUtils.buildSearchResultPageIntent(mContext,
- MyDeviceInfoFragment.class.getName(), "" /* key */, screenTitle,
- SettingsEnums.SLICE)
- .setClassName(mContext.getPackageName(), SubSettings.class.getName())
- .setData(CustomSliceRegistry.DEVICE_INFO_SLICE_URI);
- }
-
- private PendingIntent getPrimaryAction() {
- final Intent intent = getIntent();
- return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent, 0 /* flags */);
- }
-
- @VisibleForTesting
- CharSequence getPhoneNumber() {
- final SubscriptionInfo subscriptionInfo = getFirstSubscriptionInfo();
- if (subscriptionInfo == null) {
- return mContext.getString(R.string.device_info_default);
- }
- final String phoneNumber = DeviceInfoUtils.getBidiFormattedPhoneNumber(mContext,
- subscriptionInfo);
- return TextUtils.isEmpty(phoneNumber) ? mContext.getString(R.string.device_info_default)
- : phoneNumber;
- }
-
- private CharSequence getDeviceModel() {
- return HardwareInfoPreferenceController.getDeviceModel();
- }
-
- @VisibleForTesting
- SubscriptionInfo getFirstSubscriptionInfo() {
- final List<SubscriptionInfo> subscriptionInfoList =
- mSubscriptionManager.getActiveSubscriptionInfoList();
- if (subscriptionInfoList == null || subscriptionInfoList.isEmpty()) {
- return null;
- }
- return subscriptionInfoList.get(0);
- }
-
- @Override
- public void onNotifyChange(Intent intent) {
-
- }
-}
diff --git a/src/com/android/settings/homepage/contextualcards/deviceinfo/EmergencyInfoSlice.java b/src/com/android/settings/homepage/contextualcards/deviceinfo/EmergencyInfoSlice.java
deleted file mode 100644
index 10e87ff..0000000
--- a/src/com/android/settings/homepage/contextualcards/deviceinfo/EmergencyInfoSlice.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.homepage.contextualcards.deviceinfo;
-
-import android.app.PendingIntent;
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-
-import androidx.core.graphics.drawable.IconCompat;
-import androidx.slice.Slice;
-import androidx.slice.builders.ListBuilder;
-import androidx.slice.builders.SliceAction;
-
-import com.android.settings.R;
-import com.android.settings.accounts.EmergencyInfoPreferenceController;
-import com.android.settings.slices.CustomSliceRegistry;
-import com.android.settings.slices.CustomSliceable;
-
-// This is a slice helper class for EmergencyInfo
-public class EmergencyInfoSlice implements CustomSliceable {
-
- private final Context mContext;
-
- public EmergencyInfoSlice(Context context) {
- mContext = context;
- }
-
- @Override
- public Slice getSlice() {
- final ListBuilder listBuilder = new ListBuilder(mContext,
- CustomSliceRegistry.EMERGENCY_INFO_SLICE_URI,
- ListBuilder.INFINITY);
- listBuilder.addRow(
- new ListBuilder.RowBuilder()
- .setTitle(mContext.getText(R.string.emergency_info_title))
- .setSubtitle(
- mContext.getText(R.string.emergency_info_contextual_card_summary))
- .setPrimaryAction(createPrimaryAction()));
- return listBuilder.build();
- }
-
- @Override
- public Uri getUri() {
- return CustomSliceRegistry.EMERGENCY_INFO_SLICE_URI;
- }
-
- @Override
- public Intent getIntent() {
- return new Intent(EmergencyInfoPreferenceController.getIntentAction(mContext));
- }
-
- @Override
- public void onNotifyChange(Intent intent) {
- }
-
- private SliceAction createPrimaryAction() {
- final PendingIntent pendingIntent =
- PendingIntent.getActivity(
- mContext,
- 0 /* requestCode */,
- getIntent(),
- PendingIntent.FLAG_UPDATE_CURRENT);
-
- return SliceAction.createDeeplink(
- pendingIntent,
- IconCompat.createWithResource(mContext, R.drawable.empty_icon),
- ListBuilder.ICON_IMAGE,
- mContext.getText(R.string.emergency_info_title));
- }
-}
diff --git a/src/com/android/settings/network/ProxySubscriptionManager.java b/src/com/android/settings/network/ProxySubscriptionManager.java
index b10c727..0306b55 100644
--- a/src/com/android/settings/network/ProxySubscriptionManager.java
+++ b/src/com/android/settings/network/ProxySubscriptionManager.java
@@ -77,7 +77,7 @@
mActiveSubscriptionsListeners =
new ArrayList<OnActiveSubscriptionChangedListener>();
- mSubsciptionsMonitor = new ActiveSubsciptionsListener(looper, context) {
+ mSubscriptionMonitor = new ActiveSubsciptionsListener(looper, context) {
public void onChanged() {
notifyAllListeners();
}
@@ -85,16 +85,16 @@
mAirplaneModeMonitor = new GlobalSettingsChangeListener(looper,
context, Settings.Global.AIRPLANE_MODE_ON) {
public void onChanged(String field) {
- mSubsciptionsMonitor.clearCache();
+ mSubscriptionMonitor.clearCache();
notifyAllListeners();
}
};
- mSubsciptionsMonitor.start();
+ mSubscriptionMonitor.start();
}
private Lifecycle mLifecycle;
- private ActiveSubsciptionsListener mSubsciptionsMonitor;
+ private ActiveSubsciptionsListener mSubscriptionMonitor;
private GlobalSettingsChangeListener mAirplaneModeMonitor;
private List<OnActiveSubscriptionChangedListener> mActiveSubscriptionsListeners;
@@ -130,17 +130,17 @@
@OnLifecycleEvent(ON_START)
void onStart() {
- mSubsciptionsMonitor.start();
+ mSubscriptionMonitor.start();
}
@OnLifecycleEvent(ON_STOP)
void onStop() {
- mSubsciptionsMonitor.stop();
+ mSubscriptionMonitor.stop();
}
@OnLifecycleEvent(ON_DESTROY)
void onDestroy() {
- mSubsciptionsMonitor.close();
+ mSubscriptionMonitor.close();
mAirplaneModeMonitor.close();
if (mLifecycle != null) {
@@ -157,7 +157,7 @@
* @return a SubscriptionManager
*/
public SubscriptionManager get() {
- return mSubsciptionsMonitor.getSubscriptionManager();
+ return mSubscriptionMonitor.getSubscriptionManager();
}
/**
@@ -166,7 +166,7 @@
* @return max. number of active subscription info(s)
*/
public int getActiveSubscriptionInfoCountMax() {
- return mSubsciptionsMonitor.getActiveSubscriptionInfoCountMax();
+ return mSubscriptionMonitor.getActiveSubscriptionInfoCountMax();
}
/**
@@ -175,7 +175,7 @@
* @return A list of active subscription info
*/
public List<SubscriptionInfo> getActiveSubscriptionsInfo() {
- return mSubsciptionsMonitor.getActiveSubscriptionsInfo();
+ return mSubscriptionMonitor.getActiveSubscriptionsInfo();
}
/**
@@ -185,7 +185,7 @@
* @return A subscription info which is active list
*/
public SubscriptionInfo getActiveSubscriptionInfo(int subId) {
- return mSubsciptionsMonitor.getActiveSubscriptionInfo(subId);
+ return mSubscriptionMonitor.getActiveSubscriptionInfo(subId);
}
/**
@@ -194,7 +194,7 @@
* @return A list of accessible subscription info
*/
public List<SubscriptionInfo> getAccessibleSubscriptionsInfo() {
- return mSubsciptionsMonitor.getAccessibleSubscriptionsInfo();
+ return mSubscriptionMonitor.getAccessibleSubscriptionsInfo();
}
/**
@@ -204,14 +204,14 @@
* @return A subscription info which is accessible list
*/
public SubscriptionInfo getAccessibleSubscriptionInfo(int subId) {
- return mSubsciptionsMonitor.getAccessibleSubscriptionInfo(subId);
+ return mSubscriptionMonitor.getAccessibleSubscriptionInfo(subId);
}
/**
* Clear data cached within proxy
*/
public void clearCache() {
- mSubsciptionsMonitor.clearCache();
+ mSubscriptionMonitor.clearCache();
}
/**
diff --git a/src/com/android/settings/slices/CustomSliceRegistry.java b/src/com/android/settings/slices/CustomSliceRegistry.java
index 66cc600..700fe2e 100644
--- a/src/com/android/settings/slices/CustomSliceRegistry.java
+++ b/src/com/android/settings/slices/CustomSliceRegistry.java
@@ -29,9 +29,6 @@
import com.android.settings.display.AdaptiveSleepPreferenceController;
import com.android.settings.flashlight.FlashlightSlice;
import com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController;
-import com.android.settings.homepage.contextualcards.deviceinfo.DataUsageSlice;
-import com.android.settings.homepage.contextualcards.deviceinfo.DeviceInfoSlice;
-import com.android.settings.homepage.contextualcards.deviceinfo.EmergencyInfoSlice;
import com.android.settings.homepage.contextualcards.deviceinfo.StorageSlice;
import com.android.settings.homepage.contextualcards.slices.BatteryFixSlice;
import com.android.settings.homepage.contextualcards.slices.BluetoothDevicesSlice;
@@ -117,34 +114,6 @@
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
.appendPath("contextual_wifi")
.build();
-
- /**
- * Backing Uri for the Data usage Slice.
- */
- public static final Uri DATA_USAGE_SLICE_URI = new Uri.Builder()
- .scheme(ContentResolver.SCHEME_CONTENT)
- .authority(SettingsSliceProvider.SLICE_AUTHORITY)
- .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
- .appendPath("data_usage_card")
- .build();
- /**
- * Backing Uri for the Device info Slice.
- */
- public static final Uri DEVICE_INFO_SLICE_URI = new Uri.Builder()
- .scheme(ContentResolver.SCHEME_CONTENT)
- .authority(SettingsSliceProvider.SLICE_AUTHORITY)
- .appendPath(SettingsSlicesContract.PATH_SETTING_INTENT)
- .appendPath("device_info_card")
- .build();
- /**
- * Backing Uri for the Emergency Info Slice.
- */
- public static final Uri EMERGENCY_INFO_SLICE_URI = new Uri.Builder()
- .scheme(ContentResolver.SCHEME_CONTENT)
- .authority(SettingsSliceProvider.SLICE_AUTHORITY)
- .appendPath(SettingsSlicesContract.PATH_SETTING_INTENT)
- .appendPath("emergency_info_card")
- .build();
/**
* Slice Uri for Enhanced 4G slice
*/
@@ -355,9 +324,6 @@
sUriToSlice.put(CONTEXTUAL_NOTIFICATION_CHANNEL_SLICE_URI,
ContextualNotificationChannelSlice.class);
sUriToSlice.put(CONTEXTUAL_WIFI_SLICE_URI, ContextualWifiSlice.class);
- sUriToSlice.put(DATA_USAGE_SLICE_URI, DataUsageSlice.class);
- sUriToSlice.put(DEVICE_INFO_SLICE_URI, DeviceInfoSlice.class);
- sUriToSlice.put(EMERGENCY_INFO_SLICE_URI, EmergencyInfoSlice.class);
sUriToSlice.put(FACE_ENROLL_SLICE_URI, FaceSetupSlice.class);
sUriToSlice.put(FLASHLIGHT_SLICE_URI, FlashlightSlice.class);
sUriToSlice.put(LOCATION_SLICE_URI, LocationSlice.class);
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index 05fcf5e..e228a14 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -347,9 +347,13 @@
showProxyFields();
final CheckBox advancedTogglebox =
(CheckBox) mView.findViewById(R.id.wifi_advanced_togglebox);
- advancedTogglebox.setOnCheckedChangeListener(this);
- advancedTogglebox.setChecked(showAdvancedFields);
- setAdvancedOptionAccessibilityString(showAdvancedFields);
+ if (!showAdvancedFields) {
+ // Need to show Advanced Option button.
+ mView.findViewById(R.id.wifi_advanced_toggle).setVisibility(View.VISIBLE);
+ advancedTogglebox.setOnCheckedChangeListener(this);
+ advancedTogglebox.setChecked(showAdvancedFields);
+ setAdvancedOptionAccessibilityString();
+ }
mView.findViewById(R.id.wifi_advanced_fields)
.setVisibility(showAdvancedFields ? View.VISIBLE : View.GONE);
}
@@ -1553,17 +1557,10 @@
((EditText) mPasswordView).setSelection(pos);
}
} else if (view.getId() == R.id.wifi_advanced_togglebox) {
- final int toggleVisibility;
- final int stringID;
- if (isChecked) {
- toggleVisibility = View.VISIBLE;
- // Hide the SoftKeyboard temporary to let user can see most of the expanded items.
- hideSoftKeyboard(mView.getWindowToken());
- } else {
- toggleVisibility = View.GONE;
- }
- mView.findViewById(R.id.wifi_advanced_fields).setVisibility(toggleVisibility);
- setAdvancedOptionAccessibilityString(isChecked);
+ // Hide the SoftKeyboard temporary to let user can see most of the expanded items.
+ hideSoftKeyboard(mView.getWindowToken());
+ view.setVisibility(View.GONE);
+ mView.findViewById(R.id.wifi_advanced_fields).setVisibility(View.VISIBLE);
}
}
@@ -1673,7 +1670,7 @@
((CheckBox) mView.findViewById(R.id.wifi_advanced_togglebox))
.setOnCheckedChangeListener(this);
// Set correct accessibility strings.
- setAdvancedOptionAccessibilityString(false /* showAdvancedFields */);
+ setAdvancedOptionAccessibilityString();
}
/**
@@ -1765,7 +1762,7 @@
inputMethodManager.hideSoftInputFromWindow(windowToken, 0 /* flags */);
}
- private void setAdvancedOptionAccessibilityString(boolean showAdvancedFields) {
+ private void setAdvancedOptionAccessibilityString() {
final CheckBox advancedToggleBox = mView.findViewById(R.id.wifi_advanced_togglebox);
advancedToggleBox.setAccessibilityDelegate(new AccessibilityDelegate() {
@Override
@@ -1776,12 +1773,10 @@
info.setCheckable(false /* checkable */);
// To let TalkBack don't pronounce CheckBox.
info.setClassName(null /* className */);
- final CharSequence accessibilityDoubleTapExtend = mContext.getString(
- showAdvancedFields ? R.string.wifi_advanced_toggle_description_expanded
- : R.string.wifi_advanced_toggle_description_collapsed);
// Customize TalkBack's pronunciation which been appended to "Double-tap to".
final AccessibilityAction customClick = new AccessibilityAction(
- AccessibilityNodeInfo.ACTION_CLICK, accessibilityDoubleTapExtend);
+ AccessibilityNodeInfo.ACTION_CLICK,
+ mContext.getString(R.string.wifi_advanced_toggle_description_collapsed));
info.addAction(customClick);
}
});
diff --git a/src/com/android/settings/wifi/WifiConfigController2.java b/src/com/android/settings/wifi/WifiConfigController2.java
index 0e9c4d0..c6b4702 100644
--- a/src/com/android/settings/wifi/WifiConfigController2.java
+++ b/src/com/android/settings/wifi/WifiConfigController2.java
@@ -348,9 +348,13 @@
showProxyFields();
final CheckBox advancedTogglebox =
(CheckBox) mView.findViewById(R.id.wifi_advanced_togglebox);
- advancedTogglebox.setOnCheckedChangeListener(this);
- advancedTogglebox.setChecked(showAdvancedFields);
- setAdvancedOptionAccessibilityString(showAdvancedFields);
+ if (!showAdvancedFields) {
+ // Need to show Advanced Option button.
+ mView.findViewById(R.id.wifi_advanced_toggle).setVisibility(View.VISIBLE);
+ advancedTogglebox.setOnCheckedChangeListener(this);
+ advancedTogglebox.setChecked(showAdvancedFields);
+ setAdvancedOptionAccessibilityString();
+ }
mView.findViewById(R.id.wifi_advanced_fields)
.setVisibility(showAdvancedFields ? View.VISIBLE : View.GONE);
}
@@ -362,7 +366,7 @@
} else {
final String signalLevel = getSignalString();
- if (mWifiEntry.getConnectedState() != WifiEntry.CONNECTED_STATE_CONNECTED
+ if (mWifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_DISCONNECTED
&& signalLevel != null) {
mConfigUi.setSubmitButton(res.getString(R.string.wifi_connect));
} else {
@@ -384,16 +388,10 @@
}
final ConnectedInfo info = mWifiEntry.getConnectedInfo();
- // TODO(b/143326832): Replace it with ConnectedInfo#linkSpeedMbps.
- //if (info != null && info.getTxLinkSpeedMbps() != WifiInfo.LINK_SPEED_UNKNOWN) {
- // addRow(group, R.string.tx_wifi_speed, String.format(
- // res.getString(R.string.tx_link_speed), info.getTxLinkSpeedMbps()));
- //}
-
- //if (info != null && info.getRxLinkSpeedMbps() != WifiInfo.LINK_SPEED_UNKNOWN) {
- // addRow(group, R.string.rx_wifi_speed, String.format(
- // res.getString(R.string.rx_link_speed), info.getRxLinkSpeedMbps()));
- //}
+ if (info != null && info.linkSpeedMbps >= 0) {
+ addRow(group, R.string.wifi_speed, String.format(
+ res.getString(R.string.link_speed), info.linkSpeedMbps));
+ }
if (info != null && info.frequencyMhz != WifiEntry.FREQUENCY_UNKNOWN) {
final int frequency = info.frequencyMhz;
@@ -1554,17 +1552,10 @@
((EditText) mPasswordView).setSelection(pos);
}
} else if (view.getId() == R.id.wifi_advanced_togglebox) {
- final int toggleVisibility;
- final int stringID;
- if (isChecked) {
- toggleVisibility = View.VISIBLE;
- // Hide the SoftKeyboard temporary to let user can see most of the expanded items.
- hideSoftKeyboard(mView.getWindowToken());
- } else {
- toggleVisibility = View.GONE;
- }
- mView.findViewById(R.id.wifi_advanced_fields).setVisibility(toggleVisibility);
- setAdvancedOptionAccessibilityString(isChecked);
+ // Hide the SoftKeyboard temporary to let user can see most of the expanded items.
+ hideSoftKeyboard(mView.getWindowToken());
+ view.setVisibility(View.GONE);
+ mView.findViewById(R.id.wifi_advanced_fields).setVisibility(View.VISIBLE);
}
}
@@ -1674,7 +1665,7 @@
((CheckBox) mView.findViewById(R.id.wifi_advanced_togglebox))
.setOnCheckedChangeListener(this);
// Set correct accessibility strings.
- setAdvancedOptionAccessibilityString(false /* showAdvancedFields */);
+ setAdvancedOptionAccessibilityString();
}
/**
@@ -1766,7 +1757,7 @@
inputMethodManager.hideSoftInputFromWindow(windowToken, 0 /* flags */);
}
- private void setAdvancedOptionAccessibilityString(boolean showAdvancedFields) {
+ private void setAdvancedOptionAccessibilityString() {
final CheckBox advancedToggleBox = mView.findViewById(R.id.wifi_advanced_togglebox);
advancedToggleBox.setAccessibilityDelegate(new AccessibilityDelegate() {
@Override
@@ -1777,12 +1768,10 @@
info.setCheckable(false /* checkable */);
// To let TalkBack don't pronounce CheckBox.
info.setClassName(null /* className */);
- final CharSequence accessibilityDoubleTapExtend = mContext.getString(
- showAdvancedFields ? R.string.wifi_advanced_toggle_description_expanded
- : R.string.wifi_advanced_toggle_description_collapsed);
// Customize TalkBack's pronunciation which been appended to "Double-tap to".
final AccessibilityAction customClick = new AccessibilityAction(
- AccessibilityNodeInfo.ACTION_CLICK, accessibilityDoubleTapExtend);
+ AccessibilityNodeInfo.ACTION_CLICK,
+ mContext.getString(R.string.wifi_advanced_toggle_description_collapsed));
info.addAction(customClick);
}
});
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index eb02833..4310476 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -493,7 +493,7 @@
// could only be disconnected and be put in blacklists so it won't be used again.
if (mSelectedAccessPoint.isSaved() || mSelectedAccessPoint.isEphemeral()) {
final int stringId = mSelectedAccessPoint.isEphemeral() ?
- R.string.wifi_disconnect_button_text : R.string.forget;
+ R.string.wifi_disconnect_button_text : R.string.forget;
menu.add(Menu.NONE, MENU_ID_FORGET, 0 /* order */, stringId);
}
@@ -1210,28 +1210,6 @@
((AccessPointPreference) accessPoint.getTag()).onLevelChanged();
}
- public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider() {
- @Override
- public List<SearchIndexableRaw> getRawDataToIndex(Context context,
- boolean enabled) {
- final List<SearchIndexableRaw> result = new ArrayList<>();
- final Resources res = context.getResources();
-
- // Add fragment title if we are showing this fragment
- if (res.getBoolean(R.bool.config_show_wifi_settings)) {
- SearchIndexableRaw data = new SearchIndexableRaw(context);
- data.title = res.getString(R.string.wifi_settings);
- data.screenTitle = res.getString(R.string.wifi_settings);
- data.keywords = res.getString(R.string.keywords_wifi);
- data.key = DATA_KEY_REFERENCE;
- result.add(data);
- }
-
- return result;
- }
- };
-
private void handleConfigNetworkSubmitEvent(Intent data) {
final WifiConfiguration wifiConfiguration = data.getParcelableExtra(
ConfigureAccessPointFragment.NETWORK_CONFIG_KEY);
@@ -1257,4 +1235,42 @@
.setResultListener(this, CONFIG_NETWORK_REQUEST)
.launch();
}
+
+ public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider(R.xml.wifi_settings) {
+ @Override
+ public List<SearchIndexableRaw> getRawDataToIndex(Context context,
+ boolean enabled) {
+ final List<SearchIndexableRaw> result = new ArrayList<>();
+ final Resources res = context.getResources();
+
+ // Add fragment title if we are showing this fragment
+ if (res.getBoolean(R.bool.config_show_wifi_settings)) {
+ SearchIndexableRaw data = new SearchIndexableRaw(context);
+ data.title = res.getString(R.string.wifi_settings);
+ data.screenTitle = res.getString(R.string.wifi_settings);
+ data.keywords = res.getString(R.string.keywords_wifi);
+ data.key = DATA_KEY_REFERENCE;
+ result.add(data);
+ }
+ return result;
+ }
+
+ @Override
+ public List<String> getNonIndexableKeys(Context context) {
+ final List<String> keys = super.getNonIndexableKeys(context);
+
+ final WifiManager wifiManager = context.getSystemService(WifiManager.class);
+ final List<AccessPoint> accessPoints = WifiSavedConfigUtils.getAllConfigs(
+ context, wifiManager);
+ if (accessPoints == null || accessPoints.size() <= 0) {
+ keys.add(PREF_KEY_SAVED_NETWORKS);
+ }
+
+ if (!DataUsageUtils.hasWifiRadio(context)) {
+ keys.add(PREF_KEY_DATA_USAGE);
+ }
+ return keys;
+ }
+ };
}
diff --git a/src/com/android/settings/wifi/WifiSettings2.java b/src/com/android/settings/wifi/WifiSettings2.java
index ac5e31c..bd79b3f 100644
--- a/src/com/android/settings/wifi/WifiSettings2.java
+++ b/src/com/android/settings/wifi/WifiSettings2.java
@@ -142,6 +142,19 @@
private String mDialogWifiEntryKey;
private WifiEntry mDialogWifiEntry;
+ // This boolean extra specifies whether to enable the Next button when connected. Used by
+ // account creation outside of setup wizard.
+ private static final String EXTRA_ENABLE_NEXT_ON_CONNECT = "wifi_enable_next_on_connect";
+
+ // Enable the Next button when a Wi-Fi network is connected.
+ private boolean mEnableNextOnConnection;
+
+ // This string extra specifies a network to open the connect dialog on, so the user can enter
+ // network credentials. This is used by quick settings for secured networks, among other
+ // things.
+ private static final String EXTRA_START_CONNECT_SSID = "wifi_start_connect_ssid";
+ private String mOpenSsid;
+
private static boolean isVerboseLoggingEnabled() {
return WifiPickerTracker.isVerboseLoggingEnabled();
}
@@ -329,6 +342,15 @@
}
}
}
+
+ // If we're supposed to enable/disable the Next button based on our current connection
+ // state, start it off in the right state.
+ final Intent intent = getActivity().getIntent();
+ mEnableNextOnConnection = intent.getBooleanExtra(EXTRA_ENABLE_NEXT_ON_CONNECT, false);
+
+ if (intent.hasExtra(EXTRA_START_CONNECT_SSID)) {
+ mOpenSsid = intent.getStringExtra(EXTRA_START_CONNECT_SSID);
+ }
}
@Override
@@ -384,6 +406,23 @@
if (mWifiEnabler != null) {
mWifiEnabler.resume(activity);
}
+
+ changeNextButtonState(mWifiPickerTracker.getConnectedWifiEntry() != null);
+
+ // Edit the Wi-Fi network of specified SSID.
+ if (mOpenSsid != null) {
+ Optional<WifiEntry> matchedWifiEntry = mWifiPickerTracker.getWifiEntries().stream()
+ .filter(wifiEntry -> TextUtils.equals(mOpenSsid, wifiEntry.getSsid()))
+ .filter(wifiEntry -> wifiEntry.getSecurity() != WifiEntry.SECURITY_NONE
+ && wifiEntry.getSecurity() != WifiEntry.SECURITY_OWE)
+ .filter(wifiEntry -> !wifiEntry.isSaved()
+ || isDisabledByWrongPassword(wifiEntry))
+ .findFirst();
+ if (matchedWifiEntry.isPresent()) {
+ mOpenSsid = null;
+ launchConfigNewNetworkFragment(matchedWifiEntry.get());
+ }
+ }
}
@Override
@@ -626,6 +665,7 @@
@Override
public void onWifiEntriesChanged() {
updateWifiEntryPreferencesDelayed();
+ changeNextButtonState(mWifiPickerTracker.getConnectedWifiEntry() != null);
}
@Override
@@ -882,6 +922,19 @@
return R.string.help_url_wifi;
}
+ /**
+ * Renames/replaces "Next" button when appropriate. "Next" button usually exists in
+ * Wi-Fi setup screens, not in usual wifi settings screen.
+ *
+ * @param enabled true when the device is connected to a wifi network.
+ */
+ @VisibleForTesting
+ void changeNextButtonState(boolean enabled) {
+ if (mEnableNextOnConnection && hasNextButton()) {
+ getNextButton().setEnabled(enabled);
+ }
+ }
+
@Override
public void onForget(WifiDialog2 dialog) {
forget(mDialogWifiEntry);
@@ -1014,16 +1067,7 @@
if (mEditIfNoConfig) {
// Edit an unsaved secure Wi-Fi network.
if (mFullScreenEdit) {
- final Bundle bundle = new Bundle();
- bundle.putString(WifiNetworkDetailsFragment2.KEY_CHOSEN_WIFIENTRY_KEY,
- mConnectWifiEntry.getKey());
- new SubSettingLauncher(getContext())
- .setTitleText(mConnectWifiEntry.getTitle())
- .setDestination(ConfigureWifiEntryFragment.class.getName())
- .setArguments(bundle)
- .setSourceMetricsCategory(getMetricsCategory())
- .setResultListener(WifiSettings2.this, CONFIG_NETWORK_REQUEST)
- .launch();
+ launchConfigNewNetworkFragment(mConnectWifiEntry);
} else {
showDialog(mConnectWifiEntry, WifiConfigUiBase2.MODE_MODIFY);
}
@@ -1053,4 +1097,32 @@
private boolean isFisishingOrDestroyed(Activity activity) {
return activity == null || activity.isFinishing() || activity.isDestroyed();
}
+
+ private void launchConfigNewNetworkFragment(WifiEntry wifiEntry) {
+ final Bundle bundle = new Bundle();
+ bundle.putString(WifiNetworkDetailsFragment2.KEY_CHOSEN_WIFIENTRY_KEY,
+ wifiEntry.getKey());
+ new SubSettingLauncher(getContext())
+ .setTitleText(wifiEntry.getTitle())
+ .setDestination(ConfigureWifiEntryFragment.class.getName())
+ .setArguments(bundle)
+ .setSourceMetricsCategory(getMetricsCategory())
+ .setResultListener(WifiSettings2.this, CONFIG_NETWORK_REQUEST)
+ .launch();
+ }
+
+ /** Helper method to return whether an WifiEntry is disabled due to a wrong password */
+ private static boolean isDisabledByWrongPassword(WifiEntry wifiEntry) {
+ WifiConfiguration config = wifiEntry.getWifiConfiguration();
+ if (config == null) {
+ return false;
+ }
+ WifiConfiguration.NetworkSelectionStatus networkStatus =
+ config.getNetworkSelectionStatus();
+ if (networkStatus == null || networkStatus.isNetworkEnabled()) {
+ return false;
+ }
+ int reason = networkStatus.getNetworkSelectionDisableReason();
+ return WifiConfiguration.NetworkSelectionStatus.DISABLED_BY_WRONG_PASSWORD == reason;
+ }
}
diff --git a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
index f99b1d6..5f74d56 100644
--- a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
+++ b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
@@ -589,16 +589,24 @@
private void refreshButtons() {
boolean canForgetNetwork = mWifiEntry.canForget();
boolean canSignIntoNetwork = canSignIntoNetwork();
- boolean canConnectNetwork = mWifiEntry.canConnect();
+ boolean showConnectButton = mWifiEntry.canConnect()
+ || mWifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_CONNECTING;
boolean canShareNetwork = canShareNetwork();
mButtonsPref.setButton1Visible(canForgetNetwork);
mButtonsPref.setButton2Visible(canSignIntoNetwork);
- mButtonsPref.setButton3Visible(canConnectNetwork);
+ mButtonsPref.setButton3Visible(showConnectButton);
+ if (showConnectButton) {
+ if (mWifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_CONNECTING) {
+ mButtonsPref.setButton3Text(R.string.wifi_connecting).setButton3Enabled(false);
+ } else {
+ mButtonsPref.setButton3Text(R.string.wifi_connect).setButton3Enabled(true);
+ }
+ }
mButtonsPref.setButton4Visible(canShareNetwork);
mButtonsPref.setVisible(canForgetNetwork
|| canSignIntoNetwork
- || canConnectNetwork
+ || showConnectButton
|| canShareNetwork);
}
@@ -806,8 +814,6 @@
@VisibleForTesting
void connectNetwork() {
- // TODO(b/143326832): What to do with WifiManager#isWifiEnabled() false case?
- mButtonsPref.setButton3Text(R.string.wifi_connecting).setButton3Enabled(false);
mWifiEntry.connect();
}
@@ -847,8 +853,6 @@
Toast.makeText(mContext,
mContext.getString(R.string.wifi_connected_to_message, mWifiEntry.getTitle()),
Toast.LENGTH_SHORT).show();
- updateNetworkInfo();
- refreshPage();
} else if (mWifiEntry.getLevel() == WifiEntry.WIFI_LEVEL_UNREACHABLE) {
Toast.makeText(mContext,
R.string.wifi_not_in_range_message,
diff --git a/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java b/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java
index 0741695..b9b0d64 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java
@@ -105,8 +105,8 @@
// 2: no 5 GHZ support means we can't have BAND_5GHZ - default to 2GHZ
// 3: With Dual mode support we can't have BAND_5GHZ only - include 2GHZ
if (!isDualMode
- && ((band & (SoftApConfiguration.BAND_5GHZ
- | SoftApConfiguration.BAND_2GHZ)) != 0)) {
+ && ((band & SoftApConfiguration.BAND_5GHZ) != 0)
+ && ((band & SoftApConfiguration.BAND_2GHZ) != 0)) {
return SoftApConfiguration.BAND_5GHZ;
} else if (!is5GhzBandSupported() && SoftApConfiguration.BAND_5GHZ == band) {
return SoftApConfiguration.BAND_2GHZ;
diff --git a/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
index 03e9b6f..80ab42c 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
@@ -210,11 +210,8 @@
}
@Test
- public void onStop_isAvailable_unregisterCallback() {
- DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SETTINGS_UI,
- SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, "true", true);
- when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
- .thenReturn("true".getBytes());
+ public void onStop_isRegisterCallback_unregisterCallback() {
+ mController.mIsRegisterCallback = true;
mController.onStop();
@@ -234,9 +231,8 @@
}
@Test
- public void onStop_notAvailable_unregisterCallback() {
- when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
- .thenReturn("false".getBytes());
+ public void onStop_notRegisterCallback_unregisterCallback() {
+ mController.mIsRegisterCallback = false;
mController.onStop();
@@ -245,11 +241,7 @@
}
@Test
- public void onDestroy_isAvailable_recycleBitmap() {
- DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SETTINGS_UI,
- SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, "true", true);
- when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
- .thenReturn("true".getBytes());
+ public void onDestroy_recycleBitmap() {
mController.mIconCache.put(ICON_URI, mBitmap);
mController.onDestroy();
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/EligibleCardCheckerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/EligibleCardCheckerTest.java
index 7b70dad..3777920 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/EligibleCardCheckerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/EligibleCardCheckerTest.java
@@ -31,7 +31,6 @@
import androidx.slice.SliceProvider;
import androidx.slice.widget.SliceLiveData;
-import com.android.settings.homepage.contextualcards.deviceinfo.EmergencyInfoSlice;
import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.wifi.slice.ContextualWifiSlice;
@@ -66,14 +65,6 @@
}
@Test
- public void isSliceToggleable_cardWithoutToggle_returnFalse() {
- final EmergencyInfoSlice emergencyInfoSlice = new EmergencyInfoSlice(mContext);
- final Slice slice = emergencyInfoSlice.getSlice();
-
- assertThat(mEligibleCardChecker.isSliceToggleable(slice)).isFalse();
- }
-
- @Test
public void isCardEligibleToDisplay_toggleSlice_hasInlineActionShouldBeTrue() {
final ContextualWifiSlice wifiSlice = new ContextualWifiSlice(mContext);
final Slice slice = wifiSlice.getSlice();
@@ -85,17 +76,6 @@
}
@Test
- public void isCardEligibleToDisplay_notToggleSlice_hasInlineActionShouldBeFalse() {
- final EmergencyInfoSlice emergencyInfoSlice = new EmergencyInfoSlice(mContext);
- final Slice slice = emergencyInfoSlice.getSlice();
- doReturn(slice).when(mEligibleCardChecker).bindSlice(any(Uri.class));
-
- mEligibleCardChecker.isCardEligibleToDisplay(getContextualCard(TEST_SLICE_URI));
-
- assertThat(mEligibleCardChecker.mCard.hasInlineAction()).isFalse();
- }
-
- @Test
public void isCardEligibleToDisplay_customCard_returnTrue() {
final ContextualCard customCard = new ContextualCard.Builder()
.setName("custom_card")
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/DataUsageSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/DataUsageSliceTest.java
deleted file mode 100644
index 13f26e4..0000000
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/DataUsageSliceTest.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.homepage.contextualcards.deviceinfo;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import android.app.usage.NetworkStatsManager;
-import android.content.Context;
-import android.telephony.SubscriptionManager;
-import android.telephony.TelephonyManager;
-import androidx.core.graphics.drawable.IconCompat;
-import androidx.slice.Slice;
-import androidx.slice.SliceItem;
-import androidx.slice.SliceMetadata;
-import androidx.slice.SliceProvider;
-import androidx.slice.core.SliceAction;
-import androidx.slice.widget.SliceLiveData;
-import com.android.settings.R;
-import com.android.settings.testutils.SliceTester;
-import com.android.settings.testutils.shadow.ShadowDataUsageUtils;
-import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.Shadows;
-import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowTelephonyManager;
-
-@RunWith(RobolectricTestRunner.class)
-@Config(shadows = ShadowDataUsageUtils.class)
-public class DataUsageSliceTest {
- private static final String DATA_USAGE_TITLE = "Data usage";
- private static final String DATA_USAGE_SUMMARY = "test_summary";
-
- @Mock
- private NetworkStatsManager mNetworkStatsManager;
-
- private Context mContext;
- private DataUsageSlice mDataUsageSlice;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- mContext = spy(RuntimeEnvironment.application);
- // Set-up specs for SliceMetadata.
- SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
- when(mContext.getSystemService(NetworkStatsManager.class)).thenReturn(mNetworkStatsManager);
-
- mDataUsageSlice = spy(new DataUsageSlice(mContext));
-
- final TelephonyManager telephonyManager = mContext.getSystemService(TelephonyManager.class);
- final ShadowTelephonyManager shadowTelephonyManager = Shadows.shadowOf(telephonyManager);
- shadowTelephonyManager.setTelephonyManagerForSubscriptionId(
- SubscriptionManager.INVALID_SUBSCRIPTION_ID, telephonyManager);
- }
-
- @Test
- public void getSlice_hasSim_shouldBeCorrectSliceContent() {
- ShadowDataUsageUtils.HAS_SIM = true;
- doReturn(DATA_USAGE_TITLE).when(mDataUsageSlice).getDataUsageText(any());
- doReturn(DATA_USAGE_SUMMARY).when(mDataUsageSlice).getCycleTime(any());
-
- final Slice slice = mDataUsageSlice.getSlice();
-
- final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
- assertThat(metadata.getTitle()).isEqualTo(
- mContext.getString(R.string.data_usage_summary_title));
-
- final SliceAction primaryAction = metadata.getPrimaryAction();
- final IconCompat expectedIcon = IconCompat.createWithResource(mContext,
- R.drawable.ic_settings_data_usage);
- assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedIcon.toString());
- }
-
- @Test
- public void getSlice_hasNoSim_shouldShowNoSimCard() {
- ShadowDataUsageUtils.HAS_SIM = false;
-
- final Slice slice = mDataUsageSlice.getSlice();
-
- final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
- assertThat(metadata.getTitle()).isEqualTo(
- mContext.getString(R.string.data_usage_summary_title));
-
- final List<SliceItem> sliceItems = slice.getItems();
- SliceTester.assertAnySliceItemContainsTitle(sliceItems,
- mContext.getString(R.string.no_sim_card));
- }
-}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/DeviceInfoSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/DeviceInfoSliceTest.java
deleted file mode 100644
index ddc7218..0000000
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/DeviceInfoSliceTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.homepage.contextualcards.deviceinfo;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.spy;
-
-import android.content.Context;
-import android.telephony.SubscriptionInfo;
-
-import androidx.core.graphics.drawable.IconCompat;
-import androidx.slice.Slice;
-import androidx.slice.SliceItem;
-import androidx.slice.SliceMetadata;
-import androidx.slice.SliceProvider;
-import androidx.slice.core.SliceAction;
-import androidx.slice.widget.SliceLiveData;
-
-import com.android.settings.R;
-import com.android.settings.testutils.SliceTester;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
-import java.util.List;
-
-@RunWith(RobolectricTestRunner.class)
-public class DeviceInfoSliceTest {
-
- @Mock
- private SubscriptionInfo mSubscriptionInfo;
-
- private Context mContext;
- private DeviceInfoSlice mDeviceInfoSlice;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- mContext = RuntimeEnvironment.application;
-
- // Set-up specs for SliceMetadata.
- SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
-
- mDeviceInfoSlice = spy(new DeviceInfoSlice(mContext));
- }
-
- @Test
- public void getSlice_hasSubscriptionInfo_shouldBeCorrectSliceContent() {
- final String phoneNumber = "1111111111";
- doReturn(mSubscriptionInfo).when(mDeviceInfoSlice).getFirstSubscriptionInfo();
- doReturn(phoneNumber).when(mDeviceInfoSlice).getPhoneNumber();
-
- final Slice slice = mDeviceInfoSlice.getSlice();
-
- final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
- assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.device_info_label));
-
- final SliceAction primaryAction = metadata.getPrimaryAction();
- final IconCompat expectedIcon = IconCompat.createWithResource(mContext,
- R.drawable.ic_info_outline_24dp);
- assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedIcon.toString());
-
- final List<SliceItem> sliceItems = slice.getItems();
- SliceTester.assertAnySliceItemContainsTitle(sliceItems, phoneNumber);
- }
-
- @Test
- public void getSlice_hasNoSubscriptionInfo_shouldShowUnknown() {
- final Slice slice = mDeviceInfoSlice.getSlice();
-
- final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
- assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.device_info_label));
-
- final List<SliceItem> sliceItems = slice.getItems();
- SliceTester.assertAnySliceItemContainsTitle(sliceItems,
- mContext.getString(R.string.device_info_default));
- }
-}
diff --git a/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java b/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java
index 9f4fffc..37036c4 100644
--- a/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java
@@ -36,7 +36,6 @@
import androidx.slice.Slice;
import com.android.settings.R;
-import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.testutils.FakeFeatureFactory;
import org.junit.Before;
@@ -54,8 +53,6 @@
@RunWith(RobolectricTestRunner.class)
public class PanelSlicesAdapterTest {
- private static final Uri DATA_URI = CustomSliceRegistry.DATA_USAGE_SLICE_URI;
-
private Context mContext;
private PanelFragment mPanelFragment;
private PanelFeatureProvider mPanelFeatureProvider;
@@ -97,18 +94,6 @@
}
@Test
- public void onCreateViewHolder_returnsSliceRowViewHolder() {
- addTestLiveData(DATA_URI);
- final PanelSlicesAdapter adapter =
- new PanelSlicesAdapter(mPanelFragment, mData, 0 /* metrics category */);
- final ViewGroup view = new FrameLayout(mContext);
- final PanelSlicesAdapter.SliceRowViewHolder viewHolder =
- adapter.onCreateViewHolder(view, 0);
-
- assertThat(viewHolder.sliceView).isNotNull();
- }
-
- @Test
public void sizeOfAdapter_shouldNotExceedMaxNum() {
for (int i = 0; i < MAX_NUM_OF_SLICES + 2; i++) {
addTestLiveData(Uri.parse("uri" + i));
@@ -127,22 +112,6 @@
}
@Test
- public void nonMediaOutputIndicatorSlice_shouldAllowDividerAboveAndBelow() {
- addTestLiveData(DATA_URI);
- final PanelSlicesAdapter adapter =
- new PanelSlicesAdapter(mPanelFragment, mData, 0 /* metrics category */);
- final int position = 0;
- final ViewGroup view = new FrameLayout(mContext);
- final PanelSlicesAdapter.SliceRowViewHolder viewHolder =
- adapter.onCreateViewHolder(view, 0 /* view type*/);
-
- adapter.onBindViewHolder(viewHolder, position);
-
- assertThat(viewHolder.isDividerAllowedAbove()).isTrue();
- assertThat(viewHolder.isDividerAllowedBelow()).isTrue();
- }
-
- @Test
public void mediaOutputIndicatorSlice_shouldNotAllowDividerAbove() {
addTestLiveData(MEDIA_OUTPUT_INDICATOR_SLICE_URI);
@@ -157,4 +126,4 @@
assertThat(viewHolder.isDividerAllowedAbove()).isFalse();
}
-}
\ No newline at end of file
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java b/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java
index e1202ae..bf50742 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java
@@ -549,4 +549,13 @@
assertThat(advButton.getContentDescription()).isEqualTo(
mContext.getString(R.string.wifi_advanced_toggle_description));
}
+
+ @Test
+ public void getVisibility_whenAdvancedOptionClicked_shouldBeGone() {
+ final CheckBox advButton = mView.findViewById(R.id.wifi_advanced_togglebox);
+
+ advButton.performClick();
+
+ assertThat(advButton.getVisibility()).isEqualTo(View.GONE);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java b/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java
index aeec19a..eb4f326 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java
@@ -18,6 +18,7 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doNothing;
@@ -278,4 +279,11 @@
verify(menu).add(anyInt(), eq(WifiSettings2.MENU_ID_FORGET), anyInt(), anyInt());
verify(menu).add(anyInt(), eq(WifiSettings2.MENU_ID_DISCONNECT), anyInt(), anyInt());
}
+
+ @Test
+ public void onWifiEntriesChanged_shouldChangeNextButtonState() {
+ mWifiSettings2.onWifiEntriesChanged();
+
+ verify(mWifiSettings2).changeNextButtonState(anyBoolean());
+ }
}
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java
index 820a78b..36279cb 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java
@@ -35,7 +35,6 @@
import com.android.settings.R;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -49,6 +48,13 @@
private static final String ALL_BANDS = "5.0 GHz Band preferred";
private static final String TWO_GHZ_STRING = "2.4 GHz Band";
private static final String FIVE_GHZ_STRING = "5.0 GHz Band";
+ private static final String VAL_2GHZ_STR = "1";
+ private static final String VAL_5GHZ_STR = "2";
+ private static final String VAL_2_5_GHZ_STR = "3";
+ private static final int VAL_2GHZ_INT = 1;
+ private static final int VAL_5GHZ_INT = 2;
+ private static final int VAL_2_5_GHZ_INT = 3;
+
private Context mContext;
@Mock
private ConnectivityManager mConnectivityManager;
@@ -81,14 +87,16 @@
}
@Test
- @Ignore
public void display_5GhzSupported_shouldDisplayFullList() {
when(mWifiManager.getCountryCode()).thenReturn("US");
when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
when(mWifiManager.isDualModeSupported()).thenReturn(true);
+ // Create a new instance to pick the proper value of isDualModeSupported()
+ mController = new WifiTetherApBandPreferenceController(mContext, mListener);
+
mController.displayPreference(mScreen);
- mController.onPreferenceChange(mPreference, "-1");
+ mController.onPreferenceChange(mPreference, VAL_2_5_GHZ_STR);
assertThat(mPreference.getSummary()).isEqualTo(ALL_BANDS);
}
@@ -118,77 +126,77 @@
}
@Test
- @Ignore
public void changePreference_noDualModeWith5G_shouldUpdateValue() {
when(mWifiManager.getCountryCode()).thenReturn("US");
when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
mController.displayPreference(mScreen);
- // -1 is SoftApConfiguration.BAND_ANY, for 'Auto' option. This should be prevented from
- // being set since it is invalid for this configuration
- mController.onPreferenceChange(mPreference, "-1");
- assertThat(mController.getBandIndex()).isEqualTo(1);
+ // 'Auto' option should be prevented from being set since
+ // it is invalid for this configuration
+ mController.onPreferenceChange(mPreference, VAL_2_5_GHZ_STR);
+ assertThat(mController.getBandIndex()).isEqualTo(VAL_5GHZ_INT);
assertThat(mPreference.getSummary()).isEqualTo(FIVE_GHZ_STRING);
verify(mListener, times(1)).onTetherConfigUpdated(mController);
// set to 5 Ghz
- mController.onPreferenceChange(mPreference, "1");
- assertThat(mController.getBandIndex()).isEqualTo(1);
+ mController.onPreferenceChange(mPreference, VAL_5GHZ_STR);
+ assertThat(mController.getBandIndex()).isEqualTo(VAL_5GHZ_INT);
assertThat(mPreference.getSummary()).isEqualTo(FIVE_GHZ_STRING);
verify(mListener, times(2)).onTetherConfigUpdated(mController);
// set to 2 Ghz
- mController.onPreferenceChange(mPreference, "0");
- assertThat(mController.getBandIndex()).isEqualTo(0);
+ mController.onPreferenceChange(mPreference, VAL_2GHZ_STR);
+ assertThat(mController.getBandIndex()).isEqualTo(VAL_2GHZ_INT);
assertThat(mPreference.getSummary()).isEqualTo(TWO_GHZ_STRING);
verify(mListener, times(3)).onTetherConfigUpdated(mController);
}
@Test
- @Ignore
public void changePreference_dualModeWith5G_shouldUpdateValue() {
when(mWifiManager.getCountryCode()).thenReturn("US");
when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
when(mWifiManager.isDualModeSupported()).thenReturn(true);
+ // Create a new instance to pick the proper value of isDualModeSupported()
+ mController = new WifiTetherApBandPreferenceController(mContext, mListener);
+
mController.displayPreference(mScreen);
- // -1 is SoftApConfiguration.BAND_ANY, for 'Auto' option.
- mController.onPreferenceChange(mPreference, "-1");
- assertThat(mController.getBandIndex()).isEqualTo(-1);
+ // 'Auto' option
+ mController.onPreferenceChange(mPreference, VAL_2_5_GHZ_STR);
+ assertThat(mController.getBandIndex()).isEqualTo(VAL_2_5_GHZ_INT);
assertThat(mPreference.getSummary()).isEqualTo(ALL_BANDS);
verify(mListener, times(1)).onTetherConfigUpdated(mController);
// should revert to the default for 5 Ghz only since this is not supported with this config
- mController.onPreferenceChange(mPreference, "1");
- assertThat(mController.getBandIndex()).isEqualTo(-1);
+ mController.onPreferenceChange(mPreference, VAL_5GHZ_STR);
+ assertThat(mController.getBandIndex()).isEqualTo(VAL_2_5_GHZ_INT);
assertThat(mPreference.getSummary()).isEqualTo(ALL_BANDS);
verify(mListener, times(2)).onTetherConfigUpdated(mController);
// set to 2 Ghz
- mController.onPreferenceChange(mPreference, "0");
- assertThat(mController.getBandIndex()).isEqualTo(0);
+ mController.onPreferenceChange(mPreference, VAL_2GHZ_STR);
+ assertThat(mController.getBandIndex()).isEqualTo(VAL_2GHZ_INT);
assertThat(mPreference.getSummary()).isEqualTo(TWO_GHZ_STRING);
verify(mListener, times(3)).onTetherConfigUpdated(mController);
}
@Test
- @Ignore
public void updateDisplay_shouldUpdateValue() {
when(mWifiManager.getCountryCode()).thenReturn("US");
when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
- // Set controller band index to 1 and verify is set.
+ // Set controller band index to 5GHz and verify is set.
mController.displayPreference(mScreen);
- mController.onPreferenceChange(mPreference, "1");
- assertThat(mController.getBandIndex()).isEqualTo(1);
+ mController.onPreferenceChange(mPreference, VAL_5GHZ_STR);
+ assertThat(mController.getBandIndex()).isEqualTo(VAL_5GHZ_INT);
// Disable 5Ghz band
when(mWifiManager.is5GHzBandSupported()).thenReturn(false);
// Call updateDisplay and verify it's changed.
mController.updateDisplay();
- assertThat(mController.getBandIndex()).isEqualTo(0);
+ assertThat(mController.getBandIndex()).isEqualTo(VAL_2GHZ_INT);
}
}