Merge "Add placeholder summary to stablize app info pref height" into oc-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index da88f76..781e816 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -902,23 +902,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"
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..2b75bd9 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>
@@ -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/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/search/IndexDatabaseHelper.java b/src/com/android/settings/search/IndexDatabaseHelper.java
index 60378c2..76346ec 100644
--- a/src/com/android/settings/search/IndexDatabaseHelper.java
+++ b/src/com/android/settings/search/IndexDatabaseHelper.java
@@ -245,7 +245,7 @@
return version;
}
- public static void clearLocalesIndexed(Context context) {
+ public static void clearCachedIndexed(Context context) {
context.getSharedPreferences(INDEX, 0).edit().clear().commit();
}
@@ -257,8 +257,16 @@
return context.getSharedPreferences(INDEX, 0).getBoolean(locale, false);
}
+ public static boolean isBuildIndexed(Context context, String buildNo) {
+ return context.getSharedPreferences(INDEX, 0).getBoolean(buildNo, false);
+ }
+
+ public static void setBuildIndexed(Context context, String buildNo) {
+ context.getSharedPreferences(INDEX, 0).edit().putBoolean(buildNo, true).commit();
+ }
+
private void dropTables(SQLiteDatabase db) {
- clearLocalesIndexed(mContext);
+ clearCachedIndexed(mContext);
db.execSQL("DROP TABLE IF EXISTS " + Tables.TABLE_META_INDEX);
db.execSQL("DROP TABLE IF EXISTS " + Tables.TABLE_PREFS_INDEX);
db.execSQL("DROP TABLE IF EXISTS " + Tables.TABLE_SAVED_QUERIES);
diff --git a/src/com/android/settings/search2/DatabaseIndexingManager.java b/src/com/android/settings/search2/DatabaseIndexingManager.java
index 1e664ff..533884d 100644
--- a/src/com/android/settings/search2/DatabaseIndexingManager.java
+++ b/src/com/android/settings/search2/DatabaseIndexingManager.java
@@ -29,6 +29,7 @@
import android.database.sqlite.SQLiteException;
import android.net.Uri;
import android.os.AsyncTask;
+import android.os.Build;
import android.provider.SearchIndexableData;
import android.provider.SearchIndexableResource;
import android.provider.SearchIndexablesContract;
@@ -170,7 +171,16 @@
final List<ResolveInfo> list =
mContext.getPackageManager().queryIntentContentProviders(intent, 0);
- final boolean isLocaleIndexed = isLocaleIndexed();
+ final String localeStr = Locale.getDefault().toString();
+ final String fingerprint = Build.FINGERPRINT;
+ final boolean isFullIndex = isFullIndex(localeStr, fingerprint);
+
+ // Drop the database when the locale or build has changed. This eliminates rows which are
+ // dynamically inserted in the old language, or deprecated settings.
+ if (isFullIndex) {
+ final SQLiteDatabase db = getWritableDatabase();
+ IndexDatabaseHelper.getInstance(mContext).reconstruct(db);
+ }
for (final ResolveInfo info : list) {
if (!DatabaseIndexingUtils.isWellKnownProvider(info, mContext)) {
@@ -179,22 +189,32 @@
final String authority = info.providerInfo.authority;
final String packageName = info.providerInfo.packageName;
- if (!isLocaleIndexed) {
+ if (isFullIndex) {
addIndexablesFromRemoteProvider(packageName, authority);
}
addNonIndexablesKeysFromRemoteProvider(packageName, authority);
}
- final String localeStr = Locale.getDefault().toString();
- updateDatabase(isLocaleIndexed, localeStr);
+ updateDatabase(isFullIndex, localeStr);
IndexDatabaseHelper.setLocaleIndexed(mContext, localeStr);
+ IndexDatabaseHelper.setBuildIndexed(mContext, fingerprint);
}
+ /**
+ * Perform a full index on an OTA or when the locale has changed
+ *
+ * @param locale is the default for the device
+ * @param fingerprint id for the current build.
+ * @return true when the locale or build has changed since last index.
+ */
@VisibleForTesting
- boolean isLocaleIndexed() {
- final String locale = Locale.getDefault().toString();
- return IndexDatabaseHelper.getInstance(mContext).isLocaleAlreadyIndexed(mContext, locale);
+ boolean isFullIndex(String locale, String fingerprint) {
+ final boolean isLocaleIndexed = IndexDatabaseHelper.getInstance(mContext)
+ .isLocaleAlreadyIndexed(mContext, locale);
+ final boolean isBuildIndexed = IndexDatabaseHelper.getInstance(mContext)
+ .isBuildIndexed(mContext, fingerprint);
+ return !isLocaleIndexed || !isBuildIndexed;
}
/**
@@ -204,11 +224,11 @@
* Then search results are verified to have the correct value of enabled.
* Finally, we record that the locale has been indexed.
*
- * @param isIncrementalUpdate true when the language has already been indexed.
+ * @param needsReindexing true the database needs to be rebuilt.
* @param localeStr the default locale for the device.
*/
@VisibleForTesting
- void updateDatabase(boolean isIncrementalUpdate, String localeStr) {
+ void updateDatabase(boolean needsReindexing, String localeStr) {
mIsAvailable.set(false);
final UpdateData copy;
@@ -236,7 +256,7 @@
// Only check for non-indexable key updates after initial index.
// Enabled state with non-indexable keys is checked when items are first inserted.
- if (isIncrementalUpdate) {
+ if (!needsReindexing) {
updateDataInDatabase(database, nonIndexableKeys);
}
@@ -284,7 +304,7 @@
* @param database The database to validate.
* @param nonIndexableKeys A map between package name and the set of non-indexable keys for it.
*/
- @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
+ @VisibleForTesting
void updateDataInDatabase(SQLiteDatabase database,
Map<String, Set<String>> nonIndexableKeys) {
final String whereEnabled = ENABLED + " = 1";
@@ -348,7 +368,6 @@
@VisibleForTesting
boolean addIndexablesFromRemoteProvider(String packageName, String authority) {
try {
-
final Context context = mBaseAuthority.equals(authority) ?
mContext : mContext.createPackageContext(packageName, 0);
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/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/search2/DatabaseIndexingManagerTest.java b/tests/robotests/src/com/android/settings/search2/DatabaseIndexingManagerTest.java
index 327b910..aa4e4f9 100644
--- a/tests/robotests/src/com/android/settings/search2/DatabaseIndexingManagerTest.java
+++ b/tests/robotests/src/com/android/settings/search2/DatabaseIndexingManagerTest.java
@@ -30,6 +30,8 @@
import android.database.MatrixCursor;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
+import android.os.Build;
+import android.provider.SearchIndexableData;
import android.provider.SearchIndexableResource;
import android.provider.SearchIndexablesContract;
import android.util.ArrayMap;
@@ -74,7 +76,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
- shadows={ShadowRunnableAsyncTask.class})
+ shadows = {ShadowRunnableAsyncTask.class})
public class DatabaseIndexingManagerTest {
private final String localeStr = "en_US";
@@ -122,7 +124,7 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
- mManager = spy(new DatabaseIndexingManager(mContext,"com.android.settings"));
+ mManager = spy(new DatabaseIndexingManager(mContext, PACKAGE_ONE));
mDb = IndexDatabaseHelper.getInstance(mContext).getWritableDatabase();
doReturn(mPackageManager).when(mContext).getPackageManager();
@@ -671,42 +673,95 @@
// Test new public indexing flow
@Test
- @Config(shadows= {
- ShadowDatabaseIndexingUtils.class,
- })
+ @Config(shadows = {ShadowDatabaseIndexingUtils.class,})
public void testPerformIndexing_fullIndex_getsDataFromProviders() {
DummyProvider provider = new DummyProvider();
provider.onCreate();
- ShadowContentResolver.registerProvider(
- AUTHORITY_ONE, provider
- );
+ ShadowContentResolver.registerProvider(AUTHORITY_ONE, provider);
// Test that Indexables are added for Full indexing
when(mPackageManager.queryIntentContentProviders(any(Intent.class), anyInt()))
.thenReturn(getDummyResolveInfo());
DatabaseIndexingManager manager =
- spy(new DatabaseIndexingManager(mContext, "com.android.settings"));
- doReturn(false).when(manager).isLocaleIndexed();
+ spy(new DatabaseIndexingManager(mContext, PACKAGE_ONE));
+ doReturn(true).when(manager).isFullIndex(anyString(), anyString());
manager.performIndexing();
- verify(manager).updateDatabase(false, Locale.getDefault().toString());
-
- Cursor cursor = mDb.rawQuery("SELECT * FROM prefs_index", null);
- cursor.moveToPosition(0);
-
- // Data Title
- assertThat(cursor.getString(2)).isEqualTo(TITLE_ONE);
+ verify(manager).addIndexablesFromRemoteProvider(PACKAGE_ONE, AUTHORITY_ONE);
+ verify(manager).updateDatabase(true /* isFullIndex */, Locale.getDefault().toString());
}
@Test
- @Config(shadows= {
- ShadowDatabaseIndexingUtils.class,
- })
+ @Config(shadows = {ShadowDatabaseIndexingUtils.class,})
public void testPerformIndexing_incrementalIndex_noDataAdded() {
DummyProvider provider = new DummyProvider();
provider.onCreate();
+ ShadowContentResolver.registerProvider(AUTHORITY_ONE, provider);
+
+ // Test that Indexables are added for Full indexing
+ when(mPackageManager.queryIntentContentProviders(any(Intent.class), anyInt()))
+ .thenReturn(getDummyResolveInfo());
+
+ DatabaseIndexingManager manager =
+ spy(new DatabaseIndexingManager(mContext, PACKAGE_ONE));
+ doReturn(false).when(manager).isFullIndex(anyString(), anyString());
+
+ manager.mDataToProcess.dataToUpdate.clear();
+
+ manager.performIndexing();
+
+ verify(manager, times(0)).addDataToDatabase(any(SQLiteDatabase.class), anyString(),
+ anyList(), anyMap());
+ verify(manager, times(0)).addIndexablesFromRemoteProvider(PACKAGE_ONE, AUTHORITY_ONE);
+ verify(manager).updateDataInDatabase(any(SQLiteDatabase.class), anyMap());
+ }
+
+ @Test
+ @Config(shadows = {ShadowDatabaseIndexingUtils.class,})
+ public void testPerformIndexing_localeChanged_databaseDropped() {
+ DummyProvider provider = new DummyProvider();
+ provider.onCreate();
+ ShadowContentResolver.registerProvider(AUTHORITY_ONE, provider);
+
+ // Test that Indexables are added for Full indexing
+ when(mPackageManager.queryIntentContentProviders(any(Intent.class), anyInt()))
+ .thenReturn(getDummyResolveInfo());
+
+ // Initialize the Manager
+ DatabaseIndexingManager manager =
+ spy(new DatabaseIndexingManager(mContext, PACKAGE_ONE));
+ doReturn(true).when(manager).isFullIndex(anyString(), anyString());
+
+ // Insert data point which will be dropped
+ final String oldTitle = "This is French";
+ insertSpecialCase(oldTitle, true, "key");
+
+ // Add a data point to be added by the indexing
+ SearchIndexableRaw raw = new SearchIndexableRaw(mContext);
+ final String newTitle = "This is English";
+ raw.title = newTitle;
+ manager.mDataToProcess.dataToUpdate.add(raw);
+
+ manager.performIndexing();
+
+ // Assert that the New Title is inserted
+ final Cursor newCursor = mDb.rawQuery("SELECT * FROM prefs_index WHERE data_title = '" +
+ newTitle + "'", null);
+ assertThat(newCursor.getCount()).isEqualTo(1);
+
+ // Assert that the Old Title is no longer in the database, since it was dropped
+ final Cursor oldCursor = mDb.rawQuery("SELECT * FROM prefs_index WHERE data_title = '" +
+ oldTitle + "'", null);
+ assertThat(oldCursor.getCount()).isEqualTo(0);
+ }
+
+ @Test
+ @Config(shadows = {ShadowDatabaseIndexingUtils.class,})
+ public void testPerformIndexing_onOta_FullIndex() {
+ DummyProvider provider = new DummyProvider();
+ provider.onCreate();
ShadowContentResolver.registerProvider(
AUTHORITY_ONE, provider
);
@@ -716,19 +771,40 @@
.thenReturn(getDummyResolveInfo());
DatabaseIndexingManager manager =
- spy(new DatabaseIndexingManager(mContext, "com.android.settings"));
- doReturn(true).when(manager).isLocaleIndexed();
+ spy(new DatabaseIndexingManager(mContext, PACKAGE_ONE));
+ doReturn(true).when(manager).isFullIndex(anyString(), anyString());
manager.performIndexing();
- final Cursor cursor = mDb.rawQuery("SELECT * FROM prefs_index", null);
+ verify(manager).updateDatabase(true /* isFullIndex */, Locale.getDefault().toString());
+ }
- assertThat(cursor.getCount()).isEqualTo(0);
+ @Test
+ @Config(shadows = {ShadowDatabaseIndexingUtils.class,})
+ public void testPerformIndexing_onOta_buildNumberIsCached() {
+ DummyProvider provider = new DummyProvider();
+ provider.onCreate();
+ ShadowContentResolver.registerProvider(
+ AUTHORITY_ONE, provider
+ );
+
+ // Test that Indexables are added for Full indexing
+ when(mPackageManager.queryIntentContentProviders(any(Intent.class), anyInt()))
+ .thenReturn(getDummyResolveInfo());
+
+ DatabaseIndexingManager manager =
+ spy(new DatabaseIndexingManager(mContext, PACKAGE_ONE));
+ doReturn(true).when(manager).isFullIndex(anyString(), anyString());
+
+ manager.performIndexing();
+
+ assertThat(IndexDatabaseHelper.getInstance(mContext).isBuildIndexed(mContext,
+ Build.FINGERPRINT)).isTrue();
}
@Test
public void testFullUpdatedDatabase_noData_addDataToDatabaseNotCalled() {
- mManager.updateDatabase(false, localeStr);
+ mManager.updateDatabase(true /* isFullIndex */, localeStr);
mManager.mDataToProcess.dataToUpdate.clear();
verify(mManager, times(0)).addDataToDatabase(any(SQLiteDatabase.class), anyString(),
anyList(), anyMap());
@@ -736,13 +812,13 @@
@Test
public void testFullUpdatedDatabase_updatedDataInDatabaseNotCalled() {
- mManager.updateDatabase(false, localeStr);
+ mManager.updateDatabase(true /* isFullIndex */, localeStr);
verify(mManager, times(0)).updateDataInDatabase(any(SQLiteDatabase.class), anyMap());
}
@Test
public void testLocaleUpdated_afterIndexing_localeNotAdded() {
- mManager.updateDatabase(false, localeStr);
+ mManager.updateDatabase(true /* isFullIndex */, localeStr);
assertThat(IndexDatabaseHelper.getInstance(mContext)
.isLocaleAlreadyIndexed(mContext, localeStr)).isFalse();
}
@@ -758,7 +834,7 @@
public void testUpdateDatabase_newEligibleData_addedToDatabase() {
// Test that addDataToDatabase is called when dataToUpdate is non-empty
mManager.mDataToProcess.dataToUpdate.add(getFakeRaw());
- mManager.updateDatabase(false, localeStr);
+ mManager.updateDatabase(true /* isFullIndex */, localeStr);
Cursor cursor = mDb.rawQuery("SELECT * FROM prefs_index", null);
cursor.moveToPosition(0);
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();
+ }
+}