Improve isNfcEventAllowed am: cba6328078 am: e8b9e10170

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

Change-Id: I868489737a52d48fe458d1bc794a9e409f980303
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) {