Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4e1174d9 authored by Paul Crowley's avatar Paul Crowley Committed by Android Git Automerger
Browse files

am 7b6493a7: am 62d43bd9: am 9e0e6991: Merge "Use mount service to create user...

am 7b6493a7: am 62d43bd9: am 9e0e6991: Merge "Use mount service to create user dirs." into mnc-dr-dev

* commit '7b6493a7':
  Use mount service to create user dirs.
parents 7475cc16 7b6493a7
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -1192,6 +1192,22 @@ public interface IMountService extends IInterface {
                    _data.recycle();
                }
            }

            @Override
            public void createNewUserDir(int userHandle, String path) throws RemoteException {
                Parcel _data = Parcel.obtain();
                Parcel _reply = Parcel.obtain();
                try {
                    _data.writeInterfaceToken(DESCRIPTOR);
                    _data.writeInt(userHandle);
                    _data.writeString(path);
                    mRemote.transact(Stub.TRANSACTION_createNewUserDir, _data, _reply, 0);
                    _reply.readException();
                } finally {
                    _reply.recycle();
                    _data.recycle();
                }
            }
        }

        private static final String DESCRIPTOR = "IMountService";
@@ -1309,6 +1325,8 @@ public interface IMountService extends IInterface {

        static final int TRANSACTION_remountUid = IBinder.FIRST_CALL_TRANSACTION + 61;

        static final int TRANSACTION_createNewUserDir = IBinder.FIRST_CALL_TRANSACTION + 62;

        /**
         * Cast an IBinder object into an IMountService interface, generating a
         * proxy if needed.
@@ -1869,6 +1887,14 @@ public interface IMountService extends IInterface {
                    reply.writeNoException();
                    return true;
                }
                case TRANSACTION_createNewUserDir: {
                    data.enforceInterface(DESCRIPTOR);
                    int userHandle = data.readInt();
                    String path = data.readString();
                    createNewUserDir(userHandle, path);
                    reply.writeNoException();
                    return true;
                }
            }
            return super.onTransact(code, data, reply, flags);
        }
@@ -2180,4 +2206,12 @@ public interface IMountService extends IInterface {
            throws RemoteException;

    public void remountUid(int uid) throws RemoteException;

    /**
     * Creates the user data directory, possibly encrypted
     * @param userHandle Handle of the user whose directory we are creating
     * @param path Path at which to create the directory.
     */
    public void createNewUserDir(int userHandle, String path)
        throws RemoteException;
}
+9 −0
Original line number Diff line number Diff line
@@ -945,6 +945,15 @@ public class StorageManager {
                DEFAULT_FULL_THRESHOLD_BYTES);
    }

    /** {@hide} */
    public void createNewUserDir(int userHandle, File path) {
        try {
            mMountService.createNewUserDir(userHandle, path.getAbsolutePath());
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
        }
    }

    /** {@hide} */
    public static File maybeTranslateEmulatedPathToInternal(File path) {
        final IMountService mountService = IMountService.Stub.asInterface(
+28 −0
Original line number Diff line number Diff line
@@ -2558,6 +2558,34 @@ class MountService extends IMountService.Stub
        }
    }

    @Override
    public void createNewUserDir(int userHandle, String path) {
        if (Binder.getCallingUid() != Process.SYSTEM_UID) {
            throw new SecurityException("Only SYSTEM_UID can create user directories");
        }

        waitForReady();

        if (DEBUG_EVENTS) {
            Slog.i(TAG, "Creating new user dir");
        }

        try {
            NativeDaemonEvent event = mCryptConnector.execute(
                "cryptfs", "createnewuserdir", userHandle, path);
            if (!"0".equals(event.getMessage())) {
                String error = "createnewuserdir sent unexpected message: "
                    + event.getMessage();
                Slog.e(TAG,  error);
                // ext4enc:TODO is this the right exception?
                throw new RuntimeException(error);
            }
        } catch (NativeDaemonConnectorException e) {
            Slog.e(TAG, "createnewuserdir threw exception", e);
            throw new RuntimeException("createnewuserdir threw exception", e);
        }
    }

    @Override
    public int mkdirs(String callingPkg, String appPath) {
        final int userId = UserHandle.getUserId(Binder.getCallingUid());
+1 −1
Original line number Diff line number Diff line
@@ -15531,7 +15531,7 @@ public class PackageManagerService extends IPackageManager.Stub {
            if (userDir.exists()) continue;
            try {
                UserManagerService.prepareUserDirectory(userDir);
                UserManagerService.prepareUserDirectory(mContext, volumeUuid, user.id);
                UserManagerService.enforceSerialNumber(userDir, user.serialNumber);
            } catch (IOException e) {
                Log.wtf(TAG, "Failed to create user directory on " + volumeUuid, e);
+4 −0
Original line number Diff line number Diff line
@@ -38,13 +38,17 @@ import android.os.Binder;
import android.os.Build;
import android.os.Environment;
import android.os.FileUtils;
import android.os.IBinder;
import android.os.Handler;
import android.os.Message;
import android.os.PatternMatcher;
import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
import android.os.UserHandle;
import android.os.UserManager;
import android.os.storage.StorageManager;
import android.os.storage.VolumeInfo;
import android.util.AtomicFile;
import android.text.TextUtils;
Loading