diff options
author | Paul Lawrence <paullawrence@google.com> | 2014-03-18 10:56:00 -0700 |
---|---|---|
committer | Paul Lawrence <paullawrence@google.com> | 2014-04-02 07:16:05 -0700 |
commit | e51dcf98a4ddb1340cffba88059ad89f0b90909a (patch) | |
tree | af254b55a6ca13f1517b9acdec52008fef2e5f24 /core | |
parent | 9c3b2583b5fd9a610456cd42710808c5624f205b (diff) | |
download | frameworks_base-e51dcf98a4ddb1340cffba88059ad89f0b90909a.zip frameworks_base-e51dcf98a4ddb1340cffba88059ad89f0b90909a.tar.gz frameworks_base-e51dcf98a4ddb1340cffba88059ad89f0b90909a.tar.bz2 |
Save OwnerInfo so CryptKeeper can display at boot time
Requires vold change from
https://googleplex-android-review.git.corp.google.com/#/c/435164/
Bug: 13526708
Change-Id: I33153df9961832f72c3b8103bd5e1d3a17e77df3
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/os/storage/IMountService.java | 67 | ||||
-rw-r--r-- | core/java/com/android/internal/widget/LockPatternUtils.java | 25 |
2 files changed, 91 insertions, 1 deletions
diff --git a/core/java/android/os/storage/IMountService.java b/core/java/android/os/storage/IMountService.java index 4180860..2ef5b66 100644 --- a/core/java/android/os/storage/IMountService.java +++ b/core/java/android/os/storage/IMountService.java @@ -713,15 +713,46 @@ 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; } diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java index b9bc54d..4504910 100644 --- a/core/java/com/android/internal/widget/LockPatternUtils.java +++ b/core/java/com/android/internal/widget/LockPatternUtils.java @@ -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) { |