Merge "Expose getting encryptstate through IMountService"
This commit is contained in:
@@ -36,7 +36,7 @@ public interface IMountService extends IInterface {
|
|||||||
/** Local-side IPC implementation stub class. */
|
/** Local-side IPC implementation stub class. */
|
||||||
public static abstract class Stub extends Binder implements IMountService {
|
public static abstract class Stub extends Binder implements IMountService {
|
||||||
private static class Proxy implements IMountService {
|
private static class Proxy implements IMountService {
|
||||||
private IBinder mRemote;
|
private final IBinder mRemote;
|
||||||
|
|
||||||
Proxy(IBinder remote) {
|
Proxy(IBinder remote) {
|
||||||
mRemote = remote;
|
mRemote = remote;
|
||||||
@@ -589,6 +589,22 @@ public interface IMountService extends IInterface {
|
|||||||
return _result;
|
return _result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getEncryptionState() throws RemoteException {
|
||||||
|
Parcel _data = Parcel.obtain();
|
||||||
|
Parcel _reply = Parcel.obtain();
|
||||||
|
int _result;
|
||||||
|
try {
|
||||||
|
_data.writeInterfaceToken(DESCRIPTOR);
|
||||||
|
mRemote.transact(Stub.TRANSACTION_getEncryptionState, _data, _reply, 0);
|
||||||
|
_reply.readException();
|
||||||
|
_result = _reply.readInt();
|
||||||
|
} finally {
|
||||||
|
_reply.recycle();
|
||||||
|
_data.recycle();
|
||||||
|
}
|
||||||
|
return _result;
|
||||||
|
}
|
||||||
|
|
||||||
public int decryptStorage(String password) throws RemoteException {
|
public int decryptStorage(String password) throws RemoteException {
|
||||||
Parcel _data = Parcel.obtain();
|
Parcel _data = Parcel.obtain();
|
||||||
Parcel _reply = Parcel.obtain();
|
Parcel _reply = Parcel.obtain();
|
||||||
@@ -741,6 +757,8 @@ public interface IMountService extends IInterface {
|
|||||||
|
|
||||||
static final int TRANSACTION_getSecureContainerFilesystemPath = IBinder.FIRST_CALL_TRANSACTION + 30;
|
static final int TRANSACTION_getSecureContainerFilesystemPath = IBinder.FIRST_CALL_TRANSACTION + 30;
|
||||||
|
|
||||||
|
static final int TRANSACTION_getEncryptionState = IBinder.FIRST_CALL_TRANSACTION + 31;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cast an IBinder object into an IMountService interface, generating a
|
* Cast an IBinder object into an IMountService interface, generating a
|
||||||
* proxy if needed.
|
* proxy if needed.
|
||||||
@@ -1062,6 +1080,13 @@ public interface IMountService extends IInterface {
|
|||||||
reply.writeString(path);
|
reply.writeString(path);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
case TRANSACTION_getEncryptionState: {
|
||||||
|
data.enforceInterface(DESCRIPTOR);
|
||||||
|
int result = getEncryptionState();
|
||||||
|
reply.writeNoException();
|
||||||
|
reply.writeInt(result);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return super.onTransact(code, data, reply, flags);
|
return super.onTransact(code, data, reply, flags);
|
||||||
}
|
}
|
||||||
@@ -1222,6 +1247,21 @@ public interface IMountService extends IInterface {
|
|||||||
*/
|
*/
|
||||||
public boolean isExternalStorageEmulated() throws RemoteException;
|
public boolean isExternalStorageEmulated() throws RemoteException;
|
||||||
|
|
||||||
|
/** The volume is not encrypted. */
|
||||||
|
static final int ENCRYPTION_STATE_NONE = 1;
|
||||||
|
/** The volume has been encrypted succesfully. */
|
||||||
|
static final int ENCRYPTION_STATE_OK = 0;
|
||||||
|
/** The volume is in a bad state. */
|
||||||
|
static final int ENCRYPTION_STATE_ERROR_UNKNOWN = -1;
|
||||||
|
/** The volume is in a bad state - partially encrypted. Data is likely irrecoverable. */
|
||||||
|
static final int ENCRYPTION_STATE_ERROR_INCOMPLETE = -2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines the encryption state of the volume.
|
||||||
|
* @return a numerical value. See {@code ENCRYPTION_STATE_*} for possible values.
|
||||||
|
*/
|
||||||
|
public int getEncryptionState() throws RemoteException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decrypts any encrypted volumes.
|
* Decrypts any encrypted volumes.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -454,7 +454,7 @@ class MountService extends IMountService.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
|
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
@@ -484,7 +484,7 @@ class MountService extends IMountService.Stub
|
|||||||
synchronized (mVolumeStates) {
|
synchronized (mVolumeStates) {
|
||||||
Set<String> keys = mVolumeStates.keySet();
|
Set<String> keys = mVolumeStates.keySet();
|
||||||
count = keys.size();
|
count = keys.size();
|
||||||
paths = (String[])keys.toArray(new String[count]);
|
paths = keys.toArray(new String[count]);
|
||||||
states = new String[count];
|
states = new String[count];
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
states[i] = mVolumeStates.get(paths[i]);
|
states[i] = mVolumeStates.get(paths[i]);
|
||||||
@@ -1761,6 +1761,37 @@ class MountService extends IMountService.Stub
|
|||||||
Slog.i(TAG, "Send to OBB handler: " + action.toString());
|
Slog.i(TAG, "Send to OBB handler: " + action.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getEncryptionState() {
|
||||||
|
mContext.enforceCallingOrSelfPermission(Manifest.permission.CRYPT_KEEPER,
|
||||||
|
"no permission to access the crypt keeper");
|
||||||
|
|
||||||
|
waitForReady();
|
||||||
|
|
||||||
|
try {
|
||||||
|
ArrayList<String> rsp = mConnector.doCommand("cryptfs cryptocomplete");
|
||||||
|
String[] tokens = rsp.get(0).split(" ");
|
||||||
|
|
||||||
|
if (tokens == null || tokens.length != 2) {
|
||||||
|
// Unexpected.
|
||||||
|
Slog.w(TAG, "Unexpected result from cryptfs cryptocomplete");
|
||||||
|
return ENCRYPTION_STATE_ERROR_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Integer.parseInt(tokens[1]);
|
||||||
|
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
// Bad result - unexpected.
|
||||||
|
Slog.w(TAG, "Unable to parse result from cryptfs cryptocomplete");
|
||||||
|
return ENCRYPTION_STATE_ERROR_UNKNOWN;
|
||||||
|
} catch (NativeDaemonConnectorException e) {
|
||||||
|
// Something bad happened.
|
||||||
|
Slog.w(TAG, "Error in communicating with cryptfs in validating");
|
||||||
|
return ENCRYPTION_STATE_ERROR_UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int decryptStorage(String password) {
|
public int decryptStorage(String password) {
|
||||||
if (TextUtils.isEmpty(password)) {
|
if (TextUtils.isEmpty(password)) {
|
||||||
throw new IllegalArgumentException("password cannot be empty");
|
throw new IllegalArgumentException("password cannot be empty");
|
||||||
@@ -2090,7 +2121,7 @@ class MountService extends IMountService.Stub
|
|||||||
public void execute(ObbActionHandler handler) {
|
public void execute(ObbActionHandler handler) {
|
||||||
try {
|
try {
|
||||||
if (DEBUG_OBB)
|
if (DEBUG_OBB)
|
||||||
Slog.i(TAG, "Starting to execute action: " + this.toString());
|
Slog.i(TAG, "Starting to execute action: " + toString());
|
||||||
mRetries++;
|
mRetries++;
|
||||||
if (mRetries > MAX_RETRIES) {
|
if (mRetries > MAX_RETRIES) {
|
||||||
Slog.w(TAG, "Failed to invoke remote methods on default container service. Giving up");
|
Slog.w(TAG, "Failed to invoke remote methods on default container service. Giving up");
|
||||||
@@ -2147,7 +2178,7 @@ class MountService extends IMountService.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
class MountObbAction extends ObbAction {
|
class MountObbAction extends ObbAction {
|
||||||
private String mKey;
|
private final String mKey;
|
||||||
|
|
||||||
MountObbAction(ObbState obbState, String key) {
|
MountObbAction(ObbState obbState, String key) {
|
||||||
super(obbState);
|
super(obbState);
|
||||||
@@ -2258,7 +2289,7 @@ class MountService extends IMountService.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
class UnmountObbAction extends ObbAction {
|
class UnmountObbAction extends ObbAction {
|
||||||
private boolean mForceUnmount;
|
private final boolean mForceUnmount;
|
||||||
|
|
||||||
UnmountObbAction(ObbState obbState, boolean force) {
|
UnmountObbAction(ObbState obbState, boolean force) {
|
||||||
super(obbState);
|
super(obbState);
|
||||||
|
|||||||
Reference in New Issue
Block a user