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

Commit e770ea6b authored by Soonil Nagarkar's avatar Soonil Nagarkar
Browse files

Move all UI thread callbacks off ui thread to mitigate watchdog kills

Test: manual
Bug: 124288687
Change-Id: I7b869911cce6507905903e70a280ee4bcd63a542
parent c6479fd8
Loading
Loading
Loading
Loading
+21 −9
Original line number Diff line number Diff line
@@ -323,16 +323,24 @@ public class LocationManagerService extends ILocationManager.Stub {
                });
        mPackageManager.addOnPermissionsChangeListener(
                uid -> {
                    // listener invoked on ui thread, move to our thread to reduce risk of blocking
                    // ui thread
                    mHandler.post(() -> {
                        synchronized (mLock) {
                            onPermissionsChangedLocked();
                        }
                    });
                });

        mActivityManager.addOnUidImportanceListener(
                (uid, importance) -> {
                    // listener invoked on ui thread, move to our thread to reduce risk of blocking
                    // ui thread
                    mHandler.post(() -> {
                        synchronized (mLock) {
                            onUidImportanceChangedLocked(uid, importance);
                        }
                    });
                },
                FOREGROUND_IMPORTANCE_CUTOFF);
        mContext.getContentResolver().registerContentObserver(
@@ -394,10 +402,14 @@ public class LocationManagerService extends ILocationManager.Stub {
                LocalServices.getService(PowerManagerInternal.class);
        localPowerManager.registerLowPowerModeObserver(ServiceType.LOCATION,
                state -> {
                    // listener invoked on ui thread, move to our thread to reduce risk of blocking
                    // ui thread
                    mHandler.post(() -> {
                        synchronized (mLock) {
                            onBatterySaverModeChangedLocked(state.locationMode);
                        }
                    });
                });

        new PackageMonitor() {
            @Override