Revert "NFC Unlock api changes"
This reverts commit 9fef5fbcd6d47ef86823b3a2d82d34801f9be335. Change-Id: Idabe1c2901e0e26d38f84583308f69804ab2c1c3
This commit is contained in:
@@ -186,7 +186,6 @@ LOCAL_SRC_FILES += \
|
||||
core/java/android/nfc/INfcTag.aidl \
|
||||
core/java/android/nfc/INfcCardEmulation.aidl \
|
||||
core/java/android/nfc/INfcLockscreenDispatch.aidl \
|
||||
core/java/android/nfc/INfcUnlockHandler.aidl \
|
||||
core/java/android/os/IBatteryPropertiesListener.aidl \
|
||||
core/java/android/os/IBatteryPropertiesRegistrar.aidl \
|
||||
core/java/android/os/ICancellationSignal.aidl \
|
||||
|
||||
@@ -27,7 +27,6 @@ import android.nfc.INfcAdapterExtras;
|
||||
import android.nfc.INfcTag;
|
||||
import android.nfc.INfcCardEmulation;
|
||||
import android.nfc.INfcLockscreenDispatch;
|
||||
import android.nfc.INfcUnlockHandler;
|
||||
import android.os.Bundle;
|
||||
|
||||
/**
|
||||
@@ -58,6 +57,4 @@ interface INfcAdapter
|
||||
void setP2pModes(int initatorModes, int targetModes);
|
||||
|
||||
void registerLockscreenDispatch(INfcLockscreenDispatch lockscreenDispatch, in int[] techList);
|
||||
void addNfcUnlockHandler(INfcUnlockHandler unlockHandler, in int[] techList);
|
||||
void removeNfcUnlockHandler(IBinder b);
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
package android.nfc;
|
||||
|
||||
import android.nfc.Tag;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
interface INfcUnlockHandler {
|
||||
|
||||
boolean onUnlockAttempted(in Tag tag);
|
||||
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import android.content.IntentFilter;
|
||||
import android.content.pm.IPackageManager;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.nfc.BeamShareData;
|
||||
import android.nfc.tech.MifareClassic;
|
||||
import android.nfc.tech.Ndef;
|
||||
import android.nfc.tech.NfcA;
|
||||
@@ -311,8 +312,6 @@ public final class NfcAdapter {
|
||||
|
||||
final NfcActivityManager mNfcActivityManager;
|
||||
final Context mContext;
|
||||
final HashMap<NfcUnlockHandler, IBinder> mNfcUnlockHandlers;
|
||||
final Object mLock;
|
||||
|
||||
/**
|
||||
* A callback to be invoked when the system finds a tag while the foreground activity is
|
||||
@@ -394,22 +393,6 @@ public final class NfcAdapter {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A callback to be invoked when an application has registered as a
|
||||
* handler to unlock the device given an NFC tag at the lockscreen.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public interface NfcUnlockHandler {
|
||||
/**
|
||||
* Called at the lock screen to attempt to unlock the device with the given tag.
|
||||
* @param tag the detected tag, to be used to unlock the device
|
||||
* @return true if the device was successfully unlocked
|
||||
*/
|
||||
public boolean onUnlockAttempted(Tag tag);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper to check if this device has FEATURE_NFC, but without using
|
||||
* a context.
|
||||
@@ -542,8 +525,6 @@ public final class NfcAdapter {
|
||||
NfcAdapter(Context context) {
|
||||
mContext = context;
|
||||
mNfcActivityManager = new NfcActivityManager(this);
|
||||
mNfcUnlockHandlers = new HashMap<NfcUnlockHandler, IBinder>();
|
||||
mLock = new Object();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1476,7 +1457,7 @@ public final class NfcAdapter {
|
||||
public boolean onTagDetected(Tag tag) throws RemoteException {
|
||||
return lockscreenDispatch.onTagDetected(tag);
|
||||
}
|
||||
}, Tag.getTechCodesFromStrings(techList));
|
||||
}, Tag.techListFromStrings(techList));
|
||||
} catch (RemoteException e) {
|
||||
attemptDeadServiceRecovery(e);
|
||||
return false;
|
||||
@@ -1488,72 +1469,6 @@ public final class NfcAdapter {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new NFC unlock handler with the NFC service.
|
||||
*
|
||||
* <p />NFC unlock handlers are intended to unlock the keyguard in the presence of a trusted
|
||||
* NFC device. The handler should return true if it successfully authenticates the user and
|
||||
* unlocks the keyguard.
|
||||
*
|
||||
* <p /> The parameter {@code tagTechnologies} determines which Tag technologies will be polled for
|
||||
* at the lockscreen. Polling for less tag technologies reduces latency, and so it is
|
||||
* strongly recommended to only provide the Tag technologies that the handler is expected to
|
||||
* receive.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public boolean addNfcUnlockHandler(final NfcUnlockHandler unlockHandler,
|
||||
String[] tagTechnologies) {
|
||||
try {
|
||||
INfcUnlockHandler.Stub iHandler = new INfcUnlockHandler.Stub() {
|
||||
@Override
|
||||
public boolean onUnlockAttempted(Tag tag) throws RemoteException {
|
||||
return unlockHandler.onUnlockAttempted(tag);
|
||||
}
|
||||
};
|
||||
|
||||
synchronized (mLock) {
|
||||
if (mNfcUnlockHandlers.containsKey(unlockHandler)) {
|
||||
return true;
|
||||
}
|
||||
sService.addNfcUnlockHandler(iHandler, Tag.getTechCodesFromStrings(tagTechnologies));
|
||||
mNfcUnlockHandlers.put(unlockHandler, iHandler.asBinder());
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
attemptDeadServiceRecovery(e);
|
||||
return false;
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.e(TAG, "Unable to register LockscreenDispatch", e);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a previously registered unlock handler. Also removes the tag technologies
|
||||
* associated with the removed unlock handler.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public boolean removeNfcUnlockHandler(NfcUnlockHandler unlockHandler) {
|
||||
try {
|
||||
synchronized (mLock) {
|
||||
if (mNfcUnlockHandlers.containsKey(unlockHandler)) {
|
||||
sService.removeNfcUnlockHandler(mNfcUnlockHandlers.get(unlockHandler));
|
||||
mNfcUnlockHandlers.remove(unlockHandler);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
attemptDeadServiceRecovery(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
|
||||
@@ -196,7 +196,7 @@ public final class Tag implements Parcelable {
|
||||
return strings;
|
||||
}
|
||||
|
||||
static int[] getTechCodesFromStrings(String[] techStringList) throws IllegalArgumentException {
|
||||
static int[] techListFromStrings(String[] techStringList) throws IllegalArgumentException {
|
||||
if (techStringList == null) {
|
||||
throw new IllegalArgumentException("List cannot be null");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user