Merge "Update Settings search result unique ids"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 649c14f..e09b4b1 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2894,7 +2894,7 @@
<action android:name="android.settings.HOME_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
- <intent-filter android:priority="130">
+ <intent-filter android:priority="120">
<action android:name="com.android.settings.action.SETTINGS"/>
</intent-filter>
<meta-data android:name="com.android.settings.category"
diff --git a/res/layout/dashboard_tile.xml b/res/layout/dashboard_tile.xml
index 1ec1730..e35dbff 100644
--- a/res/layout/dashboard_tile.xml
+++ b/res/layout/dashboard_tile.xml
@@ -30,8 +30,8 @@
android:layout_width="@dimen/dashboard_tile_image_size"
android:layout_height="@dimen/dashboard_tile_image_size"
android:scaleType="centerInside"
- android:layout_marginStart="@dimen/dashboard_tile_image_margin_start"
- android:layout_marginEnd="@dimen/dashboard_tile_image_margin_end" />
+ android:layout_marginStart="@dimen/dashboard_tile_image_margin"
+ android:layout_marginEnd="@dimen/dashboard_tile_image_margin" />
<LinearLayout
android:layout_width="match_parent"
@@ -53,7 +53,7 @@
android:textColor="?android:attr/textColorSecondary"
android:maxLines="1"
android:ellipsize="end"
- android:paddingEnd="@dimen/dashboard_tile_image_margin_start" />
+ android:paddingEnd="@dimen/dashboard_tile_image_margin" />
</LinearLayout>
diff --git a/res/layout/search_icon_view.xml b/res/layout/search_icon_view.xml
index 7df0649..ef99bee 100644
--- a/res/layout/search_icon_view.xml
+++ b/res/layout/search_icon_view.xml
@@ -14,20 +14,12 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<LinearLayout
+
+<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/icon_container"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:minWidth="56dp"
- android:gravity="center_horizontal|top"
- android:orientation="horizontal"
- android:paddingEnd="12dp"
- android:paddingTop="4dp"
- android:paddingBottom="4dp">
- <com.android.internal.widget.PreferenceImageView
- android:id="@android:id/icon"
- android:layout_width="36dp"
- android:layout_height="36dp"
- android:scaleType="fitCenter"/>
-</LinearLayout>
\ No newline at end of file
+ android:id="@android:id/icon"
+ android:layout_width="@dimen/dashboard_tile_image_size"
+ android:layout_height="match_parent"
+ android:scaleType="centerInside"
+ android:layout_marginStart="@dimen/dashboard_tile_image_margin"
+ android:layout_marginEnd="@dimen/dashboard_tile_image_margin" />
diff --git a/res/layout/search_inline_switch_item.xml b/res/layout/search_inline_switch_item.xml
index 526f9fd..8f050a3 100644
--- a/res/layout/search_inline_switch_item.xml
+++ b/res/layout/search_inline_switch_item.xml
@@ -21,7 +21,6 @@
android:minHeight="?android:attr/listPreferredItemHeight"
android:paddingTop="16dp"
android:paddingBottom="16dp"
- android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:background="?android:attr/selectableItemBackground"
android:clipToPadding="false">
diff --git a/res/layout/search_intent_item.xml b/res/layout/search_intent_item.xml
index 98e2a9b..6bc00ad 100644
--- a/res/layout/search_intent_item.xml
+++ b/res/layout/search_intent_item.xml
@@ -21,7 +21,6 @@
android:minHeight="?android:attr/listPreferredItemHeight"
android:paddingTop="16dp"
android:paddingBottom="16dp"
- android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:background="?android:attr/selectableItemBackground"
android:clipToPadding="false">
diff --git a/res/layout/suggestion_header.xml b/res/layout/suggestion_header.xml
index f3f39ff..2268636 100644
--- a/res/layout/suggestion_header.xml
+++ b/res/layout/suggestion_header.xml
@@ -28,8 +28,8 @@
android:id="@android:id/icon"
android:layout_width="@dimen/dashboard_tile_image_size"
android:layout_height="@dimen/dashboard_tile_image_size"
- android:layout_marginStart="@dimen/dashboard_tile_image_margin_start"
- android:layout_marginEnd="@dimen/dashboard_tile_image_margin_end"
+ android:layout_marginStart="@dimen/dashboard_tile_image_margin"
+ android:layout_marginEnd="@dimen/dashboard_tile_image_margin"
android:src="@drawable/ic_expand_more"/>
<TextView
android:id="@android:id/title"
diff --git a/res/layout/suggestion_tile.xml b/res/layout/suggestion_tile.xml
index 9e17e38..cabbafd 100644
--- a/res/layout/suggestion_tile.xml
+++ b/res/layout/suggestion_tile.xml
@@ -28,8 +28,8 @@
android:id="@android:id/icon"
android:layout_width="@dimen/dashboard_tile_image_size"
android:layout_height="@dimen/dashboard_tile_image_size"
- android:layout_marginStart="@dimen/dashboard_tile_image_margin_start"
- android:layout_marginEnd="@dimen/dashboard_tile_image_margin_end"
+ android:layout_marginStart="@dimen/dashboard_tile_image_margin"
+ android:layout_marginEnd="@dimen/dashboard_tile_image_margin"
android:scaleType="centerInside"/>
<RelativeLayout
diff --git a/res/layout/support_tile.xml b/res/layout/support_tile.xml
index c2081c7..a42faf0 100644
--- a/res/layout/support_tile.xml
+++ b/res/layout/support_tile.xml
@@ -28,8 +28,8 @@
android:layout_width="@dimen/dashboard_tile_image_size"
android:layout_height="@dimen/dashboard_tile_image_size"
android:scaleType="centerInside"
- android:layout_marginStart="@dimen/dashboard_tile_image_margin_start"
- android:layout_marginEnd="@dimen/dashboard_tile_image_margin_end"/>
+ android:layout_marginStart="@dimen/dashboard_tile_image_margin"
+ android:layout_marginEnd="@dimen/dashboard_tile_image_margin"/>
<TextView
android:id="@+id/tile_title"
android:layout_width="wrap_content"
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index ea8f0d6..5c6796c 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -109,8 +109,7 @@
<dimen name="dashboard_tile_image_size">24dp</dimen>
<!-- Dashboard tile image margin start / end -->
- <dimen name="dashboard_tile_image_margin_start">16dp</dimen>
- <dimen name="dashboard_tile_image_margin_end">32dp</dimen>
+ <dimen name="dashboard_tile_image_margin">24dp</dimen>
<!-- SwitchBar margin start / end -->
<dimen name="switchbar_margin_start">16dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 0ca1628..08d1b7c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4527,6 +4527,8 @@
<string name="power_last_full_charge_summary"><xliff:g id="time">^1</xliff:g> ago</string>
<!-- Label for list of apps using battery in power use UI. Note: ^1 should be used in all translations[CHAR_LIMIT=120] -->
<string name="power_usage_list_summary">App usage since full charge (<xliff:g id="time">^1</xliff:g> ago)</string>
+ <!-- Label for device components using battery in power use UI. Note: ^1 should be used in all translations[CHAR_LIMIT=120] -->
+ <string name="power_usage_list_summary_device">Device usage since full charge (<xliff:g id="time">^1</xliff:g> ago)</string>
<!-- Description for the screen usage item [CHAR_LIMIT=120] -->
<string name="screen_usage_summary">Amount of time screen has been on since full charge</string>
<!-- Label for list of different types using battery in power use UI [CHAR_LIMIT=60] -->
@@ -6364,6 +6366,7 @@
<string name="keywords_lockscreen">slide to unlock, password, pattern, PIN</string>
<string name="keywords_profile_challenge">work challenge, work, profile</string>
<string name="keywords_unification">work profile, managed profile, unify, unification, work, profile</string>
+ <!-- Search keyword for gesture settings -->
<string name="keywords_gesture">gesture</string>
<string name="keywords_payment_settings">pay, tap, payments</string>
<string name="keywords_backup">backup, back up</string>
@@ -7440,11 +7443,11 @@
<!-- Label for menu to launch a screen showing usage alerts for battery [CHAR LIMIT=30] -->
<string name="additional_battery_info">Usage alerts</string>
- <!-- Label for menu to show all apps in battery settings [CHAR LIMIT=30] -->
- <string name="show_all_apps">Show all apps</string>
+ <!-- Label for menu to show battery usage in the device [CHAR LIMIT=45] -->
+ <string name="show_all_apps">Show full device usage</string>
- <!-- Label for menu to hide extra apps in battery settings [CHAR LIMIT=30] -->
- <string name="hide_extra_apps">Hide extra apps</string>
+ <!-- Label for menu to show app usage [CHAR LIMIT=30] -->
+ <string name="hide_extra_apps">Show app usage</string>
<!-- Title for high usage item, which means power high usage [CHAR LIMIT=30] -->
<string name="power_high_usage_title">High usage</string>
@@ -8412,7 +8415,7 @@
<string name="deletion_helper_preference_title">Free up space now</string>
<!-- Preference title for gesture settings [CHAR LIMIT=25]-->
- <string name="gesture_preference_title">Gestures</string>
+ <string name="gesture_preference_title">Gesture shortcuts</string>
<!-- Preference summary for gesture settings (phone) [CHAR LIMIT=NONE]-->
<string name="gesture_preference_summary" product="default">Quick gestures to control your phone</string>
diff --git a/res/xml/assist_gesture_settings.xml b/res/xml/assist_gesture_settings.xml
index 0dbf9c7..e79d886 100644
--- a/res/xml/assist_gesture_settings.xml
+++ b/res/xml/assist_gesture_settings.xml
@@ -27,7 +27,8 @@
<SwitchPreference
android:key="gesture_assist"
android:title="@string/assist_gesture_title"
- android:summary="@string/assist_gesture_summary" />
+ android:summary="@string/assist_gesture_summary"
+ app:keywords="@string/keywords_gesture"/>
<com.android.settings.widget.SeekBarPreference
android:key="gesture_assist_sensitivity"
diff --git a/res/xml/camera_lift_trigger_settings.xml b/res/xml/camera_lift_trigger_settings.xml
index fe8991a..d9de14f 100644
--- a/res/xml/camera_lift_trigger_settings.xml
+++ b/res/xml/camera_lift_trigger_settings.xml
@@ -27,6 +27,7 @@
<SwitchPreference
android:key="gesture_camera_lift_trigger"
android:title="@string/camera_lift_trigger_title"
- android:summary="@string/camera_lift_trigger_summary"/>
+ android:summary="@string/camera_lift_trigger_summary"
+ app:keywords="@string/keywords_gesture"/>
</PreferenceScreen>
diff --git a/res/xml/double_tap_power_settings.xml b/res/xml/double_tap_power_settings.xml
index 54854a8..4d89de6 100644
--- a/res/xml/double_tap_power_settings.xml
+++ b/res/xml/double_tap_power_settings.xml
@@ -22,11 +22,12 @@
<com.android.settings.widget.VideoPreference
android:key="gesture_double_tap_power_video"
app:animation="@raw/gesture_double_tap"
- app:preview="@drawable/gesture_double_tap"/>
+ app:preview="@drawable/gesture_double_tap" />
<SwitchPreference
android:key="gesture_double_tap_power"
android:title="@string/double_tap_power_for_camera_title"
- android:summary="@string/double_tap_power_for_camera_summary"/>
+ android:summary="@string/double_tap_power_for_camera_summary"
+ app:keywords="@string/keywords_gesture" />
</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/double_tap_screen_settings.xml b/res/xml/double_tap_screen_settings.xml
index f7fe853..1601aae 100644
--- a/res/xml/double_tap_screen_settings.xml
+++ b/res/xml/double_tap_screen_settings.xml
@@ -27,6 +27,7 @@
<SwitchPreference
android:key="gesture_double_tap_screen"
android:title="@string/ambient_display_title"
- android:summary="@string/ambient_display_summary"/>
+ android:summary="@string/ambient_display_summary"
+ app:keywords="@string/keywords_gesture"/>
</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/double_twist_gesture_settings.xml b/res/xml/double_twist_gesture_settings.xml
index f77d778..94d9782 100644
--- a/res/xml/double_twist_gesture_settings.xml
+++ b/res/xml/double_twist_gesture_settings.xml
@@ -27,6 +27,7 @@
<SwitchPreference
android:key="gesture_double_twist"
android:title="@string/double_twist_for_camera_mode_title"
- android:summary="@string/double_twist_for_camera_mode_summary"/>
+ android:summary="@string/double_twist_for_camera_mode_summary"
+ app:keywords="@string/keywords_gesture"/>
</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/language_and_input.xml b/res/xml/language_and_input.xml
index 8c83767..d88cd11 100644
--- a/res/xml/language_and_input.xml
+++ b/res/xml/language_and_input.xml
@@ -63,42 +63,43 @@
<PreferenceCategory
android:key="gesture_settings_category"
- android:title="@string/gesture_preference_title">
+ android:title="@string/gesture_preference_title"
+ settings:keywords="@string/keywords_gesture">
<Preference
android:key="gesture_assist_input_summary"
android:title="@string/assist_gesture_title"
- android:fragment="com.android.settings.gestures.AssistGestureSettings"/>
+ android:fragment="com.android.settings.gestures.AssistGestureSettings" />
<Preference
android:key="gesture_swipe_down_fingerprint_input_summary"
android:title="@string/fingerprint_swipe_for_notifications_title"
- android:fragment="com.android.settings.gestures.SwipeToNotificationSettings"/>
+ android:fragment="com.android.settings.gestures.SwipeToNotificationSettings" />
<Preference
android:key="gesture_double_tap_screen_input_summary"
android:title="@string/ambient_display_title"
- android:fragment="com.android.settings.gestures.DoubleTapScreenSettings"/>
+ android:fragment="com.android.settings.gestures.DoubleTapScreenSettings" />
<Preference
android:key="gesture_pick_up_input_summary"
android:title="@string/ambient_display_pickup_title"
- android:fragment="com.android.settings.gestures.PickupGestureSettings"/>
+ android:fragment="com.android.settings.gestures.PickupGestureSettings" />
<Preference
android:key="gesture_camera_lift_trigger_summary"
android:title="@string/camera_lift_trigger_title"
- android:fragment="com.android.settings.gestures.CameraLiftTriggerSettings"/>
+ android:fragment="com.android.settings.gestures.CameraLiftTriggerSettings" />
<Preference
android:key="gesture_double_tap_power_input_summary"
android:title="@string/double_tap_power_for_camera_title"
- android:fragment="com.android.settings.gestures.DoubleTapPowerSettings"/>
+ android:fragment="com.android.settings.gestures.DoubleTapPowerSettings" />
<Preference
android:key="gesture_double_twist_input_summary"
android:title="@string/double_twist_for_camera_mode_title"
- android:fragment="com.android.settings.gestures.DoubleTwistGestureSettings"/>
+ android:fragment="com.android.settings.gestures.DoubleTwistGestureSettings" />
</PreferenceCategory>
diff --git a/res/xml/pick_up_gesture_settings.xml b/res/xml/pick_up_gesture_settings.xml
index 78122aa..0b4a1de 100644
--- a/res/xml/pick_up_gesture_settings.xml
+++ b/res/xml/pick_up_gesture_settings.xml
@@ -23,11 +23,12 @@
<com.android.settings.widget.VideoPreference
android:key="gesture_pick_up_video"
app:animation="@raw/gesture_ambient_lift"
- app:preview="@drawable/gesture_ambient_lift"/>
+ app:preview="@drawable/gesture_ambient_lift" />
<SwitchPreference
android:key="gesture_pick_up"
android:title="@string/ambient_display_pickup_title"
- android:summary="@string/ambient_display_pickup_summary"/>
+ android:summary="@string/ambient_display_pickup_summary"
+ app:keywords="@string/keywords_gesture" />
</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/swipe_to_notification_settings.xml b/res/xml/swipe_to_notification_settings.xml
index b26af38..6269bdc 100644
--- a/res/xml/swipe_to_notification_settings.xml
+++ b/res/xml/swipe_to_notification_settings.xml
@@ -27,6 +27,7 @@
<SwitchPreference
android:key="gesture_swipe_down_fingerprint"
android:title="@string/fingerprint_swipe_for_notifications_title"
- android:summary="@string/fingerprint_swipe_for_notifications_summary"/>
+ android:summary="@string/fingerprint_swipe_for_notifications_summary"
+ app:keywords="@string/keywords_gesture"/>
</PreferenceScreen>
\ No newline at end of file
diff --git a/src/com/android/settings/EncryptionAndCredential.java b/src/com/android/settings/EncryptionAndCredential.java
index 1750e75..f6f17cf 100644
--- a/src/com/android/settings/EncryptionAndCredential.java
+++ b/src/com/android/settings/EncryptionAndCredential.java
@@ -253,7 +253,7 @@
@Override
public List<String> getNonIndexableKeys(Context context) {
- final List<String> keys = new ArrayList<String>();
+ final List<String> keys = super.getNonIndexableKeys(context);
final UserManager um = UserManager.get(context);
diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java
index 3052281..463a7e0 100755
--- a/src/com/android/settings/applications/InstalledAppDetails.java
+++ b/src/com/android/settings/applications/InstalledAppDetails.java
@@ -192,6 +192,8 @@
BatterySipper mSipper;
@VisibleForTesting
BatteryStatsHelper mBatteryHelper;
+ @VisibleForTesting
+ BatteryUtils mBatteryUtils;
protected ProcStatsData mStatsManager;
protected ProcStatsPackageEntry mStats;
@@ -200,7 +202,6 @@
private AppStorageStats mLastResult;
private String mBatteryPercent;
- private BatteryUtils mBatteryUtils;
private final LoaderCallbacks<BatteryStatsHelper> mBatteryCallbacks =
new LoaderCallbacks<BatteryStatsHelper>() {
@@ -722,8 +723,6 @@
mDataPreference.setSummary(getDataSummary());
}
- updateBattery();
-
if (!mInitialized) {
// First time init: are we displaying an uninstalled app?
mInitialized = true;
@@ -750,9 +749,10 @@
return true;
}
- private void updateBattery() {
- if (mSipper != null && mBatteryHelper != null) {
- mBatteryPreference.setEnabled(true);
+ @VisibleForTesting
+ void updateBattery() {
+ mBatteryPreference.setEnabled(true);
+ if (isBatteryStatsAvailable()) {
final int dischargeAmount = mBatteryHelper.getStats().getDischargeAmount(
BatteryStats.STATS_SINCE_CHARGED);
@@ -764,7 +764,6 @@
mBatteryPercent = Utils.formatPercentage(percentOfMax);
mBatteryPreference.setSummary(getString(R.string.battery_summary, mBatteryPercent));
} else {
- mBatteryPreference.setEnabled(false);
mBatteryPreference.setSummary(getString(R.string.no_battery_summary));
}
}
@@ -798,6 +797,11 @@
}
}
+ @VisibleForTesting
+ boolean isBatteryStatsAvailable() {
+ return mBatteryHelper != null && mSipper != null;
+ }
+
private static CharSequence getSize(Context context, AppStorageStats stats) {
return Formatter.formatFileSize(context, stats.getTotalBytes());
}
@@ -1036,9 +1040,15 @@
} else if (preference == mDataPreference) {
startAppInfoFragment(AppDataUsage.class, getString(R.string.app_data_usage));
} else if (preference == mBatteryPreference) {
- BatteryEntry entry = new BatteryEntry(getContext(), null, mUserManager, mSipper);
- AdvancedPowerUsageDetail.startBatteryDetailPage((SettingsActivity) getActivity(), this,
- mBatteryHelper, BatteryStats.STATS_SINCE_CHARGED, entry, mBatteryPercent);
+ if (isBatteryStatsAvailable()) {
+ BatteryEntry entry = new BatteryEntry(getContext(), null, mUserManager, mSipper);
+ AdvancedPowerUsageDetail.startBatteryDetailPage((SettingsActivity) getActivity(),
+ this, mBatteryHelper, BatteryStats.STATS_SINCE_CHARGED, entry,
+ mBatteryPercent);
+ } else {
+ AdvancedPowerUsageDetail.startBatteryDetailPage((SettingsActivity) getActivity(),
+ this, mPackageName);
+ }
} else {
return false;
}
diff --git a/src/com/android/settings/backup/BackupSettingsActivity.java b/src/com/android/settings/backup/BackupSettingsActivity.java
index f8bab3d..3fe740e 100644
--- a/src/com/android/settings/backup/BackupSettingsActivity.java
+++ b/src/com/android/settings/backup/BackupSettingsActivity.java
@@ -110,7 +110,7 @@
@Override
public List<String> getNonIndexableKeys(Context context) {
- final List<String> keys = new ArrayList<String>();
+ final List<String> keys = super.getNonIndexableKeys(context);
// For non-primary user, no backup is available, so don't show it in search
// TODO: http://b/22388012
diff --git a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
index 27492ce..254d5e2 100644
--- a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
+++ b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
@@ -131,9 +131,8 @@
@Override
public List<String> getNonIndexableKeys(Context context) {
+ final List<String> keys = super.getNonIndexableKeys(context);
PackageManager pm = context.getPackageManager();
- final List<String> keys = new ArrayList<String>();
-
if (!pm.hasSystemFeature(PackageManager.FEATURE_NFC)) {
keys.add(NfcPreferenceController.KEY_TOGGLE_NFC);
keys.add(NfcPreferenceController.KEY_ANDROID_BEAM_SETTINGS);
diff --git a/src/com/android/settings/datausage/DataUsageMeteredSettings.java b/src/com/android/settings/datausage/DataUsageMeteredSettings.java
index ce2bc8d..c2a18e9 100644
--- a/src/com/android/settings/datausage/DataUsageMeteredSettings.java
+++ b/src/com/android/settings/datausage/DataUsageMeteredSettings.java
@@ -226,7 +226,7 @@
@Override
public List<String> getNonIndexableKeys(Context context) {
- final ArrayList<String> result = new ArrayList<String>();
+ final List<String> result = super.getNonIndexableKeys(context);
if (!SHOW_MOBILE_CATEGORY || !hasReadyMobileRadio(context)) {
result.add("mobile");
}
diff --git a/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java b/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java
index 9abc7f9..8dbb183 100644
--- a/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java
+++ b/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java
@@ -132,6 +132,16 @@
new UserHandle(UserHandle.getUserId(sipper.getUid())));
}
+ public static void startBatteryDetailPage(SettingsActivity caller, PreferenceFragment fragment,
+ String packageName) {
+ final Bundle args = new Bundle(2);
+ args.putString(EXTRA_PACKAGE_NAME, packageName);
+ args.putString(EXTRA_POWER_USAGE_PERCENT, Utils.formatPercentage(0));
+
+ caller.startPreferencePanelAsUser(fragment, AdvancedPowerUsageDetail.class.getName(), args,
+ R.string.battery_details_title, null, new UserHandle(UserHandle.myUserId()));
+ }
+
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
diff --git a/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceController.java b/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceController.java
new file mode 100644
index 0000000..04e2c7a
--- /dev/null
+++ b/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceController.java
@@ -0,0 +1,91 @@
+/*
+ * 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.Intent;
+import android.content.IntentFilter;
+import android.support.annotation.VisibleForTesting;
+import android.support.v7.preference.PreferenceScreen;
+import android.widget.TextView;
+
+import com.android.settings.R;
+import com.android.settings.applications.LayoutPreference;
+import com.android.settings.core.PreferenceController;
+import com.android.settingslib.BatteryInfo;
+import com.android.settingslib.Utils;
+
+/**
+ * Controller that update the battery header view
+ */
+public class BatteryHeaderPreferenceController extends PreferenceController {
+ @VisibleForTesting
+ static final String KEY_BATTERY_HEADER = "battery_header";
+ @VisibleForTesting
+ BatteryMeterView mBatteryMeterView;
+ @VisibleForTesting
+ TextView mTimeText;
+ @VisibleForTesting
+ TextView mSummary;
+
+ private LayoutPreference mBatteryLayoutPref;
+
+ public BatteryHeaderPreferenceController(Context context) {
+ super(context);
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+
+ mBatteryLayoutPref = (LayoutPreference) screen.findPreference(KEY_BATTERY_HEADER);
+ mBatteryMeterView = (BatteryMeterView) mBatteryLayoutPref
+ .findViewById(R.id.battery_header_icon);
+ mTimeText = (TextView) mBatteryLayoutPref.findViewById(R.id.battery_percent);
+ mSummary = (TextView) mBatteryLayoutPref.findViewById(R.id.summary1);
+
+ Intent batteryBroadcast = mContext.registerReceiver(null,
+ new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
+ final int batteryLevel = Utils.getBatteryLevel(batteryBroadcast);
+
+ mBatteryMeterView.setBatteryLevel(batteryLevel);
+ mTimeText.setText(Utils.formatPercentage(batteryLevel));
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return true;
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_BATTERY_HEADER;
+ }
+
+ public void updateHeaderPreference(BatteryInfo info) {
+ mTimeText.setText(Utils.formatPercentage(info.batteryLevel));
+ if (info.remainingLabel == null) {
+ mSummary.setText(info.statusLabel);
+ } else {
+ mSummary.setText(info.remainingLabel);
+ }
+
+ mBatteryMeterView.setBatteryLevel(info.batteryLevel);
+ mBatteryMeterView.setCharging(!info.discharging);
+ }
+}
diff --git a/src/com/android/settings/fuelgauge/BatteryMeterView.java b/src/com/android/settings/fuelgauge/BatteryMeterView.java
index b9ed1e4..09f7c7a 100644
--- a/src/com/android/settings/fuelgauge/BatteryMeterView.java
+++ b/src/com/android/settings/fuelgauge/BatteryMeterView.java
@@ -72,6 +72,10 @@
}
}
+ public int getBatteryLevel() {
+ return mDrawable.getBatteryLevel();
+ }
+
public void setCharging(boolean charging) {
mDrawable.setCharging(charging);
}
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index 512dc17..de80d3b 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -139,6 +139,7 @@
@VisibleForTesting
SparseArray<List<Anomaly>> mAnomalySparseArray;
+ private BatteryHeaderPreferenceController mBatteryHeaderPreferenceController;
private LayoutPreference mBatteryLayoutPref;
private PreferenceGroup mAppListGroup;
private AnomalySummaryPreferenceController mAnomalySummaryPreferenceController;
@@ -192,7 +193,7 @@
Intent batteryBroadcast = getContext().registerReceiver(null,
new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
BatteryInfo batteryInfo = getBatteryInfo(elapsedRealtimeUs, batteryBroadcast);
- updateHeaderPreference(batteryInfo);
+ mBatteryHeaderPreferenceController.updateHeaderPreference(batteryInfo);
}
@Override
@@ -227,11 +228,6 @@
}
@Override
- public void onResume() {
- super.onResume();
- }
-
- @Override
public void onPause() {
BatteryEntry.stopRequestQueue();
mHandler.removeMessages(BatteryEntry.MSG_UPDATE_NAME_ICON);
@@ -277,6 +273,8 @@
@Override
protected List<PreferenceController> getPreferenceControllers(Context context) {
final List<PreferenceController> controllers = new ArrayList<>();
+ mBatteryHeaderPreferenceController = new BatteryHeaderPreferenceController(context);
+ controllers.add(mBatteryHeaderPreferenceController);
controllers.add(new AutoBrightnessPreferenceController(context, KEY_AUTO_BRIGHTNESS));
controllers.add(new TimeoutPreferenceController(context, KEY_SCREEN_TIMEOUT));
controllers.add(new BatterySaverController(context, getLifecycle()));
@@ -497,7 +495,7 @@
Intent batteryBroadcast = context.registerReceiver(null,
new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
BatteryInfo batteryInfo = getBatteryInfo(elapsedRealtimeUs, batteryBroadcast);
- updateHeaderPreference(batteryInfo);
+ mBatteryHeaderPreferenceController.updateHeaderPreference(batteryInfo);
final long runningTime = mBatteryUtils.calculateRunningTimeBasedOnStatsType(mStatsHelper,
mStatsType);
@@ -505,8 +503,9 @@
updateLastFullChargePreference(runningTime);
final CharSequence timeSequence = Utils.formatElapsedTime(context, runningTime, false);
- mAppListGroup.setTitle(
- TextUtils.expandTemplate(getText(R.string.power_usage_list_summary), timeSequence));
+ final int resId = mShowAllApps ? R.string.power_usage_list_summary_device
+ : R.string.power_usage_list_summary;
+ mAppListGroup.setTitle(TextUtils.expandTemplate(getText(resId), timeSequence));
refreshAppListGroup();
}
@@ -657,27 +656,6 @@
}
@VisibleForTesting
- void updateHeaderPreference(BatteryInfo info) {
- final Context context = getContext();
- if (context == null) {
- return;
- }
- final BatteryMeterView batteryView = (BatteryMeterView) mBatteryLayoutPref
- .findViewById(R.id.battery_header_icon);
- final TextView timeText = (TextView) mBatteryLayoutPref.findViewById(R.id.battery_percent);
- final TextView summary1 = (TextView) mBatteryLayoutPref.findViewById(R.id.summary1);
- timeText.setText(Utils.formatPercentage(info.batteryLevel));
- if (info.remainingLabel == null ) {
- summary1.setText(info.statusLabel);
- } else {
- summary1.setText(info.remainingLabel);
- }
-
- batteryView.setBatteryLevel(info.batteryLevel);
- batteryView.setCharging(!info.discharging);
- }
-
- @VisibleForTesting
double calculatePercentage(double powerUsage, double dischargeAmount) {
final double totalPower = mStatsHelper.getTotalPower();
return totalPower == 0 ? 0 :
@@ -870,7 +848,7 @@
@Override
public List<String> getNonIndexableKeys(Context context) {
- List<String> niks = new ArrayList<>();
+ List<String> niks = super.getNonIndexableKeys(context);
// Duplicates in display
niks.add(KEY_AUTO_BRIGHTNESS);
niks.add(KEY_SCREEN_TIMEOUT);
diff --git a/src/com/android/settings/network/NetworkDashboardFragment.java b/src/com/android/settings/network/NetworkDashboardFragment.java
index 869cef9..a393056 100644
--- a/src/com/android/settings/network/NetworkDashboardFragment.java
+++ b/src/com/android/settings/network/NetworkDashboardFragment.java
@@ -207,7 +207,7 @@
@Override
public List<String> getNonIndexableKeys(Context context) {
- List<String> keys = new ArrayList<>();
+ List<String> keys = super.getNonIndexableKeys(context);
// Remove master switch as a result
keys.add(WifiMasterSwitchPreferenceController.KEY_TOGGLE_WIFI);
return keys;
diff --git a/src/com/android/settings/nfc/PaymentSettings.java b/src/com/android/settings/nfc/PaymentSettings.java
index 47de1a5..64161d1 100644
--- a/src/com/android/settings/nfc/PaymentSettings.java
+++ b/src/com/android/settings/nfc/PaymentSettings.java
@@ -33,14 +33,13 @@
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.search.SearchIndexableRaw;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.nfc.PaymentBackend.PaymentAppInfo;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
+import com.android.settings.search.SearchIndexableRaw;
-import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
@@ -162,11 +161,13 @@
@Override
public List<String> getNonIndexableKeys(Context context) {
+ final List<String> nonVisibleKeys = super.getNonIndexableKeys(context);
final PackageManager pm = context.getPackageManager();
- if (pm.hasSystemFeature(PackageManager.FEATURE_NFC)) return null;
- final List<String> nonVisibleKeys = new ArrayList<String>();
+ if (pm.hasSystemFeature(PackageManager.FEATURE_NFC)) {
+ return nonVisibleKeys;
+ }
nonVisibleKeys.add(PAYMENT_KEY);
return nonVisibleKeys;
}
- };
+ };
}
diff --git a/src/com/android/settings/wifi/p2p/WifiP2pSettings.java b/src/com/android/settings/wifi/p2p/WifiP2pSettings.java
index 232666a..cd328d9 100644
--- a/src/com/android/settings/wifi/p2p/WifiP2pSettings.java
+++ b/src/com/android/settings/wifi/p2p/WifiP2pSettings.java
@@ -198,7 +198,7 @@
if (savedInstanceState != null && savedInstanceState.containsKey(SAVE_DIALOG_PEER)) {
WifiP2pDevice device = savedInstanceState.getParcelable(SAVE_DIALOG_PEER);
- mSelectedWifiPeer = new WifiP2pPeer(getActivity(), device);
+ mSelectedWifiPeer = new WifiP2pPeer(getPrefContext(), device);
}
if (savedInstanceState != null && savedInstanceState.containsKey(SAVE_DEVICE_NAME)) {
mSavedDeviceName = savedInstanceState.getString(SAVE_DEVICE_NAME);
@@ -533,7 +533,7 @@
if (DBG) Log.d(TAG, "List of available peers");
for (WifiP2pDevice peer: mPeers.getDeviceList()) {
if (DBG) Log.d(TAG, "-> " + peer);
- mPeerCategoryController.addChild(new WifiP2pPeer(getActivity(), peer));
+ mPeerCategoryController.addChild(new WifiP2pPeer(getPrefContext(), peer));
if (peer.status == WifiP2pDevice.CONNECTED) mConnectedDevices++;
}
if (DBG) Log.d(TAG, " mConnectedDevices " + mConnectedDevices);
diff --git a/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java b/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java
index a09aeec..f602236 100644
--- a/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java
@@ -20,6 +20,8 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyDouble;
+import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@@ -46,10 +48,12 @@
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.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.applications.instantapps.InstantAppButtonsController;
+import com.android.settings.fuelgauge.BatteryUtils;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settingslib.applications.AppUtils;
import com.android.settingslib.applications.ApplicationsState.AppEntry;
@@ -77,6 +81,8 @@
private static final String PACKAGE_NAME = "test_package_name";
private static final int TARGET_UID = 111;
private static final int OTHER_UID = 222;
+ private static final double BATTERY_LEVEL = 60;
+ private static final String BATTERY_LEVEL_STRING = "60%";
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Context mContext;
@@ -89,20 +95,21 @@
@Mock
private DevicePolicyManager mDevicePolicyManager;
@Mock
- private Preference mBatteryPreference;
- @Mock
private BatterySipper mBatterySipper;
@Mock
private BatterySipper mOtherBatterySipper;
- @Mock
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
private BatteryStatsHelper mBatteryStatsHelper;
@Mock
private BatteryStats.Uid mUid;
@Mock
private PackageManager mPackageManager;
+ @Mock
+ private BatteryUtils mBatteryUtils;
private InstalledAppDetails mAppDetail;
private Context mShadowContext;
+ private Preference mBatteryPreference;
@Before
public void setUp() {
@@ -110,6 +117,10 @@
mShadowContext = RuntimeEnvironment.application;
mAppDetail = spy(new InstalledAppDetails());
+ mAppDetail.mBatteryUtils = mBatteryUtils;
+
+ mBatteryPreference = new Preference(mShadowContext);
+ mAppDetail.mBatteryPreference = mBatteryPreference;
mBatterySipper.drainType = BatterySipper.DrainType.IDLE;
mBatterySipper.uidObj = mUid;
@@ -409,4 +420,42 @@
assertThat(mAppDetail.findTargetSipper(mBatteryStatsHelper, TARGET_UID)).isEqualTo(
mBatterySipper);
}
+
+ @Test
+ public void updateBattery_noBatteryStats_summaryNo() {
+ doReturn(mShadowContext.getString(R.string.no_battery_summary)).when(mAppDetail).getString(
+ R.string.no_battery_summary);
+ mAppDetail.updateBattery();
+
+ assertThat(mBatteryPreference.getSummary()).isEqualTo(
+ "No battery use since last full charge");
+ }
+
+ @Test
+ public void updateBattery_hasBatteryStats_summaryPercent() {
+ mAppDetail.mBatteryHelper = mBatteryStatsHelper;
+ mAppDetail.mSipper = mBatterySipper;
+ doReturn(BATTERY_LEVEL).when(mBatteryUtils).calculateBatteryPercent(anyDouble(),
+ anyDouble(), anyDouble(), anyInt());
+ doReturn(mShadowContext.getString(R.string.battery_summary, BATTERY_LEVEL_STRING)).when(
+ mAppDetail).getString(R.string.battery_summary, BATTERY_LEVEL_STRING);
+ doReturn(new ArrayList<>()).when(mBatteryStatsHelper).getUsageList();
+
+ mAppDetail.updateBattery();
+
+ assertThat(mBatteryPreference.getSummary()).isEqualTo("60% use since last full charge");
+ }
+
+ @Test
+ public void isBatteryStatsAvailable_hasBatteryStatsHelperAndSipper_returnTrue() {
+ mAppDetail.mBatteryHelper = mBatteryStatsHelper;
+ mAppDetail.mSipper = mBatterySipper;
+
+ assertThat(mAppDetail.isBatteryStatsAvailable()).isTrue();
+ }
+
+ @Test
+ public void isBatteryStatsAvailable_parametersNull_returnFalse() {
+ assertThat(mAppDetail.isBatteryStatsAvailable()).isFalse();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java b/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java
index 6fd626b..40db72c 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java
@@ -283,4 +283,26 @@
verify(mTestActivity).startPreferencePanelAsUser(
any(), anyString(), any(), anyInt(), any(), eq(new UserHandle(10)));
}
+
+ @Test
+ public void testStartBatteryDetailPage_noBatteryUsage_hasBasicData() {
+ final ArgumentCaptor<Bundle> captor = ArgumentCaptor.forClass(Bundle.class);
+ Answer<Void> callable = new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) throws Exception {
+ mBundle = captor.getValue();
+ return null;
+ }
+ };
+ doAnswer(callable).when(mTestActivity).startPreferencePanelAsUser(any(), anyString(),
+ captor.capture(), anyInt(), any(), any());
+
+ AdvancedPowerUsageDetail.startBatteryDetailPage(mTestActivity, null, PACKAGE_NAME[0]);
+
+ assertThat(mBundle.getString(AdvancedPowerUsageDetail.EXTRA_PACKAGE_NAME)).isEqualTo(
+ PACKAGE_NAME[0]);
+ assertThat(mBundle.getString(AdvancedPowerUsageDetail.EXTRA_POWER_USAGE_PERCENT)).isEqualTo(
+ "0%");
+ }
+
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceControllerTest.java
new file mode 100644
index 0000000..04bb2cf
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceControllerTest.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.fuelgauge;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.BatteryManager;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+import android.widget.TextView;
+
+import com.android.settings.R;
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settings.applications.LayoutPreference;
+import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settings.testutils.shadow.ShadowDynamicIndexableContentMonitor;
+import com.android.settingslib.BatteryInfo;
+
+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,
+ shadows = {
+ SettingsShadowResources.class,
+ SettingsShadowResources.SettingsShadowTheme.class,
+ ShadowDynamicIndexableContentMonitor.class
+ })
+public class BatteryHeaderPreferenceControllerTest {
+ private static final int BATTERY_LEVEL = 60;
+ private static final String TIME_LEFT = "2h30min";
+ private static final String BATTERY_STATUS = "Charging";
+
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
+ @Mock
+ private BatteryInfo mBatteryInfo;
+ private BatteryHeaderPreferenceController mController;
+ private Context mContext;
+ private BatteryMeterView mBatteryMeterView;
+ private TextView mTimeText;
+ private TextView mSummary;
+ private LayoutPreference mBatteryLayoutPref;
+ private Intent mBatteryIntent;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ mContext = spy(RuntimeEnvironment.application);
+ mBatteryMeterView = new BatteryMeterView(mContext);
+ mTimeText = new TextView(mContext);
+ mSummary = new TextView(mContext);
+
+ mBatteryIntent = new Intent();
+ mBatteryIntent.putExtra(BatteryManager.EXTRA_LEVEL, BATTERY_LEVEL);
+ mBatteryIntent.putExtra(BatteryManager.EXTRA_SCALE, 100);
+ doReturn(mBatteryIntent).when(mContext).registerReceiver(any(), any());
+
+ mBatteryLayoutPref = new LayoutPreference(mContext, R.layout.battery_header);
+ doReturn(mBatteryLayoutPref).when(mPreferenceScreen).findPreference(
+ BatteryHeaderPreferenceController.KEY_BATTERY_HEADER);
+
+ mBatteryInfo.batteryLevel = BATTERY_LEVEL;
+
+ mController = new BatteryHeaderPreferenceController(mContext);
+ mController.mBatteryMeterView = mBatteryMeterView;
+ mController.mTimeText = mTimeText;
+ mController.mSummary = mSummary;
+ }
+
+ @Test
+ public void testDisplayPreference_displayBatteryLevel() {
+ mController.displayPreference(mPreferenceScreen);
+
+ assertThat(((BatteryMeterView) mBatteryLayoutPref.findViewById(
+ R.id.battery_header_icon)).getBatteryLevel()).isEqualTo(BATTERY_LEVEL);
+ assertThat(((TextView) mBatteryLayoutPref.findViewById(
+ R.id.battery_percent)).getText()).isEqualTo("60%");
+ }
+
+ @Test
+ public void testUpdatePreference_hasRemainingTime_showRemainingLabel() {
+ mBatteryInfo.remainingLabel = TIME_LEFT;
+
+ mController.updateHeaderPreference(mBatteryInfo);
+
+ assertThat(mSummary.getText()).isEqualTo(mBatteryInfo.remainingLabel);
+ }
+
+ @Test
+ public void testUpdatePreference_updateBatteryInfo() {
+ mBatteryInfo.remainingLabel = TIME_LEFT;
+ mBatteryInfo.batteryLevel = BATTERY_LEVEL;
+ mBatteryInfo.discharging = true;
+
+ mController.updateHeaderPreference(mBatteryInfo);
+
+ assertThat(mBatteryMeterView.mDrawable.getBatteryLevel()).isEqualTo(BATTERY_LEVEL);
+ assertThat(mBatteryMeterView.mDrawable.getCharging()).isEqualTo(false);
+ }
+
+ @Test
+ public void testUpdatePreference_noRemainingTime_showStatusLabel() {
+ mBatteryInfo.remainingLabel = null;
+ mBatteryInfo.statusLabel = BATTERY_STATUS;
+
+ mController.updateHeaderPreference(mBatteryInfo);
+
+ assertThat(mSummary.getText()).isEqualTo(BATTERY_STATUS);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
index 56dfbcd..e76e185 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
@@ -90,13 +90,10 @@
})
public class PowerUsageSummaryTest {
private static final String[] PACKAGE_NAMES = {"com.app1", "com.app2"};
- private static final String TIME_LEFT = "2h30min";
private static final String STUB_STRING = "stub_string";
- private static final int BATTERY_LEVEL = 55;
private static final int UID = 123;
private static final int UID_2 = 234;
private static final int POWER_MAH = 100;
- private static final long REMAINING_TIME_US = 100000;
private static final long TIME_SINCE_LAST_FULL_CHARGE_MS = 120 * 60 * 1000;
private static final long TIME_SINCE_LAST_FULL_CHARGE_US =
TIME_SINCE_LAST_FULL_CHARGE_MS * 1000;
@@ -135,8 +132,6 @@
private TextView mBatteryPercentText;
@Mock
private TextView mSummary1;
- @Mock
- private BatteryInfo mBatteryInfo;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private BatteryStatsHelper mBatteryHelper;
@Mock
@@ -214,8 +209,6 @@
mFragment.mScreenUsagePref = mScreenUsagePref;
mFragment.mLastFullChargePref = mLastFullChargePref;
mFragment.mBatteryUtils = spy(new BatteryUtils(mRealContext));
-
- mBatteryInfo.batteryLevel = BATTERY_LEVEL;
}
@Test
@@ -335,45 +328,6 @@
assertThat(mPreference.getSummary().toString()).isEqualTo(expectedSummary);
}
- @Test
- public void testUpdatePreference_hasRemainingTime_showRemainingLabel() {
- mBatteryInfo.remainingLabel = TIME_LEFT;
-
- mFragment.updateHeaderPreference(mBatteryInfo);
-
- verify(mSummary1).setText(mBatteryInfo.remainingLabel);
- }
-
- @Test
- public void testUpdatePreference_updateBatteryInfo() {
- mBatteryInfo.remainingLabel = TIME_LEFT;
- mBatteryInfo.batteryLevel = BATTERY_LEVEL;
- mBatteryInfo.discharging = true;
-
- mFragment.updateHeaderPreference(mBatteryInfo);
-
- assertThat(mBatteryMeterView.mDrawable.getBatteryLevel()).isEqualTo(BATTERY_LEVEL);
- assertThat(mBatteryMeterView.mDrawable.getCharging()).isEqualTo(false);
- }
-
- @Test
- public void testUpdatePreference_noRemainingTime_showStatusLabel() {
- mBatteryInfo.remainingLabel = null;
-
- mFragment.updateHeaderPreference(mBatteryInfo);
-
- verify(mSummary1).setText(mBatteryInfo.statusLabel);
- }
-
- @Test
- public void testUpdateHeaderPreference_asyncUpdate_shouldNotCrash() {
- when(mFragment.getContext()).thenReturn(null);
- mBatteryInfo.remainingTimeUs = REMAINING_TIME_US;
-
- //Should not crash
- mFragment.updateHeaderPreference(mBatteryInfo);
- }
-
private void testToggleAllApps(final boolean isShowApps) {
mFragment.mShowAllApps = isShowApps;
diff --git a/tests/robotests/src/com/android/settings/nfc/PaymentSettingsTest.java b/tests/robotests/src/com/android/settings/nfc/PaymentSettingsTest.java
index 7e898fb..b54125e 100644
--- a/tests/robotests/src/com/android/settings/nfc/PaymentSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/nfc/PaymentSettingsTest.java
@@ -18,11 +18,11 @@
package com.android.settings.nfc;
import android.content.Context;
-
import android.content.pm.PackageManager;
-import android.content.pm.PackageParser;
+
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -33,7 +33,6 @@
import java.util.List;
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
@@ -67,6 +66,6 @@
when(mManager.hasSystemFeature(PackageManager.FEATURE_NFC)).thenReturn(true);
List<String> niks = mFragment.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
- assertThat(niks).isNull();
+ assertThat(niks).isEmpty();
}
}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/search/DatabaseIndexingManagerTest.java b/tests/robotests/src/com/android/settings/search/DatabaseIndexingManagerTest.java
index 85ad495..ab8891b 100644
--- a/tests/robotests/src/com/android/settings/search/DatabaseIndexingManagerTest.java
+++ b/tests/robotests/src/com/android/settings/search/DatabaseIndexingManagerTest.java
@@ -369,6 +369,7 @@
mContext.getString(R.string.fingerprint_swipe_for_notifications_title);
final String prefSummary =
mContext.getString(R.string.fingerprint_swipe_for_notifications_summary);
+ final String keywords = mContext.getString(R.string.keywords_gesture);
Cursor cursor = mDb.rawQuery(
"SELECT * FROM prefs_index where data_title='" + prefTitle + "'", null);
cursor.moveToFirst();
@@ -392,7 +393,7 @@
// Entries - only on for list preferences
assertThat(cursor.getString(8)).isNull();
// Keywords
- assertThat(cursor.getString(9)).isEmpty();
+ assertThat(cursor.getString(9)).isEqualTo(keywords);
// Screen Title
assertThat(cursor.getString(10)).isEqualTo(
mContext.getString(R.string.fingerprint_swipe_for_notifications_title));
diff --git a/tests/robotests/src/com/android/settings/search/FakeIndexProvider.java b/tests/robotests/src/com/android/settings/search/FakeIndexProvider.java
index 35486ef..69c2589 100644
--- a/tests/robotests/src/com/android/settings/search/FakeIndexProvider.java
+++ b/tests/robotests/src/com/android/settings/search/FakeIndexProvider.java
@@ -19,12 +19,12 @@
import android.content.Context;
import android.provider.SearchIndexableResource;
+
import com.android.settings.core.PreferenceController;
-import java.util.ArrayList;
import java.util.List;
-public class FakeIndexProvider implements Indexable {
+public class FakeIndexProvider implements Indexable {
public static final String KEY = "TestKey";
@@ -38,7 +38,7 @@
@Override
public List<String> getNonIndexableKeys(Context context) {
- ArrayList<String> result = new ArrayList<>();
+ List<String> result = super.getNonIndexableKeys(context);
result.add(KEY);
return result;
}