Loading cmds/statsd/src/StatsLogProcessor.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -485,6 +485,15 @@ void StatsLogProcessor::informPullAlarmFired(const int64_t timestampNs) { mStatsPullerManager.OnAlarmFired(timestampNs); } int64_t StatsLogProcessor::getLastReportTimeNs(const ConfigKey& key) { auto it = mMetricsManagers.find(key); if (it == mMetricsManagers.end()) { return 0; } else { return it->second->getLastReportTimeNs(); } } } // namespace statsd } // namespace os } // namespace android cmds/statsd/src/StatsLogProcessor.h +2 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,8 @@ public: void informPullAlarmFired(const int64_t timestampNs); int64_t getLastReportTimeNs(const ConfigKey& key); private: // For testing only. inline sp<AlarmMonitor> getAnomalyAlarmMonitor() const { Loading cmds/statsd/src/StatsService.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -90,7 +90,7 @@ StatsService::StatsService(const sp<Looper>& handlerLooper) VLOG("Statscompanion could not find a broadcast receiver for %s", key.ToString().c_str()); } else { sc->sendDataBroadcast(receiver); sc->sendDataBroadcast(receiver, mProcessor->getLastReportTimeNs(key)); } } ); Loading Loading @@ -377,14 +377,15 @@ status_t StatsService::cmd_trigger_broadcast(FILE* out, Vector<String8>& args) { print_cmd_help(out); return UNKNOWN_ERROR; } auto receiver = mConfigManager->GetConfigReceiver(ConfigKey(uid, StrToInt64(name))); ConfigKey key(uid, StrToInt64(name)); auto receiver = mConfigManager->GetConfigReceiver(key); sp<IStatsCompanionService> sc = getStatsCompanionService(); if (sc == nullptr) { VLOG("Could not access statsCompanion"); } else if (receiver == nullptr) { VLOG("Could not find receiver for %s, %s", args[1].c_str(), args[2].c_str()) } else { sc->sendDataBroadcast(receiver); sc->sendDataBroadcast(receiver, mProcessor->getLastReportTimeNs(key)); VLOG("StatsService::trigger broadcast succeeded to %s, %s", args[1].c_str(), args[2].c_str()); } Loading core/java/android/os/IStatsCompanionService.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ interface IStatsCompanionService { StatsLogEventWrapper[] pullData(int pullCode); /** Send a broadcast to the specified PendingIntent's as IBinder that it should getData now. */ oneway void sendDataBroadcast(in IBinder intentSender); oneway void sendDataBroadcast(in IBinder intentSender, long lastReportTimeNs); /** * Requests StatsCompanionService to send a broadcast using the given intentSender Loading services/core/java/com/android/server/stats/StatsCompanionService.java +12 −2 Original line number Diff line number Diff line Loading @@ -107,6 +107,15 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { public static final int CODE_DATA_BROADCAST = 1; public static final int CODE_SUBSCRIBER_BROADCAST = 1; /** * The last report time is provided with each intent registered to * StatsManager#setFetchReportsOperation. This allows easy de-duping in the receiver if * statsd is requesting the client to retrieve the same statsd data. The last report time * corresponds to the last_report_elapsed_nanos that will provided in the current * ConfigMetricsReport, and this timestamp also corresponds to the * current_report_elapsed_nanos of the most recently obtained ConfigMetricsReport. */ public static final String EXTRA_LAST_REPORT_TIME = "android.app.extra.LAST_REPORT_TIME"; public static final int DEATH_THRESHOLD = 10; private final Context mContext; Loading Loading @@ -197,10 +206,11 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { } @Override public void sendDataBroadcast(IBinder intentSenderBinder) { public void sendDataBroadcast(IBinder intentSenderBinder, long lastReportTimeNs) { enforceCallingPermission(); IntentSender intentSender = new IntentSender(intentSenderBinder); Intent intent = new Intent(); intent.putExtra(EXTRA_LAST_REPORT_TIME, lastReportTimeNs); try { intentSender.sendIntent(mContext, CODE_DATA_BROADCAST, intent, null, null); } catch (IntentSender.SendIntentException e) { Loading Loading @@ -274,7 +284,7 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { // Add in all the apps for every user/profile. for (UserInfo profile : users) { List<PackageInfo> pi = pm.getInstalledPackagesAsUser(PackageManager.MATCH_DISABLED_COMPONENTS, profile.id); pm.getInstalledPackagesAsUser(PackageManager.MATCH_KNOWN_PACKAGES, profile.id); for (int j = 0; j < pi.size(); j++) { if (pi.get(j).applicationInfo != null) { uids.add(pi.get(j).applicationInfo.uid); Loading Loading
cmds/statsd/src/StatsLogProcessor.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -485,6 +485,15 @@ void StatsLogProcessor::informPullAlarmFired(const int64_t timestampNs) { mStatsPullerManager.OnAlarmFired(timestampNs); } int64_t StatsLogProcessor::getLastReportTimeNs(const ConfigKey& key) { auto it = mMetricsManagers.find(key); if (it == mMetricsManagers.end()) { return 0; } else { return it->second->getLastReportTimeNs(); } } } // namespace statsd } // namespace os } // namespace android
cmds/statsd/src/StatsLogProcessor.h +2 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,8 @@ public: void informPullAlarmFired(const int64_t timestampNs); int64_t getLastReportTimeNs(const ConfigKey& key); private: // For testing only. inline sp<AlarmMonitor> getAnomalyAlarmMonitor() const { Loading
cmds/statsd/src/StatsService.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -90,7 +90,7 @@ StatsService::StatsService(const sp<Looper>& handlerLooper) VLOG("Statscompanion could not find a broadcast receiver for %s", key.ToString().c_str()); } else { sc->sendDataBroadcast(receiver); sc->sendDataBroadcast(receiver, mProcessor->getLastReportTimeNs(key)); } } ); Loading Loading @@ -377,14 +377,15 @@ status_t StatsService::cmd_trigger_broadcast(FILE* out, Vector<String8>& args) { print_cmd_help(out); return UNKNOWN_ERROR; } auto receiver = mConfigManager->GetConfigReceiver(ConfigKey(uid, StrToInt64(name))); ConfigKey key(uid, StrToInt64(name)); auto receiver = mConfigManager->GetConfigReceiver(key); sp<IStatsCompanionService> sc = getStatsCompanionService(); if (sc == nullptr) { VLOG("Could not access statsCompanion"); } else if (receiver == nullptr) { VLOG("Could not find receiver for %s, %s", args[1].c_str(), args[2].c_str()) } else { sc->sendDataBroadcast(receiver); sc->sendDataBroadcast(receiver, mProcessor->getLastReportTimeNs(key)); VLOG("StatsService::trigger broadcast succeeded to %s, %s", args[1].c_str(), args[2].c_str()); } Loading
core/java/android/os/IStatsCompanionService.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ interface IStatsCompanionService { StatsLogEventWrapper[] pullData(int pullCode); /** Send a broadcast to the specified PendingIntent's as IBinder that it should getData now. */ oneway void sendDataBroadcast(in IBinder intentSender); oneway void sendDataBroadcast(in IBinder intentSender, long lastReportTimeNs); /** * Requests StatsCompanionService to send a broadcast using the given intentSender Loading
services/core/java/com/android/server/stats/StatsCompanionService.java +12 −2 Original line number Diff line number Diff line Loading @@ -107,6 +107,15 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { public static final int CODE_DATA_BROADCAST = 1; public static final int CODE_SUBSCRIBER_BROADCAST = 1; /** * The last report time is provided with each intent registered to * StatsManager#setFetchReportsOperation. This allows easy de-duping in the receiver if * statsd is requesting the client to retrieve the same statsd data. The last report time * corresponds to the last_report_elapsed_nanos that will provided in the current * ConfigMetricsReport, and this timestamp also corresponds to the * current_report_elapsed_nanos of the most recently obtained ConfigMetricsReport. */ public static final String EXTRA_LAST_REPORT_TIME = "android.app.extra.LAST_REPORT_TIME"; public static final int DEATH_THRESHOLD = 10; private final Context mContext; Loading Loading @@ -197,10 +206,11 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { } @Override public void sendDataBroadcast(IBinder intentSenderBinder) { public void sendDataBroadcast(IBinder intentSenderBinder, long lastReportTimeNs) { enforceCallingPermission(); IntentSender intentSender = new IntentSender(intentSenderBinder); Intent intent = new Intent(); intent.putExtra(EXTRA_LAST_REPORT_TIME, lastReportTimeNs); try { intentSender.sendIntent(mContext, CODE_DATA_BROADCAST, intent, null, null); } catch (IntentSender.SendIntentException e) { Loading Loading @@ -274,7 +284,7 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { // Add in all the apps for every user/profile. for (UserInfo profile : users) { List<PackageInfo> pi = pm.getInstalledPackagesAsUser(PackageManager.MATCH_DISABLED_COMPONENTS, profile.id); pm.getInstalledPackagesAsUser(PackageManager.MATCH_KNOWN_PACKAGES, profile.id); for (int j = 0; j < pi.size(); j++) { if (pi.get(j).applicationInfo != null) { uids.add(pi.get(j).applicationInfo.uid); Loading