Improve isNfcEventAllowed am: cba6328078

Original change: https://android-review.googlesource.com/c/platform/packages/apps/SecureElement/+/1673187

Change-Id: Id8fa28ac5d0501f2f4d442c251fcd2a4778d291b
diff --git a/src/com/android/se/Terminal.java b/src/com/android/se/Terminal.java
index d858426..139390b 100644
--- a/src/com/android/se/Terminal.java
+++ b/src/com/android/se/Terminal.java
@@ -684,11 +684,16 @@
      */
     public boolean[] isNfcEventAllowed(PackageManager packageManager, byte[] aid,
             String[] packageNames) {
+        if (!mIsConnected) {
+            // Return if not connected
+            return null;
+        }
         // Attempt to initialize the access control enforcer if it failed in the previous attempt
         // due to a kind of temporary failure or no rule was found.
         if (mAccessControlEnforcer == null || mAccessControlEnforcer.isNoRuleFound()) {
             try {
                 initializeAccessControl();
+                Log.i(mTag, "AccessControlEnforcer initialized");
                 // Just finished to initialize the access control enforcer.
                 // It is too much to check the refresh tag in this case.
             } catch (Exception e) {