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

Commit fa1c137d authored by Tej Singh's avatar Tej Singh
Browse files

Allow pullAtomCallbacks to be unregistered in Java

Adds an API to unregister pullAtomCallbacks.
Fixes bug where the StatsEventParcels are null.
Makes onPullAtom a oneway call.
OnPullAtom returns an int code instead of a boolean
Made the APIs return RuntimeExceptions

Test: make, boots
Test: atest GtsStatsdHostTestCases
Bug: 146385842
Bug: 146385173
Bug: 144373250
Change-Id: I107a705a9024240c5c9f9e276293de8410e2b6f3
parent d2d7462e
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -26,6 +26,6 @@ interface IPullAtomCallback {
    /**
    /**
     * Initiate a request for a pull for an atom.
     * Initiate a request for a pull for an atom.
     */
     */
     void onPullAtom(int atomTag, IPullAtomResultReceiver resultReceiver);
     oneway void onPullAtom(int atomTag, IPullAtomResultReceiver resultReceiver);


}
}
+3 −0
Original line number Original line Diff line number Diff line
@@ -90,4 +90,7 @@ interface IStatsCompanionService {
    /** Tells StatsCompanionService to tell statsd to register a puller for the given atom id */
    /** Tells StatsCompanionService to tell statsd to register a puller for the given atom id */
    oneway void registerPullAtomCallback(int atomTag, long coolDownNs, long timeoutNs,
    oneway void registerPullAtomCallback(int atomTag, long coolDownNs, long timeoutNs,
            in int[] additiveFields, IPullAtomCallback pullerCallback);
            in int[] additiveFields, IPullAtomCallback pullerCallback);

    /** Tells StatsCompanionService to tell statsd to unregister a puller for the given atom id */
    oneway void unregisterPullAtomCallback(int atomTag);
}
}
+5 −0
Original line number Original line Diff line number Diff line
@@ -215,6 +215,11 @@ interface IStatsd {
    */
    */
   oneway void unregisterPullerCallback(int atomTag, String packageName);
   oneway void unregisterPullerCallback(int atomTag, String packageName);


  /**
   * Unregisters any pullAtomCallback for the given uid/atom.
   */
   oneway void unregisterPullAtomCallback(int uid, int atomTag);

    /**
    /**
     * The install requires staging.
     * The install requires staging.
     */
     */
+24 −0
Original line number Original line Diff line number Diff line
@@ -2738,6 +2738,30 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
        }
        }
    }
    }


    @Override
    public void unregisterPullAtomCallback(int atomTag) {
        synchronized (sStatsdLock) {
            // Always remove the puller in SCS.
            // If statsd is down, we will not register it when it comes back up.
            int callingUid = Binder.getCallingUid();
            final long token = Binder.clearCallingIdentity();
            PullerKey key = new PullerKey(callingUid, atomTag);
            mPullers.remove(key);

            if (sStatsd == null) {
                Slog.w(TAG, "Could not access statsd for registering puller for atom " + atomTag);
                return;
            }
            try {
                sStatsd.unregisterPullAtomCallback(callingUid, atomTag);
            } catch (RemoteException e) {
                Slog.e(TAG, "Failed to access statsd to register puller for atom " + atomTag);
            } finally {
                Binder.restoreCallingIdentity(token);
            }
        }
    }

    // Statsd related code
    // Statsd related code


    /**
    /**
+7 −0
Original line number Original line Diff line number Diff line
@@ -1320,6 +1320,13 @@ Status StatsService::unregisterPullerCallback(int32_t atomTag, const String16& p
    return Status::ok();
    return Status::ok();
}
}


Status StatsService::unregisterPullAtomCallback(int32_t uid, int32_t atomTag) {
    ENFORCE_UID(AID_SYSTEM);
    VLOG("StatsService::unregisterPullAtomCallback called.");
    mPullerManager->UnregisterPullAtomCallback(uid, atomTag);
    return Status::ok();
}

Status StatsService::sendBinaryPushStateChangedAtom(const android::String16& trainNameIn,
Status StatsService::sendBinaryPushStateChangedAtom(const android::String16& trainNameIn,
                                                    const int64_t trainVersionCodeIn,
                                                    const int64_t trainVersionCodeIn,
                                                    const int options,
                                                    const int options,
Loading