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

Commit 185a29a5 authored by Neil Fuller's avatar Neil Fuller
Browse files

Clear calling identity before doing any work

This makes sure that the system server is credited/blamed
for the logic being executed.

Test: (internal) atest FrameworksServicesTests:com.android.server.timedetector
Bug: 78217059
Change-Id: Ie2586cf0d983e9aef9371d6db285c8420e9c8dc0
parent 5392d799
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.annotation.Nullable;
import android.app.timedetector.ITimeDetectorService;
import android.app.timedetector.TimeSignal;
import android.content.Context;
import android.os.Binder;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.DumpUtils;
@@ -69,7 +70,13 @@ public final class TimeDetectorService extends ITimeDetectorService.Stub {
    @Override
    public void suggestTime(@NonNull TimeSignal timeSignal) {
        enforceSetTimePermission();

        long callerIdToken = Binder.clearCallingIdentity();
        try {
            mTimeDetectorStrategy.suggestTime(timeSignal);
        } finally {
            Binder.restoreCallingIdentity(callerIdToken);
        }
    }

    @Override