summaryrefslogtreecommitdiffstats
path: root/services/core/java/com/android/server/MountService.java
diff options
context:
space:
mode:
authorPaul Lawrence <paullawrence@google.com>2015-06-03 14:14:52 -0700
committerPaul Lawrence <paullawrence@google.com>2015-06-04 10:44:43 -0700
commit1c62cbbdfe7cb524b70685150e74c9a52fcee088 (patch)
treee6662ce04cd4e056944e1dd205bd5983b6955fe3 /services/core/java/com/android/server/MountService.java
parent5b9b66c73c80697c1d3694a2d4ee975e409bd89d (diff)
downloadframeworks_base-1c62cbbdfe7cb524b70685150e74c9a52fcee088.zip
frameworks_base-1c62cbbdfe7cb524b70685150e74c9a52fcee088.tar.gz
frameworks_base-1c62cbbdfe7cb524b70685150e74c9a52fcee088.tar.bz2
Move crypt commands to a different listener in vold
In order to prevent this bug from happening, we must allow vold cryptfs commands to complete while a long running mount is underway. While waiting for vold to be changed to a binder interface, we will simply create two listeners, one for cryptfs and one for everything else. Bug: 19197175 Change-Id: I8c40211dc1ef5ecec765ab587f093e757f1173d3
Diffstat (limited to 'services/core/java/com/android/server/MountService.java')
-rw-r--r--services/core/java/com/android/server/MountService.java43
1 files changed, 31 insertions, 12 deletions
diff --git a/services/core/java/com/android/server/MountService.java b/services/core/java/com/android/server/MountService.java
index d48953d..8c8be4e 100644
--- a/services/core/java/com/android/server/MountService.java
+++ b/services/core/java/com/android/server/MountService.java
@@ -180,6 +180,7 @@ class MountService extends IMountService.Stub
private static final String TAG_STORAGE_BENCHMARK = "storage_benchmark";
private static final String VOLD_TAG = "VoldConnector";
+ private static final String CRYPTD_TAG = "CryptdConnector";
/** Maximum number of ASEC containers allowed to be mounted. */
private static final int MAX_CONTAINERS = 250;
@@ -367,6 +368,7 @@ class MountService extends IMountService.Stub
private final Context mContext;
private final NativeDaemonConnector mConnector;
+ private final NativeDaemonConnector mCryptConnector;
private volatile boolean mSystemReady = false;
private volatile boolean mDaemonConnected = false;
@@ -375,7 +377,8 @@ class MountService extends IMountService.Stub
private final Callbacks mCallbacks;
- private final CountDownLatch mConnectedSignal = new CountDownLatch(1);
+ // Two connectors - mConnector & mCryptConnector
+ private final CountDownLatch mConnectedSignal = new CountDownLatch(2);
private final CountDownLatch mAsecsScanned = new CountDownLatch(1);
private final Object mUnmountLock = new Object();
@@ -754,6 +757,10 @@ class MountService extends IMountService.Stub
* the hounds!
*/
mConnectedSignal.countDown();
+ if (mConnectedSignal.getCount() != 0) {
+ // More daemons need to connect
+ return;
+ }
// On an encrypted device we can't see system properties yet, so pull
// the system locale out of the mount service.
@@ -1186,6 +1193,7 @@ class MountService extends IMountService.Stub
* amount of containers we'd ever expect to have. This keeps an
* "asec list" from blocking a thread repeatedly.
*/
+
mConnector = new NativeDaemonConnector(this, "vold", MAX_CONTAINERS * 2, VOLD_TAG, 25,
null);
mConnector.setDebug(true);
@@ -1193,6 +1201,14 @@ class MountService extends IMountService.Stub
Thread thread = new Thread(mConnector, VOLD_TAG);
thread.start();
+ // Reuse parameters from first connector since they are tested and safe
+ mCryptConnector = new NativeDaemonConnector(this, "cryptd",
+ MAX_CONTAINERS * 2, CRYPTD_TAG, 25, null);
+ mCryptConnector.setDebug(true);
+
+ Thread crypt_thread = new Thread(mCryptConnector, CRYPTD_TAG);
+ crypt_thread.start();
+
// Add ourself to the Watchdog monitors if enabled.
if (WATCHDOG_ENABLE) {
Watchdog.getInstance().addMonitor(this);
@@ -2049,7 +2065,7 @@ class MountService extends IMountService.Stub
final NativeDaemonEvent event;
try {
- event = mConnector.execute("cryptfs", "cryptocomplete");
+ event = mCryptConnector.execute("cryptfs", "cryptocomplete");
return Integer.parseInt(event.getMessage());
} catch (NumberFormatException e) {
// Bad result - unexpected.
@@ -2096,7 +2112,7 @@ class MountService extends IMountService.Stub
final NativeDaemonEvent event;
try {
- event = mConnector.execute("cryptfs", "checkpw", new SensitiveArg(toHex(password)));
+ event = mCryptConnector.execute("cryptfs", "checkpw", new SensitiveArg(toHex(password)));
final int code = Integer.parseInt(event.getMessage());
if (code == 0) {
@@ -2105,7 +2121,7 @@ class MountService extends IMountService.Stub
mHandler.postDelayed(new Runnable() {
public void run() {
try {
- mConnector.execute("cryptfs", "restart");
+ mCryptConnector.execute("cryptfs", "restart");
} catch (NativeDaemonConnectorException e) {
Slog.e(TAG, "problem executing in background", e);
}
@@ -2135,7 +2151,7 @@ class MountService extends IMountService.Stub
}
try {
- mConnector.execute("cryptfs", "enablecrypto", "inplace", CRYPTO_TYPES[type],
+ mCryptConnector.execute("cryptfs", "enablecrypto", "inplace", CRYPTO_TYPES[type],
new SensitiveArg(toHex(password)));
} catch (NativeDaemonConnectorException e) {
// Encryption failed
@@ -2160,7 +2176,7 @@ class MountService extends IMountService.Stub
}
try {
- NativeDaemonEvent event = mConnector.execute("cryptfs", "changepw", CRYPTO_TYPES[type],
+ NativeDaemonEvent event = mCryptConnector.execute("cryptfs", "changepw", CRYPTO_TYPES[type],
new SensitiveArg(toHex(password)));
return Integer.parseInt(event.getMessage());
} catch (NativeDaemonConnectorException e) {
@@ -2194,7 +2210,7 @@ class MountService extends IMountService.Stub
final NativeDaemonEvent event;
try {
- event = mConnector.execute("cryptfs", "verifypw", new SensitiveArg(toHex(password)));
+ event = mCryptConnector.execute("cryptfs", "verifypw", new SensitiveArg(toHex(password)));
Slog.i(TAG, "cryptfs verifypw => " + event.getMessage());
return Integer.parseInt(event.getMessage());
} catch (NativeDaemonConnectorException e) {
@@ -2214,7 +2230,7 @@ class MountService extends IMountService.Stub
final NativeDaemonEvent event;
try {
- event = mConnector.execute("cryptfs", "getpwtype");
+ event = mCryptConnector.execute("cryptfs", "getpwtype");
for (int i = 0; i < CRYPTO_TYPES.length; ++i) {
if (CRYPTO_TYPES[i].equals(event.getMessage()))
return i;
@@ -2238,7 +2254,7 @@ class MountService extends IMountService.Stub
final NativeDaemonEvent event;
try {
- event = mConnector.execute("cryptfs", "setfield", field, contents);
+ event = mCryptConnector.execute("cryptfs", "setfield", field, contents);
} catch (NativeDaemonConnectorException e) {
throw e.rethrowAsParcelableException();
}
@@ -2257,7 +2273,7 @@ class MountService extends IMountService.Stub
final NativeDaemonEvent event;
try {
final String[] contents = NativeDaemonEvent.filterMessageList(
- mConnector.executeForList("cryptfs", "getfield", field),
+ mCryptConnector.executeForList("cryptfs", "getfield", field),
VoldResponseCode.CryptfsGetfieldResult);
String result = new String();
for (String content : contents) {
@@ -2279,7 +2295,7 @@ class MountService extends IMountService.Stub
final NativeDaemonEvent event;
try {
- event = mConnector.execute("cryptfs", "getpw");
+ event = mCryptConnector.execute("cryptfs", "getpw");
if ("-1".equals(event.getMessage())) {
// -1 equals no password
return null;
@@ -2301,7 +2317,7 @@ class MountService extends IMountService.Stub
final NativeDaemonEvent event;
try {
- event = mConnector.execute("cryptfs", "clearpw");
+ event = mCryptConnector.execute("cryptfs", "clearpw");
} catch (NativeDaemonConnectorException e) {
throw e.rethrowAsParcelableException();
}
@@ -3114,5 +3130,8 @@ class MountService extends IMountService.Stub
if (mConnector != null) {
mConnector.monitor();
}
+ if (mCryptConnector != null) {
+ mCryptConnector.monitor();
+ }
}
}