diff options
| author | Nick Pelly <npelly@google.com> | 2010-12-07 22:40:28 -0800 |
|---|---|---|
| committer | Nick Pelly <npelly@google.com> | 2010-12-10 17:12:33 -0800 |
| commit | 50b4d8f643f31b37e9872f562fb869059cf79c8a (patch) | |
| tree | 6f866534d961355448a91f04ee5b3bec2b3b7dd5 /core/java/android/app/ContextImpl.java | |
| parent | a218e01437c3c47c49ced7ab363bf98fe92cf1e3 (diff) | |
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
Diffstat (limited to 'core/java/android/app/ContextImpl.java')
| -rw-r--r-- | core/java/android/app/ContextImpl.java | 13 |
1 files changed, 13 insertions, 0 deletions
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) { |
