diff options
author | Nick Pelly <npelly@google.com> | 2010-10-12 13:07:06 -0700 |
---|---|---|
committer | Nick Pelly <npelly@google.com> | 2010-10-12 13:07:06 -0700 |
commit | 454d2ef0510eb953b5060eb84239682e3ec302be (patch) | |
tree | 4ee238aefd1cc3ba31c245d140b60807b23f6553 | |
parent | 82d2908b2e1fc67f72e40f47fe053efca2bfce6c (diff) | |
download | packages_apps_settings-454d2ef0510eb953b5060eb84239682e3ec302be.zip packages_apps_settings-454d2ef0510eb953b5060eb84239682e3ec302be.tar.gz packages_apps_settings-454d2ef0510eb953b5060eb84239682e3ec302be.tar.bz2 |
Update settings app for new NFC API.
Change-Id: I2702e36d33591245fa86e00454348fc1a16f5cf8
Signed-off-by: Nick Pelly <npelly@google.com>
-rw-r--r-- | src/com/android/settings/nfc/NfcEnabler.java | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/src/com/android/settings/nfc/NfcEnabler.java b/src/com/android/settings/nfc/NfcEnabler.java index 8bd9654..9eb1307 100644 --- a/src/com/android/settings/nfc/NfcEnabler.java +++ b/src/com/android/settings/nfc/NfcEnabler.java @@ -17,9 +17,8 @@ package com.android.settings.nfc; import com.android.settings.R; -import com.trustedlogic.trustednfc.android.NfcException; -import com.trustedlogic.trustednfc.android.NfcManager; import android.content.Context; +import android.nfc.NfcAdapter; import android.preference.Preference; import android.preference.CheckBoxPreference; import android.provider.Settings; @@ -35,23 +34,23 @@ public class NfcEnabler implements Preference.OnPreferenceChangeListener { private final Context mContext; private final CheckBoxPreference mCheckbox; - private final NfcManager mNfcManager; + private final NfcAdapter mNfcAdapter; private boolean mNfcState; public NfcEnabler(Context context, CheckBoxPreference checkBoxPreference) { mContext = context; mCheckbox = checkBoxPreference; - mNfcManager = (NfcManager) context.getSystemService(Context.NFC_SERVICE); + mNfcAdapter = NfcAdapter.getDefaultAdapter(); - if (mNfcManager == null) { + if (mNfcAdapter == null) { // NFC is not supported mCheckbox.setEnabled(false); } } public void resume() { - if (mNfcManager == null) { + if (mNfcAdapter == null) { return; } mCheckbox.setOnPreferenceChangeListener(this); @@ -61,7 +60,7 @@ public class NfcEnabler implements Preference.OnPreferenceChangeListener { } public void pause() { - if (mNfcManager == null) { + if (mNfcAdapter == null) { return; } mCheckbox.setOnPreferenceChangeListener(null); @@ -77,18 +76,13 @@ public class NfcEnabler implements Preference.OnPreferenceChangeListener { private void setEnabled() { if (mNfcState) { - try { - mNfcManager.enable(); - } catch (NfcException e) { - Log.w(TAG, "NFC enabling failed: " + e.getMessage()); + if (!mNfcAdapter.enableTagDiscovery()) { + Log.w(TAG, "NFC enabling failed"); mNfcState = false; } - } else { - try { - mNfcManager.disable(); - } catch (NfcException e) { - Log.w(TAG, "NFC disabling failed: " + e.getMessage()); + if (!mNfcAdapter.disableTagDiscovery()) { + Log.w(TAG, "NFC disabling failed"); mNfcState = true; } } |