Run performInitialGrantsIfNecessaryAsync() on main thread.

performInitialGrantsIfNecessaryAsync() is already made asynchronous,
so it is no longer necessary to post it to a thread pool. After this
change both this method and onRemoveUser() can run on the main thread,
so that we won't run into a race condition with a destroyed user
state.

Bug: 130738316
Test: presubmit
Change-Id: I9f6e4d9badddf5396c5a9aee683b67739c82884a
This commit is contained in:
Hai Zhang
2019-04-18 12:08:30 +08:00
parent 30550e1f3e
commit 22ce5e5d83

View File

@@ -39,7 +39,6 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.PackageManagerInternal;
import android.content.pm.Signature;
import android.database.CursorWindow;
import android.os.AsyncTask;
import android.os.Binder;
import android.os.Bundle;
import android.os.Handler;
@@ -201,8 +200,7 @@ public class RoleManagerService extends SystemService implements RoleUserState.C
// Package is being upgraded - we're about to get ACTION_PACKAGE_ADDED
return;
}
AsyncTask.THREAD_POOL_EXECUTOR.execute(
() -> performInitialGrantsIfNecessaryAsync(userId));
performInitialGrantsIfNecessaryAsync(userId);
}
}, UserHandle.ALL, intentFilter, null, null);
}