From 50b4d8f643f31b37e9872f562fb869059cf79c8a Mon Sep 17 00:00:00 2001 From: Nick Pelly Date: Tue, 7 Dec 2010 22:40:28 -0800 Subject: Make getSystemService(NFC_SERVICE) the NFC entry point. This gives NFC service a handle to the application context. Deprecate NfcAdapter.getDefaultAdapter(), it does not provide a context. Using this method will print a warning, and will later throw an exception if a method that requires a context is called. No 2.3 API's will fail, but new API's that do require a context might fail. Also add helper NfcAdapter.getDefaultAdapter(Context). Change-Id: I9a6378de4ef4b61ad922f8d53e64e2a1a1d5d60c --- core/java/android/app/ContextImpl.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'core/java/android/app/ContextImpl.java') diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index 599807427e7c..7e7cd7a8dcf2 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -72,6 +72,7 @@ import android.net.IThrottleManager; import android.net.Uri; import android.net.wifi.IWifiManager; import android.net.wifi.WifiManager; +import android.nfc.NfcManager; import android.os.Binder; import android.os.Bundle; import android.os.DropBoxManager; @@ -201,6 +202,7 @@ class ContextImpl extends Context { private DevicePolicyManager mDevicePolicyManager = null; private UiModeManager mUiModeManager = null; private DownloadManager mDownloadManager = null; + private NfcManager mNfcManager = null; private final Object mSync = new Object(); @@ -977,6 +979,8 @@ class ContextImpl extends Context { return getUiModeManager(); } else if (DOWNLOAD_SERVICE.equals(name)) { return getDownloadManager(); + } else if (NFC_SERVICE.equals(name)) { + return getNfcManager(); } return null; @@ -1204,6 +1208,15 @@ class ContextImpl extends Context { return mDownloadManager; } + private NfcManager getNfcManager() { + synchronized (mSync) { + if (mNfcManager == null) { + mNfcManager = new NfcManager(this); + } + } + return mNfcManager; + } + @Override public int checkPermission(String permission, int pid, int uid) { if (permission == null) { -- cgit v1.2.3