Merge "Misc fixes to search and UI."
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 489bfd7..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] -->
@@ -7441,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>
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/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 9eb10c8..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 :
diff --git a/src/com/android/settings/fuelgauge/anomaly/AnomalyDetectionPolicy.java b/src/com/android/settings/fuelgauge/anomaly/AnomalyDetectionPolicy.java
index eacb31f..603bca0 100644
--- a/src/com/android/settings/fuelgauge/anomaly/AnomalyDetectionPolicy.java
+++ b/src/com/android/settings/fuelgauge/anomaly/AnomalyDetectionPolicy.java
@@ -35,7 +35,11 @@
     @VisibleForTesting
     static final String KEY_WAKELOCK_DETECTION_ENABLED = "wakelock_enabled";
     @VisibleForTesting
+    static final String KEY_WAKEUP_ALARM_DETECTION_ENABLED = "wakeup_alarm_enabled";
+    @VisibleForTesting
     static final String KEY_WAKELOCK_THRESHOLD = "wakelock_threshold";
+    @VisibleForTesting
+    static final String KEY_WAKEUP_ALARM_THRESHOLD = "wakeup_alarm_threshold";
 
     /**
      * {@code true} if general anomaly detection is enabled
@@ -54,6 +58,14 @@
     public final boolean wakeLockDetectionEnabled;
 
     /**
+     * {@code true} if wakeup alarm detection is enabled
+     *
+     * @see Settings.Global#ANOMALY_DETECTION_CONSTANTS
+     * @see #KEY_WAKEUP_ALARM_DETECTION_ENABLED
+     */
+    public final boolean wakeupAlarmDetectionEnabled;
+
+    /**
      * Threshold for wakelock time in milli seconds
      *
      * @see Settings.Global#ANOMALY_DETECTION_CONSTANTS
@@ -61,6 +73,14 @@
      */
     public final long wakeLockThreshold;
 
+    /**
+     * Threshold for wakeup alarm count per hour
+     *
+     * @see Settings.Global#ANOMALY_DETECTION_CONSTANTS
+     * @see #KEY_WAKEUP_ALARM_THRESHOLD
+     */
+    public final long wakeupAlarmThreshold;
+
     private final KeyValueListParserWrapper mParserWrapper;
 
     public AnomalyDetectionPolicy(Context context) {
@@ -81,8 +101,11 @@
 
         anomalyDetectionEnabled = mParserWrapper.getBoolean(KEY_ANOMALY_DETECTION_ENABLED, true);
         wakeLockDetectionEnabled = mParserWrapper.getBoolean(KEY_WAKELOCK_DETECTION_ENABLED, true);
+        wakeupAlarmDetectionEnabled = mParserWrapper.getBoolean(KEY_WAKEUP_ALARM_DETECTION_ENABLED,
+                true);
         wakeLockThreshold = mParserWrapper.getLong(KEY_WAKELOCK_THRESHOLD,
                 DateUtils.HOUR_IN_MILLIS);
+        wakeupAlarmThreshold = mParserWrapper.getLong(KEY_WAKEUP_ALARM_THRESHOLD, 60);
     }
 
 }
diff --git a/src/com/android/settings/fuelgauge/anomaly/checker/WakeupAlarmAnomalyDetector.java b/src/com/android/settings/fuelgauge/anomaly/checker/WakeupAlarmAnomalyDetector.java
index 82c009e..b97fd46 100644
--- a/src/com/android/settings/fuelgauge/anomaly/checker/WakeupAlarmAnomalyDetector.java
+++ b/src/com/android/settings/fuelgauge/anomaly/checker/WakeupAlarmAnomalyDetector.java
@@ -39,15 +39,20 @@
  */
 public class WakeupAlarmAnomalyDetector implements AnomalyDetector {
     private static final String TAG = "WakeupAlarmAnomalyDetector";
-    //TODO: add this threshold into AnomalyDetectionPolicy
-    private static final int WAKEUP_ALARM_THRESHOLD = 60;
-    private Context mContext;
     @VisibleForTesting
     BatteryUtils mBatteryUtils;
+    private long mWakeupAlarmThreshold;
+    private Context mContext;
 
     public WakeupAlarmAnomalyDetector(Context context) {
+        this(context, new AnomalyDetectionPolicy(context));
+    }
+
+    @VisibleForTesting
+    WakeupAlarmAnomalyDetector(Context context, AnomalyDetectionPolicy policy) {
         mContext = context;
         mBatteryUtils = BatteryUtils.getInstance(context);
+        mWakeupAlarmThreshold = policy.wakeupAlarmThreshold;
     }
 
     @Override
@@ -66,7 +71,7 @@
                 }
 
                 final int wakeups = getWakeupAlarmCountFromUid(uid);
-                if ((wakeups / totalRunningHours) > WAKEUP_ALARM_THRESHOLD) {
+                if ((wakeups / totalRunningHours) > mWakeupAlarmThreshold) {
                     final String packageName = mBatteryUtils.getPackageName(uid.getUid());
                     final CharSequence displayName = Utils.getApplicationLabel(mContext,
                             packageName);
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/fuelgauge/anomaly/AnomalyDetectionPolicyTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyDetectionPolicyTest.java
index bb8bac5..2cd6b9e 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyDetectionPolicyTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyDetectionPolicyTest.java
@@ -42,7 +42,9 @@
 public class AnomalyDetectionPolicyTest {
     private static final String ANOMALY_DETECTION_CONSTANTS_VALUE = "anomaly_detection_enabled=true"
             + ",wakelock_enabled=false"
-            + ",wakelock_threshold=3000";
+            + ",wakelock_threshold=3000"
+            + ",wakeup_alarm_enabled=true"
+            + ",wakeup_alarm_threshold=100";
     private Context mContext;
     private KeyValueListParserWrapper mKeyValueListParserWrapper;
 
@@ -62,6 +64,8 @@
                 AnomalyDetectionPolicy.KEY_ANOMALY_DETECTION_ENABLED, true);
         doReturn(false).when(mKeyValueListParserWrapper).getBoolean(
                 AnomalyDetectionPolicy.KEY_WAKELOCK_DETECTION_ENABLED, true);
+        doReturn(true).when(mKeyValueListParserWrapper).getBoolean(
+                AnomalyDetectionPolicy.KEY_WAKEUP_ALARM_DETECTION_ENABLED, true);
 
         AnomalyDetectionPolicy anomalyDetectionPolicy = new AnomalyDetectionPolicy(mContext,
                 mKeyValueListParserWrapper);
@@ -69,6 +73,8 @@
         assertThat(anomalyDetectionPolicy.anomalyDetectionEnabled).isTrue();
         assertThat(anomalyDetectionPolicy.wakeLockDetectionEnabled).isFalse();
         assertThat(anomalyDetectionPolicy.wakeLockThreshold).isEqualTo(3000);
+        assertThat(anomalyDetectionPolicy.wakeupAlarmDetectionEnabled).isTrue();
+        assertThat(anomalyDetectionPolicy.wakeupAlarmThreshold).isEqualTo(100);
     }
 
     @Test
@@ -85,5 +91,7 @@
         assertThat(anomalyDetectionPolicy.anomalyDetectionEnabled).isTrue();
         assertThat(anomalyDetectionPolicy.wakeLockDetectionEnabled).isTrue();
         assertThat(anomalyDetectionPolicy.wakeLockThreshold).isEqualTo(DateUtils.HOUR_IN_MILLIS);
+        assertThat(anomalyDetectionPolicy.wakeupAlarmDetectionEnabled).isTrue();
+        assertThat(anomalyDetectionPolicy.wakeupAlarmThreshold).isEqualTo(60);
     }
 }
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/checker/WakeupAlarmAnomalyDetectorTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/checker/WakeupAlarmAnomalyDetectorTest.java
index 826694d..2e1b7fb 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/checker/WakeupAlarmAnomalyDetectorTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/checker/WakeupAlarmAnomalyDetectorTest.java
@@ -39,6 +39,7 @@
 import com.android.settings.TestConfig;
 import com.android.settings.fuelgauge.BatteryUtils;
 import com.android.settings.fuelgauge.anomaly.Anomaly;
+import com.android.settings.fuelgauge.anomaly.AnomalyDetectionPolicy;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -47,6 +48,7 @@
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
+import org.robolectric.util.ReflectionHelpers;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -77,6 +79,8 @@
     private BatteryStats.Uid.Pkg mPkg;
     @Mock
     private BatteryStats.Counter mCounter;
+    @Mock
+    private AnomalyDetectionPolicy mPolicy;
 
     private WakeupAlarmAnomalyDetector mWakeupAlarmAnomalyDetector;
     private Context mContext;
@@ -87,6 +91,7 @@
         MockitoAnnotations.initMocks(this);
 
         mContext = spy(RuntimeEnvironment.application);
+        ReflectionHelpers.setField(mPolicy, "wakeupAlarmThreshold", 60);
 
         doReturn(false).when(mBatteryUtils).shouldHideSipper(any());
         doReturn(RUNNING_TIME_MS).when(mBatteryUtils).calculateRunningTimeBasedOnStatsType(any(),
@@ -102,7 +107,7 @@
         mUsageList.add(mNormalSipper);
         doReturn(mUsageList).when(mBatteryStatsHelper).getUsageList();
 
-        mWakeupAlarmAnomalyDetector = spy(new WakeupAlarmAnomalyDetector(mContext));
+        mWakeupAlarmAnomalyDetector = spy(new WakeupAlarmAnomalyDetector(mContext, mPolicy));
         mWakeupAlarmAnomalyDetector.mBatteryUtils = mBatteryUtils;
     }