diff options
| -rw-r--r-- | cmds/statsd/src/atoms.proto | 25 | ||||
| -rw-r--r-- | cmds/statsd/src/external/StatsPullerManagerImpl.cpp | 9 | ||||
| -rw-r--r-- | services/core/java/com/android/server/stats/StatsCompanionService.java | 39 |
3 files changed, 66 insertions, 7 deletions
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto index f55a59a53466..7a9588d1a2c4 100644 --- a/cmds/statsd/src/atoms.proto +++ b/cmds/statsd/src/atoms.proto @@ -108,6 +108,8 @@ message Atom { CpuIdleTime cpu_idle_time = 10015; CpuActiveTime cpu_active_time = 10016; CpuClusterTime cpu_cluster_time = 10017; + DiskSpace disk_space = 10018; + SystemUptime system_uptime = 10019; } } @@ -1297,4 +1299,27 @@ message CpuClusterTime { optional uint64 uid = 1; optional uint64 idx = 2; optional uint64 time_ms = 3; +} + +/* + * Pulls free disk space, for data, system partition and temporary directory. + */ +message DiskSpace { + // available bytes in data partition + optional uint64 data_available_bytes = 1; + // available bytes in system partition + optional uint64 system_available_bytes = 2; + // available bytes in download cache or temp directories + optional uint64 temp_available_bytes = 3; +} + +/* + * Pulls system up time. + */ +message SystemUptime { + // Milliseconds since the system was booted. + // This clock stops when the system enters deep sleep (CPU off, display dark, device waiting + // for external input). + // It is not affected by clock scaling, idle, or other power saving mechanisms. + optional uint64 uptime_ms = 1; }
\ No newline at end of file diff --git a/cmds/statsd/src/external/StatsPullerManagerImpl.cpp b/cmds/statsd/src/external/StatsPullerManagerImpl.cpp index 79f1a5d84174..e06ae48f7215 100644 --- a/cmds/statsd/src/external/StatsPullerManagerImpl.cpp +++ b/cmds/statsd/src/external/StatsPullerManagerImpl.cpp @@ -66,6 +66,15 @@ StatsPullerManagerImpl::StatsPullerManagerImpl() mPullers.insert({android::util::CPU_TIME_PER_UID_FREQ, make_shared<CpuTimePerUidFreqPuller>()}); mPullers.insert({android::util::CPU_SUSPEND_TIME, make_shared<StatsCompanionServicePuller>(android::util::CPU_SUSPEND_TIME)}); mPullers.insert({android::util::CPU_IDLE_TIME, make_shared<StatsCompanionServicePuller>(android::util::CPU_IDLE_TIME)}); + mPullers.insert({android::util::DISK_SPACE, + make_shared<StatsCompanionServicePuller>(android::util::DISK_SPACE)}); + mPullers.insert({android::util::SYSTEM_UPTIME, + make_shared<StatsCompanionServicePuller>(android::util::SYSTEM_UPTIME)}); + mPullers.insert( + {android::util::WIFI_ACTIVITY_ENERGY_INFO, + make_shared<StatsCompanionServicePuller>(android::util::WIFI_ACTIVITY_ENERGY_INFO)}); + mPullers.insert({android::util::MODEM_ACTIVITY_INFO, + make_shared<StatsCompanionServicePuller>(android::util::MODEM_ACTIVITY_INFO)}); mStatsCompanionService = StatsService::getStatsCompanionService(); } diff --git a/services/core/java/com/android/server/stats/StatsCompanionService.java b/services/core/java/com/android/server/stats/StatsCompanionService.java index 4cb5e089bd83..f82dc24f3d61 100644 --- a/services/core/java/com/android/server/stats/StatsCompanionService.java +++ b/services/core/java/com/android/server/stats/StatsCompanionService.java @@ -28,12 +28,10 @@ import android.content.pm.UserInfo; import android.net.NetworkStats; import android.net.wifi.IWifiManager; import android.net.wifi.WifiActivityEnergyInfo; -import android.os.SystemClock; -import android.telephony.ModemActivityInfo; -import android.telephony.TelephonyManager; import android.os.BatteryStatsInternal; import android.os.Binder; import android.os.Bundle; +import android.os.Environment; import android.os.IBinder; import android.os.IStatsCompanionService; import android.os.IStatsManager; @@ -41,18 +39,22 @@ import android.os.Parcelable; import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; +import android.os.StatFs; import android.os.StatsLogEventWrapper; import android.os.SynchronousResultReceiver; +import android.os.SystemClock; import android.os.UserHandle; import android.os.UserManager; +import android.telephony.ModemActivityInfo; +import android.telephony.TelephonyManager; import android.util.Slog; import android.util.StatsLog; import com.android.internal.annotations.GuardedBy; import com.android.internal.net.NetworkStatsFactory; +import com.android.internal.os.KernelCpuSpeedReader; import com.android.internal.os.KernelWakelockReader; import com.android.internal.os.KernelWakelockStats; -import com.android.internal.os.KernelCpuSpeedReader; import com.android.internal.os.PowerProfile; import com.android.server.LocalServices; import com.android.server.SystemService; @@ -97,6 +99,11 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { private final KernelCpuSpeedReader[] mKernelCpuSpeedReaders; private IWifiManager mWifiManager = null; private TelephonyManager mTelephony = null; + private final StatFs mStatFsData = new StatFs(Environment.getDataDirectory().getAbsolutePath()); + private final StatFs mStatFsSystem = + new StatFs(Environment.getRootDirectory().getAbsolutePath()); + private final StatFs mStatFsTemp = + new StatFs(Environment.getDownloadCacheDirectory().getAbsolutePath()); public StatsCompanionService(Context context) { super(); @@ -560,7 +567,7 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { if (clusterTimeMs != null) { for (int speed = clusterTimeMs.length - 1; speed >= 0; --speed) { StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, 3); - e.writeInt(tagId); + e.writeInt(cluster); e.writeInt(speed); e.writeLong(clusterTimeMs[speed]); ret.add(e); @@ -589,6 +596,7 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { e.writeLong(wifiInfo.getControllerIdleTimeMillis()); e.writeLong(wifiInfo.getControllerEnergyUsed()); ret.add(e); + return ret.toArray(new StatsLogEventWrapper[ret.size()]); } catch (RemoteException e) { Slog.e(TAG, "Pulling wifiManager for wifi controller activity energy info has error", e); } finally { @@ -619,6 +627,7 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { e.writeLong(modemInfo.getRxTimeMillis()); e.writeLong(modemInfo.getEnergyUsed()); ret.add(e); + return ret.toArray(new StatsLogEventWrapper[ret.size()]); } break; } @@ -627,14 +636,30 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, 1); e.writeLong(SystemClock.elapsedRealtime()); ret.add(e); - break; + return ret.toArray(new StatsLogEventWrapper[ret.size()]); } case StatsLog.CPU_IDLE_TIME: { List<StatsLogEventWrapper> ret = new ArrayList(); StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, 1); e.writeLong(SystemClock.uptimeMillis()); ret.add(e); - break; + return ret.toArray(new StatsLogEventWrapper[ret.size()]); + } + case StatsLog.DISK_SPACE: { + List<StatsLogEventWrapper> ret = new ArrayList(); + StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, 3); + e.writeLong(mStatFsData.getAvailableBytes()); + e.writeLong(mStatFsSystem.getAvailableBytes()); + e.writeLong(mStatFsTemp.getAvailableBytes()); + ret.add(e); + return ret.toArray(new StatsLogEventWrapper[ret.size()]); + } + case StatsLog.SYSTEM_UPTIME: { + List<StatsLogEventWrapper> ret = new ArrayList(); + StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, 1); + e.writeLong(SystemClock.uptimeMillis()); + ret.add(e); + return ret.toArray(new StatsLogEventWrapper[ret.size()]); } default: Slog.w(TAG, "No such tagId data as " + tagId); |