diff options
author | Ruben Brunk <rubenbrunk@google.com> | 2015-06-03 18:53:40 -0700 |
---|---|---|
committer | Ruben Brunk <rubenbrunk@google.com> | 2015-06-05 16:05:18 -0700 |
commit | 2627190bac86184ce7bfb64f3bb44b98b8c03ff6 (patch) | |
tree | e5211f11a3ff53fa16557ae433caa59b06ff93df | |
parent | bbf031ab09b445964acb5e7356ba407dd3dc2d33 (diff) | |
download | packages_apps_Settings-2627190bac86184ce7bfb64f3bb44b98b8c03ff6.zip packages_apps_Settings-2627190bac86184ce7bfb64f3bb44b98b8c03ff6.tar.gz packages_apps_Settings-2627190bac86184ce7bfb64f3bb44b98b8c03ff6.tar.bz2 |
Add UI for camera + flashlight battery reporting.
Bug: 11694505
Change-Id: Idca51a2e8cc7c2fb3e9d10f84f94e66600dee6fa
-rw-r--r-- | res/drawable/ic_settings_camera.xml | 33 | ||||
-rw-r--r-- | res/values/strings.xml | 13 | ||||
-rw-r--r-- | src/com/android/settings/fuelgauge/BatteryEntry.java | 4 | ||||
-rw-r--r-- | src/com/android/settings/fuelgauge/BatteryHistoryChart.java | 96 | ||||
-rw-r--r-- | src/com/android/settings/fuelgauge/PowerUsageDetail.java | 7 |
5 files changed, 143 insertions, 10 deletions
diff --git a/res/drawable/ic_settings_camera.xml b/res/drawable/ic_settings_camera.xml new file mode 100644 index 0000000..5309270 --- /dev/null +++ b/res/drawable/ic_settings_camera.xml @@ -0,0 +1,33 @@ +<!-- + Copyright (C) 2015 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<vector xmlns:android="http://schemas.android.com/apk/res/android" + + android:width="24dp" + android:height="24dp" + android:viewportWidth="48" + android:viewportHeight="48" + android:autoMirrored="true"> + + <path android:fillColor="#000000" + android:pathData="M18.8 21l9.53-16.51C26.94 4.18 25.49 4 24 4c-4.8 0-9.19 1.69-12.64 + 4.51l7.33 12.69.11-.2zm24.28-3c-1.84-5.85-6.3-10.52-11.99-12.68L23.77 + 18h19.31zm.52 2H28.62l.58 1 9.53 16.5C41.99 33.94 44 29.21 44 + 24c0-1.37-.14-2.71-.4-4zm-26.53 4l-7.8-13.5C6.01 14.06 4 18.79 4 24c0 + 1.37.14 2.71.4 4h14.98l-2.31-4zM4.92 30c1.84 5.85 6.3 10.52 11.99 + 12.68L24.23 30H4.92zm22.54 0l-7.8 13.51c1.4.31 2.85.49 4.34.49 4.8 0 + 9.19-1.69 12.64-4.51L29.31 26.8 27.46 30z"/> +</vector> diff --git a/res/values/strings.xml b/res/values/strings.xml index 3bea360..03efefb 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -4023,6 +4023,10 @@ <string name="battery_stats_screen_on_label">Screen on</string> <!-- [CHAR LIMIT=25] Label for battery stats gps on state graph --> <string name="battery_stats_gps_on_label">GPS on</string> + <!-- [CHAR LIMIT=25] Label for battery stats camera on state graph --> + <string name="battery_stats_camera_on_label">Camera on</string> + <!-- [CHAR LIMIT=25] Label for battery stats flashlight on state graph --> + <string name="battery_stats_flashlight_on_label">Flashlight on</string> <!-- [CHAR LIMIT=25] Label for battery stats wifi running state graph --> <string name="battery_stats_wifi_running_label">Wi\u2011Fi</string> <!-- [CHAR LIMIT=25] Label for battery stats wake lock state graph --> @@ -4054,6 +4058,8 @@ <string name="power_screen">Screen</string> <!-- Label for power consumed by the flashlight --> <string name="power_flashlight">Flashlight</string> + <!-- Label for power consumed by the camera --> + <string name="power_camera">Camera</string> <!-- Label for power consumed by Wi-Fi --> <string name="power_wifi">Wi\u2011Fi</string> <!-- Label for power consumed by Bluetooth --> @@ -4099,6 +4105,10 @@ <string name="usage_type_audio">Audio</string> <!-- Label for Video usage time --> <string name="usage_type_video">Video</string> + <!-- Label for Camera usage time --> + <string name="usage_type_camera">Camera</string> + <!-- Label for Flashlight usage time --> + <string name="usage_type_flashlight">Flashlight</string> <!-- Label for time that a feature has been on --> <string name="usage_type_on_time">Time on</string> <!-- Label for time that there was no cell coverage --> @@ -4139,6 +4149,9 @@ <!-- [CHAR_LIMIT=NONE] Description for power consumed by the flashlight --> <string name="battery_desc_flashlight">Battery used by the flashlight</string> + <!-- [CHAR_LIMIT=NONE] Description for power consumed by the camera --> + <string name="battery_desc_camera">Battery used by the camera</string> + <!-- Description for power consumed by display --> <string name="battery_desc_display">Battery used by the display and backlight</string> <!-- Suggestion for reducing display power --> diff --git a/src/com/android/settings/fuelgauge/BatteryEntry.java b/src/com/android/settings/fuelgauge/BatteryEntry.java index be7c657..44e4665 100644 --- a/src/com/android/settings/fuelgauge/BatteryEntry.java +++ b/src/com/android/settings/fuelgauge/BatteryEntry.java @@ -182,6 +182,10 @@ public class BatteryEntry { name = context.getResources().getString(R.string.power_overcounted); iconId = R.drawable.ic_power_system; break; + case CAMERA: + name = context.getResources().getString(R.string.power_camera); + iconId = R.drawable.ic_settings_camera; + break; } if (iconId > 0) { icon = context.getDrawable(iconId); diff --git a/src/com/android/settings/fuelgauge/BatteryHistoryChart.java b/src/com/android/settings/fuelgauge/BatteryHistoryChart.java index 9ec0565..76acf69 100644 --- a/src/com/android/settings/fuelgauge/BatteryHistoryChart.java +++ b/src/com/android/settings/fuelgauge/BatteryHistoryChart.java @@ -131,6 +131,8 @@ public class BatteryHistoryChart extends View { final Paint mChargingPaint = new Paint(); final Paint mScreenOnPaint = new Paint(); final Paint mGpsOnPaint = new Paint(); + final Paint mFlashlightOnPaint = new Paint(); + final Paint mCameraOnPaint = new Paint(); final Paint mWifiRunningPaint = new Paint(); final Paint mCpuRunningPaint = new Paint(); final Paint mDateLinePaint = new Paint(); @@ -147,6 +149,8 @@ public class BatteryHistoryChart extends View { final Path mChargingPath = new Path(); final Path mScreenOnPath = new Path(); final Path mGpsOnPath = new Path(); + final Path mFlashlightOnPath = new Path(); + final Path mCameraOnPath = new Path(); final Path mWifiRunningPath = new Path(); final Path mCpuRunningPath = new Path(); final Path mDateLinePath = new Path(); @@ -164,6 +168,8 @@ public class BatteryHistoryChart extends View { String mChargingLabel; String mScreenOnLabel; String mGpsOnLabel; + String mCameraOnLabel; + String mFlashlightOnLabel; String mWifiRunningLabel; String mCpuRunningLabel; String mPhoneSignalLabel; @@ -195,6 +201,8 @@ public class BatteryHistoryChart extends View { int mChargingOffset; int mScreenOnOffset; int mGpsOnOffset; + int mFlashlightOnOffset; + int mCameraOnOffset; int mWifiRunningOffset; int mCpuRunningOffset; int mPhoneSignalOffset; @@ -217,6 +225,8 @@ public class BatteryHistoryChart extends View { boolean mHaveWifi; boolean mHaveGps; boolean mHavePhoneSignal; + boolean mHaveCamera; + boolean mHaveFlashlight; final ArrayList<TimeLabel> mTimeLabels = new ArrayList<TimeLabel>(); final ArrayList<DateLabel> mDateLabels = new ArrayList<DateLabel>(); @@ -367,6 +377,8 @@ public class BatteryHistoryChart extends View { mChargingPaint.setStyle(Paint.Style.STROKE); mScreenOnPaint.setStyle(Paint.Style.STROKE); mGpsOnPaint.setStyle(Paint.Style.STROKE); + mCameraOnPaint.setStyle(Paint.Style.STROKE); + mFlashlightOnPaint.setStyle(Paint.Style.STROKE); mWifiRunningPaint.setStyle(Paint.Style.STROKE); mCpuRunningPaint.setStyle(Paint.Style.STROKE); mPhoneSignalChart.setColors(com.android.settings.Utils.BADNESS_COLORS); @@ -374,6 +386,8 @@ public class BatteryHistoryChart extends View { mDebugRectPaint.setStyle(Paint.Style.STROKE); mScreenOnPaint.setColor(0xFF009688); mGpsOnPaint.setColor(0xFF009688); + mCameraOnPaint.setColor(0xFF009688); + mFlashlightOnPaint.setColor(0xFF009688); mWifiRunningPaint.setColor(0xFF009688); mCpuRunningPaint.setColor(0xFF009688); mChargingPaint.setColor(0xFF009688); @@ -435,6 +449,8 @@ public class BatteryHistoryChart extends View { mBatteryBackgroundPaint.setColor(a.getInt(attr, 0)); mScreenOnPaint.setColor(a.getInt(attr, 0)); mGpsOnPaint.setColor(a.getInt(attr, 0)); + mCameraOnPaint.setColor(a.getInt(attr, 0)); + mFlashlightOnPaint.setColor(a.getInt(attr, 0)); mWifiRunningPaint.setColor(a.getInt(attr, 0)); mCpuRunningPaint.setColor(a.getInt(attr, 0)); mChargingPaint.setColor(a.getInt(attr, 0)); @@ -485,6 +501,8 @@ public class BatteryHistoryChart extends View { mChargingLabel = getContext().getString(R.string.battery_stats_charging_label); mScreenOnLabel = getContext().getString(R.string.battery_stats_screen_on_label); mGpsOnLabel = getContext().getString(R.string.battery_stats_gps_on_label); + mCameraOnLabel = getContext().getString(R.string.battery_stats_camera_on_label); + mFlashlightOnLabel = getContext().getString(R.string.battery_stats_flashlight_on_label); mWifiRunningLabel = getContext().getString(R.string.battery_stats_wifi_running_label); mCpuRunningLabel = getContext().getString(R.string.battery_stats_wake_lock_label); mPhoneSignalLabel = getContext().getString(R.string.battery_stats_phone_signal_label); @@ -599,6 +617,8 @@ public class BatteryHistoryChart extends View { mEndWallTime = mEndDataWallTime + (remainingTimeUs/1000); mNumHist = lastInteresting; mHaveGps = (aggrStates&HistoryItem.STATE_GPS_ON_FLAG) != 0; + mHaveFlashlight = (aggrStates2&HistoryItem.STATE2_FLASHLIGHT_FLAG) != 0; + mHaveCamera = (aggrStates2&HistoryItem.STATE2_CAMERA_FLAG) != 0; mHaveWifi = (aggrStates2&HistoryItem.STATE2_WIFI_RUNNING_FLAG) != 0 || (aggrStates&(HistoryItem.STATE_WIFI_FULL_LOCK_FLAG |HistoryItem.STATE_WIFI_MULTICAST_ON_FLAG @@ -628,7 +648,8 @@ public class BatteryHistoryChart extends View { void finishPaths(int w, int h, int levelh, int startX, int y, Path curLevelPath, int lastX, boolean lastCharging, boolean lastScreenOn, boolean lastGpsOn, - boolean lastWifiRunning, boolean lastCpuRunning, Path lastPath) { + boolean lastFlashlightOn, boolean lastCameraOn, boolean lastWifiRunning, + boolean lastCpuRunning, Path lastPath) { if (curLevelPath != null) { if (lastX >= 0 && lastX < w) { if (lastPath != null) { @@ -650,6 +671,12 @@ public class BatteryHistoryChart extends View { if (lastGpsOn) { mGpsOnPath.lineTo(w, h-mGpsOnOffset); } + if (lastFlashlightOn) { + mFlashlightOnPath.lineTo(w, h-mFlashlightOnOffset); + } + if (lastCameraOn) { + mCameraOnPath.lineTo(w, h-mCameraOnOffset); + } if (lastWifiRunning) { mWifiRunningPath.lineTo(w, h-mWifiRunningOffset); } @@ -720,6 +747,8 @@ public class BatteryHistoryChart extends View { mChargingPaint.setStrokeWidth(mLineWidth); mScreenOnPaint.setStrokeWidth(mLineWidth); mGpsOnPaint.setStrokeWidth(mLineWidth); + mCameraOnPaint.setStrokeWidth(mLineWidth); + mFlashlightOnPaint.setStrokeWidth(mLineWidth); mWifiRunningPaint.setStrokeWidth(mLineWidth); mCpuRunningPaint.setStrokeWidth(mLineWidth); mDebugRectPaint.setStrokeWidth(1); @@ -732,15 +761,18 @@ public class BatteryHistoryChart extends View { mCpuRunningOffset = mScreenOnOffset + fullBarOffset; mWifiRunningOffset = mCpuRunningOffset + fullBarOffset; mGpsOnOffset = mWifiRunningOffset + (mHaveWifi ? fullBarOffset : 0); - mPhoneSignalOffset = mGpsOnOffset + (mHaveGps ? fullBarOffset : 0); + mFlashlightOnOffset = mGpsOnOffset + (mHaveGps ? fullBarOffset : 0); + mCameraOnOffset = mFlashlightOnOffset + (mHaveFlashlight ? fullBarOffset : 0); + mPhoneSignalOffset = mCameraOnOffset + (mHaveCamera ? fullBarOffset : 0); mLevelOffset = mPhoneSignalOffset + (mHavePhoneSignal ? fullBarOffset : 0) + mLineWidth*2 + mLineWidth/2; if (mHavePhoneSignal) { mPhoneSignalChart.init(w); } } else { - mScreenOnOffset = mGpsOnOffset = mWifiRunningOffset - = mCpuRunningOffset = mChargingOffset = mPhoneSignalOffset = 0; + mScreenOnOffset = mGpsOnOffset = mCameraOnOffset = mFlashlightOnOffset = + mWifiRunningOffset = mCpuRunningOffset = mChargingOffset = + mPhoneSignalOffset = 0; mLevelOffset = fullBarOffset + mThinLineWidth*4; if (mHavePhoneSignal) { mPhoneSignalChart.init(0); @@ -754,6 +786,8 @@ public class BatteryHistoryChart extends View { mBatCriticalPath.reset(); mScreenOnPath.reset(); mGpsOnPath.reset(); + mFlashlightOnPath.reset(); + mCameraOnPath.reset(); mWifiRunningPath.reset(); mCpuRunningPath.reset(); mChargingPath.reset(); @@ -778,6 +812,7 @@ public class BatteryHistoryChart extends View { Path curLevelPath = null; Path lastLinePath = null; boolean lastCharging = false, lastScreenOn = false, lastGpsOn = false; + boolean lastFlashlightOn = false, lastCameraOn = false; boolean lastWifiRunning = false, lastWifiSupplRunning = false, lastCpuRunning = false; int lastWifiSupplState = BatteryStats.WIFI_SUPPL_STATE_INVALID; final int N = mNumHist; @@ -871,6 +906,28 @@ public class BatteryHistoryChart extends View { lastGpsOn = gpsOn; } + final boolean flashlightOn = + (rec.states2&HistoryItem.STATE2_FLASHLIGHT_FLAG) != 0; + if (flashlightOn != lastFlashlightOn) { + if (flashlightOn) { + mFlashlightOnPath.moveTo(x, h-mFlashlightOnOffset); + } else { + mFlashlightOnPath.lineTo(x, h-mFlashlightOnOffset); + } + lastFlashlightOn = flashlightOn; + } + + final boolean cameraOn = + (rec.states2&HistoryItem.STATE2_CAMERA_FLAG) != 0; + if (cameraOn != lastCameraOn) { + if (cameraOn) { + mCameraOnPath.moveTo(x, h-mCameraOnOffset); + } else { + mCameraOnPath.lineTo(x, h-mCameraOnOffset); + } + lastCameraOn = cameraOn; + } + final int wifiSupplState = ((rec.states2&HistoryItem.STATE2_WIFI_SUPPL_STATE_MASK) >> HistoryItem.STATE2_WIFI_SUPPL_STATE_SHIFT); @@ -952,12 +1009,13 @@ public class BatteryHistoryChart extends View { || Math.abs(lastWalltime-curWalltime) > (60*60*1000))) { if (curLevelPath != null) { finishPaths(x+1, h, levelh, startX, lastY, curLevelPath, lastX, - lastCharging, lastScreenOn, lastGpsOn, lastWifiRunning, - lastCpuRunning, lastLinePath); + lastCharging, lastScreenOn, lastGpsOn, lastFlashlightOn, + lastCameraOn, lastWifiRunning, lastCpuRunning, lastLinePath); lastX = lastY = -1; curLevelPath = null; lastLinePath = null; - lastCharging = lastScreenOn = lastGpsOn = lastCpuRunning = false; + lastCharging = lastScreenOn = lastGpsOn = lastFlashlightOn = + lastCameraOn = lastCpuRunning = false; } } } @@ -992,8 +1050,8 @@ public class BatteryHistoryChart extends View { } finishPaths(x, h, levelh, startX, lastY, curLevelPath, lastX, - lastCharging, lastScreenOn, lastGpsOn, lastWifiRunning, - lastCpuRunning, lastLinePath); + lastCharging, lastScreenOn, lastGpsOn, lastFlashlightOn, lastCameraOn, + lastWifiRunning, lastCpuRunning, lastLinePath); if (x < w) { // If we reserved room for the remaining time, create a final path to draw @@ -1237,6 +1295,18 @@ public class BatteryHistoryChart extends View { canvas.drawPath(mGpsOnPath, mGpsOnPaint); } } + if (mHaveFlashlight) { + if (!mFlashlightOnPath.isEmpty()) { + if (DEBUG) Log.d(TAG, "Drawing flashlight path"); + canvas.drawPath(mFlashlightOnPath, mFlashlightOnPaint); + } + } + if (mHaveCamera) { + if (!mCameraOnPath.isEmpty()) { + if (DEBUG) Log.d(TAG, "Drawing camera path"); + canvas.drawPath(mCameraOnPath, mCameraOnPaint); + } + } if (mHaveWifi) { if (!mWifiRunningPath.isEmpty()) { if (DEBUG) Log.d(TAG, "Drawing wifi path"); @@ -1260,6 +1330,14 @@ public class BatteryHistoryChart extends View { canvas.drawText(mGpsOnLabel, textStartX, height - mGpsOnOffset - mTextDescent, mTextPaint); } + if (mHaveFlashlight) { + canvas.drawText(mFlashlightOnLabel, textStartX, + height - mFlashlightOnOffset - mTextDescent, mTextPaint); + } + if (mHaveCamera) { + canvas.drawText(mCameraOnLabel, textStartX, + height - mCameraOnOffset - mTextDescent, mTextPaint); + } if (mHaveWifi) { canvas.drawText(mWifiRunningLabel, textStartX, height - mWifiRunningOffset - mTextDescent, mTextPaint); diff --git a/src/com/android/settings/fuelgauge/PowerUsageDetail.java b/src/com/android/settings/fuelgauge/PowerUsageDetail.java index 6313ff5..5cb6c24 100644 --- a/src/com/android/settings/fuelgauge/PowerUsageDetail.java +++ b/src/com/android/settings/fuelgauge/PowerUsageDetail.java @@ -80,6 +80,7 @@ public class PowerUsageDetail extends PowerUsageBase implements Button.OnClickLi R.string.battery_desc_users, R.string.battery_desc_unaccounted, R.string.battery_desc_overcounted, + R.string.battery_desc_camera, }; public static void startBatteryDetailPage( @@ -126,6 +127,8 @@ public class PowerUsageDetail extends PowerUsageBase implements Button.OnClickLi R.string.usage_type_data_wifi_send, R.string.usage_type_audio, R.string.usage_type_video, + R.string.usage_type_camera, + R.string.usage_type_flashlight, }; values = new double[] { entry.sipper.cpuTimeMs, @@ -139,7 +142,9 @@ public class PowerUsageDetail extends PowerUsageBase implements Button.OnClickLi entry.sipper.wifiRxPackets, entry.sipper.wifiTxPackets, 0, - 0 + 0, + entry.sipper.cameraTimeMs, + entry.sipper.flashlightTimeMs, }; if (entry.sipper.drainType == BatterySipper.DrainType.APP) { |