diff options
| author | 2022-07-28 17:15:05 +0100 | |
|---|---|---|
| committer | 2022-07-28 17:15:05 +0100 | |
| commit | 37471ba1ce53615c19401d6202fad5363fa62225 (patch) | |
| tree | feaf932338e2119ff9ee7a08a1d0e42590fd7555 | |
| parent | 3c7368d84c0da3bf03373898900351e430c3742a (diff) | |
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
| -rw-r--r-- | core/java/android/os/UserManager.java | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java index d6566048f2c4..b2f7c60fe3b6 100644 --- a/core/java/android/os/UserManager.java +++ b/core/java/android/os/UserManager.java @@ -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(); } |