Merge "Add some more logging to settings battery stuff" into oc-dr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
e4c9b7162d
@@ -32,6 +32,7 @@ import com.android.settings.graph.UsageView;
|
|||||||
* subsystem/app type.
|
* subsystem/app type.
|
||||||
*/
|
*/
|
||||||
public class BatteryHistoryPreference extends Preference {
|
public class BatteryHistoryPreference extends Preference {
|
||||||
|
private static final String TAG = "BatteryHistoryPreference";
|
||||||
|
|
||||||
private CharSequence mSummary;
|
private CharSequence mSummary;
|
||||||
private TextView mSummaryView;
|
private TextView mSummaryView;
|
||||||
@@ -73,6 +74,7 @@ public class BatteryHistoryPreference extends Preference {
|
|||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(PreferenceViewHolder view) {
|
public void onBindViewHolder(PreferenceViewHolder view) {
|
||||||
super.onBindViewHolder(view);
|
super.onBindViewHolder(view);
|
||||||
|
final long startTime = System.currentTimeMillis();
|
||||||
if (mBatteryInfo == null) {
|
if (mBatteryInfo == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -88,5 +90,6 @@ public class BatteryHistoryPreference extends Preference {
|
|||||||
UsageView usageView = (UsageView) view.findViewById(R.id.battery_usage);
|
UsageView usageView = (UsageView) view.findViewById(R.id.battery_usage);
|
||||||
usageView.findViewById(R.id.label_group).setAlpha(.7f);
|
usageView.findViewById(R.id.label_group).setAlpha(.7f);
|
||||||
mBatteryInfo.bindHistory(usageView);
|
mBatteryInfo.bindHistory(usageView);
|
||||||
|
BatteryUtils.logRuntime(TAG, "onBindViewHolder", startTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -136,14 +136,19 @@ public class BatteryInfo {
|
|||||||
|
|
||||||
public static void getBatteryInfo(final Context context, final Callback callback,
|
public static void getBatteryInfo(final Context context, final Callback callback,
|
||||||
boolean shortString) {
|
boolean shortString) {
|
||||||
|
final long startTime = System.currentTimeMillis();
|
||||||
BatteryStatsHelper statsHelper = new BatteryStatsHelper(context, true);
|
BatteryStatsHelper statsHelper = new BatteryStatsHelper(context, true);
|
||||||
statsHelper.create((Bundle) null);
|
statsHelper.create((Bundle) null);
|
||||||
|
BatteryUtils.logRuntime(LOG_TAG, "time to make batteryStatsHelper", startTime);
|
||||||
BatteryInfo.getBatteryInfo(context, callback, statsHelper, shortString);
|
BatteryInfo.getBatteryInfo(context, callback, statsHelper, shortString);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void getBatteryInfo(final Context context, final Callback callback,
|
public static void getBatteryInfo(final Context context, final Callback callback,
|
||||||
BatteryStatsHelper statsHelper, boolean shortString) {
|
BatteryStatsHelper statsHelper, boolean shortString) {
|
||||||
getBatteryInfo(context, callback, statsHelper.getStats(), shortString);
|
final long startTime = System.currentTimeMillis();
|
||||||
|
BatteryStats stats = statsHelper.getStats();
|
||||||
|
BatteryUtils.logRuntime(LOG_TAG, "time for getStats", startTime);
|
||||||
|
getBatteryInfo(context, callback, stats, shortString);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void getBatteryInfo(final Context context, final Callback callback,
|
public static void getBatteryInfo(final Context context, final Callback callback,
|
||||||
@@ -181,7 +186,9 @@ public class BatteryInfo {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(BatteryInfo batteryInfo) {
|
protected void onPostExecute(BatteryInfo batteryInfo) {
|
||||||
|
final long startTime = System.currentTimeMillis();
|
||||||
callback.onBatteryInfoLoaded(batteryInfo);
|
callback.onBatteryInfoLoaded(batteryInfo);
|
||||||
|
BatteryUtils.logRuntime(LOG_TAG, "time for callback", startTime);
|
||||||
}
|
}
|
||||||
}.execute();
|
}.execute();
|
||||||
}
|
}
|
||||||
|
@@ -167,6 +167,7 @@ public class PowerUsageAdvanced extends PowerUsageBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void refreshUi() {
|
protected void refreshUi() {
|
||||||
|
final long startTime = System.currentTimeMillis();
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
return;
|
return;
|
||||||
@@ -186,6 +187,7 @@ public class PowerUsageAdvanced extends PowerUsageBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BatteryEntry.startRequestQueue();
|
BatteryEntry.startRequestQueue();
|
||||||
|
BatteryUtils.logRuntime(TAG, "refreshUI", startTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
@@ -37,6 +37,7 @@ public abstract class PowerUsageBase extends DashboardFragment
|
|||||||
// +1 to allow ordering for PowerUsageSummary.
|
// +1 to allow ordering for PowerUsageSummary.
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final int MENU_STATS_REFRESH = Menu.FIRST + 1;
|
static final int MENU_STATS_REFRESH = Menu.FIRST + 1;
|
||||||
|
private static final String TAG = "PowerUsageBase";
|
||||||
|
|
||||||
protected BatteryStatsHelper mStatsHelper;
|
protected BatteryStatsHelper mStatsHelper;
|
||||||
protected UserManager mUm;
|
protected UserManager mUm;
|
||||||
@@ -89,7 +90,9 @@ public abstract class PowerUsageBase extends DashboardFragment
|
|||||||
protected abstract void refreshUi();
|
protected abstract void refreshUi();
|
||||||
|
|
||||||
protected void updatePreference(BatteryHistoryPreference historyPref) {
|
protected void updatePreference(BatteryHistoryPreference historyPref) {
|
||||||
|
final long startTime = System.currentTimeMillis();
|
||||||
historyPref.setStats(mStatsHelper);
|
historyPref.setStats(mStatsHelper);
|
||||||
|
BatteryUtils.logRuntime(TAG, "updatePreference", startTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -29,15 +29,18 @@ import android.graphics.Path;
|
|||||||
import android.graphics.Shader.TileMode;
|
import android.graphics.Shader.TileMode;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import android.util.Log;
|
||||||
import android.util.SparseIntArray;
|
import android.util.SparseIntArray;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import com.android.settings.fuelgauge.BatteryUtils;
|
||||||
import com.android.settingslib.R;
|
import com.android.settingslib.R;
|
||||||
|
|
||||||
public class UsageGraph extends View {
|
public class UsageGraph extends View {
|
||||||
|
|
||||||
private static final int PATH_DELIM = -1;
|
private static final int PATH_DELIM = -1;
|
||||||
|
public static final String LOG_TAG = "UsageGraph";
|
||||||
|
|
||||||
private final Paint mLinePaint;
|
private final Paint mLinePaint;
|
||||||
private final Paint mFillPaint;
|
private final Paint mFillPaint;
|
||||||
@@ -108,10 +111,12 @@ public class UsageGraph extends View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setMax(int maxX, int maxY) {
|
void setMax(int maxX, int maxY) {
|
||||||
|
final long startTime = System.currentTimeMillis();
|
||||||
mMaxX = maxX;
|
mMaxX = maxX;
|
||||||
mMaxY = maxY;
|
mMaxY = maxY;
|
||||||
calculateLocalPaths();
|
calculateLocalPaths();
|
||||||
postInvalidate();
|
postInvalidate();
|
||||||
|
BatteryUtils.logRuntime(LOG_TAG, "setMax", startTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDividerLoc(int height) {
|
void setDividerLoc(int height) {
|
||||||
@@ -133,6 +138,7 @@ public class UsageGraph extends View {
|
|||||||
|
|
||||||
private void addPathAndUpdate(SparseIntArray points, SparseIntArray paths,
|
private void addPathAndUpdate(SparseIntArray points, SparseIntArray paths,
|
||||||
SparseIntArray localPaths) {
|
SparseIntArray localPaths) {
|
||||||
|
final long startTime = System.currentTimeMillis();
|
||||||
for (int i = 0, size = points.size(); i < size; i++) {
|
for (int i = 0, size = points.size(); i < size; i++) {
|
||||||
paths.put(points.keyAt(i), points.valueAt(i));
|
paths.put(points.keyAt(i), points.valueAt(i));
|
||||||
}
|
}
|
||||||
@@ -140,6 +146,7 @@ public class UsageGraph extends View {
|
|||||||
paths.put(points.keyAt(points.size() - 1) + 1, PATH_DELIM);
|
paths.put(points.keyAt(points.size() - 1) + 1, PATH_DELIM);
|
||||||
calculateLocalPaths(paths, localPaths);
|
calculateLocalPaths(paths, localPaths);
|
||||||
postInvalidate();
|
postInvalidate();
|
||||||
|
BatteryUtils.logRuntime(LOG_TAG, "addPathAndUpdate", startTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAccentColor(int color) {
|
void setAccentColor(int color) {
|
||||||
@@ -151,9 +158,11 @@ public class UsageGraph extends View {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||||
|
final long startTime = System.currentTimeMillis();
|
||||||
super.onSizeChanged(w, h, oldw, oldh);
|
super.onSizeChanged(w, h, oldw, oldh);
|
||||||
updateGradient();
|
updateGradient();
|
||||||
calculateLocalPaths();
|
calculateLocalPaths();
|
||||||
|
BatteryUtils.logRuntime(LOG_TAG, "onSizeChanged", startTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void calculateLocalPaths() {
|
private void calculateLocalPaths() {
|
||||||
@@ -162,6 +171,7 @@ public class UsageGraph extends View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void calculateLocalPaths(SparseIntArray paths, SparseIntArray localPaths) {
|
private void calculateLocalPaths(SparseIntArray paths, SparseIntArray localPaths) {
|
||||||
|
final long startTime = System.currentTimeMillis();
|
||||||
if (getWidth() == 0) {
|
if (getWidth() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -194,6 +204,7 @@ public class UsageGraph extends View {
|
|||||||
localPaths.put(lx, ly);
|
localPaths.put(lx, ly);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BatteryUtils.logRuntime(LOG_TAG,"calculateLocalPaths", startTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasDiff(int x1, int x2) {
|
private boolean hasDiff(int x1, int x2) {
|
||||||
@@ -220,6 +231,7 @@ public class UsageGraph extends View {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDraw(Canvas canvas) {
|
protected void onDraw(Canvas canvas) {
|
||||||
|
final long startTime = System.currentTimeMillis();
|
||||||
// Draw lines across the top, middle, and bottom.
|
// Draw lines across the top, middle, and bottom.
|
||||||
if (mMiddleDividerLoc != 0) {
|
if (mMiddleDividerLoc != 0) {
|
||||||
drawDivider(0, canvas, mTopDividerTint);
|
drawDivider(0, canvas, mTopDividerTint);
|
||||||
@@ -235,6 +247,7 @@ public class UsageGraph extends View {
|
|||||||
drawLinePath(canvas, mLocalProjectedPaths, mDottedPaint);
|
drawLinePath(canvas, mLocalProjectedPaths, mDottedPaint);
|
||||||
drawFilledPath(canvas, mLocalPaths, mFillPaint);
|
drawFilledPath(canvas, mLocalPaths, mFillPaint);
|
||||||
drawLinePath(canvas, mLocalPaths, mLinePaint);
|
drawLinePath(canvas, mLocalPaths, mLinePaint);
|
||||||
|
BatteryUtils.logRuntime(LOG_TAG, "onDraw", startTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawLinePath(Canvas canvas, SparseIntArray localPaths, Paint paint) {
|
private void drawLinePath(Canvas canvas, SparseIntArray localPaths, Paint paint) {
|
||||||
|
Reference in New Issue
Block a user