Don't use Context#getApplicationContext

as this might be null. In PermissionControllerManager we need a context
that outlives the passed in context as we bind to a service that will
only get destroyed after a delay.

Test: atest PermissionControllerTest
Bug: 131356152
Change-Id: Iabeac669f6464b84a4b9e8f9b2a27959b116c25b
This commit is contained in:
Philip P. Moltmann
2019-04-25 16:09:03 -07:00
parent c74d6b563b
commit d56c6bdfa9

View File

@@ -39,6 +39,7 @@ import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.app.ActivityThread;
import android.app.admin.DevicePolicyManager.PermissionGrantState;
import android.content.ComponentName;
import android.content.Context;
@@ -232,7 +233,7 @@ public final class PermissionControllerManager {
intent.setPackage(context.getPackageManager().getPermissionControllerPackageName());
ResolveInfo serviceInfo = context.getPackageManager().resolveService(intent, 0);
remoteService = new RemoteService(context.getApplicationContext(),
remoteService = new RemoteService(ActivityThread.currentApplication(),
serviceInfo.getComponentInfo().getComponentName(), handler,
context.getUser());
sRemoteServices.put(key, remoteService);