Migrate pullModemActivityInfo
Test: No cts test. Ran adb shell cmd stats pull-source 10012 Change-Id: I1eec8c748916010182be310e726924325b694a34
This commit is contained in:
@@ -714,63 +714,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to extract the Parcelable controller info from a
|
||||
* SynchronousResultReceiver.
|
||||
*/
|
||||
private static <T extends Parcelable> T awaitControllerInfo(
|
||||
@Nullable SynchronousResultReceiver receiver) {
|
||||
if (receiver == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
final SynchronousResultReceiver.Result result =
|
||||
receiver.awaitResult(EXTERNAL_STATS_SYNC_TIMEOUT_MILLIS);
|
||||
if (result.bundle != null) {
|
||||
// This is the final destination for the Bundle.
|
||||
result.bundle.setDefusable(true);
|
||||
|
||||
final T data = result.bundle.getParcelable(
|
||||
RESULT_RECEIVER_CONTROLLER_KEY);
|
||||
if (data != null) {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
Slog.e(TAG, "no controller energy info supplied for " + receiver.getName());
|
||||
} catch (TimeoutException e) {
|
||||
Slog.w(TAG, "timeout reading " + receiver.getName() + " stats");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void pullModemActivityInfo(
|
||||
int tagId, long elapsedNanos, long wallClockNanos,
|
||||
List<StatsLogEventWrapper> pulledData) {
|
||||
long token = Binder.clearCallingIdentity();
|
||||
synchronized (this) {
|
||||
if (mTelephony == null) {
|
||||
mTelephony = mContext.getSystemService(TelephonyManager.class);
|
||||
}
|
||||
}
|
||||
if (mTelephony != null) {
|
||||
SynchronousResultReceiver modemReceiver = new SynchronousResultReceiver("telephony");
|
||||
mTelephony.requestModemActivityInfo(modemReceiver);
|
||||
final ModemActivityInfo modemInfo = awaitControllerInfo(modemReceiver);
|
||||
StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, elapsedNanos, wallClockNanos);
|
||||
e.writeLong(modemInfo.getTimestamp());
|
||||
e.writeLong(modemInfo.getSleepTimeMillis());
|
||||
e.writeLong(modemInfo.getIdleTimeMillis());
|
||||
e.writeLong(modemInfo.getTransmitPowerInfo().get(0).getTimeInMillis());
|
||||
e.writeLong(modemInfo.getTransmitPowerInfo().get(1).getTimeInMillis());
|
||||
e.writeLong(modemInfo.getTransmitPowerInfo().get(2).getTimeInMillis());
|
||||
e.writeLong(modemInfo.getTransmitPowerInfo().get(3).getTimeInMillis());
|
||||
e.writeLong(modemInfo.getTransmitPowerInfo().get(4).getTimeInMillis());
|
||||
e.writeLong(modemInfo.getReceiveTimeMillis());
|
||||
pulledData.add(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void pullSystemElapsedRealtime(
|
||||
int tagId, long elapsedNanos, long wallClockNanos,
|
||||
List<StatsLogEventWrapper> pulledData) {
|
||||
@@ -1962,11 +1905,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
|
||||
long wallClockNanos = SystemClock.currentTimeMicro() * 1000L;
|
||||
switch (tagId) {
|
||||
|
||||
case StatsLog.MODEM_ACTIVITY_INFO: {
|
||||
pullModemActivityInfo(tagId, elapsedNanos, wallClockNanos, ret);
|
||||
break;
|
||||
}
|
||||
|
||||
case StatsLog.SYSTEM_ELAPSED_REALTIME: {
|
||||
pullSystemElapsedRealtime(tagId, elapsedNanos, wallClockNanos, ret);
|
||||
break;
|
||||
|
||||
@@ -68,10 +68,6 @@ std::map<PullerKey, PullAtomInfo> StatsPullerManager::kAllPullAtomInfo = {
|
||||
{{.atomTag = android::util::ON_DEVICE_POWER_MEASUREMENT},
|
||||
{.puller = new PowerStatsPuller()}},
|
||||
|
||||
// modem_activity_info
|
||||
{{.atomTag = android::util::MODEM_ACTIVITY_INFO},
|
||||
{.puller = new StatsCompanionServicePuller(android::util::MODEM_ACTIVITY_INFO)}},
|
||||
|
||||
// system_elapsed_realtime
|
||||
{{.atomTag = android::util::SYSTEM_ELAPSED_REALTIME},
|
||||
{.coolDownNs = NS_PER_SEC,
|
||||
|
||||
@@ -211,6 +211,7 @@ public class StatsPullAtomService extends SystemService {
|
||||
public void onStart() {
|
||||
mStatsManager = (StatsManager) mContext.getSystemService(Context.STATS_MANAGER);
|
||||
mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
|
||||
mTelephony = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
|
||||
// Used to initialize the CPU Frequency atom.
|
||||
PowerProfile powerProfile = new PowerProfile(mContext);
|
||||
@@ -823,6 +824,7 @@ public class StatsPullAtomService extends SystemService {
|
||||
}
|
||||
|
||||
private WifiManager mWifiManager;
|
||||
private TelephonyManager mTelephony;
|
||||
|
||||
private int pullWifiActivityInfo(int atomTag, List<StatsEvent> pulledData) {
|
||||
long token = Binder.clearCallingIdentity();
|
||||
@@ -867,11 +869,41 @@ public class StatsPullAtomService extends SystemService {
|
||||
}
|
||||
|
||||
private void registerModemActivityInfo() {
|
||||
// No op.
|
||||
int tagId = StatsLog.MODEM_ACTIVITY_INFO;
|
||||
mStatsManager.registerPullAtomCallback(
|
||||
tagId,
|
||||
null, // use default PullAtomMetadata values
|
||||
(atomTag, data) -> pullModemActivityInfo(atomTag, data),
|
||||
BackgroundThread.getExecutor()
|
||||
);
|
||||
}
|
||||
|
||||
private void pullModemActivityInfo() {
|
||||
// No op.
|
||||
private int pullModemActivityInfo(int atomTag, List<StatsEvent> pulledData) {
|
||||
long token = Binder.clearCallingIdentity();
|
||||
try {
|
||||
SynchronousResultReceiver modemReceiver = new SynchronousResultReceiver("telephony");
|
||||
mTelephony.requestModemActivityInfo(modemReceiver);
|
||||
final ModemActivityInfo modemInfo = awaitControllerInfo(modemReceiver);
|
||||
if (modemInfo == null) {
|
||||
return StatsManager.PULL_SKIP;
|
||||
}
|
||||
StatsEvent e = StatsEvent.newBuilder()
|
||||
.setAtomId(atomTag)
|
||||
.writeLong(modemInfo.getTimestamp())
|
||||
.writeLong(modemInfo.getSleepTimeMillis())
|
||||
.writeLong(modemInfo.getIdleTimeMillis())
|
||||
.writeLong(modemInfo.getTransmitPowerInfo().get(0).getTimeInMillis())
|
||||
.writeLong(modemInfo.getTransmitPowerInfo().get(1).getTimeInMillis())
|
||||
.writeLong(modemInfo.getTransmitPowerInfo().get(2).getTimeInMillis())
|
||||
.writeLong(modemInfo.getTransmitPowerInfo().get(3).getTimeInMillis())
|
||||
.writeLong(modemInfo.getTransmitPowerInfo().get(4).getTimeInMillis())
|
||||
.writeLong(modemInfo.getReceiveTimeMillis())
|
||||
.build();
|
||||
pulledData.add(e);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(token);
|
||||
}
|
||||
return StatsManager.PULL_SUCCESS;
|
||||
}
|
||||
|
||||
private void registerBluetoothActivityInfo() {
|
||||
|
||||
Reference in New Issue
Block a user