Fix NPE when onStopUser.

The default value of mConnection is null, it initializes lazy when we
are serving the first request. Due to no request comes, the mConnection
keeps null which causes NPE.

Bug: 144356634
Test: Manual. Create work profile. Make usre no NPE when stop work profile.
Change-Id: Id656a83989e18ac6f62c1456609bd55e44663914
This commit is contained in:
Joanne Chung
2019-11-13 11:01:42 +08:00
parent a3eb427847
commit e3ca05bbf9

View File

@@ -120,7 +120,9 @@ public final class TextClassificationManagerService extends ITextClassifierServi
synchronized (mManagerService.mLock) {
UserState userState = mManagerService.peekUserStateLocked(userId);
if (userState != null) {
userState.mConnection.cleanupService();
if (userState.mConnection != null) {
userState.mConnection.cleanupService();
}
mManagerService.mUserStates.remove(userId);
}
}