Loading apex/statsd/aidl/android/os/IStatsCompanionService.aidl +0 −3 Original line number Diff line number Diff line Loading @@ -59,9 +59,6 @@ interface IStatsCompanionService { /** Cancel any alarm for the purpose of subscriber triggering. */ oneway void cancelAlarmForSubscriberTriggering(); /** Tells StatsCompaionService to grab the uid map snapshot and send it to statsd. */ oneway void triggerUidSnapshot(); /** * Ask StatsCompanionService if the given permission is allowed for a particular process * and user ID. statsd is incapable of doing this check itself because checkCallingPermission Loading apex/statsd/service/java/com/android/server/stats/StatsCompanionService.java +22 −38 Original line number Diff line number Diff line Loading @@ -153,7 +153,7 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { } } private static void informAllUidsLocked(Context context) throws RemoteException { private static void informAllUids(Context context) { UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE); PackageManager pm = context.getPackageManager(); final List<UserHandle> users = um.getUserHandles(true); Loading @@ -168,18 +168,26 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { Log.e(TAG, "Failed to create a pipe to send uid map data.", e); return; } sStatsd.informAllUidData(fds[0]); HandlerThread backgroundThread = new HandlerThread( "statsCompanionService.bg", THREAD_PRIORITY_BACKGROUND); backgroundThread.start(); Handler handler = new Handler(backgroundThread.getLooper()); handler.post(() -> { IStatsd statsd = getStatsdNonblocking(); if (statsd == null) { return; } try { statsd.informAllUidData(fds[0]); } catch (RemoteException e) { Log.e(TAG, "Failed to send uid map to statsd"); } try { fds[0].close(); } catch (IOException e) { Log.e(TAG, "Failed to close the read side of the pipe.", e); } final ParcelFileDescriptor writeFd = fds[1]; HandlerThread backgroundThread = new HandlerThread( "statsCompanionService.bg", THREAD_PRIORITY_BACKGROUND); backgroundThread.start(); Handler handler = new Handler(backgroundThread.getLooper()); handler.post(() -> { FileOutputStream fout = new ParcelFileDescriptor.AutoCloseOutputStream(writeFd); try { ProtoOutputStream output = new ProtoOutputStream(fout); Loading @@ -188,7 +196,8 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { for (UserHandle userHandle : users) { List<PackageInfo> pi = pm.getInstalledPackagesAsUser(PackageManager.MATCH_UNINSTALLED_PACKAGES | PackageManager.MATCH_ANY_USER, | PackageManager.MATCH_ANY_USER | PackageManager.MATCH_APEX, userHandle.getIdentifier()); for (int j = 0; j < pi.size(); j++) { if (pi.get(j).applicationInfo != null) { Loading Loading @@ -319,19 +328,9 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { private static final class UserUpdateReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { synchronized (sStatsdLock) { if (sStatsd == null) { Log.w(TAG, "Could not access statsd for UserUpdateReceiver"); return; } try { // Pull the latest state of UID->app name, version mapping. // Needed since the new user basically has a version of every app. informAllUidsLocked(context); } catch (RemoteException e) { Log.e(TAG, "Failed to inform statsd latest update of all apps", e); } } informAllUids(context); } } Loading Loading @@ -588,21 +587,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { } } @Override // Binder call public void triggerUidSnapshot() { StatsCompanion.enforceStatsdCallingUid(); synchronized (sStatsdLock) { final long token = Binder.clearCallingIdentity(); try { informAllUidsLocked(mContext); } catch (RemoteException e) { Log.e(TAG, "Failed to trigger uid snapshot.", e); } finally { Binder.restoreCallingIdentity(token); } } } @Override // Binder call public boolean checkPermission(String permission, int pid, int uid) { StatsCompanion.enforceStatsdCallingUid(); Loading Loading @@ -707,7 +691,7 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { try { // Pull the latest state of UID->app name, version mapping when // statsd starts. informAllUidsLocked(mContext); informAllUids(mContext); } finally { Binder.restoreCallingIdentity(token); } Loading Loading
apex/statsd/aidl/android/os/IStatsCompanionService.aidl +0 −3 Original line number Diff line number Diff line Loading @@ -59,9 +59,6 @@ interface IStatsCompanionService { /** Cancel any alarm for the purpose of subscriber triggering. */ oneway void cancelAlarmForSubscriberTriggering(); /** Tells StatsCompaionService to grab the uid map snapshot and send it to statsd. */ oneway void triggerUidSnapshot(); /** * Ask StatsCompanionService if the given permission is allowed for a particular process * and user ID. statsd is incapable of doing this check itself because checkCallingPermission Loading
apex/statsd/service/java/com/android/server/stats/StatsCompanionService.java +22 −38 Original line number Diff line number Diff line Loading @@ -153,7 +153,7 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { } } private static void informAllUidsLocked(Context context) throws RemoteException { private static void informAllUids(Context context) { UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE); PackageManager pm = context.getPackageManager(); final List<UserHandle> users = um.getUserHandles(true); Loading @@ -168,18 +168,26 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { Log.e(TAG, "Failed to create a pipe to send uid map data.", e); return; } sStatsd.informAllUidData(fds[0]); HandlerThread backgroundThread = new HandlerThread( "statsCompanionService.bg", THREAD_PRIORITY_BACKGROUND); backgroundThread.start(); Handler handler = new Handler(backgroundThread.getLooper()); handler.post(() -> { IStatsd statsd = getStatsdNonblocking(); if (statsd == null) { return; } try { statsd.informAllUidData(fds[0]); } catch (RemoteException e) { Log.e(TAG, "Failed to send uid map to statsd"); } try { fds[0].close(); } catch (IOException e) { Log.e(TAG, "Failed to close the read side of the pipe.", e); } final ParcelFileDescriptor writeFd = fds[1]; HandlerThread backgroundThread = new HandlerThread( "statsCompanionService.bg", THREAD_PRIORITY_BACKGROUND); backgroundThread.start(); Handler handler = new Handler(backgroundThread.getLooper()); handler.post(() -> { FileOutputStream fout = new ParcelFileDescriptor.AutoCloseOutputStream(writeFd); try { ProtoOutputStream output = new ProtoOutputStream(fout); Loading @@ -188,7 +196,8 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { for (UserHandle userHandle : users) { List<PackageInfo> pi = pm.getInstalledPackagesAsUser(PackageManager.MATCH_UNINSTALLED_PACKAGES | PackageManager.MATCH_ANY_USER, | PackageManager.MATCH_ANY_USER | PackageManager.MATCH_APEX, userHandle.getIdentifier()); for (int j = 0; j < pi.size(); j++) { if (pi.get(j).applicationInfo != null) { Loading Loading @@ -319,19 +328,9 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { private static final class UserUpdateReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { synchronized (sStatsdLock) { if (sStatsd == null) { Log.w(TAG, "Could not access statsd for UserUpdateReceiver"); return; } try { // Pull the latest state of UID->app name, version mapping. // Needed since the new user basically has a version of every app. informAllUidsLocked(context); } catch (RemoteException e) { Log.e(TAG, "Failed to inform statsd latest update of all apps", e); } } informAllUids(context); } } Loading Loading @@ -588,21 +587,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { } } @Override // Binder call public void triggerUidSnapshot() { StatsCompanion.enforceStatsdCallingUid(); synchronized (sStatsdLock) { final long token = Binder.clearCallingIdentity(); try { informAllUidsLocked(mContext); } catch (RemoteException e) { Log.e(TAG, "Failed to trigger uid snapshot.", e); } finally { Binder.restoreCallingIdentity(token); } } } @Override // Binder call public boolean checkPermission(String permission, int pid, int uid) { StatsCompanion.enforceStatsdCallingUid(); Loading Loading @@ -707,7 +691,7 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { try { // Pull the latest state of UID->app name, version mapping when // statsd starts. informAllUidsLocked(mContext); informAllUids(mContext); } finally { Binder.restoreCallingIdentity(token); } Loading