summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorJack Yu <jackcwyu@google.com>2019-12-17 17:22:18 +0800
committerGeorge Chang <georgekgchang@google.com>2020-01-16 16:06:29 +0000
commit7ee5c99bc78aec4ea232ad44c1042edba2e6877f (patch)
treee4b40d86ed74312aeee26dcc705d46d49486d142 /core/java
parentbd7fa9958430e4fd134aef0db3df1ae47aa8837d (diff)
Add a system api to reset secure element
Bug: 142495673 Test:build pass Change-Id: Icbc94a3bc65be703152bb257d06b98fd8a8c48c8
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/se/omapi/ISecureElementReader.aidl6
-rw-r--r--core/java/android/se/omapi/Reader.java23
2 files changed, 29 insertions, 0 deletions
diff --git a/core/java/android/se/omapi/ISecureElementReader.aidl b/core/java/android/se/omapi/ISecureElementReader.aidl
index a312c445395a..41244ab058e0 100644
--- a/core/java/android/se/omapi/ISecureElementReader.aidl
+++ b/core/java/android/se/omapi/ISecureElementReader.aidl
@@ -48,4 +48,10 @@ interface ISecureElementReader {
*/
void closeSessions();
+ /**
+ * Closes all the sessions opened on this reader and resets the reader.
+ * All the channels opened by all these sessions will be closed.
+ * @return true if the reset is successful, false otherwise.
+ */
+ boolean reset();
}
diff --git a/core/java/android/se/omapi/Reader.java b/core/java/android/se/omapi/Reader.java
index 80262f7533c8..7f68d9188650 100644
--- a/core/java/android/se/omapi/Reader.java
+++ b/core/java/android/se/omapi/Reader.java
@@ -23,6 +23,8 @@
package android.se.omapi;
import android.annotation.NonNull;
+import android.annotation.RequiresPermission;
+import android.annotation.SystemApi;
import android.os.RemoteException;
import android.os.ServiceSpecificException;
import android.util.Log;
@@ -150,4 +152,25 @@ public final class Reader {
} catch (RemoteException ignore) { }
}
}
+
+ /**
+ * Close all the sessions opened on this reader and reset the reader.
+ * All the channels opened by all these sessions will be closed.
+ * @return <code>true</code> if reset success, <code>false</code> otherwise.
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.SECURE_ELEMENT_PRIVILEGED)
+ public boolean reset() {
+ if (!mService.isConnected()) {
+ Log.e(TAG, "service is not connected");
+ return false;
+ }
+ synchronized (mLock) {
+ try {
+ closeSessions();
+ return mReader.reset();
+ } catch (RemoteException ignore) {return false;}
+ }
+ }
}