Check for null application context in UserManager.

UserManager currently always uses getApplicationContext for its
internal context object, but that method can return null under certain
circumstances. This CL adds a null check, so that the original context
is used if the app context is null.

Bug: 232179155
Bug: 233915566
Test: atest UserManagerTest
Test: install Apex Launcher and App Hider on device with work profile
Change-Id: I26bcf693da8f5bc53126f79f9e6ffb17bd87fc84
This commit is contained in:
Oli Lan
2022-07-28 17:15:05 +01:00
parent 3c7368d84c
commit 37471ba1ce

View File

@@ -1971,7 +1971,8 @@ public class UserManager {
/** @hide */
public UserManager(Context context, IUserManager service) {
mService = service;
mContext = context.getApplicationContext();
Context appContext = context.getApplicationContext();
mContext = (appContext == null ? context : appContext);
mUserId = context.getUserId();
}