Search in sources :

Example 56 with IMountService

use of android.os.storage.IMountService in project android_frameworks_base by ResurrectionRemix.

the class LockPatternUtils method setVisiblePatternEnabled.

/**
     * Set whether the visible pattern is enabled.
     */
public void setVisiblePatternEnabled(boolean enabled, int userId) {
    setBoolean(Settings.Secure.LOCK_PATTERN_VISIBLE, enabled, userId);
    // Update for crypto if owner
    if (userId != UserHandle.USER_SYSTEM) {
        return;
    }
    IBinder service = ServiceManager.getService("mount");
    if (service == null) {
        Log.e(TAG, "Could not find the mount service to update the user info");
        return;
    }
    IMountService mountService = IMountService.Stub.asInterface(service);
    try {
        mountService.setField(StorageManager.PATTERN_VISIBLE_KEY, enabled ? "1" : "0");
    } catch (RemoteException e) {
        Log.e(TAG, "Error changing pattern visible state", e);
    }
}
Also used : IBinder(android.os.IBinder) IMountService(android.os.storage.IMountService) RemoteException(android.os.RemoteException)

Example 57 with IMountService

use of android.os.storage.IMountService in project platform_frameworks_base by android.

the class LockPatternUtils method setVisiblePasswordEnabled.

/**
     * Set whether the visible password is enabled for cryptkeeper screen.
     */
public void setVisiblePasswordEnabled(boolean enabled, int userId) {
    // Update for crypto if owner
    if (userId != UserHandle.USER_SYSTEM) {
        return;
    }
    IBinder service = ServiceManager.getService("mount");
    if (service == null) {
        Log.e(TAG, "Could not find the mount service to update the user info");
        return;
    }
    IMountService mountService = IMountService.Stub.asInterface(service);
    try {
        mountService.setField(StorageManager.PASSWORD_VISIBLE_KEY, enabled ? "1" : "0");
    } catch (RemoteException e) {
        Log.e(TAG, "Error changing password visible state", e);
    }
}
Also used : IBinder(android.os.IBinder) IMountService(android.os.storage.IMountService) RemoteException(android.os.RemoteException)

Example 58 with IMountService

use of android.os.storage.IMountService in project platform_frameworks_base by android.

the class LockPatternUtils method updateCryptoUserInfo.

private void updateCryptoUserInfo(int userId) {
    if (userId != UserHandle.USER_SYSTEM) {
        return;
    }
    final String ownerInfo = isOwnerInfoEnabled(userId) ? getOwnerInfo(userId) : "";
    IBinder service = ServiceManager.getService("mount");
    if (service == null) {
        Log.e(TAG, "Could not find the mount service to update the user info");
        return;
    }
    IMountService mountService = IMountService.Stub.asInterface(service);
    try {
        Log.d(TAG, "Setting owner info");
        mountService.setField(StorageManager.OWNER_INFO_KEY, ownerInfo);
    } catch (RemoteException e) {
        Log.e(TAG, "Error changing user info", e);
    }
}
Also used : IBinder(android.os.IBinder) IMountService(android.os.storage.IMountService) RemoteException(android.os.RemoteException)

Example 59 with IMountService

use of android.os.storage.IMountService in project platform_frameworks_base by android.

the class LockSettingsService method addUserKeyAuth.

private void addUserKeyAuth(int userId, byte[] token, byte[] secret) throws RemoteException {
    final UserInfo userInfo = UserManager.get(mContext).getUserInfo(userId);
    final IMountService mountService = getMountService();
    final long callingId = Binder.clearCallingIdentity();
    try {
        mountService.addUserKeyAuth(userId, userInfo.serialNumber, token, secret);
    } finally {
        Binder.restoreCallingIdentity(callingId);
    }
}
Also used : IMountService(android.os.storage.IMountService) UserInfo(android.content.pm.UserInfo)

Example 60 with IMountService

use of android.os.storage.IMountService in project platform_frameworks_base by android.

the class LockSettingsService method checkVoldPassword.

@Override
public boolean checkVoldPassword(int userId) throws RemoteException {
    if (!mFirstCallToVold) {
        return false;
    }
    mFirstCallToVold = false;
    checkPasswordReadPermission(userId);
    // 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 IMountService service = getMountService();
    String password;
    long identity = Binder.clearCallingIdentity();
    try {
        password = service.getPassword();
        service.clearPassword();
    } finally {
        Binder.restoreCallingIdentity(identity);
    }
    if (password == null) {
        return false;
    }
    try {
        if (mLockPatternUtils.isLockPatternEnabled(userId)) {
            if (checkPattern(password, userId, null).getResponseCode() == GateKeeperResponse.RESPONSE_OK) {
                return true;
            }
        }
    } catch (Exception e) {
    }
    try {
        if (mLockPatternUtils.isLockPasswordEnabled(userId)) {
            if (checkPassword(password, userId, null).getResponseCode() == GateKeeperResponse.RESPONSE_OK) {
                return true;
            }
        }
    } catch (Exception e) {
    }
    return false;
}
Also used : IMountService(android.os.storage.IMountService) SettingNotFoundException(android.provider.Settings.SettingNotFoundException) KeyStoreException(java.security.KeyStoreException) IllegalBlockSizeException(javax.crypto.IllegalBlockSizeException) FileNotFoundException(java.io.FileNotFoundException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) InvalidKeyException(java.security.InvalidKeyException) RemoteException(android.os.RemoteException) InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) NoSuchPaddingException(javax.crypto.NoSuchPaddingException) UnrecoverableKeyException(java.security.UnrecoverableKeyException) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) BadPaddingException(javax.crypto.BadPaddingException)

Aggregations

IMountService (android.os.storage.IMountService)89 RemoteException (android.os.RemoteException)70 IBinder (android.os.IBinder)23 IOException (java.io.IOException)15 Context (android.content.Context)10 UserInfo (android.content.pm.UserInfo)10 FileNotFoundException (java.io.FileNotFoundException)10 Intent (android.content.Intent)9 ErrnoException (android.system.ErrnoException)9 IActivityManager (android.app.IActivityManager)6 BroadcastReceiver (android.content.BroadcastReceiver)6 IMountShutdownObserver (android.os.storage.IMountShutdownObserver)6 SettingNotFoundException (android.provider.Settings.SettingNotFoundException)5 ArraySet (android.util.ArraySet)5 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)5 InvalidKeyException (java.security.InvalidKeyException)5 KeyStoreException (java.security.KeyStoreException)5 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)5 UnrecoverableKeyException (java.security.UnrecoverableKeyException)5 CertificateException (java.security.cert.CertificateException)5