Merge "Use Slog instead of Log"
This commit is contained in:
committed by
Android (Google) Code Review
commit
02c4a5e25c
@@ -21,7 +21,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.os.BatteryManager;
|
import android.os.BatteryManager;
|
||||||
import android.util.Log;
|
import android.util.Slog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BatteryTrigger instantiates a BroadcastReceiver that listens for changes
|
* BatteryTrigger instantiates a BroadcastReceiver that listens for changes
|
||||||
@@ -42,7 +42,7 @@ public final class BatteryTrigger extends PowerStatsLogTrigger {
|
|||||||
int newBatteryLevel = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
|
int newBatteryLevel = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
|
||||||
|
|
||||||
if (newBatteryLevel < mBatteryLevel) {
|
if (newBatteryLevel < mBatteryLevel) {
|
||||||
if (DEBUG) Log.d(TAG, "Battery level dropped. Log rail data");
|
if (DEBUG) Slog.d(TAG, "Battery level dropped. Log rail data");
|
||||||
logPowerStatsData();
|
logPowerStatsData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
package com.android.server.powerstats;
|
package com.android.server.powerstats;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Slog;
|
||||||
|
|
||||||
import com.android.internal.util.FileRotator;
|
import com.android.internal.util.FileRotator;
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ public class PowerStatsDataStorage {
|
|||||||
DataElement dataElement = new DataElement(in);
|
DataElement dataElement = new DataElement(in);
|
||||||
mCallback.onReadDataElement(dataElement.getData());
|
mCallback.onReadDataElement(dataElement.getData());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(TAG, "Failed to read from storage. " + e.getMessage());
|
Slog.e(TAG, "Failed to read from storage. " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -170,7 +170,7 @@ public class PowerStatsDataStorage {
|
|||||||
mDataStorageDir = dataStoragePath;
|
mDataStorageDir = dataStoragePath;
|
||||||
|
|
||||||
if (!mDataStorageDir.exists() && !mDataStorageDir.mkdirs()) {
|
if (!mDataStorageDir.exists() && !mDataStorageDir.mkdirs()) {
|
||||||
Log.wtf(TAG, "mDataStorageDir does not exist: " + mDataStorageDir.getPath());
|
Slog.wtf(TAG, "mDataStorageDir does not exist: " + mDataStorageDir.getPath());
|
||||||
mFileRotator = null;
|
mFileRotator = null;
|
||||||
} else {
|
} else {
|
||||||
// Delete files written with an old version number. The version is included in the
|
// Delete files written with an old version number. The version is included in the
|
||||||
@@ -208,7 +208,7 @@ public class PowerStatsDataStorage {
|
|||||||
currentTimeMillis);
|
currentTimeMillis);
|
||||||
mFileRotator.maybeRotate(currentTimeMillis);
|
mFileRotator.maybeRotate(currentTimeMillis);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(TAG, "Failed to write to on-device storage: " + e);
|
Slog.e(TAG, "Failed to write to on-device storage: " + e);
|
||||||
}
|
}
|
||||||
|
|
||||||
mLock.unlock();
|
mLock.unlock();
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import android.hardware.power.stats.EnergyMeasurement;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.util.Log;
|
import android.util.Slog;
|
||||||
import android.util.proto.ProtoInputStream;
|
import android.util.proto.ProtoInputStream;
|
||||||
import android.util.proto.ProtoOutputStream;
|
import android.util.proto.ProtoOutputStream;
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ public final class PowerStatsLogger extends Handler {
|
|||||||
public void handleMessage(Message msg) {
|
public void handleMessage(Message msg) {
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
case MSG_LOG_TO_DATA_STORAGE:
|
case MSG_LOG_TO_DATA_STORAGE:
|
||||||
if (DEBUG) Log.d(TAG, "Logging to data storage");
|
if (DEBUG) Slog.d(TAG, "Logging to data storage");
|
||||||
|
|
||||||
// Log power meter data.
|
// Log power meter data.
|
||||||
EnergyMeasurement[] energyMeasurements = mPowerStatsHALWrapper.readEnergyMeters();
|
EnergyMeasurement[] energyMeasurements = mPowerStatsHALWrapper.readEnergyMeters();
|
||||||
@@ -83,7 +83,7 @@ public final class PowerStatsLogger extends Handler {
|
|||||||
* is written in protobuf format as defined by powerstatsservice.proto.
|
* is written in protobuf format as defined by powerstatsservice.proto.
|
||||||
*/
|
*/
|
||||||
public void writeMeterDataToFile(FileDescriptor fd) {
|
public void writeMeterDataToFile(FileDescriptor fd) {
|
||||||
if (DEBUG) Log.d(TAG, "Writing meter data to file");
|
if (DEBUG) Slog.d(TAG, "Writing meter data to file");
|
||||||
|
|
||||||
final ProtoOutputStream pos = new ProtoOutputStream(fd);
|
final ProtoOutputStream pos = new ProtoOutputStream(fd);
|
||||||
|
|
||||||
@@ -106,12 +106,12 @@ public final class PowerStatsLogger extends Handler {
|
|||||||
EnergyMeasurementUtils.packProtoMessage(energyMeasurement, pos);
|
EnergyMeasurementUtils.packProtoMessage(energyMeasurement, pos);
|
||||||
if (DEBUG) EnergyMeasurementUtils.print(energyMeasurement);
|
if (DEBUG) EnergyMeasurementUtils.print(energyMeasurement);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(TAG, "Failed to write energy meter data to incident report.");
|
Slog.e(TAG, "Failed to write energy meter data to incident report.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(TAG, "Failed to write energy meter info to incident report.");
|
Slog.e(TAG, "Failed to write energy meter info to incident report.");
|
||||||
}
|
}
|
||||||
|
|
||||||
pos.flush();
|
pos.flush();
|
||||||
@@ -124,7 +124,7 @@ public final class PowerStatsLogger extends Handler {
|
|||||||
* is written in protobuf format as defined by powerstatsservice.proto.
|
* is written in protobuf format as defined by powerstatsservice.proto.
|
||||||
*/
|
*/
|
||||||
public void writeModelDataToFile(FileDescriptor fd) {
|
public void writeModelDataToFile(FileDescriptor fd) {
|
||||||
if (DEBUG) Log.d(TAG, "Writing model data to file");
|
if (DEBUG) Slog.d(TAG, "Writing model data to file");
|
||||||
|
|
||||||
final ProtoOutputStream pos = new ProtoOutputStream(fd);
|
final ProtoOutputStream pos = new ProtoOutputStream(fd);
|
||||||
|
|
||||||
@@ -147,12 +147,12 @@ public final class PowerStatsLogger extends Handler {
|
|||||||
EnergyConsumerResultUtils.packProtoMessage(energyConsumerResult, pos);
|
EnergyConsumerResultUtils.packProtoMessage(energyConsumerResult, pos);
|
||||||
if (DEBUG) EnergyConsumerResultUtils.print(energyConsumerResult);
|
if (DEBUG) EnergyConsumerResultUtils.print(energyConsumerResult);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(TAG, "Failed to write energy model data to incident report.");
|
Slog.e(TAG, "Failed to write energy model data to incident report.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(TAG, "Failed to write energy model info to incident report.");
|
Slog.e(TAG, "Failed to write energy model info to incident report.");
|
||||||
}
|
}
|
||||||
|
|
||||||
pos.flush();
|
pos.flush();
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import android.content.Context;
|
|||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.util.Log;
|
import android.util.Slog;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.internal.util.DumpUtils;
|
import com.android.internal.util.DumpUtils;
|
||||||
@@ -98,7 +98,7 @@ public class PowerStatsService extends SystemService {
|
|||||||
if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;
|
if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;
|
||||||
|
|
||||||
if (mPowerStatsLogger == null) {
|
if (mPowerStatsLogger == null) {
|
||||||
Log.e(TAG, "PowerStats HAL is not initialized. No data available.");
|
Slog.e(TAG, "PowerStats HAL is not initialized. No data available.");
|
||||||
} else {
|
} else {
|
||||||
if (args.length > 0 && "--proto".equals(args[0])) {
|
if (args.length > 0 && "--proto".equals(args[0])) {
|
||||||
if ("model".equals(args[1])) {
|
if ("model".equals(args[1])) {
|
||||||
@@ -127,7 +127,7 @@ public class PowerStatsService extends SystemService {
|
|||||||
mPowerStatsHALWrapper = mInjector.createPowerStatsHALWrapperImpl();
|
mPowerStatsHALWrapper = mInjector.createPowerStatsHALWrapperImpl();
|
||||||
|
|
||||||
if (mPowerStatsHALWrapper.initialize()) {
|
if (mPowerStatsHALWrapper.initialize()) {
|
||||||
if (DEBUG) Log.d(TAG, "Starting PowerStatsService");
|
if (DEBUG) Slog.d(TAG, "Starting PowerStatsService");
|
||||||
|
|
||||||
// Only start logger and triggers if initialization is successful.
|
// Only start logger and triggers if initialization is successful.
|
||||||
mPowerStatsLogger = mInjector.createPowerStatsLogger(mContext,
|
mPowerStatsLogger = mInjector.createPowerStatsLogger(mContext,
|
||||||
@@ -136,7 +136,7 @@ public class PowerStatsService extends SystemService {
|
|||||||
mBatteryTrigger = mInjector.createBatteryTrigger(mContext, mPowerStatsLogger);
|
mBatteryTrigger = mInjector.createBatteryTrigger(mContext, mPowerStatsLogger);
|
||||||
mTimerTrigger = mInjector.createTimerTrigger(mContext, mPowerStatsLogger);
|
mTimerTrigger = mInjector.createTimerTrigger(mContext, mPowerStatsLogger);
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "Initialization of PowerStatsHAL wrapper failed");
|
Slog.e(TAG, "Initialization of PowerStatsHAL wrapper failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package com.android.server.powerstats;
|
|||||||
import android.hardware.power.stats.ChannelInfo;
|
import android.hardware.power.stats.ChannelInfo;
|
||||||
import android.hardware.power.stats.EnergyConsumerResult;
|
import android.hardware.power.stats.EnergyConsumerResult;
|
||||||
import android.hardware.power.stats.EnergyMeasurement;
|
import android.hardware.power.stats.EnergyMeasurement;
|
||||||
import android.util.Log;
|
import android.util.Slog;
|
||||||
import android.util.proto.ProtoInputStream;
|
import android.util.proto.ProtoInputStream;
|
||||||
import android.util.proto.ProtoOutputStream;
|
import android.util.proto.ProtoOutputStream;
|
||||||
import android.util.proto.ProtoUtils;
|
import android.util.proto.ProtoUtils;
|
||||||
@@ -56,7 +56,7 @@ public class ProtoStreamUtils {
|
|||||||
|
|
||||||
public static void print(ChannelInfo[] channelInfo) {
|
public static void print(ChannelInfo[] channelInfo) {
|
||||||
for (int i = 0; i < channelInfo.length; i++) {
|
for (int i = 0; i < channelInfo.length; i++) {
|
||||||
Log.d(TAG, "ChannelId = " + channelInfo[i].channelId
|
Slog.d(TAG, "ChannelId = " + channelInfo[i].channelId
|
||||||
+ ", ChannelName = " + channelInfo[i].channelName);
|
+ ", ChannelName = " + channelInfo[i].channelName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,11 +100,11 @@ public class ProtoStreamUtils {
|
|||||||
return energyMeasurementList.toArray(
|
return energyMeasurementList.toArray(
|
||||||
new EnergyMeasurement[energyMeasurementList.size()]);
|
new EnergyMeasurement[energyMeasurementList.size()]);
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "Unhandled field in proto: "
|
Slog.e(TAG, "Unhandled field in proto: "
|
||||||
+ ProtoUtils.currentFieldToString(pis));
|
+ ProtoUtils.currentFieldToString(pis));
|
||||||
}
|
}
|
||||||
} catch (WireTypeMismatchException wtme) {
|
} catch (WireTypeMismatchException wtme) {
|
||||||
Log.e(TAG, "Wire Type mismatch in proto: "
|
Slog.e(TAG, "Wire Type mismatch in proto: "
|
||||||
+ ProtoUtils.currentFieldToString(pis));
|
+ ProtoUtils.currentFieldToString(pis));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -136,12 +136,12 @@ public class ProtoStreamUtils {
|
|||||||
return energyMeasurement;
|
return energyMeasurement;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Log.e(TAG, "Unhandled field in EnergyMeasurementProto: "
|
Slog.e(TAG, "Unhandled field in EnergyMeasurementProto: "
|
||||||
+ ProtoUtils.currentFieldToString(pis));
|
+ ProtoUtils.currentFieldToString(pis));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (WireTypeMismatchException wtme) {
|
} catch (WireTypeMismatchException wtme) {
|
||||||
Log.e(TAG, "Wire Type mismatch in EnergyMeasurementProto: "
|
Slog.e(TAG, "Wire Type mismatch in EnergyMeasurementProto: "
|
||||||
+ ProtoUtils.currentFieldToString(pis));
|
+ ProtoUtils.currentFieldToString(pis));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,7 +149,7 @@ public class ProtoStreamUtils {
|
|||||||
|
|
||||||
public static void print(EnergyMeasurement[] energyMeasurement) {
|
public static void print(EnergyMeasurement[] energyMeasurement) {
|
||||||
for (int i = 0; i < energyMeasurement.length; i++) {
|
for (int i = 0; i < energyMeasurement.length; i++) {
|
||||||
Log.d(TAG, "ChannelId = " + energyMeasurement[i].channelId
|
Slog.d(TAG, "ChannelId = " + energyMeasurement[i].channelId
|
||||||
+ ", Timestamp (ms) = " + energyMeasurement[i].timestampMs
|
+ ", Timestamp (ms) = " + energyMeasurement[i].timestampMs
|
||||||
+ ", Energy (uWs) = " + energyMeasurement[i].energyUWs);
|
+ ", Energy (uWs) = " + energyMeasurement[i].energyUWs);
|
||||||
}
|
}
|
||||||
@@ -169,7 +169,7 @@ public class ProtoStreamUtils {
|
|||||||
|
|
||||||
public static void print(int[] energyConsumerId) {
|
public static void print(int[] energyConsumerId) {
|
||||||
for (int i = 0; i < energyConsumerId.length; i++) {
|
for (int i = 0; i < energyConsumerId.length; i++) {
|
||||||
Log.d(TAG, "EnergyConsumerId = " + energyConsumerId[i]);
|
Slog.d(TAG, "EnergyConsumerId = " + energyConsumerId[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -215,11 +215,11 @@ public class ProtoStreamUtils {
|
|||||||
return energyConsumerResultList.toArray(
|
return energyConsumerResultList.toArray(
|
||||||
new EnergyConsumerResult[energyConsumerResultList.size()]);
|
new EnergyConsumerResult[energyConsumerResultList.size()]);
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "Unhandled field in proto: "
|
Slog.e(TAG, "Unhandled field in proto: "
|
||||||
+ ProtoUtils.currentFieldToString(pis));
|
+ ProtoUtils.currentFieldToString(pis));
|
||||||
}
|
}
|
||||||
} catch (WireTypeMismatchException wtme) {
|
} catch (WireTypeMismatchException wtme) {
|
||||||
Log.e(TAG, "Wire Type mismatch in proto: "
|
Slog.e(TAG, "Wire Type mismatch in proto: "
|
||||||
+ ProtoUtils.currentFieldToString(pis));
|
+ ProtoUtils.currentFieldToString(pis));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -251,12 +251,12 @@ public class ProtoStreamUtils {
|
|||||||
return energyConsumerResult;
|
return energyConsumerResult;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Log.e(TAG, "Unhandled field in EnergyConsumerResultProto: "
|
Slog.e(TAG, "Unhandled field in EnergyConsumerResultProto: "
|
||||||
+ ProtoUtils.currentFieldToString(pis));
|
+ ProtoUtils.currentFieldToString(pis));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (WireTypeMismatchException wtme) {
|
} catch (WireTypeMismatchException wtme) {
|
||||||
Log.e(TAG, "Wire Type mismatch in EnergyConsumerResultProto: "
|
Slog.e(TAG, "Wire Type mismatch in EnergyConsumerResultProto: "
|
||||||
+ ProtoUtils.currentFieldToString(pis));
|
+ ProtoUtils.currentFieldToString(pis));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -264,7 +264,7 @@ public class ProtoStreamUtils {
|
|||||||
|
|
||||||
public static void print(EnergyConsumerResult[] energyConsumerResult) {
|
public static void print(EnergyConsumerResult[] energyConsumerResult) {
|
||||||
for (int i = 0; i < energyConsumerResult.length; i++) {
|
for (int i = 0; i < energyConsumerResult.length; i++) {
|
||||||
Log.d(TAG, "EnergyConsumerId = " + energyConsumerResult[i].energyConsumerId
|
Slog.d(TAG, "EnergyConsumerId = " + energyConsumerResult[i].energyConsumerId
|
||||||
+ ", Timestamp (ms) = " + energyConsumerResult[i].timestampMs
|
+ ", Timestamp (ms) = " + energyConsumerResult[i].timestampMs
|
||||||
+ ", Energy (uWs) = " + energyConsumerResult[i].energyUWs);
|
+ ", Energy (uWs) = " + energyConsumerResult[i].energyUWs);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ package com.android.server.powerstats;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.util.Log;
|
import android.util.Slog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TimerTrigger sets a 60 second opportunistic timer using postDelayed.
|
* TimerTrigger sets a 60 second opportunistic timer using postDelayed.
|
||||||
@@ -39,7 +39,7 @@ public final class TimerTrigger extends PowerStatsLogTrigger {
|
|||||||
// Do not wake the device for these messages. Opportunistically log rail data every
|
// Do not wake the device for these messages. Opportunistically log rail data every
|
||||||
// LOG_PERIOD_MS.
|
// LOG_PERIOD_MS.
|
||||||
mHandler.postDelayed(mLogData, LOG_PERIOD_MS);
|
mHandler.postDelayed(mLogData, LOG_PERIOD_MS);
|
||||||
if (DEBUG) Log.d(TAG, "Received delayed message. Log rail data");
|
if (DEBUG) Slog.d(TAG, "Received delayed message. Log rail data");
|
||||||
logPowerStatsData();
|
logPowerStatsData();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user