Do not let guest user disable secuer nfc via SettingsSlice

Do not let guest user switch the secure nfc preferernce setting.

Bug: 228314987
Test: manual
Change-Id: I60a832e32d83bb57d968af2f8b92d94e2ac7c6a2
(cherry picked from commit 2290b0af8cb4b640709fa904f73ce3e69208f872)
Merged-In: I60a832e32d83bb57d968af2f8b92d94e2ac7c6a2
diff --git a/src/com/android/settings/nfc/SecureNfcPreferenceController.java b/src/com/android/settings/nfc/SecureNfcPreferenceController.java
index 4e548d1..575bab1 100644
--- a/src/com/android/settings/nfc/SecureNfcPreferenceController.java
+++ b/src/com/android/settings/nfc/SecureNfcPreferenceController.java
@@ -17,6 +17,7 @@
 
 import android.content.Context;
 import android.nfc.NfcAdapter;
+import android.os.UserManager;
 
 import androidx.preference.PreferenceScreen;
 import androidx.preference.SwitchPreference;
@@ -31,10 +32,12 @@
 
     private final NfcAdapter mNfcAdapter;
     private SecureNfcEnabler mSecureNfcEnabler;
+    private final UserManager mUserManager;
 
     public SecureNfcPreferenceController(Context context, String key) {
         super(context, key);
         mNfcAdapter = NfcAdapter.getDefaultAdapter(context);
+        mUserManager = context.getSystemService(UserManager.class);
     }
 
     @Override
@@ -57,7 +60,11 @@
 
     @Override
     public boolean setChecked(boolean isChecked) {
-        return mNfcAdapter.enableSecureNfc(isChecked);
+        if (isToggleable()) {
+            return mNfcAdapter.enableSecureNfc(isChecked);
+        } else {
+            return false;
+        }
     }
 
     @Override
@@ -94,4 +101,12 @@
             mSecureNfcEnabler.pause();
         }
     }
+
+    private boolean isToggleable() {
+        if (mUserManager.isGuestUser()) {
+            return false;
+        }
+        return true;
+    }
+
 }