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

Commit 1f116038 authored by Suprabh Shukla's avatar Suprabh Shukla
Browse files

Ensure ActivityManagerInternal instance is non-null

Pulling up the initialization to onStart to avoid having earlier code
run into uses of mActivityManagerInternal.

Test: atest CtsAlarmManagerTestCases
atest FrameworksMockingServicesTests:AlarmManagerServiceTest

Fixes: 159651473
Change-Id: I0e06e2062603272eb22b534a81d7c2f0a5236a17
parent 91771191
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -1574,6 +1574,7 @@ public class AlarmManagerService extends SystemService {
                Slog.w(TAG, "Failed to open alarm driver. Falling back to a handler.");
            }
        }
        mActivityManagerInternal = LocalServices.getService(ActivityManagerInternal.class);
        publishLocalService(AlarmManagerInternal.class, new LocalService());
        publishBinderService(Context.ALARM_SERVICE, mService);
    }
@@ -1584,7 +1585,6 @@ public class AlarmManagerService extends SystemService {
            synchronized (mLock) {
                mConstants.start(getContext().getContentResolver());
                mAppOps = (AppOpsManager) getContext().getSystemService(Context.APP_OPS_SERVICE);
                mActivityManagerInternal = LocalServices.getService(ActivityManagerInternal.class);
                mLocalDeviceIdleController =
                        LocalServices.getService(DeviceIdleInternal.class);
                mUsageStatsManagerInternal =
@@ -2137,11 +2137,9 @@ public class AlarmManagerService extends SystemService {

        @Override
        public AlarmManager.AlarmClockInfo getNextAlarmClock(int userId) {
            if (mActivityManagerInternal != null) {
            userId = mActivityManagerInternal.handleIncomingUser(Binder.getCallingPid(),
                    Binder.getCallingUid(), userId, /*allowAll=*/false, ALLOW_NON_FULL,
                    "getNextAlarmClock", null);
            }
            return getNextAlarmClockImpl(userId);
        }