Merge "Fix capitalization on Photos & videos."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 4cc7bf0..bbf4739 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -904,15 +904,17 @@
<category android:name="android.intent.category.VOICE_LAUNCH" />
<category android:name="com.android.settings.SHORTCUT" />
</intent-filter>
- <intent-filter android:priority="9">
+ <intent-filter android:priority="7">
<action android:name="com.android.settings.action.SETTINGS" />
</intent-filter>
<meta-data android:name="com.android.settings.category"
- android:value="com.android.settings.category.device" />
+ android:value="com.android.settings.category.ia.homepage" />
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.DisplaySettings" />
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
android:value="true" />
+ <meta-data android:name="com.android.settings.summary"
+ android:value="@string/display_dashboard_summary"/>
</activity>
<!-- Keep compatibility with old shortcuts. -->
@@ -2573,15 +2575,21 @@
<category android:name="android.intent.category.VOICE_LAUNCH" />
<category android:name="com.android.settings.SHORTCUT" />
</intent-filter>
- <intent-filter android:priority="7">
+ <intent-filter android:priority="1">
+ <action android:name="android.settings.ACTION_OTHER_SOUND_SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <intent-filter android:priority="6">
<action android:name="com.android.settings.action.SETTINGS" />
</intent-filter>
<meta-data android:name="com.android.settings.category"
- android:value="com.android.settings.category.device" />
+ android:value="com.android.settings.category.ia.homepage" />
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.notification.SoundSettings" />
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
android:value="true" />
+ <meta-data android:name="com.android.settings.summary"
+ android:value="@string/sound_dashboard_summary"/>
</activity>
<!-- Keep compatibility with old shortcuts. -->
@@ -2593,24 +2601,6 @@
android:value="com.android.settings.notification.SoundSettings" />
</activity-alias>
- <activity android:name="Settings$OtherSoundSettingsActivity"
- android:label="@string/other_sound_settings"
- android:exported="true"
- android:taskAffinity="">
- <intent-filter android:priority="1">
- <action android:name="android.settings.ACTION_OTHER_SOUND_SETTINGS" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.notification.OtherSoundSettings" />
- <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
- android:value="true" />
- </activity>
-
<!-- Show apps for which application-level notification settings are applicable -->
<activity android:name="Settings$NotificationAppListActivity"
android:label="@string/app_notifications_title"
@@ -3055,37 +3045,6 @@
android:value="com.android.settings.category.ia.homepage"/>
</activity-alias>
- <activity-alias android:name="DisplayDashboardAlias"
- android:targetActivity="Settings$DisplaySettingsActivity">
- <intent-filter android:priority="7">
- <action android:name="com.android.settings.action.SETTINGS" />
- </intent-filter>
- <meta-data android:name="com.android.settings.category"
- android:value="com.android.settings.category.ia.homepage" />
- <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.DisplaySettings" />
- <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
- android:value="true" />
- <meta-data android:name="com.android.settings.summary"
- android:value="@string/display_dashboard_summary"/>
- </activity-alias>
-
- <activity-alias android:name="SoundDashboardAlias"
- android:targetActivity="Settings$SoundSettingsActivity"
- android:icon="@drawable/ic_dashboard_sound">
- <intent-filter android:priority="6">
- <action android:name="com.android.settings.action.SETTINGS" />
- </intent-filter>
- <meta-data android:name="com.android.settings.category"
- android:value="com.android.settings.category.ia.homepage" />
- <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.notification.SoundSettings" />
- <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
- android:value="true" />
- <meta-data android:name="com.android.settings.summary"
- android:value="@string/sound_dashboard_summary"/>
- </activity-alias>
-
<activity android:name=".Settings$StorageDashboardActivity"
android:label="@string/storage_settings"
android:icon="@drawable/ic_dashboard_storage">
diff --git a/res/layout/dashboard_container.xml b/res/layout/dashboard_container.xml
deleted file mode 100644
index f6b81ae..0000000
--- a/res/layout/dashboard_container.xml
+++ /dev/null
@@ -1,21 +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.
--->
-
-<com.android.settings.widget.RtlCompatibleViewPager
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/pager"
- android:layout_width="match_parent"
- android:layout_height="match_parent"/>
diff --git a/res/layout/dashboard_container_header.xml b/res/layout/dashboard_container_header.xml
deleted file mode 100644
index 37412e7..0000000
--- a/res/layout/dashboard_container_header.xml
+++ /dev/null
@@ -1,23 +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.
--->
-
-<com.android.settings.widget.SlidingTabLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/sliding_tabs"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginStart="@dimen/dashboard_header_margin_start"
- android:layout_marginEnd="@dimen/dashboard_header_margin_end"/>
diff --git a/res/values-sw720dp-land/dimens.xml b/res/values-sw720dp-land/dimens.xml
index 70faa0f..b1ec4c7 100644
--- a/res/values-sw720dp-land/dimens.xml
+++ b/res/values-sw720dp-land/dimens.xml
@@ -21,10 +21,6 @@
<dimen name="dashboard_padding_start">160dp</dimen>
<dimen name="dashboard_padding_end">160dp</dimen>
- <!-- Dashboard Header margin in its container -->
- <dimen name="dashboard_header_margin_start">304dp</dimen>
- <dimen name="dashboard_header_margin_end">304dp</dimen>
-
<!-- ActionBar contentInsetStart -->
<dimen name="actionbar_contentInsetStart">128dp</dimen>
<dimen name="actionbar_subsettings_contentInsetStart">128dp</dimen>
diff --git a/res/values-sw720dp/dimens.xml b/res/values-sw720dp/dimens.xml
index a0be467..981c936 100644
--- a/res/values-sw720dp/dimens.xml
+++ b/res/values-sw720dp/dimens.xml
@@ -42,10 +42,6 @@
<dimen name="dashboard_padding_start">80dp</dimen>
<dimen name="dashboard_padding_end">80dp</dimen>
- <!-- Dashboard Header margin in its container -->
- <dimen name="dashboard_header_margin_start">176dp</dimen>
- <dimen name="dashboard_header_margin_end">176dp</dimen>
-
<!-- Dashboard category padding start / end -->
<dimen name="dashboard_category_padding_start">24dp</dimen>
<dimen name="dashboard_category_padding_end">24dp</dimen>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 0ddc634..fe5845a 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -88,10 +88,6 @@
<dimen name="dashboard_padding_top">0dp</dimen>
<dimen name="dashboard_padding_bottom">0dp</dimen>
- <!-- Dashboard Header margin in its container -->
- <dimen name="dashboard_header_margin_start">0dp</dimen>
- <dimen name="dashboard_header_margin_end">0dp</dimen>
-
<!-- Dashboard category padding start / end -->
<dimen name="dashboard_category_padding_start">0dp</dimen>
<dimen name="dashboard_category_padding_end">0dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index f8a3964..01547ef 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -8190,7 +8190,7 @@
<string name="storage_photos_videos">Photos & videos</string>
<!-- Preference label for the Music & Audio storage section. [CHAR LIMIT=50] -->
- <string name="storage_music_audio">Music & Audio</string>
+ <string name="storage_music_audio">Music & audio</string>
<!-- Preference label for the Games storage section. [CHAR LIMIT=50] -->
<string name="storage_games">Games</string>
@@ -8225,8 +8225,6 @@
<!-- Title for audio files preference. [CHAR LIMIT=50] -->
<string name="audio_files_title">Audio files</string>
- <!-- Title for the Audio storage view. [CHAR LIMIT=50] -->
- <string name="audio_storage_title">Music</string>
<!-- UI webview setting: WebView uninstalled-for-user explanatory text [CHAR LIMIT=30] -->
<string name="webview_uninstalled_for_user">(uninstalled for user <xliff:g id="user" example="John Doe">%s</xliff:g>)</string>
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
deleted file mode 100644
index 2632c78..0000000
--- a/res/xml/display_settings.xml
+++ /dev/null
@@ -1,119 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 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:settings="http://schemas.android.com/apk/res/com.android.settings"
- android:title="@string/display_settings"
- settings:keywords="@string/keywords_display">
-
- <Preference
- android:key="brightness"
- android:title="@string/brightness"
- settings:keywords="@string/keywords_display_brightness_level">
- <intent android:action="android.intent.action.SHOW_BRIGHTNESS_DIALOG" />
- </Preference>
-
- <SwitchPreference
- android:key="auto_brightness"
- android:title="@string/auto_brightness_title"
- settings:keywords="@string/keywords_display_auto_brightness"
- android:summary="@string/auto_brightness_summary" />
-
- <com.android.settings.display.NightDisplayPreference
- android:key="night_display"
- android:title="@string/night_display_title"
- android:fragment="com.android.settings.display.NightDisplaySettings"
- settings:widgetLayout="@null"
- settings:keywords="@string/keywords_display_night_display" />
-
- <!-- Hide night mode for now
- <ListPreference
- android:key="night_mode"
- android:title="@string/night_mode_title"
- settings:keywords="@string/keywords_display_night_mode"
- android:summary="@string/night_mode_summary"
- android:entries="@array/night_mode_entries"
- android:entryValues="@array/night_mode_values" /> -->
-
- <com.android.settingslib.RestrictedPreference
- android:key="wallpaper"
- android:title="@string/wallpaper_settings_title"
- settings:keywords="@string/keywords_display_wallpaper"
- settings:useAdminDisabledSummary="true" >
- <intent
- android:targetPackage="@string/config_wallpaper_picker_package"
- android:targetClass="@string/config_wallpaper_picker_class" />
- </com.android.settingslib.RestrictedPreference>
-
- <com.android.settings.TimeoutListPreference
- android:key="screen_timeout"
- android:title="@string/screen_timeout"
- android:summary="@string/screen_timeout_summary"
- android:entries="@array/screen_timeout_entries"
- android:entryValues="@array/screen_timeout_values" />
-
- <SwitchPreference
- android:key="camera_gesture"
- android:title="@string/camera_gesture_title"
- android:summary="@string/camera_gesture_desc" />
-
- <Preference
- android:key="screensaver"
- android:title="@string/screensaver_settings_title"
- android:fragment="com.android.settings.DreamSettings" />
-
- <SwitchPreference
- android:key="lift_to_wake"
- android:title="@string/lift_to_wake_title" />
-
- <SwitchPreference
- android:key="doze"
- android:title="@string/doze_title"
- android:summary="@string/doze_summary" />
-
- <SwitchPreference
- android:key="tap_to_wake"
- android:title="@string/tap_to_wake"
- android:summary="@string/tap_to_wake_summary" />
-
- <Preference
- android:key="font_size"
- android:title="@string/title_font_size"
- android:fragment="com.android.settings.accessibility.ToggleFontSizePreferenceFragment"
- settings:keywords="@string/keywords_display_font_size" />
-
- <com.android.settings.display.ScreenZoomPreference
- android:key="screen_zoom"
- android:title="@string/screen_zoom_title"
- settings:keywords="@string/screen_zoom_keywords" />
-
- <DropDownPreference
- android:key="auto_rotate"
- android:summary="%s"
- android:title="@string/display_auto_rotate_title" />
-
- <Preference
- android:key="wifi_display"
- android:title="@string/wifi_display_settings_title"
- settings:keywords="@string/keywords_display_cast_screen"
- android:fragment="com.android.settings.wfd.WifiDisplaySettings" />
-
- <DropDownPreference
- android:key="vr_display_pref"
- android:summary="%s"
- android:title="@string/display_vr_pref_title" />
-
-</PreferenceScreen>
diff --git a/res/xml/sound_settings.xml b/res/xml/sound_settings.xml
deleted file mode 100644
index c74d1f1..0000000
--- a/res/xml/sound_settings.xml
+++ /dev/null
@@ -1,109 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 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:settings="http://schemas.android.com/apk/res/com.android.settings"
- android:title="@string/sound_settings"
- android:key="sound_settings"
- settings:keywords="@string/keywords_sounds">
-
- <!-- Media volume -->
- <com.android.settings.notification.VolumeSeekBarPreference
- android:key="media_volume"
- android:icon="@*android:drawable/ic_audio_media"
- android:title="@string/media_volume_option_title" />
-
- <!-- Alarm volume -->
- <com.android.settings.notification.VolumeSeekBarPreference
- android:key="alarm_volume"
- android:icon="@*android:drawable/ic_audio_alarm"
- android:title="@string/alarm_volume_option_title" />
-
- <!-- Ring volume -->
- <com.android.settings.notification.VolumeSeekBarPreference
- android:key="ring_volume"
- android:icon="@*android:drawable/ic_audio_ring_notif"
- android:title="@string/ring_volume_option_title" />
-
- <!-- Notification volume -->
- <com.android.settings.notification.VolumeSeekBarPreference
- android:key="notification_volume"
- android:icon="@*android:drawable/ic_audio_ring_notif"
- android:title="@string/notification_volume_option_title" />
-
- <!-- Also vibrate for calls -->
- <SwitchPreference
- android:key="vibrate_when_ringing"
- android:title="@string/vibrate_when_ringing_title" />
-
-
- <!-- Interruptions -->
- <com.android.settingslib.RestrictedPreference
- android:key="zen_mode"
- android:title="@string/zen_mode_settings_title"
- settings:useAdminDisabledSummary="true"
- settings:keywords="@string/keywords_sounds_and_notifications_interruptions"
- android:fragment="com.android.settings.notification.ZenModeSettings" />
-
- <!-- Phone ringtone -->
- <com.android.settings.DefaultRingtonePreference
- android:key="ringtone"
- android:title="@string/ringtone_title"
- android:dialogTitle="@string/ringtone_title"
- android:summary="@string/ringtone_summary"
- android:ringtoneType="ringtone" />
-
- <!-- Default notification ringtone -->
- <com.android.settings.DefaultRingtonePreference
- android:key="notification_ringtone"
- android:title="@string/notification_ringtone_title"
- android:dialogTitle="@string/notification_ringtone_title"
- android:summary="@string/ringtone_summary"
- android:ringtoneType="notification" />
-
- <!-- Default alarm ringtone -->
- <com.android.settings.DefaultRingtonePreference
- android:key="alarm_ringtone"
- android:title="@string/alarm_ringtone_title"
- android:dialogTitle="@string/alarm_ringtone_title"
- android:summary="@string/ringtone_summary"
- android:persistent="false"
- android:ringtoneType="alarm" />
-
- <com.android.settingslib.RestrictedPreference
- android:key="cell_broadcast_settings"
- android:title="@string/cell_broadcast_settings"
- settings:useAdminDisabledSummary="true">
- <intent
- android:action="android.intent.action.MAIN"
- android:targetPackage="com.android.cellbroadcastreceiver"
- android:targetClass="com.android.cellbroadcastreceiver.CellBroadcastSettings" />
- </com.android.settingslib.RestrictedPreference>
-
- <!-- Other sounds -->
- <Preference
- android:key="other_sounds"
- android:title="@string/other_sound_settings"
- android:persistent="false"
- android:fragment="com.android.settings.notification.OtherSoundSettings" />
-
- <!-- Cast -->
- <Preference
- android:key="wifi_display"
- android:title="@string/wifi_display_settings_title"
- android:fragment="com.android.settings.wfd.WifiDisplaySettings" />
-
-</PreferenceScreen>
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java
index aa17499..1e0547b 100644
--- a/src/com/android/settings/DisplaySettings.java
+++ b/src/com/android/settings/DisplaySettings.java
@@ -64,11 +64,7 @@
@Override
protected int getPreferenceScreenResId() {
- if (mDashboardFeatureProvider.isEnabled()) {
- return R.xml.ia_display_settings;
- } else {
- return R.xml.display_settings;
- }
+ return R.xml.ia_display_settings;
}
@Override
@@ -104,14 +100,7 @@
final ArrayList<SearchIndexableResource> result = new ArrayList<>();
final SearchIndexableResource sir = new SearchIndexableResource(context);
- final boolean useNewIA = FeatureFactory.getFactory(context)
- .getDashboardFeatureProvider(context)
- .isEnabled();
- if (useNewIA) {
- sir.xmlResId = R.xml.ia_display_settings;
- } else {
- sir.xmlResId = R.xml.display_settings;
- }
+ sir.xmlResId = R.xml.ia_display_settings;
result.add(sir);
return result;
}
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index e92027a..7fc3188 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -121,7 +121,6 @@
public static class NotificationAppListActivity extends SettingsActivity { /* empty */ }
public static class AppNotificationSettingsActivity extends SettingsActivity { /* empty */ }
public static class ChannelNotificationSettingsActivity extends SettingsActivity { /* empty */ }
- public static class OtherSoundSettingsActivity extends SettingsActivity { /* empty */ }
public static class ManageDomainUrlsActivity extends SettingsActivity { /* empty */ }
public static class AutomaticStorageManagerSettingsActivity extends SettingsActivity { /* empty */ }
public static class GamesStorageActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 00bdf57..84901fb 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -58,7 +58,6 @@
import com.android.settings.core.gateway.SettingsGateway;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
import com.android.settings.core.instrumentation.SharedPreferencesLogger;
-import com.android.settings.dashboard.DashboardContainerFragment;
import com.android.settings.dashboard.DashboardFeatureProvider;
import com.android.settings.dashboard.DashboardSummary;
import com.android.settings.dashboard.SearchResultsSummary;
@@ -154,6 +153,7 @@
public static final String EXTRA_SHOW_FRAGMENT_AS_SUBSETTING =
":settings:show_fragment_as_subsetting";
+ @Deprecated
public static final String EXTRA_HIDE_DRAWER = ":settings:hide_drawer";
public static final String META_DATA_KEY_FRAGMENT_CLASS =
@@ -367,9 +367,6 @@
if (intent.hasExtra(EXTRA_UI_OPTIONS)) {
getWindow().setUiOptions(intent.getIntExtra(EXTRA_UI_OPTIONS, 0));
}
- if (intent.getBooleanExtra(EXTRA_HIDE_DRAWER, false)) {
- setIsDrawerPresent(false);
- }
mDevelopmentPreferences = getSharedPreferences(DevelopmentSettings.PREF_FILE,
Context.MODE_PRIVATE);
@@ -461,17 +458,8 @@
mDisplaySearch = true;
mInitialTitleResId = R.string.dashboard_title;
- // add argument to indicate which settings tab should be initially selected
- final Bundle args = new Bundle();
- final String extraName = DashboardContainerFragment.EXTRA_SELECT_SETTINGS_TAB;
- args.putString(extraName, intent.getStringExtra(extraName));
- if (isDashboardFeatureEnabled()) {
- switchToFragment(DashboardSummary.class.getName(), args, false, false,
+ switchToFragment(DashboardSummary.class.getName(), null /* args */, false, false,
mInitialTitleResId, mInitialTitle, false);
- } else {
- switchToFragment(DashboardContainerFragment.class.getName(), args, false, false,
- mInitialTitleResId, mInitialTitle, false);
- }
}
}
@@ -957,12 +945,7 @@
if (UserHandle.MU_ENABLED && !isAdmin) {
// When on restricted users, disable all extra categories (but only the settings ones).
- List<DashboardCategory> categories;
- if (isDashboardFeatureEnabled()) {
- categories = mDashboardFeatureProvider.getAllCategories();
- } else {
- categories = getDashboardCategories();
- }
+ final List<DashboardCategory> categories = mDashboardFeatureProvider.getAllCategories();
for (DashboardCategory category : categories) {
for (Tile tile : category.tiles) {
@@ -1017,15 +1000,6 @@
}
}
- @Override
- protected boolean isDashboardFeatureEnabled() {
- if (mDashboardFeatureProvider == null) {
- mDashboardFeatureProvider =
- FeatureFactory.getFactory(this).getDashboardFeatureProvider(this);
- }
- return mDashboardFeatureProvider.isEnabled();
- }
-
// give subclasses access to the Next button
public boolean hasNextButton() {
return mNextButton != null;
@@ -1085,16 +1059,6 @@
}
@Override
- protected void onTileClicked(Tile tile) {
- if (mIsShowingDashboard) {
- // If on dashboard, don't finish so the back comes back to here.
- openTile(tile);
- } else {
- super.onTileClicked(tile);
- }
- }
-
- @Override
public void onProfileTileOpen() {
if (!mIsShowingDashboard) {
finish();
diff --git a/src/com/android/settings/TrustedCredentialsSettings.java b/src/com/android/settings/TrustedCredentialsSettings.java
index 3f5748c..4696dd3 100644
--- a/src/com/android/settings/TrustedCredentialsSettings.java
+++ b/src/com/android/settings/TrustedCredentialsSettings.java
@@ -63,7 +63,6 @@
import com.android.internal.app.UnlaunchableAppActivity;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.internal.util.ParcelableString;
import com.android.internal.widget.LockPatternUtils;
import java.security.cert.CertificateEncodingException;
@@ -125,7 +124,7 @@
mSwitch = withSwitch;
}
- private List<ParcelableString> getAliases(IKeyChainService service) throws RemoteException {
+ private List<String> getAliases(IKeyChainService service) throws RemoteException {
switch (this) {
case SYSTEM: {
return service.getSystemCaAliases().getList();
@@ -689,8 +688,8 @@
final int n = profiles.size();
// First we get all aliases for all profiles in order to show progress
// correctly. Otherwise this could all be in a single loop.
- SparseArray<List<ParcelableString>> aliasesByProfileId = new SparseArray<
- List<ParcelableString>>(n);
+ SparseArray<List<String>> aliasesByProfileId = new SparseArray<
+ List<String>>(n);
int max = 0;
int progress = 0;
for (int i = 0; i < n; ++i) {
@@ -704,7 +703,7 @@
// Saving the connection for later use on the certificate dialog.
mKeyChainConnectionByProfileId.put(profileId, keyChainConnection);
IKeyChainService service = keyChainConnection.getService();
- List<ParcelableString> aliases = mTab.getAliases(service);
+ List<String> aliases = mTab.getAliases(service);
if (isCancelled()) {
return new SparseArray<List<CertHolder>>();
}
@@ -714,7 +713,7 @@
for (int i = 0; i < n; ++i) {
UserHandle profile = profiles.get(i);
int profileId = profile.getIdentifier();
- List<ParcelableString> aliases = aliasesByProfileId.get(profileId);
+ List<String> aliases = aliasesByProfileId.get(profileId);
if (isCancelled()) {
return new SparseArray<List<CertHolder>>();
}
@@ -729,7 +728,7 @@
List<CertHolder> certHolders = new ArrayList<CertHolder>(max);
final int aliasMax = aliases.size();
for (int j = 0; j < aliasMax; ++j) {
- String alias = aliases.get(j).string;
+ String alias = aliases.get(j);
byte[] encodedCertificate = service.getEncodedCaCertificate(alias,
true);
X509Certificate cert = KeyChain.toCertificate(encodedCertificate);
diff --git a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java
index cf72383..b820cc2 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java
@@ -46,7 +46,6 @@
// Finish configuring the content view.
getActionBar().setDisplayHomeAsUpEnabled(true);
- setIsDrawerPresent(false);
}
@Override
diff --git a/src/com/android/settings/applications/AppHeaderController.java b/src/com/android/settings/applications/AppHeaderController.java
index 01d5fc7..1d64fca 100644
--- a/src/com/android/settings/applications/AppHeaderController.java
+++ b/src/com/android/settings/applications/AppHeaderController.java
@@ -267,6 +267,8 @@
|| !AppHeader.includeAppInfo(mFragment)) {
button.setVisibility(View.GONE);
} else {
+ button.setContentDescription(
+ mContext.getString(R.string.application_info_label));
button.setImageResource(com.android.settings.R.drawable.ic_info);
button.setOnClickListener(v -> AppInfoBase.startAppInfoFragment(
InstalledAppDetails.class, R.string.application_info_label,
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 8379d34..02eb0e9 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -104,7 +104,6 @@
import com.android.settings.notification.ConfigureNotificationSettings;
import com.android.settings.notification.NotificationAccessSettings;
import com.android.settings.notification.NotificationStation;
-import com.android.settings.notification.OtherSoundSettings;
import com.android.settings.notification.SoundSettings;
import com.android.settings.notification.ZenAccessSettings;
import com.android.settings.notification.ZenModeAutomationSettings;
@@ -208,7 +207,6 @@
BatterySaverSettings.class.getName(),
AppNotificationSettings.class.getName(),
ChannelNotificationSettings.class.getName(),
- OtherSoundSettings.class.getName(),
ApnSettings.class.getName(),
ApnEditor.class.getName(),
WifiCallingSettings.class.getName(),
@@ -283,7 +281,6 @@
Settings.ConnectedDeviceDashboardActivity.class.getName(),
Settings.AppAndNotificationDashboardActivity.class.getName(),
"com.android.settings.BatteryDashboardAlias",
- "com.android.settings.DisplayDashboardAlias",
"com.android.settings.SoundDashboardAlias",
"com.android.settings.SecurityDashboardAlias",
"com.android.settings.UsersDashboardAlias",
diff --git a/src/com/android/settings/dashboard/DashboardContainerFragment.java b/src/com/android/settings/dashboard/DashboardContainerFragment.java
deleted file mode 100644
index b3ee808..0000000
--- a/src/com/android/settings/dashboard/DashboardContainerFragment.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.settings.dashboard;
-
-import android.app.Activity;
-import android.app.Fragment;
-import android.app.FragmentManager;
-import android.content.Context;
-import android.os.Bundle;
-import android.support.v13.app.FragmentPagerAdapter;
-import android.text.TextUtils;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import com.android.internal.logging.nano.MetricsProto;
-import com.android.settings.R;
-import com.android.settings.SettingsActivity;
-import com.android.settings.core.InstrumentedFragment;
-import com.android.settings.core.instrumentation.MetricsFeatureProvider;
-import com.android.settings.overlay.FeatureFactory;
-import com.android.settings.overlay.SupportFeatureProvider;
-import com.android.settings.widget.RtlCompatibleViewPager;
-import com.android.settings.widget.SlidingTabLayout;
-import com.android.settingslib.drawer.SettingsDrawerActivity;
-
-/**
- * Container for Dashboard fragments.
- */
-public final class DashboardContainerFragment extends InstrumentedFragment {
-
- public static final String EXTRA_SELECT_SETTINGS_TAB = ":settings:select_settings_tab";
-
- private static final String ARG_SUPPORT_TAB = "SUPPORT";
- private static final String ARG_SUMMARY_TAB = "SUMMARY";
- private static final int INDEX_SUMMARY_FRAGMENT = 0;
- private static final int INDEX_SUPPORT_FRAGMENT = 1;
-
- private RtlCompatibleViewPager mViewPager;
- private View mHeaderView;
- private DashboardViewPagerAdapter mPagerAdapter;
-
- @Override
- public int getMetricsCategory() {
- return MetricsProto.MetricsEvent.DASHBOARD_CONTAINER;
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setHasOptionsMenu(true);
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
- final View content = inflater.inflate(R.layout.dashboard_container, parent, false);
- mViewPager = (RtlCompatibleViewPager) content.findViewById(R.id.pager);
- mPagerAdapter = new DashboardViewPagerAdapter(getContext(),
- getChildFragmentManager(), mViewPager);
- mViewPager.setAdapter(mPagerAdapter);
- mViewPager.addOnPageChangeListener(
- new TabChangeListener((SettingsActivity) getActivity(), mMetricsFeatureProvider));
-
- // check if support tab needs to be selected
- final String selectedTab = getArguments().
- getString(EXTRA_SELECT_SETTINGS_TAB, ARG_SUMMARY_TAB);
- if (TextUtils.equals(selectedTab, ARG_SUPPORT_TAB)) {
- mViewPager.setCurrentItem(INDEX_SUPPORT_FRAGMENT);
- } else {
- mViewPager.setCurrentItem(INDEX_SUMMARY_FRAGMENT);
- }
-
- mHeaderView = inflater.inflate(R.layout.dashboard_container_header, parent, false);
- ((SlidingTabLayout) mHeaderView).setViewPager(mViewPager);
- return content;
- }
-
- @Override
- public void onResume() {
- super.onResume();
- if (mPagerAdapter.getCount() > 1) {
- final Activity activity = getActivity();
- if (activity instanceof SettingsDrawerActivity) {
- ((SettingsDrawerActivity) getActivity()).setContentHeaderView(mHeaderView);
- }
- }
- }
-
- private static final class DashboardViewPagerAdapter extends FragmentPagerAdapter {
-
- private final Context mContext;
- private final SupportFeatureProvider mSupportFeatureProvider;
- private final RtlCompatibleViewPager mViewPager;
-
- public DashboardViewPagerAdapter(Context context, FragmentManager fragmentManager,
- RtlCompatibleViewPager viewPager) {
- super(fragmentManager);
- mContext = context;
- mSupportFeatureProvider =
- FeatureFactory.getFactory(context).getSupportFeatureProvider(context);
- mViewPager = viewPager;
- }
-
- @Override
- public CharSequence getPageTitle(int position) {
- switch (position) {
- case INDEX_SUMMARY_FRAGMENT:
- return mContext.getString(R.string.page_tab_title_summary);
- case INDEX_SUPPORT_FRAGMENT:
- return mContext.getString(R.string.page_tab_title_support);
- }
- return super.getPageTitle(position);
- }
-
- @Override
- public Fragment getItem(int position) {
- switch (position) {
- case INDEX_SUMMARY_FRAGMENT:
- return new DashboardSummary();
- case INDEX_SUPPORT_FRAGMENT:
- return new SupportFragment();
- default:
- throw new IllegalArgumentException(
- String.format(
- "Position %d does not map to a valid dashboard fragment",
- position));
- }
- }
-
- @Override
- public Object instantiateItem(ViewGroup container, int position) {
- return super.instantiateItem(container,
- mViewPager.getRtlAwareIndex(position));
- }
-
- @Override
- public int getCount() {
- return mSupportFeatureProvider == null ? 1 : 2;
- }
- }
-
- private static final class TabChangeListener
- implements RtlCompatibleViewPager.OnPageChangeListener {
-
- private final SettingsActivity mActivity;
- private final MetricsFeatureProvider mMetricsFeatureProvider;
-
- public TabChangeListener(SettingsActivity activity,
- MetricsFeatureProvider metricsFeatureProvider) {
- mActivity = activity;
- mMetricsFeatureProvider = metricsFeatureProvider;
- }
-
- @Override
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
- // Do nothing.
- }
-
- @Override
- public void onPageScrollStateChanged(int state) {
- // Do nothing
- }
-
- @Override
- public void onPageSelected(int position) {
- switch (position) {
- case INDEX_SUMMARY_FRAGMENT:
- mMetricsFeatureProvider.action(
- mActivity, MetricsProto.MetricsEvent.ACTION_SELECT_SUMMARY);
- mActivity.setDisplaySearchMenu(true);
- break;
- case INDEX_SUPPORT_FRAGMENT:
- mMetricsFeatureProvider.action(
- mActivity, MetricsProto.MetricsEvent.ACTION_SELECT_SUPPORT_FRAGMENT);
- mActivity.setDisplaySearchMenu(false);
- break;
- }
- }
- }
-}
diff --git a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
index e31d968..7487b28 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
@@ -225,7 +225,7 @@
args.putString(ManageApplications.EXTRA_VOLUME_NAME, mVolume.getDescription());
args.putInt(ManageApplications.EXTRA_STORAGE_TYPE, ManageApplications.STORAGE_TYPE_MUSIC);
return Utils.onBuildStartFragmentIntent(mContext,
- ManageApplications.class.getName(), args, null, R.string.audio_storage_title, null,
+ ManageApplications.class.getName(), args, null, R.string.storage_music_audio, null,
false, mMetricsFeatureProvider.getMetricsCategory(mFragment));
}
diff --git a/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java b/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java
index 826ec09..fc96340 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java
@@ -71,9 +71,11 @@
mHistPref = (BatteryHistoryPreference) findPreference(KEY_BATTERY_GRAPH);
mUsageListGroup = (PreferenceGroup) findPreference(KEY_BATTERY_USAGE_LIST);
- mPowerUsageFeatureProvider = FeatureFactory.getFactory(getContext())
- .getPowerUsageFeatureProvider(getContext());
- mPackageManager = getContext().getPackageManager();
+
+ final Context context = getContext();
+ mPowerUsageFeatureProvider = FeatureFactory.getFactory(context)
+ .getPowerUsageFeatureProvider(context);
+ mPackageManager = context.getPackageManager();
}
@Override
@@ -137,9 +139,9 @@
return UsageType.USER;
} else if (drainType == DrainType.CELL) {
return UsageType.CELL;
- } else if (uid == Process.SYSTEM_UID || uid == Process.ROOT_UID) {
+ } else if (mPowerUsageFeatureProvider.isTypeSystem(sipper)) {
return UsageType.SYSTEM;
- } else if (mPowerUsageFeatureProvider.isTypeService(sipper.mPackages)) {
+ } else if (mPowerUsageFeatureProvider.isTypeService(sipper)) {
return UsageType.SERVICE;
} else {
return UsageType.APP;
diff --git a/src/com/android/settings/fuelgauge/PowerUsageFeatureProvider.java b/src/com/android/settings/fuelgauge/PowerUsageFeatureProvider.java
index 3dab38e..7cb6c00 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageFeatureProvider.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageFeatureProvider.java
@@ -17,38 +17,44 @@
package com.android.settings.fuelgauge;
import android.content.Intent;
+import com.android.internal.os.BatterySipper;
/**
* Feature Provider used in power usage
*/
public interface PowerUsageFeatureProvider {
- /**
- * Check whether location setting is enabled
- */
- boolean isLocationSettingEnabled(String[] packages);
+ /**
+ * Check whether location setting is enabled
+ */
+ boolean isLocationSettingEnabled(String[] packages);
- /**
- * Check whether additional battery info feature is enabled.
- */
- boolean isAdditionalBatteryInfoEnabled();
+ /**
+ * Check whether additional battery info feature is enabled.
+ */
+ boolean isAdditionalBatteryInfoEnabled();
- /**
- * Gets an {@link Intent} to show additional battery info.
- */
- Intent getAdditionalBatteryInfoIntent();
+ /**
+ * Gets an {@link Intent} to show additional battery info.
+ */
+ Intent getAdditionalBatteryInfoIntent();
- /**
- * Check whether advanced ui is enabled
- */
- boolean isAdvancedUiEnabled();
+ /**
+ * Check whether advanced ui is enabled
+ */
+ boolean isAdvancedUiEnabled();
- /**
- * Check whether it is type service
- */
- boolean isTypeService(String[] packages);
+ /**
+ * Check whether it is type service
+ */
+ boolean isTypeService(BatterySipper sipper);
- /**
- * Check whether the toggle for power accounting is enabled
- */
- boolean isPowerAccountingToggleEnabled();
+ /**
+ * Check whether it is type system
+ */
+ boolean isTypeSystem(BatterySipper sipper);
+
+ /**
+ * Check whether the toggle for power accounting is enabled
+ */
+ boolean isPowerAccountingToggleEnabled();
}
diff --git a/src/com/android/settings/fuelgauge/PowerUsageFeatureProviderImpl.java b/src/com/android/settings/fuelgauge/PowerUsageFeatureProviderImpl.java
index 7f843e2..011f417 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageFeatureProviderImpl.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageFeatureProviderImpl.java
@@ -16,9 +16,40 @@
package com.android.settings.fuelgauge;
+import android.content.Context;
import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.os.Process;
+import com.android.internal.os.BatterySipper;
+import com.android.internal.util.ArrayUtils;
public class PowerUsageFeatureProviderImpl implements PowerUsageFeatureProvider {
+
+ private static final String PACKAGE_CALENDAR_PROVIDER = "com.android.providers.calendar";
+
+ protected PackageManager mPackageManager;
+
+ public PowerUsageFeatureProviderImpl(Context context) {
+ mPackageManager = context.getPackageManager();
+ }
+
+ @Override
+ public boolean isTypeService(BatterySipper sipper) {
+ return false;
+ }
+
+ @Override
+ public boolean isTypeSystem(BatterySipper sipper) {
+ final int uid = sipper.uidObj == null ? -1 : sipper.getUid();
+ sipper.mPackages = mPackageManager.getPackagesForUid(uid);
+ // Classify all the sippers to type system if the range of uid is 0...FIRST_APPLICATION_UID
+ if (uid >= Process.ROOT_UID && uid < Process.FIRST_APPLICATION_UID) {
+ return true;
+ } else {
+ return ArrayUtils.contains(sipper.mPackages, PACKAGE_CALENDAR_PROVIDER);
+ }
+ }
+
@Override
public boolean isLocationSettingEnabled(String[] packages) {
return false;
@@ -40,11 +71,6 @@
}
@Override
- public boolean isTypeService(String[] packages) {
- return false;
- }
-
- @Override
public boolean isPowerAccountingToggleEnabled() {
return false;
}
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index 5f0e6e0..18ba1aa 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -99,16 +99,17 @@
@VisibleForTesting
boolean mShowAllApps = false;
-
+ @VisibleForTesting
Preference mScreenUsagePref;
@VisibleForTesting
Preference mScreenConsumptionPref;
@VisibleForTesting
Preference mCellularNetworkPref;
+ @VisibleForTesting
+ PowerUsageFeatureProvider mPowerFeatureProvider;
private LayoutPreference mBatteryLayoutPref;
private PreferenceGroup mAppListGroup;
-
private int mStatsType = BatteryStats.STATS_SINCE_CHARGED;
@Override
@@ -121,6 +122,8 @@
mScreenUsagePref = findPreference(KEY_SCREEN_USAGE);
mScreenConsumptionPref = findPreference(KEY_SCREEN_CONSUMPTION);
mCellularNetworkPref = findPreference(KEY_CELLULAR_NETWORK);
+
+ initFeatureProvider();
}
@Override
@@ -193,14 +196,11 @@
menu.add(Menu.NONE, MENU_HIGH_POWER_APPS, Menu.NONE, R.string.high_power_apps);
- PowerUsageFeatureProvider powerUsageFeatureProvider =
- FeatureFactory.getFactory(getContext()).getPowerUsageFeatureProvider(getContext());
- if (powerUsageFeatureProvider != null &&
- powerUsageFeatureProvider.isAdditionalBatteryInfoEnabled()) {
+ if (mPowerFeatureProvider.isAdditionalBatteryInfoEnabled()) {
menu.add(Menu.NONE, MENU_ADDITIONAL_BATTERY_INFO,
Menu.NONE, R.string.additional_battery_info);
}
- if (powerUsageFeatureProvider.isPowerAccountingToggleEnabled()) {
+ if (mPowerFeatureProvider.isPowerAccountingToggleEnabled()) {
menu.add(Menu.NONE, MENU_TOGGLE_APPS, Menu.NONE,
mShowAllApps ? R.string.hide_extra_apps : R.string.show_all_apps);
}
@@ -579,12 +579,12 @@
@VisibleForTesting
boolean shouldHideSipper(BatterySipper sipper) {
final DrainType drainType = sipper.drainType;
- final int uid = sipper.getUid();
return drainType == DrainType.IDLE || drainType == DrainType.CELL
- || drainType == DrainType.SCREEN || uid == Process.ROOT_UID
- || uid == Process.SYSTEM_UID
- || (sipper.totalPowerMah * SECONDS_IN_HOUR) < MIN_POWER_THRESHOLD_MILLI_AMP;
+ || drainType == DrainType.SCREEN
+ || (sipper.totalPowerMah * SECONDS_IN_HOUR) < MIN_POWER_THRESHOLD_MILLI_AMP
+ || mPowerFeatureProvider.isTypeService(sipper)
+ || mPowerFeatureProvider.isTypeSystem(sipper);
}
@VisibleForTesting
@@ -620,6 +620,13 @@
mBatteryLayoutPref = layoutPreference;
}
+ @VisibleForTesting
+ void initFeatureProvider() {
+ final Context context = getContext();
+ mPowerFeatureProvider = FeatureFactory.getFactory(context)
+ .getPowerUsageFeatureProvider(context);
+ }
+
private static List<BatterySipper> getFakeStats() {
ArrayList<BatterySipper> stats = new ArrayList<>();
float use = 5;
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index d0f6f2e..4c310e6 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -184,6 +184,7 @@
channelPref.setKey(channel.getId());
channelPref.setTitle(channel.getName());
channelPref.setChecked(channel.getImportance() != IMPORTANCE_NONE);
+ channelPref.setMultiLine(true);
if (channel.isDeleted()) {
channelPref.setTitle(
diff --git a/src/com/android/settings/notification/OtherSoundSettings.java b/src/com/android/settings/notification/OtherSoundSettings.java
deleted file mode 100644
index 5c409d3..0000000
--- a/src/com/android/settings/notification/OtherSoundSettings.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2014 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.notification;
-
-import android.content.Context;
-import android.provider.SearchIndexableResource;
-
-import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.R;
-import com.android.settings.core.PreferenceController;
-import com.android.settings.core.lifecycle.Lifecycle;
-import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.search.BaseSearchIndexProvider;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/* This class has been deprecated Modifications to Other Sounds settings should be made in
- {@link SoundSettings } instead. */
-@Deprecated
-public class OtherSoundSettings extends DashboardFragment {
- private static final String TAG = "OtherSoundSettings";
-
- @Override
- public int getMetricsCategory() {
- return MetricsEvent.NOTIFICATION_OTHER_SOUND;
- }
-
- @Override
- protected int getHelpResource() {
- return R.string.help_uri_other_sounds;
- }
-
- @Override
- protected String getLogTag() {
- return TAG;
- }
-
- @Override
- protected int getPreferenceScreenResId() {
- return R.xml.other_sound_settings;
- }
-
- @Override
- protected List<PreferenceController> getPreferenceControllers(Context context) {
- final List<PreferenceController> controllers = new ArrayList<>();
- Lifecycle lifecycle = getLifecycle();
- controllers.add(new DialPadTonePreferenceController(context, this, lifecycle));
- controllers.add(new ScreenLockSoundPreferenceController(context, this, lifecycle));
- controllers.add(new ChargingSoundPreferenceController(context, this, lifecycle));
- controllers.add(new DockingSoundPreferenceController(context, this, lifecycle));
- controllers.add(new TouchSoundPreferenceController(context, this, lifecycle));
- controllers.add(new VibrateOnTouchPreferenceController(context, this, lifecycle));
- controllers.add(new DockAudioMediaPreferenceController(context, this, lifecycle));
- controllers.add(new BootSoundPreferenceController(context));
- controllers.add(new EmergencyTonePreferenceController(context, this, lifecycle));
- return controllers;
- }
-
- // === Indexing ===
-
- public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider() {
-
- public List<SearchIndexableResource> getXmlResourcesToIndex(
- Context context, boolean enabled) {
- final SearchIndexableResource sir = new SearchIndexableResource(context);
- sir.xmlResId = R.xml.other_sound_settings;
- return Arrays.asList(sir);
- }
-
- public List<String> getNonIndexableKeys(Context context) {
- final ArrayList<String> rt = new ArrayList<String>();
- new DialPadTonePreferenceController(context, null /* SettingsPreferenceFragment */,
- null /* Lifecycle */).updateNonIndexableKeys(rt);
- new ScreenLockSoundPreferenceController(context, null /* SettingsPreferenceFragment */,
- null /* Lifecycle */).updateNonIndexableKeys(rt);
- new ChargingSoundPreferenceController(context, null /* SettingsPreferenceFragment */,
- null /* Lifecycle */).updateNonIndexableKeys(rt);
- new DockingSoundPreferenceController(context, null /* SettingsPreferenceFragment */,
- null /* Lifecycle */).updateNonIndexableKeys(rt);
- new TouchSoundPreferenceController(context, null /* SettingsPreferenceFragment */,
- null /* Lifecycle */).updateNonIndexableKeys(rt);
- new VibrateOnTouchPreferenceController(context, null /* SettingsPreferenceFragment */,
- null /* Lifecycle */).updateNonIndexableKeys(rt);
- new DockAudioMediaPreferenceController(context, null /* SettingsPreferenceFragment */,
- null /* Lifecycle */).updateNonIndexableKeys(rt);
- new BootSoundPreferenceController(context).updateNonIndexableKeys(rt);
- new EmergencyTonePreferenceController(context, null /* SettingsPreferenceFragment */,
- null /* Lifecycle */).updateNonIndexableKeys(rt);
- return rt;
- }
- };
-}
diff --git a/src/com/android/settings/notification/SoundSettings.java b/src/com/android/settings/notification/SoundSettings.java
index c7b0384..a5a1bfd 100644
--- a/src/com/android/settings/notification/SoundSettings.java
+++ b/src/com/android/settings/notification/SoundSettings.java
@@ -100,17 +100,13 @@
@Override
protected int getPreferenceScreenResId() {
- return mDashboardFeatureProvider.isEnabled()
- ? R.xml.ia_sound_settings : R.xml.sound_settings;
+ return R.xml.ia_sound_settings;
}
@Override
protected List<PreferenceController> getPreferenceControllers(Context context) {
final List<PreferenceController> controllers = new ArrayList<>();
Lifecycle lifecycle = getLifecycle();
- if (!mDashboardFeatureProvider.isEnabled()) {
- controllers.add(new CastPreferenceController(context));
- }
controllers.add(new ZenModePreferenceController(context));
controllers.add(new EmergencyBroadcastPreferenceController(context));
controllers.add(new VibrateWhenRingPreferenceController(context));
@@ -132,17 +128,15 @@
controllers.add(mWorkSoundController);
// === Other Sound Settings ===
- if (mDashboardFeatureProvider.isEnabled()) {
- controllers.add(new DialPadTonePreferenceController(context, this, lifecycle));
- controllers.add(new ScreenLockSoundPreferenceController(context, this, lifecycle));
- controllers.add(new ChargingSoundPreferenceController(context, this, lifecycle));
- controllers.add(new DockingSoundPreferenceController(context, this, lifecycle));
- controllers.add(new TouchSoundPreferenceController(context, this, lifecycle));
- controllers.add(new VibrateOnTouchPreferenceController(context, this, lifecycle));
- controllers.add(new DockAudioMediaPreferenceController(context, this, lifecycle));
- controllers.add(new BootSoundPreferenceController(context));
- controllers.add(new EmergencyTonePreferenceController(context, this, lifecycle));
- }
+ controllers.add(new DialPadTonePreferenceController(context, this, lifecycle));
+ controllers.add(new ScreenLockSoundPreferenceController(context, this, lifecycle));
+ controllers.add(new ChargingSoundPreferenceController(context, this, lifecycle));
+ controllers.add(new DockingSoundPreferenceController(context, this, lifecycle));
+ controllers.add(new TouchSoundPreferenceController(context, this, lifecycle));
+ controllers.add(new VibrateOnTouchPreferenceController(context, this, lifecycle));
+ controllers.add(new DockAudioMediaPreferenceController(context, this, lifecycle));
+ controllers.add(new BootSoundPreferenceController(context));
+ controllers.add(new EmergencyTonePreferenceController(context, this, lifecycle));
return controllers;
}
@@ -192,8 +186,6 @@
}
}
- ;
-
// === Callbacks ===
@@ -222,7 +214,7 @@
public List<SearchIndexableResource> getXmlResourcesToIndex(
Context context, boolean enabled) {
final SearchIndexableResource sir = new SearchIndexableResource(context);
- sir.xmlResId = R.xml.sound_settings;
+ sir.xmlResId = R.xml.ia_sound_settings;
return Arrays.asList(sir);
}
@@ -237,36 +229,31 @@
new PhoneRingtonePreferenceController(context).updateNonIndexableKeys(rt);
new VibrateWhenRingPreferenceController(context).updateNonIndexableKeys(rt);
new EmergencyBroadcastPreferenceController(context).updateNonIndexableKeys(rt);
- if (FeatureFactory.getFactory(context).getDashboardFeatureProvider(context)
- .isEnabled()) {
- new DialPadTonePreferenceController(context,
- null /* SettingsPreferenceFragment */,
- null /* Lifecycle */).updateNonIndexableKeys(rt);
- new ScreenLockSoundPreferenceController(context,
- null /* SettingsPreferenceFragment */,
- null /* Lifecycle */).updateNonIndexableKeys(rt);
- new ChargingSoundPreferenceController(context,
- null /* SettingsPreferenceFragment */,
- null /* Lifecycle */).updateNonIndexableKeys(rt);
- new DockingSoundPreferenceController(context,
- null /* SettingsPreferenceFragment */,
- null /* Lifecycle */).updateNonIndexableKeys(rt);
- new TouchSoundPreferenceController(context, null /*
+ new DialPadTonePreferenceController(context,
+ null /* SettingsPreferenceFragment */,
+ null /* Lifecycle */).updateNonIndexableKeys(rt);
+ new ScreenLockSoundPreferenceController(context,
+ null /* SettingsPreferenceFragment */,
+ null /* Lifecycle */).updateNonIndexableKeys(rt);
+ new ChargingSoundPreferenceController(context,
+ null /* SettingsPreferenceFragment */,
+ null /* Lifecycle */).updateNonIndexableKeys(rt);
+ new DockingSoundPreferenceController(context,
+ null /* SettingsPreferenceFragment */,
+ null /* Lifecycle */).updateNonIndexableKeys(rt);
+ new TouchSoundPreferenceController(context, null /*
SettingsPreferenceFragment */,
- null /* Lifecycle */).updateNonIndexableKeys(rt);
- new VibrateOnTouchPreferenceController(context,
- null /* SettingsPreferenceFragment */,
- null /* Lifecycle */).updateNonIndexableKeys(rt);
- new DockAudioMediaPreferenceController(context,
- null /* SettingsPreferenceFragment */,
- null /* Lifecycle */).updateNonIndexableKeys(rt);
- new BootSoundPreferenceController(context).updateNonIndexableKeys(rt);
- new EmergencyTonePreferenceController(context,
- null /* SettingsPreferenceFragment */,
- null /* Lifecycle */).updateNonIndexableKeys(rt);
- } else {
- new CastPreferenceController(context).updateNonIndexableKeys(rt);
- }
+ null /* Lifecycle */).updateNonIndexableKeys(rt);
+ new VibrateOnTouchPreferenceController(context,
+ null /* SettingsPreferenceFragment */,
+ null /* Lifecycle */).updateNonIndexableKeys(rt);
+ new DockAudioMediaPreferenceController(context,
+ null /* SettingsPreferenceFragment */,
+ null /* Lifecycle */).updateNonIndexableKeys(rt);
+ new BootSoundPreferenceController(context).updateNonIndexableKeys(rt);
+ new EmergencyTonePreferenceController(context,
+ null /* SettingsPreferenceFragment */,
+ null /* Lifecycle */).updateNonIndexableKeys(rt);
return rt;
}
diff --git a/src/com/android/settings/overlay/FeatureFactoryImpl.java b/src/com/android/settings/overlay/FeatureFactoryImpl.java
index 377e6bb..e72ee03 100644
--- a/src/com/android/settings/overlay/FeatureFactoryImpl.java
+++ b/src/com/android/settings/overlay/FeatureFactoryImpl.java
@@ -80,7 +80,7 @@
@Override
public PowerUsageFeatureProvider getPowerUsageFeatureProvider(Context context) {
if (mPowerUsageFeatureProvider == null) {
- mPowerUsageFeatureProvider = new PowerUsageFeatureProviderImpl();
+ mPowerUsageFeatureProvider = new PowerUsageFeatureProviderImpl(context);
}
return mPowerUsageFeatureProvider;
}
diff --git a/src/com/android/settings/search/Ranking.java b/src/com/android/settings/search/Ranking.java
index fc1b8d9..9b03a57 100644
--- a/src/com/android/settings/search/Ranking.java
+++ b/src/com/android/settings/search/Ranking.java
@@ -46,7 +46,6 @@
import com.android.settings.location.LocationSettings;
import com.android.settings.location.ScanningSettings;
import com.android.settings.notification.ConfigureNotificationSettings;
-import com.android.settings.notification.OtherSoundSettings;
import com.android.settings.notification.SoundSettings;
import com.android.settings.notification.ZenModeAutomationSettings;
import com.android.settings.notification.ZenModePrioritySettings;
@@ -133,7 +132,6 @@
// Notifications
sRankMap.put(ConfigureNotificationSettings.class.getName(), RANK_NOTIFICATIONS);
- sRankMap.put(OtherSoundSettings.class.getName(), RANK_NOTIFICATIONS);
sRankMap.put(ZenModeSettings.class.getName(), RANK_NOTIFICATIONS);
sRankMap.put(ZenModePrioritySettings.class.getName(), RANK_NOTIFICATIONS);
sRankMap.put(ZenModeAutomationSettings.class.getName(), RANK_NOTIFICATIONS);
diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java
index 1968c7a..32808fb 100644
--- a/src/com/android/settings/search/SearchIndexableResources.java
+++ b/src/com/android/settings/search/SearchIndexableResources.java
@@ -69,7 +69,6 @@
import com.android.settings.network.NetworkDashboardFragment;
import com.android.settings.nfc.PaymentSettings;
import com.android.settings.notification.ConfigureNotificationSettings;
-import com.android.settings.notification.OtherSoundSettings;
import com.android.settings.notification.SoundSettings;
import com.android.settings.notification.ZenModePrioritySettings;
import com.android.settings.notification.ZenModeSettings;
@@ -122,7 +121,6 @@
addIndex(AppAndNotificationDashboardFragment.class, NO_DATA_RES_ID,
R.drawable.ic_settings_applications);
addIndex(SoundSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_sound);
- addIndex(OtherSoundSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_sound);
addIndex(ZenModeSettings.class,
R.xml.zen_mode_settings, R.drawable.ic_settings_notifications);
addIndex(ZenModePrioritySettings.class,
diff --git a/src/com/android/settings/widget/MasterSwitchPreference.java b/src/com/android/settings/widget/MasterSwitchPreference.java
index 94c429b..ba3458a 100644
--- a/src/com/android/settings/widget/MasterSwitchPreference.java
+++ b/src/com/android/settings/widget/MasterSwitchPreference.java
@@ -22,6 +22,7 @@
import android.util.AttributeSet;
import android.widget.CompoundButton;
import android.widget.Switch;
+import android.widget.TextView;
import com.android.settings.R;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
@@ -34,6 +35,7 @@
private Switch mSwitch;
private boolean mChecked;
+ private boolean mMultiLine;
public MasterSwitchPreference(Context context, AttributeSet attrs,
int defStyleAttr, int defStyleRes) {
@@ -74,6 +76,12 @@
}
});
}
+ if (mMultiLine) {
+ TextView textView = (TextView)holder.findViewById(android.R.id.title);
+ if (textView != null) {
+ textView.setSingleLine(false);
+ }
+ }
}
public boolean isChecked() {
@@ -97,6 +105,14 @@
}
}
+ public boolean isMultiLine() {
+ return mMultiLine;
+ }
+
+ public void setMultiLine(boolean multiLine) {
+ mMultiLine = multiLine;
+ }
+
/**
* If admin is not null, disables the switch.
* Otherwise, keep it enabled.
diff --git a/tests/app/src/com/android/settings/dashboard/TabSelectionOnLaunchTest.java b/tests/app/src/com/android/settings/dashboard/TabSelectionOnLaunchTest.java
deleted file mode 100644
index 24c1ead..0000000
--- a/tests/app/src/com/android/settings/dashboard/TabSelectionOnLaunchTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * 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.
- */
-package com.android.settings.dashboard;
-
-import android.content.Intent;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.filters.SmallTest;
-import android.support.test.rule.ActivityTestRule;
-import android.support.test.runner.AndroidJUnit4;
-import com.android.settings.Settings;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static android.support.test.espresso.Espresso.onView;
-import static android.support.test.espresso.assertion.ViewAssertions.matches;
-import static android.support.test.espresso.matcher.ViewMatchers.isSelected;
-import static android.support.test.espresso.matcher.ViewMatchers.withText;
-import static org.hamcrest.core.IsNot.not;
-
-@RunWith(AndroidJUnit4.class)
-@SmallTest
-public class TabSelectionOnLaunchTest {
- @Rule
- public ActivityTestRule<Settings> mActivityRule =
- new ActivityTestRule<>(Settings.class, true, false);
-
- private final int FLAG_RESTART = Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_NEW_TASK;
- private final String ARG_SELECT_SUPPORT_TAB = "SUPPORT";
- private final String ARG_SELECT_FAKE_TAB = "NOT_SUPPORT";
-
- @Test
- /* cold start for settings app with correct flags and extra always selects support tab */
- public void test_ColdStartWithCorrectArgsCorrectFlags_SupportSelected() {
- launchSettingsWithFlags(ARG_SELECT_SUPPORT_TAB, FLAG_RESTART);
- verifySupportSelected();
- }
-
- @Test
- /* cold start with correct flags and wrong extra defaults to all tab */
- public void test_ColdStartWithWrongExtra_DoesNotSelectSupport() {
- launchSettingsWithFlags(ARG_SELECT_FAKE_TAB, FLAG_RESTART);
- verifySupportNotSelected();
- }
-
- @Test
- /* warm start from elsewhere in settings with wrong flags does not select support */
- public void test_WarmStartSummarySelectedCorrectExtraWrongFlags_DoesNotSelectSupport() {
- InstrumentationRegistry.getContext().
- startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS));
- launchSettingsNoFlags(ARG_SELECT_SUPPORT_TAB);
- verifySupportNotSelected();
- }
-
- @Test
- /* warm start from elsewhere in settings with with wrong flags & extra does not select support*/
- public void test_WarmStartSummarySelectedWrongExtraWrongFlags_DoesNotSelectSupport() {
- InstrumentationRegistry.getContext().
- startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS));
- launchSettingsNoFlags(ARG_SELECT_FAKE_TAB);
- verifySupportNotSelected();
- }
-
- @Test
- /* settings does not crash on null string */
- public void test_DoesNotCrashOnNullExtra_DoesNotSelectSupport() {
- launchSettingsWithFlags(null, FLAG_RESTART);
- verifySupportNotSelected();
- }
-
- private void verifySupportNotSelected() {
- onView(withText(mActivityRule.getActivity().getApplicationContext().
- getString(com.android.settings.R.string.page_tab_title_support))).
- check(matches(not(isSelected())));
- }
-
- private void verifySupportSelected() {
- onView(withText(mActivityRule.getActivity().getApplicationContext().
- getString(com.android.settings.R.string.page_tab_title_support))).
- check(matches(isSelected()));
- }
-
- private void launchSettingsWithFlags(String extra, int flags) {
- Intent intent = new Intent(android.provider.Settings.ACTION_SETTINGS);
- intent.setFlags(flags);
- intent.putExtra(DashboardContainerFragment.EXTRA_SELECT_SETTINGS_TAB, extra);
- mActivityRule.launchActivity(intent);
- }
-
- private void launchSettingsNoFlags(String extra) {
- Intent intent = new Intent(android.provider.Settings.ACTION_SETTINGS);
- intent.putExtra(DashboardContainerFragment.EXTRA_SELECT_SETTINGS_TAB, extra);
- mActivityRule.launchActivity(intent);
- }
-}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/applications/AppHeaderControllerTest.java b/tests/robotests/src/com/android/settings/applications/AppHeaderControllerTest.java
index 458af5b..3ee33aa 100644
--- a/tests/robotests/src/com/android/settings/applications/AppHeaderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppHeaderControllerTest.java
@@ -52,6 +52,7 @@
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.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -234,6 +235,25 @@
}
@Test
+ public void bindButton_hasAppInfo_shouldHaveContentDescription() {
+ final View appLinks = mLayoutInflater
+ .inflate(R.layout.app_details, null /* root */);
+ when(mFragment.getActivity()).thenReturn(mock(Activity.class));
+ when(mContext.getString(eq(R.string.application_info_label))).thenReturn("App Info");
+
+ mController = new AppHeaderController(mContext, mFragment, appLinks);
+ mController.setPackageName("123")
+ .setUid(UserHandle.USER_SYSTEM)
+ .setButtonActions(
+ AppHeaderController.ActionType.ACTION_APP_INFO,
+ AppHeaderController.ActionType.ACTION_NOTIF_PREFERENCE);
+ mController.done();
+
+ assertThat(appLinks.findViewById(R.id.left_button).getContentDescription())
+ .isEqualTo("App Info");
+ }
+
+ @Test
public void bindButton_hasAppNotifIntent_shouldShowButton() {
final View appLinks = mLayoutInflater
.inflate(R.layout.app_details, null /* root */);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java
index e47aac9..ed7e48b 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java
@@ -1,3 +1,18 @@
+/*
+ * 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.fuelgauge;
import android.content.pm.PackageManager;
@@ -70,13 +85,10 @@
@Test
public void testExtractUsageType_TypeSystem_ReturnSystem() {
mBatterySipper.drainType = DrainType.APP;
- final int uids[] = {Process.SYSTEM_UID, Process.ROOT_UID};
+ when(mPowerUsageFeatureProvider.isTypeSystem(any())).thenReturn(true);
- for (int uid : uids) {
- when(mBatterySipper.getUid()).thenReturn(uid);
- assertThat(mPowerUsageAdvanced.extractUsageType(mBatterySipper))
- .isEqualTo(UsageType.SYSTEM);
- }
+ assertThat(mPowerUsageAdvanced.extractUsageType(mBatterySipper))
+ .isEqualTo(UsageType.SYSTEM);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageFeatureProviderImplTest.java
new file mode 100644
index 0000000..bfb4bc6
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageFeatureProviderImplTest.java
@@ -0,0 +1,106 @@
+/*
+ * 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.fuelgauge;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.os.Process;
+import com.android.internal.os.BatterySipper;
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+
+import static org.mockito.Mockito.when;
+import static com.google.common.truth.Truth.assertThat;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class PowerUsageFeatureProviderImplTest {
+ private static final int UID_CALENDAR = 1234;
+ private static final int UID_OTHER = Process.FIRST_APPLICATION_UID + 2;
+ private static final String[] PACKAGES_CALENDAR = {"com.android.providers.calendar"};
+ @Mock
+ private Context mContext;
+ @Mock
+ private BatterySipper mBatterySipper;
+ @Mock
+ private PackageManager mPackageManager;
+ private PowerUsageFeatureProviderImpl mPowerFeatureProvider;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ mPowerFeatureProvider = new PowerUsageFeatureProviderImpl(mContext);
+ when(mPackageManager.getPackagesForUid(UID_CALENDAR)).thenReturn(PACKAGES_CALENDAR);
+ mPowerFeatureProvider.mPackageManager = mPackageManager;
+ mBatterySipper.uidObj = new FakeUid(UID_OTHER);
+ }
+
+ @Test
+ public void testIsTypeSystem_UidRoot_ReturnTrue() {
+ mBatterySipper.drainType = BatterySipper.DrainType.APP;
+ when(mBatterySipper.getUid()).thenReturn(Process.ROOT_UID);
+
+ assertThat(mPowerFeatureProvider.isTypeSystem(mBatterySipper)).isTrue();
+ }
+
+ @Test
+ public void testIsTypeSystem_UidSystem_ReturnTrue() {
+ mBatterySipper.drainType = BatterySipper.DrainType.APP;
+ when(mBatterySipper.getUid()).thenReturn(Process.SYSTEM_UID);
+
+ assertThat(mPowerFeatureProvider.isTypeSystem(mBatterySipper)).isTrue();
+ }
+
+ @Test
+ public void testIsTypeSystem_UidMedia_ReturnTrue() {
+ mBatterySipper.drainType = BatterySipper.DrainType.APP;
+ when(mBatterySipper.getUid()).thenReturn(Process.MEDIA_UID);
+
+ assertThat(mPowerFeatureProvider.isTypeSystem(mBatterySipper)).isTrue();
+ }
+
+ @Test
+ public void testIsTypeSystem_AppCalendar_ReturnTrue() {
+ mBatterySipper.drainType = BatterySipper.DrainType.APP;
+ when(mBatterySipper.getUid()).thenReturn(UID_CALENDAR);
+
+ assertThat(mPowerFeatureProvider.isTypeSystem(mBatterySipper)).isTrue();
+ }
+
+ @Test
+ public void testIsTypeSystem_UidOther_ReturnFalse() {
+ mBatterySipper.drainType = BatterySipper.DrainType.APP;
+ when(mBatterySipper.getUid()).thenReturn(UID_OTHER);
+
+ assertThat(mPowerFeatureProvider.isTypeSystem(mBatterySipper)).isFalse();
+ }
+
+ @Test
+ public void testIsTypeSystem_UidObjNull_ReturnFalse() {
+ mBatterySipper.drainType = BatterySipper.DrainType.APP;
+ mBatterySipper.uidObj = null;
+
+ assertThat(mPowerFeatureProvider.isTypeSystem(mBatterySipper)).isFalse();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
index 0755a36..9513507 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
@@ -17,6 +17,7 @@
import android.content.Context;
import android.content.Intent;
+import android.os.PowerManager;
import android.os.Process;
import android.support.v7.preference.Preference;
import android.text.TextUtils;
@@ -54,6 +55,7 @@
import static com.android.settings.fuelgauge.PowerUsageSummary.MENU_TOGGLE_APPS;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doReturn;
@@ -124,12 +126,13 @@
private Preference mCellularNetworkPref;
@Mock
private BatteryStatsHelper mBatteryHelper;
+ @Mock
+ private PowerManager mPowerManager;
+ private List<BatterySipper> mUsageList;
private Context mRealContext;
private TestFragment mFragment;
private FakeFeatureFactory mFeatureFactory;
- private PowerUsageSummary mPowerUsageSummary;
- private List<BatterySipper> mUsageList;
@Before
public void setUp() {
@@ -138,8 +141,10 @@
mRealContext = RuntimeEnvironment.application;
FakeFeatureFactory.setupForTest(mContext);
mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ when(mContext.getSystemService(Context.POWER_SERVICE)).thenReturn(mPowerManager);
- mFragment = new TestFragment(mContext);
+ mFragment = spy(new TestFragment(mContext));
+ mFragment.initFeatureProvider();
when(mAdditionalBatteryInfoMenu.getItemId())
.thenReturn(MENU_ADDITIONAL_BATTERY_INFO);
@@ -148,9 +153,6 @@
.thenReturn(ADDITIONAL_BATTERY_INFO_INTENT);
when(mBatteryHelper.getTotalPower()).thenReturn(TOTAL_POWER);
- mPowerUsageSummary = spy(new PowerUsageSummary());
-
- when(mPowerUsageSummary.getContext()).thenReturn(mRealContext);
when(mNormalBatterySipper.getPackages()).thenReturn(PACKAGE_NAMES);
when(mNormalBatterySipper.getUid()).thenReturn(UID);
mNormalBatterySipper.totalPowerMah = POWER_MAH;
@@ -164,7 +166,7 @@
when(mBatteryLayoutPref.findViewById(R.id.time)).thenReturn(mTimeText);
when(mBatteryLayoutPref.findViewById(R.id.battery_header_icon))
.thenReturn(mBatteryMeterView);
- mPowerUsageSummary.setBatteryLayoutPreference(mBatteryLayoutPref);
+ mFragment.setBatteryLayoutPreference(mBatteryLayoutPref);
mScreenBatterySipper.drainType = BatterySipper.DrainType.SCREEN;
mScreenBatterySipper.totalPowerMah = BATTERY_SCREEN_USAGE;
@@ -179,11 +181,11 @@
mUsageList.add(mScreenBatterySipper);
mUsageList.add(mCellBatterySipper);
- mPowerUsageSummary.mStatsHelper = mBatteryHelper;
+ mFragment.mStatsHelper = mBatteryHelper;
when(mBatteryHelper.getUsageList()).thenReturn(mUsageList);
- mPowerUsageSummary.mScreenUsagePref = mScreenUsagePref;
- mPowerUsageSummary.mScreenConsumptionPref = mScreenConsumptionPref;
- mPowerUsageSummary.mCellularNetworkPref = mCellularNetworkPref;
+ mFragment.mScreenUsagePref = mScreenUsagePref;
+ mFragment.mScreenConsumptionPref = mScreenConsumptionPref;
+ mFragment.mCellularNetworkPref = mCellularNetworkPref;
}
@Test
@@ -235,7 +237,7 @@
mNormalBatterySipper.uidObj = null;
mNormalBatterySipper.drainType = BatterySipper.DrainType.APP;
- final String key = mPowerUsageSummary.extractKeyFromSipper(mNormalBatterySipper);
+ final String key = mFragment.extractKeyFromSipper(mNormalBatterySipper);
assertThat(key).isEqualTo(TextUtils.concat(mNormalBatterySipper.getPackages()).toString());
}
@@ -244,7 +246,7 @@
mNormalBatterySipper.uidObj = null;
mNormalBatterySipper.drainType = BatterySipper.DrainType.BLUETOOTH;
- final String key = mPowerUsageSummary.extractKeyFromSipper(mNormalBatterySipper);
+ final String key = mFragment.extractKeyFromSipper(mNormalBatterySipper);
assertThat(key).isEqualTo(mNormalBatterySipper.drainType.toString());
}
@@ -253,7 +255,7 @@
mNormalBatterySipper.uidObj = new BatteryStatsImpl.Uid(new BatteryStatsImpl(), UID);
mNormalBatterySipper.drainType = BatterySipper.DrainType.APP;
- final String key = mPowerUsageSummary.extractKeyFromSipper(mNormalBatterySipper);
+ final String key = mFragment.extractKeyFromSipper(mNormalBatterySipper);
assertThat(key).isEqualTo(Integer.toString(mNormalBatterySipper.getUid()));
}
@@ -263,8 +265,10 @@
sippers.add(mNormalBatterySipper);
sippers.add(mScreenBatterySipper);
sippers.add(mSystemBatterySipper);
+ when(mFeatureFactory.powerUsageFeatureProvider.isTypeSystem(mSystemBatterySipper))
+ .thenReturn(true);
- final double totalUsage = mPowerUsageSummary.removeHiddenBatterySippers(sippers);
+ final double totalUsage = mFragment.removeHiddenBatterySippers(sippers);
assertThat(sippers).containsExactly(mNormalBatterySipper);
assertThat(totalUsage).isWithin(PRECISION).of(BATTERY_SCREEN_USAGE + BATTERY_SYSTEM_USAGE);
}
@@ -272,47 +276,52 @@
@Test
public void testShouldHideSipper_TypeIdle_ReturnTrue() {
mNormalBatterySipper.drainType = BatterySipper.DrainType.IDLE;
- assertThat(mPowerUsageSummary.shouldHideSipper(mNormalBatterySipper)).isTrue();
+ assertThat(mFragment.shouldHideSipper(mNormalBatterySipper)).isTrue();
}
@Test
public void testShouldHideSipper_TypeCell_ReturnTrue() {
mNormalBatterySipper.drainType = BatterySipper.DrainType.CELL;
- assertThat(mPowerUsageSummary.shouldHideSipper(mNormalBatterySipper)).isTrue();
+ assertThat(mFragment.shouldHideSipper(mNormalBatterySipper)).isTrue();
}
@Test
public void testShouldHideSipper_TypeScreen_ReturnTrue() {
mNormalBatterySipper.drainType = BatterySipper.DrainType.SCREEN;
- assertThat(mPowerUsageSummary.shouldHideSipper(mNormalBatterySipper)).isTrue();
+ assertThat(mFragment.shouldHideSipper(mNormalBatterySipper)).isTrue();
}
@Test
- public void testShouldHideSipper_UidRoot_ReturnTrue() {
+ public void testShouldHideSipper_TypeSystem_ReturnTrue() {
mNormalBatterySipper.drainType = BatterySipper.DrainType.APP;
when(mNormalBatterySipper.getUid()).thenReturn(Process.ROOT_UID);
- assertThat(mPowerUsageSummary.shouldHideSipper(mNormalBatterySipper)).isTrue();
- }
-
- @Test
- public void testShouldHideSipper_UidSystem_ReturnTrue() {
- mNormalBatterySipper.drainType = BatterySipper.DrainType.APP;
- when(mNormalBatterySipper.getUid()).thenReturn(Process.SYSTEM_UID);
- assertThat(mPowerUsageSummary.shouldHideSipper(mNormalBatterySipper)).isTrue();
+ when(mFeatureFactory.powerUsageFeatureProvider.isTypeSystem(Matchers.<BatterySipper>any()))
+ .thenReturn(true);
+ assertThat(mFragment.shouldHideSipper(mNormalBatterySipper)).isTrue();
}
@Test
public void testShouldHideSipper_UidNormal_ReturnFalse() {
mNormalBatterySipper.drainType = BatterySipper.DrainType.APP;
when(mNormalBatterySipper.getUid()).thenReturn(UID);
- assertThat(mPowerUsageSummary.shouldHideSipper(mNormalBatterySipper)).isFalse();
+ assertThat(mFragment.shouldHideSipper(mNormalBatterySipper)).isFalse();
+ }
+
+ @Test
+ public void testShouldHideSipper_TypeService_ReturnTrue() {
+ mNormalBatterySipper.drainType = BatterySipper.DrainType.APP;
+ when(mNormalBatterySipper.getUid()).thenReturn(UID);
+ when(mFeatureFactory.powerUsageFeatureProvider.isTypeService(Matchers.<BatterySipper>any()))
+ .thenReturn(true);
+
+ assertThat(mFragment.shouldHideSipper(mNormalBatterySipper)).isTrue();
}
@Test
public void testSetUsageSummary_TimeLessThanOneMinute_DoNotSetSummary() {
final long usageTimeMs = 59 * DateUtils.SECOND_IN_MILLIS;
- mPowerUsageSummary.setUsageSummary(mPreference, "", usageTimeMs);
+ mFragment.setUsageSummary(mPreference, "", usageTimeMs);
verify(mPreference, never()).setSummary(anyString());
}
@@ -320,7 +329,7 @@
public void testSetUsageSummary_TimeMoreThanOneMinute_SetSummary() {
final long usageTimeMs = 2 * DateUtils.MINUTE_IN_MILLIS;
- mPowerUsageSummary.setUsageSummary(mPreference, "", usageTimeMs);
+ mFragment.setUsageSummary(mPreference, "", usageTimeMs);
verify(mPreference).setSummary(anyString());
}
@@ -328,7 +337,7 @@
public void testUpdatePreference_NoEstimatedTime_DoNotShowSummary() {
mBatteryInfo.remainingTimeUs = 0;
mBatteryInfo.remainingLabel = TIME_LEFT;
- mPowerUsageSummary.updateHeaderPreference(mBatteryInfo);
+ mFragment.updateHeaderPreference(mBatteryInfo);
verify(mSummary1).setVisibility(View.INVISIBLE);
verify(mSummary2).setVisibility(View.INVISIBLE);
@@ -338,7 +347,7 @@
public void testUpdatePreference_HasEstimatedTime_ShowSummary() {
mBatteryInfo.remainingTimeUs = REMAINING_TIME_US;
mBatteryInfo.remainingLabel = TIME_LEFT;
- mPowerUsageSummary.updateHeaderPreference(mBatteryInfo);
+ mFragment.updateHeaderPreference(mBatteryInfo);
verify(mSummary1).setVisibility(View.VISIBLE);
verify(mSummary2).setVisibility(View.VISIBLE);
@@ -349,7 +358,7 @@
mBatteryInfo.remainingTimeUs = REMAINING_TIME_US;
mBatteryInfo.mDischarging = false;
- mPowerUsageSummary.updateHeaderPreference(mBatteryInfo);
+ mFragment.updateHeaderPreference(mBatteryInfo);
verify(mSummary1).setText(R.string.estimated_charging_time_left);
}
@@ -358,17 +367,17 @@
mBatteryInfo.remainingTimeUs = REMAINING_TIME_US;
mBatteryInfo.mDischarging = true;
- mPowerUsageSummary.updateHeaderPreference(mBatteryInfo);
+ mFragment.updateHeaderPreference(mBatteryInfo);
verify(mSummary1).setText(R.string.estimated_time_left);
}
@Test
public void testUpdateHeaderPreference_AsyncUpdate_ShouldNotCrash() {
- when(mPowerUsageSummary.getContext()).thenReturn(null);
+ when(mFragment.getContext()).thenReturn(null);
mBatteryInfo.remainingTimeUs = REMAINING_TIME_US;
//Should not crash
- mPowerUsageSummary.updateHeaderPreference(mBatteryInfo);
+ mFragment.updateHeaderPreference(mBatteryInfo);
}
private void testToggleAllApps(final boolean isShowApps) {
@@ -380,7 +389,7 @@
@Test
public void testFindBatterySipperByType_findTypeScreen() {
- BatterySipper sipper = mPowerUsageSummary.findBatterySipperByType(mUsageList,
+ BatterySipper sipper = mFragment.findBatterySipperByType(mUsageList,
BatterySipper.DrainType.SCREEN);
assertThat(sipper).isSameAs(mScreenBatterySipper);
@@ -388,7 +397,7 @@
@Test
public void testFindBatterySipperByType_findTypeApp() {
- BatterySipper sipper = mPowerUsageSummary.findBatterySipperByType(mUsageList,
+ BatterySipper sipper = mFragment.findBatterySipperByType(mUsageList,
BatterySipper.DrainType.APP);
assertThat(sipper).isSameAs(mNormalBatterySipper);
@@ -399,9 +408,9 @@
final double percent = POWER_MAH / TOTAL_POWER * DISCHARGE_AMOUNT;
final String expectedSummary = mRealContext.getString(R.string.battery_overall_usage,
Utils.formatPercentage((int) percent));
- doReturn(expectedSummary).when(mPowerUsageSummary)
+ doReturn(expectedSummary).when(mFragment)
.getString(eq(R.string.battery_overall_usage), anyInt());
- mPowerUsageSummary.updateCellularPreference(DISCHARGE_AMOUNT);
+ mFragment.updateCellularPreference(DISCHARGE_AMOUNT);
verify(mCellularNetworkPref).setSummary(expectedSummary);
}
@@ -413,12 +422,12 @@
final double percent = BATTERY_SCREEN_USAGE / TOTAL_POWER * DISCHARGE_AMOUNT;
final String expectedOverallUsage = mRealContext.getString(R.string.battery_overall_usage,
Utils.formatPercentage((int) percent));
- doReturn(expectedUsedTime).when(mPowerUsageSummary).getString(
+ doReturn(expectedUsedTime).when(mFragment).getString(
eq(R.string.battery_used_for), anyInt());
- doReturn(expectedOverallUsage).when(mPowerUsageSummary).getString(
+ doReturn(expectedOverallUsage).when(mFragment).getString(
eq(R.string.battery_overall_usage), anyInt());
- mPowerUsageSummary.updateScreenPreference(DISCHARGE_AMOUNT);
+ mFragment.updateScreenPreference(DISCHARGE_AMOUNT);
verify(mScreenUsagePref).setSummary(expectedUsedTime);
verify(mScreenConsumptionPref).setSummary(expectedOverallUsage);
@@ -427,16 +436,16 @@
@Test
public void testUpdatePreference_UsageListEmpty_ShouldNotCrash() {
when(mBatteryHelper.getUsageList()).thenReturn(new ArrayList<BatterySipper>());
- doReturn("").when(mPowerUsageSummary).getString(anyInt(), Matchers.anyObject());
+ doReturn("").when(mFragment).getString(anyInt(), Matchers.anyObject());
// Should not crash when update
- mPowerUsageSummary.updateScreenPreference(DISCHARGE_AMOUNT);
- mPowerUsageSummary.updateCellularPreference(DISCHARGE_AMOUNT);
+ mFragment.updateScreenPreference(DISCHARGE_AMOUNT);
+ mFragment.updateCellularPreference(DISCHARGE_AMOUNT);
}
@Test
public void testCalculatePercentage() {
- final double percent = mPowerUsageSummary.calculatePercentage(POWER_MAH, DISCHARGE_AMOUNT);
+ final double percent = mFragment.calculatePercentage(POWER_MAH, DISCHARGE_AMOUNT);
assertThat(percent).isWithin(PRECISION).of(POWER_USAGE_PERCENTAGE);
}
diff --git a/tests/robotests/src/com/android/settings/notification/SettingPrefControllerTest.java b/tests/robotests/src/com/android/settings/notification/SettingPrefControllerTest.java
index b36b19b..25581b9 100644
--- a/tests/robotests/src/com/android/settings/notification/SettingPrefControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/SettingPrefControllerTest.java
@@ -53,7 +53,7 @@
@Mock
private PreferenceScreen mScreen;
@Mock
- private OtherSoundSettings mSetting;
+ private SoundSettings mSetting;
@Mock
private Activity mActivity;
@Mock