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

Commit 9a6e3f4b authored by Matías Hernández's avatar Matías Hernández
Browse files

Use elapsedRealtimeClock as time source for RateEstimator in NM

InstantSource.system is basically currentTimeMillis(), which means it's not suitable for timing (can jump forward or backwards). For rate estimation, we don't care about correspondence with real-world time, so elapsedRealtime() is what we want.

Also moved the creation of the InstantSource to NotificationManager; SystemServiceRegistry shouldn't need to be concerned about this, nor know the details of the specific time source that is best.

Bug: 381875150
Test: manual
Flag: android.app.nm_binder_perf_throttle_notify
Change-Id: Ic336b8d26777a875476c75950875657265b2fa16
parent 6b0271bd
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ import android.os.Parcelable;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.StrictMode;
import android.os.SystemClock;
import android.os.UserHandle;
import android.provider.Settings;
import android.provider.Settings.Global;
@@ -677,9 +678,14 @@ public class NotificationManager {
    }

    /** {@hide} */
    @UnsupportedAppUsage
    public NotificationManager(Context context, InstantSource clock)
    public NotificationManager(Context context)
    {
        this(context, SystemClock.elapsedRealtimeClock());
    }

    /** {@hide} */
    @UnsupportedAppUsage
    public NotificationManager(Context context, InstantSource clock) {
        mContext = context;
        mClock = clock;
    }
+2 −3
Original line number Diff line number Diff line
@@ -289,7 +289,6 @@ import com.android.internal.os.IDropBoxManagerService;
import com.android.internal.policy.PhoneLayoutInflater;
import com.android.internal.util.Preconditions;

import java.time.InstantSource;
import java.util.Map;
import java.util.Objects;

@@ -625,8 +624,8 @@ public final class SystemServiceRegistry {
                                    com.android.internal.R.style.Theme_Dialog,
                                    com.android.internal.R.style.Theme_Holo_Dialog,
                                    com.android.internal.R.style.Theme_DeviceDefault_Dialog,
                                    com.android.internal.R.style.Theme_DeviceDefault_Light_Dialog)),
                    InstantSource.system());
                                    com.android.internal.R.style.Theme_DeviceDefault_Light_Dialog))
                );
            }});

        registerService(Context.PEOPLE_SERVICE, PeopleManager.class,