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

Commit f17f0e0e authored by Paul Lawrence's avatar Paul Lawrence Committed by Android (Google) Code Review
Browse files

Merge "Save OwnerInfo so CryptKeeper can display at boot time"

parents a867e1de e51dcf98
Loading
Loading
Loading
Loading
+66 −1
Original line number Diff line number Diff line
@@ -711,17 +711,48 @@ public interface IMountService extends IInterface {
            }

            public void clearPassword() throws RemoteException {
                Parcel _data = Parcel.obtain();
                Parcel _reply = Parcel.obtain();
                try {
                    _data.writeInterfaceToken(DESCRIPTOR);
                    mRemote.transact(Stub.TRANSACTION_clearPassword, _data, _reply, IBinder.FLAG_ONEWAY);
                    _reply.readException();
                } finally {
                    _reply.recycle();
                    _data.recycle();
                }
            }

            public void setField(String field, String data) throws RemoteException {
                Parcel _data = Parcel.obtain();
                Parcel _reply = Parcel.obtain();
                try {
                    _data.writeInterfaceToken(DESCRIPTOR);
                    _data.writeString(field);
                    _data.writeString(data);
                    mRemote.transact(Stub.TRANSACTION_setField, _data, _reply, IBinder.FLAG_ONEWAY);
                    _reply.readException();
                } finally {
                    _reply.recycle();
                    _data.recycle();
                }
            }

            public String getField(String field) throws RemoteException {
                Parcel _data = Parcel.obtain();
                Parcel _reply = Parcel.obtain();
                String _result;
                try {
                    _data.writeInterfaceToken(DESCRIPTOR);
                    mRemote.transact(Stub.TRANSACTION_clearPassword, _data, _reply, 0);
                    _data.writeString(field);
                    mRemote.transact(Stub.TRANSACTION_getField, _data, _reply, 0);
                    _reply.readException();
                    _result = _reply.readString();
                } finally {
                    _reply.recycle();
                    _data.recycle();
                }
                return _result;
            }

            public StorageVolume[] getVolumeList() throws RemoteException {
@@ -882,6 +913,10 @@ public interface IMountService extends IInterface {

        static final int TRANSACTION_clearPassword = IBinder.FIRST_CALL_TRANSACTION + 37;

        static final int TRANSACTION_setField = IBinder.FIRST_CALL_TRANSACTION + 38;

        static final int TRANSACTION_getField = IBinder.FIRST_CALL_TRANSACTION + 39;

        /**
         * Cast an IBinder object into an IMountService interface, generating a
         * proxy if needed.
@@ -1255,6 +1290,22 @@ public interface IMountService extends IInterface {
                    reply.writeNoException();
                    return true;
                }
                case TRANSACTION_setField: {
                    data.enforceInterface(DESCRIPTOR);
                    String field = data.readString();
                    String contents = data.readString();
                    setField(field, contents);
                    reply.writeNoException();
                    return true;
                }
                case TRANSACTION_getField: {
                    data.enforceInterface(DESCRIPTOR);
                    String field = data.readString();
                    String contents = getField(field);
                    reply.writeNoException();
                    reply.writeString(contents);
                    return true;
                }
            }
            return super.onTransact(code, data, reply, flags);
        }
@@ -1504,4 +1555,18 @@ public interface IMountService extends IInterface {
     * Securely clear password from vold
     */
    public void clearPassword() throws RemoteException;

    /**
     * Set a field in the crypto header.
     * @param field field to set
     * @param contents contents to set in field
     */
    public void setField(String field, String contents) throws RemoteException;

    /**
     * Gets a field from the crypto header.
     * @param field field to get
     * @return contents of field
     */
    public String getField(String field) throws RemoteException;
}
+25 −0
Original line number Diff line number Diff line
@@ -564,12 +564,37 @@ public class LockPatternUtils {
        }
    }

    private void updateCryptoUserInfo() {
        int userId = getCurrentOrCallingUserId();
        if (userId != UserHandle.USER_OWNER) {
            return;
        }

        final String ownerInfo = isOwnerInfoEnabled() ? 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("OwnerInfo", ownerInfo);
        } catch (RemoteException e) {
            Log.e(TAG, "Error changing user info", e);
        }
    }

    public void setOwnerInfo(String info, int userId) {
        setString(LOCK_SCREEN_OWNER_INFO, info, userId);
        updateCryptoUserInfo();
    }

    public void setOwnerInfoEnabled(boolean enabled) {
        setBoolean(LOCK_SCREEN_OWNER_INFO_ENABLED, enabled);
        updateCryptoUserInfo();
    }

    public String getOwnerInfo(int userId) {
+44 −0
Original line number Diff line number Diff line
@@ -158,6 +158,7 @@ class MountService extends IMountService.Stub
        public static final int VolumeListResult               = 110;
        public static final int AsecListResult                 = 111;
        public static final int StorageUsersListResult         = 112;
        public static final int CryptfsGetfieldResult          = 113;

        /*
         * 200 series - Requestion action has been successfully completed.
@@ -2251,6 +2252,49 @@ class MountService extends IMountService.Stub
        }
    }

    /**
     * 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 {

        waitForReady();

        final NativeDaemonEvent event;
        try {
            event = mConnector.execute("cryptfs", "setfield", field, contents);
        } catch (NativeDaemonConnectorException e) {
            throw e.rethrowAsParcelableException();
        }
    }

    /**
     * Gets a field from the crypto header.
     * @param field field to get
     * @return contents of field
     */
    @Override
    public String getField(String field) throws RemoteException {

        waitForReady();

        final NativeDaemonEvent event;
        try {
            final String[] contents = NativeDaemonEvent.filterMessageList(
                    mConnector.executeForList("cryptfs", "getfield", field),
                    VoldResponseCode.CryptfsGetfieldResult);
            String result = new String();
            for (String content : contents) {
                result += content;
            }
            return result;
        } catch (NativeDaemonConnectorException e) {
            throw e.rethrowAsParcelableException();
        }
    }

    @Override
    public String getPassword() throws RemoteException {
        if (!isReady()) {