Merge "Remove hotspot receiver from manifest." into oc-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 782ca2b..ecba241 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -895,23 +895,13 @@
android:icon="@drawable/ic_settings_night_display"
android:taskAffinity="">
<intent-filter android:priority="1">
- <action android:name="android.intent.action.MAIN" />
- <category android:name="com.android.settings.suggested.category.SETTINGS_ONLY" />
- </intent-filter>
- <intent-filter android:priority="1">
<action android:name="android.settings.NIGHT_DISPLAY_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
- <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
- android:value="true" />
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.display.NightDisplaySettings" />
- <meta-data android:name="com.android.settings.dismiss"
- android:value="30" />
- <meta-data android:name="com.android.settings.title"
- android:resource="@string/night_display_suggestion_title" />
- <meta-data android:name="com.android.settings.summary"
- android:resource="@string/night_display_suggestion_summary" />
+ <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
+ android:value="true" />
</activity>
<activity android:name="Settings$DeviceInfoSettingsActivity"
@@ -2856,7 +2846,7 @@
android:label="@string/install_other_apps"
android:taskAffinity="">
<intent-filter android:priority="1">
- <action android:name="android.settings.action.MANAGE_EXTERNAL_SOURCES" />
+ <action android:name="android.settings.action.MANAGE_UNKNOWN_APP_SOURCES" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
@@ -2867,7 +2857,7 @@
android:label="@string/install_other_apps"
android:taskAffinity="">
<intent-filter android:priority="1">
- <action android:name="android.settings.action.MANAGE_EXTERNAL_SOURCES" />
+ <action android:name="android.settings.action.MANAGE_UNKNOWN_APP_SOURCES" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="package" />
</intent-filter>
diff --git a/res/layout/app_details.xml b/res/layout/app_details.xml
index 4aa1496..5ffeec5 100644
--- a/res/layout/app_details.xml
+++ b/res/layout/app_details.xml
@@ -26,17 +26,23 @@
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:paddingTop="24dp"
- android:paddingBottom="24dp" >
+ android:paddingBottom="24dp"
+ android:clipChildren="false"
+ android:clipToPadding="false">
<!-- App snippet with buttons -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingStart="8dp">
+ android:paddingStart="8dp"
+ android:clipChildren="false"
+ android:clipToPadding="false">
<FrameLayout android:id="@+id/app_icon_frame"
android:layout_width="80dp"
- android:layout_height="80dp">
+ android:layout_height="80dp"
+ android:clipChildren="false"
+ android:clipToPadding="false">
<ImageView
android:id="@+id/app_detail_icon"
android:layout_width="match_parent"
diff --git a/res/layout/preference_bluetooth.xml b/res/layout/preference_bluetooth.xml
deleted file mode 100644
index c339e67..0000000
--- a/res/layout/preference_bluetooth.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2006 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.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical">
-
- <!-- Details button -->
- <ImageView
- android:id="@+id/deviceDetails"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
- android:padding="8dip"
- android:background="?android:attr/selectableItemBackground"
- android:src="@drawable/ic_settings"
- android:contentDescription="@string/bluetooth_device_details" />
-
-</LinearLayout>
diff --git a/res/layout/preference_progress_category.xml b/res/layout/preference_progress_category.xml
index 1380698..9f5a8b4 100644
--- a/res/layout/preference_progress_category.xml
+++ b/res/layout/preference_progress_category.xml
@@ -35,7 +35,6 @@
android:id="@android:id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:tint="?android:attr/textColorPrimary"
android:maxWidth="18dp"
android:maxHeight="18dp"/>
</LinearLayout>
@@ -47,7 +46,8 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="start|center"
- android:textAppearance="@android:style/TextAppearance.Material.Body2"/>
+ android:textAppearance="@android:style/TextAppearance.Material.Body2"
+ android:textColor="?android:attr/colorAccent"/>
<ProgressBar
android:id="@+id/scanning_progress"
diff --git a/res/layout/preference_widget_summary.xml b/res/layout/preference_widget_summary.xml
index aa4c76b..2d7ed1d 100644
--- a/res/layout/preference_widget_summary.xml
+++ b/res/layout/preference_widget_summary.xml
@@ -18,5 +18,6 @@
android:id="@+id/widget_summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:textAlignment="viewEnd"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary" />
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 8980568..873576c 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -388,6 +388,21 @@
<item>GTC</item>
</string-array>
+ <!-- Type of EAP method when EAP SIM, AKA, AKA' are supported -->
+ <string-array name="wifi_peap_phase2_entries_with_sim_auth">
+ <item>None</item>
+ <!-- Do not translate. -->
+ <item>MSCHAPV2</item>
+ <!-- Do not translate. -->
+ <item>GTC</item>
+ <!-- Do not translate. -->
+ <item>SIM</item>
+ <!-- Do not translate. -->
+ <item>AKA</item>
+ <!-- Do not translate. -->
+ <item>AKA\'</item>
+ </string-array>
+
<!-- Phase 2 options for rest of EAP methods -->
<string-array name="wifi_phase2_entries">
<item>None</item>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 5efaf1e..09f7cda 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -240,6 +240,8 @@
<dimen name="mdm_app_name_padding_left">16dp</dimen>
<dimen name="mdm_app_icon_width_height">56dp</dimen>
+ <!-- Launcher Icons -->
+ <dimen name="launcher_icon_elevation">6dp</dimen>
<dimen name="shortcut_size_maskable">120dp</dimen>
<dimen name="shortcut_size">40dp</dimen>
<dimen name="shortcut_icon_size">16dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index f6b36b4..57abe34 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -743,7 +743,7 @@
<!-- Main Settings screen setting option title for the item to take you to the accounts screen [CHAR LIMIT=22] -->
<string name="account_settings_title">Accounts</string>
<!-- Main Settings screen setting option title for the item to take you to the security screen -->
- <string name="security_settings_title">Security & screen lock</string>
+ <string name="security_settings_title">Security & Location</string>
<!-- Security Settings screen setting option title for the item to take you to the encryption and credential screen -->
<string name="encryption_and_credential_settings_title">Encryption & credentials</string>
<!-- Security Settings screen Encryption and crendential summary -->
@@ -762,9 +762,9 @@
<!-- In the security screen, the header title for security statuses -->
<string name="security_status_title">Security status</string>
<!-- Summary for Security settings, explaining a few important settings under it [CHAR LIMIT=NONE]-->
- <string name="security_dashboard_summary">Location, fingerprint</string>
+ <string name="security_dashboard_summary">Screen lock, fingerprint</string>
<!-- Summary for Security settings when fingerprint is not supported [CHAR LIMIT=NONE]-->
- <string name="security_dashboard_summary_no_fingerprint">Location</string>
+ <string name="security_dashboard_summary_no_fingerprint">Screen lock</string>
<!-- Fingerprint enrollment and settings --><skip />
<!-- Title shown for menu item that launches fingerprint settings or enrollment [CHAR LIMIT=22] -->
<string name="security_settings_fingerprint_preference_title">Fingerprint</string>
@@ -1886,11 +1886,11 @@
<!-- Wifi Network Details -->
<!-- Wifi details preference title to display router IP subnet mask -->
- <string name="wifi_details_subnet_mask">Subnet Mask</string>
+ <string name="wifi_details_subnet_mask">Subnet mask</string>
<!-- Wifi details preference title to display router DNS info -->
<string name="wifi_details_dns">DNS</string>
<!-- Wifi details preference category title for IPv6 information -->
- <string name="wifi_details_ipv6_address_header">IPv6 Addresses</string>
+ <string name="wifi_details_ipv6_address_header">IPv6 addresses</string>
<!-- Wifi saved access points. Used as a label under the shortcut icon that goes to Wifi saved access points. [CHAR LIMIT=20] -->
<string name="wifi_saved_access_points_label">Saved networks</string>
@@ -2365,6 +2365,8 @@
<string name="screensaver_settings_disabled_prompt">To control what happens when the phone is docked and/or sleeping, turn screen saver on.</string>
<!-- Dream settings screen, action label, when to dream -->
<string name="screensaver_settings_when_to_dream">When to start</string>
+ <!-- Dream settings screen, action label, current selected screen saver -->
+ <string name="screensaver_settings_current">Current screen saver</string>
<!-- Dream settings screen, button label to start dreaming -->
<string name="screensaver_settings_dream_start">Start now</string>
<!-- Dream settings screen, button label for settings for a specific screensaver -->
@@ -3065,7 +3067,7 @@
<string name="tether_settings_title_bluetooth">Bluetooth tethering</string>
<!-- Tethering controls, item title to go into the tethering settings when USB and Bluetooth tethering are available [CHAR LIMIT=25]-->
<string name="tether_settings_title_usb_bluetooth">Tethering</string>
- <!-- Tethering controls, item title to go into the tethering settings when USB, Bluetooth and Wifi tethering are available [CHAR LIMIT=50]-->
+ <!-- Tethering controls, item title to go into the tethering settings when USB, Bluetooth and Wifi tethering are available [CHAR LIMIT=60]-->
<string name="tether_settings_title_all">Hotspot & tethering</string>
<!-- Tethering setting summary when both Wi-Fi hotspot and tether are turned on [CHAR LIMIT=NONE]-->
<string name="tether_settings_summary_hotspot_on_tether_on">Hotspot on, tethering</string>
@@ -3861,7 +3863,7 @@
<string name="language_settings">Languages & input</string>
<!-- Title of Languages & input settings screen -->
<string name="language_keyboard_settings_title">Languages & input</string>
- <!-- Title of preference category that lists all settings about helping user input such as spell checker [CHAR LIMIT=60]-->
+ <!-- Title of preference category that lists all settings about helping user text input such as spell checker [CHAR LIMIT=60]-->
<string name="input_assistance">Input assistance</string>
<!-- On Languages & input settings screen, heading. Inside the "Languages & input settings" screen, this is the header for settings that relate to keyboard (enable/disable each keyboard, settings for each keyboard). -->
<string name="keyboard_settings_category">Keyboard & input methods</string>
@@ -6424,10 +6426,10 @@
<!-- Do not disturb: Title for the zen mode automation listing. [CHAR LIMIT=30] -->
<string name="zen_mode_automation_settings_title">Automatic rules</string>
- <!-- Do not disturb: Title for the zen mode automation option Suggestion. [CHAR LIMIT=30] -->
+ <!-- Do not disturb: Title for the zen mode automation option Suggestion. [CHAR LIMIT=50] -->
<string name="zen_mode_automation_suggestion_title">Set Do Not Disturb rules</string>
- <!-- Do not disturb: Summary for the zen mode automation option Suggestion. [CHAR LIMIT=30] -->
+ <!-- Do not disturb: Summary for the zen mode automation option Suggestion. [CHAR LIMIT=NONE] -->
<string name="zen_mode_automation_suggestion_summary">Limit sounds & vibrations at certain times</string>
<!-- Do not disturb: Zen mode option: Important interruptions [CHAR LIMIT=60] -->
@@ -7871,12 +7873,6 @@
<!-- Summary of condition that work mode is off [CHAR LIMIT=NONE] -->
<string name="condition_work_summary">Apps, background sync, and other features related to your work profile are turned off.</string>
- <!-- Night display: Title for the night display option Suggestion (renamed "Night Light" with title caps). [CHAR LIMIT=NONE] -->
- <string name="night_display_suggestion_title">Set Night Light schedule</string>
-
- <!-- Night display: Summary for the night display option Suggestion (renamed "Night Light" with title caps). [CHAR LIMIT=30] -->
- <string name="night_display_suggestion_summary">Tint screen amber to help you fall asleep</string>
-
<!-- Title of condition that night display is on (renamed "Night Light" with title caps). [CHAR LIMIT=30] -->
<string name="condition_night_display_title">Night Light is on</string>
@@ -8390,7 +8386,7 @@
<!-- Summary text for ambient display (device) [CHAR LIMIT=160]-->
<string name="ambient_display_pickup_summary" product="device">To quickly check your notifications, pick up your device.</string>
- <!-- Title text for fingerprint swipe for notifications [CHAR LIMIT=80]-->
+ <!-- Title text for swiping downwards on fingerprint sensor for notifications [CHAR LIMIT=80]-->
<string name="fingerprint_swipe_for_notifications_title">Swipe fingerprint for notifications</string>
<!-- Summary text for fingerprint swipe for notifications (phone) [CHAR LIMIT=160]-->
@@ -8425,14 +8421,16 @@
<string name="automatic_storage_manager_freed_bytes"><xliff:g id="size" example="3.25MB">%1$s</xliff:g> total made available\n\nLast ran on <xliff:g id="date" example="Jan 12">%2$s</xliff:g></string>
<!-- Title text for enabling web actions. [CHAR_LIMIT=60] -->
- <string name="web_action_enable_title">Open links in apps</string>
+ <string name="web_action_enable_title">Instant apps</string>
<!-- Summary text for enabling web actions. [CHAR_LIMIT=250] -->
- <string name="web_action_enable_summary">Open links in supported apps, even if the
- apps aren’t installed on your device</string>
+ <string name="web_action_enable_summary">Open links in apps, even if they’re not installed</string>
<!-- Section title for the Web Action preference [CHAR LIMIT=60] -->
- <string name="web_action_section_title">Apps not installed</string>
+ <string name="web_action_section_title">Instant apps</string>
+
+ <!-- Preference label for an tappable preference that will open the account chooser for instant apps. [CHAR LIMIT=60] -->
+ <string name="instant_apps_account">Instant apps account</string>
<!-- Section title for the Domain URL app preference list [CHAR LIMIT=60]-->
<string name="domain_url_section_title">Installed apps</string>
diff --git a/res/xml/empty_settings.xml b/res/xml/empty_settings.xml
new file mode 100644
index 0000000..d63f7d6
--- /dev/null
+++ b/res/xml/empty_settings.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2017 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<PreferenceScreen />
diff --git a/res/xml/installed_app_details_ia.xml b/res/xml/installed_app_details_ia.xml
index 50d183d..b092753 100644
--- a/res/xml/installed_app_details_ia.xml
+++ b/res/xml/installed_app_details_ia.xml
@@ -43,31 +43,37 @@
<Preference
android:key="permission_settings"
android:title="@string/permissions_label"
+ android:summary="@string/summary_placeholder"
android:selectable="true"/>
<Preference
android:key="storage_settings"
android:title="@string/storage_settings"
+ android:summary="@string/summary_placeholder"
android:selectable="true"/>
<Preference
android:key="data_settings"
android:title="@string/data_usage_summary_title"
+ android:summary="@string/summary_placeholder"
android:selectable="true"/>
<Preference
android:key="battery"
android:title="@string/power_usage_summary_title"
+ android:summary="@string/summary_placeholder"
android:selectable="true"/>
<Preference
android:key="preferred_settings"
android:title="@string/launch_by_default"
+ android:summary="@string/summary_placeholder"
android:selectable="true"/>
<Preference
android:key="memory"
android:title="@string/memory_settings_title"
+ android:summary="@string/summary_placeholder"
android:enabled="false"
android:selectable="true"/>
diff --git a/res/xml/wifi_network_details_fragment.xml b/res/xml/wifi_network_details_fragment.xml
index 09bcf86..5b20d59 100644
--- a/res/xml/wifi_network_details_fragment.xml
+++ b/res/xml/wifi_network_details_fragment.xml
@@ -55,11 +55,15 @@
android:key="ip_details_category"
android:title="@string/wifi_setup_detail">
<com.android.settings.wifi.WifiDetailPreference
+ android:key="mac_address"
+ android:title="@string/wifi_advanced_mac_address_title"
+ android:selectable="false"/>
+ <com.android.settings.wifi.WifiDetailPreference
android:key="ip_address"
android:title="@string/wifi_ip_address"
android:selectable="false"/>
<com.android.settings.wifi.WifiDetailPreference
- android:key="router"
+ android:key="gateway"
android:title="@string/wifi_gateway"
android:selectable="false"/>
<com.android.settings.wifi.WifiDetailPreference
diff --git a/src/com/android/settings/ApnSettings.java b/src/com/android/settings/ApnSettings.java
index 5e31a02..b460050 100755
--- a/src/com/android/settings/ApnSettings.java
+++ b/src/com/android/settings/ApnSettings.java
@@ -184,8 +184,7 @@
mUnavailable = isUiRestricted();
setHasOptionsMenu(!mUnavailable);
if (mUnavailable) {
- setPreferenceScreen(new PreferenceScreen(getPrefContext(), null));
- getPreferenceScreen().removeAll();
+ addPreferencesFromResource(R.xml.empty_settings);
return;
}
diff --git a/src/com/android/settings/applications/AppHeaderController.java b/src/com/android/settings/applications/AppHeaderController.java
index b138ede..9e41679 100644
--- a/src/com/android/settings/applications/AppHeaderController.java
+++ b/src/com/android/settings/applications/AppHeaderController.java
@@ -24,6 +24,8 @@
import android.content.pm.PackageInfo;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
+import android.graphics.Outline;
+import android.graphics.drawable.AdaptiveIconDrawable;
import android.graphics.drawable.Drawable;
import android.os.UserHandle;
import android.support.annotation.IntDef;
@@ -31,6 +33,7 @@
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
+import android.view.ViewOutlineProvider;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
@@ -61,12 +64,23 @@
public static final String PREF_KEY_APP_HEADER = "pref_app_header";
+ public static final ViewOutlineProvider OUTLINE_PROVIDER = new ViewOutlineProvider() {
+ @Override
+ public void getOutline(View view, Outline outline) {
+ Drawable background = ((ImageView)view).getDrawable();
+ if (background != null) {
+ background.getOutline(outline);
+ }
+ }
+ };
+
private static final String TAG = "AppDetailFeature";
private final Context mContext;
private final Fragment mFragment;
private final int mMetricsCategory;
private final View mAppHeader;
+ private final int mIconElevation;
private Drawable mIcon;
private CharSequence mLabel;
@@ -93,6 +107,8 @@
mAppHeader = LayoutInflater.from(fragment.getContext())
.inflate(R.layout.app_details, null /* root */);
}
+ mIconElevation = mContext.getResources()
+ .getDimensionPixelSize(R.dimen.launcher_icon_elevation);
}
public AppHeaderController setIcon(Drawable icon) {
@@ -212,6 +228,13 @@
ImageView iconView = (ImageView) mAppHeader.findViewById(R.id.app_detail_icon);
if (iconView != null) {
iconView.setImageDrawable(mIcon);
+ if (mIcon instanceof AdaptiveIconDrawable) {
+ iconView.setElevation(mIconElevation);
+ iconView.setOutlineProvider(OUTLINE_PROVIDER);
+ } else {
+ iconView.setElevation(0);
+ iconView.setOutlineProvider(null);
+ }
ImageView badgeView = mAppHeader.findViewById(R.id.app_icon_instant_apps_badge);
if (badgeView != null) {
badgeView.setVisibility(mIsInstantApp ? View.VISIBLE : View.GONE);
diff --git a/src/com/android/settings/applications/AppStorageSettings.java b/src/com/android/settings/applications/AppStorageSettings.java
index d5d72bc..8d41558 100644
--- a/src/com/android/settings/applications/AppStorageSettings.java
+++ b/src/com/android/settings/applications/AppStorageSettings.java
@@ -101,6 +101,8 @@
private static final String KEY_URI_CATEGORY = "uri_category";
private static final String KEY_CLEAR_URI = "clear_uri_button";
+ private static final String KEY_CACHE_CLEARED = "cache_cleared";
+
// Views related to cache info
private Preference mCacheSize;
private Button mClearDataButton;
@@ -115,6 +117,7 @@
private PreferenceCategory mUri;
private boolean mCanClearData = true;
+ private boolean mCacheCleared;
private AppStorageStats mLastResult;
private AppStorageSizesController mSizeController;
@@ -133,6 +136,9 @@
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ if (savedInstanceState != null) {
+ mCacheCleared = savedInstanceState.getBoolean(KEY_CACHE_CLEARED, false);
+ }
addPreferencesFromResource(R.xml.app_storage_settings);
setupViews();
@@ -145,6 +151,12 @@
updateSize();
}
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putBoolean(KEY_CACHE_CLEARED, mCacheCleared);
+ }
+
private void setupViews() {
mComputingStr = getActivity().getText(R.string.computing_size);
mInvalidSizeStr = getActivity().getText(R.string.invalid_size_value);
@@ -523,6 +535,10 @@
}
private void updateUiWithSize(AppStorageStats result) {
+ if (mCacheCleared) {
+ mSizeController.setCacheCleared(true);
+ }
+
mSizeController.updateUi(getContext());
if (result == null) {
@@ -539,7 +555,7 @@
mClearDataButton.setEnabled(true);
mClearDataButton.setOnClickListener(this);
}
- if (cacheSize <= 0) {
+ if (cacheSize <= 0 || mCacheCleared) {
mClearCacheButton.setEnabled(false);
} else {
mClearCacheButton.setEnabled(true);
@@ -562,6 +578,7 @@
processClearMsg(msg);
break;
case MSG_CLEAR_CACHE:
+ mCacheCleared = true;
// Refresh size info
updateSize();
break;
diff --git a/src/com/android/settings/applications/AppStorageSizesController.java b/src/com/android/settings/applications/AppStorageSizesController.java
index bc8f680..94935bd 100644
--- a/src/com/android/settings/applications/AppStorageSizesController.java
+++ b/src/com/android/settings/applications/AppStorageSizesController.java
@@ -39,6 +39,7 @@
@Nullable
private StorageStatsSource.AppStorageStats mLastResult;
private boolean mLastResultFailed;
+ private boolean mCachedCleared;
private long mLastCodeSize = -1;
private long mLastDataSize = -1;
private long mLastCacheSize = -1;
@@ -77,7 +78,7 @@
mLastDataSize = dataSize;
mDataSize.setSummary(getSizeStr(context, dataSize));
}
- long cacheSize = mLastResult.getCacheBytes();
+ long cacheSize = mCachedCleared ? 0 : mLastResult.getCacheBytes();
if (mLastCacheSize != cacheSize) {
mLastCacheSize = cacheSize;
mCacheSize.setSummary(getSizeStr(context, cacheSize));
@@ -100,6 +101,15 @@
mLastResultFailed = result == null;
}
+ /**
+ * Sets if we have cleared the cache and should zero the cache bytes.
+ * When the cache is cleared, the cache directories are recreated. These directories have
+ * some size, but are empty. We zero this out to best match user expectations.
+ */
+ public void setCacheCleared(boolean isCleared) {
+ mCachedCleared = isCleared;
+ }
+
private String getSizeStr(Context context, long size) {
return Formatter.formatFileSize(context, size);
}
diff --git a/src/com/android/settings/applications/ManageApplications.java b/src/com/android/settings/applications/ManageApplications.java
index 229e294..0c28461 100644
--- a/src/com/android/settings/applications/ManageApplications.java
+++ b/src/com/android/settings/applications/ManageApplications.java
@@ -23,6 +23,7 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageItemInfo;
import android.content.pm.PackageManager;
+import android.graphics.drawable.AdaptiveIconDrawable;
import android.icu.text.AlphabeticIndex;
import android.os.Bundle;
import android.os.Environment;
@@ -34,6 +35,7 @@
import android.support.annotation.VisibleForTesting;
import android.text.TextUtils;
import android.util.ArraySet;
+import android.util.LauncherIcons;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -90,7 +92,6 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
-import java.util.List;
import java.util.Locale;
import java.util.Set;
@@ -812,6 +813,8 @@
private final AppStateBaseBridge mExtraInfoBridge;
private final Handler mBgHandler;
private final Handler mFgHandler;
+ private final LauncherIcons mLauncherIcons;
+
private int mFilterMode;
private ArrayList<ApplicationsState.AppEntry> mBaseEntries;
private ArrayList<ApplicationsState.AppEntry> mEntries;
@@ -866,6 +869,7 @@
mContext = manageApplications.getActivity();
mPm = mContext.getPackageManager();
mFilterMode = filterMode;
+ mLauncherIcons = new LauncherIcons(mContext);
if (mManageApplications.mListType == LIST_TYPE_NOTIFICATION) {
mExtraInfoBridge = new AppStateNotificationBridge(mContext, mState, this,
manageApplications.mNotifBackend);
@@ -1300,6 +1304,9 @@
}
mState.ensureIcon(entry);
if (entry.icon != null) {
+ if (entry.icon instanceof AdaptiveIconDrawable) {
+ entry.icon = mLauncherIcons.wrapIconDrawableWithShadow(entry.icon);
+ }
holder.appIcon.setImageDrawable(entry.icon);
}
updateSummary(holder);
diff --git a/src/com/android/settings/applications/ManageDomainUrls.java b/src/com/android/settings/applications/ManageDomainUrls.java
index b09a089..bdc9932 100644
--- a/src/com/android/settings/applications/ManageDomainUrls.java
+++ b/src/com/android/settings/applications/ManageDomainUrls.java
@@ -15,7 +15,9 @@
package com.android.settings.applications;
import android.app.Application;
+import android.content.ComponentName;
import android.content.Context;
+import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.UserHandle;
@@ -55,6 +57,7 @@
private ApplicationsState.Session mSession;
private PreferenceGroup mDomainAppList;
private SwitchPreference mWebAction;
+ private Preference mInstantAppAccountPreference;
@Override
public void onCreate(Bundle icicle) {
@@ -126,6 +129,26 @@
mWebAction.setOnPreferenceChangeListener(this);
webActionCategory.addPreference(mWebAction);
+ // Determine whether we should show the instant apps account chooser setting
+ ComponentName instantAppSettingsComponent = getActivity().getPackageManager()
+ .getInstantAppResolverSettingsComponent();
+ Intent instantAppSettingsIntent = null;
+ if (instantAppSettingsComponent != null) {
+ instantAppSettingsIntent =
+ new Intent().setComponent(instantAppSettingsComponent);
+ }
+ if (instantAppSettingsIntent != null) {
+ final Intent launchIntent = instantAppSettingsIntent;
+ // TODO: Make this button actually launch the account chooser.
+ mInstantAppAccountPreference = new Preference(getPrefContext());
+ mInstantAppAccountPreference.setTitle(R.string.instant_apps_account);
+ mInstantAppAccountPreference.setOnPreferenceClickListener(pref -> {
+ startActivity(launchIntent);
+ return true;
+ });
+ webActionCategory.addPreference(mInstantAppAccountPreference);
+ }
+
// list to manage link handling per app
mDomainAppList = new PreferenceCategory(getPrefContext());
mDomainAppList.setTitle(R.string.domain_url_section_title);
@@ -138,9 +161,11 @@
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (preference == mWebAction) {
- final int enabled = (boolean) newValue ? 1 : 0;
+ boolean checked = (boolean) newValue;
Settings.Secure.putInt(
- getContentResolver(), Settings.Secure.WEB_ACTION_ENABLED, enabled);
+ getContentResolver(),
+ Settings.Secure.WEB_ACTION_ENABLED, checked ? 1 : 0);
+ mWebAction.setChecked(checked);
return true;
}
return false;
diff --git a/src/com/android/settings/applications/RunningProcessesView.java b/src/com/android/settings/applications/RunningProcessesView.java
index dcb6f9e..b365435 100644
--- a/src/com/android/settings/applications/RunningProcessesView.java
+++ b/src/com/android/settings/applications/RunningProcessesView.java
@@ -411,7 +411,7 @@
args.putBoolean(RunningServiceDetails.KEY_BACKGROUND, mAdapter.mShowBackground);
SettingsActivity sa = (SettingsActivity) mOwner.getActivity();
- sa.startPreferencePanel(null, RunningServiceDetails.class.getName(), args,
+ sa.startPreferencePanel(mOwner, RunningServiceDetails.class.getName(), args,
R.string.runningservicedetails_settings_title, null, null, 0);
}
}
diff --git a/src/com/android/settings/applications/RunningServiceDetails.java b/src/com/android/settings/applications/RunningServiceDetails.java
index 9a173bc..84c2ee5 100644
--- a/src/com/android/settings/applications/RunningServiceDetails.java
+++ b/src/com/android/settings/applications/RunningServiceDetails.java
@@ -33,9 +33,9 @@
import android.widget.TextView;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.R;
import com.android.settings.Utils;
+import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import java.io.File;
@@ -493,19 +493,20 @@
}
});
}
-
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
+ setHasOptionsMenu(true);
mUid = getArguments().getInt(KEY_UID, -1);
mUserId = getArguments().getInt(KEY_USER_ID, 0);
mProcessName = getArguments().getString(KEY_PROCESS, null);
mShowBackground = getArguments().getBoolean(KEY_BACKGROUND, false);
-
- mAm = (ActivityManager)getActivity().getSystemService(Context.ACTIVITY_SERVICE);
- mInflater = (LayoutInflater)getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
-
+
+ mAm = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE);
+ mInflater = (LayoutInflater) getActivity().getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE);
+
mState = RunningState.getInstance(getActivity());
}
diff --git a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
index 5bddffa..7be6dd7 100644
--- a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
+++ b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
@@ -30,14 +30,13 @@
import android.util.Log;
import android.util.Pair;
import android.util.TypedValue;
-import android.view.View;
-import android.view.View.OnClickListener;
import android.widget.ImageView;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.widget.GearPreference;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.HidProfile;
import com.android.settingslib.bluetooth.LocalBluetoothProfile;
@@ -50,15 +49,14 @@
* BluetoothDevicePreference is the preference type used to display each remote
* Bluetooth device in the Bluetooth Settings screen.
*/
-public final class BluetoothDevicePreference extends Preference implements
- CachedBluetoothDevice.Callback, OnClickListener {
- private static final String TAG = "BluetoothDevicePreference";
+public final class BluetoothDevicePreference extends GearPreference implements
+ CachedBluetoothDevice.Callback {
+ private static final String TAG = "BluetoothDevicePref";
private static int sDimAlpha = Integer.MIN_VALUE;
private final CachedBluetoothDevice mCachedDevice;
-
- private OnClickListener mOnSettingsClickListener;
+ private final UserManager mUserManager;
private AlertDialog mDisconnectDialog;
@@ -76,7 +74,8 @@
public final String BLUETOOTH = r.getString(R.string.bluetooth_talkback_bluetooth);
public BluetoothDevicePreference(Context context, CachedBluetoothDevice cachedDevice) {
- super(context);
+ super(context, null);
+ mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
if (sDimAlpha == Integer.MIN_VALUE) {
TypedValue outValue = new TypedValue();
@@ -85,14 +84,6 @@
}
mCachedDevice = cachedDevice;
-
- if (cachedDevice.getBondState() == BluetoothDevice.BOND_BONDED) {
- UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
- if (!um.hasUserRestriction(DISALLOW_CONFIG_BLUETOOTH)) {
- setWidgetLayoutResource(R.layout.preference_bluetooth);
- }
- }
-
mCachedDevice.registerCallback(this);
onDeviceAttributesChanged();
@@ -102,12 +93,20 @@
notifyChanged();
}
- CachedBluetoothDevice getCachedDevice() {
- return mCachedDevice;
+ @Override
+ protected boolean shouldHideSecondTarget() {
+ return mCachedDevice == null
+ || mCachedDevice.getBondState() != BluetoothDevice.BOND_BONDED
+ || mUserManager.hasUserRestriction(DISALLOW_CONFIG_BLUETOOTH);
}
- public void setOnSettingsClickListener(OnClickListener listener) {
- mOnSettingsClickListener = listener;
+ @Override
+ protected int getSecondTargetResId() {
+ return R.layout.preference_widget_gear;
+ }
+
+ CachedBluetoothDevice getCachedDevice() {
+ return mCachedDevice;
}
@Override
@@ -120,6 +119,10 @@
}
}
+ public CachedBluetoothDevice getBluetoothDevice() {
+ return mCachedDevice;
+ }
+
public void onDeviceAttributesChanged() {
/*
* The preference framework takes care of making sure the value has
@@ -157,11 +160,10 @@
}
if (mCachedDevice.getBondState() == BluetoothDevice.BOND_BONDED) {
- ImageView deviceDetails = (ImageView) view.findViewById(R.id.deviceDetails);
+ ImageView deviceDetails = (ImageView) view.findViewById(R.id.settings_button);
if (deviceDetails != null) {
deviceDetails.setOnClickListener(this);
- deviceDetails.setTag(mCachedDevice);
}
}
final ImageView imageView = (ImageView) view.findViewById(android.R.id.icon);
@@ -171,13 +173,6 @@
super.onBindViewHolder(view);
}
- public void onClick(View v) {
- // Should never be null by construction
- if (mOnSettingsClickListener != null) {
- mOnSettingsClickListener.onClick(v);
- }
- }
-
@Override
public boolean equals(Object o) {
if ((o == null) || !(o instanceof BluetoothDevicePreference)) {
@@ -207,19 +202,19 @@
int bondState = mCachedDevice.getBondState();
final MetricsFeatureProvider metricsFeatureProvider =
- FeatureFactory.getFactory(getContext()).getMetricsFeatureProvider();
+ FeatureFactory.getFactory(getContext()).getMetricsFeatureProvider();
if (mCachedDevice.isConnected()) {
metricsFeatureProvider.action(getContext(),
- MetricsEvent.ACTION_SETTINGS_BLUETOOTH_DISCONNECT);
+ MetricsEvent.ACTION_SETTINGS_BLUETOOTH_DISCONNECT);
askDisconnect();
} else if (bondState == BluetoothDevice.BOND_BONDED) {
metricsFeatureProvider.action(getContext(),
- MetricsEvent.ACTION_SETTINGS_BLUETOOTH_CONNECT);
+ MetricsEvent.ACTION_SETTINGS_BLUETOOTH_CONNECT);
mCachedDevice.connect(true);
} else if (bondState == BluetoothDevice.BOND_NONE) {
metricsFeatureProvider.action(getContext(),
- MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR);
+ MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR);
pair();
}
}
@@ -283,10 +278,10 @@
}
}
if (btClass != null) {
- if (btClass.doesClassMatch(BluetoothClass.PROFILE_HEADSET)) {
+ if (btClass.doesClassMatch(BluetoothClass.PROFILE_HEADSET)) {
return new Pair<Integer, String>(R.drawable.ic_bt_headset_hfp, HEADSET);
}
- if (btClass.doesClassMatch(BluetoothClass.PROFILE_A2DP)) {
+ if (btClass.doesClassMatch(BluetoothClass.PROFILE_A2DP)) {
return new Pair<Integer, String>(R.drawable.ic_bt_headphones_a2dp, HEADPHONE);
}
}
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index 5679f90..317a350 100644
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -45,13 +45,14 @@
import com.android.settings.LinkifyUtils;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
-import com.android.settings.widget.SummaryUpdater.OnSummaryChangeListener;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.location.ScanningSettings;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settings.search.SearchIndexableRaw;
import com.android.settings.widget.FooterPreference;
+import com.android.settings.widget.GearPreference;
+import com.android.settings.widget.SummaryUpdater.OnSummaryChangeListener;
import com.android.settings.widget.SwitchBar;
import com.android.settings.widget.SwitchBarController;
import com.android.settingslib.bluetooth.BluetoothDeviceFilter;
@@ -476,24 +477,25 @@
}
}
- private final View.OnClickListener mDeviceProfilesListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- // User clicked on advanced options icon for a device in the list
- if (!(v.getTag() instanceof CachedBluetoothDevice)) {
- Log.w(TAG, "onClick() called for other View: " + v);
- return;
- }
-
- final CachedBluetoothDevice device = (CachedBluetoothDevice) v.getTag();
- Bundle args = new Bundle();
- args.putString(DeviceProfilesSettings.ARG_DEVICE_ADDRESS,
- device.getDevice().getAddress());
- DeviceProfilesSettings profileSettings = new DeviceProfilesSettings();
- profileSettings.setArguments(args);
- profileSettings.show(getFragmentManager(),
- DeviceProfilesSettings.class.getSimpleName());
+ private final GearPreference.OnGearClickListener mDeviceProfilesListener = pref -> {
+ // User clicked on advanced options icon for a device in the list
+ if (!(pref instanceof BluetoothDevicePreference)) {
+ Log.w(TAG, "onClick() called for other View: " + pref);
+ return;
}
+ final CachedBluetoothDevice device =
+ ((BluetoothDevicePreference) pref).getBluetoothDevice();
+ if (device == null) {
+ Log.w(TAG, "No BT device attached with this pref: " + pref);
+ return;
+ }
+ final Bundle args = new Bundle();
+ args.putString(DeviceProfilesSettings.ARG_DEVICE_ADDRESS,
+ device.getDevice().getAddress());
+ final DeviceProfilesSettings profileSettings = new DeviceProfilesSettings();
+ profileSettings.setArguments(args);
+ profileSettings.show(getFragmentManager(),
+ DeviceProfilesSettings.class.getSimpleName());
};
/**
@@ -506,7 +508,7 @@
CachedBluetoothDevice cachedDevice = preference.getCachedDevice();
if (cachedDevice.getBondState() == BluetoothDevice.BOND_BONDED) {
// Only paired device have an associated advanced settings screen
- preference.setOnSettingsClickListener(mDeviceProfilesListener);
+ preference.setOnGearClickListener(mDeviceProfilesListener);
}
}
diff --git a/src/com/android/settings/bluetooth/DevicePickerFragment.java b/src/com/android/settings/bluetooth/DevicePickerFragment.java
index f250c9a..490a3ad 100644
--- a/src/com/android/settings/bluetooth/DevicePickerFragment.java
+++ b/src/com/android/settings/bluetooth/DevicePickerFragment.java
@@ -62,11 +62,6 @@
}
@Override
- void initDevicePreference(BluetoothDevicePreference preference) {
- preference.setWidgetLayoutResource(R.layout.preference_empty_list);
- }
-
- @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
menu.add(Menu.NONE, MENU_ID_REFRESH, 0, R.string.bluetooth_search_for_devices)
.setEnabled(true)
diff --git a/src/com/android/settings/dashboard/ExpandPreference.java b/src/com/android/settings/dashboard/ExpandPreference.java
index 12ca5ac..3939e74 100644
--- a/src/com/android/settings/dashboard/ExpandPreference.java
+++ b/src/com/android/settings/dashboard/ExpandPreference.java
@@ -18,6 +18,7 @@
import android.content.Context;
import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceViewHolder;
import android.util.AttributeSet;
import com.android.settings.R;
@@ -51,4 +52,10 @@
setTitle(R.string.advanced_section_header);
setOrder(999);
}
+
+ @Override
+ public void onBindViewHolder(PreferenceViewHolder holder) {
+ super.onBindViewHolder(holder);
+ holder.setDividerAllowedAbove(false);
+ }
}
diff --git a/src/com/android/settings/development/DevelopmentSettings.java b/src/com/android/settings/development/DevelopmentSettings.java
index 2bfb602..3deedaf 100644
--- a/src/com/android/settings/development/DevelopmentSettings.java
+++ b/src/com/android/settings/development/DevelopmentSettings.java
@@ -396,7 +396,7 @@
// Block access to developer options if the user is not the owner, if user policy
// restricts it, or if the device has not been provisioned
mUnavailable = true;
- setPreferenceScreen(new PreferenceScreen(getPrefContext(), null));
+ addPreferencesFromResource(R.xml.empty_settings);
return;
}
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index c38b89d..78b9b1e 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -269,11 +269,6 @@
if (left.isDeleted() != right.isDeleted()) {
return Boolean.compare(left.isDeleted(), right.isDeleted());
}
- CharSequence leftName = left.getName();
- CharSequence rightName = right.getName();
- if (!Objects.equals(leftName, rightName)) {
- return sCollator.compare(leftName.toString(), rightName.toString());
- }
return left.getId().compareTo(right.getId());
}
};
@@ -290,12 +285,6 @@
} else if (right.getId() == null && left.getId() != null) {
return -1;
}
- CharSequence leftName = left.getName();
- CharSequence rightName = right.getName();
- // sort rest of the groups by name
- if (!Objects.equals(leftName, rightName)) {
- return sCollator.compare(leftName.toString(), rightName.toString());
- }
return left.getId().compareTo(right.getId());
}
};
diff --git a/src/com/android/settings/vpn2/AppDialogFragment.java b/src/com/android/settings/vpn2/AppDialogFragment.java
index b24db4e..f8e6af0 100644
--- a/src/com/android/settings/vpn2/AppDialogFragment.java
+++ b/src/com/android/settings/vpn2/AppDialogFragment.java
@@ -18,7 +18,6 @@
import android.app.AlertDialog;
import android.app.Dialog;
-import android.app.DialogFragment;
import android.app.Fragment;
import android.content.Context;
import android.content.DialogInterface;
@@ -67,13 +66,18 @@
public static void show(Fragment parent, PackageInfo packageInfo, String label,
boolean managing, boolean connected) {
+ if (!managing && !connected) {
+ // We can't display anything useful for this case.
+ return;
+ }
show(parent, null, packageInfo, label, managing, connected);
}
public static void show(Fragment parent, Listener listener, PackageInfo packageInfo,
String label, boolean managing, boolean connected) {
- if (!parent.isAdded())
+ if (!parent.isAdded()) {
return;
+ }
Bundle args = new Bundle();
args.putParcelable(ARG_PACKAGE, packageInfo);
@@ -100,7 +104,7 @@
final String label = args.getString(ARG_LABEL);
boolean managing = args.getBoolean(ARG_MANAGING);
boolean connected = args.getBoolean(ARG_CONNECTED);
- mPackageInfo = (PackageInfo) args.getParcelable(ARG_PACKAGE);
+ mPackageInfo = args.getParcelable(ARG_PACKAGE);
if (managing) {
return new AppDialog(getActivity(), this, mPackageInfo, label);
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index 4380cbe..fe2bbb3 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -106,6 +106,9 @@
public static final int WIFI_PEAP_PHASE2_NONE = 0;
public static final int WIFI_PEAP_PHASE2_MSCHAPV2 = 1;
public static final int WIFI_PEAP_PHASE2_GTC = 2;
+ public static final int WIFI_PEAP_PHASE2_SIM = 3;
+ public static final int WIFI_PEAP_PHASE2_AKA = 4;
+ public static final int WIFI_PEAP_PHASE2_AKA_PRIME = 5;
/* Phase2 methods supported by PEAP are limited */
private final ArrayAdapter<String> mPhase2PeapAdapter;
@@ -176,9 +179,16 @@
final Resources res = mContext.getResources();
mLevels = res.getStringArray(R.array.wifi_signal);
- mPhase2PeapAdapter = new ArrayAdapter<String>(
- mContext, android.R.layout.simple_spinner_item,
- res.getStringArray(R.array.wifi_peap_phase2_entries));
+ if (Utils.isWifiOnly(mContext) || !mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_eap_sim_based_auth_supported)) {
+ mPhase2PeapAdapter = new ArrayAdapter<String>(
+ mContext, android.R.layout.simple_spinner_item,
+ res.getStringArray(R.array.wifi_peap_phase2_entries));
+ } else {
+ mPhase2PeapAdapter = new ArrayAdapter<String>(
+ mContext, android.R.layout.simple_spinner_item,
+ res.getStringArray(R.array.wifi_peap_phase2_entries_with_sim_auth));
+ }
mPhase2PeapAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mPhase2FullAdapter = new ArrayAdapter<String>(
@@ -532,6 +542,15 @@
case WIFI_PEAP_PHASE2_GTC:
config.enterpriseConfig.setPhase2Method(Phase2.GTC);
break;
+ case WIFI_PEAP_PHASE2_SIM:
+ config.enterpriseConfig.setPhase2Method(Phase2.SIM);
+ break;
+ case WIFI_PEAP_PHASE2_AKA:
+ config.enterpriseConfig.setPhase2Method(Phase2.AKA);
+ break;
+ case WIFI_PEAP_PHASE2_AKA_PRIME:
+ config.enterpriseConfig.setPhase2Method(Phase2.AKA_PRIME);
+ break;
default:
Log.e(TAG, "Unknown phase2 method" + phase2Method);
break;
@@ -795,6 +814,7 @@
mEapMethodSpinner.setAdapter(spinnerAdapter);
}
mPhase2Spinner = (Spinner) mView.findViewById(R.id.phase2);
+ mPhase2Spinner.setOnItemSelectedListener(this);
mEapCaCertSpinner = (Spinner) mView.findViewById(R.id.ca_cert);
mEapCaCertSpinner.setOnItemSelectedListener(this);
mEapDomainView = (TextView) mView.findViewById(R.id.domain);
@@ -836,6 +856,15 @@
case Phase2.GTC:
mPhase2Spinner.setSelection(WIFI_PEAP_PHASE2_GTC);
break;
+ case Phase2.SIM:
+ mPhase2Spinner.setSelection(WIFI_PEAP_PHASE2_SIM);
+ break;
+ case Phase2.AKA:
+ mPhase2Spinner.setSelection(WIFI_PEAP_PHASE2_AKA);
+ break;
+ case Phase2.AKA_PRIME:
+ mPhase2Spinner.setSelection(WIFI_PEAP_PHASE2_AKA_PRIME);
+ break;
default:
Log.e(TAG, "Invalid phase 2 method " + phase2Method);
break;
@@ -874,6 +903,7 @@
mEapIdentityView.setText(enterpriseConfig.getIdentity());
mEapAnonymousView.setText(enterpriseConfig.getAnonymousIdentity());
} else {
+ mPhase2Spinner = (Spinner) mView.findViewById(R.id.phase2);
showEapFieldsByMethod(mEapMethodSpinner.getSelectedItemPosition());
}
} else {
@@ -886,11 +916,11 @@
* identity
* password
* EAP-PEAP valid fields include
- * phase2: MSCHAPV2, GTC
+ * phase2: MSCHAPV2, GTC, SIM, AKA, AKA'
* ca_cert
* identity
* anonymous_identity
- * password
+ * password (not required for SIM, AKA, AKA')
* EAP-TLS valid fields include
* user_cert
* ca_cert
@@ -938,6 +968,7 @@
}
mView.findViewById(R.id.l_phase2).setVisibility(View.VISIBLE);
mView.findViewById(R.id.l_anonymous).setVisibility(View.VISIBLE);
+ showPeapFields();
setUserCertInvisible();
break;
case WIFI_EAP_METHOD_TTLS:
@@ -974,6 +1005,21 @@
}
}
+ private void showPeapFields() {
+ int phase2Method = mPhase2Spinner.getSelectedItemPosition();
+ if (phase2Method == WIFI_PEAP_PHASE2_SIM || phase2Method == WIFI_PEAP_PHASE2_AKA
+ || phase2Method == WIFI_PEAP_PHASE2_AKA_PRIME) {
+ mEapIdentityView.setText("");
+ mView.findViewById(R.id.l_identity).setVisibility(View.GONE);
+ setPasswordInvisible();
+ } else {
+ mView.findViewById(R.id.l_identity).setVisibility(View.VISIBLE);
+ mView.findViewById(R.id.l_anonymous).setVisibility(View.VISIBLE);
+ mView.findViewById(R.id.password_layout).setVisibility(View.VISIBLE);
+ mView.findViewById(R.id.show_password_layout).setVisibility(View.VISIBLE);
+ }
+ }
+
private void setIdentityInvisible() {
mView.findViewById(R.id.l_identity).setVisibility(View.GONE);
mPhase2Spinner.setSelection(Phase2.NONE);
@@ -1239,6 +1285,9 @@
showSecurityFields();
} else if (parent == mEapMethodSpinner || parent == mEapCaCertSpinner) {
showSecurityFields();
+ } else if (parent == mPhase2Spinner
+ && mEapMethodSpinner.getSelectedItemPosition() == WIFI_EAP_METHOD_PEAP) {
+ showPeapFields();
} else if (parent == mProxySettingsSpinner) {
showProxyFields();
} else {
diff --git a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
index 92e12b0..faa2a77 100644
--- a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
@@ -18,18 +18,20 @@
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
-import android.net.DhcpInfo;
+import android.net.IpPrefix;
import android.net.LinkProperties;
import android.net.Network;
import android.net.NetworkBadging;
import android.net.NetworkInfo;
import android.net.NetworkUtils;
+import android.net.RouteInfo;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceCategory;
import android.support.v7.preference.PreferenceScreen;
+import android.text.TextUtils;
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
@@ -44,7 +46,9 @@
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.util.List;
+import java.util.StringJoiner;
/**
* Controller for logic pertaining to displaying Wifi information for the
@@ -65,9 +69,11 @@
@VisibleForTesting
static final String KEY_SECURITY_PREF = "security";
@VisibleForTesting
+ static final String KEY_MAC_ADDRESS_PREF = "mac_address";
+ @VisibleForTesting
static final String KEY_IP_ADDRESS_PREF = "ip_address";
@VisibleForTesting
- static final String KEY_ROUTER_PREF = "router";
+ static final String KEY_GATEWAY_PREF = "gateway";
@VisibleForTesting
static final String KEY_SUBNET_MASK_PREF = "subnet_mask";
@VisibleForTesting
@@ -83,6 +89,7 @@
private WifiConfiguration mWifiConfig;
private WifiInfo mWifiInfo;
private final WifiManager mWifiManager;
+ private final ConnectivityManager mConnectivityManager;
// Preferences - in order of appearance
private Preference mConnectionDetailPref;
@@ -90,14 +97,15 @@
private WifiDetailPreference mLinkSpeedPref;
private WifiDetailPreference mFrequencyPref;
private WifiDetailPreference mSecurityPref;
+ private WifiDetailPreference mMacAddressPref;
private WifiDetailPreference mIpAddressPref;
- private WifiDetailPreference mRouterPref;
+ private WifiDetailPreference mGatewayPref;
private WifiDetailPreference mSubnetPref;
private WifiDetailPreference mDnsPref;
private PreferenceCategory mIpv6AddressCategory;
public WifiDetailPreferenceController(AccessPoint accessPoint, Context context,
- Lifecycle lifecycle, WifiManager wifiManager) {
+ Lifecycle lifecycle, WifiManager wifiManager, ConnectivityManager connectivityManager) {
super(context);
mAccessPoint = accessPoint;
@@ -106,6 +114,7 @@
mSignalStr = context.getResources().getStringArray(R.array.wifi_signal);
mWifiConfig = accessPoint.getConfig();
mWifiManager = wifiManager;
+ mConnectivityManager = connectivityManager;
mWifiInfo = wifiManager.getConnectionInfo();
lifecycle.addObserver(this);
@@ -136,8 +145,9 @@
mFrequencyPref = (WifiDetailPreference) screen.findPreference(KEY_FREQUENCY_PREF);
mSecurityPref = (WifiDetailPreference) screen.findPreference(KEY_SECURITY_PREF);
+ mMacAddressPref = (WifiDetailPreference) screen.findPreference(KEY_MAC_ADDRESS_PREF);
mIpAddressPref = (WifiDetailPreference) screen.findPreference(KEY_IP_ADDRESS_PREF);
- mRouterPref = (WifiDetailPreference) screen.findPreference(KEY_ROUTER_PREF);
+ mGatewayPref = (WifiDetailPreference) screen.findPreference(KEY_GATEWAY_PREF);
mSubnetPref = (WifiDetailPreference) screen.findPreference(KEY_SUBNET_MASK_PREF);
mDnsPref = (WifiDetailPreference) screen.findPreference(KEY_DNS_PREF);
@@ -174,6 +184,9 @@
mConnectionDetailPref.setIcon(wifiIcon);
mConnectionDetailPref.setTitle(mAccessPoint.getSettingsSummary());
+ // MAC Address Pref
+ mMacAddressPref.setDetailText(mWifiInfo.getMacAddress());
+
// Signal Strength Pref
Drawable wifiIconDark = wifiIcon.getConstantState().newDrawable().mutate();
wifiIconDark.setTint(mContext.getResources().getColor(
@@ -184,6 +197,8 @@
mSignalStrengthPref.setDetailText(mSignalStr[summarySignalLevel]);
// Link Speed Pref
+ int linkSpeedMbps = mWifiInfo.getLinkSpeed();
+ mLinkSpeedPref.setVisible(linkSpeedMbps >= 0);
mLinkSpeedPref.setDetailText(mContext.getString(
R.string.link_speed, mWifiInfo.getLinkSpeed()));
@@ -203,67 +218,87 @@
}
private void setIpText() {
+ // Reset all fields
mIpv6AddressCategory.removeAll();
mIpv6AddressCategory.setVisible(false);
+ mIpAddressPref.setVisible(false);
+ mSubnetPref.setVisible(false);
+ mGatewayPref.setVisible(false);
+ mDnsPref.setVisible(false);
Network currentNetwork = mWifiManager.getCurrentNetwork();
if (currentNetwork == null) {
return;
}
- ConnectivityManager cm = mContext.getSystemService(ConnectivityManager.class);
- LinkProperties prop = cm.getLinkProperties(currentNetwork);
- List<InetAddress> addresses = prop.getAllAddresses();
+ LinkProperties linkProperties = mConnectivityManager.getLinkProperties(currentNetwork);
+ if (linkProperties == null) {
+ return;
+ }
+ List<InetAddress> addresses = linkProperties.getAddresses();
- // Set ip addresses
+ // Set IPv4 and Ipv6 addresses
for (int i = 0; i < addresses.size(); i++) {
InetAddress addr = addresses.get(i);
if (addr instanceof Inet4Address) {
mIpAddressPref.setDetailText(addr.getHostAddress());
+ mIpAddressPref.setVisible(true);
} else if (addr instanceof Inet6Address) {
String ip = addr.getHostAddress();
Preference pref = new Preference(mPrefContext);
pref.setKey(ip);
pref.setTitle(ip);
mIpv6AddressCategory.addPreference(pref);
- mIpv6AddressCategory.setVisible(true); // TODO(sghuman): Make sure to
+ mIpv6AddressCategory.setVisible(true);
}
}
- String subnetMask = null;
- String router;
- DhcpInfo dhcp = mWifiManager.getDhcpInfo();
- if (dhcp != null) {
- if (dhcp.netmask == 0) {
- Log.e(TAG, "invalid netmask value of 0 for DhcpInfo: " + dhcp);
- mSubnetPref.setVisible(false);
- } else {
- subnetMask = NetworkUtils.intToInetAddress(dhcp.netmask).getHostAddress();
- mSubnetPref.setVisible(true);
+ // Set up IPv4 gateway and subnet mask
+ String gateway = null;
+ String subnet = null;
+ for (RouteInfo routeInfo : linkProperties.getRoutes()) {
+ if (routeInfo.hasGateway() && routeInfo.getGateway() instanceof Inet4Address) {
+ gateway = routeInfo.getGateway().getHostAddress();
}
-
- router = NetworkUtils.intToInetAddress(dhcp.gateway).getHostAddress();
- } else { // Statically configured IP
-
- // TODO(sghuman): How do we get subnet mask for static ips?
- mSubnetPref.setVisible(false);
-
- router = mWifiManager.getWifiApConfiguration().getStaticIpConfiguration().gateway
- .getHostAddress();
+ IpPrefix ipPrefix = routeInfo.getDestination();
+ if (ipPrefix != null && ipPrefix.getAddress() instanceof Inet4Address
+ && ipPrefix.getPrefixLength() > 0) {
+ subnet = ipv4PrefixLengthToSubnetMask(ipPrefix.getPrefixLength());
+ }
}
- mRouterPref.setDetailText(router);
- mSubnetPref.setDetailText(subnetMask);
- // Set DNS
- addresses = prop.getDnsServers();
- StringBuilder builder = new StringBuilder();
-
- // addresses is backed by an ArrayList, so use a hand-written iterator for performance gains
- for (int i = 0; i < addresses.size(); i++) {
- if (i > 0) builder.append(", ");
- builder.append(addresses.get(i).getHostAddress());
+ if (!TextUtils.isEmpty(subnet)) {
+ mSubnetPref.setDetailText(subnet);
+ mSubnetPref.setVisible(true);
}
- mDnsPref.setDetailText(builder.toString());
+
+ if (!TextUtils.isEmpty(gateway)) {
+ mGatewayPref.setDetailText(gateway);
+ mGatewayPref.setVisible(true);
+ }
+
+ // Set IPv4 DNS addresses
+ StringJoiner stringJoiner = new StringJoiner(",");
+ for (InetAddress dnsServer : linkProperties.getDnsServers()) {
+ if (dnsServer instanceof Inet4Address) {
+ stringJoiner.add(dnsServer.getHostAddress());
+ }
+ }
+ String dnsText = stringJoiner.toString();
+ if (!dnsText.isEmpty()) {
+ mDnsPref.setDetailText(dnsText);
+ mDnsPref.setVisible(true);
+ }
+ }
+
+ private static String ipv4PrefixLengthToSubnetMask(int prefixLength) {
+ try {
+ InetAddress all = InetAddress.getByAddress(
+ new byte[]{(byte) 255, (byte) 255, (byte) 255, (byte) 255});
+ return NetworkUtils.getNetworkPart(all, prefixLength).getHostAddress();
+ } catch (UnknownHostException e) {
+ return null;
+ }
}
/**
diff --git a/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java b/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
index 7ebde38..ebd1143 100644
--- a/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
+++ b/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
@@ -16,6 +16,7 @@
package com.android.settings.wifi.details;
import android.content.Context;
+import android.net.ConnectivityManager;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.widget.Button;
@@ -45,13 +46,10 @@
private AccessPoint mAccessPoint;
private Button mForgetButton;
private WifiDetailPreferenceController mWifiDetailPreferenceController;
- private WifiManager mWifiManager;
@Override
public void onAttach(Context context) {
mAccessPoint = new AccessPoint(context, getArguments());
- mWifiManager = context.getSystemService(WifiManager.class);
-
super.onAttach(context);
}
@@ -95,7 +93,8 @@
mAccessPoint,
context,
getLifecycle(),
- mWifiManager);
+ context.getSystemService(WifiManager.class),
+ context.getSystemService(ConnectivityManager.class));
ArrayList<PreferenceController> controllers = new ArrayList(1);
controllers.add(mWifiDetailPreferenceController);
diff --git a/tests/app/src/com/android/settings/applications/ExternalSourcesSettingsTest.java b/tests/app/src/com/android/settings/applications/ExternalSourcesSettingsTest.java
index 9114c6f..82f0e0a 100644
--- a/tests/app/src/com/android/settings/applications/ExternalSourcesSettingsTest.java
+++ b/tests/app/src/com/android/settings/applications/ExternalSourcesSettingsTest.java
@@ -93,7 +93,7 @@
private Intent createManageExternalSourcesListIntent() {
final Intent manageExternalSourcesIntent = new Intent();
- manageExternalSourcesIntent.setAction(Settings.ACTION_MANAGE_EXTERNAL_SOURCES);
+ manageExternalSourcesIntent.setAction(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES);
return manageExternalSourcesIntent;
}
diff --git a/tests/app/src/com/android/settings/bluetooth/DevicePickerActivityTest.java b/tests/app/src/com/android/settings/bluetooth/DevicePickerActivityTest.java
new file mode 100644
index 0000000..1b855c9
--- /dev/null
+++ b/tests/app/src/com/android/settings/bluetooth/DevicePickerActivityTest.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.bluetooth;
+
+import android.app.Instrumentation;
+import android.content.Intent;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.SmallTest;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+@SmallTest
+public class DevicePickerActivityTest {
+
+ private Instrumentation mInstrumentation;
+
+ @Before
+ public void setUp() throws Exception {
+ mInstrumentation = InstrumentationRegistry.getInstrumentation();
+ }
+
+ @Test
+ public void startActivityNoCrash() {
+ mInstrumentation.startActivitySync(
+ new Intent("android.bluetooth.devicepicker.action.LAUNCH"));
+ // No crash
+ }
+}
diff --git a/tests/app/src/com/android/settings/fuelgauge/PowerUsageSummaryUiTest.java b/tests/app/src/com/android/settings/fuelgauge/PowerUsageSummaryUiTest.java
index 47e644a..6c372c5 100644
--- a/tests/app/src/com/android/settings/fuelgauge/PowerUsageSummaryUiTest.java
+++ b/tests/app/src/com/android/settings/fuelgauge/PowerUsageSummaryUiTest.java
@@ -16,26 +16,11 @@
package com.android.settings.fuelgauge;
-import static android.support.test.InstrumentationRegistry.getTargetContext;
-import static android.support.test.espresso.Espresso.onData;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
-import static android.support.test.espresso.intent.Intents.intended;
-import static android.support.test.espresso.intent.Intents.intending;
-import static android.support.test.espresso.intent.matcher.IntentMatchers.hasComponent;
-import static android.support.test.espresso.matcher.PreferenceMatchers.withKey;
-import static android.support.test.espresso.matcher.ViewMatchers.isDescendantOfA;
-import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
-import static org.hamcrest.Matchers.allOf;
-import static org.hamcrest.core.IsAnything.anything;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import android.app.Activity;
import android.app.Instrumentation;
-import android.content.Context;
import android.content.Intent;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
diff --git a/tests/robotests/src/android/util/LauncherIcons.java b/tests/robotests/src/android/util/LauncherIcons.java
new file mode 100644
index 0000000..a18cfae
--- /dev/null
+++ b/tests/robotests/src/android/util/LauncherIcons.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.util;
+
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+
+/**
+ * This class is only needed to get around RoboElectric issue.
+ */
+public final class LauncherIcons {
+
+ public LauncherIcons(Context context) {
+ }
+
+ public Drawable wrapIconDrawableWithShadow(Drawable drawable) {
+ return drawable;
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/applications/AppStorageSizesControllerTest.java b/tests/robotests/src/com/android/settings/applications/AppStorageSizesControllerTest.java
index 7204bd1..127100f 100644
--- a/tests/robotests/src/com/android/settings/applications/AppStorageSizesControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppStorageSizesControllerTest.java
@@ -92,4 +92,22 @@
assertThat(mDataPreference.getSummary()).isEqualTo("100B");
assertThat(mTotalPreference.getSummary()).isEqualTo("111B");
}
+
+ @Test
+ public void fakeCacheFlagSetsCacheToZero() {
+ AppStorageStats result = mock(AppStorageStats.class);
+ when(result.getCodeBytes()).thenReturn(1L);
+ when(result.getCacheBytes()).thenReturn(10L);
+ when(result.getDataBytes()).thenReturn(100L);
+ when(result.getTotalBytes()).thenReturn(111L);
+
+ mController.setResult(result);
+ mController.setCacheCleared(true);
+ mController.updateUi(mContext);
+
+ assertThat(mAppPreference.getSummary()).isEqualTo("1.00B");
+ assertThat(mCachePreference.getSummary()).isEqualTo("0.00B");
+ assertThat(mDataPreference.getSummary()).isEqualTo("100B");
+ assertThat(mTotalPreference.getSummary()).isEqualTo("101B");
+ }
}
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java
index 5915118..c4c1f8a 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java
@@ -17,8 +17,10 @@
import android.bluetooth.BluetoothDevice;
import android.content.Context;
+import android.os.UserManager;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.R;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
@@ -32,7 +34,10 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
+import org.robolectric.util.ReflectionHelpers;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -66,7 +71,7 @@
mPreference.onClicked();
verify(mMetricsFeatureProvider).action(
- mContext, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_DISCONNECT);
+ mContext, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_DISCONNECT);
}
@Test
@@ -77,7 +82,7 @@
mPreference.onClicked();
verify(mMetricsFeatureProvider).action(
- mContext, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_CONNECT);
+ mContext, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_CONNECT);
}
@Test
@@ -89,6 +94,46 @@
mPreference.onClicked();
verify(mMetricsFeatureProvider).action(
- mContext, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR);
+ mContext, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR);
+ }
+
+ @Test
+ public void getSecondTargetResource_shouldBeGearIconLayout() {
+ assertThat(mPreference.getSecondTargetResId()).isEqualTo(R.layout.preference_widget_gear);
+ }
+
+ @Test
+ public void shouldHideSecondTarget_noDevice_shouldReturnTrue() {
+ ReflectionHelpers.setField(mPreference, "mCachedDevice", null);
+
+ assertThat(mPreference.shouldHideSecondTarget()).isTrue();
+ }
+
+ @Test
+ public void shouldHideSecondTarget_notBond_shouldReturnTrue() {
+ when(mCachedBluetoothDevice.getBondState()).thenReturn(BluetoothDevice.BOND_NONE);
+
+ assertThat(mPreference.shouldHideSecondTarget()).isTrue();
+ }
+
+ @Test
+ public void shouldHideSecondTarget_hasUserRestriction_shouldReturnTrue() {
+ final UserManager um = mock(UserManager.class);
+ ReflectionHelpers.setField(mPreference, "mUserManager", um);
+ when(um.hasUserRestriction(UserManager.DISALLOW_CONFIG_BLUETOOTH))
+ .thenReturn(true);
+
+ assertThat(mPreference.shouldHideSecondTarget()).isTrue();
+ }
+
+ @Test
+ public void shouldHideSecondTarget_hasBoundDeviceAndNoRestriction_shouldReturnFalse() {
+ when(mCachedBluetoothDevice.getBondState()).thenReturn(BluetoothDevice.BOND_BONDED);
+ final UserManager um = mock(UserManager.class);
+ ReflectionHelpers.setField(mPreference, "mUserManager", um);
+ when(um.hasUserRestriction(UserManager.DISALLOW_CONFIG_BLUETOOTH))
+ .thenReturn(false);
+
+ assertThat(mPreference.shouldHideSecondTarget()).isFalse();
}
}
diff --git a/tests/robotests/src/com/android/settings/suggestions/SettingsSuggestionsTest.java b/tests/robotests/src/com/android/settings/suggestions/SettingsSuggestionsTest.java
index 3780d35..ad035bd 100644
--- a/tests/robotests/src/com/android/settings/suggestions/SettingsSuggestionsTest.java
+++ b/tests/robotests/src/com/android/settings/suggestions/SettingsSuggestionsTest.java
@@ -54,12 +54,6 @@
}
@Test
- public void nightDisplaySettings_isValid() {
- assertSuggestionEquals("Settings$NightDisplaySettingsActivity",
- R.string.night_display_suggestion_title, R.string.night_display_suggestion_summary);
- }
-
- @Test
public void fingerprintSuggestion_isValid() {
assertSuggestionEquals("com.android.settings.Settings$FingerprintSuggestionActivity",
R.string.suggestion_additional_fingerprints,
diff --git a/tests/robotests/src/com/android/settings/vpn2/AppDialogFragmentTest.java b/tests/robotests/src/com/android/settings/vpn2/AppDialogFragmentTest.java
new file mode 100644
index 0000000..088bfae
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/vpn2/AppDialogFragmentTest.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.vpn2;
+
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+
+import android.app.Fragment;
+import android.content.pm.PackageInfo;
+
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class AppDialogFragmentTest {
+
+ @Mock
+ private Fragment mParent;
+
+ private PackageInfo mPackageInfo;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mPackageInfo = new PackageInfo();
+ }
+
+ @Test
+ public void notManagingOrConnected_shouldNotShow() {
+ AppDialogFragment.show(mParent, mPackageInfo, "label", false /* manage */,
+ false /* connected */);
+
+ verify(mParent, never()).isAdded();
+ }
+
+ @Test
+ public void notManagingAndConnected_showShow() {
+ AppDialogFragment.show(mParent, mPackageInfo, "label", false /* manage */,
+ true /* connected */);
+
+ verify(mParent).isAdded();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
index f60c106..7cb69ea 100644
--- a/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
@@ -18,14 +18,22 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
import android.graphics.drawable.Drawable;
+import android.net.ConnectivityManager;
+import android.net.IpPrefix;
+import android.net.LinkAddress;
+import android.net.LinkProperties;
+import android.net.Network;
import android.net.NetworkBadging;
import android.net.NetworkInfo;
+import android.net.RouteInfo;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
@@ -46,8 +54,14 @@
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@@ -56,28 +70,35 @@
private static final int LEVEL = 1;
private static final int RSSI = -55;
private static final int LINK_SPEED = 123;
+ private static final String MAC_ADDRESS = WifiInfo.DEFAULT_MAC_ADDRESS;
private static final String SECURITY = "None";
+ private InetAddress mIpv4Address;
+
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private PreferenceScreen mockScreen;
@Mock private AccessPoint mockAccessPoint;
@Mock private WifiManager mockWifiManager;
+ @Mock private ConnectivityManager mockConnectivityManager;
@Mock private NetworkInfo mockNetworkInfo;
@Mock private WifiConfiguration mockWifiConfig;
@Mock private WifiInfo mockWifiInfo;
+ @Mock private Network mockNetwork;
@Mock private Preference mockConnectionDetailPref;
@Mock private WifiDetailPreference mockSignalStrengthPref;
@Mock private WifiDetailPreference mockLinkSpeedPref;
@Mock private WifiDetailPreference mockFrequencyPref;
@Mock private WifiDetailPreference mockSecurityPref;
+ @Mock private WifiDetailPreference mockMacAddressPref;
@Mock private WifiDetailPreference mockIpAddressPref;
- @Mock private WifiDetailPreference mockRouterPref;
+ @Mock private WifiDetailPreference mockGatewayPref;
@Mock private WifiDetailPreference mockSubnetPref;
@Mock private WifiDetailPreference mockDnsPref;
@Mock private PreferenceCategory mockIpv6AddressCategory;
+ private LinkProperties mLinkProperties;
private Context mContext = RuntimeEnvironment.application;
private Lifecycle mLifecycle;
private WifiDetailPreferenceController mController;
@@ -88,6 +109,13 @@
mLifecycle = new Lifecycle();
+ try {
+ mIpv4Address = InetAddress.getByAddress(
+ new byte[] { (byte) 255, (byte) 255, (byte) 255, (byte) 255 });
+ } catch (UnknownHostException e) {
+ throw new RuntimeException(e);
+ }
+
when(mockAccessPoint.getConfig()).thenReturn(mockWifiConfig);
when(mockAccessPoint.getLevel()).thenReturn(LEVEL);
when(mockAccessPoint.getNetworkInfo()).thenReturn(mockNetworkInfo);
@@ -96,16 +124,20 @@
when(mockWifiInfo.getLinkSpeed()).thenReturn(LINK_SPEED);
when(mockWifiInfo.getRssi()).thenReturn(RSSI);
+ when(mockWifiInfo.getMacAddress()).thenReturn(MAC_ADDRESS);
when(mockWifiManager.getConnectionInfo()).thenReturn(mockWifiInfo);
+ when(mockWifiManager.getCurrentNetwork()).thenReturn(mockNetwork);
+ mLinkProperties = new LinkProperties();
+ when(mockConnectivityManager.getLinkProperties(mockNetwork)).thenReturn(mLinkProperties);
+
mController = new WifiDetailPreferenceController(
- mockAccessPoint, mContext, mLifecycle, mockWifiManager);
+ mockAccessPoint, mContext, mLifecycle, mockWifiManager, mockConnectivityManager);
setupMockedPreferenceScreen();
}
private void setupMockedPreferenceScreen() {
-
when(mockScreen.findPreference(WifiDetailPreferenceController.KEY_CONNECTION_DETAIL_PREF))
.thenReturn(mockConnectionDetailPref);
when(mockScreen.findPreference(WifiDetailPreferenceController.KEY_SIGNAL_STRENGTH_PREF))
@@ -116,10 +148,12 @@
.thenReturn(mockFrequencyPref);
when(mockScreen.findPreference(WifiDetailPreferenceController.KEY_SECURITY_PREF))
.thenReturn(mockSecurityPref);
+ when(mockScreen.findPreference(WifiDetailPreferenceController.KEY_MAC_ADDRESS_PREF))
+ .thenReturn(mockMacAddressPref);
when(mockScreen.findPreference(WifiDetailPreferenceController.KEY_IP_ADDRESS_PREF))
.thenReturn(mockIpAddressPref);
- when(mockScreen.findPreference(WifiDetailPreferenceController.KEY_ROUTER_PREF))
- .thenReturn(mockRouterPref);
+ when(mockScreen.findPreference(WifiDetailPreferenceController.KEY_GATEWAY_PREF))
+ .thenReturn(mockGatewayPref);
when(mockScreen.findPreference(WifiDetailPreferenceController.KEY_SUBNET_MASK_PREF))
.thenReturn(mockSubnetPref);
when(mockScreen.findPreference(WifiDetailPreferenceController.KEY_DNS_PREF))
@@ -195,11 +229,101 @@
}
@Test
+ public void linkSpeedPref_shouldNotShowIfNotSet() {
+ when(mockWifiInfo.getLinkSpeed()).thenReturn(-1);
+
+ mController.onResume();
+
+ verify(mockLinkSpeedPref).setVisible(false);
+ }
+
+ @Test
+ public void macAddressPref_shouldHaveDetailTextSet() {
+ mController.onResume();
+
+ verify(mockMacAddressPref).setDetailText(MAC_ADDRESS);
+ }
+
+ @Test
+ public void ipAddressPref_shouldHaveDetailTextSet() {
+ LinkAddress ipv4Address = new LinkAddress(mIpv4Address, 32);
+
+ mLinkProperties.addLinkAddress(ipv4Address);
+
+ mController.onResume();
+
+ verify(mockIpAddressPref).setDetailText(mIpv4Address.getHostAddress());
+ }
+
+ @Test
+ public void gatewayAndSubnet_shouldHaveDetailTextSet() {
+ int prefixLength = 24;
+ IpPrefix subnet = new IpPrefix(mIpv4Address, prefixLength);
+ InetAddress gateway = mIpv4Address;
+ mLinkProperties.addRoute(new RouteInfo(subnet, gateway));
+
+ mController.onResume();
+
+ verify(mockSubnetPref).setDetailText("255.255.255.0");
+ verify(mockGatewayPref).setDetailText(mIpv4Address.getHostAddress());
+ }
+
+ @Test
+ public void dnsServersPref_shouldHaveDetailTextSet() throws UnknownHostException {
+ mLinkProperties.addDnsServer(InetAddress.getByAddress(new byte[]{8,8,4,4}));
+ mLinkProperties.addDnsServer(InetAddress.getByAddress(new byte[]{8,8,8,8}));
+
+ mController.onResume();
+
+ verify(mockDnsPref).setDetailText("8.8.4.4,8.8.8.8");
+ }
+
+ @Test
+ public void noCurrentNetwork_allIpDetailsHidden() {
+ when(mockWifiManager.getCurrentNetwork()).thenReturn(null);
+ reset(mockIpv6AddressCategory, mockIpAddressPref, mockSubnetPref, mockGatewayPref,
+ mockDnsPref);
+
+ mController.onResume();
+
+ verify(mockIpv6AddressCategory).setVisible(false);
+ verify(mockIpAddressPref).setVisible(false);
+ verify(mockSubnetPref).setVisible(false);
+ verify(mockGatewayPref).setVisible(false);
+ verify(mockDnsPref).setVisible(false);
+ verify(mockIpv6AddressCategory, never()).setVisible(true);
+ verify(mockIpAddressPref, never()).setVisible(true);
+ verify(mockSubnetPref, never()).setVisible(true);
+ verify(mockGatewayPref, never()).setVisible(true);
+ verify(mockDnsPref, never()).setVisible(true);
+ }
+
+ @Test
+ public void noLinkProperties_allIpDetailsHidden() {
+ when(mockConnectivityManager.getLinkProperties(mockNetwork)).thenReturn(null);
+ reset(mockIpv6AddressCategory, mockIpAddressPref, mockSubnetPref, mockGatewayPref,
+ mockDnsPref);
+
+ mController.onResume();
+
+ verify(mockIpv6AddressCategory).setVisible(false);
+ verify(mockIpAddressPref).setVisible(false);
+ verify(mockSubnetPref).setVisible(false);
+ verify(mockGatewayPref).setVisible(false);
+ verify(mockDnsPref).setVisible(false);
+ verify(mockIpv6AddressCategory, never()).setVisible(true);
+ verify(mockIpAddressPref, never()).setVisible(true);
+ verify(mockSubnetPref, never()).setVisible(true);
+ verify(mockGatewayPref, never()).setVisible(true);
+ verify(mockDnsPref, never()).setVisible(true);
+ }
+
+ @Test
public void canForgetNetwork_noNetwork() {
when(mockAccessPoint.getConfig()).thenReturn(null);
mController = new WifiDetailPreferenceController(
- mockAccessPoint, mContext, mLifecycle, mockWifiManager);
+ mockAccessPoint, mContext, mLifecycle, mockWifiManager, mockConnectivityManager);
assertThat(mController.canForgetNetwork()).isFalse();
}
@@ -210,7 +334,7 @@
when(mockAccessPoint.getConfig()).thenReturn(null);
mController = new WifiDetailPreferenceController(
- mockAccessPoint, mContext, mLifecycle, mockWifiManager);
+ mockAccessPoint, mContext, mLifecycle, mockWifiManager, mockConnectivityManager);
assertThat(mController.canForgetNetwork()).isTrue();
}