Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 04f948b4 authored by Jeffrey Huang's avatar Jeffrey Huang
Browse files

Update getReports

Test: GTS Tests
Bug: 146383638
Change-Id: Id640e568d41c5f30e7c42a06addfba644061c706
parent 9613a973
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -99,4 +99,12 @@ interface IStatsManagerService {
     * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS.
     */
    byte[] getMetadata(in String packageName);

    /**
     * Fetches data for the specified configuration key. Returns a byte array representing proto
     * wire-encoded of ConfigMetricsReportList.
     *
     * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS.
     */
    byte[] getData(in long key, in String packageName);
}
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ interface IStatsd {
     *
     * Requires Manifest.permission.DUMP.
     */
    byte[] getData(in long key, in String packageName);
    byte[] getData(in long key, int callingUid);

    /**
     * Fetches metadata across statsd. Returns byte array representing wire-encoded proto.
+19 −0
Original line number Diff line number Diff line
@@ -282,6 +282,25 @@ public class StatsManagerService extends IStatsManagerService.Stub {
        throw new IllegalStateException("Failed to connect to statsd to getMetadata");
    }

    @Override
    public byte[] getData(long key, String packageName) throws IllegalStateException {
        enforceDumpAndUsageStatsPermission(packageName);
        int callingUid = Binder.getCallingUid();
        final long token = Binder.clearCallingIdentity();
        try {
            IStatsd statsd = waitForStatsd();
            if (statsd != null) {
                return statsd.getData(key, callingUid);
            }
        } catch (RemoteException e) {
            Slog.e(TAG, "Failed to getData with statsd");
            throw new IllegalStateException(e.getMessage(), e);
        } finally {
            Binder.restoreCallingIdentity(token);
        }
        throw new IllegalStateException("Failed to connect to statsd to getData");
    }

    void setStatsCompanionService(StatsCompanionService statsCompanionService) {
        mStatsCompanionService = statsCompanionService;
    }
+4 −5
Original line number Diff line number Diff line
@@ -1135,12 +1135,11 @@ void StatsService::OnLogEvent(LogEvent* event) {
    }
}

Status StatsService::getData(int64_t key, const String16& packageName, vector<uint8_t>* output) {
    ENFORCE_DUMP_AND_USAGE_STATS(packageName);
Status StatsService::getData(int64_t key, const int32_t callingUid, vector<uint8_t>* output) {
    ENFORCE_UID(AID_SYSTEM);

    IPCThreadState* ipc = IPCThreadState::self();
    VLOG("StatsService::getData with Pid %i, Uid %i", ipc->getCallingPid(), ipc->getCallingUid());
    ConfigKey configKey(ipc->getCallingUid(), key);
    VLOG("StatsService::getData with Uid %i", callingUid);
    ConfigKey configKey(callingUid, key);
    // The dump latency does not matter here since we do not include the current bucket, we do not
    // need to pull any new data anyhow.
    mProcessor->onDumpReport(configKey, getElapsedRealtimeNs(), false /* include_current_bucket*/,
+1 −1
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@ public:
     * Binder call for clients to request data for this configuration key.
     */
    virtual Status getData(int64_t key,
                           const String16& packageName,
                           const int32_t callingUid,
                           vector<uint8_t>* output) override;


Loading