Use ActivityThread.currentApplication() for application context.

Context.getApplicationContext() might return null if the context is
created with Context.createPackageContextAsUser(), as the application
instance for that context won't be created. In this case we can use
ActivityThread.currentApplication() directly, which does the same
thing as if the context wasn't created for a specific package or user.
We are only using this application context to bind to other services
so it will work fine.

Bug: 131356152
Test: presubmit
Change-Id: Iee1ac9aa088d452dc58dd7f19edc58a3e0b791a6
diff --git a/core/java/android/app/role/RoleControllerManager.java b/core/java/android/app/role/RoleControllerManager.java
index 9186b3d..668dbd4 100644
--- a/core/java/android/app/role/RoleControllerManager.java
+++ b/core/java/android/app/role/RoleControllerManager.java
@@ -22,6 +22,7 @@
 import android.annotation.RequiresPermission;
 import android.annotation.SystemService;
 import android.annotation.UserIdInt;
+import android.app.ActivityThread;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
@@ -93,7 +94,7 @@
             int userId = context.getUserId();
             RemoteService remoteService = sRemoteServices.get(userId);
             if (remoteService == null) {
-                remoteService = new RemoteService(context.getApplicationContext(),
+                remoteService = new RemoteService(ActivityThread.currentApplication(),
                         remoteServiceComponentName, handler, userId);
                 sRemoteServices.put(userId, remoteService);
             }