Fix work profile applications do not receive event transaction data

Extend the API to be able to check NFC event permission based on userId.
Get packageManager based on userId.

Bug: 192994529
Test: manually with CtsVerifier
Change-Id: Ic52d6a40c289f686b692d1cfc138b943ac761869
diff --git a/src/com/android/se/SecureElementService.java b/src/com/android/se/SecureElementService.java
index fb2e771..9183649 100644
--- a/src/com/android/se/SecureElementService.java
+++ b/src/com/android/se/SecureElementService.java
@@ -22,7 +22,6 @@
 
 package com.android.se;
 
-import android.app.ActivityManager;
 import android.app.Service;
 import android.content.BroadcastReceiver;
 import android.content.Context;
@@ -123,8 +122,8 @@
         }
 
         @Override
-        public synchronized boolean[] isNFCEventAllowed(String reader, byte[] aid,
-                String[] packageNames) throws RemoteException {
+        public synchronized boolean[] isNfcEventAllowed(String reader, byte[] aid,
+                String[] packageNames, int userId) throws RemoteException {
             if (aid == null || aid.length == 0) {
                 aid = new byte[]{0x00, 0x00, 0x00, 0x00, 0x00};
             }
@@ -135,10 +134,9 @@
                 throw new IllegalArgumentException("package names not specified");
             }
             Terminal terminal = getTerminal(reader);
-            UserHandle currentUser = new UserHandle(ActivityManager.getCurrentUser());
             return terminal.isNfcEventAllowed(
-                    createContextAsUser(currentUser, /*flags=*/0).getPackageManager(),
-                    aid, packageNames);
+                    createContextAsUser(UserHandle.of(userId), /*flags=*/0)
+                    .getPackageManager(), aid, packageNames);
         }
 
         @Override