Merge changes from topic "remove-fde"
* changes: Remove unused FDE methods from StorageManager Stop checking FDE password cache Remove checks for FDE in 'adb backup'
This commit is contained in:
@@ -77,37 +77,10 @@ interface IStorageManager {
|
||||
* Gets the path to the mounted Opaque Binary Blob (OBB).
|
||||
*/
|
||||
String getMountedObbPath(in String rawPath) = 24;
|
||||
/**
|
||||
* Decrypts any encrypted volumes.
|
||||
*/
|
||||
int decryptStorage(in String password) = 26;
|
||||
/**
|
||||
* Encrypts storage.
|
||||
*/
|
||||
int encryptStorage(int type, in String password) = 27;
|
||||
/**
|
||||
* Changes the encryption password.
|
||||
*/
|
||||
int changeEncryptionPassword(int type, in String password) = 28;
|
||||
/**
|
||||
* Returns list of all mountable volumes.
|
||||
*/
|
||||
StorageVolume[] getVolumeList(int uid, in String packageName, int flags) = 29;
|
||||
/**
|
||||
* Determines the encryption state of the volume.
|
||||
* @return a numerical value. See {@code ENCRYPTION_STATE_*} for possible
|
||||
* values.
|
||||
* Note that this has been replaced in most cases by the APIs in
|
||||
* StorageManager (see isEncryptable and below)
|
||||
* This is still useful to get the error state when encryption has failed
|
||||
* and CryptKeeper needs to throw up a screen advising the user what to do
|
||||
*/
|
||||
int getEncryptionState() = 31;
|
||||
/**
|
||||
* Verify the encryption password against the stored volume. This method
|
||||
* may only be called by the system process.
|
||||
*/
|
||||
int verifyEncryptionPassword(in String password) = 32;
|
||||
/**
|
||||
* Ensure that all directories along given path exist, creating parent
|
||||
* directories as needed. Validates that given path is absolute and that it
|
||||
@@ -116,32 +89,6 @@ interface IStorageManager {
|
||||
* external storage data or OBB directory belonging to calling app.
|
||||
*/
|
||||
void mkdirs(in String callingPkg, in String path) = 34;
|
||||
/**
|
||||
* Determines the type of the encryption password
|
||||
* @return PasswordType
|
||||
*/
|
||||
int getPasswordType() = 35;
|
||||
/**
|
||||
* Get password from vold
|
||||
* @return password or empty string
|
||||
*/
|
||||
String getPassword() = 36;
|
||||
/**
|
||||
* Securely clear password from vold
|
||||
*/
|
||||
oneway void clearPassword() = 37;
|
||||
/**
|
||||
* Set a field in the crypto header.
|
||||
* @param field field to set
|
||||
* @param contents contents to set in field
|
||||
*/
|
||||
oneway void setField(in String field, in String contents) = 38;
|
||||
/**
|
||||
* Gets a field from the crypto header.
|
||||
* @param field field to get
|
||||
* @return contents of field
|
||||
*/
|
||||
String getField(in String field) = 39;
|
||||
/**
|
||||
* Report the time of the last maintenance operation such as fstrim.
|
||||
* @return Timestamp of the last maintenance operation, in the
|
||||
|
||||
@@ -2904,14 +2904,4 @@ public class StorageManager {
|
||||
public static final int CRYPT_TYPE_PATTERN = IVold.PASSWORD_TYPE_PATTERN;
|
||||
/** @hide */
|
||||
public static final int CRYPT_TYPE_PIN = IVold.PASSWORD_TYPE_PIN;
|
||||
|
||||
// Constants for the data available via StorageManagerService.getField.
|
||||
/** @hide */
|
||||
public static final String SYSTEM_LOCALE_KEY = "SystemLocale";
|
||||
/** @hide */
|
||||
public static final String OWNER_INFO_KEY = "OwnerInfo";
|
||||
/** @hide */
|
||||
public static final String PATTERN_VISIBLE_KEY = "PatternVisible";
|
||||
/** @hide */
|
||||
public static final String PASSWORD_VISIBLE_KEY = "PasswordVisible";
|
||||
}
|
||||
|
||||
@@ -51,7 +51,6 @@ interface ILockSettings {
|
||||
VerifyCredentialResponse verifyTiedProfileChallenge(in LockscreenCredential credential, int userId, int flags);
|
||||
VerifyCredentialResponse verifyGatekeeperPasswordHandle(long gatekeeperPasswordHandle, long challenge, int userId);
|
||||
void removeGatekeeperPasswordHandle(long gatekeeperPasswordHandle);
|
||||
boolean checkVoldPassword(int userId);
|
||||
int getCredentialType(int userId);
|
||||
byte[] getHashFactor(in LockscreenCredential currentCredential, int userId);
|
||||
void setSeparateProfileChallengeEnabled(int userId, boolean enabled, in LockscreenCredential managedUserPassword);
|
||||
|
||||
@@ -504,20 +504,6 @@ public class LockPatternUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if vold already has the password.
|
||||
* Note that this also clears vold's copy of the password.
|
||||
* @return Whether the vold password matches or not.
|
||||
*/
|
||||
public boolean checkVoldPassword(int userId) {
|
||||
try {
|
||||
return getLockSettings().checkVoldPassword(userId);
|
||||
} catch (RemoteException re) {
|
||||
Log.e(TAG, "failed to check vold password", re);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the password history hash factor, needed to check new password against password
|
||||
* history with {@link #checkPasswordHistory(byte[], byte[], int)}
|
||||
|
||||
@@ -48,8 +48,6 @@ enum {
|
||||
TRANSACTION_isObbMounted,
|
||||
TRANSACTION_getMountedObbPath,
|
||||
TRANSACTION_isExternalStorageEmulated,
|
||||
TRANSACTION_decryptStorage,
|
||||
TRANSACTION_encryptStorage,
|
||||
};
|
||||
|
||||
class BpMountService: public BpInterface<IMountService>
|
||||
@@ -517,40 +515,6 @@ public:
|
||||
path = reply.readString16();
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t decryptStorage(const String16& password)
|
||||
{
|
||||
Parcel data, reply;
|
||||
data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
|
||||
data.writeString16(password);
|
||||
if (remote()->transact(TRANSACTION_decryptStorage, data, &reply) != NO_ERROR) {
|
||||
ALOGD("decryptStorage could not contact remote\n");
|
||||
return -1;
|
||||
}
|
||||
int32_t err = reply.readExceptionCode();
|
||||
if (err < 0) {
|
||||
ALOGD("decryptStorage caught exception %d\n", err);
|
||||
return err;
|
||||
}
|
||||
return reply.readInt32();
|
||||
}
|
||||
|
||||
int32_t encryptStorage(const String16& password)
|
||||
{
|
||||
Parcel data, reply;
|
||||
data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
|
||||
data.writeString16(password);
|
||||
if (remote()->transact(TRANSACTION_encryptStorage, data, &reply) != NO_ERROR) {
|
||||
ALOGD("encryptStorage could not contact remote\n");
|
||||
return -1;
|
||||
}
|
||||
int32_t err = reply.readExceptionCode();
|
||||
if (err < 0) {
|
||||
ALOGD("encryptStorage caught exception %d\n", err);
|
||||
return err;
|
||||
}
|
||||
return reply.readInt32();
|
||||
}
|
||||
};
|
||||
|
||||
IMPLEMENT_META_INTERFACE(MountService, "android.os.storage.IStorageManager")
|
||||
|
||||
@@ -70,8 +70,6 @@ public:
|
||||
const sp<IObbActionListener>& token, const int32_t nonce) = 0;
|
||||
virtual bool isObbMounted(const String16& filename) = 0;
|
||||
virtual bool getMountedObbPath(const String16& filename, String16& path) = 0;
|
||||
virtual int32_t decryptStorage(const String16& password) = 0;
|
||||
virtual int32_t encryptStorage(const String16& password) = 0;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@@ -44,8 +44,6 @@
|
||||
<string name="backup_enc_password_text">Please enter a password to use for encrypting the full backup data. If this is left blank, your current backup password will be used:</string>
|
||||
<!-- Text for message to user that they may optionally supply an encryption password to use for a full backup operation. -->
|
||||
<string name="backup_enc_password_optional">If you wish to encrypt the full backup data, enter a password below:</string>
|
||||
<!-- Text for message to user that they must supply an encryption password to use for a full backup operation because their phone is locked. -->
|
||||
<string name="backup_enc_password_required">Since your device is encrypted, you are required to encrypt your backup. Please enter a password below:</string>
|
||||
|
||||
<!-- Text for message to user when performing a full restore operation, explaining that they must enter the password originally used to encrypt the full backup data. -->
|
||||
<string name="restore_enc_password_text">If the restore data is encrypted, please enter the password below:</string>
|
||||
|
||||
@@ -27,8 +27,6 @@ import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.storage.IStorageManager;
|
||||
import android.os.storage.StorageManager;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Slog;
|
||||
@@ -66,10 +64,8 @@ public class BackupRestoreConfirmation extends Activity {
|
||||
|
||||
Handler mHandler;
|
||||
IBackupManager mBackupManager;
|
||||
IStorageManager mStorageManager;
|
||||
FullObserver mObserver;
|
||||
int mToken;
|
||||
boolean mIsEncrypted;
|
||||
boolean mDidAcknowledge;
|
||||
String mAction;
|
||||
|
||||
@@ -144,7 +140,6 @@ public class BackupRestoreConfirmation extends Activity {
|
||||
}
|
||||
|
||||
mBackupManager = IBackupManager.Stub.asInterface(ServiceManager.getService(Context.BACKUP_SERVICE));
|
||||
mStorageManager = IStorageManager.Stub.asInterface(ServiceManager.getService("mount"));
|
||||
|
||||
mHandler = new ObserverHandler(getApplicationContext());
|
||||
final Object oldObserver = getLastNonConfigurationInstance();
|
||||
@@ -248,20 +243,13 @@ public class BackupRestoreConfirmation extends Activity {
|
||||
mDenyButton.setEnabled(!mDidAcknowledge);
|
||||
}
|
||||
|
||||
// We vary the password prompt depending on whether one is predefined, and whether
|
||||
// the device is encrypted.
|
||||
mIsEncrypted = deviceIsEncrypted();
|
||||
// We vary the password prompt depending on whether one is predefined.
|
||||
if (!haveBackupPassword()) {
|
||||
curPwDesc.setVisibility(View.GONE);
|
||||
mCurPassword.setVisibility(View.GONE);
|
||||
if (layoutId == R.layout.confirm_backup) {
|
||||
TextView encPwDesc = findViewById(R.id.enc_password_desc);
|
||||
if (mIsEncrypted) {
|
||||
encPwDesc.setText(R.string.backup_enc_password_required);
|
||||
monitorEncryptionPassword();
|
||||
} else {
|
||||
encPwDesc.setText(R.string.backup_enc_password_optional);
|
||||
}
|
||||
encPwDesc.setText(R.string.backup_enc_password_optional);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -312,20 +300,6 @@ public class BackupRestoreConfirmation extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
boolean deviceIsEncrypted() {
|
||||
try {
|
||||
return mStorageManager.getEncryptionState()
|
||||
!= StorageManager.ENCRYPTION_STATE_NONE
|
||||
&& mStorageManager.getPasswordType()
|
||||
!= StorageManager.CRYPT_TYPE_DEFAULT;
|
||||
} catch (Exception e) {
|
||||
// If we can't talk to the storagemanager service we have a serious problem; fail
|
||||
// "secure" i.e. assuming that the device is encrypted.
|
||||
Slog.e(TAG, "Unable to communicate with storagemanager service: " + e.getMessage());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
boolean haveBackupPassword() {
|
||||
try {
|
||||
return mBackupManager.hasBackupPassword();
|
||||
|
||||
@@ -1573,14 +1573,6 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
|
||||
if (DEBUG) Log.d(TAG, "doKeyguard: not showing because lockscreen is off");
|
||||
return;
|
||||
}
|
||||
|
||||
if (mLockPatternUtils.checkVoldPassword(KeyguardUpdateMonitor.getCurrentUser())) {
|
||||
if (DEBUG) Log.d(TAG, "Not showing lock screen since just decrypted");
|
||||
// Without this, settings is not enabled until the lock screen first appears
|
||||
setShowingLocked(false);
|
||||
hideLocked();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (DEBUG) Log.d(TAG, "doKeyguard: showing the lock screen");
|
||||
|
||||
@@ -89,8 +89,6 @@ import android.os.ServiceManager;
|
||||
import android.os.SystemClock;
|
||||
import android.os.UserHandle;
|
||||
import android.os.WorkSource;
|
||||
import android.os.storage.IStorageManager;
|
||||
import android.os.storage.StorageManager;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArraySet;
|
||||
@@ -336,7 +334,6 @@ public class UserBackupManagerService {
|
||||
private final ActivityManagerInternal mActivityManagerInternal;
|
||||
private PowerManager mPowerManager;
|
||||
private final AlarmManager mAlarmManager;
|
||||
private final IStorageManager mStorageManager;
|
||||
private final BackupManagerConstants mConstants;
|
||||
private final BackupWakeLock mWakelock;
|
||||
private final BackupHandler mBackupHandler;
|
||||
@@ -567,7 +564,6 @@ public class UserBackupManagerService {
|
||||
mBackupPasswordManager = null;
|
||||
mPackageManagerBinder = null;
|
||||
mActivityManager = null;
|
||||
mStorageManager = null;
|
||||
mBackupManagerBinder = null;
|
||||
mScheduledBackupEligibility = null;
|
||||
}
|
||||
@@ -591,7 +587,6 @@ public class UserBackupManagerService {
|
||||
|
||||
mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||
mPowerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
mStorageManager = IStorageManager.Stub.asInterface(ServiceManager.getService("mount"));
|
||||
|
||||
Objects.requireNonNull(parent, "parent cannot be null");
|
||||
mBackupManagerBinder = BackupManagerService.asInterface(parent.asBinder());
|
||||
@@ -2252,26 +2247,6 @@ public class UserBackupManagerService {
|
||||
}
|
||||
}
|
||||
|
||||
/** For adb backup/restore. */
|
||||
public boolean deviceIsEncrypted() {
|
||||
try {
|
||||
return mStorageManager.getEncryptionState()
|
||||
!= StorageManager.ENCRYPTION_STATE_NONE
|
||||
&& mStorageManager.getPasswordType()
|
||||
!= StorageManager.CRYPT_TYPE_DEFAULT;
|
||||
} catch (Exception e) {
|
||||
// If we can't talk to the storagemanager service we have a serious problem; fail
|
||||
// "secure" i.e. assuming that the device is encrypted.
|
||||
Slog.e(
|
||||
TAG,
|
||||
addUserIdToLogMessage(
|
||||
mUserId,
|
||||
"Unable to communicate with storagemanager service: "
|
||||
+ e.getMessage()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// ----- Full-data backup scheduling -----
|
||||
|
||||
/**
|
||||
|
||||
@@ -316,12 +316,6 @@ public class PerformAdbBackupTask extends FullBackupTask implements BackupRestor
|
||||
try {
|
||||
boolean encrypting = (mEncryptPassword != null && mEncryptPassword.length() > 0);
|
||||
|
||||
// Only allow encrypted backups of encrypted devices
|
||||
if (mUserBackupManagerService.deviceIsEncrypted() && !encrypting) {
|
||||
Slog.e(TAG, "Unencrypted backup of encrypted device; aborting");
|
||||
return;
|
||||
}
|
||||
|
||||
OutputStream finalOutput = ofstream;
|
||||
|
||||
// Verify that the given password matches the currently-active
|
||||
|
||||
@@ -3072,203 +3072,6 @@ class StorageManagerService extends IStorageManager.Stub
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEncryptionState() {
|
||||
mContext.enforceCallingOrSelfPermission(Manifest.permission.CRYPT_KEEPER,
|
||||
"no permission to access the crypt keeper");
|
||||
|
||||
try {
|
||||
return mVold.fdeComplete();
|
||||
} catch (Exception e) {
|
||||
Slog.wtf(TAG, e);
|
||||
return StorageManager.ENCRYPTION_STATE_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int decryptStorage(String password) {
|
||||
mContext.enforceCallingOrSelfPermission(Manifest.permission.CRYPT_KEEPER,
|
||||
"no permission to access the crypt keeper");
|
||||
|
||||
if (TextUtils.isEmpty(password)) {
|
||||
throw new IllegalArgumentException("password cannot be empty");
|
||||
}
|
||||
|
||||
if (DEBUG_EVENTS) {
|
||||
Slog.i(TAG, "decrypting storage...");
|
||||
}
|
||||
|
||||
try {
|
||||
mVold.fdeCheckPassword(password);
|
||||
mHandler.postDelayed(() -> {
|
||||
try {
|
||||
mVold.fdeRestart();
|
||||
} catch (Exception e) {
|
||||
Slog.wtf(TAG, e);
|
||||
}
|
||||
}, DateUtils.SECOND_IN_MILLIS);
|
||||
return 0;
|
||||
} catch (ServiceSpecificException e) {
|
||||
Slog.e(TAG, "fdeCheckPassword failed", e);
|
||||
return e.errorCode;
|
||||
} catch (Exception e) {
|
||||
Slog.wtf(TAG, e);
|
||||
return StorageManager.ENCRYPTION_STATE_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int encryptStorage(int type, String password) {
|
||||
mContext.enforceCallingOrSelfPermission(Manifest.permission.CRYPT_KEEPER,
|
||||
"no permission to access the crypt keeper");
|
||||
|
||||
if (type == StorageManager.CRYPT_TYPE_DEFAULT) {
|
||||
password = "";
|
||||
} else if (TextUtils.isEmpty(password)) {
|
||||
throw new IllegalArgumentException("password cannot be empty");
|
||||
}
|
||||
|
||||
if (DEBUG_EVENTS) {
|
||||
Slog.i(TAG, "encrypting storage...");
|
||||
}
|
||||
|
||||
try {
|
||||
mVold.fdeEnable(type, password, 0);
|
||||
} catch (Exception e) {
|
||||
Slog.wtf(TAG, e);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Set the password for encrypting the main key.
|
||||
* @param type One of the CRYPTO_TYPE_XXX consts defined in StorageManager.
|
||||
* @param password The password to set.
|
||||
*/
|
||||
@Override
|
||||
public int changeEncryptionPassword(int type, String password) {
|
||||
mContext.enforceCallingOrSelfPermission(Manifest.permission.CRYPT_KEEPER,
|
||||
"no permission to access the crypt keeper");
|
||||
|
||||
if (StorageManager.isFileEncryptedNativeOnly()) {
|
||||
// Not supported on FBE devices
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (type == StorageManager.CRYPT_TYPE_DEFAULT) {
|
||||
password = "";
|
||||
} else if (TextUtils.isEmpty(password)) {
|
||||
throw new IllegalArgumentException("password cannot be empty");
|
||||
}
|
||||
|
||||
if (DEBUG_EVENTS) {
|
||||
Slog.i(TAG, "changing encryption password...");
|
||||
}
|
||||
|
||||
try {
|
||||
mVold.fdeChangePassword(type, password);
|
||||
return 0;
|
||||
} catch (Exception e) {
|
||||
Slog.wtf(TAG, e);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a user-supplied password string with cryptfs
|
||||
*/
|
||||
@Override
|
||||
public int verifyEncryptionPassword(String password) throws RemoteException {
|
||||
// Only the system process is permitted to validate passwords
|
||||
if (Binder.getCallingUid() != android.os.Process.SYSTEM_UID) {
|
||||
throw new SecurityException("no permission to access the crypt keeper");
|
||||
}
|
||||
|
||||
mContext.enforceCallingOrSelfPermission(Manifest.permission.CRYPT_KEEPER,
|
||||
"no permission to access the crypt keeper");
|
||||
|
||||
if (TextUtils.isEmpty(password)) {
|
||||
throw new IllegalArgumentException("password cannot be empty");
|
||||
}
|
||||
|
||||
if (DEBUG_EVENTS) {
|
||||
Slog.i(TAG, "validating encryption password...");
|
||||
}
|
||||
|
||||
try {
|
||||
mVold.fdeVerifyPassword(password);
|
||||
return 0;
|
||||
} catch (Exception e) {
|
||||
Slog.wtf(TAG, e);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of encryption used to encrypt the main key.
|
||||
* @return The type, one of the CRYPT_TYPE_XXX consts from StorageManager.
|
||||
*/
|
||||
@Override
|
||||
public int getPasswordType() {
|
||||
mContext.enforceCallingOrSelfPermission(Manifest.permission.CRYPT_KEEPER,
|
||||
"no permission to access the crypt keeper");
|
||||
|
||||
try {
|
||||
return mVold.fdeGetPasswordType();
|
||||
} catch (Exception e) {
|
||||
Slog.wtf(TAG, e);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a field in the crypto header.
|
||||
* @param field field to set
|
||||
* @param contents contents to set in field
|
||||
*/
|
||||
@Override
|
||||
public void setField(String field, String contents) throws RemoteException {
|
||||
mContext.enforceCallingOrSelfPermission(Manifest.permission.CRYPT_KEEPER,
|
||||
"no permission to access the crypt keeper");
|
||||
|
||||
if (!StorageManager.isBlockEncrypted()) {
|
||||
// Only supported on FDE devices
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
mVold.fdeSetField(field, contents);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
Slog.wtf(TAG, e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a field from the crypto header.
|
||||
* @param field field to get
|
||||
* @return contents of field
|
||||
*/
|
||||
@Override
|
||||
public String getField(String field) throws RemoteException {
|
||||
mContext.enforceCallingOrSelfPermission(Manifest.permission.CRYPT_KEEPER,
|
||||
"no permission to access the crypt keeper");
|
||||
|
||||
if (!StorageManager.isBlockEncrypted()) {
|
||||
// Only supported on FDE devices
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return mVold.fdeGetField(field);
|
||||
} catch (Exception e) {
|
||||
Slog.wtf(TAG, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is userdata convertible to file based encryption?
|
||||
* @return non zero for convertible
|
||||
@@ -3350,33 +3153,6 @@ class StorageManagerService extends IStorageManager.Stub
|
||||
mVold.abortChanges(message, retry);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassword() throws RemoteException {
|
||||
mContext.enforceCallingOrSelfPermission(Manifest.permission.CRYPT_KEEPER,
|
||||
"only keyguard can retrieve password");
|
||||
|
||||
try {
|
||||
return mVold.fdeGetPassword();
|
||||
} catch (Exception e) {
|
||||
Slog.wtf(TAG, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPassword() throws RemoteException {
|
||||
mContext.enforceCallingOrSelfPermission(Manifest.permission.CRYPT_KEEPER,
|
||||
"only keyguard can clear password");
|
||||
|
||||
try {
|
||||
mVold.fdeClearPassword();
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
Slog.wtf(TAG, e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createUserKey(int userId, int serialNumber, boolean ephemeral) {
|
||||
enforcePermission(android.Manifest.permission.STORAGE_INTERNAL);
|
||||
|
||||
@@ -237,8 +237,6 @@ public class LockSettingsService extends ILockSettings.Stub {
|
||||
|
||||
private final RebootEscrowManager mRebootEscrowManager;
|
||||
|
||||
private boolean mFirstCallToVold;
|
||||
|
||||
// Current password metric for all users on the device. Updated when user unlocks
|
||||
// the device or changes password. Removed when user is stopped.
|
||||
@GuardedBy("this")
|
||||
@@ -573,8 +571,6 @@ public class LockSettingsService extends ILockSettings.Stub {
|
||||
mStrongAuth = injector.getStrongAuth();
|
||||
mActivityManager = injector.getActivityManager();
|
||||
|
||||
mFirstCallToVold = true;
|
||||
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(Intent.ACTION_USER_ADDED);
|
||||
filter.addAction(Intent.ACTION_USER_STARTING);
|
||||
@@ -2367,77 +2363,6 @@ public class LockSettingsService extends ILockSettings.Stub {
|
||||
});
|
||||
}
|
||||
|
||||
private LockscreenCredential createPattern(String patternString) {
|
||||
final byte[] patternBytes = patternString.getBytes();
|
||||
LockscreenCredential pattern = LockscreenCredential.createPattern(
|
||||
LockPatternUtils.byteArrayToPattern(patternBytes));
|
||||
Arrays.fill(patternBytes, (byte) 0);
|
||||
return pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkVoldPassword(int userId) {
|
||||
if (!mFirstCallToVold) {
|
||||
return false;
|
||||
}
|
||||
mFirstCallToVold = false;
|
||||
|
||||
checkPasswordReadPermission();
|
||||
|
||||
// There's no guarantee that this will safely connect, but if it fails
|
||||
// we will simply show the lock screen when we shouldn't, so relatively
|
||||
// benign. There is an outside chance something nasty would happen if
|
||||
// this service restarted before vold stales out the password in this
|
||||
// case. The nastiness is limited to not showing the lock screen when
|
||||
// we should, within the first minute of decrypting the phone if this
|
||||
// service can't connect to vold, it restarts, and then the new instance
|
||||
// does successfully connect.
|
||||
final IStorageManager service = mInjector.getStorageManager();
|
||||
// TODO(b/120484642): Update vold to return a password as a byte array
|
||||
String password;
|
||||
final long identity = Binder.clearCallingIdentity();
|
||||
try {
|
||||
password = service.getPassword();
|
||||
service.clearPassword();
|
||||
} catch (RemoteException e) {
|
||||
Slog.w(TAG, "vold getPassword() failed", e);
|
||||
return false;
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(identity);
|
||||
}
|
||||
if (TextUtils.isEmpty(password)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
final LockscreenCredential credential;
|
||||
switch (getCredentialTypeInternal(userId)) {
|
||||
case CREDENTIAL_TYPE_PATTERN:
|
||||
credential = createPattern(password);
|
||||
break;
|
||||
case CREDENTIAL_TYPE_PIN:
|
||||
credential = LockscreenCredential.createPin(password);
|
||||
break;
|
||||
case CREDENTIAL_TYPE_PASSWORD:
|
||||
credential = LockscreenCredential.createPassword(password);
|
||||
break;
|
||||
default:
|
||||
credential = null;
|
||||
Slog.e(TAG, "Unknown credential type");
|
||||
}
|
||||
|
||||
if (credential != null
|
||||
&& checkCredential(credential, userId, null /* progressCallback */)
|
||||
.getResponseCode() == GateKeeperResponse.RESPONSE_OK) {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Slog.e(TAG, "checkVoldPassword failed: ", e);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void removeUser(int userId, boolean unknownUser) {
|
||||
Slog.i(TAG, "RemoveUser: " + userId);
|
||||
removeBiometricsForUser(userId);
|
||||
|
||||
Reference in New Issue
Block a user