Remove some debugging log to avoid print too much data out
Fixes: 194251993 Fixes: 194021631 Test: make SettingsRoboTests Change-Id: Ibd1c7ce9d664820b2975039582a1ea5fb18b0be1
This commit is contained in:
@@ -173,6 +173,9 @@ public class AppBatteryPreferenceController extends BasePreferenceController
|
|||||||
new AsyncTask<Void, Void, BatteryDiffEntry>() {
|
new AsyncTask<Void, Void, BatteryDiffEntry>() {
|
||||||
@Override
|
@Override
|
||||||
protected BatteryDiffEntry doInBackground(Void... unused) {
|
protected BatteryDiffEntry doInBackground(Void... unused) {
|
||||||
|
if (mPackageName == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
final List<BatteryDiffEntry> batteryDiffEntries =
|
final List<BatteryDiffEntry> batteryDiffEntries =
|
||||||
BatteryChartPreferenceController.getBatteryLast24HrUsageData(mContext);
|
BatteryChartPreferenceController.getBatteryLast24HrUsageData(mContext);
|
||||||
if (batteryDiffEntries == null) {
|
if (batteryDiffEntries == null) {
|
||||||
@@ -186,8 +189,7 @@ public class AppBatteryPreferenceController extends BasePreferenceController
|
|||||||
== ConvertUtils.CONSUMER_TYPE_UID_BATTERY)
|
== ConvertUtils.CONSUMER_TYPE_UID_BATTERY)
|
||||||
.filter(entry -> entry.mBatteryHistEntry.mUserId == mUserId)
|
.filter(entry -> entry.mBatteryHistEntry.mUserId == mUserId)
|
||||||
.filter(entry -> {
|
.filter(entry -> {
|
||||||
if (entry.mBatteryHistEntry.mPackageName
|
if (mPackageName.equals(entry.getPackageName())) {
|
||||||
.equals(mPackageName)) {
|
|
||||||
Log.i(TAG, "Return target application: "
|
Log.i(TAG, "Return target application: "
|
||||||
+ entry.mBatteryHistEntry.mPackageName
|
+ entry.mBatteryHistEntry.mPackageName
|
||||||
+ " | uid: " + entry.mBatteryHistEntry.mUid
|
+ " | uid: " + entry.mBatteryHistEntry.mUid
|
||||||
|
@@ -226,8 +226,8 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
|||||||
new Pair(ConvertUtils.METRIC_KEY_PACKAGE, packageName),
|
new Pair(ConvertUtils.METRIC_KEY_PACKAGE, packageName),
|
||||||
new Pair(ConvertUtils.METRIC_KEY_BATTERY_LEVEL, histEntry.mBatteryLevel),
|
new Pair(ConvertUtils.METRIC_KEY_BATTERY_LEVEL, histEntry.mBatteryLevel),
|
||||||
new Pair(ConvertUtils.METRIC_KEY_BATTERY_USAGE, powerPref.getPercent()));
|
new Pair(ConvertUtils.METRIC_KEY_BATTERY_USAGE, powerPref.getPercent()));
|
||||||
Log.d(TAG, String.format("handleClick() label=%s key=%s enntry=\n%s",
|
Log.d(TAG, String.format("handleClick() label=%s key=%s package=%s",
|
||||||
diffEntry.getAppLabel(), histEntry.getKey(), histEntry));
|
diffEntry.getAppLabel(), histEntry.getKey(), histEntry.mPackageName));
|
||||||
AdvancedPowerUsageDetail.startBatteryDetailPage(
|
AdvancedPowerUsageDetail.startBatteryDetailPage(
|
||||||
mActivity, mFragment, diffEntry, powerPref.getPercent(),
|
mActivity, mFragment, diffEntry, powerPref.getPercent(),
|
||||||
isValidToShowSummary(packageName), getSlotInformation());
|
isValidToShowSummary(packageName), getSlotInformation());
|
||||||
@@ -285,9 +285,10 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
|||||||
}
|
}
|
||||||
forceRefreshUi();
|
forceRefreshUi();
|
||||||
Log.d(TAG, String.format(
|
Log.d(TAG, String.format(
|
||||||
"setBatteryHistoryMap() size=%d\nkeys=%s\nlevels=%s",
|
"setBatteryHistoryMap() size=%d key=%s\nlevels=%s",
|
||||||
batteryHistoryMap.size(),
|
batteryHistoryMap.size(),
|
||||||
utcToLocalTime(mPrefContext, mBatteryHistoryKeys),
|
ConvertUtils.utcToLocalTime(mPrefContext,
|
||||||
|
mBatteryHistoryKeys[mBatteryHistoryKeys.length - 1]),
|
||||||
Arrays.toString(mBatteryHistoryLevels)));
|
Arrays.toString(mBatteryHistoryLevels)));
|
||||||
|
|
||||||
// Loads item icon and label in the background.
|
// Loads item icon and label in the background.
|
||||||
@@ -403,14 +404,14 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
|||||||
final String appLabel = entry.getAppLabel();
|
final String appLabel = entry.getAppLabel();
|
||||||
final Drawable appIcon = entry.getAppIcon();
|
final Drawable appIcon = entry.getAppIcon();
|
||||||
if (TextUtils.isEmpty(appLabel) || appIcon == null) {
|
if (TextUtils.isEmpty(appLabel) || appIcon == null) {
|
||||||
Log.w(TAG, "cannot find app resource for\n" + entry);
|
Log.w(TAG, "cannot find app resource for:" + entry.getPackageName());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final String prefKey = entry.mBatteryHistEntry.getKey();
|
final String prefKey = entry.mBatteryHistEntry.getKey();
|
||||||
PowerGaugePreference pref = mAppListPrefGroup.findPreference(prefKey);
|
PowerGaugePreference pref = mAppListPrefGroup.findPreference(prefKey);
|
||||||
if (pref != null) {
|
if (pref != null) {
|
||||||
isAdded = true;
|
isAdded = true;
|
||||||
Log.w(TAG, "preference should be removed for\n" + entry);
|
Log.w(TAG, "preference should be removed for:" + entry.getPackageName());
|
||||||
} else {
|
} else {
|
||||||
pref = (PowerGaugePreference) mPreferenceCache.get(prefKey);
|
pref = (PowerGaugePreference) mPreferenceCache.get(prefKey);
|
||||||
}
|
}
|
||||||
@@ -587,15 +588,6 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
|||||||
mHandler.post(() -> mPreferenceScreen.addPreference(mFooterPreference));
|
mHandler.post(() -> mPreferenceScreen.addPreference(mFooterPreference));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String utcToLocalTime(Context context, long[] timestamps) {
|
|
||||||
final StringBuilder builder = new StringBuilder();
|
|
||||||
for (int index = 0; index < timestamps.length; index++) {
|
|
||||||
builder.append(String.format("%s| ",
|
|
||||||
ConvertUtils.utcToLocalTime(context, timestamps[index])));
|
|
||||||
}
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean contains(String target, CharSequence[] packageNames) {
|
private static boolean contains(String target, CharSequence[] packageNames) {
|
||||||
if (target != null && packageNames != null) {
|
if (target != null && packageNames != null) {
|
||||||
for (CharSequence packageName : packageNames) {
|
for (CharSequence packageName : packageNames) {
|
||||||
|
@@ -139,6 +139,7 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
|
|||||||
|
|
||||||
/** Sets all levels value to draw the trapezoid shape */
|
/** Sets all levels value to draw the trapezoid shape */
|
||||||
public void setLevels(int[] levels) {
|
public void setLevels(int[] levels) {
|
||||||
|
Log.d(TAG, "setLevels() " + (levels == null ? "null" : levels.length));
|
||||||
if (levels == null) {
|
if (levels == null) {
|
||||||
mLevels = null;
|
mLevels = null;
|
||||||
return;
|
return;
|
||||||
|
@@ -22,6 +22,7 @@ import java.time.Duration;
|
|||||||
|
|
||||||
/** A container class to carry data from {@link ContentValues}. */
|
/** A container class to carry data from {@link ContentValues}. */
|
||||||
public class BatteryHistEntry {
|
public class BatteryHistEntry {
|
||||||
|
private static final boolean DEBUG = false;
|
||||||
private static final String TAG = "BatteryHistEntry";
|
private static final String TAG = "BatteryHistEntry";
|
||||||
|
|
||||||
/** Keys for accessing {@link ContentValues} or {@link Cursor}. */
|
/** Keys for accessing {@link ContentValues} or {@link Cursor}. */
|
||||||
@@ -316,10 +317,12 @@ public class BatteryHistEntry {
|
|||||||
if (upperHistEntry.mConsumePower < consumePower
|
if (upperHistEntry.mConsumePower < consumePower
|
||||||
|| upperHistEntry.mForegroundUsageTimeInMs < foregroundUsageTimeInMs
|
|| upperHistEntry.mForegroundUsageTimeInMs < foregroundUsageTimeInMs
|
||||||
|| upperHistEntry.mBackgroundUsageTimeInMs < backgroundUsageTimeInMs) {
|
|| upperHistEntry.mBackgroundUsageTimeInMs < backgroundUsageTimeInMs) {
|
||||||
|
if (DEBUG) {
|
||||||
Log.w(TAG, String.format(
|
Log.w(TAG, String.format(
|
||||||
"abnormal interpolation:\nupper:%s\nlower:%s",
|
"abnormal interpolation:\nupper:%s\nlower:%s",
|
||||||
upperHistEntry, lowerHistEntry));
|
upperHistEntry, lowerHistEntry));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
final double batteryLevel =
|
final double batteryLevel =
|
||||||
lowerHistEntry == null
|
lowerHistEntry == null
|
||||||
? upperHistEntry.mBatteryLevel
|
? upperHistEntry.mBatteryLevel
|
||||||
|
@@ -41,6 +41,7 @@ import java.util.TimeZone;
|
|||||||
|
|
||||||
/** A utility class to convert data into another types. */
|
/** A utility class to convert data into another types. */
|
||||||
public final class ConvertUtils {
|
public final class ConvertUtils {
|
||||||
|
private static final boolean DEBUG = false;
|
||||||
private static final String TAG = "ConvertUtils";
|
private static final String TAG = "ConvertUtils";
|
||||||
private static final Map<String, BatteryHistEntry> EMPTY_BATTERY_MAP = new HashMap<>();
|
private static final Map<String, BatteryHistEntry> EMPTY_BATTERY_MAP = new HashMap<>();
|
||||||
private static final BatteryHistEntry EMPTY_BATTERY_HIST_ENTRY =
|
private static final BatteryHistEntry EMPTY_BATTERY_HIST_ENTRY =
|
||||||
@@ -259,10 +260,12 @@ public final class ConvertUtils {
|
|||||||
foregroundUsageTimeInMs + backgroundUsageTimeInMs;
|
foregroundUsageTimeInMs + backgroundUsageTimeInMs;
|
||||||
if (totalUsageTimeInMs > TOTAL_TIME_THRESHOLD) {
|
if (totalUsageTimeInMs > TOTAL_TIME_THRESHOLD) {
|
||||||
final float ratio = TOTAL_TIME_THRESHOLD / totalUsageTimeInMs;
|
final float ratio = TOTAL_TIME_THRESHOLD / totalUsageTimeInMs;
|
||||||
|
if (DEBUG) {
|
||||||
Log.w(TAG, String.format("abnormal usage time %d|%d for:\n%s",
|
Log.w(TAG, String.format("abnormal usage time %d|%d for:\n%s",
|
||||||
Duration.ofMillis(foregroundUsageTimeInMs).getSeconds(),
|
Duration.ofMillis(foregroundUsageTimeInMs).getSeconds(),
|
||||||
Duration.ofMillis(backgroundUsageTimeInMs).getSeconds(),
|
Duration.ofMillis(backgroundUsageTimeInMs).getSeconds(),
|
||||||
currentEntry));
|
currentEntry));
|
||||||
|
}
|
||||||
foregroundUsageTimeInMs =
|
foregroundUsageTimeInMs =
|
||||||
Math.round(foregroundUsageTimeInMs * ratio);
|
Math.round(foregroundUsageTimeInMs * ratio);
|
||||||
backgroundUsageTimeInMs =
|
backgroundUsageTimeInMs =
|
||||||
|
Reference in New Issue
Block a user