Merge "Wifi: Fix rototests for wifi tethering"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index fca80b4..ab3be11 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] -->
@@ -1956,8 +1954,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 -->
@@ -7319,6 +7315,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 +11213,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/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..ee3eaa4 100644
--- a/src/com/android/settings/AirplaneModeEnabler.java
+++ b/src/com/android/settings/AirplaneModeEnabler.java
@@ -104,8 +104,8 @@
}
}
- for (ServiceStateListener ssListener : mServiceStateListeners) {
- ssListener.start();
+ for (ServiceStateListener listener : mServiceStateListeners) {
+ listener.start();
}
}
@@ -113,8 +113,8 @@
if (mServiceStateListeners == null) {
return;
}
- for (ServiceStateListener ssListener : mServiceStateListeners) {
- ssListener.stop();
+ for (ServiceStateListener listener : mServiceStateListeners) {
+ listener.stop();
}
mServiceStateListeners = null;
}
@@ -210,9 +210,9 @@
mEnabler = enabler;
}
- private int mSubId;
- private TelephonyManager mTelephonyManager;
- private AirplaneModeEnabler mEnabler;
+ private final int mSubId;
+ private final TelephonyManager mTelephonyManager;
+ private final AirplaneModeEnabler mEnabler;
int getSubscriptionId() {
return mSubId;
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/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..3e8a42c 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);
}
@@ -1554,17 +1558,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 +1671,7 @@
((CheckBox) mView.findViewById(R.id.wifi_advanced_togglebox))
.setOnCheckedChangeListener(this);
// Set correct accessibility strings.
- setAdvancedOptionAccessibilityString(false /* showAdvancedFields */);
+ setAdvancedOptionAccessibilityString();
}
/**
@@ -1766,7 +1763,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 +1774,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/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/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);
+ }
}