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

Commit d17175f6 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Avoid NullPointerException" into main

parents 8b5b8a45 ed587c17
Loading
Loading
Loading
Loading
+18 −11
Original line number Diff line number Diff line
@@ -68,6 +68,10 @@ class UserDataPreparer {
    void prepareUserData(UserInfo userInfo, int flags) {
        try (PackageManagerTracedLock installLock = mInstallLock.acquireLock()) {
            final StorageManager storage = mContext.getSystemService(StorageManager.class);
            if (storage == null) {
                Log.e(TAG, "prepareUserData failed due to unable get StorageManager");
                return;
            }
            /*
             * Internal storage must be prepared before adoptable storage, since the user's volume
             * keys are stored in their internal storage.
@@ -159,6 +163,7 @@ class UserDataPreparer {
    void destroyUserData(int userId, int flags) {
        try (PackageManagerTracedLock installLock = mInstallLock.acquireLock()) {
            final StorageManager storage = mContext.getSystemService(StorageManager.class);
            if (storage != null) {
                /*
                 * Volume destruction order isn't really important, but to avoid any weird issues we
                 * process internal storage last, the opposite of prepareUserData.
@@ -169,6 +174,7 @@ class UserDataPreparer {
                        destroyUserDataLI(volumeUuid, userId, flags);
                    }
                }
            }
            destroyUserDataLI(null /* internal storage */, userId, flags);
        }
    }
@@ -194,9 +200,10 @@ class UserDataPreparer {
                }
            }

            if (storage != null) {
                // All the user's data directories should be empty now, so finish the job.
                storage.destroyUserStorage(volumeUuid, userId, flags);

            }
        } catch (Exception e) {
            logCriticalInfo(Log.WARN,
                    "Failed to destroy user " + userId + " on volume " + volumeUuid + ": " + e);