Merge "Fix battery usage screen issues" into mnc-dev
Before Width: | Height: | Size: 523 B |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 523 B |
Before Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 419 B |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 419 B |
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 582 B |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 582 B |
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 758 B After Width: | Height: | Size: 758 B |
Before Width: | Height: | Size: 932 B After Width: | Height: | Size: 932 B |
@@ -1,21 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
Copyright (C) 2015 The Android Open Source Project
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:src="@drawable/ic_settings_bluetooth2_alpha"
|
|
||||||
android:tint="?android:attr/colorAccent" />
|
|
||||||
|
|
@@ -1,21 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
Copyright (C) 2015 The Android Open Source Project
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:src="@drawable/ic_settings_wifi_alpha"
|
|
||||||
android:tint="?android:attr/colorAccent" />
|
|
||||||
|
|
@@ -36,7 +36,7 @@
|
|||||||
android:id="@+id/bluetooth_settings"
|
android:id="@+id/bluetooth_settings"
|
||||||
android:title="@string/bluetooth_settings_title"
|
android:title="@string/bluetooth_settings_title"
|
||||||
android:fragment="com.android.settings.bluetooth.BluetoothSettings"
|
android:fragment="com.android.settings.bluetooth.BluetoothSettings"
|
||||||
android:icon="@drawable/ic_settings_bluetooth2"
|
android:icon="@drawable/ic_settings_bluetooth"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- SIM Cards -->
|
<!-- SIM Cards -->
|
||||||
|
47
src/com/android/settings/TintablePreference.java
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
package com.android.settings;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.ColorStateList;
|
||||||
|
import android.preference.Preference;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
public class TintablePreference extends Preference {
|
||||||
|
|
||||||
|
private int mTintColor;
|
||||||
|
|
||||||
|
public TintablePreference(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTint(int color) {
|
||||||
|
mTintColor = color;
|
||||||
|
notifyChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onBindView(View view) {
|
||||||
|
super.onBindView(view);
|
||||||
|
|
||||||
|
if (mTintColor != 0) {
|
||||||
|
((ImageView) view.findViewById(R.id.icon)).setImageTintList(
|
||||||
|
ColorStateList.valueOf(mTintColor));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -222,7 +222,7 @@ public final class BluetoothDevicePreference extends Preference implements
|
|||||||
data.className = BluetoothSettings.class.getName();
|
data.className = BluetoothSettings.class.getName();
|
||||||
data.title = mCachedDevice.getName();
|
data.title = mCachedDevice.getName();
|
||||||
data.screenTitle = context.getResources().getString(R.string.bluetooth_settings);
|
data.screenTitle = context.getResources().getString(R.string.bluetooth_settings);
|
||||||
data.iconResId = R.drawable.ic_settings_bluetooth2;
|
data.iconResId = R.drawable.ic_settings_bluetooth;
|
||||||
data.enabled = true;
|
data.enabled = true;
|
||||||
|
|
||||||
Index.getInstance(context).updateFromSearchIndexableData(data);
|
Index.getInstance(context).updateFromSearchIndexableData(data);
|
||||||
@@ -268,6 +268,6 @@ public final class BluetoothDevicePreference extends Preference implements
|
|||||||
return R.drawable.ic_bt_headset_hfp;
|
return R.drawable.ic_bt_headset_hfp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return R.drawable.ic_settings_bluetooth2;
|
return R.drawable.ic_settings_bluetooth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -488,7 +488,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
|
|||||||
com.android.settings.bluetooth.Utils.updateSearchIndex(activity,
|
com.android.settings.bluetooth.Utils.updateSearchIndex(activity,
|
||||||
BluetoothSettings.class.getName(), device.getName(),
|
BluetoothSettings.class.getName(), device.getName(),
|
||||||
context.getResources().getString(R.string.bluetooth_settings),
|
context.getResources().getString(R.string.bluetooth_settings),
|
||||||
R.drawable.ic_settings_bluetooth2, false);
|
R.drawable.ic_settings_bluetooth, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -146,7 +146,7 @@ public class BatteryEntry {
|
|||||||
break;
|
break;
|
||||||
case WIFI:
|
case WIFI:
|
||||||
name = context.getResources().getString(R.string.power_wifi);
|
name = context.getResources().getString(R.string.power_wifi);
|
||||||
iconId = R.drawable.ic_settings_wifi;
|
iconId = R.drawable.ic_settings_wireless;
|
||||||
break;
|
break;
|
||||||
case BLUETOOTH:
|
case BLUETOOTH:
|
||||||
name = context.getResources().getString(R.string.power_bluetooth);
|
name = context.getResources().getString(R.string.power_bluetooth);
|
||||||
|
@@ -25,13 +25,14 @@ import android.widget.ProgressBar;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.TintablePreference;
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom preference for displaying power consumption as a bar and an icon on
|
* Custom preference for displaying power consumption as a bar and an icon on
|
||||||
* the left for the subsystem/app type.
|
* the left for the subsystem/app type.
|
||||||
*/
|
*/
|
||||||
public class PowerGaugePreference extends Preference {
|
public class PowerGaugePreference extends TintablePreference {
|
||||||
private BatteryEntry mInfo;
|
private BatteryEntry mInfo;
|
||||||
private int mProgress;
|
private int mProgress;
|
||||||
private CharSequence mProgressText;
|
private CharSequence mProgressText;
|
||||||
@@ -39,7 +40,7 @@ public class PowerGaugePreference extends Preference {
|
|||||||
|
|
||||||
public PowerGaugePreference(Context context, Drawable icon, CharSequence contentDescription,
|
public PowerGaugePreference(Context context, Drawable icon, CharSequence contentDescription,
|
||||||
BatteryEntry info) {
|
BatteryEntry info) {
|
||||||
super(context);
|
super(context, null);
|
||||||
setLayoutResource(R.layout.preference_app_percentage);
|
setLayoutResource(R.layout.preference_app_percentage);
|
||||||
setIcon(icon != null ? icon : new ColorDrawable(0));
|
setIcon(icon != null ? icon : new ColorDrawable(0));
|
||||||
mInfo = info;
|
mInfo = info;
|
||||||
|
@@ -28,6 +28,7 @@ import android.preference.Preference;
|
|||||||
import android.preference.PreferenceGroup;
|
import android.preference.PreferenceGroup;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.TypedValue;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@@ -35,12 +36,14 @@ import android.view.MenuItem;
|
|||||||
import com.android.internal.logging.MetricsLogger;
|
import com.android.internal.logging.MetricsLogger;
|
||||||
import com.android.internal.os.BatterySipper;
|
import com.android.internal.os.BatterySipper;
|
||||||
import com.android.internal.os.PowerProfile;
|
import com.android.internal.os.PowerProfile;
|
||||||
|
import com.android.internal.os.BatterySipper.DrainType;
|
||||||
import com.android.settings.HelpUtils;
|
import com.android.settings.HelpUtils;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.Settings.HighPowerApplicationsActivity;
|
import com.android.settings.Settings.HighPowerApplicationsActivity;
|
||||||
import com.android.settings.SettingsActivity;
|
import com.android.settings.SettingsActivity;
|
||||||
import com.android.settings.applications.ManageApplications;
|
import com.android.settings.applications.ManageApplications;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,6 +54,8 @@ public class PowerUsageSummary extends PowerUsageBase {
|
|||||||
|
|
||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
|
|
||||||
|
private static final boolean USE_FAKE_DATA = false;
|
||||||
|
|
||||||
static final String TAG = "PowerUsageSummary";
|
static final String TAG = "PowerUsageSummary";
|
||||||
|
|
||||||
private static final String KEY_APP_LIST = "app_list";
|
private static final String KEY_APP_LIST = "app_list";
|
||||||
@@ -184,18 +189,25 @@ public class PowerUsageSummary extends PowerUsageBase {
|
|||||||
final BatteryStats stats = mStatsHelper.getStats();
|
final BatteryStats stats = mStatsHelper.getStats();
|
||||||
final double averagePower = powerProfile.getAveragePower(PowerProfile.POWER_SCREEN_FULL);
|
final double averagePower = powerProfile.getAveragePower(PowerProfile.POWER_SCREEN_FULL);
|
||||||
|
|
||||||
if (averagePower >= MIN_AVERAGE_POWER_THRESHOLD_MILLI_AMP) {
|
TypedValue value = new TypedValue();
|
||||||
final List<BatterySipper> usageList = mStatsHelper.getUsageList();
|
getContext().getTheme().resolveAttribute(android.R.attr.colorControlNormal, value, true);
|
||||||
|
int colorControl = getContext().getColor(value.resourceId);
|
||||||
|
|
||||||
final int dischargeAmount = stats != null ? stats.getDischargeAmount(mStatsType) : 0;
|
if (averagePower >= MIN_AVERAGE_POWER_THRESHOLD_MILLI_AMP || USE_FAKE_DATA) {
|
||||||
|
final List<BatterySipper> usageList = USE_FAKE_DATA ? getFakeStats()
|
||||||
|
: mStatsHelper.getUsageList();
|
||||||
|
|
||||||
|
final int dischargeAmount = USE_FAKE_DATA ? 5000
|
||||||
|
: stats != null ? stats.getDischargeAmount(mStatsType) : 0;
|
||||||
final int numSippers = usageList.size();
|
final int numSippers = usageList.size();
|
||||||
for (int i = 0; i < numSippers; i++) {
|
for (int i = 0; i < numSippers; i++) {
|
||||||
final BatterySipper sipper = usageList.get(i);
|
final BatterySipper sipper = usageList.get(i);
|
||||||
if ((sipper.totalPowerMah * SECONDS_IN_HOUR) < MIN_POWER_THRESHOLD_MILLI_AMP) {
|
if ((sipper.totalPowerMah * SECONDS_IN_HOUR) < MIN_POWER_THRESHOLD_MILLI_AMP) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
double totalPower = USE_FAKE_DATA ? 4000 : mStatsHelper.getTotalPower();
|
||||||
final double percentOfTotal =
|
final double percentOfTotal =
|
||||||
((sipper.totalPowerMah / mStatsHelper.getTotalPower()) * dischargeAmount);
|
((sipper.totalPowerMah / totalPower) * dischargeAmount);
|
||||||
if (((int) (percentOfTotal + .5)) < 1) {
|
if (((int) (percentOfTotal + .5)) < 1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -243,6 +255,9 @@ public class PowerUsageSummary extends PowerUsageBase {
|
|||||||
if (sipper.uidObj != null) {
|
if (sipper.uidObj != null) {
|
||||||
pref.setKey(Integer.toString(sipper.uidObj.getUid()));
|
pref.setKey(Integer.toString(sipper.uidObj.getUid()));
|
||||||
}
|
}
|
||||||
|
if (sipper.drainType != DrainType.APP && sipper.drainType != DrainType.USER) {
|
||||||
|
pref.setTint(colorControl);
|
||||||
|
}
|
||||||
addedSome = true;
|
addedSome = true;
|
||||||
mAppListGroup.addPreference(pref);
|
mAppListGroup.addPreference(pref);
|
||||||
if (mAppListGroup.getPreferenceCount() > (MAX_ITEMS_TO_LIST + 1)) {
|
if (mAppListGroup.getPreferenceCount() > (MAX_ITEMS_TO_LIST + 1)) {
|
||||||
@@ -257,6 +272,19 @@ public class PowerUsageSummary extends PowerUsageBase {
|
|||||||
BatteryEntry.startRequestQueue();
|
BatteryEntry.startRequestQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static List<BatterySipper> getFakeStats() {
|
||||||
|
ArrayList<BatterySipper> stats = new ArrayList<>();
|
||||||
|
float use = 5;
|
||||||
|
for (DrainType type : DrainType.values()) {
|
||||||
|
if (type == DrainType.APP) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
stats.add(new BatterySipper(type, null, use));
|
||||||
|
use += 5;
|
||||||
|
}
|
||||||
|
return stats;
|
||||||
|
}
|
||||||
|
|
||||||
Handler mHandler = new Handler() {
|
Handler mHandler = new Handler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -91,7 +91,7 @@ public final class SearchIndexableResources {
|
|||||||
Ranking.getRankForClassName(BluetoothSettings.class.getName()),
|
Ranking.getRankForClassName(BluetoothSettings.class.getName()),
|
||||||
NO_DATA_RES_ID,
|
NO_DATA_RES_ID,
|
||||||
BluetoothSettings.class.getName(),
|
BluetoothSettings.class.getName(),
|
||||||
R.drawable.ic_settings_bluetooth2));
|
R.drawable.ic_settings_bluetooth));
|
||||||
|
|
||||||
sResMap.put(SimSettings.class.getName(),
|
sResMap.put(SimSettings.class.getName(),
|
||||||
new SearchIndexableResource(
|
new SearchIndexableResource(
|
||||||
|