Merge "Remove the getSwitch() in SwitchWidgetController"
diff --git a/res/drawable-hdpi/empty_search_results.png b/res/drawable-hdpi/empty_search_results.png
deleted file mode 100644
index 6202a33..0000000
--- a/res/drawable-hdpi/empty_search_results.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/empty_search_results.png b/res/drawable-mdpi/empty_search_results.png
deleted file mode 100644
index e418d7c..0000000
--- a/res/drawable-mdpi/empty_search_results.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/empty_search_results.png b/res/drawable-xhdpi/empty_search_results.png
deleted file mode 100644
index a92f000..0000000
--- a/res/drawable-xhdpi/empty_search_results.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/empty_search_results.png b/res/drawable-xxhdpi/empty_search_results.png
deleted file mode 100644
index 4c549bc..0000000
--- a/res/drawable-xxhdpi/empty_search_results.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/empty_search_results.png b/res/drawable-xxxhdpi/empty_search_results.png
deleted file mode 100644
index 1aed6ad..0000000
--- a/res/drawable-xxxhdpi/empty_search_results.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/empty_search_results.xml b/res/drawable/empty_search_results.xml
new file mode 100644
index 0000000..9162107
--- /dev/null
+++ b/res/drawable/empty_search_results.xml
@@ -0,0 +1,30 @@
+<?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.
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="96dp"
+ android:height="96dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24"
+ android:tint="?android:attr/colorControlNormal">
+
+ <path
+ android:fillColor="#000000"
+ android:pathData="M15.5,14h-0.79l-0.28-0.27c1.2-1.4,1.82-3.31,1.48-5.34c-0.47-2.78-2.79-5-5.59-5.34c-4.23-0.52-7.79,3.04-7.27,7.27
+c0.34,2.8,2.56,5.12,5.34,5.59c2.03,0.34,3.94-0.28,5.34-1.48L14,14.71v0.79l5.2,5.19c0.41,0.41,1.07,0.41,1.48,0l0.01-0.01
+c0.41-0.41,0.41-1.07,0-1.48L15.5,14z M9.5,14C7.01,14,5,11.99,5,9.5S7.01,5,9.5,5S14,7.01,14,9.5S11.99,14,9.5,14z" />
+</vector>
\ No newline at end of file
diff --git a/res/layout-land/fingerprint_enroll_enrolling.xml b/res/layout-land/fingerprint_enroll_enrolling.xml
index fb6c78b..8b902f1 100644
--- a/res/layout-land/fingerprint_enroll_enrolling.xml
+++ b/res/layout-land/fingerprint_enroll_enrolling.xml
@@ -110,10 +110,11 @@
<com.android.setupwizardlib.view.FillContentLayout
android:layout_width="wrap_content"
- android:layout_height="wrap_content"
+ android:layout_height="0dp"
+ android:layout_marginVertical="24dp"
+ android:layout_weight="1"
android:paddingTop="0dp"
- android:paddingBottom="0dp"
- android:layout_marginVertical="24dp">
+ android:paddingBottom="0dp">
<include layout="@layout/fingerprint_enroll_enrolling_content"
android:layout_width="match_parent"
diff --git a/res/layout/preference_dropdown_material_settings.xml b/res/layout/preference_dropdown_material_settings.xml
deleted file mode 100644
index a3f5ab9..0000000
--- a/res/layout/preference_dropdown_material_settings.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2016 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.
- -->
-
-
-<!-- Based off frameworks/base/core/res/res/layout/preference_dropdown_material.xml
- except that icon space in this layout is always reserved -->
-<FrameLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <Spinner
- android:id="@+id/spinner"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_marginStart="@dimen/preference_no_icon_padding_start"
- android:visibility="invisible" />
-
- <include layout="@layout/preference_material"/>
-
-</FrameLayout>
\ No newline at end of file
diff --git a/res/layout/search_panel.xml b/res/layout/search_panel.xml
index 42fbefb..10c2a00 100644
--- a/res/layout/search_panel.xml
+++ b/res/layout/search_panel.xml
@@ -85,8 +85,8 @@
android:layout_height="?android:attr/actionBarSize"/>
<ImageView
- android:layout_height="160dp"
- android:layout_width="160dp"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
android:src="@drawable/empty_search_results"/>
diff --git a/res/layout/settings_main_dashboard.xml b/res/layout/settings_main_dashboard.xml
index 7c34803..4f8c308 100644
--- a/res/layout/settings_main_dashboard.xml
+++ b/res/layout/settings_main_dashboard.xml
@@ -17,7 +17,8 @@
*/
-->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -32,7 +33,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/search_bar_margin"
- app:cardCornerRadius="@dimen/search_bar_half_height"
+ app:cardCornerRadius="@dimen/search_bar_corner_radius"
app:cardBackgroundColor="?android:attr/colorBackground"
app:cardElevation="2dp">
<Toolbar
@@ -43,13 +44,18 @@
android:contentInsetStartWithNavigation="64dp"
android:navigationIcon="@drawable/ic_search_24dp"
android:navigationContentDescription="@string/search_menu"
- android:title="@string/search_menu"
- android:titleTextAppearance="@style/TextAppearance.SearchBar"
- android:theme="?android:attr/actionBarTheme"/>
+ android:theme="?android:attr/actionBarTheme">
+ <TextView
+ android:id="@+id/search_action_bar_title"
+ style="@style/TextAppearance.SearchBar"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/search_menu" />
+ </Toolbar>
</android.support.v7.widget.CardView>
</FrameLayout>
<FrameLayout
android:id="@+id/main_content"
android:layout_height="match_parent"
- android:layout_width="match_parent"/>
+ android:layout_width="match_parent" />
</LinearLayout>
diff --git a/res/layout/storage_summary_donut.xml b/res/layout/storage_summary_donut.xml
index 8e11d71..ce7e272 100644
--- a/res/layout/storage_summary_donut.xml
+++ b/res/layout/storage_summary_donut.xml
@@ -63,7 +63,7 @@
android:layout_height="wrap_content"
android:layout_below="@android:id/summary"
android:text="@string/storage_menu_free"
- style="@android:style/@Widget.Material.Button.Colored" />
+ style="@style/ActionPrimaryButton" />
</LinearLayout>
<com.android.settings.widget.DonutView
diff --git a/res/layout/suggestion_tile_with_button.xml b/res/layout/suggestion_tile_with_button.xml
index 085f88c..081df5b 100644
--- a/res/layout/suggestion_tile_with_button.xml
+++ b/res/layout/suggestion_tile_with_button.xml
@@ -61,7 +61,7 @@
<Button
android:id="@android:id/primary"
- style="@style/SuwGlifButton.Primary"
+ style="@style/ActionPrimaryButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
diff --git a/res/layout/support_escalation_options.xml b/res/layout/support_escalation_options.xml
index 17e03ff..ae208f1 100644
--- a/res/layout/support_escalation_options.xml
+++ b/res/layout/support_escalation_options.xml
@@ -65,7 +65,7 @@
android:orientation="vertical">
<Button
android:id="@android:id/text1"
- style="@style/SupportPrimaryButton"
+ style="@style/ActionPrimaryButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"/>
@@ -86,7 +86,7 @@
android:orientation="vertical">
<Button
android:id="@android:id/text2"
- style="@style/SupportPrimaryButton"
+ style="@style/ActionPrimaryButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"/>
diff --git a/res/layout/support_offline_escalation_options.xml b/res/layout/support_offline_escalation_options.xml
index 18d8f98..09863d3 100644
--- a/res/layout/support_offline_escalation_options.xml
+++ b/res/layout/support_offline_escalation_options.xml
@@ -56,7 +56,7 @@
</LinearLayout>
<Button
android:id="@android:id/text1"
- style="@style/SupportPrimaryButton"
+ style="@style/ActionPrimaryButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
diff --git a/res/layout/support_sign_in_button.xml b/res/layout/support_sign_in_button.xml
index 45de571..5bea068 100644
--- a/res/layout/support_sign_in_button.xml
+++ b/res/layout/support_sign_in_button.xml
@@ -38,7 +38,7 @@
android:textColor="?android:attr/textColorSecondary"/>
<Button
android:id="@android:id/text1"
- style="@style/SupportPrimaryButton"
+ style="@style/ActionPrimaryButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"/>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 2f00297..ef4d269 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -121,7 +121,7 @@
<dimen name="search_bar_negative_margin">-8dp</dimen>
<dimen name="search_bar_height">48dp</dimen>
- <dimen name="search_bar_half_height">24dp</dimen>
+ <dimen name="search_bar_corner_radius">2dp</dimen>
<dimen name="search_bar_text_size">16dp</dimen>
<!-- Dimensions for Wifi Assistant Card -->
diff --git a/res/values/styles.xml b/res/values/styles.xml
index e2b6d44..c68eb72 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -338,10 +338,8 @@
<style name="TextAppearance.SupportSummary" parent="TextAppearance.CategoryTitle"/>
- <style name="SupportPrimaryButton" parent="android:Widget.Material.Button.Colored"/>
-
<style name="SupportSecondaryButton"
- parent="android:Widget.Material.Button.Borderless.Colored">
+ parent="android:Widget.DeviceDefault.Button.Borderless.Colored">
<item name="android:textSize">12sp</item>
</style>
@@ -425,11 +423,11 @@
<item name="android:textSize">16sp</item>
</style>
- <style name="ActionPrimaryButton" parent="android:Widget.Material.Button.Colored"/>
+ <style name="ActionPrimaryButton" parent="android:Widget.DeviceDefault.Button.Colored"/>
- <style name="ActionSecondaryButton" parent="android:Widget.Material.Button"/>
+ <style name="ActionSecondaryButton" parent="android:Widget.DeviceDefault.Button"/>
- <style name="DreamStartButton" parent="android:Widget.Material.Button" />
+ <style name="DreamStartButton" parent="android:Widget.DeviceDefault.Button" />
<style name="LockPatternContainerStyle">
<item name="android:maxHeight">400dp</item>
diff --git a/res/values/styles_preference.xml b/res/values/styles_preference.xml
index 056d55a..b8b9eb3 100644
--- a/res/values/styles_preference.xml
+++ b/res/values/styles_preference.xml
@@ -20,19 +20,19 @@
<resources>
<!-- Fragment style -->
- <style name="SettingsPreferenceFragmentStyle" parent="@style/PreferenceFragmentStyle.SettingsBase">
+ <style name="SettingsPreferenceFragmentStyle" parent="@style/PreferenceFragment.Material">
<item name="android:layout">@layout/preference_list_fragment</item>
</style>
- <style name="ApnPreference" parent="Preference.SettingsBase">
+ <style name="ApnPreference" parent="@style/Preference.Material">
<item name="android:layout">@layout/apn_preference_layout</item>
</style>
- <style name="SettingsSeekBarPreference" parent="Preference.SettingsBase">
+ <style name="SettingsSeekBarPreference" parent="@style/Preference.Material">
<item name="android:layout">@layout/preference_widget_seekbar_settings</item>
</style>
- <style name="SyncSwitchPreference" parent="Preference.SettingsBase">
+ <style name="SyncSwitchPreference" parent="@style/Preference.Material">
<item name="android:widgetLayout">@layout/preference_widget_sync_toggle</item>
</style>
diff --git a/res/xml/app_info_settings.xml b/res/xml/app_info_settings.xml
new file mode 100644
index 0000000..48a4b6a
--- /dev/null
+++ b/res/xml/app_info_settings.xml
@@ -0,0 +1,93 @@
+<?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
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:key="installed_app_detail_settings_screen"
+ app:initialExpandedChildrenCount="6">
+
+ <com.android.settings.applications.LayoutPreference
+ android:key="header_view"
+ android:layout="@layout/settings_entity_header"
+ android:selectable="false"
+ android:order="-10000"/>
+
+ <com.android.settings.applications.LayoutPreference
+ android:key="instant_app_buttons"
+ android:layout="@layout/instant_app_buttons"
+ android:selectable="false"
+ android:order="-9999"/>
+
+ <com.android.settings.widget.ActionButtonPreference
+ android:key="action_buttons"
+ android:order="-9998" />
+
+ <Preference
+ android:key="notification_settings"
+ android:title="@string/notifications_label"
+ android:selectable="true"/>
+
+ <com.android.settings.widget.FixedLineSummaryPreference
+ android:key="permission_settings"
+ android:title="@string/permissions_label"
+ android:summary="@string/summary_placeholder"
+ android:selectable="true"
+ app:summaryLineCount="1" />
+
+ <Preference
+ android:key="storage_settings"
+ android:title="@string/storage_settings"
+ android:summary="@string/summary_placeholder"
+ android:selectable="true"/>
+
+ <com.android.settings.applications.AppDomainsPreference
+ android:key="instant_app_launch_supported_domain_urls"
+ android:title="@string/app_launch_supported_domain_urls_title"
+ 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"/>
+
+ <Preference
+ android:key="app_version"
+ android:selectable="false"
+ android:order="9999"/>
+
+</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/connected_devices.xml b/res/xml/connected_devices.xml
index d24dd51..497a485 100644
--- a/res/xml/connected_devices.xml
+++ b/res/xml/connected_devices.xml
@@ -22,4 +22,8 @@
<PreferenceCategory
android:key="connected_device_list"
android:title="@string/connected_device_connected_title"/>
+
+ <PreferenceCategory
+ android:key="saved_device_list"
+ android:title="@string/connected_device_saved_title"/>
</PreferenceScreen>
diff --git a/res/xml/night_display_settings.xml b/res/xml/night_display_settings.xml
index dc4fecd..8f2bb97 100644
--- a/res/xml/night_display_settings.xml
+++ b/res/xml/night_display_settings.xml
@@ -16,7 +16,8 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
- android:title="@string/night_display_title">
+ android:title="@string/night_display_title"
+ android:key="night_display_title">
<DropDownPreference
android:key="night_display_auto_mode"
diff --git a/res/xml/notification_settings.xml b/res/xml/notification_settings.xml
index 85952e9..144bef6 100644
--- a/res/xml/notification_settings.xml
+++ b/res/xml/notification_settings.xml
@@ -15,6 +15,7 @@
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto">
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
+ android:title="@string/app_notifications_title">
</PreferenceScreen>
diff --git a/res/xml/wifi_display_settings.xml b/res/xml/wifi_display_settings.xml
index 2be31d2..7ad214e 100644
--- a/res/xml/wifi_display_settings.xml
+++ b/res/xml/wifi_display_settings.xml
@@ -14,7 +14,9 @@
limitations under the License.
-->
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:key="wifi_display_settings_screen"
android:title="@string/wifi_display_settings_title">
</PreferenceScreen>
diff --git a/res/xml/zen_mode_settings.xml b/res/xml/zen_mode_settings.xml
index 82bef4d..dbd1d42 100644
--- a/res/xml/zen_mode_settings.xml
+++ b/res/xml/zen_mode_settings.xml
@@ -33,7 +33,8 @@
<!-- Turn on DND button -->
<!-- Layout preference doesn't obey allowDividerAbove, so put it in a PreferenceCategory -->
- <PreferenceCategory>
+ <PreferenceCategory
+ android:key="zen_mode_settings_button_category">
<com.android.settings.applications.LayoutPreference
android:key="zen_mode_settings_button_container"
android:selectable="false"
diff --git a/src/com/android/settings/CredentialStorage.java b/src/com/android/settings/CredentialStorage.java
index e5d40b7..ffbd2ce 100644
--- a/src/com/android/settings/CredentialStorage.java
+++ b/src/com/android/settings/CredentialStorage.java
@@ -275,6 +275,16 @@
Log.e(TAG, "Failed to install " + key + " as uid " + uid);
return;
}
+ // The key was prepended USER_PRIVATE_KEY by the CredentialHelper. However,
+ // KeyChain internally uses the raw alias name and only prepends USER_PRIVATE_KEY
+ // to the key name when interfacing with KeyStore.
+ // This is generally a symptom of CredentialStorage and CredentialHelper relying
+ // on internal implementation details of KeyChain and imitating its functionality
+ // rather than delegating to KeyChain for the certificate installation.
+ if (uid == Process.SYSTEM_UID || uid == KeyStore.UID_SELF) {
+ new MarkKeyAsUserSelectable(
+ key.replaceFirst("^" + Credentials.USER_PRIVATE_KEY, "")).execute();
+ }
}
int flags = KeyStore.FLAG_NONE;
@@ -391,6 +401,33 @@
}
/**
+ * Background task to mark a given key alias as user-selectable, so that
+ * it can be selected by users from the Certificate Selection prompt.
+ */
+ private class MarkKeyAsUserSelectable extends AsyncTask<Void, Void, Boolean> {
+ final String mAlias;
+
+ public MarkKeyAsUserSelectable(String alias) {
+ mAlias = alias;
+ }
+
+ @Override
+ protected Boolean doInBackground(Void... unused) {
+ try (KeyChainConnection keyChainConnection = KeyChain.bind(CredentialStorage.this)) {
+ keyChainConnection.getService().setUserSelectable(mAlias, true);
+ return true;
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed to mark key " + mAlias + " as user-selectable.");
+ return false;
+ } catch (InterruptedException e) {
+ Log.w(TAG, "Failed to mark key " + mAlias + " as user-selectable.");
+ Thread.currentThread().interrupt();
+ return false;
+ }
+ }
+ }
+
+ /**
* Check that the caller is either certinstaller or Settings running in a profile of this user.
*/
private boolean checkCallerIsCertInstallerOrSelfInProfile() {
diff --git a/src/com/android/settings/DeviceInfoSettings.java b/src/com/android/settings/DeviceInfoSettings.java
index c791775..a5f7c45 100644
--- a/src/com/android/settings/DeviceInfoSettings.java
+++ b/src/com/android/settings/DeviceInfoSettings.java
@@ -76,7 +76,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_uri_about;
}
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java
index d67758a..e726c63 100644
--- a/src/com/android/settings/DisplaySettings.java
+++ b/src/com/android/settings/DisplaySettings.java
@@ -56,6 +56,8 @@
private static final String KEY_SCREEN_TIMEOUT = "screen_timeout";
private static final String KEY_AMBIENT_DISPLAY = "ambient_display";
+ private static final String KEY_NIGHT_DISPLAY = "night_display";
+
@Override
public int getMetricsCategory() {
return MetricsEvent.DISPLAY;
@@ -77,7 +79,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_uri_display;
}
@@ -126,6 +128,7 @@
keys.add(KEY_DISPLAY_SIZE);
keys.add(WallpaperPreferenceController.KEY_WALLPAPER);
keys.add(KEY_AMBIENT_DISPLAY);
+ keys.add(KEY_NIGHT_DISPLAY);
return keys;
}
diff --git a/src/com/android/settings/IccLockSettings.java b/src/com/android/settings/IccLockSettings.java
index 0517b13..b9f3b10 100644
--- a/src/com/android/settings/IccLockSettings.java
+++ b/src/com/android/settings/IccLockSettings.java
@@ -295,7 +295,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_icc_lock;
}
diff --git a/src/com/android/settings/PrivacySettings.java b/src/com/android/settings/PrivacySettings.java
index e547570..24774e0 100644
--- a/src/com/android/settings/PrivacySettings.java
+++ b/src/com/android/settings/PrivacySettings.java
@@ -220,7 +220,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_backup_reset;
}
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 193c2b3..dc961be 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -340,6 +340,7 @@
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(mDisplayHomeAsUpEnabled);
actionBar.setHomeButtonEnabled(mDisplayHomeAsUpEnabled);
+ actionBar.setDisplayShowTitleEnabled(!mIsShowingDashboard);
}
mSwitchBar = findViewById(R.id.switch_bar);
if (mSwitchBar != null) {
diff --git a/src/com/android/settings/SettingsPreferenceFragment.java b/src/com/android/settings/SettingsPreferenceFragment.java
index 5d3bf00..d9e264b 100644
--- a/src/com/android/settings/SettingsPreferenceFragment.java
+++ b/src/com/android/settings/SettingsPreferenceFragment.java
@@ -39,8 +39,6 @@
import android.util.ArrayMap;
import android.util.Log;
import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
@@ -49,10 +47,12 @@
import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.core.instrumentation.Instrumentable;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import com.android.settings.search.actionbar.SearchMenuController;
+import com.android.settings.support.actionbar.HelpMenuController;
+import com.android.settings.support.actionbar.HelpResourceProvider;
import com.android.settings.widget.LoadingViewController;
import com.android.settingslib.CustomDialogPreference;
import com.android.settingslib.CustomEditTextPreference;
-import com.android.settingslib.HelpUtils;
import com.android.settingslib.widget.FooterPreferenceMixin;
import java.util.UUID;
@@ -61,13 +61,7 @@
* Base class for Settings fragments, with some helper functions and dialog management.
*/
public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceFragment
- implements DialogCreatable {
-
- /**
- * The Help Uri Resource key. This can be passed as an extra argument when creating the
- * Fragment.
- **/
- public static final String HELP_URI_RESOURCE_KEY = "help_uri_resource";
+ implements DialogCreatable, HelpResourceProvider {
private static final String TAG = "SettingsPreference";
@@ -79,13 +73,11 @@
protected final FooterPreferenceMixin mFooterPreferenceMixin =
new FooterPreferenceMixin(this, getLifecycle());
- private SettingsDialogFragment mDialogFragment;
-
- private String mHelpUri;
private static final int ORDER_FIRST = -1;
private static final int ORDER_LAST = Integer.MAX_VALUE -1;
+ private SettingsDialogFragment mDialogFragment;
// Cache the content resolver for async callbacks
private ContentResolver mContentResolver;
@@ -144,22 +136,13 @@
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
+ SearchMenuController.init(this /* host */);
+ HelpMenuController.init(this /* host */);
if (icicle != null) {
mPreferenceHighlighted = icicle.getBoolean(SAVE_HIGHLIGHTED_KEY);
}
-
- // Prepare help url and enable menu if necessary
final Bundle arguments = getArguments();
- final int helpResource;
- if (arguments != null && arguments.containsKey(HELP_URI_RESOURCE_KEY)) {
- helpResource = arguments.getInt(HELP_URI_RESOURCE_KEY);
- } else {
- helpResource = getHelpResource();
- }
- if (helpResource != 0) {
- mHelpUri = getResources().getString(helpResource);
- }
// Check if we should keep the preferences expanded.
if (arguments != null) {
@@ -177,8 +160,8 @@
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View root = super.onCreateView(inflater, container, savedInstanceState);
- mPinnedHeaderFrameLayout = (ViewGroup) root.findViewById(R.id.pinned_header);
- mButtonBar = (ViewGroup) root.findViewById(R.id.button_bar);
+ mPinnedHeaderFrameLayout = root.findViewById(R.id.pinned_header);
+ mButtonBar = root.findViewById(R.id.button_bar);
return root;
}
@@ -465,22 +448,6 @@
return false;
}
- /**
- * Override this if you want to show a help item in the menu, by returning the resource id.
- * @return the resource id for the help url
- */
- protected int getHelpResource() {
- return R.string.help_uri_default;
- }
-
- @Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- super.onCreateOptionsMenu(menu, inflater);
- if (mHelpUri != null && getActivity() != null) {
- HelpUtils.prepareHelpMenuItem(getActivity(), menu, mHelpUri, getClass().getName());
- }
- }
-
/*
* The name is intentionally made different from Activity#finish(), so that
* users won't misunderstand its meaning.
diff --git a/src/com/android/settings/WifiCallingSettingsForSub.java b/src/com/android/settings/WifiCallingSettingsForSub.java
index 57a4ab2..ba5ba84 100644
--- a/src/com/android/settings/WifiCallingSettingsForSub.java
+++ b/src/com/android/settings/WifiCallingSettingsForSub.java
@@ -131,7 +131,7 @@
};
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
// Helper resource is already defined in the container fragment.
return 0;
}
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 877894b..0611b09 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -230,7 +230,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_uri_accessibility;
}
diff --git a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java
index b820cc2..f6e044e 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java
@@ -17,22 +17,14 @@
package com.android.settings.accessibility;
import android.app.Fragment;
-import android.app.FragmentTransaction;
import android.os.Bundle;
import android.text.TextUtils;
-import android.view.accessibility.AccessibilityEvent;
-import android.view.LayoutInflater;
import android.view.Menu;
-import android.view.View;
-import android.view.WindowInsets;
-import android.widget.FrameLayout;
-import android.widget.LinearLayout;
+import android.view.accessibility.AccessibilityEvent;
-import com.android.settings.R;
import com.android.settings.SettingsActivity;
-import com.android.settings.SettingsPreferenceFragment;
-import com.android.setupwizardlib.util.SystemBarHelper;
-import com.android.setupwizardlib.view.NavigationBar;
+import com.android.settings.search.actionbar.SearchMenuController;
+import com.android.settings.support.actionbar.HelpResourceProvider;
public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivity {
@@ -94,7 +86,8 @@
}
// Start the new Fragment.
- args.putInt(SettingsPreferenceFragment.HELP_URI_RESOURCE_KEY, 0);
+ args.putInt(HelpResourceProvider.HELP_URI_RESOURCE_KEY, 0);
+ args.putBoolean(SearchMenuController.NEED_SEARCH_ICON_IN_ACTION_BAR, false);
startPreferenceFragment(Fragment.instantiate(this, fragmentClass, args), true);
mSendExtraWindowStateChanged = true;
}
diff --git a/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java b/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java
index c437a16..db121e2 100644
--- a/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java
@@ -51,7 +51,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_accessibility_shortcut;
}
diff --git a/src/com/android/settings/accessibility/MagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/MagnificationPreferenceFragment.java
index d0197cf..24e87fc 100644
--- a/src/com/android/settings/accessibility/MagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/MagnificationPreferenceFragment.java
@@ -66,7 +66,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_magnification;
}
diff --git a/src/com/android/settings/accessibility/ToggleAutoclickPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAutoclickPreferenceFragment.java
index a94b72c..acb918c 100644
--- a/src/com/android/settings/accessibility/ToggleAutoclickPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleAutoclickPreferenceFragment.java
@@ -103,7 +103,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_autoclick;
}
diff --git a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
index 8e76e48..146f697 100644
--- a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
@@ -41,7 +41,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_color_correction;
}
diff --git a/src/com/android/settings/accounts/AccountDetailDashboardFragment.java b/src/com/android/settings/accounts/AccountDetailDashboardFragment.java
index 53664f5..9239b8e 100644
--- a/src/com/android/settings/accounts/AccountDetailDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountDetailDashboardFragment.java
@@ -99,7 +99,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_account_detail;
}
diff --git a/src/com/android/settings/accounts/AccountSyncSettings.java b/src/com/android/settings/accounts/AccountSyncSettings.java
index 675de0e..d83694d 100644
--- a/src/com/android/settings/accounts/AccountSyncSettings.java
+++ b/src/com/android/settings/accounts/AccountSyncSettings.java
@@ -573,7 +573,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_accounts;
}
}
diff --git a/src/com/android/settings/accounts/UserAndAccountDashboardFragment.java b/src/com/android/settings/accounts/UserAndAccountDashboardFragment.java
index de200cb..37584fc 100644
--- a/src/com/android/settings/accounts/UserAndAccountDashboardFragment.java
+++ b/src/com/android/settings/accounts/UserAndAccountDashboardFragment.java
@@ -56,7 +56,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_user_and_account_dashboard;
}
diff --git a/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java b/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java
index 5eccd44..7d6bdbb 100644
--- a/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java
+++ b/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java
@@ -48,7 +48,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_apps_and_notifications;
}
diff --git a/src/com/android/settings/applications/AppInfoDashboardFragment.java b/src/com/android/settings/applications/AppInfoDashboardFragment.java
index 0e73ad7..ba8b901 100755
--- a/src/com/android/settings/applications/AppInfoDashboardFragment.java
+++ b/src/com/android/settings/applications/AppInfoDashboardFragment.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007 The Android Open Source Project
+ * 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
@@ -25,35 +25,22 @@
import android.app.Dialog;
import android.app.DialogFragment;
import android.app.Fragment;
-import android.app.LoaderManager;
-import android.app.LoaderManager.LoaderCallbacks;
import android.app.admin.DevicePolicyManager;
-import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
-import android.content.Loader;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.pm.UserInfo;
-import android.content.res.Resources;
-import android.hardware.usb.IUsbManager;
-import android.icu.text.ListFormatter;
-import android.net.INetworkStatsService;
-import android.net.INetworkStatsSession;
-import android.net.NetworkTemplate;
-import android.net.TrafficStats;
import android.net.Uri;
import android.os.AsyncTask;
-import android.os.BatteryStats;
import android.os.Bundle;
-import android.os.IBinder;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
@@ -65,8 +52,6 @@
import android.support.v7.preference.PreferenceScreen;
import android.text.BidiFormatter;
import android.text.TextUtils;
-import android.text.format.DateUtils;
-import android.text.format.Formatter;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
@@ -76,13 +61,19 @@
import com.android.internal.logging.nano.MetricsProto;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.internal.os.BatterySipper;
-import com.android.internal.os.BatteryStatsHelper;
import com.android.settings.DeviceAdminAdd;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils;
+import com.android.settings.applications.appinfo.AppBatteryPreferenceController;
+import com.android.settings.applications.appinfo.AppDataUsagePreferenceController;
+import com.android.settings.applications.appinfo.AppMemoryPreferenceController;
+import com.android.settings.applications.appinfo.AppNotificationPreferenceController;
+import com.android.settings.applications.appinfo.AppOpenByDefaultPreferenceController;
+import com.android.settings.applications.appinfo.AppPermissionPreferenceController;
+import com.android.settings.applications.appinfo.AppStoragePreferenceController;
+import com.android.settings.applications.appinfo.AppVersionPreferenceController;
import com.android.settings.applications.defaultapps.DefaultBrowserPreferenceController;
import com.android.settings.applications.defaultapps.DefaultEmergencyPreferenceController;
import com.android.settings.applications.defaultapps.DefaultHomePreferenceController;
@@ -91,32 +82,17 @@
import com.android.settings.applications.instantapps.InstantAppButtonsController;
import com.android.settings.applications.manageapplications.ManageApplications;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
-import com.android.settings.datausage.AppDataUsage;
-import com.android.settings.datausage.DataUsageList;
-import com.android.settings.datausage.DataUsageUtils;
-import com.android.settings.fuelgauge.AdvancedPowerUsageDetail;
-import com.android.settings.fuelgauge.BatteryEntry;
-import com.android.settings.fuelgauge.BatteryStatsHelperLoader;
-import com.android.settings.fuelgauge.BatteryUtils;
-import com.android.settings.notification.AppNotificationSettings;
-import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.NotificationBackend.AppRow;
+import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.widget.ActionButtonPreference;
import com.android.settings.widget.EntityHeaderController;
import com.android.settings.wrapper.DevicePolicyManagerWrapper;
-import com.android.settingslib.AppItem;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.applications.AppUtils;
import com.android.settingslib.applications.ApplicationsState;
import com.android.settingslib.applications.ApplicationsState.AppEntry;
-import com.android.settingslib.applications.PermissionsSummaryHelper;
-import com.android.settingslib.applications.PermissionsSummaryHelper.PermissionsResultCallback;
-import com.android.settingslib.applications.StorageStatsSource;
-import com.android.settingslib.applications.StorageStatsSource.AppStorageStats;
-import com.android.settingslib.development.DevelopmentSettingsEnabler;
-import com.android.settingslib.net.ChartData;
-import com.android.settingslib.net.ChartDataLoader;
+import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.wrapper.PackageManagerWrapper;
import java.lang.ref.WeakReference;
@@ -134,11 +110,10 @@
* For non-system applications, there is no option to clear data. Instead there is an option to
* uninstall the application.
*/
-public class AppInfoDashboardFragment extends SettingsPreferenceFragment
- implements ApplicationsState.Callbacks, OnPreferenceClickListener,
- LoaderCallbacks<AppStorageStats> {
+public class AppInfoDashboardFragment extends DashboardFragment
+ implements ApplicationsState.Callbacks {
- private static final String LOG_TAG = "AppInfoDashboardFragment";
+ private static final String TAG = "AppInfoDashboard";
// Menu identifiers
public static final int UNINSTALL_ALL_USERS_MENU = 1;
@@ -148,37 +123,27 @@
public static final int REQUEST_UNINSTALL = 0;
private static final int REQUEST_REMOVE_DEVICE_ADMIN = 1;
- private static final int SUB_INFO_FRAGMENT = 1;
+ public static final int SUB_INFO_FRAGMENT = 1;
- private static final int LOADER_CHART_DATA = 2;
- private static final int LOADER_STORAGE = 3;
+ public static final int LOADER_CHART_DATA = 2;
+ public static final int LOADER_STORAGE = 3;
@VisibleForTesting
- static final int LOADER_BATTERY = 4;
+ public static final int LOADER_BATTERY = 4;
// Dialog identifiers used in showDialog
private static final int DLG_BASE = 0;
private static final int DLG_FORCE_STOP = DLG_BASE + 1;
private static final int DLG_DISABLE = DLG_BASE + 2;
private static final int DLG_SPECIAL_DISABLE = DLG_BASE + 3;
- private static final String EXTRA_HIDE_INFO_BUTTON = "hideInfoButton";
private static final String KEY_HEADER = "header_view";
private static final String KEY_INSTANT_APP_BUTTONS = "instant_app_buttons";
private static final String KEY_ACTION_BUTTONS = "action_buttons";
- private static final String KEY_NOTIFICATION = "notification_settings";
- private static final String KEY_STORAGE = "storage_settings";
- private static final String KEY_PERMISSION = "permission_settings";
- private static final String KEY_DATA = "data_settings";
- private static final String KEY_LAUNCH = "preferred_settings";
- private static final String KEY_BATTERY = "battery";
- private static final String KEY_MEMORY = "memory";
- private static final String KEY_VERSION = "app_version";
private static final String KEY_INSTANT_APP_SUPPORTED_LINKS =
"instant_app_launch_supported_domain_urls";
- // The following copied from AppInfoBase
+
public static final String ARG_PACKAGE_NAME = "package";
public static final String ARG_PACKAGE_UID = "uid";
- protected static final String TAG = AppInfoBase.class.getSimpleName();
protected static final boolean localLOGV = false;
private EnforcedAdmin mAppsControlDisallowedAdmin;
@@ -192,7 +157,6 @@
private int mUserId;
private String mPackageName;
- private IUsbManager mUsbManager;
private DevicePolicyManagerWrapper mDpm;
private UserManager mUserManager;
private PackageManager mPm;
@@ -207,66 +171,22 @@
private boolean mShowUninstalled;
private LayoutPreference mHeader;
private boolean mUpdatedSysApp = false;
- private Preference mNotificationPreference;
- private Preference mStoragePreference;
- private Preference mPermissionsPreference;
- private Preference mLaunchPreference;
- private Preference mDataPreference;
- private Preference mMemoryPreference;
- private Preference mVersionPreference;
private AppDomainsPreference mInstantAppDomainsPreference;
private boolean mDisableAfterUninstall;
- // Used for updating notification preference.
- private final NotificationBackend mBackend = new NotificationBackend();
-
- private ChartData mChartData;
- private INetworkStatsSession mStatsSession;
+ private List<Callback> mCallbacks = new ArrayList<>();
@VisibleForTesting
ActionButtonPreference mActionButtons;
- @VisibleForTesting
- Preference mBatteryPreference;
- @VisibleForTesting
- BatterySipper mSipper;
- @VisibleForTesting
- BatteryStatsHelper mBatteryHelper;
- @VisibleForTesting
- BatteryUtils mBatteryUtils;
-
- protected ProcStatsData mStatsManager;
- protected ProcStatsPackageEntry mStats;
private InstantAppButtonsController mInstantAppButtonsController;
- private AppStorageStats mLastResult;
- private String mBatteryPercent;
-
- @VisibleForTesting
- final LoaderCallbacks<BatteryStatsHelper> mBatteryCallbacks =
- new LoaderCallbacks<BatteryStatsHelper>() {
-
- @Override
- public Loader<BatteryStatsHelper> onCreateLoader(int id, Bundle args) {
- return new BatteryStatsHelperLoader(getContext());
- }
-
- @Override
- public void onLoadFinished(Loader<BatteryStatsHelper> loader,
- BatteryStatsHelper batteryHelper) {
- mBatteryHelper = batteryHelper;
- if (mPackageInfo != null) {
- mSipper = findTargetSipper(batteryHelper, mPackageInfo.applicationInfo.uid);
- if (getActivity() != null) {
- updateBattery();
- }
- }
- }
-
- @Override
- public void onLoaderReset(Loader<BatteryStatsHelper> loader) {
- }
- };
+ /**
+ * Callback to invoke when app info has been changed.
+ */
+ public interface Callback {
+ void refreshUi();
+ }
@VisibleForTesting
boolean handleDisableable() {
@@ -401,14 +321,10 @@
final Activity activity = getActivity();
mApplicationFeatureProvider = FeatureFactory.getFactory(activity)
.getApplicationFeatureProvider(activity);
- mState = ApplicationsState.getInstance(activity.getApplication());
- mSession = mState.newSession(this, getLifecycle());
mDpm = new DevicePolicyManagerWrapper(
(DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE));
mUserManager = (UserManager) activity.getSystemService(Context.USER_SERVICE);
mPm = activity.getPackageManager();
- IBinder b = ServiceManager.getService(Context.USB_SERVICE);
- mUsbManager = IUsbManager.Stub.asInterface(b);
retrieveAppEntry();
startListeningToPackageRemove();
@@ -418,21 +334,8 @@
}
setHasOptionsMenu(true);
- addPreferencesFromResource(R.xml.installed_app_details);
addDynamicPrefs();
- if (Utils.isBandwidthControlEnabled()) {
- INetworkStatsService statsService = INetworkStatsService.Stub.asInterface(
- ServiceManager.getService(Context.NETWORK_STATS_SERVICE));
- try {
- mStatsSession = statsService.openSession();
- } catch (RemoteException e) {
- throw new RuntimeException(e);
- }
- } else {
- removePreference(KEY_DATA);
- }
- mBatteryUtils = BatteryUtils.getInstance(getContext());
}
@Override
@@ -455,31 +358,54 @@
if (mFinishing) {
return;
}
- AppItem app = new AppItem(mAppEntry.info.uid);
- app.addUid(mAppEntry.info.uid);
- if (mStatsSession != null) {
- LoaderManager loaderManager = getLoaderManager();
- loaderManager.restartLoader(LOADER_CHART_DATA,
- ChartDataLoader.buildArgs(getTemplate(getContext()), app),
- mDataCallbacks);
- loaderManager.restartLoader(LOADER_STORAGE, Bundle.EMPTY, this);
- }
- restartBatteryStatsLoader();
- if (DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(getContext())) {
- new MemoryUpdater().execute();
- }
updateDynamicPrefs();
}
- @VisibleForTesting
- public void restartBatteryStatsLoader() {
- getLoaderManager().restartLoader(LOADER_BATTERY, Bundle.EMPTY, mBatteryCallbacks);
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.app_info_settings;
}
@Override
- public void onPause() {
- getLoaderManager().destroyLoader(LOADER_CHART_DATA);
- super.onPause();
+ protected String getLogTag() {
+ return TAG;
+ }
+
+ @Override
+ protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
+ final String packageName = getPackageName();
+ final List<AbstractPreferenceController> controllers = new ArrayList<>();
+ final Lifecycle lifecycle = getLifecycle();
+
+ // The following are controllers for preferences that needs to refresh the preference state
+ // when app state changes.
+ controllers.add(new AppStoragePreferenceController(context, this, lifecycle));
+ controllers.add(new AppDataUsagePreferenceController(context, this, lifecycle));
+ controllers.add(new AppNotificationPreferenceController(context, this));
+ controllers.add(new AppOpenByDefaultPreferenceController(context, this));
+ controllers.add(new AppPermissionPreferenceController(context, this, packageName));
+ controllers.add(new AppVersionPreferenceController(context, this));
+
+ for (AbstractPreferenceController controller : controllers) {
+ mCallbacks.add((Callback) controller);
+ }
+
+ // The following are controllers for preferences that don't need to refresh the preference
+ // state when app state changes.
+ controllers.add(new AppBatteryPreferenceController(context, this, packageName, lifecycle));
+ controllers.add(new AppMemoryPreferenceController(context, this, lifecycle));
+ return controllers;
+ }
+
+ public ApplicationsState.AppEntry getAppEntry() {
+ if (mAppEntry == null) {
+ retrieveAppEntry();
+ }
+ return mAppEntry;
+ }
+
+ public PackageInfo getPackageInfo() {
+ return mPackageInfo;
}
public void onActivityCreated(Bundle savedInstanceState) {
@@ -502,43 +428,14 @@
.styleActionBar(activity)
.bindHeaderButtons();
- mNotificationPreference = findPreference(KEY_NOTIFICATION);
- mNotificationPreference.setOnPreferenceClickListener(this);
- mStoragePreference = findPreference(KEY_STORAGE);
- mStoragePreference.setOnPreferenceClickListener(this);
- mPermissionsPreference = findPreference(KEY_PERMISSION);
- mPermissionsPreference.setOnPreferenceClickListener(this);
- mDataPreference = findPreference(KEY_DATA);
- if (mDataPreference != null) {
- mDataPreference.setOnPreferenceClickListener(this);
- }
- mBatteryPreference = findPreference(KEY_BATTERY);
- mBatteryPreference.setEnabled(false);
- mBatteryPreference.setOnPreferenceClickListener(this);
- mMemoryPreference = findPreference(KEY_MEMORY);
- mMemoryPreference.setOnPreferenceClickListener(this);
- mMemoryPreference.setVisible(
- DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(getContext()));
- mVersionPreference = findPreference(KEY_VERSION);
mInstantAppDomainsPreference =
(AppDomainsPreference) findPreference(KEY_INSTANT_APP_SUPPORTED_LINKS);
- mLaunchPreference = findPreference(KEY_LAUNCH);
- if (mAppEntry != null && mAppEntry.info != null) {
- if ((mAppEntry.info.flags&ApplicationInfo.FLAG_INSTALLED) == 0 ||
- !mAppEntry.info.enabled) {
- mLaunchPreference.setEnabled(false);
- } else {
- mLaunchPreference.setOnPreferenceClickListener(this);
- }
- } else {
- mLaunchPreference.setEnabled(false);
- }
}
@Override
public void onPackageSizeChanged(String packageName) {
if (!TextUtils.equals(packageName, mPackageName)) {
- Log.d(LOG_TAG, "Package change irrelevant, skipping");
+ Log.d(TAG, "Package change irrelevant, skipping");
return;
}
refreshUi();
@@ -554,7 +451,7 @@
boolean ensurePackageInfoAvailable(Activity activity) {
if (mPackageInfo == null) {
mFinishing = true;
- Log.w(LOG_TAG, "Package info not available. Is this package already uninstalled?");
+ Log.w(TAG, "Package info not available. Is this package already uninstalled?");
activity.finishAndRemoveTask();
return false;
}
@@ -563,6 +460,7 @@
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ super.onCreateOptionsMenu(menu, inflater);
menu.add(0, UNINSTALL_UPDATES, 0, R.string.app_factory_reset)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
menu.add(0, UNINSTALL_ALL_USERS_MENU, 1, R.string.uninstall_all_users_text)
@@ -622,23 +520,6 @@
}
}
- @Override
- public Loader<AppStorageStats> onCreateLoader(int id, Bundle args) {
- Context context = getContext();
- return new FetchPackageStorageAsyncLoader(
- context, new StorageStatsSource(context), mAppEntry.info, UserHandle.of(mUserId));
- }
-
- @Override
- public void onLoadFinished(Loader<AppStorageStats> loader, AppStorageStats result) {
- mLastResult = result;
- refreshUi();
- }
-
- @Override
- public void onLoaderReset(Loader<AppStorageStats> loader) {
- }
-
/**
* Utility method to hide and show specific preferences based on whether the app being displayed
* is an Instant App or an installed app.
@@ -652,7 +533,6 @@
mInstantAppDomainsPreference.setTitles(handledDomains);
// Dummy values, unused in the implementation
mInstantAppDomainsPreference.setValues(new int[handledDomains.length]);
- getPreferenceScreen().removePreference(mLaunchPreference);
} else {
getPreferenceScreen().removePreference(mInstantAppDomainsPreference);
}
@@ -672,8 +552,6 @@
.setSummary(summary)
.setIsInstantApp(isInstantApp)
.done(activity, false /* rebindActions */);
- mVersionPreference.setSummary(getString(R.string.version_text,
- BidiFormatter.getInstance().unicodeWrap(pkgInfo.versionName)));
}
@VisibleForTesting
@@ -700,19 +578,6 @@
return showIt;
}
- @VisibleForTesting
- BatterySipper findTargetSipper(BatteryStatsHelper batteryHelper, int uid) {
- List<BatterySipper> usageList = batteryHelper.getUsageList();
- for (int i = 0, size = usageList.size(); i < size; i++) {
- BatterySipper sipper = usageList.get(i);
- if (sipper.getUid() == uid) {
- return sipper;
- }
- }
-
- return null;
- }
-
private boolean signaturesMatch(String pkg1, String pkg2) {
if (pkg1 != null && pkg2 != null) {
try {
@@ -764,17 +629,8 @@
// Update the preference summaries.
Activity context = getActivity();
- boolean isExternal = ((mAppEntry.info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0);
- mStoragePreference.setSummary(getStorageSummary(context, mLastResult, isExternal));
-
- PermissionsSummaryHelper.getPermissionSummary(getContext(),
- mPackageName, mPermissionCallback);
- mLaunchPreference.setSummary(AppUtils.getLaunchByDefaultSummary(mAppEntry, mUsbManager,
- mPm, context));
- mNotificationPreference.setSummary(getNotificationSummary(mAppEntry, context,
- mBackend));
- if (mDataPreference != null) {
- mDataPreference.setSummary(getDataSummary());
+ for (Callback callback : mCallbacks) {
+ callback.refreshUi();
}
if (!mInitialized) {
@@ -803,63 +659,6 @@
return true;
}
- @VisibleForTesting
- void updateBattery() {
- mBatteryPreference.setEnabled(true);
- if (isBatteryStatsAvailable()) {
- final int dischargeAmount = mBatteryHelper.getStats().getDischargeAmount(
- BatteryStats.STATS_SINCE_CHARGED);
-
- final List<BatterySipper> usageList = new ArrayList<>(mBatteryHelper.getUsageList());
- final double hiddenAmount = mBatteryUtils.removeHiddenBatterySippers(usageList);
- final int percentOfMax = (int) mBatteryUtils.calculateBatteryPercent(
- mSipper.totalPowerMah, mBatteryHelper.getTotalPower(), hiddenAmount,
- dischargeAmount);
- mBatteryPercent = Utils.formatPercentage(percentOfMax);
- mBatteryPreference.setSummary(getString(R.string.battery_summary, mBatteryPercent));
- } else {
- mBatteryPreference.setSummary(getString(R.string.no_battery_summary));
- }
- }
-
- private CharSequence getDataSummary() {
- if (mChartData != null) {
- long totalBytes = mChartData.detail.getTotalBytes();
- if (totalBytes == 0) {
- return getString(R.string.no_data_usage);
- }
- Context context = getActivity();
- return getString(R.string.data_summary_format,
- Formatter.formatFileSize(context, totalBytes),
- DateUtils.formatDateTime(context, mChartData.detail.getStart(),
- DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH));
- }
- return getString(R.string.computing_size);
- }
-
- @VisibleForTesting
- static CharSequence getStorageSummary(
- Context context, AppStorageStats stats, boolean isExternal) {
- if (stats == null) {
- return context.getText(R.string.computing_size);
- } else {
- CharSequence storageType = context.getString(isExternal
- ? R.string.storage_type_external
- : R.string.storage_type_internal);
- return context.getString(R.string.storage_summary_format,
- getSize(context, stats), storageType.toString().toLowerCase());
- }
- }
-
- @VisibleForTesting
- boolean isBatteryStatsAvailable() {
- return mBatteryHelper != null && mSipper != null;
- }
-
- private static CharSequence getSize(Context context, AppStorageStats stats) {
- return Formatter.formatFileSize(context, stats.getTotalBytes());
- }
-
protected AlertDialog createDialog(int id, int errorCode) {
switch (id) {
case DLG_DISABLE:
@@ -928,7 +727,7 @@
mMetricsFeatureProvider.action(getContext(), MetricsEvent.ACTION_APP_FORCE_STOP, pkgName);
ActivityManager am = (ActivityManager) getActivity().getSystemService(
Context.ACTIVITY_SERVICE);
- Log.d(LOG_TAG, "Stopping package " + pkgName);
+ Log.d(TAG, "Stopping package " + pkgName);
am.forceStopPackage(pkgName);
int userId = UserHandle.getUserId(mAppEntry.info.uid);
mState.invalidatePackage(pkgName, userId);
@@ -950,7 +749,7 @@
void checkForceStop() {
if (mDpm.packageHasActiveAdmins(mPackageInfo.packageName)) {
// User can't force stop device admin.
- Log.w(LOG_TAG, "User can't force stop device admin");
+ Log.w(TAG, "User can't force stop device admin");
updateForceStopButton(false);
} else if (AppUtils.isInstant(mPackageInfo.applicationInfo)) {
updateForceStopButton(false);
@@ -958,7 +757,7 @@
} else if ((mAppEntry.info.flags & ApplicationInfo.FLAG_STOPPED) == 0) {
// If the app isn't explicitly stopped, then always show the
// force stop button.
- Log.w(LOG_TAG, "App is not explicitly stopped");
+ Log.w(TAG, "App is not explicitly stopped");
updateForceStopButton(true);
} else {
Intent intent = new Intent(Intent.ACTION_QUERY_PACKAGE_RESTART,
@@ -966,25 +765,13 @@
intent.putExtra(Intent.EXTRA_PACKAGES, new String[] { mAppEntry.info.packageName });
intent.putExtra(Intent.EXTRA_UID, mAppEntry.info.uid);
intent.putExtra(Intent.EXTRA_USER_HANDLE, UserHandle.getUserId(mAppEntry.info.uid));
- Log.d(LOG_TAG, "Sending broadcast to query restart status for "
+ Log.d(TAG, "Sending broadcast to query restart status for "
+ mAppEntry.info.packageName);
getActivity().sendOrderedBroadcastAsUser(intent, UserHandle.CURRENT, null,
mCheckKillProcessesReceiver, null, Activity.RESULT_CANCELED, null, null);
}
}
- private void startManagePermissionsActivity() {
- // start new activity to manage app permissions
- Intent intent = new Intent(Intent.ACTION_MANAGE_APP_PERMISSIONS);
- intent.putExtra(Intent.EXTRA_PACKAGE_NAME, mAppEntry.info.packageName);
- intent.putExtra(EXTRA_HIDE_INFO_BUTTON, true);
- try {
- getActivity().startActivityForResult(intent, SUB_INFO_FRAGMENT);
- } catch (ActivityNotFoundException e) {
- Log.w(LOG_TAG, "No app can handle android.intent.action.MANAGE_APP_PERMISSIONS");
- }
- }
-
private void startAppInfoFragment(Class<?> fragment, int title) {
startAppInfoFragment(fragment, title, this, mAppEntry);
}
@@ -1070,38 +857,6 @@
|| (mUserManager.isSplitSystemUser() && userCount == 2);
}
- @Override
- public boolean onPreferenceClick(Preference preference) {
- if (preference == mStoragePreference) {
- startAppInfoFragment(AppStorageSettings.class, R.string.storage_settings);
- } else if (preference == mNotificationPreference) {
- startAppInfoFragment(AppNotificationSettings.class, R.string.app_notifications_title);
- } else if (preference == mPermissionsPreference) {
- startManagePermissionsActivity();
- } else if (preference == mLaunchPreference) {
- startAppInfoFragment(AppLaunchSettings.class, R.string.launch_by_default);
- } else if (preference == mMemoryPreference) {
- ProcessStatsBase.launchMemoryDetail((SettingsActivity) getActivity(),
- mStatsManager.getMemInfo(), mStats, false);
- } else if (preference == mDataPreference) {
- startAppInfoFragment(AppDataUsage.class, R.string.app_data_usage);
- } else if (preference == mBatteryPreference) {
- if (isBatteryStatsAvailable()) {
- BatteryEntry entry = new BatteryEntry(getContext(), null, mUserManager, mSipper);
- entry.defaultPackageName = mPackageName;
- AdvancedPowerUsageDetail.startBatteryDetailPage((SettingsActivity) getActivity(),
- this, mBatteryHelper, BatteryStats.STATS_SINCE_CHARGED, entry,
- mBatteryPercent, null /* mAnomalies */);
- } else {
- AdvancedPowerUsageDetail.startBatteryDetailPage((SettingsActivity) getActivity(),
- this, mPackageName);
- }
- } else {
- return false;
- }
- return true;
- }
-
private void addDynamicPrefs() {
if (UserManager.get(getContext()).isManagedProfile()) {
return;
@@ -1330,78 +1085,11 @@
}
}
- public static NetworkTemplate getTemplate(Context context) {
- if (DataUsageList.hasReadyMobileRadio(context)) {
- return NetworkTemplate.buildTemplateMobileWildcard();
- }
- if (DataUsageUtils.hasWifiRadio(context)) {
- return NetworkTemplate.buildTemplateWifiWildcard();
- }
- return NetworkTemplate.buildTemplateEthernet();
- }
-
- public static CharSequence getNotificationSummary(AppEntry appEntry, Context context,
- NotificationBackend backend) {
- AppRow appRow = backend.loadAppRow(context, context.getPackageManager(), appEntry.info);
- return getNotificationSummary(appRow, context);
- }
-
- public static CharSequence getNotificationSummary(AppRow appRow, Context context) {
- // TODO: implement summary when it is known what it should say
- return "";
- }
-
private void onPackageRemoved() {
getActivity().finishActivity(SUB_INFO_FRAGMENT);
getActivity().finishAndRemoveTask();
}
- private class MemoryUpdater extends AsyncTask<Void, Void, ProcStatsPackageEntry> {
-
- @Override
- protected ProcStatsPackageEntry doInBackground(Void... params) {
- if (getActivity() == null) {
- return null;
- }
- if (mPackageInfo == null) {
- return null;
- }
- if (mStatsManager == null) {
- mStatsManager = new ProcStatsData(getActivity(), false);
- mStatsManager.setDuration(ProcessStatsBase.sDurations[0]);
- }
- mStatsManager.refreshStats(true);
- for (ProcStatsPackageEntry pkgEntry : mStatsManager.getEntries()) {
- for (ProcStatsEntry entry : pkgEntry.mEntries) {
- if (entry.mUid == mPackageInfo.applicationInfo.uid) {
- pkgEntry.updateMetrics();
- return pkgEntry;
- }
- }
- }
- return null;
- }
-
- @Override
- protected void onPostExecute(ProcStatsPackageEntry entry) {
- if (getActivity() == null) {
- return;
- }
- if (entry != null) {
- mStats = entry;
- mMemoryPreference.setEnabled(true);
- double amount = Math.max(entry.mRunWeight, entry.mBgWeight)
- * mStatsManager.getMemInfo().weightToRam;
- mMemoryPreference.setSummary(getString(R.string.memory_use_summary,
- Formatter.formatShortFileSize(getContext(), (long) amount)));
- } else {
- mMemoryPreference.setEnabled(false);
- mMemoryPreference.setSummary(getString(R.string.no_memory_use_summary));
- }
- }
-
- }
-
/**
* Elicit this class for testing. Test cannot be done in robolectric because it
* invokes the new API.
@@ -1453,76 +1141,22 @@
}
}
- private final LoaderCallbacks<ChartData> mDataCallbacks = new LoaderCallbacks<ChartData>() {
-
- @Override
- public Loader<ChartData> onCreateLoader(int id, Bundle args) {
- return new ChartDataLoader(getActivity(), mStatsSession, args);
- }
-
- @Override
- public void onLoadFinished(Loader<ChartData> loader, ChartData data) {
- mChartData = data;
- mDataPreference.setSummary(getDataSummary());
- }
-
- @Override
- public void onLoaderReset(Loader<ChartData> loader) {
- // Leave last result.
- }
- };
-
private final BroadcastReceiver mCheckKillProcessesReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final boolean enabled = getResultCode() != Activity.RESULT_CANCELED;
- Log.d(LOG_TAG, "Got broadcast response: Restart status for "
+ Log.d(TAG, "Got broadcast response: Restart status for "
+ mAppEntry.info.packageName + " " + enabled);
updateForceStopButton(enabled);
}
};
- private final PermissionsResultCallback mPermissionCallback
- = new PermissionsResultCallback() {
- @Override
- public void onPermissionSummaryResult(int standardGrantedPermissionCount,
- int requestedPermissionCount, int additionalGrantedPermissionCount,
- List<CharSequence> grantedGroupLabels) {
- if (getActivity() == null) {
- return;
- }
- final Resources res = getResources();
- CharSequence summary = null;
-
- if (requestedPermissionCount == 0) {
- summary = res.getString(
- R.string.runtime_permissions_summary_no_permissions_requested);
- mPermissionsPreference.setOnPreferenceClickListener(null);
- mPermissionsPreference.setEnabled(false);
- } else {
- final ArrayList<CharSequence> list = new ArrayList<>(grantedGroupLabels);
- if (additionalGrantedPermissionCount > 0) {
- // N additional permissions.
- list.add(res.getQuantityString(
- R.plurals.runtime_permissions_additional_count,
- additionalGrantedPermissionCount, additionalGrantedPermissionCount));
- }
- if (list.size() == 0) {
- summary = res.getString(
- R.string.runtime_permissions_summary_no_permissions_granted);
- } else {
- summary = ListFormatter.getInstance().format(list);
- }
- mPermissionsPreference.setOnPreferenceClickListener(AppInfoDashboardFragment.this);
- mPermissionsPreference.setEnabled(true);
- }
- mPermissionsPreference.setSummary(summary);
+ private String getPackageName() {
+ if (mPackageName != null) {
+ return mPackageName;
}
- };
-
- private String retrieveAppEntry() {
final Bundle args = getArguments();
- mPackageName = (args != null) ? args.getString(ARG_PACKAGE_NAME) : null;
+ String mPackageName = (args != null) ? args.getString(ARG_PACKAGE_NAME) : null;
if (mPackageName == null) {
Intent intent = (args == null) ?
getActivity().getIntent() : (Intent) args.getParcelable("intent");
@@ -1530,12 +1164,25 @@
mPackageName = intent.getData().getSchemeSpecificPart();
}
}
+ return mPackageName;
+ }
+
+ private void retrieveAppEntry() {
+ final Activity activity = getActivity();
+ if (activity == null) {
+ return;
+ }
+ if (mState == null) {
+ mState = ApplicationsState.getInstance(activity.getApplication());
+ mSession = mState.newSession(this, getLifecycle());
+ }
mUserId = UserHandle.myUserId();
- mAppEntry = mState.getEntry(mPackageName, mUserId);
+ mAppEntry = mState.getEntry(getPackageName(), UserHandle.myUserId());
if (mAppEntry != null) {
// Get application info again to refresh changed properties of application
try {
- mPackageInfo = mPm.getPackageInfo(mAppEntry.info.packageName,
+ mPackageInfo = activity.getPackageManager().getPackageInfo(
+ mAppEntry.info.packageName,
PackageManager.MATCH_DISABLED_COMPONENTS |
PackageManager.MATCH_ANY_USER |
PackageManager.GET_SIGNATURES |
@@ -1547,8 +1194,6 @@
Log.w(TAG, "Missing AppEntry; maybe reinstalling?");
mPackageInfo = null;
}
-
- return mPackageName;
}
private void setIntentAndFinish(boolean finish, boolean appChanged) {
diff --git a/src/com/android/settings/applications/AppInfoWithHeader.java b/src/com/android/settings/applications/AppInfoWithHeader.java
index 3df81c7..af0cf5b 100644
--- a/src/com/android/settings/applications/AppInfoWithHeader.java
+++ b/src/com/android/settings/applications/AppInfoWithHeader.java
@@ -16,6 +16,8 @@
package com.android.settings.applications;
+import static com.android.settings.widget.EntityHeaderController.ActionType;
+
import android.app.Activity;
import android.os.Bundle;
import android.support.v7.preference.Preference;
@@ -25,8 +27,6 @@
import com.android.settings.widget.EntityHeaderController;
import com.android.settingslib.applications.AppUtils;
-import static com.android.settings.widget.EntityHeaderController.ActionType;
-
public abstract class AppInfoWithHeader extends AppInfoBase {
private boolean mCreated;
@@ -44,7 +44,7 @@
final Preference pref = EntityHeaderController
.newInstance(activity, this, null /* header */)
.setRecyclerView(getListView(), getLifecycle())
- .setIcon(IconDrawableFactory.newInstance(activity)
+ .setIcon(IconDrawableFactory.newInstance(getContext())
.getBadgedIcon(mPackageInfo.applicationInfo))
.setLabel(mPackageInfo.applicationInfo.loadLabel(mPm))
.setSummary(mPackageInfo)
diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java
index 91d1cb3..6f94015 100755
--- a/src/com/android/settings/applications/InstalledAppDetails.java
+++ b/src/com/android/settings/applications/InstalledAppDetails.java
@@ -508,6 +508,7 @@
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ super.onCreateOptionsMenu(menu, inflater);
menu.add(0, UNINSTALL_UPDATES, 0, R.string.app_factory_reset)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
menu.add(0, UNINSTALL_ALL_USERS_MENU, 1, R.string.uninstall_all_users_text)
diff --git a/src/com/android/settings/applications/ProcStatsData.java b/src/com/android/settings/applications/ProcStatsData.java
index dd85dd2..c1ec070 100644
--- a/src/com/android/settings/applications/ProcStatsData.java
+++ b/src/com/android/settings/applications/ProcStatsData.java
@@ -372,6 +372,10 @@
double totalScale;
long memTotalTime;
+ public double getWeightToRam() {
+ return weightToRam;
+ }
+
private MemInfo(Context context, ProcessStats.TotalMemoryUseCollection totalMem,
long memTotalTime) {
this.memTotalTime = memTotalTime;
diff --git a/src/com/android/settings/applications/ProcStatsEntry.java b/src/com/android/settings/applications/ProcStatsEntry.java
index 90ef5d7..2388a04 100644
--- a/src/com/android/settings/applications/ProcStatsEntry.java
+++ b/src/com/android/settings/applications/ProcStatsEntry.java
@@ -297,6 +297,10 @@
}
}
+ public int getUid() {
+ return mUid;
+ }
+
public static final Parcelable.Creator<ProcStatsEntry> CREATOR
= new Parcelable.Creator<ProcStatsEntry>() {
public ProcStatsEntry createFromParcel(Parcel in) {
diff --git a/src/com/android/settings/applications/ProcStatsPackageEntry.java b/src/com/android/settings/applications/ProcStatsPackageEntry.java
index 39a0042..88d5bd6 100644
--- a/src/com/android/settings/applications/ProcStatsPackageEntry.java
+++ b/src/com/android/settings/applications/ProcStatsPackageEntry.java
@@ -175,4 +175,17 @@
Utils.formatPercentage((int) (amount * 100)));
}
}
+
+ public double getRunWeight() {
+ return mRunWeight;
+ }
+
+ public double getBgWeight() {
+ return mBgWeight;
+ }
+
+ public ArrayList<ProcStatsEntry> getEntries() {
+ return mEntries;
+ }
+
}
diff --git a/src/com/android/settings/applications/ProcessStatsSummary.java b/src/com/android/settings/applications/ProcessStatsSummary.java
index cdb8a4c..75f8ba6 100644
--- a/src/com/android/settings/applications/ProcessStatsSummary.java
+++ b/src/com/android/settings/applications/ProcessStatsSummary.java
@@ -103,7 +103,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_uri_process_stats_summary;
}
diff --git a/src/com/android/settings/applications/ProcessStatsUi.java b/src/com/android/settings/applications/ProcessStatsUi.java
index 9f76fb2..cb2a1eb 100644
--- a/src/com/android/settings/applications/ProcessStatsUi.java
+++ b/src/com/android/settings/applications/ProcessStatsUi.java
@@ -96,7 +96,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_uri_process_stats_apps;
}
diff --git a/src/com/android/settings/applications/appinfo/AppBatteryPreferenceController.java b/src/com/android/settings/applications/appinfo/AppBatteryPreferenceController.java
new file mode 100644
index 0000000..d341d53
--- /dev/null
+++ b/src/com/android/settings/applications/appinfo/AppBatteryPreferenceController.java
@@ -0,0 +1,186 @@
+/*
+ * 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.applications.appinfo;
+
+import android.app.LoaderManager;
+import android.app.slice.Slice;
+import android.content.Context;
+import android.content.Loader;
+import android.content.pm.PackageInfo;
+import android.os.BatteryStats;
+import android.os.Bundle;
+import android.os.UserManager;
+import android.support.annotation.VisibleForTesting;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+
+import com.android.internal.os.BatterySipper;
+import com.android.internal.os.BatteryStatsHelper;
+import com.android.settings.R;
+import com.android.settings.SettingsActivity;
+import com.android.settings.Utils;
+import com.android.settings.applications.AppInfoDashboardFragment;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.fuelgauge.AdvancedPowerUsageDetail;
+import com.android.settings.fuelgauge.BatteryEntry;
+import com.android.settings.fuelgauge.BatteryStatsHelperLoader;
+import com.android.settings.fuelgauge.BatteryUtils;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnPause;
+import com.android.settingslib.core.lifecycle.events.OnResume;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class AppBatteryPreferenceController extends BasePreferenceController
+ implements LoaderManager.LoaderCallbacks<BatteryStatsHelper>,
+ LifecycleObserver, OnResume, OnPause {
+
+ private static final String KEY_BATTERY = "battery";
+
+ @VisibleForTesting
+ BatterySipper mSipper;
+ @VisibleForTesting
+ BatteryStatsHelper mBatteryHelper;
+ @VisibleForTesting
+ BatteryUtils mBatteryUtils;
+
+ private Preference mPreference;
+ private final AppInfoDashboardFragment mParent;
+ private String mBatteryPercent;
+ private final String mPackageName;
+
+ public AppBatteryPreferenceController(Context context, AppInfoDashboardFragment parent,
+ String packageName, Lifecycle lifecycle) {
+ super(context, KEY_BATTERY);
+ mParent = parent;
+ mBatteryUtils = BatteryUtils.getInstance(mContext);
+ mPackageName = packageName;
+ if (lifecycle != null) {
+ lifecycle.addObserver(this);
+ }
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+
+ @Override
+ public Slice getSettingSlice() {
+ return null;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreference = screen.findPreference(getPreferenceKey());
+ mPreference.setEnabled(false);
+ }
+
+ @Override
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ if (!KEY_BATTERY.equals(preference.getKey())) {
+ return false;
+ }
+ if (isBatteryStatsAvailable()) {
+ final UserManager userManager =
+ (UserManager) mContext.getSystemService(Context.USER_SERVICE);
+ final BatteryEntry entry = new BatteryEntry(mContext, null, userManager, mSipper);
+ entry.defaultPackageName = mPackageName;
+ AdvancedPowerUsageDetail.startBatteryDetailPage(
+ (SettingsActivity) mParent.getActivity(), mParent, mBatteryHelper,
+ BatteryStats.STATS_SINCE_CHARGED, entry, mBatteryPercent,
+ null /* mAnomalies */);
+ } else {
+ AdvancedPowerUsageDetail.startBatteryDetailPage(
+ (SettingsActivity) mParent.getActivity(), mParent, mPackageName);
+ }
+ return true;
+ }
+
+ @Override
+ public void onResume() {
+ mParent.getLoaderManager().restartLoader(
+ mParent.LOADER_BATTERY, Bundle.EMPTY, this);
+ }
+
+ @Override
+ public void onPause() {
+ mParent.getLoaderManager().destroyLoader(mParent.LOADER_BATTERY);
+ }
+
+ @Override
+ public Loader<BatteryStatsHelper> onCreateLoader(int id, Bundle args) {
+ return new BatteryStatsHelperLoader(mContext);
+ }
+
+ @Override
+ public void onLoadFinished(Loader<BatteryStatsHelper> loader,
+ BatteryStatsHelper batteryHelper) {
+ mBatteryHelper = batteryHelper;
+ final PackageInfo packageInfo = mParent.getPackageInfo();
+ if (packageInfo != null) {
+ mSipper = findTargetSipper(batteryHelper, packageInfo.applicationInfo.uid);
+ if (mParent.getActivity() != null) {
+ updateBattery();
+ }
+ }
+ }
+
+ @Override
+ public void onLoaderReset(Loader<BatteryStatsHelper> loader) {
+ }
+
+ @VisibleForTesting
+ void updateBattery() {
+ mPreference.setEnabled(true);
+ if (isBatteryStatsAvailable()) {
+ final int dischargeAmount = mBatteryHelper.getStats().getDischargeAmount(
+ BatteryStats.STATS_SINCE_CHARGED);
+
+ final List<BatterySipper> usageList = new ArrayList<>(mBatteryHelper.getUsageList());
+ final double hiddenAmount = mBatteryUtils.removeHiddenBatterySippers(usageList);
+ final int percentOfMax = (int) mBatteryUtils.calculateBatteryPercent(
+ mSipper.totalPowerMah, mBatteryHelper.getTotalPower(), hiddenAmount,
+ dischargeAmount);
+ mBatteryPercent = Utils.formatPercentage(percentOfMax);
+ mPreference.setSummary(mContext.getString(R.string.battery_summary, mBatteryPercent));
+ } else {
+ mPreference.setSummary(mContext.getString(R.string.no_battery_summary));
+ }
+ }
+
+ @VisibleForTesting
+ boolean isBatteryStatsAvailable() {
+ return mBatteryHelper != null && mSipper != null;
+ }
+
+ @VisibleForTesting
+ BatterySipper findTargetSipper(BatteryStatsHelper batteryHelper, int uid) {
+ final List<BatterySipper> usageList = batteryHelper.getUsageList();
+ for (int i = 0, size = usageList.size(); i < size; i++) {
+ final BatterySipper sipper = usageList.get(i);
+ if (sipper.getUid() == uid) {
+ return sipper;
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/src/com/android/settings/applications/appinfo/AppDataUsagePreferenceController.java b/src/com/android/settings/applications/appinfo/AppDataUsagePreferenceController.java
new file mode 100644
index 0000000..61f3e46
--- /dev/null
+++ b/src/com/android/settings/applications/appinfo/AppDataUsagePreferenceController.java
@@ -0,0 +1,155 @@
+/*
+ * 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.applications.appinfo;
+
+import android.app.LoaderManager;
+import android.content.Context;
+import android.content.Loader;
+import android.net.INetworkStatsService;
+import android.net.INetworkStatsSession;
+import android.net.NetworkTemplate;
+import android.os.Bundle;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.support.annotation.VisibleForTesting;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+import android.text.format.DateUtils;
+import android.text.format.Formatter;
+
+import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.Utils;
+import com.android.settings.applications.AppInfoDashboardFragment;
+import com.android.settings.datausage.AppDataUsage;
+import com.android.settings.datausage.DataUsageList;
+import com.android.settings.datausage.DataUsageUtils;
+import com.android.settingslib.AppItem;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnPause;
+import com.android.settingslib.core.lifecycle.events.OnResume;
+import com.android.settingslib.net.ChartData;
+import com.android.settingslib.net.ChartDataLoader;
+
+public class AppDataUsagePreferenceController extends AppInfoPreferenceControllerBase
+ implements LoaderManager.LoaderCallbacks<ChartData>, LifecycleObserver, OnResume, OnPause {
+
+ private static final String KEY_DATA = "data_settings";
+ private ChartData mChartData;
+ private INetworkStatsSession mStatsSession;
+
+ public AppDataUsagePreferenceController(Context context, AppInfoDashboardFragment parent,
+ Lifecycle lifecycle) {
+ super(context, parent, KEY_DATA);
+ if (lifecycle != null) {
+ lifecycle.addObserver(this);
+ }
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return isBandwidthControlEnabled() ? AVAILABLE : DISABLED_UNSUPPORTED;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ if (isAvailable()) {
+ final INetworkStatsService statsService = INetworkStatsService.Stub.asInterface(
+ ServiceManager.getService(Context.NETWORK_STATS_SERVICE));
+ try {
+ mStatsSession = statsService.openSession();
+ } catch (RemoteException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ preference.setSummary(getDataSummary());
+ }
+
+ @Override
+ public void onResume() {
+ if (mStatsSession != null) {
+ final int uid = mParent.getAppEntry().info.uid;
+ final AppItem app = new AppItem(uid);
+ app.addUid(uid);
+ mParent.getLoaderManager().restartLoader(mParent.LOADER_CHART_DATA,
+ ChartDataLoader.buildArgs(getTemplate(mContext), app),
+ this);
+ }
+ }
+
+ @Override
+ public void onPause() {
+ mParent.getLoaderManager().destroyLoader(mParent.LOADER_CHART_DATA);
+ }
+
+ @Override
+ public Loader<ChartData> onCreateLoader(int id, Bundle args) {
+ return new ChartDataLoader(mContext, mStatsSession, args);
+ }
+
+ @Override
+ public void onLoadFinished(Loader<ChartData> loader, ChartData data) {
+ mChartData = data;
+ updateState(mPreference);
+ }
+
+ @Override
+ public void onLoaderReset(Loader<ChartData> loader) {
+ // Leave last result.
+ }
+
+ @Override
+ protected Class<? extends SettingsPreferenceFragment> getDetailFragmentClass() {
+ return AppDataUsage.class;
+ }
+
+ private CharSequence getDataSummary() {
+ if (mChartData != null) {
+ final long totalBytes = mChartData.detail.getTotalBytes();
+ if (totalBytes == 0) {
+ return mContext.getString(R.string.no_data_usage);
+ }
+ return mContext.getString(R.string.data_summary_format,
+ Formatter.formatFileSize(mContext, totalBytes),
+ DateUtils.formatDateTime(mContext, mChartData.detail.getStart(),
+ DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH));
+ }
+ return mContext.getString(R.string.computing_size);
+ }
+
+ private static NetworkTemplate getTemplate(Context context) {
+ if (DataUsageList.hasReadyMobileRadio(context)) {
+ return NetworkTemplate.buildTemplateMobileWildcard();
+ }
+ if (DataUsageUtils.hasWifiRadio(context)) {
+ return NetworkTemplate.buildTemplateWifiWildcard();
+ }
+ return NetworkTemplate.buildTemplateEthernet();
+ }
+
+ @VisibleForTesting
+ boolean isBandwidthControlEnabled() {
+ return Utils.isBandwidthControlEnabled();
+ }
+
+}
diff --git a/src/com/android/settings/applications/appinfo/AppInfoPreferenceControllerBase.java b/src/com/android/settings/applications/appinfo/AppInfoPreferenceControllerBase.java
new file mode 100644
index 0000000..0d6c038
--- /dev/null
+++ b/src/com/android/settings/applications/appinfo/AppInfoPreferenceControllerBase.java
@@ -0,0 +1,87 @@
+/*
+ * 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.applications.appinfo;
+
+import android.app.slice.Slice;
+import android.content.Context;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+import android.text.TextUtils;
+
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.applications.AppInfoDashboardFragment;
+import com.android.settings.core.BasePreferenceController;
+
+/*
+ * Abstract base controller for the app detail preferences that refresh the state when the app state
+ * changes and launch a specific detail fragment when the preference is clicked.
+ */
+public abstract class AppInfoPreferenceControllerBase extends BasePreferenceController
+ implements AppInfoDashboardFragment.Callback {
+
+ protected final AppInfoDashboardFragment mParent;
+ private final Class<? extends SettingsPreferenceFragment> mDetailFragmenClass;
+
+ protected Preference mPreference;
+
+ public AppInfoPreferenceControllerBase(Context context, AppInfoDashboardFragment parent,
+ String preferenceKey) {
+ super(context, preferenceKey);
+ mParent = parent;
+ mDetailFragmenClass = getDetailFragmentClass();
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+
+ @Override
+ public Slice getSettingSlice() {
+ return null;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreference = screen.findPreference(getPreferenceKey());
+ }
+
+ @Override
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ if (TextUtils.equals(preference.getKey(), mPreferenceKey) && mDetailFragmenClass != null) {
+ AppInfoDashboardFragment.startAppInfoFragment(
+ mDetailFragmenClass, -1, mParent, mParent.getAppEntry());
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void refreshUi() {
+ updateState(mPreference);
+ }
+
+ /**
+ * Gets the fragment class to be launched when the preference is clicked.
+ * @return the fragment to launch
+ */
+ protected Class<? extends SettingsPreferenceFragment> getDetailFragmentClass() {
+ return null;
+ }
+
+}
diff --git a/src/com/android/settings/applications/appinfo/AppMemoryPreferenceController.java b/src/com/android/settings/applications/appinfo/AppMemoryPreferenceController.java
new file mode 100644
index 0000000..2a20f80
--- /dev/null
+++ b/src/com/android/settings/applications/appinfo/AppMemoryPreferenceController.java
@@ -0,0 +1,141 @@
+/*
+ * 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.applications.appinfo;
+
+import android.app.Activity;
+import android.app.slice.Slice;
+import android.content.Context;
+import android.content.pm.PackageInfo;
+import android.os.AsyncTask;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+import android.text.format.Formatter;
+
+import com.android.settings.R;
+import com.android.settings.SettingsActivity;
+import com.android.settings.applications.AppInfoDashboardFragment;
+import com.android.settings.applications.ProcStatsData;
+import com.android.settings.applications.ProcStatsEntry;
+import com.android.settings.applications.ProcStatsPackageEntry;
+import com.android.settings.applications.ProcessStatsBase;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnResume;
+import com.android.settingslib.development.DevelopmentSettingsEnabler;
+
+public class AppMemoryPreferenceController extends BasePreferenceController
+ implements LifecycleObserver, OnResume {
+
+ private static final String KEY_MEMORY = "memory";
+
+ private Preference mPreference;
+ private final AppInfoDashboardFragment mParent;
+ private ProcStatsData mStatsManager;
+ private ProcStatsPackageEntry mStats;
+
+ private class MemoryUpdater extends AsyncTask<Void, Void, ProcStatsPackageEntry> {
+
+ @Override
+ protected ProcStatsPackageEntry doInBackground(Void... params) {
+ final Activity activity = mParent.getActivity();
+ if (activity == null) {
+ return null;
+ }
+ PackageInfo packageInfo = mParent.getPackageInfo();
+ if (packageInfo == null) {
+ return null;
+ }
+ if (mStatsManager == null) {
+ mStatsManager = new ProcStatsData(activity, false);
+ mStatsManager.setDuration(ProcessStatsBase.sDurations[0]);
+ }
+ mStatsManager.refreshStats(true);
+ for (ProcStatsPackageEntry pkgEntry : mStatsManager.getEntries()) {
+ for (ProcStatsEntry entry : pkgEntry.getEntries()) {
+ if (entry.getUid() == packageInfo.applicationInfo.uid) {
+ pkgEntry.updateMetrics();
+ return pkgEntry;
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(ProcStatsPackageEntry entry) {
+ if (mParent.getActivity() == null) {
+ return;
+ }
+ if (entry != null) {
+ mStats = entry;
+ mPreference.setEnabled(true);
+ double amount = Math.max(entry.getRunWeight(), entry.getBgWeight())
+ * mStatsManager.getMemInfo().getWeightToRam();
+ mPreference.setSummary(mContext.getString(R.string.memory_use_summary,
+ Formatter.formatShortFileSize(mContext, (long) amount)));
+ } else {
+ mPreference.setEnabled(false);
+ mPreference.setSummary(mContext.getString(R.string.no_memory_use_summary));
+ }
+ }
+ }
+
+ public AppMemoryPreferenceController(Context context, AppInfoDashboardFragment parent,
+ Lifecycle lifecycle) {
+ super(context, KEY_MEMORY);
+ mParent = parent;
+ if (lifecycle != null) {
+ lifecycle.addObserver(this);
+ }
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(mContext)
+ ? AVAILABLE : DISABLED_DEPENDENT_SETTING;
+ }
+
+ @Override
+ public Slice getSettingSlice() {
+ return null;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreference = screen.findPreference(getPreferenceKey());
+ }
+
+ @Override
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ if (KEY_MEMORY.equals(preference.getKey())) {
+ ProcessStatsBase.launchMemoryDetail((SettingsActivity) mParent.getActivity(),
+ mStatsManager.getMemInfo(), mStats, false);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void onResume() {
+ if (isAvailable()) {
+ new MemoryUpdater().execute();
+ }
+ }
+
+}
diff --git a/src/com/android/settings/applications/appinfo/AppNotificationPreferenceController.java b/src/com/android/settings/applications/appinfo/AppNotificationPreferenceController.java
new file mode 100644
index 0000000..7eef370
--- /dev/null
+++ b/src/com/android/settings/applications/appinfo/AppNotificationPreferenceController.java
@@ -0,0 +1,61 @@
+/*
+ * 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.applications.appinfo;
+
+import android.content.Context;
+import android.support.v7.preference.Preference;
+
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.applications.AppInfoDashboardFragment;
+import com.android.settings.notification.AppNotificationSettings;
+import com.android.settings.notification.NotificationBackend;
+import com.android.settingslib.applications.ApplicationsState;
+
+public class AppNotificationPreferenceController extends AppInfoPreferenceControllerBase {
+
+ private static final String KEY_NOTIFICATION = "notification_settings";
+
+ // Used for updating notification preference.
+ private final NotificationBackend mBackend = new NotificationBackend();
+
+ public AppNotificationPreferenceController(Context context, AppInfoDashboardFragment parent) {
+ super(context, parent, KEY_NOTIFICATION);
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ preference.setSummary(getNotificationSummary(mParent.getAppEntry(), mContext, mBackend));
+ }
+
+ @Override
+ protected Class<? extends SettingsPreferenceFragment> getDetailFragmentClass() {
+ return AppNotificationSettings.class;
+ }
+
+ private CharSequence getNotificationSummary(ApplicationsState.AppEntry appEntry,
+ Context context, NotificationBackend backend) {
+ NotificationBackend.AppRow appRow =
+ backend.loadAppRow(context, context.getPackageManager(), appEntry.info);
+ return getNotificationSummary(appRow, context);
+ }
+
+ public static CharSequence getNotificationSummary(NotificationBackend.AppRow appRow,
+ Context context) {
+ // TODO: implement summary when it is known what it should say
+ return "";
+ }
+}
diff --git a/src/com/android/settings/applications/appinfo/AppOpenByDefaultPreferenceController.java b/src/com/android/settings/applications/appinfo/AppOpenByDefaultPreferenceController.java
new file mode 100644
index 0000000..a56e3fb
--- /dev/null
+++ b/src/com/android/settings/applications/appinfo/AppOpenByDefaultPreferenceController.java
@@ -0,0 +1,76 @@
+/*
+ * 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.applications.appinfo;
+
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.hardware.usb.IUsbManager;
+import android.os.ServiceManager;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.applications.AppInfoDashboardFragment;
+import com.android.settings.applications.AppLaunchSettings;
+import com.android.settingslib.applications.AppUtils;
+import com.android.settingslib.applications.ApplicationsState;
+
+public class AppOpenByDefaultPreferenceController extends AppInfoPreferenceControllerBase {
+
+ private static final String KEY_LAUNCH = "preferred_settings";
+
+ private IUsbManager mUsbManager;
+ private PackageManager mPackageManager;
+
+ public AppOpenByDefaultPreferenceController(Context context, AppInfoDashboardFragment parent) {
+ super(context, parent, KEY_LAUNCH);
+ mUsbManager = IUsbManager.Stub.asInterface(ServiceManager.getService(Context.USB_SERVICE));
+ mPackageManager = context.getPackageManager();
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ final ApplicationsState.AppEntry appEntry = mParent.getAppEntry();
+ if (appEntry == null || appEntry.info == null) {
+ mPreference.setEnabled(false);
+ } else if ((appEntry.info.flags& ApplicationInfo.FLAG_INSTALLED) == 0
+ || !appEntry.info.enabled) {
+ mPreference.setEnabled(false);
+ }
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ final PackageInfo packageInfo = mParent.getPackageInfo();
+ if (packageInfo != null && !AppUtils.isInstant(packageInfo.applicationInfo)) {
+ preference.setVisible(true);
+ preference.setSummary(AppUtils.getLaunchByDefaultSummary(mParent.getAppEntry(),
+ mUsbManager, mPackageManager, mContext));
+ } else {
+ preference.setVisible(false);
+ }
+ }
+
+ @Override
+ protected Class<? extends SettingsPreferenceFragment> getDetailFragmentClass() {
+ return AppLaunchSettings.class;
+ }
+
+}
diff --git a/src/com/android/settings/applications/appinfo/AppPermissionPreferenceController.java b/src/com/android/settings/applications/appinfo/AppPermissionPreferenceController.java
new file mode 100644
index 0000000..bd309c6
--- /dev/null
+++ b/src/com/android/settings/applications/appinfo/AppPermissionPreferenceController.java
@@ -0,0 +1,114 @@
+/*
+ * 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.applications.appinfo;
+
+import android.content.ActivityNotFoundException;
+import android.content.Context;
+import android.content.Intent;
+import android.content.res.Resources;
+import android.icu.text.ListFormatter;
+import android.support.annotation.VisibleForTesting;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+import android.util.Log;
+
+import com.android.settings.R;
+import com.android.settings.applications.AppInfoDashboardFragment;
+import com.android.settingslib.applications.PermissionsSummaryHelper;
+import com.android.settingslib.core.AbstractPreferenceController;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class AppPermissionPreferenceController extends AppInfoPreferenceControllerBase {
+
+ private static final String TAG = "PermissionPrefControl";
+ private static final String KEY_PERMISSION = "permission_settings";
+ private static final String EXTRA_HIDE_INFO_BUTTON = "hideInfoButton";
+
+ private final String mPackageName;
+
+ @VisibleForTesting
+ final PermissionsSummaryHelper.PermissionsResultCallback mPermissionCallback
+ = new PermissionsSummaryHelper.PermissionsResultCallback() {
+ @Override
+ public void onPermissionSummaryResult(int standardGrantedPermissionCount,
+ int requestedPermissionCount, int additionalGrantedPermissionCount,
+ List<CharSequence> grantedGroupLabels) {
+ if (mParent.getActivity() == null) {
+ return;
+ }
+ final Resources res = mContext.getResources();
+ CharSequence summary = null;
+
+ if (requestedPermissionCount == 0) {
+ summary = res.getString(
+ R.string.runtime_permissions_summary_no_permissions_requested);
+ mPreference.setEnabled(false);
+ } else {
+ final ArrayList<CharSequence> list = new ArrayList<>(grantedGroupLabels);
+ if (additionalGrantedPermissionCount > 0) {
+ // N additional permissions.
+ list.add(res.getQuantityString(
+ R.plurals.runtime_permissions_additional_count,
+ additionalGrantedPermissionCount, additionalGrantedPermissionCount));
+ }
+ if (list.size() == 0) {
+ summary = res.getString(
+ R.string.runtime_permissions_summary_no_permissions_granted);
+ } else {
+ summary = ListFormatter.getInstance().format(list);
+ }
+ mPreference.setEnabled(true);
+ }
+ mPreference.setSummary(summary);
+ }
+ };
+
+ public AppPermissionPreferenceController(Context context, AppInfoDashboardFragment parent,
+ String packageName) {
+ super(context, parent, KEY_PERMISSION);
+ mPackageName = packageName;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ PermissionsSummaryHelper.getPermissionSummary(mContext, mPackageName, mPermissionCallback);
+ }
+
+ @Override
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ if (KEY_PERMISSION.equals(preference.getKey())) {
+ startManagePermissionsActivity();
+ return true;
+ }
+ return false;
+ }
+
+ private void startManagePermissionsActivity() {
+ // start new activity to manage app permissions
+ final Intent intent = new Intent(Intent.ACTION_MANAGE_APP_PERMISSIONS);
+ intent.putExtra(Intent.EXTRA_PACKAGE_NAME, mParent.getAppEntry().info.packageName);
+ intent.putExtra(EXTRA_HIDE_INFO_BUTTON, true);
+ try {
+ mParent.getActivity().startActivityForResult(intent, mParent.SUB_INFO_FRAGMENT);
+ } catch (ActivityNotFoundException e) {
+ Log.w(TAG, "No app can handle android.intent.action.MANAGE_APP_PERMISSIONS");
+ }
+ }
+
+}
diff --git a/src/com/android/settings/applications/appinfo/AppStoragePreferenceController.java b/src/com/android/settings/applications/appinfo/AppStoragePreferenceController.java
new file mode 100644
index 0000000..d737288
--- /dev/null
+++ b/src/com/android/settings/applications/appinfo/AppStoragePreferenceController.java
@@ -0,0 +1,108 @@
+/*
+ * 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.applications.appinfo;
+
+import android.app.LoaderManager;
+import android.content.Context;
+import android.content.Loader;
+import android.content.pm.ApplicationInfo;
+import android.os.Bundle;
+import android.os.UserHandle;
+import android.support.annotation.VisibleForTesting;
+import android.support.v7.preference.Preference;
+import android.text.format.Formatter;
+
+import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.applications.AppInfoDashboardFragment;
+import com.android.settings.applications.AppStorageSettings;
+import com.android.settings.applications.FetchPackageStorageAsyncLoader;
+import com.android.settingslib.applications.StorageStatsSource;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnPause;
+import com.android.settingslib.core.lifecycle.events.OnResume;
+
+public class AppStoragePreferenceController extends AppInfoPreferenceControllerBase
+ implements LoaderManager.LoaderCallbacks<StorageStatsSource.AppStorageStats>,
+ LifecycleObserver, OnResume, OnPause {
+
+ private static final String KEY_STORAGE = "storage_settings";
+ private StorageStatsSource.AppStorageStats mLastResult;
+
+ public AppStoragePreferenceController(Context context, AppInfoDashboardFragment parent,
+ Lifecycle lifecycle) {
+ super(context, parent, KEY_STORAGE);
+ if (lifecycle != null) {
+ lifecycle.addObserver(this);
+ }
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ final boolean isExternal =
+ (mParent.getAppEntry().info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0;
+ preference.setSummary(getStorageSummary(mLastResult, isExternal));
+ }
+
+ @Override
+ public void onResume() {
+ mParent.getLoaderManager().restartLoader(mParent.LOADER_STORAGE, Bundle.EMPTY, this);
+ }
+
+ @Override
+ public void onPause() {
+ mParent.getLoaderManager().destroyLoader(mParent.LOADER_STORAGE);
+ }
+
+ @Override
+ protected Class<? extends SettingsPreferenceFragment> getDetailFragmentClass() {
+ return AppStorageSettings.class;
+ }
+
+ @VisibleForTesting
+ CharSequence getStorageSummary(
+ StorageStatsSource.AppStorageStats stats, boolean isExternal) {
+ if (stats == null) {
+ return mContext.getText(R.string.computing_size);
+ }
+ final CharSequence storageType = mContext.getString(isExternal
+ ? R.string.storage_type_external
+ : R.string.storage_type_internal);
+ return mContext.getString(R.string.storage_summary_format,
+ Formatter.formatFileSize(mContext, stats.getTotalBytes()),
+ storageType.toString().toLowerCase());
+ }
+
+ @Override
+ public Loader<StorageStatsSource.AppStorageStats> onCreateLoader(int id, Bundle args) {
+ return new FetchPackageStorageAsyncLoader(mContext, new StorageStatsSource(mContext),
+ mParent.getAppEntry().info, UserHandle.of(UserHandle.myUserId()));
+ }
+
+ @Override
+ public void onLoadFinished(Loader<StorageStatsSource.AppStorageStats> loader,
+ StorageStatsSource.AppStorageStats result) {
+ mLastResult = result;
+ updateState(mPreference);
+ }
+
+ @Override
+ public void onLoaderReset(Loader<StorageStatsSource.AppStorageStats> loader) {
+ }
+
+}
diff --git a/src/com/android/settings/applications/appinfo/AppVersionPreferenceController.java b/src/com/android/settings/applications/appinfo/AppVersionPreferenceController.java
new file mode 100644
index 0000000..82719f7
--- /dev/null
+++ b/src/com/android/settings/applications/appinfo/AppVersionPreferenceController.java
@@ -0,0 +1,40 @@
+/*
+ * 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.applications.appinfo;
+
+import android.content.Context;
+import android.support.v7.preference.Preference;
+import android.text.BidiFormatter;
+
+import com.android.settings.R;
+import com.android.settings.applications.AppInfoDashboardFragment;
+
+public class AppVersionPreferenceController extends AppInfoPreferenceControllerBase {
+
+ private static final String KEY_VERSION = "app_version";
+
+ public AppVersionPreferenceController(Context context, AppInfoDashboardFragment parent) {
+ super(context, parent, KEY_VERSION);
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ preference.setSummary(mContext.getString(R.string.version_text,
+ BidiFormatter.getInstance().unicodeWrap(mParent.getPackageInfo().versionName)));
+ }
+
+}
diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
index e053bc9..127730b 100644
--- a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
@@ -149,9 +149,22 @@
}
/**
+ * Return {@code true} if {@code cachedBluetoothDevice} matches this
+ * {@link BluetoothDeviceUpdater} and should stay in the list, otherwise return {@code false}
+ */
+ public abstract boolean isFilterMatched(CachedBluetoothDevice cachedBluetoothDevice);
+
+ /**
* Update whether to show {@cde cachedBluetoothDevice} in the list.
*/
- abstract public void update(CachedBluetoothDevice cachedBluetoothDevice);
+ protected void update(CachedBluetoothDevice cachedBluetoothDevice) {
+ if (isFilterMatched(cachedBluetoothDevice)) {
+ // Add the preference if it is new one
+ addPreference(cachedBluetoothDevice);
+ } else {
+ removePreference(cachedBluetoothDevice);
+ }
+ }
/**
* Add the {@link Preference} that represents the {@code cachedDevice}
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingController.java b/src/com/android/settings/bluetooth/BluetoothPairingController.java
index ce82612..7d2d7b4 100644
--- a/src/com/android/settings/bluetooth/BluetoothPairingController.java
+++ b/src/com/android/settings/bluetooth/BluetoothPairingController.java
@@ -172,6 +172,22 @@
}
/**
+ * Update Phone book permission
+ *
+ */
+ public void setContactSharingState() {
+ if ((mDevice.getPhonebookAccessPermission() != BluetoothDevice.ACCESS_ALLOWED)
+ && (mDevice.getPhonebookAccessPermission() != BluetoothDevice.ACCESS_REJECTED)) {
+ if (mDevice.getBluetoothClass().getDeviceClass()
+ == BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE) {
+ onCheckedChanged(null, true);
+ } else {
+ onCheckedChanged(null, false);
+ }
+ }
+ }
+
+ /**
* A method for querying if the provided editable is a valid passkey/pin format for this device.
*
* @param s - The passkey/pin
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingDetail.java b/src/com/android/settings/bluetooth/BluetoothPairingDetail.java
index 60011f9..fcfa3e2 100644
--- a/src/com/android/settings/bluetooth/BluetoothPairingDetail.java
+++ b/src/com/android/settings/bluetooth/BluetoothPairingDetail.java
@@ -169,7 +169,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_bluetooth;
}
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java b/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java
index 1aac0ff..18839dc 100644
--- a/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java
+++ b/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java
@@ -241,6 +241,7 @@
contactSharing.setVisibility(mPairingController.isProfileReady()
? View.GONE : View.VISIBLE);
+ mPairingController.setContactSharingState();
contactSharing.setOnCheckedChangeListener(mPairingController);
contactSharing.setChecked(mPairingController.getContactSharingState());
@@ -331,6 +332,7 @@
contactSharing.setVisibility(
mPairingController.isProfileReady() ? View.GONE : View.VISIBLE);
+ mPairingController.setContactSharingState();
contactSharing.setChecked(mPairingController.getContactSharingState());
contactSharing.setOnCheckedChangeListener(mPairingController);
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index 9789310..72d8023 100644
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -345,7 +345,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_bluetooth;
}
diff --git a/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdater.java
index 239e405..deab29f 100644
--- a/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdater.java
@@ -51,16 +51,8 @@
}
@Override
- public void update(CachedBluetoothDevice cachedDevice) {
+ public boolean isFilterMatched(CachedBluetoothDevice cachedDevice) {
final BluetoothDevice device = cachedDevice.getDevice();
- final boolean filterMatch =
- device.getBondState() == BluetoothDevice.BOND_BONDED && device.isConnected();
-
- if (filterMatch) {
- // Add the preference if it is new one
- addPreference(cachedDevice);
- } else {
- removePreference(cachedDevice);
- }
+ return device.getBondState() == BluetoothDevice.BOND_BONDED && device.isConnected();
}
}
diff --git a/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
new file mode 100644
index 0000000..da7679a
--- /dev/null
+++ b/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
@@ -0,0 +1,58 @@
+/*
+ * 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.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothDevice;
+import android.support.annotation.VisibleForTesting;
+
+import com.android.settings.connecteddevice.DevicePreferenceCallback;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settingslib.bluetooth.CachedBluetoothDevice;
+import com.android.settingslib.bluetooth.LocalBluetoothManager;
+
+/**
+ * Maintain and update saved bluetooth devices(bonded but not connected)
+ */
+public class SavedBluetoothDeviceUpdater extends BluetoothDeviceUpdater {
+
+ public SavedBluetoothDeviceUpdater(DashboardFragment fragment,
+ DevicePreferenceCallback devicePreferenceCallback) {
+ super(fragment, devicePreferenceCallback);
+ }
+
+ @VisibleForTesting
+ SavedBluetoothDeviceUpdater(DashboardFragment fragment,
+ DevicePreferenceCallback devicePreferenceCallback,
+ LocalBluetoothManager localBluetoothManager) {
+ super(fragment, devicePreferenceCallback, localBluetoothManager);
+ }
+
+ @Override
+ public void onConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state) {
+ if (state == BluetoothAdapter.STATE_CONNECTED) {
+ removePreference(cachedDevice);
+ } else if (state == BluetoothAdapter.STATE_DISCONNECTED) {
+ addPreference(cachedDevice);
+ }
+ }
+
+ @Override
+ public boolean isFilterMatched(CachedBluetoothDevice cachedDevice) {
+ final BluetoothDevice device = cachedDevice.getDevice();
+ return device.getBondState() == BluetoothDevice.BOND_BONDED && !device.isConnected();
+ }
+}
diff --git a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
index 14acd89..e4a6a64 100644
--- a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
+++ b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
@@ -48,7 +48,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_connected_devices;
}
@@ -62,9 +62,8 @@
final List<AbstractPreferenceController> controllers = new ArrayList<>();
final Lifecycle lifecycle = getLifecycle();
- final ConnectedDeviceGroupController connectedDeviceGroupController =
- new ConnectedDeviceGroupController(this, lifecycle);
- controllers.add(connectedDeviceGroupController);
+ controllers.add(new ConnectedDeviceGroupController(this, lifecycle));
+ controllers.add(new SavedDeviceGroupController(this, lifecycle));
return controllers;
}
diff --git a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentOld.java b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentOld.java
index 6a8f26d..7097b36 100644
--- a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentOld.java
+++ b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentOld.java
@@ -62,7 +62,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_connected_devices;
}
diff --git a/src/com/android/settings/connecteddevice/SavedDeviceGroupController.java b/src/com/android/settings/connecteddevice/SavedDeviceGroupController.java
new file mode 100644
index 0000000..7445047
--- /dev/null
+++ b/src/com/android/settings/connecteddevice/SavedDeviceGroupController.java
@@ -0,0 +1,109 @@
+/*
+ * 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.connecteddevice;
+
+import android.support.annotation.VisibleForTesting;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceGroup;
+import android.support.v7.preference.PreferenceScreen;
+
+import com.android.settings.bluetooth.BluetoothDeviceUpdater;
+import com.android.settings.bluetooth.SavedBluetoothDeviceUpdater;
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnStart;
+import com.android.settingslib.core.lifecycle.events.OnStop;
+
+/**
+ * Controller to maintain the {@link PreferenceGroup} for all
+ * saved devices. It uses {@link DevicePreferenceCallback} to add/remove {@link Preference}
+ */
+public class SavedDeviceGroupController extends AbstractPreferenceController
+ implements PreferenceControllerMixin, LifecycleObserver, OnStart, OnStop,
+ DevicePreferenceCallback {
+
+ private static final String KEY = "saved_device_list";
+
+ @VisibleForTesting
+ PreferenceGroup mPreferenceGroup;
+ private BluetoothDeviceUpdater mBluetoothDeviceUpdater;
+
+ public SavedDeviceGroupController(DashboardFragment fragment, Lifecycle lifecycle) {
+ super(fragment.getContext());
+ init(lifecycle, new SavedBluetoothDeviceUpdater(fragment, SavedDeviceGroupController.this));
+ }
+
+ @VisibleForTesting
+ SavedDeviceGroupController(DashboardFragment fragment, Lifecycle lifecycle,
+ BluetoothDeviceUpdater bluetoothDeviceUpdater) {
+ super(fragment.getContext());
+ init(lifecycle, bluetoothDeviceUpdater);
+ }
+
+ @Override
+ public void onStart() {
+ mBluetoothDeviceUpdater.registerCallback();
+ }
+
+ @Override
+ public void onStop() {
+ mBluetoothDeviceUpdater.unregisterCallback();
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ mPreferenceGroup = (PreferenceGroup) screen.findPreference(KEY);
+ mPreferenceGroup.setVisible(false);
+ mBluetoothDeviceUpdater.setPrefContext(screen.getContext());
+ mBluetoothDeviceUpdater.forceUpdate();
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return true;
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY;
+ }
+
+ @Override
+ public void onDeviceAdded(Preference preference) {
+ if (mPreferenceGroup.getPreferenceCount() == 0) {
+ mPreferenceGroup.setVisible(true);
+ }
+ mPreferenceGroup.addPreference(preference);
+ }
+
+ @Override
+ public void onDeviceRemoved(Preference preference) {
+ mPreferenceGroup.removePreference(preference);
+ if (mPreferenceGroup.getPreferenceCount() == 0) {
+ mPreferenceGroup.setVisible(false);
+ }
+ }
+
+ private void init(Lifecycle lifecycle, BluetoothDeviceUpdater bluetoothDeviceUpdater) {
+ if (lifecycle != null) {
+ lifecycle.addObserver(this);
+ }
+ mBluetoothDeviceUpdater = bluetoothDeviceUpdater;
+ }
+}
diff --git a/src/com/android/settings/core/BasePreferenceController.java b/src/com/android/settings/core/BasePreferenceController.java
new file mode 100644
index 0000000..b3d9878
--- /dev/null
+++ b/src/com/android/settings/core/BasePreferenceController.java
@@ -0,0 +1,159 @@
+/*
+ * 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.core;
+
+import android.annotation.IntDef;
+import android.app.slice.Slice;
+import android.content.Context;
+import android.support.v7.preference.Preference;
+import android.text.TextUtils;
+import android.util.Log;
+
+
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.search.ResultPayload;
+import com.android.settings.search.SearchIndexableRaw;
+import com.android.settingslib.core.AbstractPreferenceController;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.util.List;
+
+/**
+ * Abstract class to consolidate utility between preference controllers and act as an interface
+ * for Slices. The abstract classes that inherit from this class will act as the direct interfaces
+ * for each type when plugging into Slices.
+ */
+public abstract class BasePreferenceController extends AbstractPreferenceController {
+
+ private static final String TAG = "SettingsPrefController";
+
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef({AVAILABLE, DISABLED_UNSUPPORTED, DISABLED_FOR_USER, DISABLED_DEPENDENT_SETTING,
+ UNAVAILABLE_UNKNOWN})
+ public @interface AvailabilityStatus {
+ }
+
+ /**
+ * The setting is available.
+ */
+ public static final int AVAILABLE = 0;
+
+ /**
+ * The setting is not supported by the device.
+ */
+ public static final int DISABLED_UNSUPPORTED = 1;
+
+ /**
+ * The setting cannot be changed by the current user.
+ */
+ public static final int DISABLED_FOR_USER = 2;
+
+ /**
+ * The setting has a dependency in the Settings App which is currently blocking access.
+ */
+ public static final int DISABLED_DEPENDENT_SETTING = 3;
+
+ /**
+ * A catch-all case for internal errors and inexplicable unavailability.
+ */
+ public static final int UNAVAILABLE_UNKNOWN = 4;
+
+ protected final String mPreferenceKey;
+
+ public BasePreferenceController(Context context, String preferenceKey) {
+ super(context);
+ mPreferenceKey = preferenceKey;
+ }
+
+ /**
+ * @return {@AvailabilityStatus} for the Setting. This status is used to determine if the
+ * Setting should be shown or disabled in Settings. Further, it can be used to produce
+ * appropriate error / warning Slice in the case of unavailability.
+ * </p>
+ * The status is used for the convenience methods: {@link #isAvailable()},
+ * {@link #isSupported()}
+ */
+ @AvailabilityStatus
+ public abstract int getAvailabilityStatus();
+
+ /**
+ * @return A slice for the corresponding setting.
+ */
+ public abstract Slice getSettingSlice();
+
+ @Override
+ public String getPreferenceKey() {
+ return mPreferenceKey;
+ }
+
+ @Override
+ public final boolean isAvailable() {
+ return getAvailabilityStatus() == AVAILABLE;
+ }
+
+ /**
+ * @return {@code false} if the setting is not applicable to the device. This covers both
+ * settings which were only introduced in future versions of android, or settings that have
+ * hardware dependencies.
+ * </p>
+ * Note that a return value of {@code true} does not mean that the setting is available.
+ */
+ public final boolean isSupported() {
+ return getAvailabilityStatus() != DISABLED_UNSUPPORTED;
+ }
+
+ /**
+ * Updates non-indexable keys for search provider.
+ *
+ * Called by SearchIndexProvider#getNonIndexableKeys
+ */
+ public void updateNonIndexableKeys(List<String> keys) {
+ if (this instanceof AbstractPreferenceController) {
+ if (!isAvailable()) {
+ final String key = getPreferenceKey();
+ if (TextUtils.isEmpty(key)) {
+ Log.w(TAG,
+ "Skipping updateNonIndexableKeys due to empty key " + this.toString());
+ return;
+ }
+ keys.add(key);
+ }
+ }
+ }
+
+ /**
+ * Updates raw data for search provider.
+ *
+ * Called by SearchIndexProvider#getRawDataToIndex
+ */
+ public void updateRawDataToIndex(List<SearchIndexableRaw> rawData) {
+ }
+
+ /**
+ * @return the {@link ResultPayload} corresponding to the search result type for the preference.
+ * TODO (b/69808376) Remove this method.
+ * Do not extend this method. It will not launch with P.
+ */
+ @Deprecated
+ public ResultPayload getResultPayload() {
+ return null;
+ }
+
+ // TODO (b/69380366) Add Method to get preference UI
+
+ // TODO (b/69380464) Add method to get intent
+
+ // TODO (b/69380560) Add method to get broadcast intent
+}
\ No newline at end of file
diff --git a/src/com/android/settings/core/PreferenceControllerMixin.java b/src/com/android/settings/core/PreferenceControllerMixin.java
index 1c54af7..23facba 100644
--- a/src/com/android/settings/core/PreferenceControllerMixin.java
+++ b/src/com/android/settings/core/PreferenceControllerMixin.java
@@ -26,6 +26,7 @@
/**
* A controller mixin that adds mobile settings specific functionality
+ * TODO (b/69808530) Replace with BasePreferenceController.
*/
public interface PreferenceControllerMixin {
@@ -60,7 +61,11 @@
/**
* @return the {@link ResultPayload} corresponding to the search result type for the preference.
+ *
+ * Do not rely on this method for intent-based or inline results. It will be removed in the
+ * unbundling effort.
*/
+ @Deprecated
default ResultPayload getResultPayload() {
return null;
}
diff --git a/src/com/android/settings/core/TogglePreferenceController.java b/src/com/android/settings/core/TogglePreferenceController.java
new file mode 100644
index 0000000..03106d3
--- /dev/null
+++ b/src/com/android/settings/core/TogglePreferenceController.java
@@ -0,0 +1,64 @@
+/*
+ * 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.core;
+
+import android.app.slice.Slice;
+import android.content.Context;
+import android.support.v14.preference.SwitchPreference;
+import android.support.v7.preference.Preference;
+
+/**
+ * Abstract class that consolidates logic for updating toggle controllers.
+ * It automatically handles the getting and setting of the switch UI element.
+ * Children of this class implement methods to get and set the underlying value of the setting.
+ */
+public abstract class TogglePreferenceController extends BasePreferenceController implements
+ Preference.OnPreferenceChangeListener {
+
+ private static final String TAG = "TogglePrefController";
+
+ public TogglePreferenceController(Context context, String preferenceKey) {
+ super(context, preferenceKey);
+ }
+
+ /**
+ * @return {@code true} if the Setting is enabled.
+ */
+ public abstract boolean isChecked();
+
+ /**
+ * Set the Setting to {@param isChecked}
+ *
+ * @param isChecked Is {@true} when the setting should be enabled.
+ */
+ public abstract void setChecked(boolean isChecked);
+
+ @Override
+ public final void updateState(Preference preference) {
+ ((SwitchPreference) preference).setChecked(isChecked());
+ }
+
+ @Override
+ public final boolean onPreferenceChange(Preference preference, Object newValue) {
+ boolean auto = (Boolean) newValue;
+ setChecked(auto);
+ return true;
+ }
+
+ @Override
+ public Slice getSettingSlice() {
+ // TODO
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/src/com/android/settings/dashboard/DashboardAdapter.java b/src/com/android/settings/dashboard/DashboardAdapter.java
index fd2adac..54a1eeb 100644
--- a/src/com/android/settings/dashboard/DashboardAdapter.java
+++ b/src/com/android/settings/dashboard/DashboardAdapter.java
@@ -477,7 +477,7 @@
final int tintColor = a.getColor(0, mContext.getColor(R.color.fallback_tintColor));
a.recycle();
if (category != null) {
- for (Tile tile : category.tiles) {
+ for (Tile tile : category.getTiles()) {
if (tile.isIconTintable) {
// If this drawable is tintable, tint it to match the color.
tile.icon.setTint(tintColor);
diff --git a/src/com/android/settings/dashboard/DashboardData.java b/src/com/android/settings/dashboard/DashboardData.java
index a14b8c2..6407960 100644
--- a/src/com/android/settings/dashboard/DashboardData.java
+++ b/src/com/android/settings/dashboard/DashboardData.java
@@ -268,8 +268,9 @@
&& hiddenSuggestion == 0);
if (mCategory != null) {
- for (int j = 0; j < mCategory.tiles.size(); j++) {
- final Tile tile = mCategory.tiles.get(j);
+ final List<Tile> tiles = mCategory.getTiles();
+ for (int j = 0; j < tiles.size(); j++) {
+ final Tile tile = tiles.get(j);
addToItemList(tile, R.layout.dashboard_tile, Objects.hash(tile.title),
true /* add */);
}
diff --git a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
index bee822a..9ef38b8 100644
--- a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
+++ b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
@@ -91,7 +91,7 @@
Log.d(TAG, "NO dashboard tiles for " + TAG);
return null;
}
- final List<Tile> tiles = category.tiles;
+ final List<Tile> tiles = category.getTiles();
if (tiles == null || tiles.isEmpty()) {
Log.d(TAG, "tile list is empty, skipping category " + category.title);
return null;
diff --git a/src/com/android/settings/dashboard/DashboardFragment.java b/src/com/android/settings/dashboard/DashboardFragment.java
index 3551d23..3e1e881 100644
--- a/src/com/android/settings/dashboard/DashboardFragment.java
+++ b/src/com/android/settings/dashboard/DashboardFragment.java
@@ -307,7 +307,7 @@
Log.d(TAG, "NO dashboard tiles for " + TAG);
return;
}
- List<Tile> tiles = category.tiles;
+ final List<Tile> tiles = category.getTiles();
if (tiles == null) {
Log.d(TAG, "tile list is empty, skipping category " + category.title);
return;
diff --git a/src/com/android/settings/dashboard/SiteMapManager.java b/src/com/android/settings/dashboard/SiteMapManager.java
index facd9ed..b54e061 100644
--- a/src/com/android/settings/dashboard/SiteMapManager.java
+++ b/src/com/android/settings/dashboard/SiteMapManager.java
@@ -16,23 +16,26 @@
package com.android.settings.dashboard;
+import static android.provider.SearchIndexablesContract.SITE_MAP_COLUMNS;
import static com.android.settings.dashboard.DashboardFragmentRegistry.CATEGORY_KEY_TO_PARENT_MAP;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
+import android.provider.SearchIndexablesContract.SiteMapColumns;
import android.support.annotation.VisibleForTesting;
import android.support.annotation.WorkerThread;
import android.support.v4.util.ArrayMap;
import android.text.TextUtils;
import android.util.Log;
+
import com.android.settings.SettingsActivity;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.IndexDatabaseHelper;
import com.android.settings.search.IndexDatabaseHelper.IndexColumns;
-import com.android.settings.search.IndexDatabaseHelper.SiteMapColumns;
import com.android.settingslib.drawer.DashboardCategory;
import com.android.settingslib.drawer.Tile;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -47,14 +50,6 @@
private static final String TAG = "SiteMapManager";
private static final boolean DEBUG_TIMING = false;
- @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
- public static final String[] SITE_MAP_COLUMNS = {
- SiteMapColumns.PARENT_CLASS,
- SiteMapColumns.PARENT_TITLE,
- SiteMapColumns.CHILD_CLASS,
- SiteMapColumns.CHILD_TITLE
- };
-
private static final String[] CLASS_TO_SCREEN_TITLE_COLUMNS = {
IndexColumns.CLASS_NAME,
IndexColumns.SCREEN_TITLE,
@@ -108,7 +103,7 @@
* 2. IA: We know from {@link DashboardFeatureProvider} which page can be dynamically
* injected to where.
*/
- @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
+ @VisibleForTesting
@WorkerThread
synchronized void init(Context context) {
if (mInitialized) {
@@ -159,7 +154,7 @@
continue;
}
// Build parent-child mPairs for all children listed under this key.
- for (Tile tile : category.tiles) {
+ for (Tile tile : category.getTiles()) {
final String childTitle = tile.title.toString();
String childClass = null;
if (tile.metaData != null) {
diff --git a/src/com/android/settings/dashboard/SummaryLoader.java b/src/com/android/settings/dashboard/SummaryLoader.java
index fe55be8..5af276c 100644
--- a/src/com/android/settings/dashboard/SummaryLoader.java
+++ b/src/com/android/settings/dashboard/SummaryLoader.java
@@ -216,7 +216,7 @@
if (category == null) {
return;
}
- for (Tile tile : category.tiles) {
+ for (Tile tile : category.getTiles()) {
final String key = mDashboardFeatureProvider.getDashboardKeyForTile(tile);
if (mSummaryTextMap.containsKey(key)) {
tile.summary = mSummaryTextMap.get(key);
@@ -250,12 +250,13 @@
}
private Tile getTileFromCategory(DashboardCategory category, ComponentName component) {
- if (category == null || category.tiles == null) {
+ if (category == null || category.getTilesCount() == 0) {
return null;
}
- final int tileCount = category.tiles.size();
+ final List<Tile> tiles = category.getTiles();
+ final int tileCount = tiles.size();
for (int j = 0; j < tileCount; j++) {
- final Tile tile = category.tiles.get(j);
+ final Tile tile = tiles.get(j);
if (component.equals(tile.intent.getComponent())) {
return tile;
}
@@ -291,10 +292,10 @@
case MSG_GET_CATEGORY_TILES_AND_SET_LISTENING:
final DashboardCategory category =
mDashboardFeatureProvider.getTilesForCategory(mCategoryKey);
- if (category == null || category.tiles == null) {
+ if (category == null || category.getTilesCount() == 0) {
return;
}
- final List<Tile> tiles = category.tiles;
+ final List<Tile> tiles = category.getTiles();
for (Tile tile : tiles) {
makeProviderW(tile);
}
diff --git a/src/com/android/settings/datausage/DataPlanUsageSummary.java b/src/com/android/settings/datausage/DataPlanUsageSummary.java
index 912db0a..a56bfa1 100644
--- a/src/com/android/settings/datausage/DataPlanUsageSummary.java
+++ b/src/com/android/settings/datausage/DataPlanUsageSummary.java
@@ -74,7 +74,7 @@
private NetworkPolicyEditor mPolicyEditor;
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_data_usage;
}
diff --git a/src/com/android/settings/datausage/DataSaverSummary.java b/src/com/android/settings/datausage/DataSaverSummary.java
index c623395..4ada3af 100644
--- a/src/com/android/settings/datausage/DataSaverSummary.java
+++ b/src/com/android/settings/datausage/DataSaverSummary.java
@@ -105,7 +105,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_data_saver;
}
diff --git a/src/com/android/settings/datausage/DataUsageSummary.java b/src/com/android/settings/datausage/DataUsageSummary.java
index 6fddb2b..fe22022 100644
--- a/src/com/android/settings/datausage/DataUsageSummary.java
+++ b/src/com/android/settings/datausage/DataUsageSummary.java
@@ -91,7 +91,7 @@
private NetworkPolicyEditor mPolicyEditor;
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_data_usage;
}
diff --git a/src/com/android/settings/datausage/UnrestrictedDataAccess.java b/src/com/android/settings/datausage/UnrestrictedDataAccess.java
index b382b8c..5b55ada 100644
--- a/src/com/android/settings/datausage/UnrestrictedDataAccess.java
+++ b/src/com/android/settings/datausage/UnrestrictedDataAccess.java
@@ -133,7 +133,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_unrestricted_data_access;
}
diff --git a/src/com/android/settings/deletionhelper/AutomaticStorageManagerSettings.java b/src/com/android/settings/deletionhelper/AutomaticStorageManagerSettings.java
index e38317a..cb9e750 100644
--- a/src/com/android/settings/deletionhelper/AutomaticStorageManagerSettings.java
+++ b/src/com/android/settings/deletionhelper/AutomaticStorageManagerSettings.java
@@ -137,7 +137,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_uri_storage;
}
diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
index 237f9ba..8f114fc 100644
--- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
+++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
@@ -292,7 +292,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return 0;
}
diff --git a/src/com/android/settings/development/OemUnlockPreferenceController.java b/src/com/android/settings/development/OemUnlockPreferenceController.java
index f486b3d..c6ba60c 100644
--- a/src/com/android/settings/development/OemUnlockPreferenceController.java
+++ b/src/com/android/settings/development/OemUnlockPreferenceController.java
@@ -98,7 +98,7 @@
@Override
public void updateState(Preference preference) {
super.updateState(preference);
- mPreference.setChecked(mOemLockManager.isOemUnlockAllowed());
+ mPreference.setChecked(isOemUnlockedAllowed());
updateOemUnlockSettingDescription();
// Showing mEnableOemUnlock preference as device has persistent data block.
mPreference.setDisabledByAdmin(null);
@@ -183,7 +183,8 @@
/**
* Returns {@code true} if the bootloader has been unlocked. Otherwise, returns {code false}.
*/
- private boolean isBootloaderUnlocked() {
+ @VisibleForTesting
+ boolean isBootloaderUnlocked() {
return mOemLockManager.isDeviceOemUnlocked();
}
@@ -216,4 +217,9 @@
userHandle);
}
+ @VisibleForTesting
+ boolean isOemUnlockedAllowed() {
+ return mOemLockManager.isOemUnlockAllowed();
+ }
+
}
diff --git a/src/com/android/settings/development/featureflags/FeatureFlagsDashboard.java b/src/com/android/settings/development/featureflags/FeatureFlagsDashboard.java
index c482d87..8f37c67 100644
--- a/src/com/android/settings/development/featureflags/FeatureFlagsDashboard.java
+++ b/src/com/android/settings/development/featureflags/FeatureFlagsDashboard.java
@@ -46,7 +46,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return 0;
}
diff --git a/src/com/android/settings/deviceinfo/StorageDashboardFragment.java b/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
index 5b9b375..341c76f 100644
--- a/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
+++ b/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
@@ -117,7 +117,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_storage_dashboard;
}
diff --git a/src/com/android/settings/deviceinfo/StorageSettings.java b/src/com/android/settings/deviceinfo/StorageSettings.java
index e9d3c85..0f88b4a 100644
--- a/src/com/android/settings/deviceinfo/StorageSettings.java
+++ b/src/com/android/settings/deviceinfo/StorageSettings.java
@@ -100,7 +100,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_uri_storage;
}
diff --git a/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java b/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java
index 2fb538e..9132daa 100644
--- a/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java
+++ b/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java
@@ -21,6 +21,7 @@
import android.provider.Settings;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
+import android.support.annotation.VisibleForTesting;
import com.android.internal.hardware.AmbientDisplayConfiguration;
import com.android.settings.R;
@@ -81,7 +82,7 @@
@Override
public boolean isAvailable() {
- return isAvailable(mConfig);
+ return alwaysOnAvailableForUser(mConfig);
}
public static boolean isAvailable(AmbientDisplayConfiguration config) {
@@ -102,4 +103,9 @@
ResultPayload.SettingsSource.SECURE, ON /* onValue */, intent, isAvailable(),
ON /* defaultValue */);
}
+
+ @VisibleForTesting
+ boolean alwaysOnAvailableForUser(AmbientDisplayConfiguration config) {
+ return isAvailable(config);
+ }
}
diff --git a/src/com/android/settings/display/AutoBrightnessPreferenceController.java b/src/com/android/settings/display/AutoBrightnessPreferenceController.java
index f242022..d71a1f8 100644
--- a/src/com/android/settings/display/AutoBrightnessPreferenceController.java
+++ b/src/com/android/settings/display/AutoBrightnessPreferenceController.java
@@ -16,65 +16,54 @@
import android.content.Context;
import android.content.Intent;
import android.provider.Settings;
-import android.support.v14.preference.SwitchPreference;
-import android.support.v7.preference.Preference;
import com.android.settings.DisplaySettings;
-import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.core.TogglePreferenceController;
import com.android.settings.search.DatabaseIndexingUtils;
import com.android.settings.search.InlineSwitchPayload;
import com.android.settings.search.ResultPayload;
import com.android.settings.R;
-import com.android.settingslib.core.AbstractPreferenceController;
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE;
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL;
-public class AutoBrightnessPreferenceController extends AbstractPreferenceController implements
- PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
-
- private final String mAutoBrightnessKey;
+public class AutoBrightnessPreferenceController extends TogglePreferenceController {
private final String SYSTEM_KEY = SCREEN_BRIGHTNESS_MODE;
private final int DEFAULT_VALUE = SCREEN_BRIGHTNESS_MODE_MANUAL;
public AutoBrightnessPreferenceController(Context context, String key) {
- super(context);
- mAutoBrightnessKey = key;
+ super(context, key);
}
@Override
- public boolean isAvailable() {
- return mContext.getResources().getBoolean(
- com.android.internal.R.bool.config_automatic_brightness_available);
+ public boolean isChecked() {
+ return Settings.System.getInt(mContext.getContentResolver(),
+ SYSTEM_KEY, DEFAULT_VALUE) != DEFAULT_VALUE;
}
@Override
- public String getPreferenceKey() {
- return mAutoBrightnessKey;
- }
-
- @Override
- public void updateState(Preference preference) {
- int brightnessMode = Settings.System.getInt(mContext.getContentResolver(),
- SYSTEM_KEY, DEFAULT_VALUE);
- ((SwitchPreference) preference).setChecked(brightnessMode != DEFAULT_VALUE);
- }
-
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- boolean auto = (Boolean) newValue;
+ public void setChecked(boolean isChecked) {
Settings.System.putInt(mContext.getContentResolver(), SYSTEM_KEY,
- auto ? SCREEN_BRIGHTNESS_MODE_AUTOMATIC : DEFAULT_VALUE);
- return true;
+ isChecked ? SCREEN_BRIGHTNESS_MODE_AUTOMATIC : DEFAULT_VALUE);
+ }
+
+ @Override
+ @AvailabilityStatus
+ public int getAvailabilityStatus() {
+ return mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_automatic_brightness_available)
+ ? AVAILABLE
+ : DISABLED_UNSUPPORTED;
}
@Override
public ResultPayload getResultPayload() {
+ // TODO remove result payload
final Intent intent = DatabaseIndexingUtils.buildSearchResultPageIntent(mContext,
- DisplaySettings.class.getName(), mAutoBrightnessKey,
+ DisplaySettings.class.getName(), getPreferenceKey(),
mContext.getString(R.string.display_settings));
return new InlineSwitchPayload(SYSTEM_KEY,
diff --git a/src/com/android/settings/display/NightDisplayPreferenceController.java b/src/com/android/settings/display/NightDisplayPreferenceController.java
index 643f1d4..2761eca 100644
--- a/src/com/android/settings/display/NightDisplayPreferenceController.java
+++ b/src/com/android/settings/display/NightDisplayPreferenceController.java
@@ -37,4 +37,4 @@
public String getPreferenceKey() {
return KEY_NIGHT_DISPLAY;
}
-}
+}
\ No newline at end of file
diff --git a/src/com/android/settings/display/NightDisplaySettings.java b/src/com/android/settings/display/NightDisplaySettings.java
index ab94720..4e0ebcd 100644
--- a/src/com/android/settings/display/NightDisplaySettings.java
+++ b/src/com/android/settings/display/NightDisplaySettings.java
@@ -20,27 +20,34 @@
import android.app.TimePickerDialog;
import android.content.Context;
import android.os.Bundle;
+import android.provider.SearchIndexableResource;
import android.support.v7.preference.DropDownPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.TwoStatePreference;
-import android.widget.TimePicker;
import com.android.internal.app.ColorDisplayController;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
import com.android.settings.widget.SeekBarPreference;
import com.android.settings.SettingsPreferenceFragment;
+import com.android.settingslib.core.AbstractPreferenceController;
import java.text.DateFormat;
import java.time.LocalTime;
+import java.util.ArrayList;
import java.util.Calendar;
+import java.util.List;
import java.util.TimeZone;
/**
* Settings screen for Night display.
+ * TODO (b/69912911) Upgrade to Dashboard fragment
*/
public class NightDisplaySettings extends SettingsPreferenceFragment
- implements ColorDisplayController.Callback, Preference.OnPreferenceChangeListener {
+ implements ColorDisplayController.Callback, Preference.OnPreferenceChangeListener,
+ Indexable {
private static final String KEY_NIGHT_DISPLAY_AUTO_MODE = "night_display_auto_mode";
private static final String KEY_NIGHT_DISPLAY_START_TIME = "night_display_start_time";
@@ -75,7 +82,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_night_display;
}
@@ -92,12 +99,12 @@
mActivatedPreference = (TwoStatePreference) findPreference(KEY_NIGHT_DISPLAY_ACTIVATED);
mTemperaturePreference = (SeekBarPreference) findPreference(KEY_NIGHT_DISPLAY_TEMPERATURE);
- mAutoModePreference.setEntries(new CharSequence[] {
+ mAutoModePreference.setEntries(new CharSequence[]{
getString(R.string.night_display_auto_mode_never),
getString(R.string.night_display_auto_mode_custom),
getString(R.string.night_display_auto_mode_twilight)
});
- mAutoModePreference.setEntryValues(new CharSequence[] {
+ mAutoModePreference.setEntryValues(new CharSequence[]{
String.valueOf(ColorDisplayController.AUTO_MODE_DISABLED),
String.valueOf(ColorDisplayController.AUTO_MODE_CUSTOM),
String.valueOf(ColorDisplayController.AUTO_MODE_TWILIGHT)
@@ -155,15 +162,12 @@
final Context context = getContext();
final boolean use24HourFormat = android.text.format.DateFormat.is24HourFormat(context);
- return new TimePickerDialog(context, new TimePickerDialog.OnTimeSetListener() {
- @Override
- public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
- final LocalTime time = LocalTime.of(hourOfDay, minute);
- if (dialogId == DIALOG_START_TIME) {
- mController.setCustomStartTime(time);
- } else {
- mController.setCustomEndTime(time);
- }
+ return new TimePickerDialog(context, (view, hourOfDay, minute) -> {
+ final LocalTime time = LocalTime.of(hourOfDay, minute);
+ if (dialogId == DIALOG_START_TIME) {
+ mController.setCustomStartTime(time);
+ } else {
+ mController.setCustomEndTime(time);
}
}, initialTime.getHour(), initialTime.getMinute(), use24HourFormat);
}
@@ -247,4 +251,23 @@
public int getMetricsCategory() {
return MetricsEvent.NIGHT_DISPLAY_SETTINGS;
}
+
+ public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider() {
+ @Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
+ boolean enabled) {
+ final ArrayList<SearchIndexableResource> result = new ArrayList<>();
+
+ final SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.night_display_settings;
+ result.add(sir);
+ return result;
+ }
+
+ @Override
+ protected boolean isPageSearchEnabled(Context context) {
+ return ColorDisplayController.isAvailable(context);
+ }
+ };
}
diff --git a/src/com/android/settings/dream/DreamSettings.java b/src/com/android/settings/dream/DreamSettings.java
index 94ec149..c3eaa7f 100644
--- a/src/com/android/settings/dream/DreamSettings.java
+++ b/src/com/android/settings/dream/DreamSettings.java
@@ -99,7 +99,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_screen_saver;
}
diff --git a/src/com/android/settings/fingerprint/FingerprintSettings.java b/src/com/android/settings/fingerprint/FingerprintSettings.java
index fb09f7a..ad7f83a 100644
--- a/src/com/android/settings/fingerprint/FingerprintSettings.java
+++ b/src/com/android/settings/fingerprint/FingerprintSettings.java
@@ -545,7 +545,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_fingerprint;
}
diff --git a/src/com/android/settings/fuelgauge/FakeUid.java b/src/com/android/settings/fuelgauge/FakeUid.java
index 2c3e3cf..2b5afe1 100644
--- a/src/com/android/settings/fuelgauge/FakeUid.java
+++ b/src/com/android/settings/fuelgauge/FakeUid.java
@@ -51,6 +51,11 @@
}
@Override
+ public Timer getMulticastWakelockStats() {
+ return null;
+ }
+
+ @Override
public ArrayMap<String, ? extends Timer> getSyncStats() {
return null;
}
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index dd8c169..bf3cc64 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -340,7 +340,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_battery;
}
diff --git a/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java b/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
index deffa97..5412f36 100644
--- a/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
+++ b/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
@@ -22,6 +22,7 @@
import android.content.SharedPreferences;
import android.provider.Settings;
import android.support.v7.preference.Preference;
+import android.support.annotation.VisibleForTesting;
import com.android.internal.hardware.AmbientDisplayConfiguration;
import com.android.settings.R;
@@ -55,8 +56,13 @@
}
public static boolean isSuggestionComplete(Context context, SharedPreferences prefs) {
- AmbientDisplayConfiguration ambientConfig = new AmbientDisplayConfiguration(context);
- return !ambientConfig.pulseOnDoubleTapAvailable()
+ return isSuggestionComplete(new AmbientDisplayConfiguration(context), prefs);
+ }
+
+ @VisibleForTesting
+ static boolean isSuggestionComplete(AmbientDisplayConfiguration config,
+ SharedPreferences prefs) {
+ return !config.pulseOnDoubleTapAvailable()
|| prefs.getBoolean(DoubleTapScreenSettings.PREF_KEY_SUGGESTION_COMPLETE, false);
}
diff --git a/src/com/android/settings/gestures/DoubleTapScreenSettings.java b/src/com/android/settings/gestures/DoubleTapScreenSettings.java
index c0cd453e..f2148b4 100644
--- a/src/com/android/settings/gestures/DoubleTapScreenSettings.java
+++ b/src/com/android/settings/gestures/DoubleTapScreenSettings.java
@@ -68,7 +68,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_double_tap_screen;
}
diff --git a/src/com/android/settings/gestures/PickupGesturePreferenceController.java b/src/com/android/settings/gestures/PickupGesturePreferenceController.java
index 314cbc3..02107c1 100644
--- a/src/com/android/settings/gestures/PickupGesturePreferenceController.java
+++ b/src/com/android/settings/gestures/PickupGesturePreferenceController.java
@@ -24,6 +24,7 @@
import android.content.SharedPreferences;
import android.provider.Settings;
import android.support.v7.preference.Preference;
+import android.support.annotation.VisibleForTesting;
import com.android.internal.hardware.AmbientDisplayConfiguration;
import com.android.settings.R;
@@ -90,7 +91,7 @@
@Override
public boolean canHandleClicks() {
- return mAmbientConfig.pulseOnPickupCanBeModified(mUserId);
+ return pulseOnPickupCanBeModified();
}
@Override
@@ -102,4 +103,9 @@
return new InlineSwitchPayload(SECURE_KEY, ResultPayload.SettingsSource.SECURE,
ON /* onValue */, intent, isAvailable(), ON /* defaultValue */);
}
+
+ @VisibleForTesting
+ boolean pulseOnPickupCanBeModified() {
+ return mAmbientConfig.pulseOnPickupCanBeModified(mUserId);
+ }
}
diff --git a/src/com/android/settings/gestures/PickupGestureSettings.java b/src/com/android/settings/gestures/PickupGestureSettings.java
index a4f1776..1762ba8 100644
--- a/src/com/android/settings/gestures/PickupGestureSettings.java
+++ b/src/com/android/settings/gestures/PickupGestureSettings.java
@@ -68,7 +68,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_pickup_gesture;
}
diff --git a/src/com/android/settings/network/NetworkDashboardFragment.java b/src/com/android/settings/network/NetworkDashboardFragment.java
index 2a04d27..4b1da31 100644
--- a/src/com/android/settings/network/NetworkDashboardFragment.java
+++ b/src/com/android/settings/network/NetworkDashboardFragment.java
@@ -78,7 +78,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_network_dashboard;
}
diff --git a/src/com/android/settings/notification/EmergencyBroadcastPreferenceController.java b/src/com/android/settings/notification/EmergencyBroadcastPreferenceController.java
index d6291a8..2eb9f6a 100644
--- a/src/com/android/settings/notification/EmergencyBroadcastPreferenceController.java
+++ b/src/com/android/settings/notification/EmergencyBroadcastPreferenceController.java
@@ -40,7 +40,6 @@
private AccountRestrictionHelper mHelper;
private UserManager mUserManager;
private PackageManager mPm;
- private boolean mCellBroadcastAppLinkEnabled;
public EmergencyBroadcastPreferenceController(Context context, String prefKey) {
this(context, new AccountRestrictionHelper(context), prefKey);
@@ -54,8 +53,6 @@
mHelper = helper;
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
mPm = mContext.getPackageManager();
- // Enable link to CMAS app settings depending on the value in config.xml.
- mCellBroadcastAppLinkEnabled = isCellBroadcastAppLinkEnabled();
}
@Override
@@ -79,12 +76,13 @@
@Override
public boolean isAvailable() {
- return mUserManager.isAdminUser() && mCellBroadcastAppLinkEnabled
+ return mUserManager.isAdminUser() && isCellBroadcastAppLinkEnabled()
&& !mHelper.hasBaseUserRestriction(
UserManager.DISALLOW_CONFIG_CELL_BROADCASTS, UserHandle.myUserId());
}
private boolean isCellBroadcastAppLinkEnabled() {
+ // Enable link to CMAS app settings depending on the value in config.xml.
boolean enabled = mContext.getResources().getBoolean(
com.android.internal.R.bool.config_cellBroadcastAppLinks);
if (enabled) {
diff --git a/src/com/android/settings/notification/SoundSettings.java b/src/com/android/settings/notification/SoundSettings.java
index a724338..6e998f6 100644
--- a/src/com/android/settings/notification/SoundSettings.java
+++ b/src/com/android/settings/notification/SoundSettings.java
@@ -71,7 +71,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_sound;
}
diff --git a/src/com/android/settings/notification/ZenModeAutomationSettings.java b/src/com/android/settings/notification/ZenModeAutomationSettings.java
index d096e8c..582fb03 100644
--- a/src/com/android/settings/notification/ZenModeAutomationSettings.java
+++ b/src/com/android/settings/notification/ZenModeAutomationSettings.java
@@ -18,6 +18,7 @@
import android.app.Fragment;
import android.content.Context;
+import android.provider.SearchIndexableResource;
import android.service.notification.ConditionProviderService;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
@@ -78,17 +79,30 @@
*/
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
- @Override
- public List<String> getNonIndexableKeys(Context context) {
- final List<String> keys = super.getNonIndexableKeys(context);
- keys.add(KEY_ADD_RULE);
- keys.add(KEY_AUTOMATIC_RULES);
- return keys;
- }
- @Override
- public List<AbstractPreferenceController> getPreferenceControllers(Context context) {
- return buildPreferenceControllers(context, null, null);
- }
- };
+ @Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
+ boolean enabled) {
+ final ArrayList<SearchIndexableResource> result = new ArrayList<>();
+
+ final SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.zen_mode_automation_settings;
+ result.add(sir);
+ return result;
+ }
+
+ @Override
+ public List<String> getNonIndexableKeys(Context context) {
+ final List<String> keys = super.getNonIndexableKeys(context);
+ keys.add(KEY_ADD_RULE);
+ keys.add(KEY_AUTOMATIC_RULES);
+ return keys;
+ }
+
+ @Override
+ public List<AbstractPreferenceController> getPreferenceControllers(
+ Context context) {
+ return buildPreferenceControllers(context, null, null);
+ }
+ };
}
diff --git a/src/com/android/settings/notification/ZenModeBehaviorSettings.java b/src/com/android/settings/notification/ZenModeBehaviorSettings.java
index dfe6786..b58ef86 100644
--- a/src/com/android/settings/notification/ZenModeBehaviorSettings.java
+++ b/src/com/android/settings/notification/ZenModeBehaviorSettings.java
@@ -17,6 +17,7 @@
package com.android.settings.notification;
import android.content.Context;
+import android.provider.SearchIndexableResource;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
@@ -65,6 +66,18 @@
*/
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
+
+ @Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
+ boolean enabled) {
+ final ArrayList<SearchIndexableResource> result = new ArrayList<>();
+
+ final SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.zen_mode_behavior_settings;
+ result.add(sir);
+ return result;
+ }
+
@Override
public List<String> getNonIndexableKeys(Context context) {
final List<String> keys = super.getNonIndexableKeys(context);
diff --git a/src/com/android/settings/notification/ZenModeRuleSettingsBase.java b/src/com/android/settings/notification/ZenModeRuleSettingsBase.java
index 9eccfdc..069d38b 100644
--- a/src/com/android/settings/notification/ZenModeRuleSettingsBase.java
+++ b/src/com/android/settings/notification/ZenModeRuleSettingsBase.java
@@ -26,7 +26,6 @@
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
-import android.provider.SearchIndexableResource;
import android.service.notification.ConditionProviderService;
import android.support.v7.preference.DropDownPreference;
import android.support.v7.preference.Preference;
@@ -44,15 +43,9 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
-import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.search.Indexable;
import com.android.settings.widget.SwitchBar;
import com.android.settingslib.core.AbstractPreferenceController;
-import java.util.Arrays;
-import java.util.List;
-
-import java.util.Arrays;
import java.util.List;
public abstract class ZenModeRuleSettingsBase extends ZenModeSettingsBase
@@ -62,8 +55,6 @@
private static final String KEY_RULE_NAME = "rule_name";
private static final String KEY_ZEN_MODE = "zen_mode";
- private static final String KEY_EVENT_RULE_SETTINGS = "zen_mode_event_rule_settings";
- private static final String KEY_SCHEDULE_RULE_SETTINGS = "zen_mode_schedule_rule_settings";
protected Context mContext;
protected boolean mDisableListeners;
@@ -306,26 +297,4 @@
}
mDisableListeners = false;
}
-
- /**
- * For Search.
- */
- public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider() {
- @Override
- public List<SearchIndexableResource> getXmlResourcesToIndex(
- Context context, boolean enabled) {
- final SearchIndexableResource sir = new SearchIndexableResource(context);
- // not indexable
- return Arrays.asList(sir);
- }
-
- @Override
- public List<String> getNonIndexableKeys(Context context) {
- final List<String> keys = super.getNonIndexableKeys(context);
- keys.add(KEY_SCHEDULE_RULE_SETTINGS);
- keys.add(KEY_EVENT_RULE_SETTINGS);
- return keys;
- }
- };
}
diff --git a/src/com/android/settings/notification/ZenModeSettings.java b/src/com/android/settings/notification/ZenModeSettings.java
index fbc9f7d..22d6fca 100644
--- a/src/com/android/settings/notification/ZenModeSettings.java
+++ b/src/com/android/settings/notification/ZenModeSettings.java
@@ -54,7 +54,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_uri_interruptions;
}
diff --git a/src/com/android/settings/password/ChooseLockGeneric.java b/src/com/android/settings/password/ChooseLockGeneric.java
index a694603..e5ba200 100644
--- a/src/com/android/settings/password/ChooseLockGeneric.java
+++ b/src/com/android/settings/password/ChooseLockGeneric.java
@@ -753,7 +753,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_choose_lockscreen;
}
diff --git a/src/com/android/settings/print/PrintSettingsFragment.java b/src/com/android/settings/print/PrintSettingsFragment.java
index 6bdce48..56bebcc 100644
--- a/src/com/android/settings/print/PrintSettingsFragment.java
+++ b/src/com/android/settings/print/PrintSettingsFragment.java
@@ -98,7 +98,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_uri_printing;
}
diff --git a/src/com/android/settings/search/BaseSearchIndexProvider.java b/src/com/android/settings/search/BaseSearchIndexProvider.java
index 0f02f49..5723300 100644
--- a/src/com/android/settings/search/BaseSearchIndexProvider.java
+++ b/src/com/android/settings/search/BaseSearchIndexProvider.java
@@ -27,6 +27,7 @@
import android.util.Log;
import android.util.Xml;
+import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -71,6 +72,9 @@
if (controller instanceof PreferenceControllerMixin) {
((PreferenceControllerMixin) controller)
.updateNonIndexableKeys(nonIndexableKeys);
+ } else if (controller instanceof BasePreferenceController) {
+ ((BasePreferenceController) controller).updateNonIndexableKeys(
+ nonIndexableKeys);
} else {
throw new IllegalStateException(controller.getClass().getName()
+ " must implement " + PreferenceControllerMixin.class.getName());
diff --git a/src/com/android/settings/search/DatabaseIndexingManager.java b/src/com/android/settings/search/DatabaseIndexingManager.java
index 970b50f..0aeda66 100644
--- a/src/com/android/settings/search/DatabaseIndexingManager.java
+++ b/src/com/android/settings/search/DatabaseIndexingManager.java
@@ -19,20 +19,18 @@
import static com.android.settings.search.CursorToSearchResultConverter.COLUMN_INDEX_ID;
-import static com.android.settings.search.CursorToSearchResultConverter
- .COLUMN_INDEX_INTENT_ACTION_TARGET_PACKAGE;
+import static com.android.settings.search.CursorToSearchResultConverter.COLUMN_INDEX_INTENT_ACTION_TARGET_PACKAGE;
import static com.android.settings.search.CursorToSearchResultConverter.COLUMN_INDEX_KEY;
import static com.android.settings.search.DatabaseResultLoader.SELECT_COLUMNS;
-import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DOCID;
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.CLASS_NAME;
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_ENTRIES;
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_KEYWORDS;
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_KEY_REF;
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_SUMMARY_ON;
-import static com.android.settings.search.IndexDatabaseHelper.IndexColumns
- .DATA_SUMMARY_ON_NORMALIZED;
+import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_SUMMARY_ON_NORMALIZED;
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_TITLE;
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_TITLE_NORMALIZED;
+import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DOCID;
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.ENABLED;
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.ICON;
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.INTENT_ACTION;
@@ -55,6 +53,7 @@
import android.os.AsyncTask;
import android.os.Build;
import android.provider.SearchIndexablesContract;
+import android.provider.SearchIndexablesContract.SiteMapColumns;
import android.support.annotation.VisibleForTesting;
import android.text.TextUtils;
import android.util.Log;
@@ -68,7 +67,6 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
-import java.util.Objects;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -276,17 +274,11 @@
if (!TextUtils.isEmpty(dataRow.className)
&& !TextUtils.isEmpty(dataRow.childClassName)) {
- ContentValues siteMapPair = new ContentValues();
- final int pairDocId = Objects.hash(dataRow.className, dataRow.childClassName);
- siteMapPair.put(IndexDatabaseHelper.SiteMapColumns.DOCID, pairDocId);
- siteMapPair.put(IndexDatabaseHelper.SiteMapColumns.PARENT_CLASS,
- dataRow.className);
- siteMapPair.put(IndexDatabaseHelper.SiteMapColumns.PARENT_TITLE,
- dataRow.screenTitle);
- siteMapPair.put(IndexDatabaseHelper.SiteMapColumns.CHILD_CLASS,
- dataRow.childClassName);
- siteMapPair.put(IndexDatabaseHelper.SiteMapColumns.CHILD_TITLE,
- dataRow.updatedTitle);
+ final ContentValues siteMapPair = new ContentValues();
+ siteMapPair.put(SiteMapColumns.PARENT_CLASS, dataRow.className);
+ siteMapPair.put(SiteMapColumns.PARENT_TITLE, dataRow.screenTitle);
+ siteMapPair.put(SiteMapColumns.CHILD_CLASS, dataRow.childClassName);
+ siteMapPair.put(SiteMapColumns.CHILD_TITLE, dataRow.updatedTitle);
database.replaceOrThrow(IndexDatabaseHelper.Tables.TABLE_SITE_MAP,
null /* nullColumnHack */, siteMapPair);
diff --git a/src/com/android/settings/search/DatabaseIndexingUtils.java b/src/com/android/settings/search/DatabaseIndexingUtils.java
index 39bcdf84..207d09f 100644
--- a/src/com/android/settings/search/DatabaseIndexingUtils.java
+++ b/src/com/android/settings/search/DatabaseIndexingUtils.java
@@ -27,6 +27,7 @@
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.SettingsActivity;
import com.android.settings.Utils;
+import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -72,10 +73,11 @@
* @return A map between {@link Uri}s and {@link PreferenceControllerMixin}s to get the payload
* types for Settings.
*/
- public static Map<String, PreferenceControllerMixin> getPreferenceControllerUriMap(
+ public static Map<String, ResultPayload> getPayloadKeyMap(
String className, Context context) {
+ ArrayMap<String, ResultPayload> map = new ArrayMap<>();
if (context == null) {
- return null;
+ return map;
}
final Class<?> clazz = getIndexableClass(className);
@@ -83,7 +85,7 @@
if (clazz == null) {
Log.d(TAG, "SearchIndexableResource '" + className +
"' should implement the " + Indexable.class.getName() + " interface!");
- return null;
+ return map;
}
// Will be non null only for a Local provider implementing a
@@ -94,44 +96,28 @@
provider.getPreferenceControllers(context);
if (controllers == null) {
- return null;
+ return map;
}
- ArrayMap<String, PreferenceControllerMixin> map = new ArrayMap<>();
-
for (AbstractPreferenceController controller : controllers) {
+ ResultPayload payload;
if (controller instanceof PreferenceControllerMixin) {
- map.put(controller.getPreferenceKey(), (PreferenceControllerMixin) controller);
+ payload = ((PreferenceControllerMixin) controller).getResultPayload();
+
+ } else if (controller instanceof BasePreferenceController) {
+ payload = ((BasePreferenceController) controller).getResultPayload();
} else {
throw new IllegalStateException(controller.getClass().getName()
+ " must implement " + PreferenceControllerMixin.class.getName());
}
+ if (payload != null) {
+ map.put(controller.getPreferenceKey(), payload);
+ }
}
return map;
}
- /**
- * @param uriMap Map between the {@link PreferenceControllerMixin} keys
- * and the controllers themselves.
- * @param key The look-up key
- * @return The Payload from the {@link PreferenceControllerMixin} specified by the key,
- * if it exists. Otherwise null.
- */
- public static ResultPayload getPayloadFromUriMap(Map<String, PreferenceControllerMixin> uriMap,
- String key) {
- if (uriMap == null) {
- return null;
- }
-
- PreferenceControllerMixin controller = uriMap.get(key);
- if (controller == null) {
- return null;
- }
-
- return controller.getResultPayload();
- }
-
public static Class<?> getIndexableClass(String className) {
final Class<?> clazz;
try {
@@ -164,4 +150,4 @@
}
return null;
}
-}
+}
\ No newline at end of file
diff --git a/src/com/android/settings/search/IndexDatabaseHelper.java b/src/com/android/settings/search/IndexDatabaseHelper.java
index b85b6c0..19e3419 100644
--- a/src/com/android/settings/search/IndexDatabaseHelper.java
+++ b/src/com/android/settings/search/IndexDatabaseHelper.java
@@ -22,6 +22,7 @@
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Build;
+import android.provider.SearchIndexablesContract.SiteMapColumns;
import android.support.annotation.VisibleForTesting;
import android.text.TextUtils;
import android.util.Log;
@@ -33,7 +34,7 @@
private static final String TAG = "IndexDatabaseHelper";
private static final String DATABASE_NAME = "search_index.db";
- private static final int DATABASE_VERSION = 117;
+ private static final int DATABASE_VERSION = 118;
private static final String SHARED_PREFS_TAG = "indexing_manager";
@@ -80,14 +81,6 @@
String TIME_STAMP = "timestamp";
}
- public interface SiteMapColumns {
- String DOCID = "docid";
- String PARENT_CLASS = "parent_class";
- String CHILD_CLASS = "child_class";
- String PARENT_TITLE = "parent_title";
- String CHILD_TITLE = "child_title";
- }
-
private static final String CREATE_INDEX_TABLE =
"CREATE VIRTUAL TABLE " + Tables.TABLE_PREFS_INDEX + " USING fts4" +
"(" +
diff --git a/src/com/android/settings/search/SearchFeatureProvider.java b/src/com/android/settings/search/SearchFeatureProvider.java
index d0c0cd9..437fc86 100644
--- a/src/com/android/settings/search/SearchFeatureProvider.java
+++ b/src/com/android/settings/search/SearchFeatureProvider.java
@@ -38,6 +38,8 @@
*/
public interface SearchFeatureProvider {
+ Intent SEARCH_UI_INTENT = new Intent("com.android.settings.action.SETTINGS_SEARCH");
+
/**
* Ensures the caller has necessary privilege to launch search result page.
*
@@ -165,6 +167,10 @@
return null;
}
+ default boolean isSearchV2Enabled(Context context) {
+ return FeatureFlagUtils.isEnabled(context, FeatureFlags.SEARCH_V2);
+ }
+
/**
* Initializes the search toolbar.
*/
@@ -174,8 +180,8 @@
}
toolbar.setOnClickListener(tb -> {
final Intent intent;
- if (FeatureFlagUtils.isEnabled(activity, FeatureFlags.SEARCH_V2)) {
- intent = new Intent("com.android.settings.action.SETTINGS_SEARCH");
+ if (isSearchV2Enabled(activity)) {
+ intent = SEARCH_UI_INTENT;
} else {
intent = new Intent(activity, SearchActivity.class);
}
diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java
index 7512c13..1f88872 100644
--- a/src/com/android/settings/search/SearchIndexableResources.java
+++ b/src/com/android/settings/search/SearchIndexableResources.java
@@ -39,10 +39,10 @@
import com.android.settings.datausage.DataUsageSummary;
import com.android.settings.deletionhelper.AutomaticStorageManagerSettings;
import com.android.settings.development.DevelopmentSettingsDashboardFragment;
-import com.android.settings.deviceinfo.Status;
import com.android.settings.deviceinfo.StorageDashboardFragment;
import com.android.settings.deviceinfo.StorageSettings;
import com.android.settings.display.AmbientDisplaySettings;
+import com.android.settings.display.NightDisplaySettings;
import com.android.settings.display.ScreenZoomSettings;
import com.android.settings.dream.DreamSettings;
import com.android.settings.enterprise.EnterprisePrivacySettings;
@@ -69,8 +69,6 @@
import com.android.settings.notification.SoundSettings;
import com.android.settings.notification.ZenModeAutomationSettings;
import com.android.settings.notification.ZenModeBehaviorSettings;
-import com.android.settings.notification.ZenModeEventRuleSettings;
-import com.android.settings.notification.ZenModeScheduleRuleSettings;
import com.android.settings.notification.ZenModeSettings;
import com.android.settings.print.PrintSettingsFragment;
import com.android.settings.security.EncryptionAndCredential;
@@ -86,6 +84,7 @@
import com.android.settings.tts.TtsEnginePreferenceFragment;
import com.android.settings.users.UserSettings;
import com.android.settings.wallpaper.WallpaperTypeSettings;
+import com.android.settings.wfd.WifiDisplaySettings;
import com.android.settings.wifi.ConfigureWifiSettings;
import com.android.settings.wifi.WifiSettings;
@@ -169,10 +168,10 @@
addIndex(PowerUsageSummary.class);
addIndex(BatterySaverSettings.class);
addIndex(LockscreenDashboardFragment.class);
+ addIndex(WifiDisplaySettings.class);
addIndex(ZenModeBehaviorSettings.class);
addIndex(ZenModeAutomationSettings.class);
- addIndex(ZenModeEventRuleSettings.class);
- addIndex(ZenModeScheduleRuleSettings.class);
+ addIndex(NightDisplaySettings.class);
}
private SearchIndexableResources() {
diff --git a/src/com/android/settings/search/SettingsSearchIndexablesProvider.java b/src/com/android/settings/search/SettingsSearchIndexablesProvider.java
index 968847b..0c98b9c 100644
--- a/src/com/android/settings/search/SettingsSearchIndexablesProvider.java
+++ b/src/com/android/settings/search/SettingsSearchIndexablesProvider.java
@@ -40,16 +40,24 @@
import static android.provider.SearchIndexablesContract.INDEXABLES_RAW_COLUMNS;
import static android.provider.SearchIndexablesContract.INDEXABLES_XML_RES_COLUMNS;
import static android.provider.SearchIndexablesContract.NON_INDEXABLES_KEYS_COLUMNS;
+import static android.provider.SearchIndexablesContract.SITE_MAP_COLUMNS;
+import static com.android.settings.dashboard.DashboardFragmentRegistry.CATEGORY_KEY_TO_PARENT_MAP;
import android.content.Context;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.provider.SearchIndexableResource;
+import android.provider.SearchIndexablesContract;
import android.provider.SearchIndexablesProvider;
import android.text.TextUtils;
import android.util.ArraySet;
import android.util.Log;
+import com.android.settings.SettingsActivity;
+import com.android.settings.overlay.FeatureFactory;
+import com.android.settingslib.drawer.DashboardCategory;
+import com.android.settingslib.drawer.Tile;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -134,6 +142,38 @@
return cursor;
}
+ @Override
+ public Cursor querySiteMapPairs() {
+ final MatrixCursor cursor = new MatrixCursor(SITE_MAP_COLUMNS);
+ final Context context = getContext();
+ // Loop through all IA categories and pages and build additional SiteMapPairs
+ final List<DashboardCategory> categories = FeatureFactory.getFactory(context)
+ .getDashboardFeatureProvider(context).getAllCategories();
+ for (DashboardCategory category : categories) {
+ // Use the category key to look up parent (which page hosts this key)
+ final String parentClass = CATEGORY_KEY_TO_PARENT_MAP.get(category.key);
+ if (parentClass == null) {
+ continue;
+ }
+ // Build parent-child class pairs for all children listed under this key.
+ for (Tile tile : category.getTiles()) {
+ String childClass = null;
+ if (tile.metaData != null) {
+ childClass = tile.metaData.getString(
+ SettingsActivity.META_DATA_KEY_FRAGMENT_CLASS);
+ }
+ if (childClass == null) {
+ continue;
+ }
+ cursor.newRow()
+ .add(SearchIndexablesContract.SiteMapColumns.PARENT_CLASS, parentClass)
+ .add(SearchIndexablesContract.SiteMapColumns.CHILD_CLASS, childClass);
+ }
+ }
+ // Done.
+ return cursor;
+ }
+
private List<String> getNonIndexableKeysFromProvider(Context context) {
final Collection<Class> values = SearchIndexableResources.providerValues();
final List<String> nonIndexableKeys = new ArrayList<>();
diff --git a/src/com/android/settings/search/actionbar/SearchMenuController.java b/src/com/android/settings/search/actionbar/SearchMenuController.java
new file mode 100644
index 0000000..28bde33
--- /dev/null
+++ b/src/com/android/settings/search/actionbar/SearchMenuController.java
@@ -0,0 +1,75 @@
+/*
+ * 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.search.actionbar;
+
+import android.annotation.NonNull;
+import android.app.Fragment;
+import android.content.Context;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+
+import com.android.settings.R;
+import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.search.SearchFeatureProvider;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.ObservablePreferenceFragment;
+import com.android.settingslib.core.lifecycle.events.OnCreateOptionsMenu;
+
+public class SearchMenuController implements LifecycleObserver, OnCreateOptionsMenu {
+
+ public static final String NEED_SEARCH_ICON_IN_ACTION_BAR = "need_search_icon_in_action_bar";
+
+ private final Fragment mHost;
+
+ public static void init(@NonNull ObservablePreferenceFragment host) {
+ final Context context = host.getContext();
+ final boolean isSearchV2Enabled = FeatureFactory.getFactory(context)
+ .getSearchFeatureProvider()
+ .isSearchV2Enabled(context);
+
+ if (isSearchV2Enabled) {
+ host.getLifecycle().addObserver(new SearchMenuController(host));
+ }
+ }
+
+ private SearchMenuController(@NonNull Fragment host) {
+ mHost = host;
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ if (menu == null) {
+ return;
+ }
+ final Bundle arguments = mHost.getArguments();
+ if (arguments != null && !arguments.getBoolean(NEED_SEARCH_ICON_IN_ACTION_BAR, true)) {
+ return;
+ }
+ final MenuItem searchItem = menu.add(Menu.NONE, Menu.NONE, 0 /* order */,
+ R.string.search_menu);
+ searchItem.setIcon(R.drawable.ic_search_24dp);
+ searchItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
+
+ searchItem.setOnMenuItemClickListener(target -> {
+ mHost.startActivityForResult(
+ SearchFeatureProvider.SEARCH_UI_INTENT, 0 /* requestCode */);
+ return true;
+ });
+ }
+}
diff --git a/src/com/android/settings/search/indexing/IndexDataConverter.java b/src/com/android/settings/search/indexing/IndexDataConverter.java
index 65fa279..c40a466 100644
--- a/src/com/android/settings/search/indexing/IndexDataConverter.java
+++ b/src/com/android/settings/search/indexing/IndexDataConverter.java
@@ -40,6 +40,7 @@
import java.io.IOException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -178,11 +179,11 @@
final String intentTargetPackage = sir.intentTargetPackage;
final String intentTargetClass = sir.intentTargetClass;
- Map<String, PreferenceControllerMixin> controllerUriMap = null;
+ Map<String, ResultPayload> controllerUriMap = new HashMap<>();
if (fragmentName != null) {
controllerUriMap = DatabaseIndexingUtils
- .getPreferenceControllerUriMap(fragmentName, context);
+ .getPayloadKeyMap(fragmentName, context);
}
headerTitle = XmlParserUtils.getDataTitle(context, attrs);
@@ -249,7 +250,7 @@
}
// TODO (b/62254931) index primitives instead of payload
- payload = DatabaseIndexingUtils.getPayloadFromUriMap(controllerUriMap, key);
+ payload = controllerUriMap.get(key);
childFragment = XmlParserUtils.getDataChildFragment(context, attrs);
builder.setSummaryOn(summary)
diff --git a/src/com/android/settings/security/EncryptionAndCredential.java b/src/com/android/settings/security/EncryptionAndCredential.java
index 301742b..62f5a0c 100644
--- a/src/com/android/settings/security/EncryptionAndCredential.java
+++ b/src/com/android/settings/security/EncryptionAndCredential.java
@@ -76,7 +76,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_encryption;
}
diff --git a/src/com/android/settings/security/LockscreenDashboardFragment.java b/src/com/android/settings/security/LockscreenDashboardFragment.java
index 6ff2ca1..df4ca30 100644
--- a/src/com/android/settings/security/LockscreenDashboardFragment.java
+++ b/src/com/android/settings/security/LockscreenDashboardFragment.java
@@ -71,7 +71,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_lockscreen;
}
diff --git a/src/com/android/settings/security/ScreenPinningSettings.java b/src/com/android/settings/security/ScreenPinningSettings.java
index 488e0c8..6e4856e 100644
--- a/src/com/android/settings/security/ScreenPinningSettings.java
+++ b/src/com/android/settings/security/ScreenPinningSettings.java
@@ -78,7 +78,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_screen_pinning;
}
diff --git a/src/com/android/settings/security/SecuritySettings.java b/src/com/android/settings/security/SecuritySettings.java
index 01c138a..31f1ec6 100644
--- a/src/com/android/settings/security/SecuritySettings.java
+++ b/src/com/android/settings/security/SecuritySettings.java
@@ -749,7 +749,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_security;
}
diff --git a/src/com/android/settings/security/trustagent/TrustAgentSettings.java b/src/com/android/settings/security/trustagent/TrustAgentSettings.java
index c7001a0..b7f89ba 100644
--- a/src/com/android/settings/security/trustagent/TrustAgentSettings.java
+++ b/src/com/android/settings/security/trustagent/TrustAgentSettings.java
@@ -79,7 +79,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_trust_agent;
}
diff --git a/src/com/android/settings/support/actionbar/HelpMenuController.java b/src/com/android/settings/support/actionbar/HelpMenuController.java
new file mode 100644
index 0000000..a95d44e
--- /dev/null
+++ b/src/com/android/settings/support/actionbar/HelpMenuController.java
@@ -0,0 +1,67 @@
+/*
+ * 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.support.actionbar;
+
+import static com.android.settings.support.actionbar.HelpResourceProvider.HELP_URI_RESOURCE_KEY;
+
+import android.annotation.NonNull;
+import android.app.Activity;
+import android.app.Fragment;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuInflater;
+
+import com.android.settingslib.HelpUtils;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.ObservablePreferenceFragment;
+import com.android.settingslib.core.lifecycle.events.OnCreateOptionsMenu;
+
+/**
+ * A controller that adds help menu to any Settings page.
+ */
+public class HelpMenuController implements LifecycleObserver, OnCreateOptionsMenu {
+
+ private final Fragment mHost;
+
+ public static void init(@NonNull ObservablePreferenceFragment host) {
+ host.getLifecycle().addObserver(new HelpMenuController(host));
+ }
+
+ private HelpMenuController(@NonNull Fragment host) {
+ mHost = host;
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ final Bundle arguments = mHost.getArguments();
+ int helpResourceId = 0;
+ if (arguments != null && arguments.containsKey(HELP_URI_RESOURCE_KEY)) {
+ helpResourceId = arguments.getInt(HELP_URI_RESOURCE_KEY);
+ } else if (mHost instanceof HelpResourceProvider) {
+ helpResourceId = ((HelpResourceProvider) mHost).getHelpResource();
+ }
+
+ String helpUri = null;
+ if (helpResourceId != 0) {
+ helpUri = mHost.getContext().getString(helpResourceId);
+ }
+ final Activity activity = mHost.getActivity();
+ if (helpUri != null && activity != null) {
+ HelpUtils.prepareHelpMenuItem(activity, menu, helpUri, mHost.getClass().getName());
+ }
+ }
+}
diff --git a/src/com/android/settings/support/actionbar/HelpResourceProvider.java b/src/com/android/settings/support/actionbar/HelpResourceProvider.java
new file mode 100644
index 0000000..2898986
--- /dev/null
+++ b/src/com/android/settings/support/actionbar/HelpResourceProvider.java
@@ -0,0 +1,36 @@
+/*
+ * 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.support.actionbar;
+
+import com.android.settings.R;
+
+public interface HelpResourceProvider {
+ /**
+ * The Help Uri Resource key. This can be passed as an extra argument when creating the
+ * Fragment.
+ **/
+ String HELP_URI_RESOURCE_KEY = "help_uri_resource";
+
+ /**
+ * Override this if you want to show a help item in the menu, by returning the resource id.
+ *
+ * @return the resource id for the help url
+ */
+ default int getHelpResource() {
+ return R.string.help_uri_default;
+ }
+}
diff --git a/src/com/android/settings/system/SystemDashboardFragment.java b/src/com/android/settings/system/SystemDashboardFragment.java
index 2485cce..c01bfcc 100644
--- a/src/com/android/settings/system/SystemDashboardFragment.java
+++ b/src/com/android/settings/system/SystemDashboardFragment.java
@@ -56,7 +56,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_system_dashboard;
}
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index 9f510d2..834166b 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -923,7 +923,7 @@
for (int userId : values[0]) {
Bitmap bitmap = mUserManager.getUserIcon(userId);
if (bitmap == null) {
- bitmap = getDefaultUserIconAsBitmap(userId);
+ bitmap = getDefaultUserIconAsBitmap(getContext().getResources(), userId);
}
mUserIcons.append(userId, bitmap);
}
@@ -934,7 +934,8 @@
private Drawable getEncircledDefaultIcon() {
if (mDefaultIconDrawable == null) {
- mDefaultIconDrawable = encircle(getDefaultUserIconAsBitmap(UserHandle.USER_NULL));
+ mDefaultIconDrawable = encircle(
+ getDefaultUserIconAsBitmap(getContext().getResources(), UserHandle.USER_NULL));
}
return mDefaultIconDrawable;
}
@@ -1038,14 +1039,16 @@
* Returns a default user icon (as a {@link Bitmap}) for the given user.
*
* Note that for guest users, you should pass in {@code UserHandle.USER_NULL}.
+ * @param resources resources object to fetch the user icon.
* @param userId the user id or {@code UserHandle.USER_NULL} for a non-user specific icon
*/
- private static Bitmap getDefaultUserIconAsBitmap(int userId) {
+ private static Bitmap getDefaultUserIconAsBitmap(Resources resources, int userId) {
Bitmap bitmap = null;
// Try finding the corresponding bitmap in the dark bitmap cache
bitmap = sDarkDefaultUserBitmapCache.get(userId);
if (bitmap == null) {
- bitmap = UserIcons.convertToBitmap(UserIcons.getDefaultUserIcon(userId, false));
+ bitmap = UserIcons.convertToBitmap(
+ UserIcons.getDefaultUserIcon(resources, userId, false));
// Save it to cache
sDarkDefaultUserBitmapCache.put(userId, bitmap);
}
@@ -1064,7 +1067,7 @@
return false;
}
UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
- Bitmap bitmap = getDefaultUserIconAsBitmap(userId);
+ Bitmap bitmap = getDefaultUserIconAsBitmap(context.getResources(), userId);
um.setUserIcon(userId, bitmap);
return true;
diff --git a/src/com/android/settings/vpn2/VpnSettings.java b/src/com/android/settings/vpn2/VpnSettings.java
index d40441f..0a3bfe6 100644
--- a/src/com/android/settings/vpn2/VpnSettings.java
+++ b/src/com/android/settings/vpn2/VpnSettings.java
@@ -401,7 +401,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_vpn;
}
diff --git a/src/com/android/settings/wallpaper/WallpaperTypeSettings.java b/src/com/android/settings/wallpaper/WallpaperTypeSettings.java
index a87249e..1ff1faa 100644
--- a/src/com/android/settings/wallpaper/WallpaperTypeSettings.java
+++ b/src/com/android/settings/wallpaper/WallpaperTypeSettings.java
@@ -43,7 +43,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_uri_wallpaper;
}
diff --git a/src/com/android/settings/wfd/WifiDisplaySettings.java b/src/com/android/settings/wfd/WifiDisplaySettings.java
index 3fe438f..7a9fc39 100755
--- a/src/com/android/settings/wfd/WifiDisplaySettings.java
+++ b/src/com/android/settings/wfd/WifiDisplaySettings.java
@@ -36,7 +36,7 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
-import android.os.ServiceManager;
+import android.provider.SearchIndexableResource;
import android.provider.Settings;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.ListPreference;
@@ -63,6 +63,11 @@
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.dashboard.SummaryLoader;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
+
+import java.util.ArrayList;
+import java.util.List;
/**
* The Settings screen for WifiDisplay configuration and connection management.
@@ -72,7 +77,7 @@
* on the system. In that case, the enable option will not be shown but other
* remote display routes will continue to be made available.
*/
-public final class WifiDisplaySettings extends SettingsPreferenceFragment {
+public final class WifiDisplaySettings extends SettingsPreferenceFragment implements Indexable {
private static final String TAG = "WifiDisplaySettings";
private static final boolean DEBUG = false;
@@ -136,7 +141,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_remote_display;
}
@@ -823,4 +828,18 @@
public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
= (activity, summaryLoader) -> new SummaryProvider(activity, summaryLoader);
+
+ public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider() {
+ @Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
+ boolean enabled) {
+ final ArrayList<SearchIndexableResource> result = new ArrayList<>();
+
+ final SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.wifi_display_settings;
+ result.add(sir);
+ return result;
+ }
+ };
}
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index cc48064..30b6d96 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -1071,7 +1071,7 @@
}
@Override
- protected int getHelpResource() {
+ public int getHelpResource() {
return R.string.help_url_wifi;
}
diff --git a/tests/robotests/assets/grandfather_not_implementing_index_provider b/tests/robotests/assets/grandfather_not_implementing_index_provider
index 6704fc3..4d5b256 100644
--- a/tests/robotests/assets/grandfather_not_implementing_index_provider
+++ b/tests/robotests/assets/grandfather_not_implementing_index_provider
@@ -1,3 +1,4 @@
+com.android.settings.applications.AppInfoDashboardFragment
com.android.settings.bluetooth.DevicePickerFragment
com.android.settings.bluetooth.BluetoothDeviceDetailsFragment
com.android.settings.bluetooth.BluetoothPairingDetail
@@ -19,4 +20,6 @@
com.android.settings.enterprise.ApplicationListFragment$EnterpriseInstalledPackages
com.android.settings.enterprise.EnterpriseSetDefaultAppsListFragment
com.android.settings.wifi.tether.WifiTetherSettings
-com.android.settings.wifi.SavedAccessPointsWifiSettings
\ No newline at end of file
+com.android.settings.wifi.SavedAccessPointsWifiSettings
+com.android.settings.notification.ZenModeEventRuleSettings
+com.android.settings.notification.ZenModeScheduleRuleSettings
diff --git a/tests/robotests/assets/grandfather_not_implementing_indexable b/tests/robotests/assets/grandfather_not_implementing_indexable
index 500a582..245d321 100644
--- a/tests/robotests/assets/grandfather_not_implementing_indexable
+++ b/tests/robotests/assets/grandfather_not_implementing_indexable
@@ -9,7 +9,6 @@
com.android.settings.deviceinfo.ImeiInformation
com.android.settings.datausage.DataUsageList
com.android.settings.vpn2.AppManagementFragment
-com.android.settings.display.NightDisplaySettings
com.android.settings.vpn2.VpnSettings
com.android.settings.fingerprint.FingerprintSettings$FingerprintSettingsFragment
com.android.settings.applications.ProcessStatsDetail
@@ -47,10 +46,8 @@
com.android.settings.applications.ConfirmConvertToFbe
com.android.settings.deviceinfo.PublicVolumeSettings
com.android.settings.applications.InstalledAppDetails
-com.android.settings.applications.AppInfoDashboardFragment
com.android.settings.accessibility.ToggleAccessibilityServicePreferenceFragment
com.android.settings.print.PrintServiceSettingsFragment
-com.android.settings.wfd.WifiDisplaySettings
com.android.settings.deviceinfo.PrivateVolumeSettings
com.android.settings.users.AppRestrictionsFragment
com.android.settings.deviceinfo.PrivateVolumeUnmount
diff --git a/tests/robotests/res/values-mcc999/config.xml b/tests/robotests/res/values-mcc999/config.xml
index c2909ac..4113c90 100644
--- a/tests/robotests/res/values-mcc999/config.xml
+++ b/tests/robotests/res/values-mcc999/config.xml
@@ -15,7 +15,9 @@
-->
<resources>
+ <bool name="config_tintSettingIcon">false</bool>
<bool name="config_enableColorTemperature">false</bool>
<bool name="config_show_camera_laser_sensor">false</bool>
<bool name="config_show_connectivity_monitor">false</bool>
+ <bool name="config_display_recent_apps">false</bool>
</resources>
\ No newline at end of file
diff --git a/tests/robotests/res/values/config.xml b/tests/robotests/res/values/config.xml
index 9e2d911..4004106 100644
--- a/tests/robotests/res/values/config.xml
+++ b/tests/robotests/res/values/config.xml
@@ -20,4 +20,5 @@
<bool name="config_enableColorTemperature">true</bool>
<bool name="config_show_camera_laser_sensor">true</bool>
<bool name="config_show_connectivity_monitor">true</bool>
+ <bool name="config_display_recent_apps">true</bool>
</resources>
\ No newline at end of file
diff --git a/tests/robotests/res/values/themes.xml b/tests/robotests/res/values/themes.xml
index b91df65..74bdd9b 100644
--- a/tests/robotests/res/values/themes.xml
+++ b/tests/robotests/res/values/themes.xml
@@ -1,3 +1,7 @@
<resources>
- <style name="Theme.Settings" parent="@android:style/Theme.DeviceDefault.Settings"/>
+ <style name="Theme.Settings" parent="@android:style/Theme.DeviceDefault.Settings" />
+
+ <!-- Override the main app's style for ActionPrimaryButton to get around lack of new style
+ support in robolectric -->
+ <style name="ActionPrimaryButton" parent="android:Widget.DeviceDefault.Button" />
</resources>
diff --git a/tests/robotests/src/com/android/settings/DeviceInfoSettingsTest.java b/tests/robotests/src/com/android/settings/DeviceInfoSettingsTest.java
index 56343e2..0bd8933 100644
--- a/tests/robotests/src/com/android/settings/DeviceInfoSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/DeviceInfoSettingsTest.java
@@ -18,9 +18,7 @@
import static com.android.settings.DeviceInfoSettings.NON_SIM_PREFERENCES_COUNT;
import static com.android.settings.DeviceInfoSettings.SIM_PREFERENCES_COUNT;
-
import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
@@ -34,10 +32,10 @@
import android.support.v7.preference.PreferenceScreen;
import android.telephony.TelephonyManager;
import android.util.FeatureFlagUtils;
-import android.view.View;
import com.android.settings.core.FeatureFlags;
import com.android.settings.dashboard.SummaryLoader;
+import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.XmlTestUtils;
import com.android.settings.testutils.shadow.SettingsShadowResources;
@@ -54,7 +52,6 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
-import org.robolectric.util.ReflectionHelpers;
import java.util.List;
@@ -81,6 +78,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
+ FakeFeatureFactory.setupForTest();
mContext = RuntimeEnvironment.application;
mSettings = spy(new DeviceInfoSettings());
diff --git a/tests/robotests/src/com/android/settings/SettingsPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/SettingsPreferenceFragmentTest.java
index c84c1c6..788d185 100644
--- a/tests/robotests/src/com/android/settings/SettingsPreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/SettingsPreferenceFragmentTest.java
@@ -42,6 +42,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResources;
@@ -64,6 +65,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
+ FakeFeatureFactory.setupForTest();
mContext = RuntimeEnvironment.application;
mFragment = spy(new TestFragment());
doReturn(mActivity).when(mFragment).getActivity();
diff --git a/tests/robotests/src/com/android/settings/applications/AppAndNotificationDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/applications/AppAndNotificationDashboardFragmentTest.java
index 5a798f9..55141f7 100644
--- a/tests/robotests/src/com/android/settings/applications/AppAndNotificationDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppAndNotificationDashboardFragmentTest.java
@@ -16,32 +16,35 @@
package com.android.settings.applications;
-import android.content.Context;
+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.when;
+
+import android.content.Context;
import android.os.UserManager;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+import com.android.settings.notification.EmergencyBroadcastPreferenceController;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.XmlTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
-import org.robolectric.util.ReflectionHelpers;
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
import java.util.List;
-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.when;
-
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AppAndNotificationDashboardFragmentTest {
@Test
+ @Config(shadows = {ShadowEmergencyBroadcastPreferenceController.class})
public void testNonIndexableKeys_existInXmlLayout() {
final Context context = spy(RuntimeEnvironment.application);
UserManager manager = mock(UserManager.class);
@@ -56,4 +59,13 @@
assertThat(keys).containsAllIn(niks);
}
+
+ @Implements(EmergencyBroadcastPreferenceController.class)
+ public static class ShadowEmergencyBroadcastPreferenceController {
+
+ @Implementation
+ public boolean isAvailable() {
+ return true;
+ }
+ }
}
diff --git a/tests/robotests/src/com/android/settings/applications/AppInfoDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/applications/AppInfoDashboardFragmentTest.java
new file mode 100644
index 0000000..3462467
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/applications/AppInfoDashboardFragmentTest.java
@@ -0,0 +1,459 @@
+/*
+ * 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.applications;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.nullable;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.AlertDialog;
+import android.app.AppOpsManager;
+import android.app.Fragment;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.content.res.Resources;
+import android.os.UserManager;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceManager;
+import android.support.v7.preference.PreferenceScreen;
+import android.view.View;
+
+import com.android.settings.R;
+import com.android.settings.SettingsActivity;
+import com.android.settings.TestConfig;
+import com.android.settings.applications.instantapps.InstantAppButtonsController;
+import com.android.settings.applications.instantapps.InstantAppButtonsController.ShowDialogDelegate;
+import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.widget.ActionButtonPreferenceTest;
+import com.android.settings.wrapper.DevicePolicyManagerWrapper;
+import com.android.settingslib.Utils;
+import com.android.settingslib.applications.AppUtils;
+import com.android.settingslib.applications.ApplicationsState.AppEntry;
+import com.android.settingslib.applications.instantapps.InstantAppDataProvider;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+import org.robolectric.util.ReflectionHelpers;
+
+import java.util.HashSet;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(
+ manifest = TestConfig.MANIFEST_PATH,
+ sdk = TestConfig.SDK_VERSION_O,
+ shadows = AppInfoDashboardFragmentTest.ShadowUtils.class
+)
+public final class AppInfoDashboardFragmentTest {
+
+ private static final String PACKAGE_NAME = "test_package_name";
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private Context mContext;
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private UserManager mUserManager;
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private SettingsActivity mActivity;
+ @Mock
+ private DevicePolicyManagerWrapper mDevicePolicyManager;
+ @Mock
+ private PackageManager mPackageManager;
+ @Mock
+ private AppOpsManager mAppOpsManager;
+
+ private FakeFeatureFactory mFeatureFactory;
+ private AppInfoDashboardFragment mAppDetail;
+ private Context mShadowContext;
+
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mFeatureFactory = FakeFeatureFactory.setupForTest(mContext);
+ mShadowContext = RuntimeEnvironment.application;
+ mAppDetail = spy(new AppInfoDashboardFragment());
+ doReturn(mActivity).when(mAppDetail).getActivity();
+ doReturn(mShadowContext).when(mAppDetail).getContext();
+ doReturn(mPackageManager).when(mActivity).getPackageManager();
+ doReturn(mAppOpsManager).when(mActivity).getSystemService(Context.APP_OPS_SERVICE);
+ mAppDetail.mActionButtons = ActionButtonPreferenceTest.createMock();
+
+ // Default to not considering any apps to be instant (individual tests can override this).
+ ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
+ (InstantAppDataProvider) (i -> false));
+ }
+
+ @Test
+ public void shouldShowUninstallForAll_installForOneOtherUserOnly_shouldReturnTrue() {
+ when(mDevicePolicyManager.packageHasActiveAdmins(nullable(String.class))).thenReturn(false);
+ when(mUserManager.getUsers().size()).thenReturn(2);
+ ReflectionHelpers.setField(mAppDetail, "mDpm", mDevicePolicyManager);
+ ReflectionHelpers.setField(mAppDetail, "mUserManager", mUserManager);
+ final ApplicationInfo info = new ApplicationInfo();
+ info.enabled = true;
+ final AppEntry appEntry = mock(AppEntry.class);
+ appEntry.info = info;
+ final PackageInfo packageInfo = mock(PackageInfo.class);
+ ReflectionHelpers.setField(mAppDetail, "mPackageInfo", packageInfo);
+
+ assertThat(mAppDetail.shouldShowUninstallForAll(appEntry)).isTrue();
+ }
+
+ @Test
+ public void shouldShowUninstallForAll_installForSelfOnly_shouldReturnFalse() {
+ when(mDevicePolicyManager.packageHasActiveAdmins(nullable(String.class))).thenReturn(false);
+ when(mUserManager.getUsers().size()).thenReturn(2);
+ ReflectionHelpers.setField(mAppDetail, "mDpm", mDevicePolicyManager);
+ ReflectionHelpers.setField(mAppDetail, "mUserManager", mUserManager);
+ final ApplicationInfo info = new ApplicationInfo();
+ info.flags = ApplicationInfo.FLAG_INSTALLED;
+ info.enabled = true;
+ final AppEntry appEntry = mock(AppEntry.class);
+ appEntry.info = info;
+ final PackageInfo packageInfo = mock(PackageInfo.class);
+ ReflectionHelpers.setField(mAppDetail, "mPackageInfo", packageInfo);
+
+ assertThat(mAppDetail.shouldShowUninstallForAll(appEntry)).isFalse();
+ }
+
+ @Test
+ public void launchFragment_hasNoPackageInfo_shouldFinish() {
+ ReflectionHelpers.setField(mAppDetail, "mPackageInfo", null);
+
+ assertThat(mAppDetail.ensurePackageInfoAvailable(mActivity)).isFalse();
+ verify(mActivity).finishAndRemoveTask();
+ }
+
+ @Test
+ public void launchFragment_hasPackageInfo_shouldReturnTrue() {
+ final PackageInfo packageInfo = mock(PackageInfo.class);
+ ReflectionHelpers.setField(mAppDetail, "mPackageInfo", packageInfo);
+
+ assertThat(mAppDetail.ensurePackageInfoAvailable(mActivity)).isTrue();
+ verify(mActivity, never()).finishAndRemoveTask();
+ }
+
+ @Test
+ public void packageSizeChange_isOtherPackage_shouldNotRefreshUi() {
+ ReflectionHelpers.setField(mAppDetail, "mPackageName", PACKAGE_NAME);
+ mAppDetail.onPackageSizeChanged("Not_" + PACKAGE_NAME);
+
+ verify(mAppDetail, never()).refreshUi();
+ }
+
+ @Test
+ public void packageSizeChange_isOwnPackage_shouldRefreshUi() {
+ doReturn(Boolean.TRUE).when(mAppDetail).refreshUi();
+ ReflectionHelpers.setField(mAppDetail, "mPackageName", PACKAGE_NAME);
+
+ mAppDetail.onPackageSizeChanged(PACKAGE_NAME);
+
+ verify(mAppDetail).refreshUi();
+ }
+
+ // Tests that we don't show the "uninstall for all users" button for instant apps.
+ @Test
+ public void instantApps_noUninstallForAllButton() {
+ // Make this app appear to be instant.
+ ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
+ (InstantAppDataProvider) (i -> true));
+ when(mDevicePolicyManager.packageHasActiveAdmins(nullable(String.class))).thenReturn(false);
+ when(mUserManager.getUsers().size()).thenReturn(2);
+
+ final ApplicationInfo info = new ApplicationInfo();
+ info.enabled = true;
+ final AppEntry appEntry = mock(AppEntry.class);
+ appEntry.info = info;
+ final PackageInfo packageInfo = mock(PackageInfo.class);
+
+ ReflectionHelpers.setField(mAppDetail, "mDpm", mDevicePolicyManager);
+ ReflectionHelpers.setField(mAppDetail, "mUserManager", mUserManager);
+ ReflectionHelpers.setField(mAppDetail, "mPackageInfo", packageInfo);
+
+ assertThat(mAppDetail.shouldShowUninstallForAll(appEntry)).isFalse();
+ }
+
+ // Tests that we don't show the uninstall button for instant apps"
+ @Test
+ public void instantApps_noUninstallButton() {
+ // Make this app appear to be instant.
+ ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
+ (InstantAppDataProvider) (i -> true));
+ final ApplicationInfo info = new ApplicationInfo();
+ info.flags = ApplicationInfo.FLAG_INSTALLED;
+ info.enabled = true;
+ final AppEntry appEntry = mock(AppEntry.class);
+ appEntry.info = info;
+ final PackageInfo packageInfo = mock(PackageInfo.class);
+ packageInfo.applicationInfo = info;
+
+ ReflectionHelpers.setField(mAppDetail, "mUserManager", mUserManager);
+ ReflectionHelpers.setField(mAppDetail, "mAppEntry", appEntry);
+ ReflectionHelpers.setField(mAppDetail, "mPackageInfo", packageInfo);
+
+ mAppDetail.initUninstallButtonForUserApp();
+ verify(mAppDetail.mActionButtons).setButton1Visible(false);
+ }
+
+ // Tests that we don't show the force stop button for instant apps (they aren't allowed to run
+ // when they aren't in the foreground).
+ @Test
+ public void instantApps_noForceStop() {
+ // Make this app appear to be instant.
+ ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
+ (InstantAppDataProvider) (i -> true));
+ final PackageInfo packageInfo = mock(PackageInfo.class);
+ final AppEntry appEntry = mock(AppEntry.class);
+ final ApplicationInfo info = new ApplicationInfo();
+ appEntry.info = info;
+
+ ReflectionHelpers.setField(mAppDetail, "mDpm", mDevicePolicyManager);
+ ReflectionHelpers.setField(mAppDetail, "mPackageInfo", packageInfo);
+ ReflectionHelpers.setField(mAppDetail, "mAppEntry", appEntry);
+
+ mAppDetail.checkForceStop();
+ verify(mAppDetail.mActionButtons).setButton2Visible(false);
+ }
+
+ @Test
+ public void instantApps_buttonControllerHandlesDialog() {
+ InstantAppButtonsController mockController = mock(InstantAppButtonsController.class);
+ ReflectionHelpers.setField(
+ mAppDetail, "mInstantAppButtonsController", mockController);
+ // Make sure first that button controller is not called for supported dialog id
+ AlertDialog mockDialog = mock(AlertDialog.class);
+ when(mockController.createDialog(InstantAppButtonsController.DLG_CLEAR_APP))
+ .thenReturn(mockDialog);
+ assertThat(mAppDetail.createDialog(InstantAppButtonsController.DLG_CLEAR_APP, 0))
+ .isEqualTo(mockDialog);
+ verify(mockController).createDialog(InstantAppButtonsController.DLG_CLEAR_APP);
+ }
+
+ // A helper class for testing the InstantAppButtonsController - it lets us look up the
+ // preference associated with a key for instant app buttons and get back a mock
+ // LayoutPreference (to avoid a null pointer exception).
+ public static class InstalledAppDetailsWithMockInstantButtons extends InstalledAppDetails {
+ @Mock
+ private LayoutPreference mInstantButtons;
+
+ public InstalledAppDetailsWithMockInstantButtons() {
+ super();
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Override
+ public Preference findPreference(CharSequence key) {
+ if (key == "instant_app_buttons") {
+ return mInstantButtons;
+ }
+ return super.findPreference(key);
+ }
+ }
+
+ @Test
+ public void instantApps_instantSpecificButtons() {
+ // Make this app appear to be instant.
+ ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
+ (InstantAppDataProvider) (i -> true));
+ final PackageInfo packageInfo = mock(PackageInfo.class);
+
+ final InstalledAppDetailsWithMockInstantButtons
+ fragment = new InstalledAppDetailsWithMockInstantButtons();
+ ReflectionHelpers.setField(fragment, "mPackageInfo", packageInfo);
+ ReflectionHelpers.setField(fragment, "mApplicationFeatureProvider",
+ mFeatureFactory.applicationFeatureProvider);
+
+ final InstantAppButtonsController buttonsController =
+ mock(InstantAppButtonsController.class);
+ when(buttonsController.setPackageName(nullable(String.class)))
+ .thenReturn(buttonsController);
+ when(mFeatureFactory.applicationFeatureProvider.newInstantAppButtonsController(
+ nullable(Fragment.class), nullable(View.class), nullable(ShowDialogDelegate.class)))
+ .thenReturn(buttonsController);
+
+ fragment.maybeAddInstantAppButtons();
+ verify(buttonsController).setPackageName(nullable(String.class));
+ verify(buttonsController).show();
+ }
+
+ @Test
+ public void instantApps_removeCorrectPref() {
+ PreferenceScreen mockPreferenceScreen = mock(PreferenceScreen.class);
+ PreferenceManager mockPreferenceManager = mock(PreferenceManager.class);
+ AppDomainsPreference mockAppDomainsPref = mock(AppDomainsPreference.class);
+ PackageInfo mockPackageInfo = mock(PackageInfo.class);
+ PackageManager mockPackageManager = mock(PackageManager.class);
+ ReflectionHelpers.setField(
+ mAppDetail, "mInstantAppDomainsPreference", mockAppDomainsPref);
+ ReflectionHelpers.setField(
+ mAppDetail, "mPreferenceManager", mockPreferenceManager);
+ ReflectionHelpers.setField(
+ mAppDetail, "mPackageInfo", mockPackageInfo);
+ ReflectionHelpers.setField(
+ mAppDetail, "mPm", mockPackageManager);
+ when(mockPreferenceManager.getPreferenceScreen()).thenReturn(mockPreferenceScreen);
+
+ ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
+ (InstantAppDataProvider) (i -> false));
+ mAppDetail.prepareInstantAppPrefs();
+
+ // For the non instant case we remove the app domain pref, and leave the launch pref
+ verify(mockPreferenceScreen).removePreference(mockAppDomainsPref);
+
+ // For the instant app case we remove the launch preff, and leave the app domain pref
+ ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
+ (InstantAppDataProvider) (i -> true));
+
+ mAppDetail.prepareInstantAppPrefs();
+ // Will be 1 still due to above call
+ verify(mockPreferenceScreen, times(1))
+ .removePreference(mockAppDomainsPref);
+ }
+
+ @Test
+ public void onActivityResult_uninstalledUpdates_shouldInvalidateOptionsMenu() {
+ doReturn(true).when(mAppDetail).refreshUi();
+
+ mAppDetail.onActivityResult(InstalledAppDetails.REQUEST_UNINSTALL, 0, mock(Intent.class));
+
+ verify(mActivity).invalidateOptionsMenu();
+ }
+
+ @Test
+ public void handleDisableable_appIsHomeApp_buttonShouldNotWork() {
+ final ApplicationInfo info = new ApplicationInfo();
+ info.packageName = "pkg";
+ info.enabled = true;
+ final AppEntry appEntry = mock(AppEntry.class);
+ appEntry.info = info;
+ final HashSet<String> homePackages = new HashSet<>();
+ homePackages.add(info.packageName);
+
+ ReflectionHelpers.setField(mAppDetail, "mHomePackages", homePackages);
+ ReflectionHelpers.setField(mAppDetail, "mAppEntry", appEntry);
+
+ assertThat(mAppDetail.handleDisableable()).isFalse();
+ verify(mAppDetail.mActionButtons).setButton1Text(R.string.disable_text);
+ }
+
+ @Test
+ public void handleDisableable_appIsEnabled_buttonShouldWork() {
+ final ApplicationInfo info = new ApplicationInfo();
+ info.packageName = "pkg";
+ info.enabled = true;
+ info.enabledSetting = PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
+
+ final AppEntry appEntry = mock(AppEntry.class);
+ appEntry.info = info;
+ when(mFeatureFactory.applicationFeatureProvider.getKeepEnabledPackages()).thenReturn(
+ new HashSet<>());
+
+ ReflectionHelpers.setField(mAppDetail, "mApplicationFeatureProvider",
+ mFeatureFactory.applicationFeatureProvider);
+ ReflectionHelpers.setField(mAppDetail, "mAppEntry", appEntry);
+
+ assertThat(mAppDetail.handleDisableable()).isTrue();
+ verify(mAppDetail.mActionButtons).setButton1Text(R.string.disable_text);
+ }
+
+ @Test
+ @Config(shadows = ShadowUtils.class)
+ public void handleDisableable_appIsDisabled_buttonShouldShowEnable() {
+ final ApplicationInfo info = new ApplicationInfo();
+ info.packageName = "pkg";
+ info.enabled = false;
+ info.enabledSetting = PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
+
+ final AppEntry appEntry = mock(AppEntry.class);
+ appEntry.info = info;
+ when(mFeatureFactory.applicationFeatureProvider.getKeepEnabledPackages()).thenReturn(
+ new HashSet<>());
+
+ ReflectionHelpers.setField(mAppDetail, "mApplicationFeatureProvider",
+ mFeatureFactory.applicationFeatureProvider);
+ ReflectionHelpers.setField(mAppDetail, "mAppEntry", appEntry);
+
+ assertThat(mAppDetail.handleDisableable()).isTrue();
+ verify(mAppDetail.mActionButtons).setButton1Text(R.string.enable_text);
+ verify(mAppDetail.mActionButtons).setButton1Positive(true);
+ }
+
+ @Test
+ public void handleDisableable_appIsEnabledAndInKeepEnabledWhitelist_buttonShouldNotWork() {
+ final ApplicationInfo info = new ApplicationInfo();
+ info.packageName = "pkg";
+ info.enabled = true;
+ info.enabledSetting = PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
+
+ final AppEntry appEntry = mock(AppEntry.class);
+ appEntry.info = info;
+
+ final HashSet<String> packages = new HashSet<>();
+ packages.add(info.packageName);
+ when(mFeatureFactory.applicationFeatureProvider.getKeepEnabledPackages()).thenReturn(
+ packages);
+
+ ReflectionHelpers.setField(mAppDetail, "mApplicationFeatureProvider",
+ mFeatureFactory.applicationFeatureProvider);
+ ReflectionHelpers.setField(mAppDetail, "mAppEntry", appEntry);
+
+ assertThat(mAppDetail.handleDisableable()).isFalse();
+ verify(mAppDetail.mActionButtons).setButton1Text(R.string.disable_text);
+ }
+
+ @Test
+ public void initUninstallButtonForUserApp_shouldSetNegativeButton() {
+ final ApplicationInfo info = new ApplicationInfo();
+ info.flags = ApplicationInfo.FLAG_INSTALLED;
+ info.enabled = true;
+ final PackageInfo packageInfo = mock(PackageInfo.class);
+ packageInfo.applicationInfo = info;
+ ReflectionHelpers.setField(mAppDetail, "mUserManager", mUserManager);
+ ReflectionHelpers.setField(mAppDetail, "mPackageInfo", packageInfo);
+
+ mAppDetail.initUninstallButtonForUserApp();
+
+ verify(mAppDetail.mActionButtons).setButton1Positive(false);
+ }
+
+ @Implements(Utils.class)
+ public static class ShadowUtils {
+ @Implementation
+ public static boolean isSystemPackage(Resources resources, PackageManager pm,
+ PackageInfo pkg) {
+ return false;
+ }
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java b/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java
index 62395f3..75ae458 100644
--- a/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java
@@ -16,6 +16,13 @@
package com.android.settings.applications;
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -49,14 +56,8 @@
import org.robolectric.shadows.ShadowApplication;
import org.robolectric.util.ReflectionHelpers;
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = ShadowEntityHeaderController.class)
public class AppInfoWithHeaderTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/applications/AppPermissionsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/AppPermissionsPreferenceControllerTest.java
index 2e52214..b0f0d0c 100644
--- a/tests/robotests/src/com/android/settings/applications/AppPermissionsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppPermissionsPreferenceControllerTest.java
@@ -46,7 +46,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AppPermissionsPreferenceControllerTest {
private static final String PERM_LOCATION = "android.permission-group.LOCATION";
diff --git a/tests/robotests/src/com/android/settings/applications/AppStateAppOpsBridgeTest.java b/tests/robotests/src/com/android/settings/applications/AppStateAppOpsBridgeTest.java
index d63697e..6fadb43 100644
--- a/tests/robotests/src/com/android/settings/applications/AppStateAppOpsBridgeTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppStateAppOpsBridgeTest.java
@@ -37,7 +37,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class AppStateAppOpsBridgeTest {
@Mock private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/applications/AppStateInstallAppsBridgeTest.java b/tests/robotests/src/com/android/settings/applications/AppStateInstallAppsBridgeTest.java
index 62623e5..c88f878 100644
--- a/tests/robotests/src/com/android/settings/applications/AppStateInstallAppsBridgeTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppStateInstallAppsBridgeTest.java
@@ -28,7 +28,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AppStateInstallAppsBridgeTest {
@Test
diff --git a/tests/robotests/src/com/android/settings/applications/AppStorageSettingsTest.java b/tests/robotests/src/com/android/settings/applications/AppStorageSettingsTest.java
index 1f6aea4..d254074 100644
--- a/tests/robotests/src/com/android/settings/applications/AppStorageSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppStorageSettingsTest.java
@@ -45,7 +45,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AppStorageSettingsTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/applications/AppStorageSizesControllerTest.java b/tests/robotests/src/com/android/settings/applications/AppStorageSizesControllerTest.java
index 027bd33..62cb26c 100644
--- a/tests/robotests/src/com/android/settings/applications/AppStorageSizesControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppStorageSizesControllerTest.java
@@ -8,8 +8,10 @@
import android.content.Context;
import android.support.v7.preference.Preference;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.R;
import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.applications.StorageStatsSource.AppStorageStats;
import org.junit.Before;
import org.junit.Test;
@@ -18,11 +20,8 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
-import com.android.settings.R;
-import com.android.settingslib.applications.StorageStatsSource.AppStorageStats;
-
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AppStorageSizesControllerTest {
private static final String COMPUTING = "Computing…";
private static final String INVALID_SIZE = "Couldn’t compute package size.";
@@ -85,9 +84,9 @@
mController.setResult(result);
mController.updateUi(mContext);
- assertThat(mAppPreference.getSummary()).isEqualTo("1.00 B");
- assertThat(mCachePreference.getSummary()).isEqualTo("10.00 B");
- assertThat(mDataPreference.getSummary()).isEqualTo("90.00 B");
+ assertThat(mAppPreference.getSummary()).isEqualTo("1 B");
+ assertThat(mCachePreference.getSummary()).isEqualTo("10 B");
+ assertThat(mDataPreference.getSummary()).isEqualTo("90 B");
assertThat(mTotalPreference.getSummary()).isEqualTo("101 B");
}
@@ -103,10 +102,10 @@
mController.setCacheCleared(true);
mController.updateUi(mContext);
- assertThat(mAppPreference.getSummary()).isEqualTo("1.00 B");
- assertThat(mCachePreference.getSummary()).isEqualTo("0.00 B");
- assertThat(mDataPreference.getSummary()).isEqualTo("90.00 B");
- assertThat(mTotalPreference.getSummary()).isEqualTo("91.00 B");
+ assertThat(mAppPreference.getSummary()).isEqualTo("1 B");
+ assertThat(mCachePreference.getSummary()).isEqualTo("0 B");
+ assertThat(mDataPreference.getSummary()).isEqualTo("90 B");
+ assertThat(mTotalPreference.getSummary()).isEqualTo("91 B");
}
@Test
@@ -121,9 +120,9 @@
mController.setDataCleared(true);
mController.updateUi(mContext);
- assertThat(mAppPreference.getSummary()).isEqualTo("1.00 B");
- assertThat(mCachePreference.getSummary()).isEqualTo("0.00 B");
- assertThat(mDataPreference.getSummary()).isEqualTo("0.00 B");
- assertThat(mTotalPreference.getSummary()).isEqualTo("1.00 B");
+ assertThat(mAppPreference.getSummary()).isEqualTo("1 B");
+ assertThat(mCachePreference.getSummary()).isEqualTo("0 B");
+ assertThat(mDataPreference.getSummary()).isEqualTo("0 B");
+ assertThat(mTotalPreference.getSummary()).isEqualTo("1 B");
}
}
diff --git a/tests/robotests/src/com/android/settings/applications/AppWithAdminGrantedPermissionsCounterTest.java b/tests/robotests/src/com/android/settings/applications/AppWithAdminGrantedPermissionsCounterTest.java
index 33d261f..eb3d94f 100644
--- a/tests/robotests/src/com/android/settings/applications/AppWithAdminGrantedPermissionsCounterTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppWithAdminGrantedPermissionsCounterTest.java
@@ -56,7 +56,7 @@
* Tests for {@link InstalledAppCounter}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class AppWithAdminGrantedPermissionsCounterTest {
private final String APP_1 = "app1";
diff --git a/tests/robotests/src/com/android/settings/applications/AppWithAdminGrantedPermissionsListerTest.java b/tests/robotests/src/com/android/settings/applications/AppWithAdminGrantedPermissionsListerTest.java
index 2e9328a..d7c8059 100644
--- a/tests/robotests/src/com/android/settings/applications/AppWithAdminGrantedPermissionsListerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppWithAdminGrantedPermissionsListerTest.java
@@ -55,7 +55,7 @@
* Tests for {@link AppWithAdminGrantedPermissionsLister}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class AppWithAdminGrantedPermissionsListerTest {
private final String APP_1 = "app1";
diff --git a/tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java
index e5b7a66..dad02ef 100644
--- a/tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java
@@ -55,7 +55,7 @@
* Tests for {@link ApplicationFeatureProviderImpl}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = {ShadowUserManager.class})
public final class ApplicationFeatureProviderImplTest {
diff --git a/tests/robotests/src/com/android/settings/applications/DefaultAppSettingsTest.java b/tests/robotests/src/com/android/settings/applications/DefaultAppSettingsTest.java
index 9441707..78ec265 100644
--- a/tests/robotests/src/com/android/settings/applications/DefaultAppSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/DefaultAppSettingsTest.java
@@ -52,7 +52,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DefaultAppSettingsTest {
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/applications/DrawOverlayDetailsTest.java b/tests/robotests/src/com/android/settings/applications/DrawOverlayDetailsTest.java
index 5d20a4c..38c0128 100644
--- a/tests/robotests/src/com/android/settings/applications/DrawOverlayDetailsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/DrawOverlayDetailsTest.java
@@ -46,7 +46,7 @@
import org.robolectric.shadows.ShadowApplication;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DrawOverlayDetailsTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/applications/EnterpriseDefaultAppsTest.java b/tests/robotests/src/com/android/settings/applications/EnterpriseDefaultAppsTest.java
index 10caf13..8014dbb 100644
--- a/tests/robotests/src/com/android/settings/applications/EnterpriseDefaultAppsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/EnterpriseDefaultAppsTest.java
@@ -27,7 +27,7 @@
import static junit.framework.Assert.assertTrue;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class EnterpriseDefaultAppsTest {
@Test
public void testNumberOfIntentsCorrelateWithUI() throws Exception {
diff --git a/tests/robotests/src/com/android/settings/applications/FetchPackageStorageAsyncLoaderTest.java b/tests/robotests/src/com/android/settings/applications/FetchPackageStorageAsyncLoaderTest.java
index 3269acb..d34b2eb 100644
--- a/tests/robotests/src/com/android/settings/applications/FetchPackageStorageAsyncLoaderTest.java
+++ b/tests/robotests/src/com/android/settings/applications/FetchPackageStorageAsyncLoaderTest.java
@@ -44,7 +44,7 @@
import java.io.IOException;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class FetchPackageStorageAsyncLoaderTest {
private static final String PACKAGE_NAME = "com.test.package";
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/applications/InstalledAppCounterTest.java b/tests/robotests/src/com/android/settings/applications/InstalledAppCounterTest.java
index 58c4386..def8758 100644
--- a/tests/robotests/src/com/android/settings/applications/InstalledAppCounterTest.java
+++ b/tests/robotests/src/com/android/settings/applications/InstalledAppCounterTest.java
@@ -61,7 +61,7 @@
* Tests for {@link InstalledAppCounter}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = {ShadowUserManager.class})
public final class InstalledAppCounterTest {
diff --git a/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java b/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java
index 58a9577..b8a27b9 100644
--- a/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java
@@ -17,6 +17,7 @@
package com.android.settings.applications;
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.anyDouble;
import static org.mockito.Matchers.anyInt;
@@ -83,9 +84,9 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(
- manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
- shadows = InstalledAppDetailsTest.ShadowUtils.class
+ manifest = TestConfig.MANIFEST_PATH,
+ sdk = TestConfig.SDK_VERSION_O,
+ shadows = InstalledAppDetailsTest.ShadowUtils.class
)
public final class InstalledAppDetailsTest {
@@ -192,7 +193,7 @@
when(stats.getTotalBytes()).thenReturn(1L);
assertThat(InstalledAppDetails.getStorageSummary(context, stats, true))
- .isEqualTo("1.00 B used in external storage");
+ .isEqualTo("1 B used in external storage");
}
@Test
@@ -202,7 +203,7 @@
when(stats.getTotalBytes()).thenReturn(1L);
assertThat(InstalledAppDetails.getStorageSummary(context, stats, false))
- .isEqualTo("1.00 B used in internal storage");
+ .isEqualTo("1 B used in internal storage");
}
@Test
diff --git a/tests/robotests/src/com/android/settings/applications/InstalledAppListerTest.java b/tests/robotests/src/com/android/settings/applications/InstalledAppListerTest.java
index c74deae..6a5cfeb 100644
--- a/tests/robotests/src/com/android/settings/applications/InstalledAppListerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/InstalledAppListerTest.java
@@ -57,7 +57,7 @@
* Tests for {@link InstalledAppLister}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class InstalledAppListerTest {
private final String APP_1 = "app1";
diff --git a/tests/robotests/src/com/android/settings/applications/NotificationAppsTest.java b/tests/robotests/src/com/android/settings/applications/NotificationAppsTest.java
index 11d757f..735a811 100644
--- a/tests/robotests/src/com/android/settings/applications/NotificationAppsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/NotificationAppsTest.java
@@ -49,7 +49,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class NotificationAppsTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/applications/PictureInPictureDetailsTest.java b/tests/robotests/src/com/android/settings/applications/PictureInPictureDetailsTest.java
index 02b8c7a..b998b81e 100644
--- a/tests/robotests/src/com/android/settings/applications/PictureInPictureDetailsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/PictureInPictureDetailsTest.java
@@ -39,7 +39,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class PictureInPictureDetailsTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/applications/PictureInPictureSettingsTest.java b/tests/robotests/src/com/android/settings/applications/PictureInPictureSettingsTest.java
index d379dbd..85b398a 100644
--- a/tests/robotests/src/com/android/settings/applications/PictureInPictureSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/PictureInPictureSettingsTest.java
@@ -51,7 +51,7 @@
import java.util.Collections;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class PictureInPictureSettingsTest {
private static final int PRIMARY_USER_ID = 0;
diff --git a/tests/robotests/src/com/android/settings/applications/PremiumSmsAccessTest.java b/tests/robotests/src/com/android/settings/applications/PremiumSmsAccessTest.java
index 30ebcde..dedb61d 100644
--- a/tests/robotests/src/com/android/settings/applications/PremiumSmsAccessTest.java
+++ b/tests/robotests/src/com/android/settings/applications/PremiumSmsAccessTest.java
@@ -38,7 +38,7 @@
import org.robolectric.shadows.ShadowApplication;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class PremiumSmsAccessTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/applications/RecentAppsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/RecentAppsPreferenceControllerTest.java
index 5e85f9b..d0d8a3b 100644
--- a/tests/robotests/src/com/android/settings/applications/RecentAppsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/RecentAppsPreferenceControllerTest.java
@@ -16,13 +16,30 @@
package com.android.settings.applications;
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.argThat;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
import android.app.Application;
import android.app.usage.UsageStats;
import android.app.usage.UsageStatsManager;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
-import android.content.res.Configuration;
import android.os.UserHandle;
import android.os.UserManager;
import android.support.v7.preference.Preference;
@@ -31,14 +48,13 @@
import android.text.TextUtils;
import com.android.settings.R;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settingslib.applications.ApplicationsState;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Answers;
import org.mockito.ArgumentMatcher;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -47,25 +63,9 @@
import java.util.ArrayList;
import java.util.List;
-import java.util.Locale;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.anyLong;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.argThat;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class RecentAppsPreferenceControllerTest {
@Mock
@@ -76,14 +76,18 @@
private Preference mSeeAllPref;
@Mock
private PreferenceCategory mDivider;
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mMockContext;
@Mock
private UsageStatsManager mUsageStatsManager;
@Mock
private UserManager mUserManager;
@Mock
private ApplicationsState mAppState;
+ @Mock
+ private PackageManager mPackageManager;
+ @Mock
+ private ApplicationsState.AppEntry mAppEntry;
+ @Mock
+ private ApplicationInfo mApplicationInfo;
private Context mContext;
private RecentAppsPreferenceController mController;
@@ -91,12 +95,11 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- when(mMockContext.getSystemService(Context.USAGE_STATS_SERVICE))
- .thenReturn(mUsageStatsManager);
- when(mMockContext.getSystemService(Context.USER_SERVICE))
- .thenReturn(mUserManager);
+ mContext = spy(RuntimeEnvironment.application);
+ doReturn(mUsageStatsManager).when(mContext).getSystemService(Context.USAGE_STATS_SERVICE);
+ doReturn(mUserManager).when(mContext).getSystemService(Context.USER_SERVICE);
+ doReturn(mPackageManager).when(mContext).getPackageManager();
- mContext = RuntimeEnvironment.application;
mController = new RecentAppsPreferenceController(mContext, mAppState, null);
when(mScreen.findPreference(anyString())).thenReturn(mCategory);
@@ -125,7 +128,7 @@
@Test
public void onDisplayAndUpdateState_shouldRefreshUi() {
mController = spy(
- new RecentAppsPreferenceController(mMockContext, (Application) null, null));
+ new RecentAppsPreferenceController(mContext, (Application) null, null));
doNothing().when(mController).refreshUi(mContext);
@@ -136,11 +139,8 @@
}
@Test
+ @Config(qualifiers = "mcc999")
public void display_shouldNotShowRecents_showAppInfoPreference() {
- mController = new RecentAppsPreferenceController(mMockContext, mAppState, null);
- when(mMockContext.getResources().getBoolean(R.bool.config_display_recent_apps))
- .thenReturn(false);
-
mController.displayPreference(mScreen);
verify(mCategory, never()).addPreference(any(Preference.class));
@@ -152,8 +152,6 @@
@Test
public void display_showRecents() {
- when(mMockContext.getResources().getBoolean(R.bool.config_display_recent_apps))
- .thenReturn(true);
final List<UsageStats> stats = new ArrayList<>();
final UsageStats stat1 = new UsageStats();
final UsageStats stat2 = new UsageStats();
@@ -172,20 +170,17 @@
// stat1, stat2 are valid apps. stat3 is invalid.
when(mAppState.getEntry(stat1.mPackageName, UserHandle.myUserId()))
- .thenReturn(mock(ApplicationsState.AppEntry.class));
+ .thenReturn(mAppEntry);
when(mAppState.getEntry(stat2.mPackageName, UserHandle.myUserId()))
- .thenReturn(mock(ApplicationsState.AppEntry.class));
+ .thenReturn(mAppEntry);
when(mAppState.getEntry(stat3.mPackageName, UserHandle.myUserId()))
.thenReturn(null);
- when(mMockContext.getPackageManager().resolveActivity(any(Intent.class), anyInt()))
- .thenReturn(new ResolveInfo());
+ when(mPackageManager.resolveActivity(any(Intent.class), anyInt())).thenReturn(
+ new ResolveInfo());
when(mUsageStatsManager.queryUsageStats(anyInt(), anyLong(), anyLong()))
.thenReturn(stats);
- final Configuration configuration = new Configuration();
- configuration.locale = Locale.US;
- when(mMockContext.getResources().getConfiguration()).thenReturn(configuration);
+ mAppEntry.info = mApplicationInfo;
- mController = new RecentAppsPreferenceController(mMockContext, mAppState, null);
mController.displayPreference(mScreen);
verify(mCategory).setTitle(R.string.recent_app_category_title);
@@ -200,8 +195,6 @@
@Test
public void display_hasRecentButNoneDisplayable_showAppInfo() {
- when(mMockContext.getResources().getBoolean(R.bool.config_display_recent_apps))
- .thenReturn(true);
final List<UsageStats> stats = new ArrayList<>();
final UsageStats stat1 = new UsageStats();
final UsageStats stat2 = new UsageStats();
@@ -218,12 +211,11 @@
.thenReturn(mock(ApplicationsState.AppEntry.class));
when(mAppState.getEntry(stat2.mPackageName, UserHandle.myUserId()))
.thenReturn(mock(ApplicationsState.AppEntry.class));
- when(mMockContext.getPackageManager().resolveActivity(any(Intent.class), anyInt()))
- .thenReturn(new ResolveInfo());
+ when(mPackageManager.resolveActivity(any(Intent.class), anyInt())).thenReturn(
+ new ResolveInfo());
when(mUsageStatsManager.queryUsageStats(anyInt(), anyLong(), anyLong()))
.thenReturn(stats);
- mController = new RecentAppsPreferenceController(mMockContext, mAppState, null);
mController.displayPreference(mScreen);
verify(mCategory, never()).addPreference(any(Preference.class));
@@ -234,8 +226,6 @@
@Test
public void display_showRecents_formatSummary() {
- when(mMockContext.getResources().getBoolean(R.bool.config_display_recent_apps))
- .thenReturn(true);
final List<UsageStats> stats = new ArrayList<>();
final UsageStats stat1 = new UsageStats();
stat1.mLastTimeUsed = System.currentTimeMillis();
@@ -243,17 +233,13 @@
stats.add(stat1);
when(mAppState.getEntry(stat1.mPackageName, UserHandle.myUserId()))
- .thenReturn(mock(ApplicationsState.AppEntry.class));
- when(mMockContext.getPackageManager().resolveActivity(any(Intent.class), anyInt()))
- .thenReturn(new ResolveInfo());
+ .thenReturn(mAppEntry);
+ when(mPackageManager.resolveActivity(any(Intent.class), anyInt())).thenReturn(
+ new ResolveInfo());
when(mUsageStatsManager.queryUsageStats(anyInt(), anyLong(), anyLong()))
- .thenReturn(stats);
+ .thenReturn(stats);
+ mAppEntry.info = mApplicationInfo;
- final Configuration configuration = new Configuration();
- configuration.locale = Locale.US;
- when(mMockContext.getResources().getConfiguration()).thenReturn(configuration);
-
- mController = new RecentAppsPreferenceController(mMockContext, mAppState, null);
mController.displayPreference(mScreen);
verify(mCategory).addPreference(argThat(summaryMatches("0 min. ago")));
diff --git a/tests/robotests/src/com/android/settings/applications/SpecialAppAccessPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/SpecialAppAccessPreferenceControllerTest.java
index f17addd..09bfc29 100644
--- a/tests/robotests/src/com/android/settings/applications/SpecialAppAccessPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/SpecialAppAccessPreferenceControllerTest.java
@@ -36,7 +36,7 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SpecialAppAccessPreferenceControllerTest {
private Context mContext;
@Mock
diff --git a/tests/robotests/src/com/android/settings/applications/UsageAccessDetailsTest.java b/tests/robotests/src/com/android/settings/applications/UsageAccessDetailsTest.java
index 1a3aeb5..64ef4ff 100644
--- a/tests/robotests/src/com/android/settings/applications/UsageAccessDetailsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/UsageAccessDetailsTest.java
@@ -41,7 +41,7 @@
import org.robolectric.shadows.ShadowApplication;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class UsageAccessDetailsTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/applications/VrListenerSettingsTest.java b/tests/robotests/src/com/android/settings/applications/VrListenerSettingsTest.java
index d2f1bbd..5f9ec95 100644
--- a/tests/robotests/src/com/android/settings/applications/VrListenerSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/VrListenerSettingsTest.java
@@ -36,7 +36,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class VrListenerSettingsTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/applications/WriteSettingsDetailsTest.java b/tests/robotests/src/com/android/settings/applications/WriteSettingsDetailsTest.java
index a995394..6cd07e3 100644
--- a/tests/robotests/src/com/android/settings/applications/WriteSettingsDetailsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/WriteSettingsDetailsTest.java
@@ -36,7 +36,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class WriteSettingsDetailsTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppBatteryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppBatteryPreferenceControllerTest.java
new file mode 100644
index 0000000..065fe2b
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppBatteryPreferenceControllerTest.java
@@ -0,0 +1,198 @@
+/*
+ * 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.applications.appinfo;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.anyDouble;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.AppOpsManager;
+import android.app.LoaderManager;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.os.BatteryStats;
+import android.os.Bundle;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+
+import com.android.internal.os.BatterySipper;
+import com.android.internal.os.BatteryStatsHelper;
+import com.android.settings.SettingsActivity;
+import com.android.settings.TestConfig;
+import com.android.settings.applications.AppInfoDashboardFragment;
+import com.android.settings.fuelgauge.BatteryUtils;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
+public class AppBatteryPreferenceControllerTest {
+
+ private static final int TARGET_UID = 111;
+ private static final int OTHER_UID = 222;
+ private static final double BATTERY_LEVEL = 60;
+
+ @Mock
+ private SettingsActivity mActivity;
+ @Mock
+ private BatteryUtils mBatteryUtils;
+ @Mock
+ private BatterySipper mBatterySipper;
+ @Mock
+ private BatterySipper mOtherBatterySipper;
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private BatteryStatsHelper mBatteryStatsHelper;
+ @Mock
+ private BatteryStats.Uid mUid;
+ @Mock
+ private PreferenceScreen mScreen;
+ @Mock
+ private PackageManager mPackageManager;
+ @Mock
+ private LoaderManager mLoaderManager;
+
+ private Context mContext;
+ private AppInfoDashboardFragment mFragment;
+ private AppBatteryPreferenceController mController;
+ private Preference mBatteryPreference;
+
+ @Before
+ public void setUp() throws NameNotFoundException {
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(RuntimeEnvironment.application);
+ when(mContext.getPackageManager()).thenReturn(mPackageManager);
+
+ mFragment = spy(new AppInfoDashboardFragment());
+
+ mBatteryPreference = spy(new Preference(mContext));
+
+ mBatterySipper.drainType = BatterySipper.DrainType.IDLE;
+ mBatterySipper.uidObj = mUid;
+ doReturn(TARGET_UID).when(mBatterySipper).getUid();
+ doReturn(OTHER_UID).when(mOtherBatterySipper).getUid();
+
+ mController = spy(new AppBatteryPreferenceController(
+ mContext, mFragment, "package1", null /* lifecycle */));
+ mController.mBatteryUtils = mBatteryUtils;
+ when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mBatteryPreference);
+ }
+
+ @Test
+ public void getAvailabilityStatus_shouldAlwaysReturnAvailable() {
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(mController.AVAILABLE);
+ }
+
+ @Test
+ public void findTargetSipper_findCorrectSipper() {
+ final List<BatterySipper> usageList = new ArrayList<>();
+ usageList.add(mBatterySipper);
+ usageList.add(mOtherBatterySipper);
+ doReturn(usageList).when(mBatteryStatsHelper).getUsageList();
+
+ assertThat(mController.findTargetSipper(mBatteryStatsHelper, TARGET_UID)).isEqualTo(
+ mBatterySipper);
+ }
+
+ @Test
+ public void updateBattery_noBatteryStats_summaryNo() {
+ mController.displayPreference(mScreen);
+
+ mController.updateBattery();
+
+ assertThat(mBatteryPreference.getSummary()).isEqualTo(
+ "No battery use since last full charge");
+ }
+
+ @Test
+ public void updateBattery_hasBatteryStats_summaryPercent() {
+ mController.mBatteryHelper = mBatteryStatsHelper;
+ mController.mSipper = mBatterySipper;
+ doReturn(BATTERY_LEVEL).when(mBatteryUtils).calculateBatteryPercent(anyDouble(),
+ anyDouble(), anyDouble(), anyInt());
+ doReturn(new ArrayList<>()).when(mBatteryStatsHelper).getUsageList();
+ mController.displayPreference(mScreen);
+
+ mController.updateBattery();
+
+ assertThat(mBatteryPreference.getSummary()).isEqualTo("60% use since last full charge");
+ }
+
+ @Test
+ public void isBatteryStatsAvailable_hasBatteryStatsHelperAndSipper_returnTrue() {
+ mController.mBatteryHelper = mBatteryStatsHelper;
+ mController.mSipper = mBatterySipper;
+
+ assertThat(mController.isBatteryStatsAvailable()).isTrue();
+ }
+
+ @Test
+ public void isBatteryStatsAvailable_parametersNull_returnFalse() {
+ assertThat(mController.isBatteryStatsAvailable()).isFalse();
+ }
+
+ @Test
+ public void launchPowerUsageDetailFragment_shouldNotCrash() {
+ when(mActivity.getSystemService(Context.APP_OPS_SERVICE))
+ .thenReturn(mock(AppOpsManager.class));
+ when(mFragment.getActivity()).thenReturn(mActivity);
+ final String key = mController.getPreferenceKey();
+ when(mBatteryPreference.getKey()).thenReturn(key);
+ mController.mSipper = mBatterySipper;
+ mController.mBatteryHelper = mBatteryStatsHelper;
+
+ // Should not crash
+ mController.handlePreferenceTreeClick(mBatteryPreference);
+ }
+
+ @Test
+ public void onResume_shouldRestartBatteryStatsLoader() {
+ doReturn(mLoaderManager).when(mFragment).getLoaderManager();
+
+ mController.onResume();
+
+ verify(mLoaderManager).restartLoader(AppInfoDashboardFragment.LOADER_BATTERY, Bundle.EMPTY,
+ mController);
+ }
+
+ @Test
+ public void onPause_shouldDestroyBatteryStatsLoader() {
+ doReturn(mLoaderManager).when(mFragment).getLoaderManager();
+
+ mController.onPause();
+
+ verify(mLoaderManager).destroyLoader(AppInfoDashboardFragment.LOADER_BATTERY);
+ }
+
+}
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppDataUsagePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppDataUsagePreferenceControllerTest.java
new file mode 100644
index 0000000..40f095c
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppDataUsagePreferenceControllerTest.java
@@ -0,0 +1,140 @@
+/*
+ * 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.applications.appinfo;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.LoaderManager;
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.net.ConnectivityManager;
+import android.net.INetworkStatsSession;
+import android.os.Bundle;
+import android.support.v7.preference.Preference;
+
+import com.android.settings.R;
+import com.android.settings.TestConfig;
+import com.android.settings.applications.AppInfoDashboardFragment;
+import com.android.settings.datausage.AppDataUsage;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.applications.ApplicationsState.AppEntry;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.util.ReflectionHelpers;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
+public class AppDataUsagePreferenceControllerTest {
+
+ @Mock
+ private LoaderManager mLoaderManager;
+ @Mock
+ private AppInfoDashboardFragment mFragment;
+
+ private Context mContext;
+ private AppDataUsagePreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(RuntimeEnvironment.application.getApplicationContext());
+ mController = spy(
+ new AppDataUsagePreferenceController(mContext, mFragment, null /* lifecycle */));
+ }
+
+ @Test
+ public void getAvailabilityStatus_bandwidthControlEnabled_shouldReturnAvailable() {
+ doReturn(true).when(mController).isBandwidthControlEnabled();
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(mController.AVAILABLE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_bandwidthControlDisabled_shouldReturnDisabled() {
+ doReturn(false).when(mController).isBandwidthControlEnabled();
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(mController.DISABLED_UNSUPPORTED);
+ }
+
+ @Test
+ public void onResume_noSession_shouldNotRestartDataLoader() {
+ doReturn(mLoaderManager).when(mFragment).getLoaderManager();
+
+ mController.onResume();
+
+ verify(mLoaderManager, never()).restartLoader(
+ AppInfoDashboardFragment.LOADER_CHART_DATA, Bundle.EMPTY, mController);
+ }
+
+ @Test
+ public void onResume_hasSession_shouldRestartDataLoader() {
+ final ConnectivityManager connectivityManager = mock(ConnectivityManager.class);
+ when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE))
+ .thenReturn(connectivityManager);
+ when(connectivityManager.isNetworkSupported(anyInt())).thenReturn(true);
+ doReturn(mLoaderManager).when(mFragment).getLoaderManager();
+ ReflectionHelpers.setField(mController, "mStatsSession", mock(INetworkStatsSession.class));
+ final AppEntry appEntry = mock(AppEntry.class);
+ appEntry.info = new ApplicationInfo();
+ when(mFragment.getAppEntry()).thenReturn(appEntry);
+
+ mController.onResume();
+
+ verify(mLoaderManager).restartLoader(
+ eq(AppInfoDashboardFragment.LOADER_CHART_DATA), any(Bundle.class), eq(mController));
+ }
+
+ @Test
+ public void onPause_shouldDestroyDataLoader() {
+ doReturn(mLoaderManager).when(mFragment).getLoaderManager();
+
+ mController.onPause();
+
+ verify(mLoaderManager).destroyLoader(AppInfoDashboardFragment.LOADER_CHART_DATA);
+ }
+
+ @Test
+ public void getDetailFragmentClass_shouldReturnAppDataUsage() {
+ assertThat(mController.getDetailFragmentClass()).isEqualTo(AppDataUsage.class);
+ }
+
+ @Test
+ public void updateState_shouldUpdatePreferenceSummary() {
+ final Preference preference = mock(Preference.class);
+
+ mController.updateState(preference);
+
+ verify(preference).setSummary(any());
+ }
+
+}
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoPreferenceControllerBaseTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoPreferenceControllerBaseTest.java
new file mode 100644
index 0000000..0803c93
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoPreferenceControllerBaseTest.java
@@ -0,0 +1,120 @@
+/*
+ * 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.applications.appinfo;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.pm.ApplicationInfo;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.SettingsActivity;
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.TestConfig;
+import com.android.settings.applications.AppInfoDashboardFragment;
+import com.android.settings.notification.AppNotificationSettings;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.applications.ApplicationsState;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
+public class AppInfoPreferenceControllerBaseTest {
+
+ @Mock
+ private SettingsActivity mActivity;
+ @Mock
+ private AppInfoDashboardFragment mFragment;
+ @Mock
+ private PreferenceScreen mScreen;
+ @Mock
+ private Preference mPreference;
+
+ private TestPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mController = new TestPreferenceController(mFragment);
+ final String key = mController.getPreferenceKey();
+ when(mScreen.findPreference(key)).thenReturn(mPreference);
+ when(mPreference.getKey()).thenReturn(key);
+ when(mFragment.getActivity()).thenReturn(mActivity);
+ }
+
+ @Test
+ public void getAvailabilityStatus_shouldReturnAvailable() {
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(mController.AVAILABLE);
+ }
+
+ @Test
+ public void refreshUi_shouldUpdatePreference() {
+ mController.displayPreference(mScreen);
+ mController.refreshUi();
+
+ assertThat(mController.preferenceUpdated).isTrue();
+ }
+
+ @Test
+ public void handlePreferenceTreeClick_shouldStartDetailFragmentClass() {
+ final ApplicationsState.AppEntry appEntry = mock(ApplicationsState.AppEntry.class);
+ appEntry.info = new ApplicationInfo();
+ when(mFragment.getAppEntry()).thenReturn(appEntry);
+
+ mController.handlePreferenceTreeClick(mPreference);
+
+ verify(mActivity).startPreferencePanel(any(),
+ eq(mController.getDetailFragmentClass().getName()), any(), anyInt(), any(), any(),
+ anyInt());
+ }
+
+ private class TestPreferenceController extends AppInfoPreferenceControllerBase {
+
+ private boolean preferenceUpdated;
+
+ public TestPreferenceController(AppInfoDashboardFragment parent) {
+ super(RuntimeEnvironment.application, parent, "TestKey");
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ preferenceUpdated = true;
+ }
+
+ @Override
+ public Class<? extends SettingsPreferenceFragment> getDetailFragmentClass() {
+ return AppNotificationSettings.class;
+ }
+
+ }
+
+}
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppMemoryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppMemoryPreferenceControllerTest.java
new file mode 100644
index 0000000..39bb875
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppMemoryPreferenceControllerTest.java
@@ -0,0 +1,108 @@
+/*
+ * 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.applications.appinfo;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.provider.Settings;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.SettingsActivity;
+import com.android.settings.TestConfig;
+import com.android.settings.applications.AppInfoDashboardFragment;
+import com.android.settings.applications.ProcStatsData;
+import com.android.settings.applications.ProcessStatsDetail;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.util.ReflectionHelpers;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
+public class AppMemoryPreferenceControllerTest {
+
+ @Mock
+ private SettingsActivity mActivity;
+ @Mock
+ private AppInfoDashboardFragment mFragment;
+ @Mock
+ private PreferenceScreen mScreen;
+ @Mock
+ private Preference mPreference;
+
+ private Context mContext;
+ private AppMemoryPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mController =
+ spy(new AppMemoryPreferenceController(mContext, mFragment, null /* lifecycle */));
+ when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
+ final String key = mController.getPreferenceKey();
+ when(mPreference.getKey()).thenReturn(key);
+ when(mFragment.getActivity()).thenReturn(mActivity);
+ }
+
+ @Test
+ public void getAvailabilityStatus_developmentSettingsEnabled_shouldReturnAvailable() {
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(mController.AVAILABLE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_developmentSettingsDisabled_shouldReturnDisabled() {
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
+
+ assertThat(mController.getAvailabilityStatus())
+ .isEqualTo(mController.DISABLED_DEPENDENT_SETTING);
+ }
+
+ @Test
+ public void handlePreferenceTreeClick_shouldStartProcessStatsDetail() {
+ final ProcStatsData data = mock(ProcStatsData.class);
+ when(data.getMemInfo()).thenReturn(mock(ProcStatsData.MemInfo.class));
+ ReflectionHelpers.setField(mController, "mStatsManager", data);
+
+ mController.handlePreferenceTreeClick(mPreference);
+
+ verify(mActivity).startPreferencePanel(any(), eq(ProcessStatsDetail.class.getName()), any(),
+ eq(R.string.memory_usage), any(), any(), anyInt());
+ }
+
+}
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppNotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppNotificationPreferenceControllerTest.java
new file mode 100644
index 0000000..0d42fc2
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppNotificationPreferenceControllerTest.java
@@ -0,0 +1,92 @@
+/*
+ * 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.applications.appinfo;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.TestConfig;
+import com.android.settings.applications.AppInfoDashboardFragment;
+import com.android.settings.notification.AppNotificationSettings;
+import com.android.settings.notification.NotificationBackend;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.applications.ApplicationsState;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.util.ReflectionHelpers;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
+public class AppNotificationPreferenceControllerTest {
+
+ @Mock
+ private AppInfoDashboardFragment mFragment;
+ @Mock
+ private PreferenceScreen mScreen;
+ @Mock
+ private Preference mPreference;
+
+ private Context mContext;
+ private AppNotificationPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mController =
+ spy(new AppNotificationPreferenceController(mContext, mFragment));
+ when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
+ final String key = mController.getPreferenceKey();
+ when(mPreference.getKey()).thenReturn(key);
+ }
+
+ @Test
+ public void getDetailFragmentClass_shouldReturnAppNotificationSettings() {
+ assertThat(mController.getDetailFragmentClass()).isEqualTo(AppNotificationSettings.class);
+ }
+
+ @Test
+ public void updateState_shouldSetSummary() {
+ final ApplicationsState.AppEntry appEntry = mock(ApplicationsState.AppEntry.class);
+ appEntry.info = new ApplicationInfo();
+ when(mFragment.getAppEntry()).thenReturn(appEntry);
+ ReflectionHelpers.setField(mController, "mBackend", new NotificationBackend());
+ mController.displayPreference(mScreen);
+
+ mController.updateState(mPreference);
+
+ verify(mPreference).setSummary(any());
+ }
+
+}
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppOpenByDefaultPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppOpenByDefaultPreferenceControllerTest.java
new file mode 100644
index 0000000..d4f0179
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppOpenByDefaultPreferenceControllerTest.java
@@ -0,0 +1,166 @@
+/*
+ * 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.applications.appinfo;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageInfo;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.TestConfig;
+import com.android.settings.applications.AppInfoDashboardFragment;
+import com.android.settings.applications.AppLaunchSettings;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.applications.AppUtils;
+import com.android.settingslib.applications.ApplicationsState.AppEntry;
+import com.android.settingslib.applications.instantapps.InstantAppDataProvider;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.util.ReflectionHelpers;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
+public class AppOpenByDefaultPreferenceControllerTest {
+
+ @Mock
+ private AppInfoDashboardFragment mFragment;
+ @Mock
+ private PreferenceScreen mScreen;
+ @Mock
+ private Preference mPreference;
+
+ private Context mContext;
+ private AppOpenByDefaultPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application.getApplicationContext();
+ mController = spy(new AppOpenByDefaultPreferenceController(mContext, mFragment));
+ when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
+ }
+
+ @Test
+ public void getDetailFragmentClass_shouldReturnAppLaunchSettings() {
+ assertThat(mController.getDetailFragmentClass()).isEqualTo(AppLaunchSettings.class);
+ }
+
+ @Test
+ public void displayPreference_noAppEntry_shouldDisablePreference() {
+ mController.displayPreference(mScreen);
+
+ verify(mPreference).setEnabled(false);
+ }
+
+ @Test
+ public void displayPreference_noAppInfo_shouldDisablePreference() {
+ final AppEntry appEntry = mock(AppEntry.class);
+ when(mFragment.getAppEntry()).thenReturn(appEntry);
+
+ mController.displayPreference(mScreen);
+
+ verify(mPreference).setEnabled(false);
+ }
+
+ @Test
+ public void displayPreference_appNotInstalled_shouldDisablePreference() {
+ final AppEntry appEntry = mock(AppEntry.class);
+ appEntry.info = new ApplicationInfo();
+ when(mFragment.getAppEntry()).thenReturn(appEntry);
+
+ mController.displayPreference(mScreen);
+
+ verify(mPreference).setEnabled(false);
+ }
+
+ @Test
+ public void displayPreference_appDisabled_shouldDisablePreference() {
+ final AppEntry appEntry = mock(AppEntry.class);
+ appEntry.info = new ApplicationInfo();
+ appEntry.info.flags &= ApplicationInfo.FLAG_INSTALLED;
+ appEntry.info.enabled = false;
+ when(mFragment.getAppEntry()).thenReturn(appEntry);
+
+ mController.displayPreference(mScreen);
+
+ verify(mPreference).setEnabled(false);
+ }
+
+ @Test
+ public void displayPreference_appEnabled_shouldNotDisablePreference() {
+ final AppEntry appEntry = mock(AppEntry.class);
+ appEntry.info = new ApplicationInfo();
+ appEntry.info.flags |= ApplicationInfo.FLAG_INSTALLED;
+ appEntry.info.enabled = true;
+ when(mFragment.getAppEntry()).thenReturn(appEntry);
+
+ mController.displayPreference(mScreen);
+
+ verify(mPreference, never()).setEnabled(false);
+ }
+
+ @Test
+ public void updateState_noPackageInfo_shouldNotShowPreference() {
+ mController.updateState(mPreference);
+
+ verify(mPreference).setVisible(false);
+ }
+
+ @Test
+ public void updateState_isInstantApp_shouldNotShowPreference() {
+ when(mFragment.getPackageInfo()).thenReturn(new PackageInfo());
+ ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
+ (InstantAppDataProvider) (i -> true));
+
+ mController.updateState(mPreference);
+
+ verify(mPreference).setVisible(false);
+ }
+
+ @Test
+ public void updateState_notInstantApp_shouldShowPreferenceAndSetSummary() {
+ when(mFragment.getPackageInfo()).thenReturn(new PackageInfo());
+ final AppEntry appEntry = mock(AppEntry.class);
+ appEntry.info = new ApplicationInfo();
+ when(mFragment.getAppEntry()).thenReturn(appEntry);
+ ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
+ (InstantAppDataProvider) (i -> false));
+
+ mController.updateState(mPreference);
+
+ verify(mPreference).setVisible(true);
+ verify(mPreference).setSummary(any());
+ }
+
+}
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppPermissionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppPermissionPreferenceControllerTest.java
new file mode 100644
index 0000000..3ddfaf0
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppPermissionPreferenceControllerTest.java
@@ -0,0 +1,145 @@
+/*
+ * 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.applications.appinfo;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ApplicationInfo;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.SettingsActivity;
+import com.android.settings.TestConfig;
+import com.android.settings.applications.AppInfoDashboardFragment;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.applications.ApplicationsState;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+import java.util.ArrayList;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
+public class AppPermissionPreferenceControllerTest {
+
+ @Mock
+ private SettingsActivity mActivity;
+ @Mock
+ private AppInfoDashboardFragment mFragment;
+ @Mock
+ private PreferenceScreen mScreen;
+ @Mock
+ private Preference mPreference;
+
+ private Context mContext;
+ private AppPermissionPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mController = new AppPermissionPreferenceController(mContext, mFragment, "Package1");
+ when(mScreen.findPreference(any())).thenReturn(mPreference);
+ final String key = mController.getPreferenceKey();
+ when(mPreference.getKey()).thenReturn(key);
+ when(mFragment.getActivity()).thenReturn(mActivity);
+ }
+
+ @Test
+ public void getAvailabilityStatus_isAlwaysAvailable() {
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(mController.AVAILABLE);
+ }
+
+ @Test
+ public void onPermissionSummaryResult_noRequestedPermission_shouldDisablePreference() {
+ mController.displayPreference(mScreen);
+
+ mController.mPermissionCallback.onPermissionSummaryResult(
+ 1, 0, 1, new ArrayList<CharSequence>());
+
+ verify(mPreference).setEnabled(false);
+ verify(mPreference).setSummary(mContext.getString(
+ R.string.runtime_permissions_summary_no_permissions_requested));
+ }
+
+ @Test
+ public void onPermissionSummaryResult_noGrantedPermission_shouldSetNoPermissionSummary() {
+ mController.displayPreference(mScreen);
+
+ mController.mPermissionCallback.onPermissionSummaryResult(
+ 1, 5, 0, new ArrayList<CharSequence>());
+
+ verify(mPreference).setEnabled(true);
+ verify(mPreference).setSummary(mContext.getString(
+ R.string.runtime_permissions_summary_no_permissions_granted));
+ }
+
+ @Test
+ public void onPermissionSummaryResult_hasRuntimePermission_shouldSetPermissionAsSummary() {
+ mController.displayPreference(mScreen);
+ final String permission = "Storage";
+ final ArrayList<CharSequence> labels = new ArrayList<>();
+ labels.add(permission);
+
+ mController.mPermissionCallback.onPermissionSummaryResult(1, 5, 0, labels);
+
+ verify(mPreference).setEnabled(true);
+ verify(mPreference).setSummary(permission);
+ }
+
+ @Test
+ public void onPermissionSummaryResult_hasAdditionalPermission_shouldSetAdditionalSummary() {
+ mController.displayPreference(mScreen);
+ final String permission = "Storage";
+ final ArrayList<CharSequence> labels = new ArrayList<>();
+ labels.add(permission);
+
+ mController.mPermissionCallback.onPermissionSummaryResult(1, 5, 2, labels);
+
+ verify(mPreference).setEnabled(true);
+ verify(mPreference).setSummary("Storage and 2 additional permissions");
+ }
+
+ @Test
+ public void handlePreferenceTreeClick_shouldStartManagePermissionsActivity() {
+ final ApplicationsState.AppEntry appEntry = mock(ApplicationsState.AppEntry.class);
+ appEntry.info = new ApplicationInfo();
+ when(mFragment.getAppEntry()).thenReturn(appEntry);
+
+ mController.handlePreferenceTreeClick(mPreference);
+
+ verify(mActivity).startActivityForResult(argThat(intent-> intent != null &&
+ Intent.ACTION_MANAGE_APP_PERMISSIONS.equals(intent.getAction())), anyInt());
+ }
+
+}
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppStoragePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppStoragePreferenceControllerTest.java
new file mode 100644
index 0000000..1b6b3c0
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppStoragePreferenceControllerTest.java
@@ -0,0 +1,126 @@
+/*
+ * 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.applications.appinfo;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.LoaderManager;
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.os.Bundle;
+import android.support.v7.preference.Preference;
+
+import com.android.settings.R;
+import com.android.settings.TestConfig;
+import com.android.settings.applications.AppInfoDashboardFragment;
+import com.android.settings.applications.AppStorageSettings;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.applications.ApplicationsState.AppEntry;
+import com.android.settingslib.applications.StorageStatsSource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
+public class AppStoragePreferenceControllerTest {
+
+ @Mock
+ private LoaderManager mLoaderManager;
+ @Mock
+ private AppInfoDashboardFragment mFragment;
+
+ private Context mContext;
+ private AppStoragePreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application.getApplicationContext();
+ mController =
+ spy(new AppStoragePreferenceController(mContext, mFragment, null /* lifecycle */));
+ }
+
+ @Test
+ public void onResume_shouldRestartStorageLoader() {
+ doReturn(mLoaderManager).when(mFragment).getLoaderManager();
+
+ mController.onResume();
+
+ verify(mLoaderManager).restartLoader(AppInfoDashboardFragment.LOADER_STORAGE, Bundle.EMPTY,
+ mController);
+ }
+
+ @Test
+ public void onPause_shouldDestroyStorageLoader() {
+ doReturn(mLoaderManager).when(mFragment).getLoaderManager();
+
+ mController.onPause();
+
+ verify(mLoaderManager).destroyLoader(AppInfoDashboardFragment.LOADER_STORAGE);
+ }
+
+ @Test
+ public void getDetailFragmentClass_shouldReturnAppStorageSettings() {
+ assertThat(mController.getDetailFragmentClass()).isEqualTo(AppStorageSettings.class);
+ }
+
+ @Test
+ public void updateState_shouldUpdatePreferenceSummary() {
+ final AppEntry appEntry = mock(AppEntry.class);
+ appEntry.info = new ApplicationInfo();
+ when(mFragment.getAppEntry()).thenReturn(appEntry);
+ Preference preference = mock(Preference.class);
+
+ mController.updateState(preference);
+
+ verify(preference).setSummary(any());
+ }
+
+ @Test
+ public void getStorageSummary_shouldWorkForExternal() {
+ final StorageStatsSource.AppStorageStats stats =
+ mock(StorageStatsSource.AppStorageStats.class);
+ when(stats.getTotalBytes()).thenReturn(1L);
+
+ assertThat(mController.getStorageSummary(stats, true))
+ .isEqualTo("1 B used in external storage");
+ }
+
+ @Test
+ public void getStorageSummary_shouldWorkForInternal() {
+ final StorageStatsSource.AppStorageStats stats =
+ mock(StorageStatsSource.AppStorageStats.class);
+ when(stats.getTotalBytes()).thenReturn(1L);
+
+ assertThat(mController.getStorageSummary(stats, false))
+ .isEqualTo("1 B used in internal storage");
+ }
+
+}
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppVersionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppVersionPreferenceControllerTest.java
new file mode 100644
index 0000000..838b442
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppVersionPreferenceControllerTest.java
@@ -0,0 +1,69 @@
+/*
+ * 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.applications.appinfo;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.pm.PackageInfo;
+import android.support.v7.preference.Preference;
+
+import com.android.settings.TestConfig;
+import com.android.settings.applications.AppInfoDashboardFragment;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
+public class AppVersionPreferenceControllerTest {
+
+ @Mock
+ private AppInfoDashboardFragment mFragment;
+ @Mock
+ private Preference mPreference;
+
+ private Context mContext;
+ private AppVersionPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mController = new AppVersionPreferenceController(mContext, mFragment);
+ }
+
+ @Test
+ public void updateState_shouldUpdatePreferenceSummary() {
+ final PackageInfo packageInfo = mock(PackageInfo.class);
+ packageInfo.versionName = "test1234";
+ when(mFragment.getPackageInfo()).thenReturn(packageInfo);
+
+ mController.updateState(mPreference);
+
+ verify(mPreference).setSummary("version test1234");
+ }
+
+}
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppInfoTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppInfoTest.java
index d4cd6da..0b933c6 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppInfoTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppInfoTest.java
@@ -17,11 +17,17 @@
package com.android.settings.applications.defaultapps;
import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.ComponentName;
import android.content.Context;
+import android.content.pm.ApplicationInfo;
import android.content.pm.PackageItemInfo;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
@@ -39,7 +45,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DefaultAppInfoTest {
@Mock
@@ -50,15 +56,24 @@
private PackageManager mPackageManager;
@Mock
private PackageManagerWrapper mPackageManagerWrapper;
+ @Mock
+ private ApplicationInfo mApplicationInfo;
+ @Mock
+ private Drawable mIcon;
private Context mContext;
private DefaultAppInfo mInfo;
@Before
- public void setUp() {
+ public void setUp() throws PackageManager.NameNotFoundException {
MockitoAnnotations.initMocks(this);
- mContext = RuntimeEnvironment.application;
+ mContext = spy(RuntimeEnvironment.application);
+ doReturn(mPackageManager).when(mContext).getPackageManager();
when(mPackageManagerWrapper.getPackageManager()).thenReturn(mPackageManager);
+ when(mPackageManagerWrapper.getApplicationInfoAsUser(anyString(), anyInt(),
+ anyInt())).thenReturn(mApplicationInfo);
+ when(mPackageManager.loadUnbadgedItemIcon(mPackageItemInfo, mApplicationInfo)).thenReturn(
+ mIcon);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragmentTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragmentTest.java
index 42a6225..804df51 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragmentTest.java
@@ -51,7 +51,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DefaultAppPickerFragmentTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceControllerTest.java
index a02a2de..f16c05e 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceControllerTest.java
@@ -39,7 +39,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DefaultAppPreferenceControllerTest {
private static final String TEST_APP_NAME = "test";
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPickerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPickerTest.java
index 06d3b8b..61d7f34 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPickerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPickerTest.java
@@ -43,7 +43,7 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DefaultAutofillPickerTest {
private static final String TEST_APP_KEY = "foo.bar/foo.bar.Baz";
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceControllerTest.java
index bc72ee4..8a181d8 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceControllerTest.java
@@ -46,7 +46,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DefaultAutofillPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultBrowserPickerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultBrowserPickerTest.java
index e8a6c1e..934c4c6 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultBrowserPickerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultBrowserPickerTest.java
@@ -39,7 +39,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DefaultBrowserPickerTest {
private static final String TEST_APP_KEY = "";
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultBrowserPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultBrowserPreferenceControllerTest.java
index 8d527ff..b3406a1 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultBrowserPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultBrowserPreferenceControllerTest.java
@@ -48,7 +48,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DefaultBrowserPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultEmergencyPickerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultEmergencyPickerTest.java
index 124817a..d499ac2 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultEmergencyPickerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultEmergencyPickerTest.java
@@ -41,7 +41,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DefaultEmergencyPickerTest {
private static final String TEST_APP_KEY = "test_app";
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultHomePickerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultHomePickerTest.java
index 4b82f1a..4680a08 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultHomePickerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultHomePickerTest.java
@@ -59,7 +59,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DefaultHomePickerTest {
private static final String TEST_APP_KEY = "com.android.settings/DefaultEmergencyPickerTest";
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultHomePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultHomePreferenceControllerTest.java
index 8a8cc29..cf19655 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultHomePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultHomePreferenceControllerTest.java
@@ -51,7 +51,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DefaultHomePreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultPaymentSettingsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultPaymentSettingsPreferenceControllerTest.java
index 6a73269..025d50a 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultPaymentSettingsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultPaymentSettingsPreferenceControllerTest.java
@@ -42,7 +42,7 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DefaultPaymentSettingsPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultPhonePickerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultPhonePickerTest.java
index f2b7db8..b1bea25 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultPhonePickerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultPhonePickerTest.java
@@ -43,7 +43,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DefaultPhonePickerTest {
private static final String TEST_APP_KEY = "com.android.settings/PickerTest";
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultSmsPickerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultSmsPickerTest.java
index 91e68ea..e9bdfe3 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultSmsPickerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultSmsPickerTest.java
@@ -42,7 +42,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DefaultSmsPickerTest {
private static final String TEST_APP_KEY = "com.android.settings/PickerTest";
diff --git a/tests/robotests/src/com/android/settings/applications/manageapplications/AppFilterItemTest.java b/tests/robotests/src/com/android/settings/applications/manageapplications/AppFilterItemTest.java
index 982fb56..2dde6f4 100644
--- a/tests/robotests/src/com/android/settings/applications/manageapplications/AppFilterItemTest.java
+++ b/tests/robotests/src/com/android/settings/applications/manageapplications/AppFilterItemTest.java
@@ -35,7 +35,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AppFilterItemTest {
@Test
diff --git a/tests/robotests/src/com/android/settings/applications/manageapplications/AppFilterRegistryTest.java b/tests/robotests/src/com/android/settings/applications/manageapplications/AppFilterRegistryTest.java
index 3fe5e67..ccd8470 100644
--- a/tests/robotests/src/com/android/settings/applications/manageapplications/AppFilterRegistryTest.java
+++ b/tests/robotests/src/com/android/settings/applications/manageapplications/AppFilterRegistryTest.java
@@ -60,7 +60,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AppFilterRegistryTest {
@Test
diff --git a/tests/robotests/src/com/android/settings/applications/manageapplications/ApplicationViewHolderTest.java b/tests/robotests/src/com/android/settings/applications/manageapplications/ApplicationViewHolderTest.java
index c32b262..ebc0ddc 100644
--- a/tests/robotests/src/com/android/settings/applications/manageapplications/ApplicationViewHolderTest.java
+++ b/tests/robotests/src/com/android/settings/applications/manageapplications/ApplicationViewHolderTest.java
@@ -37,7 +37,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ApplicationViewHolderTest {
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
index dfe8e4c..d208194 100644
--- a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
@@ -73,7 +73,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
// TODO: Consider making the shadow class set global using a robolectric.properties file.
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {
SettingsShadowResources.class,
SettingsShadowTheme.class,
diff --git a/tests/robotests/src/com/android/settings/applications/manageapplications/MusicViewHolderControllerTest.java b/tests/robotests/src/com/android/settings/applications/manageapplications/MusicViewHolderControllerTest.java
index fc761cc..c7f2f53 100644
--- a/tests/robotests/src/com/android/settings/applications/manageapplications/MusicViewHolderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/manageapplications/MusicViewHolderControllerTest.java
@@ -17,6 +17,7 @@
package com.android.settings.applications.manageapplications;
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.Matchers.nullable;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -27,6 +28,7 @@
import android.os.UserHandle;
import android.os.storage.VolumeInfo;
import android.provider.DocumentsContract;
+import android.text.format.Formatter;
import android.view.View;
import android.widget.FrameLayout;
@@ -46,7 +48,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class MusicViewHolderControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Fragment mFragment;
@@ -75,7 +77,8 @@
public void storageShouldBeZeroBytesIfQueriedBeforeStorageQueryFinishes() {
mController.setupView(mHolder);
- assertThat(mHolder.mSummary.getText().toString()).isEqualTo("0.00 B");
+ assertThat(mHolder.mSummary.getText().toString()).isEqualTo(
+ Formatter.formatFileSize(mContext, 0));
}
@Test
@@ -86,7 +89,8 @@
mController.queryStats();
mController.setupView(mHolder);
- assertThat(mHolder.mSummary.getText().toString()).isEqualTo("1.00 B");
+ assertThat(mHolder.mSummary.getText().toString()).isEqualTo(
+ Formatter.formatFileSize(mContext, 1));
}
@Test
diff --git a/tests/robotests/src/com/android/settings/applications/manageapplications/PhotosViewHolderControllerTest.java b/tests/robotests/src/com/android/settings/applications/manageapplications/PhotosViewHolderControllerTest.java
index 0a147ac..fd25921 100644
--- a/tests/robotests/src/com/android/settings/applications/manageapplications/PhotosViewHolderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/manageapplications/PhotosViewHolderControllerTest.java
@@ -17,6 +17,7 @@
package com.android.settings.applications.manageapplications;
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.Matchers.nullable;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -26,6 +27,7 @@
import android.content.Intent;
import android.os.UserHandle;
import android.os.storage.VolumeInfo;
+import android.text.format.Formatter;
import android.view.View;
import android.widget.FrameLayout;
@@ -44,11 +46,12 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class PhotosViewHolderControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Fragment mFragment;
- @Mock private StorageStatsSource mSource;
+ @Mock
+ private StorageStatsSource mSource;
private Context mContext;
private PhotosViewHolderController mController;
@@ -74,7 +77,8 @@
public void storageShouldBeZeroBytesIfQueriedBeforeStorageQueryFinishes() {
mController.setupView(mHolder);
- assertThat(mHolder.mSummary.getText().toString()).isEqualTo("0.00 B");
+ assertThat(mHolder.mSummary.getText().toString()).isEqualTo(
+ Formatter.formatFileSize(mContext, 0));
}
@Test
@@ -85,7 +89,8 @@
mController.queryStats();
mController.setupView(mHolder);
- assertThat(mHolder.mSummary.getText().toString()).isEqualTo("11.00 B");
+ assertThat(mHolder.mSummary.getText().toString()).isEqualTo(
+ Formatter.formatFileSize(mContext, 11));
}
@Test
diff --git a/tests/robotests/src/com/android/settings/backup/BackupSettingsActivityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/backup/BackupSettingsActivityPreferenceControllerTest.java
index 5fc3ebc..39cc9a2 100644
--- a/tests/robotests/src/com/android/settings/backup/BackupSettingsActivityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/backup/BackupSettingsActivityPreferenceControllerTest.java
@@ -45,7 +45,7 @@
import org.robolectric.annotation.Implements;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = {BackupSettingsActivityPreferenceControllerTest.ShadowBackupManager.class})
public class BackupSettingsActivityPreferenceControllerTest {
private static final String KEY_BACKUP_SETTINGS = "backup_settings";
diff --git a/tests/robotests/src/com/android/settings/backup/BackupSettingsActivityTest.java b/tests/robotests/src/com/android/settings/backup/BackupSettingsActivityTest.java
index 44c7e10..cf3cb53 100644
--- a/tests/robotests/src/com/android/settings/backup/BackupSettingsActivityTest.java
+++ b/tests/robotests/src/com/android/settings/backup/BackupSettingsActivityTest.java
@@ -58,7 +58,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = {BackupSettingsActivityTest.ShadowBackupSettingsHelper.class,
BackupSettingsActivityTest.ShadowUserHandle.class})
public class BackupSettingsActivityTest {
diff --git a/tests/robotests/src/com/android/settings/backup/BackupSettingsHelperTest.java b/tests/robotests/src/com/android/settings/backup/BackupSettingsHelperTest.java
index 9de0c6a..eb33cd6 100644
--- a/tests/robotests/src/com/android/settings/backup/BackupSettingsHelperTest.java
+++ b/tests/robotests/src/com/android/settings/backup/BackupSettingsHelperTest.java
@@ -50,7 +50,7 @@
import com.android.settingslib.drawer.SettingsDrawerActivity;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = {BackupSettingsHelperTest.ShadowBackupManagerStub.class})
public class BackupSettingsHelperTest {
diff --git a/tests/robotests/src/com/android/settings/backup/BackupSettingsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/backup/BackupSettingsPreferenceControllerTest.java
index 3ad49e7..83d9709 100644
--- a/tests/robotests/src/com/android/settings/backup/BackupSettingsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/backup/BackupSettingsPreferenceControllerTest.java
@@ -41,7 +41,7 @@
import android.support.v7.preference.PreferenceScreen;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = {BackupSettingsPreferenceControllerTest.ShadowBackupSettingsHelper.class})
public class BackupSettingsPreferenceControllerTest {
private static final String BACKUP_SETTINGS = "backup_settings";
diff --git a/tests/robotests/src/com/android/settings/bluetooth/AlwaysDiscoverableTest.java b/tests/robotests/src/com/android/settings/bluetooth/AlwaysDiscoverableTest.java
index fd46b4b..3cc90bd 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/AlwaysDiscoverableTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/AlwaysDiscoverableTest.java
@@ -41,7 +41,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AlwaysDiscoverableTest {
@Mock
private LocalBluetoothAdapter mLocalAdapter;
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsButtonsControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsButtonsControllerTest.java
index 7b0a3f23..e7ce7e0 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsButtonsControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsButtonsControllerTest.java
@@ -43,7 +43,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = SettingsShadowBluetoothDevice.class)
public class BluetoothDetailsButtonsControllerTest extends BluetoothDetailsControllerTestBase {
private BluetoothDetailsButtonsController mController;
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsControllerTestBase.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsControllerTestBase.java
index 33a5ed5..b03ecc1 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsControllerTestBase.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsControllerTestBase.java
@@ -28,14 +28,20 @@
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.R;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.Before;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BluetoothDetailsControllerTestBase {
protected Context mContext;
protected Lifecycle mLifecycle;
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragmentTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragmentTest.java
index 544b590..cd07a90 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragmentTest.java
@@ -53,7 +53,7 @@
import org.robolectric.fakes.RoboMenu;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BluetoothDeviceDetailsFragmentTest {
private BluetoothDeviceDetailsFragment mFragment;
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceNamePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceNamePreferenceControllerTest.java
index 2e094e2..93de52d 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceNamePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceNamePreferenceControllerTest.java
@@ -40,7 +40,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BluetoothDeviceNamePreferenceControllerTest {
private static final String DEVICE_NAME = "Nightshade";
private static final int ORDER = 1;
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java
index bc1151b..3dd97bb 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java
@@ -49,7 +49,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = SettingsShadowResources.class)
public class BluetoothDevicePreferenceTest {
private static final boolean SHOW_DEVICES_WITHOUT_NAMES = true;
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceRenamePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceRenamePreferenceControllerTest.java
index cde95cd..186e274 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceRenamePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceRenamePreferenceControllerTest.java
@@ -43,7 +43,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BluetoothDeviceRenamePreferenceControllerTest {
private static final String DEVICE_NAME = "Nightshade";
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceUpdaterTest.java
index 525f70e..d5abd93 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceUpdaterTest.java
@@ -73,8 +73,8 @@
mBluetoothDeviceUpdater = new BluetoothDeviceUpdater(mDashboardFragment,
mDevicePreferenceCallback, null) {
@Override
- public void update(CachedBluetoothDevice cachedBluetoothDevice) {
- // do nothing
+ public boolean isFilterMatched(CachedBluetoothDevice cachedBluetoothDevice) {
+ return true;
}
};
mBluetoothDeviceUpdater.setPrefContext(mContext);
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothEnablerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothEnablerTest.java
index b973edb..102f0a7 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothEnablerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothEnablerTest.java
@@ -58,7 +58,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows = {
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O, shadows = {
SettingsShadowResources.class, SettingsShadowResources.SettingsShadowTheme.class
})
public class BluetoothEnablerTest {
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothFilesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothFilesPreferenceControllerTest.java
index cdaf876..ed63fc4 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothFilesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothFilesPreferenceControllerTest.java
@@ -35,7 +35,7 @@
import org.robolectric.shadows.ShadowApplication;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BluetoothFilesPreferenceControllerTest {
private Context mContext;
private BluetoothFilesPreferenceController mController;
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothMasterSwitchPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothMasterSwitchPreferenceControllerTest.java
index c9d5746..534cace 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothMasterSwitchPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothMasterSwitchPreferenceControllerTest.java
@@ -47,7 +47,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BluetoothMasterSwitchPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDetailTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDetailTest.java
index d1d4935..2b30ae4 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDetailTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDetailTest.java
@@ -52,7 +52,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BluetoothPairingDetailTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDialogTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDialogTest.java
index fba11de..25a24d4 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDialogTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDialogTest.java
@@ -53,7 +53,7 @@
import org.robolectric.util.FragmentTestUtil;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows=ShadowEventLogWriter.class)
public class BluetoothPairingDialogTest {
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingPreferenceControllerTest.java
index 4459f61..192e447 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingPreferenceControllerTest.java
@@ -49,7 +49,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BluetoothPairingPreferenceControllerTest {
private static final int ORDER = 1;
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSettingsSummaryProviderTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSettingsSummaryProviderTest.java
index 0061ee5..e7a66fa 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSettingsSummaryProviderTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSettingsSummaryProviderTest.java
@@ -35,7 +35,7 @@
import static org.mockito.Mockito.verify;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BluetoothSettingsSummaryProviderTest {
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSettingsTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSettingsTest.java
index c772560..b177729 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSettingsTest.java
@@ -50,7 +50,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BluetoothSettingsTest {
private static final String FOOTAGE_MAC_STRING = "Bluetooth mac: xxxx";
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSummaryUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSummaryUpdaterTest.java
index 0c27412..cb04347 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSummaryUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSummaryUpdaterTest.java
@@ -51,7 +51,7 @@
import java.util.Set;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BluetoothSummaryUpdaterTest {
private static final String DEVICE_NAME = "Nightshade";
private static final String DEVICE_KEYBOARD_NAME = "Bluetooth Keyboard";
diff --git a/tests/robotests/src/com/android/settings/bluetooth/DeviceListPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/bluetooth/DeviceListPreferenceFragmentTest.java
index 49efecb..169db24 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/DeviceListPreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/DeviceListPreferenceFragmentTest.java
@@ -49,7 +49,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DeviceListPreferenceFragmentTest {
private static final String FOOTAGE_MAC_STRING = "Bluetooth mac: xxxx";
diff --git a/tests/robotests/src/com/android/settings/bluetooth/DevicePickerFragmentTest.java b/tests/robotests/src/com/android/settings/bluetooth/DevicePickerFragmentTest.java
index 3294ffd..f9b392e 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/DevicePickerFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/DevicePickerFragmentTest.java
@@ -30,7 +30,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DevicePickerFragmentTest {
@Mock
private LocalBluetoothAdapter mLocalAdapter;
diff --git a/tests/robotests/src/com/android/settings/bluetooth/DeviceProfilesSettingsTest.java b/tests/robotests/src/com/android/settings/bluetooth/DeviceProfilesSettingsTest.java
index a6793bb..56454b8 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/DeviceProfilesSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/DeviceProfilesSettingsTest.java
@@ -56,7 +56,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows = {
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O, shadows = {
ShadowEventLogWriter.class
})
public class DeviceProfilesSettingsTest {
diff --git a/tests/robotests/src/com/android/settings/bluetooth/ForgetDeviceDialogFragmentTest.java b/tests/robotests/src/com/android/settings/bluetooth/ForgetDeviceDialogFragmentTest.java
index 9343721..71e9933 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/ForgetDeviceDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/ForgetDeviceDialogFragmentTest.java
@@ -46,7 +46,7 @@
import org.robolectric.shadows.ShadowDialog;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ForgetDeviceDialogFragmentTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/bluetooth/RemoteDeviceNameDialogFragmentTest.java b/tests/robotests/src/com/android/settings/bluetooth/RemoteDeviceNameDialogFragmentTest.java
index a8ef4e6..65fe46c 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/RemoteDeviceNameDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/RemoteDeviceNameDialogFragmentTest.java
@@ -50,7 +50,7 @@
import org.robolectric.util.FragmentTestUtil;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class RemoteDeviceNameDialogFragmentTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
new file mode 100644
index 0000000..d0f367e
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
@@ -0,0 +1,108 @@
+/*
+ * 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 static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothDevice;
+import android.content.Context;
+
+import com.android.settings.TestConfig;
+import com.android.settings.connecteddevice.DevicePreferenceCallback;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.bluetooth.CachedBluetoothDevice;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
+public class SavedBluetoothDeviceUpdaterTest {
+ @Mock
+ private DashboardFragment mDashboardFragment;
+ @Mock
+ private DevicePreferenceCallback mDevicePreferenceCallback;
+ @Mock
+ private CachedBluetoothDevice mCachedBluetoothDevice;
+ @Mock
+ private BluetoothDevice mBluetoothDevice;
+
+ private Context mContext;
+ private BluetoothDeviceUpdater mBluetoothDeviceUpdater;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ mContext = RuntimeEnvironment.application;
+ doReturn(mContext).when(mDashboardFragment).getContext();
+ doReturn(mBluetoothDevice).when(mCachedBluetoothDevice).getDevice();
+
+ mBluetoothDeviceUpdater = spy(new SavedBluetoothDeviceUpdater(mDashboardFragment,
+ mDevicePreferenceCallback, null));
+ mBluetoothDeviceUpdater.setPrefContext(mContext);
+ doNothing().when(mBluetoothDeviceUpdater).addPreference(any());
+ doNothing().when(mBluetoothDeviceUpdater).removePreference(any());
+ }
+
+ @Test
+ public void testUpdate_filterMatch_addPreference() {
+ doReturn(BluetoothDevice.BOND_BONDED).when(mBluetoothDevice).getBondState();
+ doReturn(false).when(mBluetoothDevice).isConnected();
+
+ mBluetoothDeviceUpdater.update(mCachedBluetoothDevice);
+
+ verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
+ }
+
+ @Test
+ public void testUpdate_filterNotMatch_removePreference() {
+ doReturn(BluetoothDevice.BOND_NONE).when(mBluetoothDevice).getBondState();
+ doReturn(true).when(mBluetoothDevice).isConnected();
+
+ mBluetoothDeviceUpdater.update(mCachedBluetoothDevice);
+
+ verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
+ }
+
+ @Test
+ public void testOnConnectionStateChanged_deviceConnected_removePreference() {
+ mBluetoothDeviceUpdater.onConnectionStateChanged(mCachedBluetoothDevice,
+ BluetoothAdapter.STATE_CONNECTED);
+
+ verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
+ }
+
+ @Test
+ public void testOnConnectionStateChanged_deviceDisconnected_addPreference() {
+ mBluetoothDeviceUpdater.onConnectionStateChanged(mCachedBluetoothDevice,
+ BluetoothAdapter.STATE_DISCONNECTED);
+
+ verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
+ }
+
+}
diff --git a/tests/robotests/src/com/android/settings/bluetooth/UtilsTest.java b/tests/robotests/src/com/android/settings/bluetooth/UtilsTest.java
index e0d4638..43583ed 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/UtilsTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/UtilsTest.java
@@ -41,7 +41,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = SettingsShadowResources.class)
public class UtilsTest {
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment2Test.java b/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment2Test.java
index de83f5e..4bcb299 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment2Test.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment2Test.java
@@ -50,7 +50,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ConnectedDeviceDashboardFragment2Test {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/UsbModePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/UsbModePreferenceControllerTest.java
index 7edde6e..59a5172 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/UsbModePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/UsbModePreferenceControllerTest.java
@@ -26,7 +26,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class UsbModePreferenceControllerTest {
@Mock(answer = RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/core/BasePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/core/BasePreferenceControllerTest.java
new file mode 100644
index 0000000..d153e9a
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/core/BasePreferenceControllerTest.java
@@ -0,0 +1,120 @@
+/*
+ * 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.core;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController
+ .DISABLED_DEPENDENT_SETTING;
+import static com.android.settings.core.BasePreferenceController.DISABLED_FOR_USER;
+import static com.android.settings.core.BasePreferenceController.DISABLED_UNSUPPORTED;
+import static com.android.settings.core.BasePreferenceController.UNAVAILABLE_UNKNOWN;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.when;
+
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+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_O)
+public class BasePreferenceControllerTest {
+
+ @Mock
+ BasePreferenceController mPreferenceController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void isAvailable_availableStatusAvailable_returnsTrue() {
+ when(mPreferenceController.getAvailabilityStatus()).thenReturn(AVAILABLE);
+
+ assertThat(mPreferenceController.isAvailable()).isTrue();
+ }
+
+ @Test
+ public void isAvailable_availableStatusUnsupported_returnsFalse() {
+ when(mPreferenceController.getAvailabilityStatus()).thenReturn(DISABLED_UNSUPPORTED);
+
+ assertThat(mPreferenceController.isAvailable()).isFalse();
+ }
+
+ @Test
+ public void isAvailable_availableStatusDisabled_returnsFalse() {
+ when(mPreferenceController.getAvailabilityStatus()).thenReturn(DISABLED_FOR_USER);
+
+ assertThat(mPreferenceController.isAvailable()).isFalse();
+ }
+
+ @Test
+ public void isAvailable_availableStatusBlockedDependent_returnsFalse() {
+ when(mPreferenceController.getAvailabilityStatus()).thenReturn(DISABLED_DEPENDENT_SETTING);
+
+ assertThat(mPreferenceController.isAvailable()).isFalse();
+ }
+
+ @Test
+ public void isAvailable_availableStatusUnavailable_returnsFalse() {
+ when(mPreferenceController.getAvailabilityStatus()).thenReturn(UNAVAILABLE_UNKNOWN);
+
+ assertThat(mPreferenceController.isAvailable()).isFalse();
+ }
+
+ @Test
+ public void isSupported_availableStatusAvailable_returnsTrue() {
+ when(mPreferenceController.getAvailabilityStatus()).thenReturn(AVAILABLE);
+
+ assertThat(mPreferenceController.isSupported()).isTrue();
+ }
+
+ @Test
+ public void isSupported_availableStatusUnsupported_returnsFalse() {
+ when(mPreferenceController.getAvailabilityStatus()).thenReturn(DISABLED_UNSUPPORTED);
+
+ assertThat(mPreferenceController.isSupported()).isFalse();
+ }
+
+ @Test
+ public void isSupported_availableStatusDisabled_returnsTrue() {
+ when(mPreferenceController.getAvailabilityStatus()).thenReturn(DISABLED_FOR_USER);
+
+ assertThat(mPreferenceController.isSupported()).isTrue();
+ }
+
+ @Test
+ public void isSupported_availableStatusDependentSetting_returnsTrue() {
+ when(mPreferenceController.getAvailabilityStatus()).thenReturn(DISABLED_DEPENDENT_SETTING);
+
+ assertThat(mPreferenceController.isSupported()).isTrue();
+ }
+
+ @Test
+ public void isSupported_availableStatusUnavailable_returnsTrue() {
+ when(mPreferenceController.getAvailabilityStatus()).thenReturn(UNAVAILABLE_UNKNOWN);
+
+ assertThat(mPreferenceController.isSupported()).isTrue();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/core/TogglePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/core/TogglePreferenceControllerTest.java
new file mode 100644
index 0000000..b3df90a
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/core/TogglePreferenceControllerTest.java
@@ -0,0 +1,92 @@
+/*
+ * 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.core;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.support.v14.preference.SwitchPreference;
+
+import com.android.settings.TestConfig;
+import com.android.settings.core.TogglePreferenceController;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
+public class TogglePreferenceControllerTest {
+
+ @Mock
+ TogglePreferenceController mTogglePreferenceController;
+
+ Context mContext;
+ SwitchPreference mPreference;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mPreference = new SwitchPreference(mContext);
+ }
+
+ @Test
+ public void testSetsPreferenceValue_setsChecked() {
+ when(mTogglePreferenceController.isChecked()).thenReturn(true);
+ mPreference.setChecked(false);
+
+ mTogglePreferenceController.updateState(mPreference);
+
+ assertThat(mPreference.isChecked()).isTrue();
+ }
+
+ @Test
+ public void testSetsPreferenceValue_setsNotChecked() {
+ when(mTogglePreferenceController.isChecked()).thenReturn(false);
+ mPreference.setChecked(true);
+
+ mTogglePreferenceController.updateState(mPreference);
+
+ assertThat(mPreference.isChecked()).isFalse();
+ }
+
+ @Test
+ public void testUpdatesPreferenceOnChange_turnsOn() {
+ boolean newValue = true;
+
+ mTogglePreferenceController.onPreferenceChange(mPreference, newValue);
+
+ verify(mTogglePreferenceController).setChecked(newValue);
+ }
+
+ @Test
+ public void testUpdatesPreferenceOnChange_turnsOff() {
+ boolean newValue = false;
+
+ mTogglePreferenceController.onPreferenceChange(mPreference, newValue);
+
+ verify(mTogglePreferenceController).setChecked(newValue);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java
index 14da5d6..fdb1470 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java
@@ -68,7 +68,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {
SettingsShadowResources.class,
SettingsShadowResources.SettingsShadowTheme.class,
@@ -222,14 +222,12 @@
doReturn(mockTypedArray).when(mContext).obtainStyledAttributes(any(int[].class));
doReturn(0x89000000).when(mockTypedArray).getColor(anyInt(), anyInt());
- final DashboardCategory category = mock(DashboardCategory.class);
- final List<Tile> tiles = new ArrayList<>();
+ final DashboardCategory category = new DashboardCategory();
final Icon mockIcon = mock(Icon.class);
final Tile tile = new Tile();
tile.isIconTintable = true;
tile.icon = mockIcon;
- tiles.add(tile);
- category.tiles = tiles;
+ category.addTile(tile);
mDashboardAdapter.setCategory(category);
@@ -250,10 +248,8 @@
public void testBindConditionAndSuggestion_shouldSetSuggestionAdapterAndNoCrash() {
mDashboardAdapter = new DashboardAdapter(mContext, null, null, null, null, null);
final List<Tile> suggestions = makeSuggestions("pkg1");
- final DashboardCategory category = mock(DashboardCategory.class);
- final List<Tile> tiles = new ArrayList<>();
- tiles.add(mock(Tile.class));
- category.tiles = tiles;
+ final DashboardCategory category = new DashboardCategory();
+ category.addTile(mock(Tile.class));
mDashboardAdapter.setCategoriesAndSuggestions(category, suggestions);
@@ -277,10 +273,8 @@
public void testBindConditionAndSuggestion_v2_shouldSetSuggestionAdapterAndNoCrash() {
mDashboardAdapter = new DashboardAdapter(mContext, null, null, null, null, null);
final List<Suggestion> suggestions = makeSuggestionsV2("pkg1");
- final DashboardCategory category = mock(DashboardCategory.class);
- final List<Tile> tiles = new ArrayList<>();
- tiles.add(mock(Tile.class));
- category.tiles = tiles;
+ final DashboardCategory category = new DashboardCategory();
+ category.addTile(mock(Tile.class));
mDashboardAdapter.setSuggestionsV2(suggestions);
@@ -310,10 +304,8 @@
null /* SuggestionDismissController.Callback */);
final List<Tile> suggestions = new ArrayList<>();
- final DashboardCategory category = mock(DashboardCategory.class);
- final List<Tile> tiles = new ArrayList<>();
- tiles.add(mock(Tile.class));
- category.tiles = tiles;
+ final DashboardCategory category = new DashboardCategory();
+ category.addTile(mock(Tile.class));
mDashboardAdapter.setCategoriesAndSuggestions(category, suggestions);
final RecyclerView data = mock(RecyclerView.class);
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardDataTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardDataTest.java
index cc4f741..33f379e 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardDataTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardDataTest.java
@@ -49,7 +49,7 @@
import java.util.Objects;
@RunWith(RobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DashboardDataTest {
private static final String TEST_SUGGESTION_TITLE = "Use fingerprint";
private static final String TEST_CATEGORY_TILE_TITLE = "Display";
@@ -57,13 +57,12 @@
private DashboardData mDashboardDataWithOneConditions;
private DashboardData mDashboardDataWithTwoConditions;
private DashboardData mDashboardDataWithNoItems;
+ private DashboardCategory mDashboardCategory;
@Mock
private Tile mTestCategoryTile;
@Mock
private Tile mTestSuggestion;
@Mock
- private DashboardCategory mDashboardCategory;
- @Mock
private Condition mTestCondition;
@Mock
private Condition mSecondCondition; // condition used to test insert in DiffUtil
@@ -72,6 +71,8 @@
public void SetUp() {
MockitoAnnotations.initMocks(this);
+ mDashboardCategory = new DashboardCategory();
+
// Build suggestions
final List<Tile> suggestions = new ArrayList<>();
mTestSuggestion.title = TEST_SUGGESTION_TITLE;
@@ -91,8 +92,8 @@
// Build category
mTestCategoryTile.title = TEST_CATEGORY_TILE_TITLE;
mDashboardCategory.title = "test";
- mDashboardCategory.tiles = new ArrayList<>();
- mDashboardCategory.tiles.add(mTestCategoryTile);
+
+ mDashboardCategory.addTile(mTestCategoryTile);
// Build DashboardData
mDashboardDataWithOneConditions = new DashboardData.Builder()
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
index a977872..3d36e6f 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
@@ -17,10 +17,13 @@
package com.android.settings.dashboard;
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.robolectric.RuntimeEnvironment.application;
@@ -30,7 +33,8 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
-import android.content.res.Resources;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.graphics.Bitmap;
import android.graphics.drawable.Icon;
import android.os.Bundle;
@@ -60,6 +64,7 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
+import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowActivity;
import org.robolectric.shadows.ShadowApplication;
@@ -69,7 +74,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = ShadowUserManager.class)
public class DashboardFeatureProviderImplTest {
@@ -79,21 +84,28 @@
private UserManager mUserManager;
@Mock
private CategoryManager mCategoryManager;
+ @Mock
+ private PackageManager mPackageManager;
private FakeFeatureFactory mFeatureFactory;
+ private Context mContext;
private DashboardFeatureProviderImpl mImpl;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
+ mContext = spy(RuntimeEnvironment.application);
+ doReturn(mPackageManager).when(mContext).getPackageManager();
+ when(mPackageManager.resolveActivity(any(Intent.class), anyInt())).thenReturn(
+ new ResolveInfo());
FakeFeatureFactory.setupForTest(mActivity);
mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mActivity);
- mImpl = new DashboardFeatureProviderImpl(mActivity);
+ mImpl = new DashboardFeatureProviderImpl(mContext);
}
@Test
public void shouldHoldAppContext() {
- assertThat(mImpl.mContext).isEqualTo(mActivity.getApplicationContext());
+ assertThat(mImpl.mContext).isEqualTo(mContext.getApplicationContext());
}
@Test
@@ -342,7 +354,7 @@
}
@Test
- public void bindPreference_withIntentActionMetatdata_shouldSetLaunchAction() {
+ public void bindPreference_withIntentActionMetadata_shouldSetLaunchAction() {
Activity activity = Robolectric.buildActivity(Activity.class).get();
final ShadowApplication application = ShadowApplication.getInstance();
final Preference preference = new Preference(application.getApplicationContext());
@@ -419,7 +431,7 @@
mImpl = new DashboardFeatureProviderImpl(mActivity);
ReflectionHelpers.setField(mImpl, "mCategoryManager", mCategoryManager);
final DashboardCategory category = new DashboardCategory();
- category.tiles.add(new Tile());
+ category.addTile(new Tile());
when(mCategoryManager
.getTilesByCategory(any(Context.class), eq(CategoryKey.CATEGORY_HOMEPAGE)))
.thenReturn(category);
@@ -437,14 +449,13 @@
}
@Test
- public void testShouldTintIcon_shouldReturnValueFromResource() {
- final Resources res = mActivity.getApplicationContext().getResources();
- when(res.getBoolean(R.bool.config_tintSettingIcon))
- .thenReturn(false);
- assertThat(mImpl.shouldTintIcon()).isFalse();
-
- when(res.getBoolean(R.bool.config_tintSettingIcon))
- .thenReturn(true);
+ public void testShouldTintIcon_enabledInResources_shouldBeTrue() {
assertThat(mImpl.shouldTintIcon()).isTrue();
}
+
+ @Test
+ @Config(qualifiers = "mcc999")
+ public void testShouldTintIcon_disabledInResources_shouldBeFalse() {
+ assertThat(mImpl.shouldTintIcon()).isFalse();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentTest.java
index 9ba0807..14f3078 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentTest.java
@@ -58,15 +58,14 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DashboardFragmentTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Context mContext;
@Mock
- private DashboardCategory mDashboardCategory;
- @Mock
private FakeFeatureFactory mFakeFeatureFactory;
+ private DashboardCategory mDashboardCategory;
private TestFragment mTestFragment;
@Before
@@ -74,8 +73,8 @@
MockitoAnnotations.initMocks(this);
FakeFeatureFactory.setupForTest(mContext);
mFakeFeatureFactory = (FakeFeatureFactory) FeatureFactory.getFactory(mContext);
- mDashboardCategory.tiles = new ArrayList<>();
- mDashboardCategory.tiles.add(new Tile());
+ mDashboardCategory = new DashboardCategory();
+ mDashboardCategory.addTile(new Tile());
mTestFragment = new TestFragment(ShadowApplication.getInstance().getApplicationContext());
when(mFakeFeatureFactory.dashboardFeatureProvider
.getTilesForCategory(nullable(String.class)))
@@ -117,7 +116,7 @@
@Test
public void displayTilesAsPreference_withEmptyCategory_shouldNotAddTiles() {
- mDashboardCategory.tiles = null;
+ mDashboardCategory.removeTile(0);
mTestFragment.onCreatePreferences(new Bundle(), "rootKey");
verify(mTestFragment.mScreen, never()).addPreference(nullable(Preference.class));
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardItemAnimatorTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardItemAnimatorTest.java
index cda9a22..bb24435 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardItemAnimatorTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardItemAnimatorTest.java
@@ -31,7 +31,7 @@
import static com.google.common.truth.Truth.assertThat;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DashboardItemAnimatorTest {
private DashboardItemAnimator mDashboardItemAnimator;
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardSummaryTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardSummaryTest.java
index f3ed57c..2437565 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardSummaryTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardSummaryTest.java
@@ -47,7 +47,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DashboardSummaryTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardTilePlaceholderPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardTilePlaceholderPreferenceControllerTest.java
index c48f30c..6ea3222 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardTilePlaceholderPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardTilePlaceholderPreferenceControllerTest.java
@@ -37,7 +37,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DashboardTilePlaceholderPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/dashboard/SummaryLoaderTest.java b/tests/robotests/src/com/android/settings/dashboard/SummaryLoaderTest.java
index 44b6139..92ed7b4 100644
--- a/tests/robotests/src/com/android/settings/dashboard/SummaryLoaderTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/SummaryLoaderTest.java
@@ -41,7 +41,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SummaryLoaderTest {
private static final String SUMMARY_1 = "summary1";
diff --git a/tests/robotests/src/com/android/settings/dashboard/SupportItemAdapterTest.java b/tests/robotests/src/com/android/settings/dashboard/SupportItemAdapterTest.java
index 3dd5266..52c8fbb 100644
--- a/tests/robotests/src/com/android/settings/dashboard/SupportItemAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/SupportItemAdapterTest.java
@@ -49,7 +49,7 @@
import static org.robolectric.Shadows.shadowOf;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SupportItemAdapterTest {
private static final String ACCOUNT_TYPE = "com.google";
private final Account USER_1 = new Account("user1", ACCOUNT_TYPE);
diff --git a/tests/robotests/src/com/android/settings/dashboard/conditional/ConditionAdapterTest.java b/tests/robotests/src/com/android/settings/dashboard/conditional/ConditionAdapterTest.java
index d943fe3..03165c6 100644
--- a/tests/robotests/src/com/android/settings/dashboard/conditional/ConditionAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/conditional/ConditionAdapterTest.java
@@ -43,7 +43,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ConditionAdapterTest {
@Mock
private Condition mCondition1;
diff --git a/tests/robotests/src/com/android/settings/dashboard/conditional/ConditionTest.java b/tests/robotests/src/com/android/settings/dashboard/conditional/ConditionTest.java
index d077e6f..623f762 100644
--- a/tests/robotests/src/com/android/settings/dashboard/conditional/ConditionTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/conditional/ConditionTest.java
@@ -41,7 +41,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ConditionTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/dashboard/conditional/DndConditionTest.java b/tests/robotests/src/com/android/settings/dashboard/conditional/DndConditionTest.java
index e46ae9e..aa81a1c 100644
--- a/tests/robotests/src/com/android/settings/dashboard/conditional/DndConditionTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/conditional/DndConditionTest.java
@@ -35,7 +35,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DndConditionTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/dashboard/suggestions/EventStoreTest.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/EventStoreTest.java
index 114ee2b..9598c1e 100644
--- a/tests/robotests/src/com/android/settings/dashboard/suggestions/EventStoreTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/suggestions/EventStoreTest.java
@@ -29,7 +29,7 @@
import org.robolectric.RuntimeEnvironment;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class EventStoreTest {
private EventStore mEventStore;
diff --git a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java
index 1a170c8..b052527 100644
--- a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java
@@ -62,7 +62,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SuggestionAdapterTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionControllerMixinTest.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionControllerMixinTest.java
index c48978c..ad97e18 100644
--- a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionControllerMixinTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionControllerMixinTest.java
@@ -43,7 +43,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = {
ShadowSuggestionController.class
})
diff --git a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionDismissControllerTest.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionDismissControllerTest.java
index 4aced2f..c94f200 100644
--- a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionDismissControllerTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionDismissControllerTest.java
@@ -46,7 +46,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SuggestionDismissControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionFeaturizerTest.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionFeaturizerTest.java
index 4d6a743..f5e342b 100644
--- a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionFeaturizerTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionFeaturizerTest.java
@@ -32,7 +32,7 @@
import org.robolectric.RuntimeEnvironment;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SuggestionFeaturizerTest {
private EventStore mEventStore;
diff --git a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionRankerTest.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionRankerTest.java
index 1f32531..3698e4e 100644
--- a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionRankerTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionRankerTest.java
@@ -41,7 +41,7 @@
import static org.mockito.Mockito.spy;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SuggestionRankerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionStateProviderTest.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionStateProviderTest.java
index 2122d54..6ddba03 100644
--- a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionStateProviderTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionStateProviderTest.java
@@ -38,7 +38,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SuggestionStateProviderTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/datausage/AppDataUsagePreferenceTest.java b/tests/robotests/src/com/android/settings/datausage/AppDataUsagePreferenceTest.java
index 15ca6e4..4f7e216 100644
--- a/tests/robotests/src/com/android/settings/datausage/AppDataUsagePreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/AppDataUsagePreferenceTest.java
@@ -39,7 +39,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = ShadowThreadUtils.class)
public class AppDataUsagePreferenceTest {
diff --git a/tests/robotests/src/com/android/settings/datausage/AppDataUsageTest.java b/tests/robotests/src/com/android/settings/datausage/AppDataUsageTest.java
index 26071ed..75fec68 100644
--- a/tests/robotests/src/com/android/settings/datausage/AppDataUsageTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/AppDataUsageTest.java
@@ -57,7 +57,7 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = ShadowEntityHeaderController.class)
public class AppDataUsageTest {
diff --git a/tests/robotests/src/com/android/settings/datausage/AppPrefLoaderTest.java b/tests/robotests/src/com/android/settings/datausage/AppPrefLoaderTest.java
index ac28e1d..b6547ab 100644
--- a/tests/robotests/src/com/android/settings/datausage/AppPrefLoaderTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/AppPrefLoaderTest.java
@@ -44,7 +44,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AppPrefLoaderTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/datausage/BillingCycleSettingsTest.java b/tests/robotests/src/com/android/settings/datausage/BillingCycleSettingsTest.java
index 8b635d2..d735342 100644
--- a/tests/robotests/src/com/android/settings/datausage/BillingCycleSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/BillingCycleSettingsTest.java
@@ -38,7 +38,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BillingCycleSettingsTest {
private static final int LIMIT_BYTES = 123;
diff --git a/tests/robotests/src/com/android/settings/datausage/DataPlanSummaryPreferenceTest.java b/tests/robotests/src/com/android/settings/datausage/DataPlanSummaryPreferenceTest.java
index 9ddce53..a5dea97 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataPlanSummaryPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataPlanSummaryPreferenceTest.java
@@ -38,7 +38,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = {
SettingsShadowResources.class,
SettingsShadowResources.SettingsShadowTheme.class
diff --git a/tests/robotests/src/com/android/settings/datausage/DataPlanUsageSummaryTest.java b/tests/robotests/src/com/android/settings/datausage/DataPlanUsageSummaryTest.java
index 748c317..cf790e9 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataPlanUsageSummaryTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataPlanUsageSummaryTest.java
@@ -45,7 +45,7 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DataPlanUsageSummaryTest {
@Mock
private ConnectivityManager mManager;
diff --git a/tests/robotests/src/com/android/settings/datausage/DataPlansSyncTimePreferenceTest.java b/tests/robotests/src/com/android/settings/datausage/DataPlansSyncTimePreferenceTest.java
index ba2d5f1..1e2565e 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataPlansSyncTimePreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataPlansSyncTimePreferenceTest.java
@@ -35,7 +35,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class DataPlansSyncTimePreferenceTest {
private static final String SYNC_TIME = "Today 12:24pm";
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageInfoControllerTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageInfoControllerTest.java
index e60243b..57041fd 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataUsageInfoControllerTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageInfoControllerTest.java
@@ -13,7 +13,7 @@
import static com.google.common.truth.Truth.assertThat;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DataUsageInfoControllerTest {
private DataUsageInfoController mInfoController;
private DataUsageInfo info;
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageListTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageListTest.java
index 9ab88d3..59c99f4 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataUsageListTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageListTest.java
@@ -36,7 +36,7 @@
import static org.mockito.Mockito.verify;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DataUsageListTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryTest.java
index dc53ca1..179f743 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryTest.java
@@ -48,7 +48,7 @@
import java.util.ArrayList;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DataUsageSummaryTest {
@Mock
private ConnectivityManager mManager;
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageUtilsTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageUtilsTest.java
index cdcd3a9..1dacc68 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataUsageUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageUtilsTest.java
@@ -33,7 +33,7 @@
import org.robolectric.shadows.ShadowApplication;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class DataUsageUtilsTest {
@Mock private ConnectivityManager mManager;
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/datausage/ManageDataPlansPreferenceTest.java b/tests/robotests/src/com/android/settings/datausage/ManageDataPlansPreferenceTest.java
index 6eff393..e96b4e8 100644
--- a/tests/robotests/src/com/android/settings/datausage/ManageDataPlansPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/ManageDataPlansPreferenceTest.java
@@ -35,7 +35,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class ManageDataPlansPreferenceTest {
private Preference mPreference;
private PreferenceViewHolder mHolder;
diff --git a/tests/robotests/src/com/android/settings/datausage/UnrestrictedDataAccessTest.java b/tests/robotests/src/com/android/settings/datausage/UnrestrictedDataAccessTest.java
index f20e50c..081337f 100644
--- a/tests/robotests/src/com/android/settings/datausage/UnrestrictedDataAccessTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/UnrestrictedDataAccessTest.java
@@ -40,7 +40,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class UnrestrictedDataAccessTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/datetime/AutoTimeFormatPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/datetime/AutoTimeFormatPreferenceControllerTest.java
index 06969bb..f9784ef 100644
--- a/tests/robotests/src/com/android/settings/datetime/AutoTimeFormatPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/datetime/AutoTimeFormatPreferenceControllerTest.java
@@ -40,7 +40,7 @@
import org.robolectric.shadows.ShadowApplication;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AutoTimeFormatPreferenceControllerTest {
@Mock(answer = RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/datetime/AutoTimePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/datetime/AutoTimePreferenceControllerTest.java
index d28cad1..f4c1596 100644
--- a/tests/robotests/src/com/android/settings/datetime/AutoTimePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/datetime/AutoTimePreferenceControllerTest.java
@@ -35,7 +35,7 @@
import static org.mockito.Mockito.verify;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AutoTimePreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/datetime/AutoTimeZonePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/datetime/AutoTimeZonePreferenceControllerTest.java
index 5cbef72..950fd0d 100644
--- a/tests/robotests/src/com/android/settings/datetime/AutoTimeZonePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/datetime/AutoTimeZonePreferenceControllerTest.java
@@ -39,7 +39,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = ShadowConnectivityManager.class)
public class AutoTimeZonePreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/datetime/DatePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/datetime/DatePreferenceControllerTest.java
index f1d34f8..000dd2c 100644
--- a/tests/robotests/src/com/android/settings/datetime/DatePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/datetime/DatePreferenceControllerTest.java
@@ -37,7 +37,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DatePreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/datetime/TimeChangeListenerMixinTest.java b/tests/robotests/src/com/android/settings/datetime/TimeChangeListenerMixinTest.java
index ada59f4..524a88e 100644
--- a/tests/robotests/src/com/android/settings/datetime/TimeChangeListenerMixinTest.java
+++ b/tests/robotests/src/com/android/settings/datetime/TimeChangeListenerMixinTest.java
@@ -39,7 +39,7 @@
import static org.mockito.Mockito.verify;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class TimeChangeListenerMixinTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/datetime/TimeFormatPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/datetime/TimeFormatPreferenceControllerTest.java
index cd13513..2e975c3 100644
--- a/tests/robotests/src/com/android/settings/datetime/TimeFormatPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/datetime/TimeFormatPreferenceControllerTest.java
@@ -41,7 +41,7 @@
import static org.mockito.Mockito.verify;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class TimeFormatPreferenceControllerTest {
@Mock(answer = RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/datetime/TimePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/datetime/TimePreferenceControllerTest.java
index 89c5f47..afec523 100644
--- a/tests/robotests/src/com/android/settings/datetime/TimePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/datetime/TimePreferenceControllerTest.java
@@ -37,7 +37,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class TimePreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/datetime/TimeZonePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/datetime/TimeZonePreferenceControllerTest.java
index ec26448..aa10a70 100644
--- a/tests/robotests/src/com/android/settings/datetime/TimeZonePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/datetime/TimeZonePreferenceControllerTest.java
@@ -37,7 +37,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class TimeZonePreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/datetime/ZonePickerComparatorTest.java b/tests/robotests/src/com/android/settings/datetime/ZonePickerComparatorTest.java
index 4c1794c..10e5e5c 100644
--- a/tests/robotests/src/com/android/settings/datetime/ZonePickerComparatorTest.java
+++ b/tests/robotests/src/com/android/settings/datetime/ZonePickerComparatorTest.java
@@ -23,7 +23,7 @@
import static com.google.common.truth.Truth.assertThat;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ZonePickerComparatorTest {
// Strings in Chinese are sorted by alphabet order of their Pinyin.
diff --git a/tests/robotests/src/com/android/settings/datetime/ZonePickerTest.java b/tests/robotests/src/com/android/settings/datetime/ZonePickerTest.java
index 92807e9..09ff1cd 100644
--- a/tests/robotests/src/com/android/settings/datetime/ZonePickerTest.java
+++ b/tests/robotests/src/com/android/settings/datetime/ZonePickerTest.java
@@ -39,7 +39,7 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ZonePickerTest {
private Activity mActivity;
diff --git a/tests/robotests/src/com/android/settings/deletionhelper/AutomaticStorageManagerDescriptionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deletionhelper/AutomaticStorageManagerDescriptionPreferenceControllerTest.java
index dd438ff..d0f895a 100644
--- a/tests/robotests/src/com/android/settings/deletionhelper/AutomaticStorageManagerDescriptionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deletionhelper/AutomaticStorageManagerDescriptionPreferenceControllerTest.java
@@ -23,7 +23,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AutomaticStorageManagerDescriptionPreferenceControllerTest {
@Mock private PreferenceScreen mScreen;
@Mock private Preference mPreference;
diff --git a/tests/robotests/src/com/android/settings/deletionhelper/AutomaticStorageManagerSwitchBarControllerTest.java b/tests/robotests/src/com/android/settings/deletionhelper/AutomaticStorageManagerSwitchBarControllerTest.java
index 38c4ab2..3b98063 100644
--- a/tests/robotests/src/com/android/settings/deletionhelper/AutomaticStorageManagerSwitchBarControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deletionhelper/AutomaticStorageManagerSwitchBarControllerTest.java
@@ -51,7 +51,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AutomaticStorageManagerSwitchBarControllerTest {
private Context mContext;
private SwitchBar mSwitchBar;
diff --git a/tests/robotests/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceControllerTest.java
index 582400d..29f19df 100644
--- a/tests/robotests/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceControllerTest.java
@@ -46,7 +46,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AbstractBluetoothA2dpPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/AdbPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/AdbPreferenceControllerTest.java
index ddcd850..6dac819 100644
--- a/tests/robotests/src/com/android/settings/development/AdbPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/AdbPreferenceControllerTest.java
@@ -41,7 +41,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AdbPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/AllowAppsOnExternalPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/AllowAppsOnExternalPreferenceControllerTest.java
index e23c4cc..2703617 100644
--- a/tests/robotests/src/com/android/settings/development/AllowAppsOnExternalPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/AllowAppsOnExternalPreferenceControllerTest.java
@@ -44,7 +44,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AllowAppsOnExternalPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/AnimatorDurationScalePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/AnimatorDurationScalePreferenceControllerTest.java
index 5acaf0a..6c83e47 100644
--- a/tests/robotests/src/com/android/settings/development/AnimatorDurationScalePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/AnimatorDurationScalePreferenceControllerTest.java
@@ -44,7 +44,7 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AnimatorDurationScalePreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/AppsNotRespondingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/AppsNotRespondingPreferenceControllerTest.java
index 15c84b5..8850df0 100644
--- a/tests/robotests/src/com/android/settings/development/AppsNotRespondingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/AppsNotRespondingPreferenceControllerTest.java
@@ -43,7 +43,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AppsNotRespondingPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/BackgroundProcessLimitPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/BackgroundProcessLimitPreferenceControllerTest.java
index b384cd0..67b2abe 100644
--- a/tests/robotests/src/com/android/settings/development/BackgroundProcessLimitPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/BackgroundProcessLimitPreferenceControllerTest.java
@@ -40,7 +40,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BackgroundProcessLimitPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/BluetoothAbsoluteVolumePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/BluetoothAbsoluteVolumePreferenceControllerTest.java
index 09e6e9c..652832f 100644
--- a/tests/robotests/src/com/android/settings/development/BluetoothAbsoluteVolumePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/BluetoothAbsoluteVolumePreferenceControllerTest.java
@@ -43,7 +43,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class BluetoothAbsoluteVolumePreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/development/BluetoothAudioBitsPerSamplePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/BluetoothAudioBitsPerSamplePreferenceControllerTest.java
index fe0a41a..586d626 100644
--- a/tests/robotests/src/com/android/settings/development/BluetoothAudioBitsPerSamplePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/BluetoothAudioBitsPerSamplePreferenceControllerTest.java
@@ -40,7 +40,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BluetoothAudioBitsPerSamplePreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/BluetoothAudioChannelModePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/BluetoothAudioChannelModePreferenceControllerTest.java
index c4dcc19..2f51f1c 100644
--- a/tests/robotests/src/com/android/settings/development/BluetoothAudioChannelModePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/BluetoothAudioChannelModePreferenceControllerTest.java
@@ -40,7 +40,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BluetoothAudioChannelModePreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/BluetoothAudioCodecPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/BluetoothAudioCodecPreferenceControllerTest.java
index 29d8047..33cd3a1 100644
--- a/tests/robotests/src/com/android/settings/development/BluetoothAudioCodecPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/BluetoothAudioCodecPreferenceControllerTest.java
@@ -40,7 +40,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BluetoothAudioCodecPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/BluetoothAudioQualityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/BluetoothAudioQualityPreferenceControllerTest.java
index e76f1d0..20593dc 100644
--- a/tests/robotests/src/com/android/settings/development/BluetoothAudioQualityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/BluetoothAudioQualityPreferenceControllerTest.java
@@ -40,7 +40,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BluetoothAudioQualityPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/BluetoothAudioSampleRatePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/BluetoothAudioSampleRatePreferenceControllerTest.java
index 4c113b1..95f07c2 100644
--- a/tests/robotests/src/com/android/settings/development/BluetoothAudioSampleRatePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/BluetoothAudioSampleRatePreferenceControllerTest.java
@@ -40,7 +40,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BluetoothAudioSampleRatePreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/BluetoothAvrcpVersionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/BluetoothAvrcpVersionPreferenceControllerTest.java
index 07d0e50..3f993e5 100644
--- a/tests/robotests/src/com/android/settings/development/BluetoothAvrcpVersionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/BluetoothAvrcpVersionPreferenceControllerTest.java
@@ -45,7 +45,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class BluetoothAvrcpVersionPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/development/BluetoothDeviceNoNamePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/BluetoothDeviceNoNamePreferenceControllerTest.java
index 4e4d8fa..0bc527a 100644
--- a/tests/robotests/src/com/android/settings/development/BluetoothDeviceNoNamePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/BluetoothDeviceNoNamePreferenceControllerTest.java
@@ -42,7 +42,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class BluetoothDeviceNoNamePreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/development/BluetoothInbandRingingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/BluetoothInbandRingingPreferenceControllerTest.java
index 4074e25..d132224 100644
--- a/tests/robotests/src/com/android/settings/development/BluetoothInbandRingingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/BluetoothInbandRingingPreferenceControllerTest.java
@@ -45,7 +45,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class BluetoothInbandRingingPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/development/BluetoothSnoopLogPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/BluetoothSnoopLogPreferenceControllerTest.java
index 4fa991b..7d29637 100644
--- a/tests/robotests/src/com/android/settings/development/BluetoothSnoopLogPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/BluetoothSnoopLogPreferenceControllerTest.java
@@ -41,7 +41,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class BluetoothSnoopLogPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/development/BugReportInPowerPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/BugReportInPowerPreferenceControllerTest.java
index 82086dd..bce9b0d 100644
--- a/tests/robotests/src/com/android/settings/development/BugReportInPowerPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/BugReportInPowerPreferenceControllerTest.java
@@ -51,7 +51,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BugReportInPowerPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/BugReportPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/BugReportPreferenceControllerTest.java
index 908c519..77a109a 100644
--- a/tests/robotests/src/com/android/settings/development/BugReportPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/BugReportPreferenceControllerTest.java
@@ -35,7 +35,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BugReportPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/CameraLaserSensorPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/CameraLaserSensorPreferenceControllerTest.java
index 1443d16..21a01aa 100644
--- a/tests/robotests/src/com/android/settings/development/CameraLaserSensorPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/CameraLaserSensorPreferenceControllerTest.java
@@ -45,7 +45,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class CameraLaserSensorPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/development/ClearAdbKeysPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/ClearAdbKeysPreferenceControllerTest.java
index c4be569..471bf27 100644
--- a/tests/robotests/src/com/android/settings/development/ClearAdbKeysPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/ClearAdbKeysPreferenceControllerTest.java
@@ -54,7 +54,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class, ShadowUtils.class})
public class ClearAdbKeysPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/development/ConnectivityMonitorPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/ConnectivityMonitorPreferenceControllerTest.java
index 5e99ec9..bb974f4 100644
--- a/tests/robotests/src/com/android/settings/development/ConnectivityMonitorPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/ConnectivityMonitorPreferenceControllerTest.java
@@ -43,7 +43,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows =
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O, shadows =
SettingsShadowSystemProperties.class)
public class ConnectivityMonitorPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/development/CoolColorTemperaturePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/CoolColorTemperaturePreferenceControllerTest.java
index 16e6c2a..6e85ca6 100644
--- a/tests/robotests/src/com/android/settings/development/CoolColorTemperaturePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/CoolColorTemperaturePreferenceControllerTest.java
@@ -45,7 +45,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class CoolColorTemperaturePreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/development/DebugGpuOverdrawPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/DebugGpuOverdrawPreferenceControllerTest.java
index 2a35993..7aa34ca 100644
--- a/tests/robotests/src/com/android/settings/development/DebugGpuOverdrawPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/DebugGpuOverdrawPreferenceControllerTest.java
@@ -43,7 +43,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class DebugGpuOverdrawPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/development/DebugNonRectClipOperationsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/DebugNonRectClipOperationsPreferenceControllerTest.java
index 585fe51..877f7fb 100644
--- a/tests/robotests/src/com/android/settings/development/DebugNonRectClipOperationsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/DebugNonRectClipOperationsPreferenceControllerTest.java
@@ -43,7 +43,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class DebugNonRectClipOperationsPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/development/DebugViewAttributesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/DebugViewAttributesPreferenceControllerTest.java
index 76efa90..6256ddb 100644
--- a/tests/robotests/src/com/android/settings/development/DebugViewAttributesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/DebugViewAttributesPreferenceControllerTest.java
@@ -38,7 +38,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DebugViewAttributesPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/DevelopmentSettingsDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/development/DevelopmentSettingsDashboardFragmentTest.java
index 881ee84..43e389a 100644
--- a/tests/robotests/src/com/android/settings/development/DevelopmentSettingsDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/development/DevelopmentSettingsDashboardFragmentTest.java
@@ -52,7 +52,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DevelopmentSettingsDashboardFragmentTest {
private SwitchBar mSwitchBar;
diff --git a/tests/robotests/src/com/android/settings/development/DevelopmentSettingsDisabledActivityTest.java b/tests/robotests/src/com/android/settings/development/DevelopmentSettingsDisabledActivityTest.java
index 5927646..aa9a3a3 100644
--- a/tests/robotests/src/com/android/settings/development/DevelopmentSettingsDisabledActivityTest.java
+++ b/tests/robotests/src/com/android/settings/development/DevelopmentSettingsDisabledActivityTest.java
@@ -31,7 +31,7 @@
import static com.google.common.truth.Truth.assertThat;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DevelopmentSettingsDisabledActivityTest {
@Test
diff --git a/tests/robotests/src/com/android/settings/development/DevelopmentSwitchBarControllerTest.java b/tests/robotests/src/com/android/settings/development/DevelopmentSwitchBarControllerTest.java
index bfe30fb..f34bedf 100644
--- a/tests/robotests/src/com/android/settings/development/DevelopmentSwitchBarControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/DevelopmentSwitchBarControllerTest.java
@@ -44,7 +44,7 @@
import java.util.ArrayList;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = {
ShadowUtils.class
})
diff --git a/tests/robotests/src/com/android/settings/development/DisableAutomaticUpdatesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/DisableAutomaticUpdatesPreferenceControllerTest.java
index b4e0755..d1e2fd9 100644
--- a/tests/robotests/src/com/android/settings/development/DisableAutomaticUpdatesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/DisableAutomaticUpdatesPreferenceControllerTest.java
@@ -38,7 +38,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DisableAutomaticUpdatesPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/FileEncryptionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/FileEncryptionPreferenceControllerTest.java
index 1810b11..f94213f 100644
--- a/tests/robotests/src/com/android/settings/development/FileEncryptionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/FileEncryptionPreferenceControllerTest.java
@@ -51,7 +51,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class FileEncryptionPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/development/ForceGpuRenderingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/ForceGpuRenderingPreferenceControllerTest.java
index 66060a8..e81b422 100644
--- a/tests/robotests/src/com/android/settings/development/ForceGpuRenderingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/ForceGpuRenderingPreferenceControllerTest.java
@@ -43,7 +43,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class ForceGpuRenderingPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/development/ForceMSAAPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/ForceMSAAPreferenceControllerTest.java
index ca1ff08..5aaadb4 100644
--- a/tests/robotests/src/com/android/settings/development/ForceMSAAPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/ForceMSAAPreferenceControllerTest.java
@@ -40,7 +40,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class ForceMSAAPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/development/FreeformWindowsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/FreeformWindowsPreferenceControllerTest.java
index b4a4212..43757d0 100644
--- a/tests/robotests/src/com/android/settings/development/FreeformWindowsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/FreeformWindowsPreferenceControllerTest.java
@@ -45,7 +45,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class FreeformWindowsPreferenceControllerTest {
private static final String ENG_BUILD_TYPE = "eng";
diff --git a/tests/robotests/src/com/android/settings/development/GpuViewUpdatesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/GpuViewUpdatesPreferenceControllerTest.java
index ecb0da5..028c29e 100644
--- a/tests/robotests/src/com/android/settings/development/GpuViewUpdatesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/GpuViewUpdatesPreferenceControllerTest.java
@@ -41,7 +41,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class GpuViewUpdatesPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/development/HardwareLayersUpdatesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/HardwareLayersUpdatesPreferenceControllerTest.java
index 9288df9..e7c984b 100644
--- a/tests/robotests/src/com/android/settings/development/HardwareLayersUpdatesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/HardwareLayersUpdatesPreferenceControllerTest.java
@@ -41,7 +41,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class HardwareLayersUpdatesPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/development/HardwareOverlaysPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/HardwareOverlaysPreferenceControllerTest.java
index 09e48d3..31e910e 100644
--- a/tests/robotests/src/com/android/settings/development/HardwareOverlaysPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/HardwareOverlaysPreferenceControllerTest.java
@@ -47,7 +47,7 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class HardwareOverlaysPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/HdcpCheckingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/HdcpCheckingPreferenceControllerTest.java
index 434941c..a85075b 100644
--- a/tests/robotests/src/com/android/settings/development/HdcpCheckingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/HdcpCheckingPreferenceControllerTest.java
@@ -47,7 +47,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class HdcpCheckingPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/development/KeepActivitiesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/KeepActivitiesPreferenceControllerTest.java
index 02a5df6..9736365 100644
--- a/tests/robotests/src/com/android/settings/development/KeepActivitiesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/KeepActivitiesPreferenceControllerTest.java
@@ -42,7 +42,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class KeepActivitiesPreferenceControllerTest {
private static final int SETTING_VALUE_ON = 1;
diff --git a/tests/robotests/src/com/android/settings/development/LocalBackupPasswordPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/LocalBackupPasswordPreferenceControllerTest.java
index c698313..24b0290 100644
--- a/tests/robotests/src/com/android/settings/development/LocalBackupPasswordPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/LocalBackupPasswordPreferenceControllerTest.java
@@ -28,7 +28,7 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class LocalBackupPasswordPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/LocalTerminalPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/LocalTerminalPreferenceControllerTest.java
index bd33319..66e7ccd 100644
--- a/tests/robotests/src/com/android/settings/development/LocalTerminalPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/LocalTerminalPreferenceControllerTest.java
@@ -43,7 +43,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class LocalTerminalPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/LogPersistPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/LogPersistPreferenceControllerTest.java
index 1dc1255..b567dbe 100644
--- a/tests/robotests/src/com/android/settings/development/LogPersistPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/LogPersistPreferenceControllerTest.java
@@ -40,7 +40,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class LogPersistPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/development/LogdSizePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/LogdSizePreferenceControllerTest.java
index f7be653..ec0f492 100644
--- a/tests/robotests/src/com/android/settings/development/LogdSizePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/LogdSizePreferenceControllerTest.java
@@ -39,7 +39,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class LogdSizePreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/development/MemoryUsagePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/MemoryUsagePreferenceControllerTest.java
index d68f276..a769344 100644
--- a/tests/robotests/src/com/android/settings/development/MemoryUsagePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/MemoryUsagePreferenceControllerTest.java
@@ -41,7 +41,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class MemoryUsagePreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/MobileDataAlwaysOnPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/MobileDataAlwaysOnPreferenceControllerTest.java
index 01ed435..7f33630 100644
--- a/tests/robotests/src/com/android/settings/development/MobileDataAlwaysOnPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/MobileDataAlwaysOnPreferenceControllerTest.java
@@ -38,7 +38,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class MobileDataAlwaysOnPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/MockLocationAppPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/MockLocationAppPreferenceControllerTest.java
index 0aab0db..e136fc0 100644
--- a/tests/robotests/src/com/android/settings/development/MockLocationAppPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/MockLocationAppPreferenceControllerTest.java
@@ -39,7 +39,7 @@
import java.util.Collections;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class MockLocationAppPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/NotificationChannelWarningsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/NotificationChannelWarningsPreferenceControllerTest.java
index 5ad0329..f471f35 100644
--- a/tests/robotests/src/com/android/settings/development/NotificationChannelWarningsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/NotificationChannelWarningsPreferenceControllerTest.java
@@ -41,7 +41,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class NotificationChannelWarningsPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/OemUnlockPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/OemUnlockPreferenceControllerTest.java
index f59c29f..5018b75 100644
--- a/tests/robotests/src/com/android/settings/development/OemUnlockPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/OemUnlockPreferenceControllerTest.java
@@ -48,7 +48,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class OemUnlockPreferenceControllerTest {
@Mock
@@ -108,6 +108,7 @@
doReturn(false).when(mController).showKeyguardConfirmation(mResources,
REQUEST_CODE_ENABLE_OEM_UNLOCK);
doNothing().when(mController).confirmEnableOemUnlock();
+
mController.onPreferenceChange(null, true);
verify(mController).confirmEnableOemUnlock();
@@ -115,17 +116,20 @@
@Test
public void onPreferenceChanged_turnOffUnlock() {
+ mController = spy(mController);
mController.onPreferenceChange(null, false);
- verify(mOemLockManager).setOemUnlockAllowedByUser(false);
+ doReturn(false).when(mController).isBootloaderUnlocked();
+
verify(mFragment).getChildFragmentManager();
}
@Test
public void updateState_preferenceShouldBeCheckedAndShouldBeDisabled() {
mController = spy(mController);
- when(mOemLockManager.isOemUnlockAllowed()).thenReturn(true);
+ doReturn(true).when(mController).isOemUnlockedAllowed();
doReturn(true).when(mController).isOemUnlockAllowedByUserAndCarrier();
- when(mOemLockManager.isDeviceOemUnlocked()).thenReturn(true);
+ doReturn(true).when(mController).isBootloaderUnlocked();
+
mController.updateState(mPreference);
verify(mPreference).setChecked(true);
@@ -135,9 +139,10 @@
@Test
public void updateState_preferenceShouldBeUncheckedAndShouldBeDisabled() {
mController = spy(mController);
- when(mOemLockManager.isOemUnlockAllowed()).thenReturn(false);
+ doReturn(false).when(mController).isOemUnlockedAllowed();
doReturn(true).when(mController).isOemUnlockAllowedByUserAndCarrier();
- when(mOemLockManager.isDeviceOemUnlocked()).thenReturn(true);
+ doReturn(true).when(mController).isBootloaderUnlocked();
+
mController.updateState(mPreference);
verify(mPreference).setChecked(false);
@@ -147,9 +152,10 @@
@Test
public void updateState_preferenceShouldBeCheckedAndShouldBeEnabled() {
mController = spy(mController);
- when(mOemLockManager.isOemUnlockAllowed()).thenReturn(true);
+ doReturn(true).when(mController).isOemUnlockedAllowed();
doReturn(true).when(mController).isOemUnlockAllowedByUserAndCarrier();
- when(mOemLockManager.isDeviceOemUnlocked()).thenReturn(false);
+ doReturn(false).when(mController).isBootloaderUnlocked();
+
mController.updateState(mPreference);
verify(mPreference).setChecked(true);
@@ -176,7 +182,9 @@
public void onDeveloperOptionsEnabled_preferenceShouldCheckRestriction() {
mController = spy(mController);
doReturn(false).when(mController).isOemUnlockAllowedByUserAndCarrier();
+ doReturn(false).when(mController).isBootloaderUnlocked();
when(mPreference.isEnabled()).thenReturn(true);
+
mController.onDeveloperOptionsEnabled();
verify(mPreference).checkRestrictionAndSetDisabled(UserManager.DISALLOW_FACTORY_RESET);
@@ -186,8 +194,11 @@
@Test
public void onDeveloperOptionsDisabled_preferenceShouldCheckRestriction() {
mController = spy(mController);
+ doReturn(true).when(mController).isOemUnlockedAllowed();
doReturn(false).when(mController).isOemUnlockAllowedByUserAndCarrier();
+ doReturn(false).when(mController).isBootloaderUnlocked();
when(mPreference.isEnabled()).thenReturn(true);
+
mController.onDeveloperOptionsDisabled();
verify(mPreference).checkRestrictionAndSetDisabled(UserManager.DISALLOW_FACTORY_RESET);
diff --git a/tests/robotests/src/com/android/settings/development/PictureColorModePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/PictureColorModePreferenceControllerTest.java
index fac74ac..ff5ffd3 100644
--- a/tests/robotests/src/com/android/settings/development/PictureColorModePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/PictureColorModePreferenceControllerTest.java
@@ -43,7 +43,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class PictureColorModePreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/PointerLocationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/PointerLocationPreferenceControllerTest.java
index 6a6cd2c..120e4a4 100644
--- a/tests/robotests/src/com/android/settings/development/PointerLocationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/PointerLocationPreferenceControllerTest.java
@@ -40,7 +40,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class PointerLocationPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/ProfileGpuRenderingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/ProfileGpuRenderingPreferenceControllerTest.java
index 8175110..d6c6185 100644
--- a/tests/robotests/src/com/android/settings/development/ProfileGpuRenderingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/ProfileGpuRenderingPreferenceControllerTest.java
@@ -43,7 +43,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class ProfileGpuRenderingPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/development/ResizableActivityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/ResizableActivityPreferenceControllerTest.java
index 1289aec..3d6bd16 100644
--- a/tests/robotests/src/com/android/settings/development/ResizableActivityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/ResizableActivityPreferenceControllerTest.java
@@ -39,7 +39,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ResizableActivityPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/RtlLayoutPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/RtlLayoutPreferenceControllerTest.java
index 808e2a7..d607a27 100644
--- a/tests/robotests/src/com/android/settings/development/RtlLayoutPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/RtlLayoutPreferenceControllerTest.java
@@ -40,7 +40,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class RtlLayoutPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/SecondaryDisplayPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/SecondaryDisplayPreferenceControllerTest.java
index 485e441..d11c117 100644
--- a/tests/robotests/src/com/android/settings/development/SecondaryDisplayPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/SecondaryDisplayPreferenceControllerTest.java
@@ -39,7 +39,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SecondaryDisplayPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/SelectDebugAppPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/SelectDebugAppPreferenceControllerTest.java
index 03f4972..6c38cea 100644
--- a/tests/robotests/src/com/android/settings/development/SelectDebugAppPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/SelectDebugAppPreferenceControllerTest.java
@@ -48,7 +48,7 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SelectDebugAppPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/SelectUsbConfigPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/SelectUsbConfigPreferenceControllerTest.java
index 5a82ca0..bbbc52b 100644
--- a/tests/robotests/src/com/android/settings/development/SelectUsbConfigPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/SelectUsbConfigPreferenceControllerTest.java
@@ -57,7 +57,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {ShadowUtils.class})
public class SelectUsbConfigPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/development/SetGpuRendererPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/SetGpuRendererPreferenceControllerTest.java
index 7b3097b..9ad1540 100644
--- a/tests/robotests/src/com/android/settings/development/SetGpuRendererPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/SetGpuRendererPreferenceControllerTest.java
@@ -43,7 +43,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class SetGpuRendererPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/development/ShortcutManagerThrottlingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/ShortcutManagerThrottlingPreferenceControllerTest.java
index 0a189cb..6654f9a 100644
--- a/tests/robotests/src/com/android/settings/development/ShortcutManagerThrottlingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/ShortcutManagerThrottlingPreferenceControllerTest.java
@@ -40,7 +40,7 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ShortcutManagerThrottlingPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/ShowLayoutBoundsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/ShowLayoutBoundsPreferenceControllerTest.java
index 2eb1070..8320c97 100644
--- a/tests/robotests/src/com/android/settings/development/ShowLayoutBoundsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/ShowLayoutBoundsPreferenceControllerTest.java
@@ -41,7 +41,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class ShowLayoutBoundsPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/development/ShowSurfaceUpdatesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/ShowSurfaceUpdatesPreferenceControllerTest.java
index a5cfa22..94af993 100644
--- a/tests/robotests/src/com/android/settings/development/ShowSurfaceUpdatesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/ShowSurfaceUpdatesPreferenceControllerTest.java
@@ -47,7 +47,7 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ShowSurfaceUpdatesPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/ShowTapsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/ShowTapsPreferenceControllerTest.java
index 40e2fbd..d8fec93 100644
--- a/tests/robotests/src/com/android/settings/development/ShowTapsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/ShowTapsPreferenceControllerTest.java
@@ -40,7 +40,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ShowTapsPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/SimulateColorSpacePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/SimulateColorSpacePreferenceControllerTest.java
index 23c6e4c..3570368 100644
--- a/tests/robotests/src/com/android/settings/development/SimulateColorSpacePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/SimulateColorSpacePreferenceControllerTest.java
@@ -46,7 +46,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SimulateColorSpacePreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/StayAwakePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/StayAwakePreferenceControllerTest.java
index 41b9fde..2dd0caf 100644
--- a/tests/robotests/src/com/android/settings/development/StayAwakePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/StayAwakePreferenceControllerTest.java
@@ -45,7 +45,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class StayAwakePreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/StrictModePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/StrictModePreferenceControllerTest.java
index 0f839c1..fdc841b 100644
--- a/tests/robotests/src/com/android/settings/development/StrictModePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/StrictModePreferenceControllerTest.java
@@ -45,7 +45,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class StrictModePreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/development/TetheringHardwareAccelPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/TetheringHardwareAccelPreferenceControllerTest.java
index e044f2a..43798c0 100644
--- a/tests/robotests/src/com/android/settings/development/TetheringHardwareAccelPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/TetheringHardwareAccelPreferenceControllerTest.java
@@ -38,7 +38,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class TetheringHardwareAccelPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/TransitionAnimationScalePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/TransitionAnimationScalePreferenceControllerTest.java
index e8f9980..5da1abc 100644
--- a/tests/robotests/src/com/android/settings/development/TransitionAnimationScalePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/TransitionAnimationScalePreferenceControllerTest.java
@@ -44,7 +44,7 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class TransitionAnimationScalePreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/UsbAudioRoutingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/UsbAudioRoutingPreferenceControllerTest.java
index 4b7e82b..644e7c9 100644
--- a/tests/robotests/src/com/android/settings/development/UsbAudioRoutingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/UsbAudioRoutingPreferenceControllerTest.java
@@ -38,7 +38,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class UsbAudioRoutingPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/VerifyAppsOverUsbPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/VerifyAppsOverUsbPreferenceControllerTest.java
index e396ebe..4585b6d 100644
--- a/tests/robotests/src/com/android/settings/development/VerifyAppsOverUsbPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/VerifyAppsOverUsbPreferenceControllerTest.java
@@ -51,7 +51,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class VerifyAppsOverUsbPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/WaitForDebuggerPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/WaitForDebuggerPreferenceControllerTest.java
index e1d96d1..1d7f3f7 100644
--- a/tests/robotests/src/com/android/settings/development/WaitForDebuggerPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/WaitForDebuggerPreferenceControllerTest.java
@@ -50,7 +50,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class WaitForDebuggerPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/WebViewAppPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/WebViewAppPreferenceControllerTest.java
index 59f6e35..26331b1 100644
--- a/tests/robotests/src/com/android/settings/development/WebViewAppPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/WebViewAppPreferenceControllerTest.java
@@ -42,7 +42,7 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class WebViewAppPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/WifiAggressiveHandoverPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/WifiAggressiveHandoverPreferenceControllerTest.java
index ebda837..57b6e1d 100644
--- a/tests/robotests/src/com/android/settings/development/WifiAggressiveHandoverPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/WifiAggressiveHandoverPreferenceControllerTest.java
@@ -40,7 +40,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class WifiAggressiveHandoverPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/WifiDisplayCertificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/WifiDisplayCertificationPreferenceControllerTest.java
index c049bc1..9ca9b55d 100644
--- a/tests/robotests/src/com/android/settings/development/WifiDisplayCertificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/WifiDisplayCertificationPreferenceControllerTest.java
@@ -38,7 +38,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class WifiDisplayCertificationPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/WifiRoamScansPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/WifiRoamScansPreferenceControllerTest.java
index 60e5e49..a7a6608 100644
--- a/tests/robotests/src/com/android/settings/development/WifiRoamScansPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/WifiRoamScansPreferenceControllerTest.java
@@ -35,7 +35,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class WifiRoamScansPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/WifiVerboseLoggingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/WifiVerboseLoggingPreferenceControllerTest.java
index f8a9b87..09a5e9c 100644
--- a/tests/robotests/src/com/android/settings/development/WifiVerboseLoggingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/WifiVerboseLoggingPreferenceControllerTest.java
@@ -35,7 +35,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class WifiVerboseLoggingPreferenceControllerTest {
@Mock
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/development/WindowAnimationScalePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/WindowAnimationScalePreferenceControllerTest.java
index 0fbff3b..c7e2258 100644
--- a/tests/robotests/src/com/android/settings/development/WindowAnimationScalePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/WindowAnimationScalePreferenceControllerTest.java
@@ -44,7 +44,7 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class WindowAnimationScalePreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/featureflags/FeatureFlagsDashboardTest.java b/tests/robotests/src/com/android/settings/development/featureflags/FeatureFlagsDashboardTest.java
index 0839a02..1fd07c3 100644
--- a/tests/robotests/src/com/android/settings/development/featureflags/FeatureFlagsDashboardTest.java
+++ b/tests/robotests/src/com/android/settings/development/featureflags/FeatureFlagsDashboardTest.java
@@ -29,7 +29,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class FeatureFlagsDashboardTest {
private FeatureFlagsDashboard mDashboard;
diff --git a/tests/robotests/src/com/android/settings/development/qstile/DevelopmentTilePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/qstile/DevelopmentTilePreferenceControllerTest.java
index 1cdff20..e4c479e 100644
--- a/tests/robotests/src/com/android/settings/development/qstile/DevelopmentTilePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/qstile/DevelopmentTilePreferenceControllerTest.java
@@ -45,7 +45,7 @@
import org.robolectric.shadows.ShadowPackageManager;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DevelopmentTilePreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/BasebandVersionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/BasebandVersionPreferenceControllerTest.java
index a7d7355..f71bae6 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/BasebandVersionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/BasebandVersionPreferenceControllerTest.java
@@ -24,6 +24,7 @@
import android.support.v7.preference.Preference;
import com.android.settings.TestConfig;
+import com.android.settings.deviceinfo.firmwareversion.BasebandVersionDialogController;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowSystemProperties;
import com.android.settings.testutils.shadow.ShadowConnectivityManager;
@@ -36,6 +37,10 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
+/**
+ * Deprecated in favor of {@link BasebandVersionDialogController}
+ */
+@Deprecated
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
shadows = ShadowConnectivityManager.class)
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/BatteryInfoPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/BatteryInfoPreferenceControllerTest.java
index 0ccc139..5587f4b 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/BatteryInfoPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/BatteryInfoPreferenceControllerTest.java
@@ -50,7 +50,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BatteryInfoPreferenceControllerTest {
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java
index 16de8ea..8312673 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java
@@ -58,7 +58,7 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = {
ShadowUtils.class
})
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/FccEquipmentIdPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/FccEquipmentIdPreferenceControllerTest.java
index 951d8c7..c77a279 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/FccEquipmentIdPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/FccEquipmentIdPreferenceControllerTest.java
@@ -36,7 +36,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class FccEquipmentIdPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/FeedbackPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/FeedbackPreferenceControllerTest.java
index dfc1a0c..293127c 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/FeedbackPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/FeedbackPreferenceControllerTest.java
@@ -34,7 +34,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class FeedbackPreferenceControllerTest {
@Mock
private Fragment mFragment;
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/FirmwareVersionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/FirmwareVersionPreferenceControllerTest.java
index 207d58e..09b2e7f 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/FirmwareVersionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/FirmwareVersionPreferenceControllerTest.java
@@ -25,6 +25,7 @@
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.TestConfig;
+import com.android.settings.deviceinfo.firmwareversion.FirmwareVersionDialogController;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -36,6 +37,10 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
+/**
+ * Deprecated in favor of {@link FirmwareVersionDialogController}
+ */
+@Deprecated
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class FirmwareVersionPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/KernelVersionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/KernelVersionPreferenceControllerTest.java
index 10e4958..a889e9b 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/KernelVersionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/KernelVersionPreferenceControllerTest.java
@@ -30,7 +30,7 @@
import static com.google.common.truth.Truth.assertThat;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class KernelVersionPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/ManualPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/ManualPreferenceControllerTest.java
index 6151ca0..916c45d 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/ManualPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/ManualPreferenceControllerTest.java
@@ -34,7 +34,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ManualPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/PrivateVolumeOptionMenuControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/PrivateVolumeOptionMenuControllerTest.java
index 6363317..866b53d 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/PrivateVolumeOptionMenuControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/PrivateVolumeOptionMenuControllerTest.java
@@ -43,7 +43,7 @@
import org.robolectric.shadows.ShadowApplication;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class PrivateVolumeOptionMenuControllerTest {
@Mock
private MenuItem mMigrateMenuItem;
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/RegulatoryInfoPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/RegulatoryInfoPreferenceControllerTest.java
index 4ea33ee..99a835f 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/RegulatoryInfoPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/RegulatoryInfoPreferenceControllerTest.java
@@ -42,7 +42,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class RegulatoryInfoPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/StorageDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/deviceinfo/StorageDashboardFragmentTest.java
index b1296e5..8ad91cd 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/StorageDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/StorageDashboardFragmentTest.java
@@ -52,7 +52,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class StorageDashboardFragmentTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private StorageManager mStorageManager;
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/StorageItemPreferenceTest.java b/tests/robotests/src/com/android/settings/deviceinfo/StorageItemPreferenceTest.java
index 5b34c7d..cec1887 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/StorageItemPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/StorageItemPreferenceTest.java
@@ -35,7 +35,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class StorageItemPreferenceTest {
private Context mContext;
private StorageItemPreference mPreference;
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/StorageProfileFragmentTest.java b/tests/robotests/src/com/android/settings/deviceinfo/StorageProfileFragmentTest.java
index b0f464c..80aebab 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/StorageProfileFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/StorageProfileFragmentTest.java
@@ -37,7 +37,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class StorageProfileFragmentTest {
@Captor
private ArgumentCaptor<SparseArray<StorageAsyncLoader.AppsStorageResult>> mCaptor;
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/StorageSettingsTest.java b/tests/robotests/src/com/android/settings/deviceinfo/StorageSettingsTest.java
index 5e95a61..cc8b31d 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/StorageSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/StorageSettingsTest.java
@@ -48,7 +48,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class StorageSettingsTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/UsbBackendTest.java b/tests/robotests/src/com/android/settings/deviceinfo/UsbBackendTest.java
index ce384a5..5939174 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/UsbBackendTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/UsbBackendTest.java
@@ -37,7 +37,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class UsbBackendTest {
@Mock(answer = RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/UsbModeChooserActivityTest.java b/tests/robotests/src/com/android/settings/deviceinfo/UsbModeChooserActivityTest.java
index 1817bfb..34246b4 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/UsbModeChooserActivityTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/UsbModeChooserActivityTest.java
@@ -32,7 +32,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class UsbModeChooserActivityTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceControllerV2Test.java b/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceControllerV2Test.java
index 5fa8a91..d27d880 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceControllerV2Test.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceControllerV2Test.java
@@ -43,7 +43,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class FirmwareVersionPreferenceControllerV2Test {
@Mock
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogControllerTest.java
index c95c4db..921c41f 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogControllerTest.java
@@ -49,7 +49,7 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ImeiInfoDialogControllerTest {
private static final String PRL_VERSION = "some_prl_version";
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerV2Test.java b/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerV2Test.java
index 3fed589..f077386 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerV2Test.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerV2Test.java
@@ -50,7 +50,7 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ImeiInfoPreferenceControllerV2Test {
@Mock
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogControllerTest.java
index fd48162..3eb4955 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogControllerTest.java
@@ -68,7 +68,7 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SimStatusDialogControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/simstatus/SimStatusPreferenceControllerV2Test.java b/tests/robotests/src/com/android/settings/deviceinfo/simstatus/SimStatusPreferenceControllerV2Test.java
index 53324b5..ec6b0be 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/simstatus/SimStatusPreferenceControllerV2Test.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/simstatus/SimStatusPreferenceControllerV2Test.java
@@ -48,7 +48,7 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SimStatusPreferenceControllerV2Test {
@Mock
diff --git a/tests/robotests/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceControllerTest.java
index dfe81db..d1d479a 100644
--- a/tests/robotests/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceControllerTest.java
@@ -17,7 +17,11 @@
package com.android.settings.display;
import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -41,22 +45,27 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = {ShadowSecureSettings.class})
public class AmbientDisplayAlwaysOnPreferenceControllerTest {
- @Mock Context mContext;
- @Mock AmbientDisplayConfiguration mConfig;
- @Mock SwitchPreference mSwitchPreference;
+ @Mock
+ private Context mContext;
+ @Mock
+ private AmbientDisplayConfiguration mConfig;
+ @Mock
+ private SwitchPreference mSwitchPreference;
- AmbientDisplayAlwaysOnPreferenceController mController;
- boolean mCallbackInvoked;
+ private AmbientDisplayAlwaysOnPreferenceController mController;
+ private boolean mCallbackInvoked;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mController = new AmbientDisplayAlwaysOnPreferenceController(mContext, mConfig,
- () -> { mCallbackInvoked = true; });
+ () -> {
+ mCallbackInvoked = true;
+ });
}
@Test
@@ -91,7 +100,7 @@
mController.onPreferenceChange(mSwitchPreference, true);
assertThat(Settings.Secure.getInt(null, Settings.Secure.DOZE_ALWAYS_ON, -1))
- .isEqualTo(1);
+ .isEqualTo(1);
}
@Test
@@ -99,39 +108,45 @@
mController.onPreferenceChange(mSwitchPreference, false);
assertThat(Settings.Secure.getInt(null, Settings.Secure.DOZE_ALWAYS_ON, -1))
- .isEqualTo(0);
+ .isEqualTo(0);
}
@Test
public void isAvailable_available() throws Exception {
- when(mConfig.alwaysOnAvailableForUser(anyInt()))
- .thenReturn(true);
+ mController = spy(mController);
+ doReturn(true).when(mController).alwaysOnAvailableForUser(any());
assertThat(mController.isAvailable()).isTrue();
}
@Test
public void isAvailable_unavailable() throws Exception {
- when(mConfig.alwaysOnAvailableForUser(anyInt()))
- .thenReturn(false);
+ mController = spy(mController);
+ doReturn(false).when(mController).alwaysOnAvailableForUser(any());
+
assertThat(mController.isAvailable()).isFalse();
}
@Test
public void testPreferenceController_ProperResultPayloadType() {
+ mController = spy(mController);
+ doReturn(false).when(mController).alwaysOnAvailableForUser(any());
assertThat(mController.getResultPayload()).isInstanceOf(InlineSwitchPayload.class);
}
@Test
@Config(shadows = ShadowSecureSettings.class)
public void testSetValue_updatesCorrectly() {
- int newValue = 1;
- ContentResolver resolver = mContext.getContentResolver();
- Settings.Secure.putInt(resolver, Settings.Secure.DOZE_ALWAYS_ON, 0);
+ mController = spy(mController);
+ doReturn(false).when(mController).alwaysOnAvailableForUser(any());
+ final int newValue = 1;
+ final ContentResolver resolver = mContext.getContentResolver();
+ Settings.Secure.putInt(resolver, Settings.Secure.DOZE_ALWAYS_ON, 0 /* value */);
((InlinePayload) mController.getResultPayload()).setValue(mContext, newValue);
- int updatedValue = Settings.Secure.getInt(resolver, Settings.Secure.DOZE_ALWAYS_ON, 1);
+ final int updatedValue = Settings.Secure.getInt(resolver,
+ Settings.Secure.DOZE_ALWAYS_ON, 1 /* default */);
assertThat(updatedValue).isEqualTo(newValue);
}
@@ -139,11 +154,13 @@
@Test
@Config(shadows = ShadowSecureSettings.class)
public void testGetValue_correctValueReturned() {
- int currentValue = 1;
- ContentResolver resolver = mContext.getContentResolver();
+ mController = spy(mController);
+ doReturn(false).when(mController).alwaysOnAvailableForUser(any());
+ final int currentValue = 1;
+ final ContentResolver resolver = mContext.getContentResolver();
Settings.Secure.putInt(resolver, Settings.Secure.DOZE_ALWAYS_ON, currentValue);
- int newValue = ((InlinePayload) mController.getResultPayload()).getValue(mContext);
+ final int newValue = ((InlinePayload) mController.getResultPayload()).getValue(mContext);
assertThat(newValue).isEqualTo(currentValue);
}
diff --git a/tests/robotests/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceControllerTest.java
index e1ce694..d442c82 100644
--- a/tests/robotests/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceControllerTest.java
@@ -46,7 +46,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = {ShadowSecureSettings.class})
public class AmbientDisplayNotificationsPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/display/AmbientDisplayPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/AmbientDisplayPreferenceControllerTest.java
index 2933517..123dd85 100644
--- a/tests/robotests/src/com/android/settings/display/AmbientDisplayPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/AmbientDisplayPreferenceControllerTest.java
@@ -39,7 +39,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = {ShadowSecureSettings.class})
public class AmbientDisplayPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/display/AppGridViewTest.java b/tests/robotests/src/com/android/settings/display/AppGridViewTest.java
index d0a92c9..a2cc76d 100644
--- a/tests/robotests/src/com/android/settings/display/AppGridViewTest.java
+++ b/tests/robotests/src/com/android/settings/display/AppGridViewTest.java
@@ -18,9 +18,16 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
import android.content.Context;
import android.content.pm.ActivityInfo;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.graphics.drawable.Drawable;
import android.util.IconDrawableFactory;
import com.android.settings.TestConfig;
@@ -35,13 +42,19 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AppGridViewTest {
@Mock
private ResolveInfo mInfo;
@Mock
private ActivityInfo mActivityInfo;
+ @Mock
+ private ApplicationInfo mApplicationInfo;
+ @Mock
+ private Drawable mIcon;
+ @Mock
+ private PackageManager mPackageManager;
private Context mContext;
private IconDrawableFactory mIconFactory;
@@ -49,13 +62,16 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
mInfo.activityInfo = mActivityInfo;
- mContext = RuntimeEnvironment.application;
+ mInfo.activityInfo.applicationInfo = mApplicationInfo;
+ mContext = spy(RuntimeEnvironment.application);
+ doReturn(mPackageManager).when(mContext).getPackageManager();
mIconFactory = IconDrawableFactory.newInstance(mContext);
}
@Test
public void appEntry_shouldLoadIcon() {
-
+ when(mPackageManager.loadUnbadgedItemIcon(mActivityInfo, mApplicationInfo)).thenReturn(
+ mIcon);
final AppGridView.ActivityEntry activityEntry = new AppGridView.ActivityEntry(
mInfo, "label", mIconFactory);
diff --git a/tests/robotests/src/com/android/settings/display/AutoBrightnessPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/AutoBrightnessPreferenceControllerTest.java
index b46441d..4acf609 100644
--- a/tests/robotests/src/com/android/settings/display/AutoBrightnessPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/AutoBrightnessPreferenceControllerTest.java
@@ -19,6 +19,7 @@
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE;
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL;
+
import static com.google.common.truth.Truth.assertThat;
import android.content.ContentResolver;
@@ -26,9 +27,6 @@
import android.provider.Settings;
import com.android.settings.TestConfig;
-import com.android.settings.search.InlinePayload;
-import com.android.settings.search.InlineSwitchPayload;
-import com.android.settings.search.ResultPayload;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
@@ -38,10 +36,9 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowApplication;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AutoBrightnessPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Context mContext;
@@ -74,33 +71,27 @@
}
@Test
- public void testPreferenceController_ProperResultPayloadType() {
- final Context context = ShadowApplication.getInstance().getApplicationContext();
- mController = new AutoBrightnessPreferenceController(context, PREFERENCE_KEY);
- ResultPayload payload = mController.getResultPayload();
- assertThat(payload).isInstanceOf(InlineSwitchPayload.class);
- }
-
- @Test
public void testSetValue_updatesCorrectly() {
- int newValue = 1;
+ boolean newValue = true;
ContentResolver resolver = mContext.getContentResolver();
- Settings.System.putInt(resolver, SCREEN_BRIGHTNESS_MODE, 0);
+ Settings.System.putInt(resolver, SCREEN_BRIGHTNESS_MODE, SCREEN_BRIGHTNESS_MODE_MANUAL);
- ((InlinePayload) mController.getResultPayload()).setValue(mContext, newValue);
- int updatedValue = Settings.System.getInt(resolver, SCREEN_BRIGHTNESS_MODE, -1);
+ mController.setChecked(newValue);
+ boolean updatedValue = Settings.System.getInt(resolver, SCREEN_BRIGHTNESS_MODE, -1)
+ != SCREEN_BRIGHTNESS_MODE_MANUAL;
assertThat(updatedValue).isEqualTo(newValue);
}
@Test
public void testGetValue_correctValueReturned() {
- int currentValue = 1;
ContentResolver resolver = mContext.getContentResolver();
- Settings.System.putInt(resolver, SCREEN_BRIGHTNESS_MODE, currentValue);
+ Settings.System.putInt(resolver, SCREEN_BRIGHTNESS_MODE, SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
- int newValue = ((InlinePayload) mController.getResultPayload()).getValue(mContext);
+ int newValue = mController.isChecked() ?
+ SCREEN_BRIGHTNESS_MODE_AUTOMATIC
+ : SCREEN_BRIGHTNESS_MODE_MANUAL;
- assertThat(newValue).isEqualTo(currentValue);
+ assertThat(newValue).isEqualTo(SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
}
}
diff --git a/tests/robotests/src/com/android/settings/display/AutoRotatePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/AutoRotatePreferenceControllerTest.java
index 091ae1a..febbaf1 100644
--- a/tests/robotests/src/com/android/settings/display/AutoRotatePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/AutoRotatePreferenceControllerTest.java
@@ -48,7 +48,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(
manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = ShadowSystemSettings.class
)
public class AutoRotatePreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/display/BatteryPercentagePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/BatteryPercentagePreferenceControllerTest.java
index 73c5374..655cf51 100644
--- a/tests/robotests/src/com/android/settings/display/BatteryPercentagePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/BatteryPercentagePreferenceControllerTest.java
@@ -31,7 +31,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BatteryPercentagePreferenceControllerTest {
@Mock private Context mContext;
private BatteryPercentagePreferenceController mController;
diff --git a/tests/robotests/src/com/android/settings/display/BrightnessLevelPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/BrightnessLevelPreferenceControllerTest.java
index 95144bd..f8999b5 100644
--- a/tests/robotests/src/com/android/settings/display/BrightnessLevelPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/BrightnessLevelPreferenceControllerTest.java
@@ -46,7 +46,7 @@
import org.robolectric.shadows.ShadowContentResolver;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BrightnessLevelPreferenceControllerTest {
@Mock
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/display/ColorModePreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/display/ColorModePreferenceFragmentTest.java
index dc3d27a..dc9dc5b 100644
--- a/tests/robotests/src/com/android/settings/display/ColorModePreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/display/ColorModePreferenceFragmentTest.java
@@ -46,7 +46,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ColorModePreferenceFragmentTest {
private ColorModePreferenceFragment mFragment;
diff --git a/tests/robotests/src/com/android/settings/display/NightDisplaySettingsTest.java b/tests/robotests/src/com/android/settings/display/NightDisplaySettingsTest.java
new file mode 100644
index 0000000..113e7ec
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/display/NightDisplaySettingsTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.display;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.provider.SearchIndexableResource;
+
+import com.android.settings.R;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
+public class NightDisplaySettingsTest {
+
+ private Context mContext;
+
+ @Before
+ public void setUp() {
+ mContext = RuntimeEnvironment.application;
+ }
+
+ @Test
+ public void testNightDisplayIndexing_containsResource() {
+ List<SearchIndexableResource> resources =
+ NightDisplaySettings.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(mContext,
+ true /* enabled */);
+
+ List<Integer> indexedXml = new ArrayList<>();
+ for (SearchIndexableResource resource : resources) {
+ indexedXml.add(resource.xmlResId);
+ }
+
+ assertThat(indexedXml).contains(R.xml.night_display_settings);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/display/ShowOperatorNamePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/ShowOperatorNamePreferenceControllerTest.java
index 23b43d6..4d701ca 100644
--- a/tests/robotests/src/com/android/settings/display/ShowOperatorNamePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/ShowOperatorNamePreferenceControllerTest.java
@@ -36,7 +36,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ShowOperatorNamePreferenceControllerTest {
private static final String KEY_SHOW_OPERATOR_NAME = "show_operator_name";
diff --git a/tests/robotests/src/com/android/settings/display/ThemePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/ThemePreferenceControllerTest.java
index 3d99f65..289b8c1 100644
--- a/tests/robotests/src/com/android/settings/display/ThemePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/ThemePreferenceControllerTest.java
@@ -47,7 +47,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ThemePreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/display/TimeoutPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/TimeoutPreferenceControllerTest.java
index 480e41f..48997c3 100644
--- a/tests/robotests/src/com/android/settings/display/TimeoutPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/TimeoutPreferenceControllerTest.java
@@ -33,7 +33,7 @@
import static com.google.common.truth.Truth.assertThat;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class TimeoutPreferenceControllerTest {
private static final int TIMEOUT = 30;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/display/VrDisplayPreferencePickerTest.java b/tests/robotests/src/com/android/settings/display/VrDisplayPreferencePickerTest.java
index 191a8fb..f874007 100644
--- a/tests/robotests/src/com/android/settings/display/VrDisplayPreferencePickerTest.java
+++ b/tests/robotests/src/com/android/settings/display/VrDisplayPreferencePickerTest.java
@@ -39,7 +39,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class VrDisplayPreferencePickerTest {
private VrDisplayPreferencePicker mPicker;
diff --git a/tests/robotests/src/com/android/settings/display/WallpaperPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/WallpaperPreferenceControllerTest.java
index 1419ad5..17d12c0 100644
--- a/tests/robotests/src/com/android/settings/display/WallpaperPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/WallpaperPreferenceControllerTest.java
@@ -43,7 +43,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class WallpaperPreferenceControllerTest {
private static final String WALLPAPER_PACKAGE = "TestPkg";
diff --git a/tests/robotests/src/com/android/settings/dream/CurrentDreamPickerTest.java b/tests/robotests/src/com/android/settings/dream/CurrentDreamPickerTest.java
index bd25d92..e0a59b5 100644
--- a/tests/robotests/src/com/android/settings/dream/CurrentDreamPickerTest.java
+++ b/tests/robotests/src/com/android/settings/dream/CurrentDreamPickerTest.java
@@ -42,7 +42,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class CurrentDreamPickerTest {
private static String COMPONENT_KEY = "mocked_component_name_string";
diff --git a/tests/robotests/src/com/android/settings/dream/CurrentDreamPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/dream/CurrentDreamPreferenceControllerTest.java
index e3493a1..b0ef640 100644
--- a/tests/robotests/src/com/android/settings/dream/CurrentDreamPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/dream/CurrentDreamPreferenceControllerTest.java
@@ -41,7 +41,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class CurrentDreamPreferenceControllerTest {
private static String TAG = "CurrentDreamPreferenceControllerTest";
diff --git a/tests/robotests/src/com/android/settings/dream/DreamSettingsTest.java b/tests/robotests/src/com/android/settings/dream/DreamSettingsTest.java
index 73526e5..ba3aab5 100644
--- a/tests/robotests/src/com/android/settings/dream/DreamSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/dream/DreamSettingsTest.java
@@ -33,7 +33,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DreamSettingsTest {
private static final List<String> KEYS = Arrays.asList(
DreamSettings.WHILE_CHARGING_ONLY,
diff --git a/tests/robotests/src/com/android/settings/dream/StartNowPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/dream/StartNowPreferenceControllerTest.java
index 444591a..7e310c3 100644
--- a/tests/robotests/src/com/android/settings/dream/StartNowPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/dream/StartNowPreferenceControllerTest.java
@@ -40,7 +40,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class StartNowPreferenceControllerTest {
private StartNowPreferenceController mController;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/dream/WhenToDreamPickerTest.java b/tests/robotests/src/com/android/settings/dream/WhenToDreamPickerTest.java
index bafc2d4..542e0b7 100644
--- a/tests/robotests/src/com/android/settings/dream/WhenToDreamPickerTest.java
+++ b/tests/robotests/src/com/android/settings/dream/WhenToDreamPickerTest.java
@@ -37,7 +37,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class WhenToDreamPickerTest {
private WhenToDreamPicker mPicker;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/dream/WhenToDreamPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/dream/WhenToDreamPreferenceControllerTest.java
index 2acf82b..4763f29 100644
--- a/tests/robotests/src/com/android/settings/dream/WhenToDreamPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/dream/WhenToDreamPreferenceControllerTest.java
@@ -37,7 +37,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class WhenToDreamPreferenceControllerTest {
private WhenToDreamPreferenceController mController;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/enterprise/AdminActionPreferenceControllerBaseTest.java b/tests/robotests/src/com/android/settings/enterprise/AdminActionPreferenceControllerBaseTest.java
index 111e503..24a96b1 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AdminActionPreferenceControllerBaseTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AdminActionPreferenceControllerBaseTest.java
@@ -31,7 +31,7 @@
* Tests for {@link AdminActionPreferenceControllerBase}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class AdminActionPreferenceControllerBaseTest extends
AdminActionPreferenceControllerTestBase {
diff --git a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedCameraPermissionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedCameraPermissionPreferenceControllerTest.java
index 1154aa7..b003ad8 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedCameraPermissionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedCameraPermissionPreferenceControllerTest.java
@@ -28,7 +28,7 @@
* Tests for {@link AdminGrantedCameraPermissionPreferenceController}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class AdminGrantedCameraPermissionPreferenceControllerTest extends
AdminGrantedPermissionsPreferenceControllerTestBase {
diff --git a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedLocationPermissionsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedLocationPermissionsPreferenceControllerTest.java
index 1c30da1..2fb3e21 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedLocationPermissionsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedLocationPermissionsPreferenceControllerTest.java
@@ -28,7 +28,7 @@
* Tests for {@link AdminGrantedLocationPermissionsPreferenceController}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class AdminGrantedLocationPermissionsPreferenceControllerTest extends
AdminGrantedPermissionsPreferenceControllerTestBase {
diff --git a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedMicrophonePermissionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedMicrophonePermissionPreferenceControllerTest.java
index 624022b..9ee8100 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedMicrophonePermissionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedMicrophonePermissionPreferenceControllerTest.java
@@ -28,7 +28,7 @@
* Tests for {@link AdminGrantedMicrophonePermissionPreferenceController}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class AdminGrantedMicrophonePermissionPreferenceControllerTest extends
AdminGrantedPermissionsPreferenceControllerTestBase {
diff --git a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerBaseTest.java b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerBaseTest.java
index a5d1d1a..918c5fb 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerBaseTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerBaseTest.java
@@ -26,7 +26,7 @@
* Tests for {@link AdminGrantedPermissionsPreferenceControllerBase}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class AdminGrantedPermissionsPreferenceControllerBaseTest extends
AdminGrantedPermissionsPreferenceControllerTestBase {
diff --git a/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnCurrentUserPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnCurrentUserPreferenceControllerTest.java
index 365b9be..17649bb 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnCurrentUserPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnCurrentUserPreferenceControllerTest.java
@@ -39,7 +39,7 @@
* Tests for {@link AlwaysOnVpnCurrentUserPreferenceController}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class AlwaysOnVpnCurrentUserPreferenceControllerTest {
private static final String VPN_SET_DEVICE = "VPN set";
diff --git a/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnManagedProfilePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnManagedProfilePreferenceControllerTest.java
index 5f921cd..d54505b 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnManagedProfilePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnManagedProfilePreferenceControllerTest.java
@@ -38,7 +38,7 @@
* Tests for {@link AlwaysOnVpnManagedProfilePreferenceController}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class AlwaysOnVpnManagedProfilePreferenceControllerTest {
private static final String KEY_ALWAYS_ON_VPN_MANAGED_PROFILE = "always_on_vpn_managed_profile";
diff --git a/tests/robotests/src/com/android/settings/enterprise/ApplicationListFragmentTest.java b/tests/robotests/src/com/android/settings/enterprise/ApplicationListFragmentTest.java
index 80d4aaf..fce2719 100644
--- a/tests/robotests/src/com/android/settings/enterprise/ApplicationListFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/ApplicationListFragmentTest.java
@@ -46,7 +46,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ApplicationListFragmentTest {
private static final int USER_ID = 0;
private static final int USER_APP_UID = 0;
diff --git a/tests/robotests/src/com/android/settings/enterprise/ApplicationListPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/ApplicationListPreferenceControllerTest.java
index 81223a5..963b2ce 100644
--- a/tests/robotests/src/com/android/settings/enterprise/ApplicationListPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/ApplicationListPreferenceControllerTest.java
@@ -17,11 +17,15 @@
package com.android.settings.enterprise;
import static com.android.settings.testutils.ApplicationTestUtils.buildInfo;
+
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.Answers.RETURNS_DEEP_STUBS;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -29,6 +33,7 @@
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
+import android.os.UserManager;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
@@ -54,7 +59,7 @@
import java.util.Set;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ApplicationListPreferenceControllerTest {
private static final int MAIN_USER_ID = 0;
@@ -74,6 +79,8 @@
private PackageManager mPackageManager;
@Mock(answer = RETURNS_DEEP_STUBS)
private SettingsPreferenceFragment mFragment;
+ @Mock
+ private UserManager mUserManager;
private Context mContext;
private ApplicationListPreferenceController mController;
@@ -82,7 +89,8 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
final ShadowApplication shadowContext = ShadowApplication.getInstance();
- mContext = shadowContext.getApplicationContext();
+ mContext = spy(shadowContext.getApplicationContext());
+ doReturn(mUserManager).when(mContext).getSystemService(UserManager.class);
when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
when(mFragment.getPreferenceManager().getContext()).thenReturn(mContext);
when(mPackageManager.getText(eq(APP_1), anyInt(), any())).thenReturn(APP_1);
diff --git a/tests/robotests/src/com/android/settings/enterprise/BugReportsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/BugReportsPreferenceControllerTest.java
index 0b97353..cc1de27 100644
--- a/tests/robotests/src/com/android/settings/enterprise/BugReportsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/BugReportsPreferenceControllerTest.java
@@ -32,7 +32,7 @@
* Tests for {@link BugReportsPreferenceController}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class BugReportsPreferenceControllerTest extends
AdminActionPreferenceControllerTestBase {
diff --git a/tests/robotests/src/com/android/settings/enterprise/CaCertsCurrentUserPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/CaCertsCurrentUserPreferenceControllerTest.java
index 5ee1145..c933d18 100644
--- a/tests/robotests/src/com/android/settings/enterprise/CaCertsCurrentUserPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/CaCertsCurrentUserPreferenceControllerTest.java
@@ -35,7 +35,7 @@
* Tests for {@link CaCertsCurrentUserPreferenceController}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class CaCertsCurrentUserPreferenceControllerTest extends
CaCertsPreferenceControllerTestBase {
diff --git a/tests/robotests/src/com/android/settings/enterprise/CaCertsManagedProfilePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/CaCertsManagedProfilePreferenceControllerTest.java
index 2aa5306..d246488 100644
--- a/tests/robotests/src/com/android/settings/enterprise/CaCertsManagedProfilePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/CaCertsManagedProfilePreferenceControllerTest.java
@@ -28,7 +28,7 @@
* Tests for {@link CaCertsManagedProfilePreferenceController}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class CaCertsManagedProfilePreferenceControllerTest extends
CaCertsPreferenceControllerTestBase {
diff --git a/tests/robotests/src/com/android/settings/enterprise/CaCertsPreferenceControllerBaseTest.java b/tests/robotests/src/com/android/settings/enterprise/CaCertsPreferenceControllerBaseTest.java
index ec76b2b..7a6bc88 100644
--- a/tests/robotests/src/com/android/settings/enterprise/CaCertsPreferenceControllerBaseTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/CaCertsPreferenceControllerBaseTest.java
@@ -28,7 +28,7 @@
* Tests for {@link CaCertsPreferenceControllerBase}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class CaCertsPreferenceControllerBaseTest extends CaCertsPreferenceControllerTestBase {
private static final String PREF_KEY = "pref";
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceControllerTest.java
index b4f7827..7ecd0e3 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceControllerTest.java
@@ -45,7 +45,7 @@
* Tests for {@link EnterpriseInstalledPackagesPreferenceController}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class EnterpriseInstalledPackagesPreferenceControllerTest {
private static final String KEY_NUMBER_ENTERPRISE_INSTALLED_PACKAGES
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImplTest.java
index 1ea2567..516ccb5 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImplTest.java
@@ -57,7 +57,7 @@
* Tests for {@link EnterprisePrivacyFeatureProviderImpl}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class EnterprisePrivacyFeatureProviderImplTest {
private final ComponentName OWNER = new ComponentName("dummy", "component");
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyPreferenceControllerTest.java
index 18f16f4..dd97cc0 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyPreferenceControllerTest.java
@@ -39,7 +39,7 @@
* Tests for {@link EnterprisePrivacyPreferenceController}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class EnterprisePrivacyPreferenceControllerTest {
private static final String MANAGED_GENERIC = "managed by organization";
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java
index a2b539d..1a37e63 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java
@@ -44,7 +44,7 @@
* Tests for {@link EnterprisePrivacySettings}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class EnterprisePrivacySettingsTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsListFragmentTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsListFragmentTest.java
index 567c06f..c47a0ac 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsListFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsListFragmentTest.java
@@ -42,7 +42,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class EnterpriseSetDefaultAppsListFragmentTest {
@Mock(answer = RETURNS_DEEP_STUBS)
private PreferenceScreen mScreen;
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsListPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsListPreferenceControllerTest.java
index c38f56a..cf66967 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsListPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsListPreferenceControllerTest.java
@@ -59,7 +59,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class EnterpriseSetDefaultAppsListPreferenceControllerTest {
private static final int USER_ID = 0;
private static final int APP_UID = 0;
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsPreferenceControllerTest.java
index 9eb6d66..1223558 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsPreferenceControllerTest.java
@@ -52,7 +52,7 @@
* Tests for {@link EnterpriseSetDefaultAppsPreferenceController}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class EnterpriseSetDefaultAppsPreferenceControllerTest {
private static final String KEY_DEFAULT_APPS = "number_enterprise_set_default_apps";
diff --git a/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipeCurrentUserPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipeCurrentUserPreferenceControllerTest.java
index 8453d62..77d6ea0 100644
--- a/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipeCurrentUserPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipeCurrentUserPreferenceControllerTest.java
@@ -28,7 +28,7 @@
* Tests for {@link FailedPasswordWipeCurrentUserPreferenceController}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class FailedPasswordWipeCurrentUserPreferenceControllerTest extends
FailedPasswordWipePreferenceControllerTestBase {
diff --git a/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipeManagedProfilePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipeManagedProfilePreferenceControllerTest.java
index a001a9c..c88c22b 100644
--- a/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipeManagedProfilePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipeManagedProfilePreferenceControllerTest.java
@@ -28,7 +28,7 @@
* Tests for {@link FailedPasswordWipeManagedProfilePreferenceController}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class FailedPasswordWipeManagedProfilePreferenceControllerTest extends
FailedPasswordWipePreferenceControllerTestBase {
diff --git a/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerBaseTest.java b/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerBaseTest.java
index f80667c..ecc490f 100644
--- a/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerBaseTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerBaseTest.java
@@ -26,7 +26,7 @@
* Tests for {@link FailedPasswordWipePreferenceControllerBase}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class FailedPasswordWipePreferenceControllerBaseTest extends
FailedPasswordWipePreferenceControllerTestBase {
diff --git a/tests/robotests/src/com/android/settings/enterprise/GlobalHttpProxyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/GlobalHttpProxyPreferenceControllerTest.java
index b9c24bf..e31b40f 100644
--- a/tests/robotests/src/com/android/settings/enterprise/GlobalHttpProxyPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/GlobalHttpProxyPreferenceControllerTest.java
@@ -38,7 +38,7 @@
* Tests for {@link GlobalHttpProxyPreferenceController}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class GlobalHttpProxyPreferenceControllerTest {
private static final String KEY_GLOBAL_HTTP_PROXY = "global_http_proxy";
diff --git a/tests/robotests/src/com/android/settings/enterprise/ImePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/ImePreferenceControllerTest.java
index 1e05383..caa5121 100644
--- a/tests/robotests/src/com/android/settings/enterprise/ImePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/ImePreferenceControllerTest.java
@@ -39,7 +39,7 @@
* Tests for {@link ImePreferenceController}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class ImePreferenceControllerTest {
private static final String DEFAULT_IME_LABEL = "Test IME";
diff --git a/tests/robotests/src/com/android/settings/enterprise/ManageDeviceAdminPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/ManageDeviceAdminPreferenceControllerTest.java
index 2df05c2..f46ecce 100644
--- a/tests/robotests/src/com/android/settings/enterprise/ManageDeviceAdminPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/ManageDeviceAdminPreferenceControllerTest.java
@@ -39,7 +39,7 @@
* Tests for {@link ManageDeviceAdminPreferenceController}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class ManageDeviceAdminPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/enterprise/NetworkLogsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/NetworkLogsPreferenceControllerTest.java
index 43b793d..e8f7398 100644
--- a/tests/robotests/src/com/android/settings/enterprise/NetworkLogsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/NetworkLogsPreferenceControllerTest.java
@@ -32,7 +32,7 @@
* Tests for {@link NetworkLogsPreferenceController}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class NetworkLogsPreferenceControllerTest extends
AdminActionPreferenceControllerTestBase {
diff --git a/tests/robotests/src/com/android/settings/enterprise/SecurityLogsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/SecurityLogsPreferenceControllerTest.java
index 11e219a..7a597dc 100644
--- a/tests/robotests/src/com/android/settings/enterprise/SecurityLogsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/SecurityLogsPreferenceControllerTest.java
@@ -32,7 +32,7 @@
* Tests for {@link SecurityLogsPreferenceController}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public final class SecurityLogsPreferenceControllerTest extends
AdminActionPreferenceControllerTestBase {
diff --git a/tests/robotests/src/com/android/settings/fingerprint/DeleteFingerprintDialogTest.java b/tests/robotests/src/com/android/settings/fingerprint/DeleteFingerprintDialogTest.java
index c3c1b42..125977f 100644
--- a/tests/robotests/src/com/android/settings/fingerprint/DeleteFingerprintDialogTest.java
+++ b/tests/robotests/src/com/android/settings/fingerprint/DeleteFingerprintDialogTest.java
@@ -17,6 +17,10 @@
package com.android.settings.fingerprint;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
import android.app.Dialog;
import android.hardware.fingerprint.Fingerprint;
@@ -26,6 +30,7 @@
.DeleteFingerprintDialog;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.ShadowEventLogWriter;
+import com.android.settings.testutils.shadow.ShadowFragment;
import org.junit.Before;
import org.junit.Test;
@@ -35,27 +40,25 @@
import org.robolectric.annotation.Config;
import org.robolectric.util.FragmentTestUtil;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = {
- ShadowEventLogWriter.class
+ ShadowEventLogWriter.class,
+ ShadowFragment.class
})
public class DeleteFingerprintDialogTest {
@Mock
- private FingerprintSettingsFragment mTarget;
- @Mock
private Fingerprint mFingerprint;
- private DeleteFingerprintDialog mFragment;
+ @Mock
+ private FingerprintSettingsFragment mTarget;
+ private DeleteFingerprintDialog mFragment;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mFragment = DeleteFingerprintDialog.newInstance(mFingerprint, mTarget);
+ mFragment = spy(DeleteFingerprintDialog.newInstance(mFingerprint, mTarget));
}
@Test
diff --git a/tests/robotests/src/com/android/settings/fingerprint/FingerprintEnrollEnrollingTest.java b/tests/robotests/src/com/android/settings/fingerprint/FingerprintEnrollEnrollingTest.java
index ace535e..190d65d 100644
--- a/tests/robotests/src/com/android/settings/fingerprint/FingerprintEnrollEnrollingTest.java
+++ b/tests/robotests/src/com/android/settings/fingerprint/FingerprintEnrollEnrollingTest.java
@@ -57,7 +57,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(
manifest = TestConfig.MANIFEST_PATH,
- sdk = Config.NEWEST_SDK,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {
ShadowUtils.class,
ShadowVibrator.class
diff --git a/tests/robotests/src/com/android/settings/fingerprint/FingerprintEnrollFindSensorTest.java b/tests/robotests/src/com/android/settings/fingerprint/FingerprintEnrollFindSensorTest.java
index d495b74..d479e1e 100644
--- a/tests/robotests/src/com/android/settings/fingerprint/FingerprintEnrollFindSensorTest.java
+++ b/tests/robotests/src/com/android/settings/fingerprint/FingerprintEnrollFindSensorTest.java
@@ -55,7 +55,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(
manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {
SettingsShadowResources.class,
SettingsShadowResources.SettingsShadowTheme.class,
diff --git a/tests/robotests/src/com/android/settings/fingerprint/FingerprintEnrollSuggestionActivityTest.java b/tests/robotests/src/com/android/settings/fingerprint/FingerprintEnrollSuggestionActivityTest.java
index e299fd5..2856325 100644
--- a/tests/robotests/src/com/android/settings/fingerprint/FingerprintEnrollSuggestionActivityTest.java
+++ b/tests/robotests/src/com/android/settings/fingerprint/FingerprintEnrollSuggestionActivityTest.java
@@ -38,7 +38,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class FingerprintEnrollSuggestionActivityTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/fingerprint/FingerprintLocationAnimationVideoViewTest.java b/tests/robotests/src/com/android/settings/fingerprint/FingerprintLocationAnimationVideoViewTest.java
index 7b7e440..f80b324 100644
--- a/tests/robotests/src/com/android/settings/fingerprint/FingerprintLocationAnimationVideoViewTest.java
+++ b/tests/robotests/src/com/android/settings/fingerprint/FingerprintLocationAnimationVideoViewTest.java
@@ -37,7 +37,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class FingerprintLocationAnimationVideoViewTest {
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/fingerprint/FingerprintPreferenceTest.java b/tests/robotests/src/com/android/settings/fingerprint/FingerprintPreferenceTest.java
index 29c6f10..23e0e73 100644
--- a/tests/robotests/src/com/android/settings/fingerprint/FingerprintPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/fingerprint/FingerprintPreferenceTest.java
@@ -39,7 +39,7 @@
import static org.mockito.Mockito.verify;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class FingerprintPreferenceTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/fingerprint/FingerprintSuggestionActivityTest.java b/tests/robotests/src/com/android/settings/fingerprint/FingerprintSuggestionActivityTest.java
index 0254bcb..0e4446f 100644
--- a/tests/robotests/src/com/android/settings/fingerprint/FingerprintSuggestionActivityTest.java
+++ b/tests/robotests/src/com/android/settings/fingerprint/FingerprintSuggestionActivityTest.java
@@ -50,7 +50,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(
manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {
ShadowEventLogWriter.class,
ShadowLockPatternUtils.class,
diff --git a/tests/robotests/src/com/android/settings/fingerprint/SetupFingerprintEnrollFindSensorTest.java b/tests/robotests/src/com/android/settings/fingerprint/SetupFingerprintEnrollFindSensorTest.java
index c3899e9..f9d1994 100644
--- a/tests/robotests/src/com/android/settings/fingerprint/SetupFingerprintEnrollFindSensorTest.java
+++ b/tests/robotests/src/com/android/settings/fingerprint/SetupFingerprintEnrollFindSensorTest.java
@@ -47,7 +47,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(
manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {
SettingsShadowResources.class,
SettingsShadowResources.SettingsShadowTheme.class,
diff --git a/tests/robotests/src/com/android/settings/fingerprint/SetupFingerprintEnrollIntroductionTest.java b/tests/robotests/src/com/android/settings/fingerprint/SetupFingerprintEnrollIntroductionTest.java
index 2d98bf4..bf5c187 100644
--- a/tests/robotests/src/com/android/settings/fingerprint/SetupFingerprintEnrollIntroductionTest.java
+++ b/tests/robotests/src/com/android/settings/fingerprint/SetupFingerprintEnrollIntroductionTest.java
@@ -60,7 +60,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(
manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {
ShadowEventLogWriter.class,
ShadowFingerprintManager.class,
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java b/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java
index c9fcf26..99b0945 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java
@@ -78,7 +78,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = {ShadowEntityHeaderController.class, ShadowActivityManager.class})
public class AdvancedPowerUsageDetailTest {
private static final String APP_LABEL = "app label";
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/AppButtonsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/AppButtonsPreferenceControllerTest.java
index ad5f5b0..5c28a06 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/AppButtonsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/AppButtonsPreferenceControllerTest.java
@@ -66,7 +66,7 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(RobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AppButtonsPreferenceControllerTest {
private static final String PACKAGE_NAME = "com.android.settings";
private static final String RESOURCE_STRING = "string";
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BackgroundActivityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BackgroundActivityPreferenceControllerTest.java
index e010cf3..cb5914f 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BackgroundActivityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BackgroundActivityPreferenceControllerTest.java
@@ -39,6 +39,7 @@
import com.android.settings.R;
import com.android.settings.TestConfig;
import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settings.testutils.shadow.ShadowFragment;
import com.android.settings.wrapper.DevicePolicyManagerWrapper;
import org.junit.Before;
@@ -57,10 +58,11 @@
@RunWith(RobolectricTestRunner.class)
@Config(
manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {
SettingsShadowResources.class,
- SettingsShadowResources.SettingsShadowTheme.class
+ SettingsShadowResources.SettingsShadowTheme.class,
+ ShadowFragment.class
})
public class BackgroundActivityPreferenceControllerTest {
private static final int UID_LOW_SDK = 1234;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryBroadcastReceiverTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryBroadcastReceiverTest.java
index a163a43..30b3448 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryBroadcastReceiverTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryBroadcastReceiverTest.java
@@ -41,7 +41,7 @@
import static org.mockito.Mockito.verify;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BatteryBroadcastReceiverTest {
private static final String BATTERY_INIT_LEVEL = "100%";
private static final String BATTERY_INIT_STATUS = "Not charging";
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryEntryTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryEntryTest.java
index a57b6ca..04040ac 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryEntryTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryEntryTest.java
@@ -43,7 +43,7 @@
import static org.mockito.Mockito.when;
@RunWith(RobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BatteryEntryTest {
private static final int APP_UID = 123;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceControllerTest.java
index 719cc33..e433b3c 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceControllerTest.java
@@ -43,6 +43,7 @@
import com.android.settings.applications.LayoutPreference;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
import com.android.settings.testutils.shadow.ShadowEntityHeaderController;
import com.android.settings.widget.EntityHeaderController;
import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -58,9 +59,10 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {
SettingsShadowResources.class,
+ SettingsShadowResourcesImpl.class,
SettingsShadowResources.SettingsShadowTheme.class,
ShadowEntityHeaderController.class
})
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryHistoryPreferenceTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryHistoryPreferenceTest.java
index 0d03512..60d06cd 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryHistoryPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryHistoryPreferenceTest.java
@@ -44,7 +44,8 @@
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O
+ ,
shadows = {
SettingsShadowResources.class,
SettingsShadowResources.SettingsShadowTheme.class
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoLoaderTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoLoaderTest.java
index b87089a..5029897 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoLoaderTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoLoaderTest.java
@@ -42,7 +42,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BatteryInfoLoaderTest {
private static final long TEST_TIME_REMAINING = 1000L;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java
index d82a89b..dd6b709 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java
@@ -58,7 +58,7 @@
import java.util.concurrent.TimeUnit;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BatteryInfoTest {
private static final String STATUS_FULL = "Full";
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryMeterViewTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryMeterViewTest.java
index 3a1fad0..fba6a24 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryMeterViewTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryMeterViewTest.java
@@ -39,7 +39,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
// TODO: Consider making the shadow class set global using a robolectric.properties file.
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {
SettingsShadowResources.class,
SettingsShadowTheme.class,
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryOptimizationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryOptimizationPreferenceControllerTest.java
index 77e3198..8b8541a 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryOptimizationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryOptimizationPreferenceControllerTest.java
@@ -45,7 +45,7 @@
import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BatteryOptimizationPreferenceControllerTest {
private static final String PKG_IN_WHITELIST = "com.pkg.in.whitelist";
private static final String PKG_NOT_IN_WHITELIST = "com.pkg.not.in.whitelist";
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverControllerTest.java
index c75a6a6..eeca72f 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverControllerTest.java
@@ -37,7 +37,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BatterySaverControllerTest {
@Mock
private MasterSwitchPreference mBatterySaverPref;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverReceiverTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverReceiverTest.java
index 259bcd2..944f755 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverReceiverTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverReceiverTest.java
@@ -33,7 +33,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BatterySaverReceiverTest {
@Mock
private BatterySaverReceiver.BatterySaverListener mBatterySaverListener;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverSettingsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverSettingsTest.java
index 0e32f6b..a7bcf53 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverSettingsTest.java
@@ -35,7 +35,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BatterySaverSettingsTest {
private Context mContext;
private BatterySaverSettings mBatterySaverSettings;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryStatsHelperLoaderTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryStatsHelperLoaderTest.java
index 5f8d7cf..5ba98f2 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryStatsHelperLoaderTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryStatsHelperLoaderTest.java
@@ -36,7 +36,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BatteryStatsHelperLoaderTest {
@Mock
private BatteryUtils mBatteryUtils;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java
index c08b01d..56abf48 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java
@@ -69,7 +69,7 @@
import static org.mockito.Mockito.spy;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BatteryUtilsTest {
// unit that used to converted ms to us
private static final long UNIT = 1000;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/ButtonActionDialogFragmentTest.java b/tests/robotests/src/com/android/settings/fuelgauge/ButtonActionDialogFragmentTest.java
index dec445d..468c160 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/ButtonActionDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/ButtonActionDialogFragmentTest.java
@@ -45,7 +45,7 @@
import org.robolectric.util.FragmentTestUtil;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows = {
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O, shadows = {
ShadowEventLogWriter.class
})
public class ButtonActionDialogFragmentTest {
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/HighPowerDetailTest.java b/tests/robotests/src/com/android/settings/fuelgauge/HighPowerDetailTest.java
index d87020e..fe3cd29 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/HighPowerDetailTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/HighPowerDetailTest.java
@@ -36,7 +36,7 @@
import static org.mockito.Mockito.verify;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class HighPowerDetailTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerGaugePreferenceTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerGaugePreferenceTest.java
index 32f6a96..e2f5fad 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerGaugePreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerGaugePreferenceTest.java
@@ -38,7 +38,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class PowerGaugePreferenceTest {
private static final String SUBTITLE = "Summary";
private static final String CONTENT_DESCRIPTION = "Content description";
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java
index 2b5e704..2056262 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java
@@ -63,7 +63,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class PowerUsageAdvancedTest {
private static final int FAKE_UID_1 = 50;
private static final int FAKE_UID_2 = 100;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAnomalyDetailsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAnomalyDetailsTest.java
index c992d0a..c6040c0 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAnomalyDetailsTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAnomalyDetailsTest.java
@@ -59,7 +59,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class PowerUsageAnomalyDetailsTest {
private static final String NAME_APP_1 = "app1";
private static final String NAME_APP_2 = "app2";
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageBaseTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageBaseTest.java
index 9e0d4de..df829aa 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageBaseTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageBaseTest.java
@@ -47,7 +47,7 @@
* Unit tests for {@link PowerUsageBase}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = ShadowDashboardFragment.class)
public class PowerUsageBaseTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageFeatureProviderImplTest.java
index afda69f..6961b60 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageFeatureProviderImplTest.java
@@ -33,7 +33,7 @@
import static com.google.common.truth.Truth.assertThat;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class PowerUsageFeatureProviderImplTest {
private static final int UID_OTHER = Process.FIRST_APPLICATION_UID + 2;
private static final int UID_CALENDAR = Process.FIRST_APPLICATION_UID + 3;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
index 4385409..5be2fe6 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
@@ -86,7 +86,7 @@
// TODO: Improve this test class so that it starts up the real activity and fragment.
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {
SettingsShadowResources.class,
SettingsShadowResources.SettingsShadowTheme.class,
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyDetectionPolicyTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyDetectionPolicyTest.java
index 46db6b3..4ecd1dd 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyDetectionPolicyTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyDetectionPolicyTest.java
@@ -39,7 +39,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AnomalyDetectionPolicyTest {
private static final String ANOMALY_DETECTION_CONSTANTS_VALUE =
"anomaly_detection_enabled=true"
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyDialogFragmentTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyDialogFragmentTest.java
index 6b3791a..ccce08f 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyDialogFragmentTest.java
@@ -49,7 +49,7 @@
import org.robolectric.util.FragmentTestUtil;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = ShadowRuntimePermissionPresenter.class)
public class AnomalyDialogFragmentTest {
private static final String PACKAGE_NAME = "com.android.app";
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyLoaderTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyLoaderTest.java
index 48749d5..dfb7d21 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyLoaderTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyLoaderTest.java
@@ -49,7 +49,8 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O
+)
public class AnomalyLoaderTest {
private static final String PACKAGE_NAME = "com.android.settings";
private static final CharSequence DISPLAY_NAME = "Settings";
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyPreferenceTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyPreferenceTest.java
index c0157ae..7061b8a 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyPreferenceTest.java
@@ -31,7 +31,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AnomalyPreferenceTest {
@Anomaly.AnomalyType
private static final int ANOMALY_TYPE = Anomaly.AnomalyType.WAKE_LOCK;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalySummaryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalySummaryPreferenceControllerTest.java
index 3f48d0a..1114e6a 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalySummaryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalySummaryPreferenceControllerTest.java
@@ -30,6 +30,7 @@
import android.content.Context;
import android.support.v14.preference.PreferenceFragment;
import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
import com.android.settings.SettingsActivity;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
@@ -48,7 +49,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AnomalySummaryPreferenceControllerTest {
@Anomaly.AnomalyType
private static final int ANOMALY_TYPE = Anomaly.AnomalyType.WAKE_LOCK;
@@ -56,7 +57,7 @@
private static final String DISPLAY_NAME = "appName";
private static final int UID = 111;
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ @Mock
private PreferenceFragment mFragment;
@Mock
private FragmentManager mFragmentManager;
@@ -64,6 +65,9 @@
private FragmentTransaction mFragmentTransaction;
@Mock
private SettingsActivity mSettingsActivity;
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
+
private AnomalySummaryPreferenceController mAnomalySummaryPreferenceController;
private Preference mPreference;
private Context mContext;
@@ -76,11 +80,12 @@
mContext = RuntimeEnvironment.application;
mPreference = new Preference(mContext);
mPreference.setKey(AnomalySummaryPreferenceController.ANOMALY_KEY);
- when(mFragment.getPreferenceScreen().findPreference(any())).thenReturn(mPreference);
+ when(mFragment.getPreferenceScreen()).thenReturn(mPreferenceScreen);
when(mFragment.getFragmentManager()).thenReturn(mFragmentManager);
when(mFragmentManager.beginTransaction()).thenReturn(mFragmentTransaction);
when(mFragment.getContext()).thenReturn(mContext);
when(mSettingsActivity.getApplicationContext()).thenReturn(mContext);
+ when(mPreferenceScreen.findPreference(any())).thenReturn(mPreference);
mAnomalyList = new ArrayList<>();
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyTest.java
index 13a5b31..dae1141 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyTest.java
@@ -29,7 +29,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AnomalyTest {
private static int TYPE = Anomaly.AnomalyType.WAKE_LOCK;
private static int UID = 111;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyUtilsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyUtilsTest.java
index 38391c9..d37d01e 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyUtilsTest.java
@@ -45,7 +45,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows = {
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O, shadows = {
ShadowKeyValueListParserWrapperImpl.class})
public class AnomalyUtilsTest {
private static final String PACKAGE_NAME_WAKEUP = "com.android.app1";
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/AnomalyActionTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/AnomalyActionTest.java
index 8db1a8c..6f3e9b4 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/AnomalyActionTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/AnomalyActionTest.java
@@ -38,7 +38,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AnomalyActionTest {
private static final String PACKAGE_NAME = "com.android.app";
private static final int UID = 111;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/BackgroundCheckActionTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/BackgroundCheckActionTest.java
index 7e5fc4a..e72039a 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/BackgroundCheckActionTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/BackgroundCheckActionTest.java
@@ -40,7 +40,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BackgroundCheckActionTest {
private static final String PACKAGE_NAME = "com.android.app";
private static final int UID = 111;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/ForceStopActionTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/ForceStopActionTest.java
index 89b1a16..fcb029c 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/ForceStopActionTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/ForceStopActionTest.java
@@ -40,7 +40,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ForceStopActionTest {
private static final String PACKAGE_NAME = "com.android.app";
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/LocationCheckActionTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/LocationCheckActionTest.java
index 234dd12..d2b6fcb 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/LocationCheckActionTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/LocationCheckActionTest.java
@@ -37,7 +37,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows =
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O, shadows =
ShadowPermissionChecker.class)
public class LocationCheckActionTest {
private static final String PACKAGE_NAME = "com.android.app";
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/StopAndBackgroundActionTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/StopAndBackgroundActionTest.java
index c06bddd..de7402b 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/StopAndBackgroundActionTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/StopAndBackgroundActionTest.java
@@ -36,7 +36,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class StopAndBackgroundActionTest {
private static final String PACKAGE_NAME = "com.android.app";
private static final int UID = 111;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/checker/BluetoothScanAnomalyDetectorTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/checker/BluetoothScanAnomalyDetectorTest.java
index edf026a..b148ce9 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/checker/BluetoothScanAnomalyDetectorTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/checker/BluetoothScanAnomalyDetectorTest.java
@@ -52,7 +52,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BluetoothScanAnomalyDetectorTest {
private static final String TARGET_PACKAGE_NAME = "com.android.app";
private static final int ANOMALY_UID = 111;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/checker/WakeLockAnomalyDetectorTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/checker/WakeLockAnomalyDetectorTest.java
index d7682ea..0991d89 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/checker/WakeLockAnomalyDetectorTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/checker/WakeLockAnomalyDetectorTest.java
@@ -55,7 +55,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class WakeLockAnomalyDetectorTest {
private static final String TARGET_PACKAGE_NAME = "com.android.app";
private static final long ANOMALY_WAKELOCK_TIME_MS = 2 * DateUtils.HOUR_IN_MILLIS;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/checker/WakeupAlarmAnomalyDetectorTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/checker/WakeupAlarmAnomalyDetectorTest.java
index 13a5ab8..f014f8d 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/checker/WakeupAlarmAnomalyDetectorTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/checker/WakeupAlarmAnomalyDetectorTest.java
@@ -56,7 +56,7 @@
import java.util.Set;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class WakeupAlarmAnomalyDetectorTest {
private static final String TARGET_PACKAGE_NAME = "com.android.target";
private static final String ANOMALY_PACKAGE_NAME = "com.android.anomaly";
diff --git a/tests/robotests/src/com/android/settings/gestures/AssistGestureSettingsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/AssistGestureSettingsPreferenceControllerTest.java
index 7633ce9..40c4af3 100644
--- a/tests/robotests/src/com/android/settings/gestures/AssistGestureSettingsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/AssistGestureSettingsPreferenceControllerTest.java
@@ -45,7 +45,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(
manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = ShadowSecureSettings.class
)
public class AssistGestureSettingsPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/gestures/AssistGestureSettingsTest.java b/tests/robotests/src/com/android/settings/gestures/AssistGestureSettingsTest.java
index 041b7e0..b2bd27e 100644
--- a/tests/robotests/src/com/android/settings/gestures/AssistGestureSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/AssistGestureSettingsTest.java
@@ -41,7 +41,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AssistGestureSettingsTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/gestures/DoubleTapPowerPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/DoubleTapPowerPreferenceControllerTest.java
index 1f5ca20..12ecc90 100644
--- a/tests/robotests/src/com/android/settings/gestures/DoubleTapPowerPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/DoubleTapPowerPreferenceControllerTest.java
@@ -48,7 +48,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows = {
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O, shadows = {
SettingsShadowResources.class
})
public class DoubleTapPowerPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/gestures/DoubleTapPowerSettingsTest.java b/tests/robotests/src/com/android/settings/gestures/DoubleTapPowerSettingsTest.java
index b9635a7..e322b07 100644
--- a/tests/robotests/src/com/android/settings/gestures/DoubleTapPowerSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/DoubleTapPowerSettingsTest.java
@@ -32,7 +32,7 @@
import static com.google.common.truth.Truth.assertThat;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DoubleTapPowerSettingsTest {
private DoubleTapPowerSettings mSettings;
diff --git a/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java
index 2565dc8..72a77b0 100644
--- a/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java
@@ -17,6 +17,7 @@
package com.android.settings.gestures;
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.when;
@@ -46,9 +47,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows = {
- SettingsShadowResources.class
-})
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DoubleTapScreenPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
@@ -139,25 +138,19 @@
@Test
public void isSuggestionCompleted_ambientDisplay_falseWhenNotVisited() {
- SettingsShadowResources.overrideResource(
- com.android.internal.R.string.config_dozeComponent, "foo");
- SettingsShadowResources.overrideResource(
- com.android.internal.R.string.config_dozeDoubleTapSensorType, "bar");
+ when(mAmbientDisplayConfiguration.pulseOnDoubleTapAvailable()).thenReturn(true);
// No stored value in shared preferences if not visited yet.
final Context context = RuntimeEnvironment.application;
final SharedPreferences prefs = new SuggestionFeatureProviderImpl(context)
.getSharedPrefs(context);
- assertThat(DoubleTapScreenPreferenceController.isSuggestionComplete(context, prefs))
- .isFalse();
+ assertThat(DoubleTapScreenPreferenceController.isSuggestionComplete(
+ mAmbientDisplayConfiguration, prefs)).isFalse();
}
@Test
public void isSuggestionCompleted_ambientDisplay_trueWhenVisited() {
- SettingsShadowResources.overrideResource(
- com.android.internal.R.string.config_dozeComponent, "foo");
- SettingsShadowResources.overrideResource(
- com.android.internal.R.string.config_dozeDoubleTapSensorType, "bar");
+ when(mAmbientDisplayConfiguration.pulseOnDoubleTapAvailable()).thenReturn(false);
final Context context = RuntimeEnvironment.application;
final SharedPreferences prefs = new SuggestionFeatureProviderImpl(context)
.getSharedPrefs(context);
@@ -165,7 +158,7 @@
prefs.edit().putBoolean(
DoubleTapScreenSettings.PREF_KEY_SUGGESTION_COMPLETE, true).commit();
- assertThat(DoubleTapScreenPreferenceController.isSuggestionComplete(context, prefs))
- .isTrue();
+ assertThat(DoubleTapScreenPreferenceController.isSuggestionComplete(
+ mAmbientDisplayConfiguration, prefs)).isTrue();
}
}
diff --git a/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenSettingsTest.java b/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenSettingsTest.java
index 3d56d71..e29bf79 100644
--- a/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenSettingsTest.java
@@ -32,7 +32,7 @@
import static com.google.common.truth.Truth.assertThat;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DoubleTapScreenSettingsTest {
private DoubleTapScreenSettings mSettings;
diff --git a/tests/robotests/src/com/android/settings/gestures/DoubleTwistGestureSettingsTest.java b/tests/robotests/src/com/android/settings/gestures/DoubleTwistGestureSettingsTest.java
index 236896a..081ff79 100644
--- a/tests/robotests/src/com/android/settings/gestures/DoubleTwistGestureSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/DoubleTwistGestureSettingsTest.java
@@ -32,7 +32,7 @@
import static com.google.common.truth.Truth.assertThat;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DoubleTwistGestureSettingsTest {
private DoubleTwistGestureSettings mSettings;
diff --git a/tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java
index a7516fc..b48889f 100644
--- a/tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java
@@ -51,7 +51,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows = {
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O, shadows = {
SettingsShadowResources.class
})
public class DoubleTwistPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/gestures/GesturesSettingsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/GesturesSettingsPreferenceControllerTest.java
index b12b373..dcc06af 100644
--- a/tests/robotests/src/com/android/settings/gestures/GesturesSettingsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/GesturesSettingsPreferenceControllerTest.java
@@ -48,7 +48,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class GesturesSettingsPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java
index 8757a65..ffd4928 100644
--- a/tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java
@@ -18,6 +18,8 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import android.content.ContentResolver;
@@ -46,7 +48,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows = {
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O, shadows = {
SettingsShadowResources.class
})
public class PickupGesturePreferenceControllerTest {
@@ -105,14 +107,16 @@
@Test
public void testCanHandleClicks_configIsSet_shouldReturnTrue() {
- when(mAmbientDisplayConfiguration.pulseOnPickupCanBeModified(anyInt())).thenReturn(true);
+ mController = spy(mController);
+ doReturn(true).when(mController).pulseOnPickupCanBeModified();
assertThat(mController.canHandleClicks()).isTrue();
}
@Test
public void testCanHandleClicks_configIsNotSet_shouldReturnFalse() {
- when(mAmbientDisplayConfiguration.pulseOnPickupCanBeModified(anyInt())).thenReturn(false);
+ mController = spy(mController);
+ doReturn(false).when(mController).pulseOnPickupCanBeModified();
assertThat(mController.canHandleClicks()).isFalse();
}
diff --git a/tests/robotests/src/com/android/settings/gestures/PickupGestureSettingsTest.java b/tests/robotests/src/com/android/settings/gestures/PickupGestureSettingsTest.java
index 2c4a1c4..05c88ba 100644
--- a/tests/robotests/src/com/android/settings/gestures/PickupGestureSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/PickupGestureSettingsTest.java
@@ -32,7 +32,7 @@
import static com.google.common.truth.Truth.assertThat;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class PickupGestureSettingsTest {
private PickupGestureSettings mSettings;
diff --git a/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java
index f3cc2ca..f535a99 100644
--- a/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java
@@ -41,7 +41,7 @@
import org.robolectric.shadows.ShadowApplication;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SwipeToNotificationPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationSettingsTest.java b/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationSettingsTest.java
index 0b329d3..7e3b90e 100644
--- a/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationSettingsTest.java
@@ -37,7 +37,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SwipeToNotificationSettingsTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/graph/BottomLabelLayoutTest.java b/tests/robotests/src/com/android/settings/graph/BottomLabelLayoutTest.java
index c9804d6..eef6921 100644
--- a/tests/robotests/src/com/android/settings/graph/BottomLabelLayoutTest.java
+++ b/tests/robotests/src/com/android/settings/graph/BottomLabelLayoutTest.java
@@ -35,7 +35,7 @@
import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BottomLabelLayoutTest {
private BottomLabelLayout mBottomLabelLayout;
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/graph/UsageGraphTest.java b/tests/robotests/src/com/android/settings/graph/UsageGraphTest.java
index fbd6fd4..4ab3381 100644
--- a/tests/robotests/src/com/android/settings/graph/UsageGraphTest.java
+++ b/tests/robotests/src/com/android/settings/graph/UsageGraphTest.java
@@ -37,7 +37,7 @@
import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class UsageGraphTest {
private UsageGraph mGraph;
diff --git a/tests/robotests/src/com/android/settings/inputmethod/GameControllerPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/inputmethod/GameControllerPreferenceControllerTest.java
index 2716fc3..b8a63e4 100644
--- a/tests/robotests/src/com/android/settings/inputmethod/GameControllerPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/inputmethod/GameControllerPreferenceControllerTest.java
@@ -41,7 +41,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class GameControllerPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/inputmethod/PhysicalKeyboardPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/inputmethod/PhysicalKeyboardPreferenceControllerTest.java
index 8f9b2c5..5684f17 100644
--- a/tests/robotests/src/com/android/settings/inputmethod/PhysicalKeyboardPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/inputmethod/PhysicalKeyboardPreferenceControllerTest.java
@@ -40,7 +40,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class PhysicalKeyboardPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/inputmethod/SpellCheckerPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/inputmethod/SpellCheckerPreferenceControllerTest.java
index 4457cc0..1991460 100644
--- a/tests/robotests/src/com/android/settings/inputmethod/SpellCheckerPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/inputmethod/SpellCheckerPreferenceControllerTest.java
@@ -39,7 +39,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SpellCheckerPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/inputmethod/UserDictionaryCursorLoaderTest.java b/tests/robotests/src/com/android/settings/inputmethod/UserDictionaryCursorLoaderTest.java
index 7b149f3..c21cc76 100644
--- a/tests/robotests/src/com/android/settings/inputmethod/UserDictionaryCursorLoaderTest.java
+++ b/tests/robotests/src/com/android/settings/inputmethod/UserDictionaryCursorLoaderTest.java
@@ -38,7 +38,7 @@
import org.robolectric.shadows.ShadowContentResolver;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class UserDictionaryCursorLoaderTest {
private ContentProvider mContentProvider;
diff --git a/tests/robotests/src/com/android/settings/inputmethod/UserDictionaryListTest.java b/tests/robotests/src/com/android/settings/inputmethod/UserDictionaryListTest.java
index 91fcaae..b220dd5 100644
--- a/tests/robotests/src/com/android/settings/inputmethod/UserDictionaryListTest.java
+++ b/tests/robotests/src/com/android/settings/inputmethod/UserDictionaryListTest.java
@@ -37,7 +37,7 @@
import org.robolectric.shadows.ShadowContentResolver;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class UserDictionaryListTest {
private FakeProvider mContentProvider;
diff --git a/tests/robotests/src/com/android/settings/inputmethod/VirtualKeyboardPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/inputmethod/VirtualKeyboardPreferenceControllerTest.java
index fe2b0df..5913f7e 100644
--- a/tests/robotests/src/com/android/settings/inputmethod/VirtualKeyboardPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/inputmethod/VirtualKeyboardPreferenceControllerTest.java
@@ -49,7 +49,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class VirtualKeyboardPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/language/LanguageAndInputSettingsTest.java b/tests/robotests/src/com/android/settings/language/LanguageAndInputSettingsTest.java
index 141d59d..da996e8 100644
--- a/tests/robotests/src/com/android/settings/language/LanguageAndInputSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/language/LanguageAndInputSettingsTest.java
@@ -64,7 +64,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class LanguageAndInputSettingsTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
@@ -159,12 +159,15 @@
final Context context = spy(RuntimeEnvironment.application);
final Resources res = spy(RuntimeEnvironment.application.getResources());
//(InputManager) context.getSystemService(Context.INPUT_SERVICE);
- InputManager manager = mock(InputManager.class);
- when(manager.getInputDeviceIds()).thenReturn(new int[]{});
- doReturn(manager).when(context).getSystemService(Context.INPUT_SERVICE);
+ final InputManager inputManager = mock(InputManager.class);
+ final TextServicesManager textServicesManager = mock(TextServicesManager.class);
+ when(inputManager.getInputDeviceIds()).thenReturn(new int[]{});
+ doReturn(inputManager).when(context).getSystemService(Context.INPUT_SERVICE);
+ doReturn(textServicesManager).when(context).getSystemService(
+ Context.TEXT_SERVICES_MANAGER_SERVICE);
doReturn(res).when(context).getResources();
doReturn(false).when(res)
- .getBoolean(com.android.internal.R.bool.config_supportSystemNavigationKeys);
+ .getBoolean(com.android.internal.R.bool.config_supportSystemNavigationKeys);
final List<String> niks = LanguageAndInputSettings.SEARCH_INDEX_DATA_PROVIDER
.getNonIndexableKeys(context);
LanguageAndInputSettings settings = new LanguageAndInputSettings();
@@ -177,7 +180,10 @@
@Test
public void testPreferenceControllers_getPreferenceKeys_existInPreferenceScreen() {
- final Context context = RuntimeEnvironment.application;
+ final Context context = spy(RuntimeEnvironment.application);
+ final TextServicesManager textServicesManager = mock(TextServicesManager.class);
+ doReturn(textServicesManager).when(context).getSystemService(
+ Context.TEXT_SERVICES_MANAGER_SERVICE);
final LanguageAndInputSettings fragment = new LanguageAndInputSettings();
final List<String> preferenceScreenKeys = XmlTestUtils.getKeysFromPreferenceXml(context,
fragment.getPreferenceScreenResId());
diff --git a/tests/robotests/src/com/android/settings/language/PhoneLanguagePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/language/PhoneLanguagePreferenceControllerTest.java
index 7b315aa..485efbe 100644
--- a/tests/robotests/src/com/android/settings/language/PhoneLanguagePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/language/PhoneLanguagePreferenceControllerTest.java
@@ -39,7 +39,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class PhoneLanguagePreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/language/UserDictionaryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/language/UserDictionaryPreferenceControllerTest.java
index 26a160d..77d60cb 100644
--- a/tests/robotests/src/com/android/settings/language/UserDictionaryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/language/UserDictionaryPreferenceControllerTest.java
@@ -39,7 +39,7 @@
import java.util.TreeSet;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class UserDictionaryPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/localepicker/LocaleListEditorTest.java b/tests/robotests/src/com/android/settings/localepicker/LocaleListEditorTest.java
index 1ee52ca..40a42b5 100644
--- a/tests/robotests/src/com/android/settings/localepicker/LocaleListEditorTest.java
+++ b/tests/robotests/src/com/android/settings/localepicker/LocaleListEditorTest.java
@@ -33,7 +33,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = { ShadowSettingsPreferenceFragment.class })
public class LocaleListEditorTest {
diff --git a/tests/robotests/src/com/android/settings/location/LocationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/LocationPreferenceControllerTest.java
index fe45a93..01ca899 100644
--- a/tests/robotests/src/com/android/settings/location/LocationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/location/LocationPreferenceControllerTest.java
@@ -55,7 +55,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class LocationPreferenceControllerTest {
@Mock
private Preference mPreference;
diff --git a/tests/robotests/src/com/android/settings/network/MobileNetworkPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/MobileNetworkPreferenceControllerTest.java
index d593b58..4dd890d 100644
--- a/tests/robotests/src/com/android/settings/network/MobileNetworkPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/MobileNetworkPreferenceControllerTest.java
@@ -53,7 +53,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(
manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {ShadowRestrictedLockUtilsWrapper.class, ShadowConnectivityManager.class,
ShadowUserManager.class}
)
diff --git a/tests/robotests/src/com/android/settings/network/MobilePlanPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/MobilePlanPreferenceControllerTest.java
index a84179d..01d578f 100644
--- a/tests/robotests/src/com/android/settings/network/MobilePlanPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/MobilePlanPreferenceControllerTest.java
@@ -30,7 +30,7 @@
import static com.google.common.truth.Truth.assertThat;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class MobilePlanPreferenceControllerTest {
@Test
diff --git a/tests/robotests/src/com/android/settings/network/NetworkDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/network/NetworkDashboardFragmentTest.java
index 548d144..76ade7b 100644
--- a/tests/robotests/src/com/android/settings/network/NetworkDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/network/NetworkDashboardFragmentTest.java
@@ -46,7 +46,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class NetworkDashboardFragmentTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/network/NetworkResetActionMenuControllerTest.java b/tests/robotests/src/com/android/settings/network/NetworkResetActionMenuControllerTest.java
index 896e802..087c0ff 100644
--- a/tests/robotests/src/com/android/settings/network/NetworkResetActionMenuControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/NetworkResetActionMenuControllerTest.java
@@ -40,7 +40,7 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class NetworkResetActionMenuControllerTest {
private static final int MENU_ID = Menu.FIRST;
diff --git a/tests/robotests/src/com/android/settings/network/NetworkResetPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/NetworkResetPreferenceControllerTest.java
index 4d8c626..5cbba61 100644
--- a/tests/robotests/src/com/android/settings/network/NetworkResetPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/NetworkResetPreferenceControllerTest.java
@@ -37,7 +37,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class NetworkResetPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/network/NetworkResetRestrictionCheckerTest.java b/tests/robotests/src/com/android/settings/network/NetworkResetRestrictionCheckerTest.java
index 792bdd3..87bf812 100644
--- a/tests/robotests/src/com/android/settings/network/NetworkResetRestrictionCheckerTest.java
+++ b/tests/robotests/src/com/android/settings/network/NetworkResetRestrictionCheckerTest.java
@@ -36,7 +36,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class NetworkResetRestrictionCheckerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/network/NetworkScorerPickerPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/NetworkScorerPickerPreferenceControllerTest.java
index 7ed7f3f..5794820 100644
--- a/tests/robotests/src/com/android/settings/network/NetworkScorerPickerPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/NetworkScorerPickerPreferenceControllerTest.java
@@ -43,7 +43,7 @@
import java.util.Collections;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class NetworkScorerPickerPreferenceControllerTest {
private static final String TEST_SCORER_PACKAGE = "Test Package";
diff --git a/tests/robotests/src/com/android/settings/network/NetworkScorerPickerTest.java b/tests/robotests/src/com/android/settings/network/NetworkScorerPickerTest.java
index 7cfced8..773b311 100644
--- a/tests/robotests/src/com/android/settings/network/NetworkScorerPickerTest.java
+++ b/tests/robotests/src/com/android/settings/network/NetworkScorerPickerTest.java
@@ -48,7 +48,7 @@
import java.util.ArrayList;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class NetworkScorerPickerTest {
private static final String TEST_SCORER_PACKAGE_1 = "Test Package 1";
diff --git a/tests/robotests/src/com/android/settings/network/PrivateDnsMenuControllerTest.java b/tests/robotests/src/com/android/settings/network/PrivateDnsMenuControllerTest.java
index 0be66e0..4e37d56 100644
--- a/tests/robotests/src/com/android/settings/network/PrivateDnsMenuControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/PrivateDnsMenuControllerTest.java
@@ -37,7 +37,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class PrivateDnsMenuControllerTest {
private static final int MENU_ID = 0;
diff --git a/tests/robotests/src/com/android/settings/network/PrivateDnsModeDialogFragmentTest.java b/tests/robotests/src/com/android/settings/network/PrivateDnsModeDialogFragmentTest.java
index f1d7a73..2dcfdc8 100644
--- a/tests/robotests/src/com/android/settings/network/PrivateDnsModeDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/network/PrivateDnsModeDialogFragmentTest.java
@@ -41,7 +41,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class PrivateDnsModeDialogFragmentTest {
private static final String HOST_NAME = "192.168.1.1";
private static final String INVALID_HOST_NAME = "...,";
diff --git a/tests/robotests/src/com/android/settings/network/TetherPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/TetherPreferenceControllerTest.java
index b8a6d28..33fd36b 100644
--- a/tests/robotests/src/com/android/settings/network/TetherPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/TetherPreferenceControllerTest.java
@@ -52,7 +52,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class TetherPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/network/VpnPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/VpnPreferenceControllerTest.java
index c35f1cf..96a29c2 100644
--- a/tests/robotests/src/com/android/settings/network/VpnPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/VpnPreferenceControllerTest.java
@@ -48,7 +48,7 @@
import org.robolectric.shadows.ShadowServiceManager;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class VpnPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/network/WifiCallingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/WifiCallingPreferenceControllerTest.java
index 172508d..4d6a0be 100644
--- a/tests/robotests/src/com/android/settings/network/WifiCallingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/WifiCallingPreferenceControllerTest.java
@@ -39,7 +39,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class WifiCallingPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/nfc/PaymentSettingsTest.java b/tests/robotests/src/com/android/settings/nfc/PaymentSettingsTest.java
index a82daf3..d4c74ed 100644
--- a/tests/robotests/src/com/android/settings/nfc/PaymentSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/nfc/PaymentSettingsTest.java
@@ -36,7 +36,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class PaymentSettingsTest {
@Mock
Context mContext;
diff --git a/tests/robotests/src/com/android/settings/notification/AdjustVolumeRestrictedPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/AdjustVolumeRestrictedPreferenceControllerTest.java
index d33d734..cc27649 100644
--- a/tests/robotests/src/com/android/settings/notification/AdjustVolumeRestrictedPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/AdjustVolumeRestrictedPreferenceControllerTest.java
@@ -43,7 +43,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AdjustVolumeRestrictedPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/notification/AlarmRingtonePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/AlarmRingtonePreferenceControllerTest.java
index f4bd522..85a3027 100644
--- a/tests/robotests/src/com/android/settings/notification/AlarmRingtonePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/AlarmRingtonePreferenceControllerTest.java
@@ -32,7 +32,7 @@
import static com.google.common.truth.Truth.assertThat;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AlarmRingtonePreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/notification/AlarmVolumePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/AlarmVolumePreferenceControllerTest.java
index 7b0b033..f070421 100644
--- a/tests/robotests/src/com/android/settings/notification/AlarmVolumePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/AlarmVolumePreferenceControllerTest.java
@@ -33,7 +33,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AlarmVolumePreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/notification/AllowSoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/AllowSoundPreferenceControllerTest.java
index 9ba8706..c14e4aa 100644
--- a/tests/robotests/src/com/android/settings/notification/AllowSoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/AllowSoundPreferenceControllerTest.java
@@ -57,7 +57,7 @@
import org.robolectric.shadows.ShadowApplication;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = Build.VERSION_CODES.O)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AllowSoundPreferenceControllerTest {
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/notification/AppLinkPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/AppLinkPreferenceControllerTest.java
index b440704..7198993 100644
--- a/tests/robotests/src/com/android/settings/notification/AppLinkPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/AppLinkPreferenceControllerTest.java
@@ -49,7 +49,7 @@
import org.robolectric.shadows.ShadowApplication;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = Build.VERSION_CODES.O)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AppLinkPreferenceControllerTest {
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/notification/BadgePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/BadgePreferenceControllerTest.java
index 6052478..55dbd3c 100644
--- a/tests/robotests/src/com/android/settings/notification/BadgePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/BadgePreferenceControllerTest.java
@@ -61,7 +61,7 @@
import org.robolectric.shadows.ShadowApplication;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = Build.VERSION_CODES.O)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BadgePreferenceControllerTest {
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/notification/BlockPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/BlockPreferenceControllerTest.java
index 9014f4e..aca814a 100644
--- a/tests/robotests/src/com/android/settings/notification/BlockPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/BlockPreferenceControllerTest.java
@@ -59,7 +59,7 @@
import org.robolectric.shadows.ShadowApplication;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = Build.VERSION_CODES.O)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BlockPreferenceControllerTest {
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/notification/BootSoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/BootSoundPreferenceControllerTest.java
index 58ba46b..3157d31 100644
--- a/tests/robotests/src/com/android/settings/notification/BootSoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/BootSoundPreferenceControllerTest.java
@@ -38,7 +38,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BootSoundPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/notification/CastPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/CastPreferenceControllerTest.java
index ed9cc98..faace1b 100644
--- a/tests/robotests/src/com/android/settings/notification/CastPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/CastPreferenceControllerTest.java
@@ -36,7 +36,7 @@
import static com.google.common.truth.Truth.assertThat;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class CastPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/notification/ChargingSoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ChargingSoundPreferenceControllerTest.java
index 2b2d024..e8d945b 100644
--- a/tests/robotests/src/com/android/settings/notification/ChargingSoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ChargingSoundPreferenceControllerTest.java
@@ -39,7 +39,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ChargingSoundPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/notification/ConfigureNotificationSettingsTest.java b/tests/robotests/src/com/android/settings/notification/ConfigureNotificationSettingsTest.java
index 8cf8f83..afdc355 100644
--- a/tests/robotests/src/com/android/settings/notification/ConfigureNotificationSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ConfigureNotificationSettingsTest.java
@@ -40,7 +40,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ConfigureNotificationSettingsTest {
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/notification/DeletedChannelsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/DeletedChannelsPreferenceControllerTest.java
index fd903f9..2742d0d 100644
--- a/tests/robotests/src/com/android/settings/notification/DeletedChannelsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/DeletedChannelsPreferenceControllerTest.java
@@ -46,7 +46,7 @@
import org.robolectric.shadows.ShadowApplication;
@RunWith(RobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DeletedChannelsPreferenceControllerTest {
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/notification/DescriptionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/DescriptionPreferenceControllerTest.java
index 1776a9b..7f695f3 100644
--- a/tests/robotests/src/com/android/settings/notification/DescriptionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/DescriptionPreferenceControllerTest.java
@@ -51,7 +51,7 @@
import org.robolectric.shadows.ShadowApplication;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = Build.VERSION_CODES.O)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DescriptionPreferenceControllerTest {
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/notification/DialPadTonePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/DialPadTonePreferenceControllerTest.java
index 4ec67e6..3400181 100644
--- a/tests/robotests/src/com/android/settings/notification/DialPadTonePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/DialPadTonePreferenceControllerTest.java
@@ -40,7 +40,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DialPadTonePreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/notification/DndPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/DndPreferenceControllerTest.java
index 241e279..428f536 100644
--- a/tests/robotests/src/com/android/settings/notification/DndPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/DndPreferenceControllerTest.java
@@ -61,7 +61,7 @@
import org.robolectric.shadows.ShadowApplication;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = Build.VERSION_CODES.O)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DndPreferenceControllerTest {
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/notification/DockAudioMediaPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/DockAudioMediaPreferenceControllerTest.java
index 58e5636..0634cef 100644
--- a/tests/robotests/src/com/android/settings/notification/DockAudioMediaPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/DockAudioMediaPreferenceControllerTest.java
@@ -41,7 +41,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DockAudioMediaPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/notification/DockingSoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/DockingSoundPreferenceControllerTest.java
index d6a277f..517b722 100644
--- a/tests/robotests/src/com/android/settings/notification/DockingSoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/DockingSoundPreferenceControllerTest.java
@@ -40,7 +40,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DockingSoundPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/notification/EmergencyBroadcastPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/EmergencyBroadcastPreferenceControllerTest.java
index 24f4b6c..6a7be85 100644
--- a/tests/robotests/src/com/android/settings/notification/EmergencyBroadcastPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/EmergencyBroadcastPreferenceControllerTest.java
@@ -41,7 +41,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class EmergencyBroadcastPreferenceControllerTest {
private static final String PREF_TEST_KEY = "test_key";
diff --git a/tests/robotests/src/com/android/settings/notification/EmergencyTonePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/EmergencyTonePreferenceControllerTest.java
index c3e887f..9e35ad9 100644
--- a/tests/robotests/src/com/android/settings/notification/EmergencyTonePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/EmergencyTonePreferenceControllerTest.java
@@ -40,7 +40,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class EmergencyTonePreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/notification/HeaderPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/HeaderPreferenceControllerTest.java
index 385376f..f6b7e00 100644
--- a/tests/robotests/src/com/android/settings/notification/HeaderPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/HeaderPreferenceControllerTest.java
@@ -54,7 +54,7 @@
import org.robolectric.shadows.ShadowApplication;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = Build.VERSION_CODES.O)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class HeaderPreferenceControllerTest {
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/notification/ImportancePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ImportancePreferenceControllerTest.java
index aebd6c9..d04a4c6 100644
--- a/tests/robotests/src/com/android/settings/notification/ImportancePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ImportancePreferenceControllerTest.java
@@ -52,7 +52,7 @@
import org.robolectric.shadows.ShadowApplication;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = Build.VERSION_CODES.O)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ImportancePreferenceControllerTest {
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/notification/LightsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/LightsPreferenceControllerTest.java
index 017cb88..0f3a37d 100644
--- a/tests/robotests/src/com/android/settings/notification/LightsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/LightsPreferenceControllerTest.java
@@ -59,7 +59,7 @@
import org.robolectric.shadows.ShadowApplication;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = Build.VERSION_CODES.O, shadows = {
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O, shadows = {
SettingsShadowResources.class,
})
public class LightsPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/notification/MediaVolumePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/MediaVolumePreferenceControllerTest.java
index ca7fc44..30cb158 100644
--- a/tests/robotests/src/com/android/settings/notification/MediaVolumePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/MediaVolumePreferenceControllerTest.java
@@ -32,7 +32,7 @@
import static com.google.common.truth.Truth.assertThat;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class MediaVolumePreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/notification/NotificationAccessSettingsTest.java b/tests/robotests/src/com/android/settings/notification/NotificationAccessSettingsTest.java
index d3f66b9..8e74e79 100644
--- a/tests/robotests/src/com/android/settings/notification/NotificationAccessSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/notification/NotificationAccessSettingsTest.java
@@ -36,7 +36,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class NotificationAccessSettingsTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/notification/NotificationBackendTest.java b/tests/robotests/src/com/android/settings/notification/NotificationBackendTest.java
index 089e330..0fb2e5c 100644
--- a/tests/robotests/src/com/android/settings/notification/NotificationBackendTest.java
+++ b/tests/robotests/src/com/android/settings/notification/NotificationBackendTest.java
@@ -31,7 +31,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class NotificationBackendTest {
@Test
diff --git a/tests/robotests/src/com/android/settings/notification/NotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/NotificationPreferenceControllerTest.java
index 1f49ff2..f4a5924 100644
--- a/tests/robotests/src/com/android/settings/notification/NotificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/NotificationPreferenceControllerTest.java
@@ -57,7 +57,7 @@
import org.robolectric.shadows.ShadowApplication;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = Build.VERSION_CODES.O)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class NotificationPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/notification/NotificationRingtonePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/NotificationRingtonePreferenceControllerTest.java
index 940a948..ab26226 100644
--- a/tests/robotests/src/com/android/settings/notification/NotificationRingtonePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/NotificationRingtonePreferenceControllerTest.java
@@ -32,7 +32,7 @@
import static com.google.common.truth.Truth.assertThat;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class NotificationRingtonePreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/notification/NotificationVolumePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/NotificationVolumePreferenceControllerTest.java
index f919e7b..3e0fd7b 100644
--- a/tests/robotests/src/com/android/settings/notification/NotificationVolumePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/NotificationVolumePreferenceControllerTest.java
@@ -35,7 +35,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class NotificationVolumePreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/notification/NotificationsOffPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/NotificationsOffPreferenceControllerTest.java
index e1f9eb7..aacccf4 100644
--- a/tests/robotests/src/com/android/settings/notification/NotificationsOffPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/NotificationsOffPreferenceControllerTest.java
@@ -48,7 +48,7 @@
import org.robolectric.shadows.ShadowApplication;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = Build.VERSION_CODES.O)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class NotificationsOffPreferenceControllerTest {
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/notification/PhoneRingtonePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/PhoneRingtonePreferenceControllerTest.java
index 57ab4d3..614de6f 100644
--- a/tests/robotests/src/com/android/settings/notification/PhoneRingtonePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/PhoneRingtonePreferenceControllerTest.java
@@ -35,7 +35,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class PhoneRingtonePreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/notification/RingVolumePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/RingVolumePreferenceControllerTest.java
index 1a6d3d7..48edcf7 100644
--- a/tests/robotests/src/com/android/settings/notification/RingVolumePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/RingVolumePreferenceControllerTest.java
@@ -38,7 +38,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class RingVolumePreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/notification/RingtonePreferenceControllerBaseTest.java b/tests/robotests/src/com/android/settings/notification/RingtonePreferenceControllerBaseTest.java
index e72ef53..82f4dab 100644
--- a/tests/robotests/src/com/android/settings/notification/RingtonePreferenceControllerBaseTest.java
+++ b/tests/robotests/src/com/android/settings/notification/RingtonePreferenceControllerBaseTest.java
@@ -36,7 +36,7 @@
import static org.mockito.Mockito.verify;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class RingtonePreferenceControllerBaseTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/notification/ScreenLockSoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ScreenLockSoundPreferenceControllerTest.java
index f94f8bf..4e77793 100644
--- a/tests/robotests/src/com/android/settings/notification/ScreenLockSoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ScreenLockSoundPreferenceControllerTest.java
@@ -39,7 +39,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ScreenLockSoundPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/notification/SettingPrefControllerTest.java b/tests/robotests/src/com/android/settings/notification/SettingPrefControllerTest.java
index 307536d..ef7ee04 100644
--- a/tests/robotests/src/com/android/settings/notification/SettingPrefControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/SettingPrefControllerTest.java
@@ -47,7 +47,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SettingPrefControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/notification/SoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/SoundPreferenceControllerTest.java
index 1d5a791..3d6bc92 100644
--- a/tests/robotests/src/com/android/settings/notification/SoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/SoundPreferenceControllerTest.java
@@ -65,7 +65,7 @@
import org.robolectric.shadows.ShadowApplication;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = Build.VERSION_CODES.O)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SoundPreferenceControllerTest {
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/notification/SoundSettingsTest.java b/tests/robotests/src/com/android/settings/notification/SoundSettingsTest.java
index ec0b6ea..5b816d4 100644
--- a/tests/robotests/src/com/android/settings/notification/SoundSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/notification/SoundSettingsTest.java
@@ -41,7 +41,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SoundSettingsTest {
@Test
diff --git a/tests/robotests/src/com/android/settings/notification/SuppressorHelperTest.java b/tests/robotests/src/com/android/settings/notification/SuppressorHelperTest.java
index 74c41f3..5efad20 100644
--- a/tests/robotests/src/com/android/settings/notification/SuppressorHelperTest.java
+++ b/tests/robotests/src/com/android/settings/notification/SuppressorHelperTest.java
@@ -33,7 +33,7 @@
import com.android.settings.testutils.SettingsRobolectricTestRunner;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SuppressorHelperTest {
private static final String SUPPRESSOR_NAME = "wear";
diff --git a/tests/robotests/src/com/android/settings/notification/TouchSoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/TouchSoundPreferenceControllerTest.java
index eaf9bb5..ad9eb8f 100644
--- a/tests/robotests/src/com/android/settings/notification/TouchSoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/TouchSoundPreferenceControllerTest.java
@@ -41,7 +41,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class TouchSoundPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/notification/VibrateOnTouchPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/VibrateOnTouchPreferenceControllerTest.java
index b0ab54b..b469f9b 100644
--- a/tests/robotests/src/com/android/settings/notification/VibrateOnTouchPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/VibrateOnTouchPreferenceControllerTest.java
@@ -41,7 +41,7 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class VibrateOnTouchPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/notification/VibrationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/VibrationPreferenceControllerTest.java
index 4695590..ea2c058 100644
--- a/tests/robotests/src/com/android/settings/notification/VibrationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/VibrationPreferenceControllerTest.java
@@ -57,7 +57,7 @@
import org.robolectric.shadows.ShadowApplication;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = Build.VERSION_CODES.O)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class VibrationPreferenceControllerTest {
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/notification/VisibilityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/VisibilityPreferenceControllerTest.java
index ed658fe..cd8cdad 100644
--- a/tests/robotests/src/com/android/settings/notification/VisibilityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/VisibilityPreferenceControllerTest.java
@@ -68,7 +68,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = Build.VERSION_CODES.O, shadows = {
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O, shadows = {
ShadowRestrictionUtils.class,
})
public class VisibilityPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/notification/VolumeSeekBarPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/VolumeSeekBarPreferenceControllerTest.java
index a1d9205..f659e82 100644
--- a/tests/robotests/src/com/android/settings/notification/VolumeSeekBarPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/VolumeSeekBarPreferenceControllerTest.java
@@ -38,7 +38,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class VolumeSeekBarPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/notification/VolumeSeekBarPreferenceTest.java b/tests/robotests/src/com/android/settings/notification/VolumeSeekBarPreferenceTest.java
index b091cd3..df98cff 100644
--- a/tests/robotests/src/com/android/settings/notification/VolumeSeekBarPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/notification/VolumeSeekBarPreferenceTest.java
@@ -35,7 +35,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class VolumeSeekBarPreferenceTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/notification/WorkSoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/WorkSoundPreferenceControllerTest.java
index 0c826ed..a9abdce 100644
--- a/tests/robotests/src/com/android/settings/notification/WorkSoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/WorkSoundPreferenceControllerTest.java
@@ -49,7 +49,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class WorkSoundPreferenceControllerTest {
private static final String KEY_WORK_CATEGORY = "sound_work_settings_section";
diff --git a/tests/robotests/src/com/android/settings/notification/ZenAccessSettingsTest.java b/tests/robotests/src/com/android/settings/notification/ZenAccessSettingsTest.java
index 591378f..f65752f 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenAccessSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenAccessSettingsTest.java
@@ -36,7 +36,7 @@
import static org.mockito.Mockito.verify;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ZenAccessSettingsTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeCallsTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeCallsTest.java
index 3cc87a8..c495759 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeCallsTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeCallsTest.java
@@ -41,7 +41,7 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ZenModeCallsTest {
private ZenModeCallsSettings mCalls;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeMessagesTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeMessagesTest.java
index fe92570..03226f9 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeMessagesTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeMessagesTest.java
@@ -41,7 +41,7 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ZenModeMessagesTest {
private ZenModeMessagesSettings mMessages;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeScheduleRuleSettingsTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeScheduleRuleSettingsTest.java
index 89b3f2a..e45847d 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeScheduleRuleSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeScheduleRuleSettingsTest.java
@@ -47,7 +47,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
+ sdk = TestConfig.SDK_VERSION_O,
shadows = {
SettingsShadowResources.class,
SettingsShadowResources.SettingsShadowTheme.class,
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java
index fa2c6b9..966c927 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java
@@ -38,7 +38,7 @@
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ZenModeSettingsTest {
private ZenModeSettings.SummaryBuilder mBuilder;
diff --git a/tests/robotests/src/com/android/settings/print/PrintSettingsFragmentTest.java b/tests/robotests/src/com/android/settings/print/PrintSettingsFragmentTest.java
index cf34f45..717fe88 100644
--- a/tests/robotests/src/com/android/settings/print/PrintSettingsFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/print/PrintSettingsFragmentTest.java
@@ -45,7 +45,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class PrintSettingsFragmentTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/search/DatabaseIndexingUtilsTest.java b/tests/robotests/src/com/android/settings/search/DatabaseIndexingUtilsTest.java
index 9ce725b..94ce487 100644
--- a/tests/robotests/src/com/android/settings/search/DatabaseIndexingUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/search/DatabaseIndexingUtilsTest.java
@@ -20,18 +20,14 @@
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
-import android.util.ArrayMap;
-import com.android.internal.hardware.AmbientDisplayConfiguration;
import com.android.settings.TestConfig;
-import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.deviceinfo.SystemUpdatePreferenceController;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@@ -43,8 +39,6 @@
public class DatabaseIndexingUtilsTest {
private Context mContext;
- @Mock
- private AmbientDisplayConfiguration mAmbientDisplayConfiguration;
@Before
public void setUp() {
@@ -54,44 +48,22 @@
@Test
public void testGetPreferenceControllerUriMap_BadClassName_ReturnsNull() {
- Map map = DatabaseIndexingUtils.getPreferenceControllerUriMap("dummy", mContext);
- assertThat(map).isNull();
+ Map map = DatabaseIndexingUtils.getPayloadKeyMap("dummy", mContext);
+ assertThat(map).isEmpty();
}
@Test
public void testGetPreferenceControllerUriMap_NullContext_ReturnsNull() {
- Map map = DatabaseIndexingUtils.getPreferenceControllerUriMap("dummy", null);
- assertThat(map).isNull();
- }
-
- @Test
- public void testGetPreferenceControllerUriMap_CompatibleClass_ReturnsValidMap() {
- final String className = "com.android.settings.system.SystemDashboardFragment";
- final Map<String, PreferenceControllerMixin> map =
- DatabaseIndexingUtils.getPreferenceControllerUriMap(className, mContext);
- assertThat(map.get("system_update_settings"))
- .isInstanceOf(SystemUpdatePreferenceController.class);
+ Map map = DatabaseIndexingUtils.getPayloadKeyMap("dummy", null);
+ assertThat(map).isEmpty();
}
@Test
public void testGetPayloadFromMap_NullMap_ReturnsNull() {
- ResultPayload payload = DatabaseIndexingUtils.getPayloadFromUriMap(null, "");
+ final String className = "com.android.settings.system.SystemDashboardFragment";
+ final Map<String, ResultPayload> map =
+ DatabaseIndexingUtils.getPayloadKeyMap(className, mContext);
+ ResultPayload payload = map.get(null);
assertThat(payload).isNull();
}
-
- @Test
- public void testGetPayloadFromMap_MatchingKey_ReturnsPayload() {
- final String key = "key";
- PreferenceControllerMixin prefController = new PreferenceControllerMixin() {
- @Override
- public ResultPayload getResultPayload() {
- return new ResultPayload(null);
- }
- };
- ArrayMap<String, PreferenceControllerMixin> map = new ArrayMap<>();
- map.put(key, prefController);
-
- ResultPayload payload = DatabaseIndexingUtils.getPayloadFromUriMap(map, key);
- assertThat(payload).isInstanceOf(ResultPayload.class);
- }
}
diff --git a/tests/robotests/src/com/android/settings/search/SearchIndexProviderCodeInspector.java b/tests/robotests/src/com/android/settings/search/SearchIndexProviderCodeInspector.java
index 3c51a90..a8372d9 100644
--- a/tests/robotests/src/com/android/settings/search/SearchIndexProviderCodeInspector.java
+++ b/tests/robotests/src/com/android/settings/search/SearchIndexProviderCodeInspector.java
@@ -16,6 +16,9 @@
package com.android.settings.search;
+import static com.google.common.truth.Truth.assertWithMessage;
+
+import android.provider.SearchIndexableResource;
import android.util.ArraySet;
import android.util.Log;
@@ -23,13 +26,13 @@
import com.android.settings.core.codeinspection.CodeInspector;
import com.android.settings.dashboard.DashboardFragmentSearchIndexProviderInspector;
+import org.robolectric.RuntimeEnvironment;
+
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
-import static com.google.common.truth.Truth.assertWithMessage;
-
/**
* {@link CodeInspector} to ensure fragments implement search components correctly.
*/
@@ -49,6 +52,9 @@
"Class containing " + DatabaseIndexingManager.FIELD_NAME_SEARCH_INDEX_DATA_PROVIDER
+ " must be added to " + SearchIndexableResources.class.getName()
+ " but these are not: \n";
+ private static final String NOT_PROVIDING_VALID_RESOURCE_ERROR =
+ "SearchIndexableProvider must either provide no resource to index, or valid ones. "
+ + "But the followings contain resource with xml id = 0\n";
private final List<String> notImplementingIndexableGrandfatherList;
private final List<String> notImplementingIndexProviderGrandfatherList;
@@ -77,6 +83,7 @@
final Set<String> notImplementingIndexProvider = new ArraySet<>();
final Set<String> notInSearchProviderRegistry = new ArraySet<>();
final Set<String> notSharingPreferenceControllers = new ArraySet<>();
+ final Set<String> notProvidingValidResource = new ArraySet<>();
for (Class clazz : mClasses) {
if (!isConcreteSettingsClass(clazz)) {
@@ -119,6 +126,10 @@
notInSearchProviderRegistry.add(className);
}
}
+ // Search provider must either don't provider resource xml, or provide valid ones.
+ if (!hasValidResourceFromProvider(clazz)) {
+ notProvidingValidResource.add(className);
+ }
}
// Build error messages
@@ -131,6 +142,8 @@
notSharingPreferenceControllers);
final String notInProviderRegistryError =
buildErrorMessage(NOT_IN_INDEXABLE_PROVIDER_REGISTRY, notInSearchProviderRegistry);
+ final String notProvidingValidResourceError = buildErrorMessage(
+ NOT_PROVIDING_VALID_RESOURCE_ERROR, notProvidingValidResource);
assertWithMessage(indexableError)
.that(notImplementingIndexable)
.isEmpty();
@@ -143,6 +156,9 @@
assertWithMessage(notInProviderRegistryError)
.that(notInSearchProviderRegistry)
.isEmpty();
+ assertWithMessage(notProvidingValidResourceError)
+ .that(notProvidingValidResource)
+ .isEmpty();
assertNoObsoleteInGrandfatherList("grandfather_not_implementing_indexable",
notImplementingIndexableGrandfatherList);
assertNoObsoleteInGrandfatherList("grandfather_not_implementing_index_provider",
@@ -168,6 +184,28 @@
}
}
+ private boolean hasValidResourceFromProvider(Class clazz) {
+ try {
+ final Indexable.SearchIndexProvider provider =
+ DatabaseIndexingUtils.getSearchIndexProvider(clazz);
+ final List<SearchIndexableResource> resources = provider.getXmlResourcesToIndex(
+ RuntimeEnvironment.application, true /* enabled */);
+ if (resources == null) {
+ // No resource, that's fine.
+ return true;
+ }
+ for (SearchIndexableResource res : resources) {
+ if (res.xmlResId == 0) {
+ // Invalid resource
+ return false;
+ }
+ }
+ } catch (Exception e) {
+ // Ignore.
+ }
+ return true;
+ }
+
private String buildErrorMessage(String errorSummary, Set<String> errorClasses) {
final StringBuilder error = new StringBuilder(errorSummary);
for (String c : errorClasses) {
diff --git a/tests/robotests/src/com/android/settings/search/SiteMapManagerTest.java b/tests/robotests/src/com/android/settings/search/SiteMapManagerTest.java
deleted file mode 100644
index b441b66..0000000
--- a/tests/robotests/src/com/android/settings/search/SiteMapManagerTest.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * 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.search;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.sqlite.SQLiteDatabase;
-import android.os.Bundle;
-
-import com.android.settings.SettingsActivity;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.TestConfig;
-import com.android.settings.dashboard.SiteMapManager;
-import com.android.settings.search.IndexDatabaseHelper.SiteMapColumns;
-import com.android.settings.system.SystemDashboardFragment;
-import com.android.settings.testutils.DatabaseTestUtils;
-import com.android.settings.testutils.FakeFeatureFactory;
-import com.android.settingslib.drawer.CategoryKey;
-import com.android.settingslib.drawer.DashboardCategory;
-import com.android.settingslib.drawer.Tile;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-
-import java.util.Arrays;
-import java.util.List;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.when;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class SiteMapManagerTest {
-
- private static final int STATIC_DB_DEPTH = 4;
- private static final String CLASS_PREFIX = "class_";
- private static final String TITLE_PREFIX = "title_";
-
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mMockContext;
- private Context mContext;
- private SQLiteDatabase mDb;
- private SiteMapManager mSiteMapManager;
- private FakeFeatureFactory mFeatureFactory;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mMockContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mMockContext);
-
- mContext = RuntimeEnvironment.application;
- mDb = IndexDatabaseHelper.getInstance(mContext).getWritableDatabase();
- buildDb();
- mSiteMapManager = new SiteMapManager();
- }
-
- @After
- public void cleanUp() {
- DatabaseTestUtils.clearDb(mContext);
- }
-
- @Test
- public void buildBreadCrumb_onlyFromSiteMapDb_breadcrumbShouldLinkUp() {
- List<String> breadcrumb = mSiteMapManager.buildBreadCrumb(mContext,
- CLASS_PREFIX + 0, TITLE_PREFIX + 0);
- assertThat(breadcrumb.size()).isEqualTo(STATIC_DB_DEPTH + 1);
- for (int i = 0; i < STATIC_DB_DEPTH; i++) {
- assertThat(breadcrumb.get(i)).isEqualTo(TITLE_PREFIX + (STATIC_DB_DEPTH - i));
- }
- }
-
- @Test
- public void buildBreadCrumb_fromSiteMapDbAndDashboardProvider_breadcrumbShouldLinkUp() {
- final String iaClass = SystemDashboardFragment.class.getName();
- final String iaTitle = "ia_title";
-
- ContentValues index = new ContentValues();
- index.put(IndexDatabaseHelper.IndexColumns.CLASS_NAME, iaClass);
- index.put(IndexDatabaseHelper.IndexColumns.SCREEN_TITLE, iaTitle);
- mDb.replaceOrThrow(IndexDatabaseHelper.Tables.TABLE_PREFS_INDEX, null, index);
-
- final DashboardCategory category = new DashboardCategory();
- category.key = CategoryKey.CATEGORY_SYSTEM;
- category.tiles.add(new Tile());
- category.tiles.get(0).title = TITLE_PREFIX + STATIC_DB_DEPTH;
- category.tiles.get(0).metaData = new Bundle();
- category.tiles.get(0).metaData.putString(SettingsActivity.META_DATA_KEY_FRAGMENT_CLASS,
- CLASS_PREFIX + STATIC_DB_DEPTH);
- when(mFeatureFactory.dashboardFeatureProvider.getAllCategories())
- .thenReturn(Arrays.asList(category));
-
- final List<String> breadcrumb = mSiteMapManager.buildBreadCrumb(mContext,
- CLASS_PREFIX + 0, TITLE_PREFIX + 0);
-
- assertThat(breadcrumb.size()).isEqualTo(STATIC_DB_DEPTH + 2);
- assertThat(breadcrumb.get(0))
- .isEqualTo(iaTitle);
- }
-
- @Test
- public void buildBreadCrumb_classNotIndexed_shouldNotHaveBreadCrumb() {
- final String title = "wrong_title";
-
- final List<String> breadcrumb = mSiteMapManager.buildBreadCrumb(mContext,
- "wrong_class", title);
-
- assertThat(breadcrumb.size()).isEqualTo(1);
- assertThat(breadcrumb.get(0)).isEqualTo(title);
- }
-
- private void buildDb() {
- for (int i = 0; i < STATIC_DB_DEPTH; i++) {
- final ContentValues siteMapPair = new ContentValues();
- siteMapPair.put(SiteMapColumns.DOCID, i);
- siteMapPair.put(SiteMapColumns.PARENT_CLASS, CLASS_PREFIX + (i + 1));
- siteMapPair.put(SiteMapColumns.PARENT_TITLE, TITLE_PREFIX + (i + 1));
- siteMapPair.put(SiteMapColumns.CHILD_CLASS, CLASS_PREFIX + i);
- siteMapPair.put(SiteMapColumns.CHILD_TITLE, TITLE_PREFIX + i);
- mDb.replaceOrThrow(IndexDatabaseHelper.Tables.TABLE_SITE_MAP, null, siteMapPair);
- }
- }
-}
diff --git a/tests/robotests/src/com/android/settings/search/actionbar/SearchMenuControllerTest.java b/tests/robotests/src/com/android/settings/search/actionbar/SearchMenuControllerTest.java
new file mode 100644
index 0000000..52918fb
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/search/actionbar/SearchMenuControllerTest.java
@@ -0,0 +1,90 @@
+/*
+ * 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.search.actionbar;
+
+import static org.mockito.Matchers.nullable;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+
+import com.android.settings.R;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.core.lifecycle.ObservablePreferenceFragment;
+
+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_O)
+public class SearchMenuControllerTest {
+
+ @Mock
+ private Menu mMenu;
+ private TestFragment mHost;
+ private FakeFeatureFactory mFeatureFactory;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mHost = new TestFragment();
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
+ }
+
+ @Test
+ public void init_searchV2Disabled_shouldNotAddMenu() {
+ when(mFeatureFactory.searchFeatureProvider.isSearchV2Enabled(nullable(Context.class)))
+ .thenReturn(false);
+
+ SearchMenuController.init(mHost);
+ mHost.getLifecycle().onCreateOptionsMenu(mMenu, null /* inflater */);
+
+ verifyZeroInteractions(mMenu);
+ }
+
+ @Test
+ public void init_searchV2Enabled_shouldAddMenu() {
+ when(mFeatureFactory.searchFeatureProvider.isSearchV2Enabled(nullable(Context.class)))
+ .thenReturn(true);
+ when(mMenu.add(Menu.NONE, Menu.NONE, 0 /* order */, R.string.search_menu))
+ .thenReturn(mock(MenuItem.class));
+
+ SearchMenuController.init(mHost);
+ mHost.getLifecycle().onCreateOptionsMenu(mMenu, null /* inflater */);
+
+ verify(mMenu).add(Menu.NONE, Menu.NONE, 0 /* order */, R.string.search_menu);
+ }
+
+ public static class TestFragment extends ObservablePreferenceFragment {
+
+ @Override
+ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
+
+ }
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/support/actionbar/HelpMenuControllerTest.java b/tests/robotests/src/com/android/settings/support/actionbar/HelpMenuControllerTest.java
new file mode 100644
index 0000000..24e7d81
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/support/actionbar/HelpMenuControllerTest.java
@@ -0,0 +1,84 @@
+/*
+ * 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.support.actionbar;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+import android.content.Context;
+import android.os.Bundle;
+
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.core.lifecycle.ObservablePreferenceFragment;
+
+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_O)
+public class HelpMenuControllerTest {
+
+ @Mock
+ private Context mContext;
+ private TestFragment mHost;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mHost = spy(new TestFragment());
+ doReturn(mContext).when(mHost).getContext();
+ }
+
+ @Test
+ public void onCreateOptionsMenu_withArgumentOverride_shouldPrepareHelpUsingOverride() {
+ final Bundle bundle = new Bundle();
+ bundle.putInt(HelpResourceProvider.HELP_URI_RESOURCE_KEY, 123);
+ mHost.setArguments(bundle);
+
+ HelpMenuController.init(mHost);
+
+ mHost.getLifecycle().onCreateOptionsMenu(null /* menu */, null /* inflater */);
+
+ verify(mContext).getString(123);
+
+ }
+
+ @Test
+ public void onCreateOptionsMenu_noArgumentOverride_shouldPrepareHelpUsingProvider() {
+ HelpMenuController.init(mHost);
+
+ mHost.getLifecycle().onCreateOptionsMenu(null /* menu */, null /* inflater */);
+
+ verify(mContext).getString(mHost.getHelpResource());
+ }
+
+
+ public static class TestFragment extends ObservablePreferenceFragment
+ implements HelpResourceProvider {
+
+ @Override
+ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
+
+ }
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowFragment.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowFragment.java
new file mode 100644
index 0000000..4596559
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowFragment.java
@@ -0,0 +1,47 @@
+/*
+ * 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.testutils.shadow;
+
+import android.app.Fragment;
+import android.app.FragmentManager;
+
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+
+/**
+ * Override the {@link #setTargetFragment(Fragment, int)} to skip an illegal state exception
+ * in SDK 26. SDK 26 requires that the target fragment be in the same {@link FragmentManager} as
+ * the current {@link Fragment}. This is infeasible with our current framework.
+ */
+@Implements(
+ value = Fragment.class,
+ minSdk = 26
+)
+public class ShadowFragment {
+
+ private Fragment mTargetFragment;
+
+ @Implementation
+ public void setTargetFragment(Fragment fragment, int requestCode) {
+ mTargetFragment = fragment;
+ }
+
+ @Implementation
+ final public Fragment getTargetFragment() {
+ return mTargetFragment;
+ }
+}
diff --git a/tests/unit/src/com/android/settings/core/PreferenceControllerContractTest.java b/tests/unit/src/com/android/settings/core/PreferenceControllerContractTest.java
index bc82125..86e8dc1 100644
--- a/tests/unit/src/com/android/settings/core/PreferenceControllerContractTest.java
+++ b/tests/unit/src/com/android/settings/core/PreferenceControllerContractTest.java
@@ -54,7 +54,7 @@
public void controllersInSearchShouldImplementPreferenceControllerMixin() {
final Set<String> errorClasses = new ArraySet<>();
- for (Class clazz: SearchIndexableResources.providerValues()) {
+ for (Class clazz : SearchIndexableResources.providerValues()) {
final Indexable.SearchIndexProvider provider =
DatabaseIndexingUtils.getSearchIndexProvider(clazz);
@@ -68,7 +68,8 @@
continue;
}
for (AbstractPreferenceController controller : controllers) {
- if (!(controller instanceof PreferenceControllerMixin)) {
+ if (!(controller instanceof PreferenceControllerMixin)
+ && !(controller instanceof BasePreferenceController)) {
errorClasses.add(controller.getClass().getName());
}
}
@@ -76,7 +77,8 @@
if (!errorClasses.isEmpty()) {
final StringBuilder errorMessage = new StringBuilder()
- .append("Each preference must implement PreferenceControllerMixin, ")
+ .append("Each preference must implement PreferenceControllerMixin ")
+ .append("or extend BasePreferenceController, ")
.append("the following classes don't:\n");
for (String c : errorClasses) {
errorMessage.append(c).append("\n");
diff --git a/tests/unit/src/com/android/settings/search/SettingsSearchIndexablesProviderTest.java b/tests/unit/src/com/android/settings/search/SettingsSearchIndexablesProviderTest.java
new file mode 100644
index 0000000..aed94a0
--- /dev/null
+++ b/tests/unit/src/com/android/settings/search/SettingsSearchIndexablesProviderTest.java
@@ -0,0 +1,62 @@
+/*
+ * 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.search;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.database.Cursor;
+import android.net.Uri;
+import android.provider.SearchIndexablesContract;
+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 SettingsSearchIndexablesProviderTest {
+
+ private Context mContext;
+
+
+ @Before
+ public void setUp() {
+ mContext = InstrumentationRegistry.getTargetContext();
+ }
+
+ @Test
+ public void testSiteMapPairsFetched() {
+ final Uri uri = Uri.parse("content://" + mContext.getPackageName() + "/" +
+ SearchIndexablesContract.SITE_MAP_PAIRS_PATH);
+ final Cursor cursor = mContext.getContentResolver().query(uri, null, null, null, null);
+
+ final int size = cursor.getCount();
+ assertThat(size).isGreaterThan(0);
+ while (cursor.moveToNext()) {
+ assertThat(cursor.getString(cursor.getColumnIndexOrThrow(
+ SearchIndexablesContract.SiteMapColumns.PARENT_CLASS)))
+ .isNotEmpty();
+ assertThat(cursor.getString(cursor.getColumnIndexOrThrow(
+ SearchIndexablesContract.SiteMapColumns.CHILD_CLASS)))
+ .isNotEmpty();
+ }
+ }
+}