summaryrefslogtreecommitdiff
path: root/services/java/com/android/server/usb/UsbDebuggingManager.java
diff options
context:
space:
mode:
authorBenoit Goby <benoit@android.com>2012-12-21 16:44:50 -0800
committerBenoit Goby <benoit@android.com>2013-01-28 19:15:30 -0800
commitcd7a17c645761ac0b64c75346b159dd30cbcb01c (patch)
tree6448cea70f29002a373b40cd101e06e760ae865f /services/java/com/android/server/usb/UsbDebuggingManager.java
parent5924dc4d7a42d04011d2e67aa3f9e28b7d940681 (diff)
UsbDebuggingManager: Add interface to clear secure adb keys
This is called from Settings that has a button to clear secure adb public keys installed on the device. Change-Id: I63ef499c049766ef13ea6cb0594ed6719f35e5f3
Diffstat (limited to 'services/java/com/android/server/usb/UsbDebuggingManager.java')
-rw-r--r--services/java/com/android/server/usb/UsbDebuggingManager.java28
1 files changed, 25 insertions, 3 deletions
diff --git a/services/java/com/android/server/usb/UsbDebuggingManager.java b/services/java/com/android/server/usb/UsbDebuggingManager.java
index 1bb3a2c519e5..93d31144815f 100644
--- a/services/java/com/android/server/usb/UsbDebuggingManager.java
+++ b/services/java/com/android/server/usb/UsbDebuggingManager.java
@@ -151,6 +151,7 @@ public class UsbDebuggingManager implements Runnable {
private static final int MESSAGE_ADB_ALLOW = 3;
private static final int MESSAGE_ADB_DENY = 4;
private static final int MESSAGE_ADB_CONFIRM = 5;
+ private static final int MESSAGE_ADB_CLEAR = 6;
public UsbDebuggingHandler(Looper looper) {
super(looper);
@@ -214,6 +215,10 @@ public class UsbDebuggingManager implements Runnable {
showConfirmationDialog(key, mFingerprints);
break;
}
+
+ case MESSAGE_ADB_CLEAR:
+ deleteKeyFile();
+ break;
}
}
}
@@ -257,17 +262,25 @@ public class UsbDebuggingManager implements Runnable {
}
}
- private void writeKey(String key) {
+ private File getUserKeyFile() {
File dataDir = Environment.getDataDirectory();
File adbDir = new File(dataDir, ADB_DIRECTORY);
if (!adbDir.exists()) {
Slog.e(TAG, "ADB data directory does not exist");
- return;
+ return null;
}
+ return new File(adbDir, ADB_KEYS_FILE);
+ }
+
+ private void writeKey(String key) {
try {
- File keyFile = new File(adbDir, ADB_KEYS_FILE);
+ File keyFile = getUserKeyFile();
+
+ if (keyFile == null) {
+ return;
+ }
if (!keyFile.exists()) {
keyFile.createNewFile();
@@ -286,6 +299,12 @@ public class UsbDebuggingManager implements Runnable {
}
}
+ private void deleteKeyFile() {
+ File keyFile = getUserKeyFile();
+ if (keyFile != null) {
+ keyFile.delete();
+ }
+ }
public void setAdbEnabled(boolean enabled) {
mHandler.sendEmptyMessage(enabled ? UsbDebuggingHandler.MESSAGE_ADB_ENABLED
@@ -303,6 +322,9 @@ public class UsbDebuggingManager implements Runnable {
mHandler.sendEmptyMessage(UsbDebuggingHandler.MESSAGE_ADB_DENY);
}
+ public void clearUsbDebuggingKeys() {
+ mHandler.sendEmptyMessage(UsbDebuggingHandler.MESSAGE_ADB_CLEAR);
+ }
public void dump(FileDescriptor fd, PrintWriter pw) {
pw.println(" USB Debugging State:");