Loading services/core/java/com/android/server/stats/pull/StatsPullAtomService.java +50 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ import android.app.AppOpsManager.HistoricalPackageOps; import android.app.AppOpsManager.HistoricalUidOps; import android.app.INotificationManager; import android.app.ProcessMemoryState; import android.app.RuntimeAppOpAccessMessage; import android.app.StatsManager; import android.app.StatsManager.PullAtomMetadata; import android.bluetooth.BluetoothActivityEnergyInfo; Loading Loading @@ -377,6 +378,8 @@ public class StatsPullAtomService extends SystemService { return pullFaceSettings(atomTag, data); case FrameworkStatsLog.APP_OPS: return pullAppOps(atomTag, data); case FrameworkStatsLog.RUNTIME_APP_OP_ACCESS: return pullRuntimeAppOpAccessMessage(atomTag, data); case FrameworkStatsLog.NOTIFICATION_REMOTE_VIEWS: return pullNotificationRemoteViews(atomTag, data); case FrameworkStatsLog.DANGEROUS_PERMISSION_STATE_SAMPLED: Loading Loading @@ -539,6 +542,7 @@ public class StatsPullAtomService extends SystemService { registerAppsOnExternalStorageInfo(); registerFaceSettings(); registerAppOps(); registerRuntimeAppOpAccessMessage(); registerNotificationRemoteViews(); registerDangerousPermissionState(); registerDangerousPermissionStateSampled(); Loading Loading @@ -2834,6 +2838,17 @@ public class StatsPullAtomService extends SystemService { } private void registerRuntimeAppOpAccessMessage() { int tagId = FrameworkStatsLog.RUNTIME_APP_OP_ACCESS; mStatsManager.registerPullAtomCallback( tagId, null, // use default PullAtomMetadata values BackgroundThread.getExecutor(), mStatsCallbackImpl ); } int pullAppOps(int atomTag, List<StatsEvent> pulledData) { final long token = Binder.clearCallingIdentity(); try { Loading Loading @@ -2894,6 +2909,41 @@ public class StatsPullAtomService extends SystemService { return StatsManager.PULL_SUCCESS; } int pullRuntimeAppOpAccessMessage(int atomTag, List<StatsEvent> pulledData) { final long token = Binder.clearCallingIdentity(); try { AppOpsManager appOps = mContext.getSystemService(AppOpsManager.class); RuntimeAppOpAccessMessage message = appOps.collectRuntimeAppOpAccessMessage(); if (message == null) { Slog.i(TAG, "No runtime appop access message collected"); return StatsManager.PULL_SUCCESS; } StatsEvent.Builder e = StatsEvent.newBuilder(); e.setAtomId(atomTag); e.writeInt(message.getUid()); e.writeString(message.getPackageName()); e.writeString(message.getOp()); if (message.getFeatureId() == null) { e.writeString(""); } else { e.writeString(message.getFeatureId()); } e.writeString(message.getMessage()); e.writeInt(message.getSamplingStrategy()); pulledData.add(e.build()); } catch (Throwable t) { // TODO: catch exceptions at a more granular level Slog.e(TAG, "Could not read runtime appop access message", t); return StatsManager.PULL_SKIP; } finally { Binder.restoreCallingIdentity(token); } return StatsManager.PULL_SUCCESS; } static void unpackStreamedData(int atomTag, List<StatsEvent> pulledData, List<ParcelFileDescriptor> statsFiles) throws IOException { InputStream stream = new ParcelFileDescriptor.AutoCloseInputStream(statsFiles.get(0)); Loading Loading
services/core/java/com/android/server/stats/pull/StatsPullAtomService.java +50 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ import android.app.AppOpsManager.HistoricalPackageOps; import android.app.AppOpsManager.HistoricalUidOps; import android.app.INotificationManager; import android.app.ProcessMemoryState; import android.app.RuntimeAppOpAccessMessage; import android.app.StatsManager; import android.app.StatsManager.PullAtomMetadata; import android.bluetooth.BluetoothActivityEnergyInfo; Loading Loading @@ -377,6 +378,8 @@ public class StatsPullAtomService extends SystemService { return pullFaceSettings(atomTag, data); case FrameworkStatsLog.APP_OPS: return pullAppOps(atomTag, data); case FrameworkStatsLog.RUNTIME_APP_OP_ACCESS: return pullRuntimeAppOpAccessMessage(atomTag, data); case FrameworkStatsLog.NOTIFICATION_REMOTE_VIEWS: return pullNotificationRemoteViews(atomTag, data); case FrameworkStatsLog.DANGEROUS_PERMISSION_STATE_SAMPLED: Loading Loading @@ -539,6 +542,7 @@ public class StatsPullAtomService extends SystemService { registerAppsOnExternalStorageInfo(); registerFaceSettings(); registerAppOps(); registerRuntimeAppOpAccessMessage(); registerNotificationRemoteViews(); registerDangerousPermissionState(); registerDangerousPermissionStateSampled(); Loading Loading @@ -2834,6 +2838,17 @@ public class StatsPullAtomService extends SystemService { } private void registerRuntimeAppOpAccessMessage() { int tagId = FrameworkStatsLog.RUNTIME_APP_OP_ACCESS; mStatsManager.registerPullAtomCallback( tagId, null, // use default PullAtomMetadata values BackgroundThread.getExecutor(), mStatsCallbackImpl ); } int pullAppOps(int atomTag, List<StatsEvent> pulledData) { final long token = Binder.clearCallingIdentity(); try { Loading Loading @@ -2894,6 +2909,41 @@ public class StatsPullAtomService extends SystemService { return StatsManager.PULL_SUCCESS; } int pullRuntimeAppOpAccessMessage(int atomTag, List<StatsEvent> pulledData) { final long token = Binder.clearCallingIdentity(); try { AppOpsManager appOps = mContext.getSystemService(AppOpsManager.class); RuntimeAppOpAccessMessage message = appOps.collectRuntimeAppOpAccessMessage(); if (message == null) { Slog.i(TAG, "No runtime appop access message collected"); return StatsManager.PULL_SUCCESS; } StatsEvent.Builder e = StatsEvent.newBuilder(); e.setAtomId(atomTag); e.writeInt(message.getUid()); e.writeString(message.getPackageName()); e.writeString(message.getOp()); if (message.getFeatureId() == null) { e.writeString(""); } else { e.writeString(message.getFeatureId()); } e.writeString(message.getMessage()); e.writeInt(message.getSamplingStrategy()); pulledData.add(e.build()); } catch (Throwable t) { // TODO: catch exceptions at a more granular level Slog.e(TAG, "Could not read runtime appop access message", t); return StatsManager.PULL_SKIP; } finally { Binder.restoreCallingIdentity(token); } return StatsManager.PULL_SUCCESS; } static void unpackStreamedData(int atomTag, List<StatsEvent> pulledData, List<ParcelFileDescriptor> statsFiles) throws IOException { InputStream stream = new ParcelFileDescriptor.AutoCloseInputStream(statsFiles.get(0)); Loading