Search in sources :

Example 86 with IMountService

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

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 87 with IMountService

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

the class PackageHelper method createSdDir.

public static String createSdDir(long sizeBytes, String cid, String sdEncKey, int uid, boolean isExternal) {
    // Round up to nearest MB, plus another MB for filesystem overhead
    final int sizeMb = (int) ((sizeBytes + MB_IN_BYTES) / MB_IN_BYTES) + 1;
    try {
        IMountService mountService = getMountService();
        if (localLOGV)
            Log.i(TAG, "Size of container " + sizeMb + " MB");
        int rc = mountService.createSecureContainer(cid, sizeMb, "ext4", sdEncKey, uid, isExternal);
        if (rc != StorageResultCode.OperationSucceeded) {
            Log.e(TAG, "Failed to create secure container " + cid);
            return null;
        }
        String cachePath = mountService.getSecureContainerPath(cid);
        if (localLOGV)
            Log.i(TAG, "Created secure container " + cid + " at " + cachePath);
        return cachePath;
    } catch (RemoteException e) {
        Log.e(TAG, "MountService running?");
    }
    return null;
}
Also used : IMountService(android.os.storage.IMountService) RemoteException(android.os.RemoteException)

Example 88 with IMountService

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

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 89 with IMountService

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

the class UserController method unlockUserCleared.

boolean unlockUserCleared(final int userId, byte[] token, byte[] secret, IProgressListener listener) {
    UserState uss;
    synchronized (mService) {
        // TODO Move this block outside of synchronized if it causes lock contention
        if (!StorageManager.isUserKeyUnlocked(userId)) {
            final UserInfo userInfo = getUserInfo(userId);
            final IMountService mountService = getMountService();
            try {
                // We always want to unlock user storage, even user is not started yet
                mountService.unlockUserKey(userId, userInfo.serialNumber, token, secret);
            } catch (RemoteException | RuntimeException e) {
                Slog.w(TAG, "Failed to unlock: " + e.getMessage());
            }
        }
        // Bail if user isn't actually running, otherwise register the given
        // listener to watch for unlock progress
        uss = mStartedUsers.get(userId);
        if (uss == null) {
            notifyFinished(userId, listener);
            return false;
        } else {
            uss.mUnlockProgress.addListener(listener);
            uss.tokenProvided = (token != null);
        }
    }
    finishUserUnlocking(uss);
    final ArraySet<Integer> childProfilesToUnlock = new ArraySet<>();
    synchronized (mService) {
        // managed profiles under that user.
        for (int i = 0; i < mStartedUsers.size(); i++) {
            final int testUserId = mStartedUsers.keyAt(i);
            final UserInfo parent = getUserManager().getProfileParent(testUserId);
            if (parent != null && parent.id == userId && testUserId != userId) {
                Slog.d(TAG, "User " + testUserId + " (parent " + parent.id + "): attempting unlock because parent was just unlocked");
                childProfilesToUnlock.add(testUserId);
            }
        }
    }
    final int size = childProfilesToUnlock.size();
    for (int i = 0; i < size; i++) {
        maybeUnlockUser(childProfilesToUnlock.valueAt(i));
    }
    return true;
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ArraySet(android.util.ArraySet) IMountService(android.os.storage.IMountService) UserInfo(android.content.pm.UserInfo) RemoteException(android.os.RemoteException)

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