Loading cmds/statsd/src/atoms.proto +14 −1 Original line number Diff line number Diff line Loading @@ -257,7 +257,7 @@ message Atom { } // Pulled events will start at field 10000. // Next: 10057 // Next: 10058 oneof pulled { WifiBytesTransfer wifi_bytes_transfer = 10000; WifiBytesTransferByFgBg wifi_bytes_transfer_by_fg_bg = 10001; Loading Loading @@ -316,6 +316,7 @@ message Atom { GpuStatsGlobalInfo gpu_stats_global_info = 10054; GpuStatsAppInfo gpu_stats_app_info = 10055; SystemIonHeapSize system_ion_heap_size = 10056; AppsOnExternalStorageInfo apps_on_external_storage_info = 10057; } // DO NOT USE field numbers above 100,000 in AOSP. Loading Loading @@ -5869,3 +5870,15 @@ message NetworkStackReported { optional int32 eventId = 1; optional android.stats.connectivity.NetworkStackEventData network_stack_event = 2 [(log_mode) = MODE_BYTES]; } /** * Logs the apps that are installed on the external storage. * Pulled from: * StatsCompanionService */ message AppsOnExternalStorageInfo { // The type of the external storage. optional android.stats.storage.ExternalStorageType external_storage_type = 1; // The name of the package that is installed on the external storage. optional string package_name = 2; } cmds/statsd/src/external/StatsPullerManager.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -251,6 +251,9 @@ std::map<int, PullAtomInfo> StatsPullerManager::kAllPullAtomInfo = { // GpuStatsAppInfo {android::util::GPU_STATS_APP_INFO, {.puller = new GpuStatsPuller(android::util::GPU_STATS_APP_INFO)}}, // AppsOnExternalStorageInfo {android::util::APPS_ON_EXTERNAL_STORAGE_INFO, {.puller = new StatsCompanionServicePuller(android::util::APPS_ON_EXTERNAL_STORAGE_INFO)}}, }; StatsPullerManager::StatsPullerManager() : mNextPullTimeNs(NO_ALARM_UPDATE) { Loading services/core/java/com/android/server/stats/StatsCompanionService.java +40 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.IntentSender; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PermissionInfo; Loading Loading @@ -149,6 +150,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; Loading Loading @@ -2010,6 +2012,40 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { } } private void pullAppsOnExternalStorageInfo(int tagId, long elapsedNanos, long wallClockNanos, List<StatsLogEventWrapper> pulledData) { PackageManager pm = mContext.getPackageManager(); StorageManager storage = mContext.getSystemService(StorageManager.class); List<ApplicationInfo> apps = pm.getInstalledApplications(/* flags = */ 0); for (ApplicationInfo appInfo : apps) { UUID storageUuid = appInfo.storageUuid; if (storageUuid != null) { VolumeInfo volumeInfo = storage.findVolumeByUuid(appInfo.storageUuid.toString()); if (volumeInfo != null) { DiskInfo diskInfo = volumeInfo.getDisk(); if (diskInfo != null) { int externalStorageType = -1; if (diskInfo.isSd()) { externalStorageType = StorageEnums.SD_CARD; } else if (diskInfo.isUsb()) { externalStorageType = StorageEnums.USB; } else if (appInfo.isExternal()) { externalStorageType = StorageEnums.OTHER; } // App is installed on external storage. if (externalStorageType != -1) { StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, elapsedNanos, wallClockNanos); e.writeInt(externalStorageType); e.writeString(appInfo.packageName); pulledData.add(e); } } } } } } /** * Pulls various data. */ Loading Loading @@ -2210,6 +2246,10 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { pullExternalStorageInfo(tagId, elapsedNanos, wallClockNanos, ret); break; } case StatsLog.APPS_ON_EXTERNAL_STORAGE_INFO: { pullAppsOnExternalStorageInfo(tagId, elapsedNanos, wallClockNanos, ret); break; } default: Slog.w(TAG, "No such tagId data as " + tagId); return null; Loading Loading
cmds/statsd/src/atoms.proto +14 −1 Original line number Diff line number Diff line Loading @@ -257,7 +257,7 @@ message Atom { } // Pulled events will start at field 10000. // Next: 10057 // Next: 10058 oneof pulled { WifiBytesTransfer wifi_bytes_transfer = 10000; WifiBytesTransferByFgBg wifi_bytes_transfer_by_fg_bg = 10001; Loading Loading @@ -316,6 +316,7 @@ message Atom { GpuStatsGlobalInfo gpu_stats_global_info = 10054; GpuStatsAppInfo gpu_stats_app_info = 10055; SystemIonHeapSize system_ion_heap_size = 10056; AppsOnExternalStorageInfo apps_on_external_storage_info = 10057; } // DO NOT USE field numbers above 100,000 in AOSP. Loading Loading @@ -5869,3 +5870,15 @@ message NetworkStackReported { optional int32 eventId = 1; optional android.stats.connectivity.NetworkStackEventData network_stack_event = 2 [(log_mode) = MODE_BYTES]; } /** * Logs the apps that are installed on the external storage. * Pulled from: * StatsCompanionService */ message AppsOnExternalStorageInfo { // The type of the external storage. optional android.stats.storage.ExternalStorageType external_storage_type = 1; // The name of the package that is installed on the external storage. optional string package_name = 2; }
cmds/statsd/src/external/StatsPullerManager.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -251,6 +251,9 @@ std::map<int, PullAtomInfo> StatsPullerManager::kAllPullAtomInfo = { // GpuStatsAppInfo {android::util::GPU_STATS_APP_INFO, {.puller = new GpuStatsPuller(android::util::GPU_STATS_APP_INFO)}}, // AppsOnExternalStorageInfo {android::util::APPS_ON_EXTERNAL_STORAGE_INFO, {.puller = new StatsCompanionServicePuller(android::util::APPS_ON_EXTERNAL_STORAGE_INFO)}}, }; StatsPullerManager::StatsPullerManager() : mNextPullTimeNs(NO_ALARM_UPDATE) { Loading
services/core/java/com/android/server/stats/StatsCompanionService.java +40 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.IntentSender; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PermissionInfo; Loading Loading @@ -149,6 +150,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; Loading Loading @@ -2010,6 +2012,40 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { } } private void pullAppsOnExternalStorageInfo(int tagId, long elapsedNanos, long wallClockNanos, List<StatsLogEventWrapper> pulledData) { PackageManager pm = mContext.getPackageManager(); StorageManager storage = mContext.getSystemService(StorageManager.class); List<ApplicationInfo> apps = pm.getInstalledApplications(/* flags = */ 0); for (ApplicationInfo appInfo : apps) { UUID storageUuid = appInfo.storageUuid; if (storageUuid != null) { VolumeInfo volumeInfo = storage.findVolumeByUuid(appInfo.storageUuid.toString()); if (volumeInfo != null) { DiskInfo diskInfo = volumeInfo.getDisk(); if (diskInfo != null) { int externalStorageType = -1; if (diskInfo.isSd()) { externalStorageType = StorageEnums.SD_CARD; } else if (diskInfo.isUsb()) { externalStorageType = StorageEnums.USB; } else if (appInfo.isExternal()) { externalStorageType = StorageEnums.OTHER; } // App is installed on external storage. if (externalStorageType != -1) { StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, elapsedNanos, wallClockNanos); e.writeInt(externalStorageType); e.writeString(appInfo.packageName); pulledData.add(e); } } } } } } /** * Pulls various data. */ Loading Loading @@ -2210,6 +2246,10 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { pullExternalStorageInfo(tagId, elapsedNanos, wallClockNanos, ret); break; } case StatsLog.APPS_ON_EXTERNAL_STORAGE_INFO: { pullAppsOnExternalStorageInfo(tagId, elapsedNanos, wallClockNanos, ret); break; } default: Slog.w(TAG, "No such tagId data as " + tagId); return null; Loading