Merge "Add logging for UwbActivityInfo to StatsPullAtomService" into udc-dev
This commit is contained in:
@@ -171,6 +171,8 @@ import android.util.SparseArray;
|
||||
import android.util.SparseIntArray;
|
||||
import android.util.StatsEvent;
|
||||
import android.util.proto.ProtoOutputStream;
|
||||
import android.uwb.UwbActivityEnergyInfo;
|
||||
import android.uwb.UwbManager;
|
||||
import android.view.Display;
|
||||
|
||||
import com.android.internal.annotations.GuardedBy;
|
||||
@@ -346,6 +348,7 @@ public class StatsPullAtomService extends SystemService {
|
||||
private StorageManager mStorageManager;
|
||||
private WifiManager mWifiManager;
|
||||
private TelephonyManager mTelephony;
|
||||
private UwbManager mUwbManager;
|
||||
private SubscriptionManager mSubscriptionManager;
|
||||
private NetworkStatsManager mNetworkStatsManager;
|
||||
|
||||
@@ -415,6 +418,7 @@ public class StatsPullAtomService extends SystemService {
|
||||
private final Object mWifiActivityInfoLock = new Object();
|
||||
private final Object mModemActivityInfoLock = new Object();
|
||||
private final Object mBluetoothActivityInfoLock = new Object();
|
||||
private final Object mUwbActivityInfoLock = new Object();
|
||||
private final Object mSystemElapsedRealtimeLock = new Object();
|
||||
private final Object mSystemUptimeLock = new Object();
|
||||
private final Object mProcessMemoryStateLock = new Object();
|
||||
@@ -537,6 +541,10 @@ public class StatsPullAtomService extends SystemService {
|
||||
synchronized (mBluetoothActivityInfoLock) {
|
||||
return pullBluetoothActivityInfoLocked(atomTag, data);
|
||||
}
|
||||
case FrameworkStatsLog.UWB_ACTIVITY_INFO:
|
||||
synchronized (mUwbActivityInfoLock) {
|
||||
return pullUwbActivityInfoLocked(atomTag, data);
|
||||
}
|
||||
case FrameworkStatsLog.SYSTEM_ELAPSED_REALTIME:
|
||||
synchronized (mSystemElapsedRealtimeLock) {
|
||||
return pullSystemElapsedRealtimeLocked(atomTag, data);
|
||||
@@ -778,8 +786,12 @@ public class StatsPullAtomService extends SystemService {
|
||||
registerEventListeners();
|
||||
});
|
||||
} else if (phase == PHASE_THIRD_PARTY_APPS_CAN_START) {
|
||||
// Network stats related pullers can only be initialized after service is ready.
|
||||
BackgroundThread.getHandler().post(() -> initAndRegisterNetworkStatsPullers());
|
||||
BackgroundThread.getHandler().post(() -> {
|
||||
// Network stats related pullers can only be initialized after service is ready.
|
||||
initAndRegisterNetworkStatsPullers();
|
||||
// For services that are not ready at boot phase PHASE_SYSTEM_SERVICES_READY
|
||||
initAndRegisterDeferredPullers();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -990,6 +1002,12 @@ public class StatsPullAtomService extends SystemService {
|
||||
registerOemManagedBytesTransfer();
|
||||
}
|
||||
|
||||
private void initAndRegisterDeferredPullers() {
|
||||
mUwbManager = mContext.getSystemService(UwbManager.class);
|
||||
|
||||
registerUwbActivityInfo();
|
||||
}
|
||||
|
||||
private IThermalService getIThermalService() {
|
||||
synchronized (mThermalLock) {
|
||||
if (mThermalService == null) {
|
||||
@@ -2152,6 +2170,46 @@ public class StatsPullAtomService extends SystemService {
|
||||
return StatsManager.PULL_SUCCESS;
|
||||
}
|
||||
|
||||
private void registerUwbActivityInfo() {
|
||||
int tagId = FrameworkStatsLog.UWB_ACTIVITY_INFO;
|
||||
mStatsManager.setPullAtomCallback(
|
||||
tagId,
|
||||
null, // use default PullAtomMetadata values
|
||||
DIRECT_EXECUTOR,
|
||||
mStatsCallbackImpl
|
||||
);
|
||||
}
|
||||
|
||||
int pullUwbActivityInfoLocked(int atomTag, List<StatsEvent> pulledData) {
|
||||
final long token = Binder.clearCallingIdentity();
|
||||
try {
|
||||
SynchronousResultReceiver uwbReceiver = new SynchronousResultReceiver("uwb");
|
||||
mUwbManager.getUwbActivityEnergyInfoAsync(Runnable::run,
|
||||
info -> {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable(BatteryStats.RESULT_RECEIVER_CONTROLLER_KEY, info);
|
||||
uwbReceiver.send(0, bundle);
|
||||
}
|
||||
);
|
||||
final UwbActivityEnergyInfo uwbInfo = awaitControllerInfo(uwbReceiver);
|
||||
if (uwbInfo == null) {
|
||||
return StatsManager.PULL_SKIP;
|
||||
}
|
||||
pulledData.add(
|
||||
FrameworkStatsLog.buildStatsEvent(atomTag,
|
||||
uwbInfo.getControllerTxDurationMillis(),
|
||||
uwbInfo.getControllerRxDurationMillis(),
|
||||
uwbInfo.getControllerIdleDurationMillis(),
|
||||
uwbInfo.getControllerWakeCount()));
|
||||
} catch (RuntimeException e) {
|
||||
Slog.e(TAG, "failed to getUwbActivityEnergyInfoAsync", e);
|
||||
return StatsManager.PULL_SKIP;
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(token);
|
||||
}
|
||||
return StatsManager.PULL_SUCCESS;
|
||||
}
|
||||
|
||||
private void registerSystemElapsedRealtime() {
|
||||
int tagId = FrameworkStatsLog.SYSTEM_ELAPSED_REALTIME;
|
||||
PullAtomMetadata metadata = new PullAtomMetadata.Builder()
|
||||
|
||||
Reference in New Issue
Block a user