Loading cmds/statsd/src/atoms.proto +14 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import "frameworks/base/core/proto/android/stats/docsui/docsui_enums.proto"; import "frameworks/base/core/proto/android/stats/devicepolicy/device_policy.proto"; import "frameworks/base/core/proto/android/stats/devicepolicy/device_policy_enums.proto"; import "frameworks/base/core/proto/android/stats/launcher/launcher.proto"; import "frameworks/base/core/proto/android/stats/storage/storage_enums.proto"; import "frameworks/base/core/proto/android/stats/style/style_enums.proto"; import "frameworks/base/core/proto/android/telecomm/enums.proto"; import "frameworks/base/core/proto/android/telephony/enums.proto"; Loading Loading @@ -250,6 +251,7 @@ message Atom { HiddenApiUsed hidden_api_used = 178 [(allow_from_any_uid) = true]; StyleUIChanged style_ui_changed = 179; PrivacyIndicatorsInteracted privacy_indicators_interacted = 180; AppInstallOnExternalStorageReported app_install_on_external_storage_reported = 181; } // Pulled events will start at field 10000. Loading Loading @@ -2557,6 +2559,18 @@ message AppOptimizedAfterDowngraded { optional string package_name = 1; } /** * Logs whenever an app is installed on external storage. * Logged from: frameworks/base/services/core/java/com/android/server/pm/PackageManagerService.java */ message AppInstallOnExternalStorageReported { // The type of external storage. optional android.stats.storage.ExternalStorageType storage_type = 1; // The name of the package that is installed on the sd card. optional string package_name = 2; } /** * Logs when an app crashes. * Logged from: Loading core/proto/android/stats/storage/storage_enums.proto 0 → 100644 +26 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ syntax = "proto2"; package android.stats.storage; enum ExternalStorageType { UNKNOWN = 0; SD_CARD = 1; USB = 2; OTHER = 3; } services/core/java/com/android/server/pm/PackageManagerService.java +39 −1 Original line number Diff line number Diff line Loading @@ -160,9 +160,9 @@ import android.content.pm.InstantAppInfo; import android.content.pm.InstantAppRequest; import android.content.pm.InstrumentationInfo; import android.content.pm.IntentFilterVerificationInfo; import android.content.pm.PackageBackwardCompatibility; import android.content.pm.KeySet; import android.content.pm.ModuleInfo; import android.content.pm.PackageBackwardCompatibility; import android.content.pm.PackageInfo; import android.content.pm.PackageInfoLite; import android.content.pm.PackageInstaller; Loading Loading @@ -232,6 +232,7 @@ import android.os.Trace; import android.os.UserHandle; import android.os.UserManager; import android.os.UserManagerInternal; import android.os.storage.DiskInfo; import android.os.storage.IStorageManager; import android.os.storage.StorageEventListener; import android.os.storage.StorageManager; Loading @@ -245,6 +246,7 @@ import android.provider.Settings.Secure; import android.security.KeyStore; import android.security.SystemKeyStore; import android.service.pm.PackageServiceDumpProto; import android.stats.storage.StorageEnums; import android.system.ErrnoException; import android.system.Os; import android.text.TextUtils; Loading @@ -269,6 +271,7 @@ import android.util.Slog; import android.util.SparseArray; import android.util.SparseBooleanArray; import android.util.SparseIntArray; import android.util.StatsLog; import android.util.TimingsTraceLog; import android.util.Xml; import android.util.jar.StrictJarFile; Loading Loading @@ -1912,6 +1915,15 @@ public class PackageManagerService extends IPackageManager.Stub // Send broadcast package appeared if external for all users if (isExternal(res.pkg)) { if (!update) { int packageExternalStorageType = getPackageExternalStorageType(res.pkg); // If the package was installed externally, log it. if (packageExternalStorageType != StorageEnums.UNKNOWN) { StatsLog.write(StatsLog.APP_INSTALL_ON_EXTERNAL_STORAGE_REPORTED, packageExternalStorageType, res.pkg.packageName); } } if (DEBUG_INSTALL) { Slog.i(TAG, "upgrading pkg " + res.pkg + " is external"); } Loading Loading @@ -2000,6 +2012,32 @@ public class PackageManagerService extends IPackageManager.Stub } } /** * Gets the type of the external storage a package is installed on. * @param pkg The package for which to get the external storage type. * @return {@link StorageEnum#TYPE_UNKNOWN} if it is not stored externally or the corresponding * {@link StorageEnum} storage type value if it is. */ private int getPackageExternalStorageType(PackageParser.Package pkg) { final StorageManager storage = mContext.getSystemService(StorageManager.class); VolumeInfo volume = storage.findVolumeByUuid(pkg.applicationInfo.storageUuid.toString()); if (volume != null) { DiskInfo disk = volume.getDisk(); if (disk != null) { if (disk.isSd()) { return StorageEnums.SD_CARD; } if (disk.isUsb()) { return StorageEnums.USB; } if (isExternal(pkg)) { return StorageEnums.OTHER; } } } return StorageEnums.UNKNOWN; } private StorageEventListener mStorageListener = new StorageEventListener() { @Override public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) { Loading
cmds/statsd/src/atoms.proto +14 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import "frameworks/base/core/proto/android/stats/docsui/docsui_enums.proto"; import "frameworks/base/core/proto/android/stats/devicepolicy/device_policy.proto"; import "frameworks/base/core/proto/android/stats/devicepolicy/device_policy_enums.proto"; import "frameworks/base/core/proto/android/stats/launcher/launcher.proto"; import "frameworks/base/core/proto/android/stats/storage/storage_enums.proto"; import "frameworks/base/core/proto/android/stats/style/style_enums.proto"; import "frameworks/base/core/proto/android/telecomm/enums.proto"; import "frameworks/base/core/proto/android/telephony/enums.proto"; Loading Loading @@ -250,6 +251,7 @@ message Atom { HiddenApiUsed hidden_api_used = 178 [(allow_from_any_uid) = true]; StyleUIChanged style_ui_changed = 179; PrivacyIndicatorsInteracted privacy_indicators_interacted = 180; AppInstallOnExternalStorageReported app_install_on_external_storage_reported = 181; } // Pulled events will start at field 10000. Loading Loading @@ -2557,6 +2559,18 @@ message AppOptimizedAfterDowngraded { optional string package_name = 1; } /** * Logs whenever an app is installed on external storage. * Logged from: frameworks/base/services/core/java/com/android/server/pm/PackageManagerService.java */ message AppInstallOnExternalStorageReported { // The type of external storage. optional android.stats.storage.ExternalStorageType storage_type = 1; // The name of the package that is installed on the sd card. optional string package_name = 2; } /** * Logs when an app crashes. * Logged from: Loading
core/proto/android/stats/storage/storage_enums.proto 0 → 100644 +26 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ syntax = "proto2"; package android.stats.storage; enum ExternalStorageType { UNKNOWN = 0; SD_CARD = 1; USB = 2; OTHER = 3; }
services/core/java/com/android/server/pm/PackageManagerService.java +39 −1 Original line number Diff line number Diff line Loading @@ -160,9 +160,9 @@ import android.content.pm.InstantAppInfo; import android.content.pm.InstantAppRequest; import android.content.pm.InstrumentationInfo; import android.content.pm.IntentFilterVerificationInfo; import android.content.pm.PackageBackwardCompatibility; import android.content.pm.KeySet; import android.content.pm.ModuleInfo; import android.content.pm.PackageBackwardCompatibility; import android.content.pm.PackageInfo; import android.content.pm.PackageInfoLite; import android.content.pm.PackageInstaller; Loading Loading @@ -232,6 +232,7 @@ import android.os.Trace; import android.os.UserHandle; import android.os.UserManager; import android.os.UserManagerInternal; import android.os.storage.DiskInfo; import android.os.storage.IStorageManager; import android.os.storage.StorageEventListener; import android.os.storage.StorageManager; Loading @@ -245,6 +246,7 @@ import android.provider.Settings.Secure; import android.security.KeyStore; import android.security.SystemKeyStore; import android.service.pm.PackageServiceDumpProto; import android.stats.storage.StorageEnums; import android.system.ErrnoException; import android.system.Os; import android.text.TextUtils; Loading @@ -269,6 +271,7 @@ import android.util.Slog; import android.util.SparseArray; import android.util.SparseBooleanArray; import android.util.SparseIntArray; import android.util.StatsLog; import android.util.TimingsTraceLog; import android.util.Xml; import android.util.jar.StrictJarFile; Loading Loading @@ -1912,6 +1915,15 @@ public class PackageManagerService extends IPackageManager.Stub // Send broadcast package appeared if external for all users if (isExternal(res.pkg)) { if (!update) { int packageExternalStorageType = getPackageExternalStorageType(res.pkg); // If the package was installed externally, log it. if (packageExternalStorageType != StorageEnums.UNKNOWN) { StatsLog.write(StatsLog.APP_INSTALL_ON_EXTERNAL_STORAGE_REPORTED, packageExternalStorageType, res.pkg.packageName); } } if (DEBUG_INSTALL) { Slog.i(TAG, "upgrading pkg " + res.pkg + " is external"); } Loading Loading @@ -2000,6 +2012,32 @@ public class PackageManagerService extends IPackageManager.Stub } } /** * Gets the type of the external storage a package is installed on. * @param pkg The package for which to get the external storage type. * @return {@link StorageEnum#TYPE_UNKNOWN} if it is not stored externally or the corresponding * {@link StorageEnum} storage type value if it is. */ private int getPackageExternalStorageType(PackageParser.Package pkg) { final StorageManager storage = mContext.getSystemService(StorageManager.class); VolumeInfo volume = storage.findVolumeByUuid(pkg.applicationInfo.storageUuid.toString()); if (volume != null) { DiskInfo disk = volume.getDisk(); if (disk != null) { if (disk.isSd()) { return StorageEnums.SD_CARD; } if (disk.isUsb()) { return StorageEnums.USB; } if (isExternal(pkg)) { return StorageEnums.OTHER; } } } return StorageEnums.UNKNOWN; } private StorageEventListener mStorageListener = new StorageEventListener() { @Override public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) {