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

Commit 4dfc368d authored by Yi Jiang's avatar Yi Jiang
Browse files

Resolves null pointer error in AttentionManagerService

Bug: 128940784
Test: manually
Change-Id: I2a9322801528faca2ee08df08bce833b58b0a7e5
parent 3a6c5e6c
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.server.attention;
import static android.provider.DeviceConfig.NAMESPACE_ATTENTION_MANAGER_SERVICE;

import android.Manifest;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.app.ActivityManager;
@@ -553,8 +554,8 @@ public class AttentionManagerService extends SystemService {
        }
    }

    private void cancel(UserState userState, @AttentionFailureCodes int failureCode) {
        if (userState != null && userState.mService != null) {
    private void cancel(@NonNull UserState userState, @AttentionFailureCodes int failureCode) {
        if (userState.mService != null) {
            try {
                userState.mService.cancelAttentionCheck(
                        userState.mCurrentAttentionCheckRequestCode);
@@ -571,6 +572,9 @@ public class AttentionManagerService extends SystemService {
    @GuardedBy("mLock")
    private void cancelAndUnbindLocked(UserState userState) {
        synchronized (mLock) {
            if (userState == null) {
                return;
            }
            cancel(userState, AttentionService.ATTENTION_FAILURE_UNKNOWN);

            mContext.unbindService(userState.mConnection);