Loading core/java/com/android/internal/widget/ILockSettings.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -40,4 +40,5 @@ interface ILockSettings { void registerStrongAuthTracker(in IStrongAuthTracker tracker); void unregisterStrongAuthTracker(in IStrongAuthTracker tracker); void requireStrongAuth(int strongAuthReason, int userId); String getPassword(); } services/core/java/com/android/server/LockSettingsService.java +21 −1 Original line number Diff line number Diff line Loading @@ -388,7 +388,27 @@ public class LockSettingsService extends ILockSettings.Stub { } } private boolean checkCryptKeeperPermissions() { boolean permission_err = false; try { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.CRYPT_KEEPER, "no permission to get the password"); } catch (SecurityException e) { permission_err = true; } return permission_err; } public String getPassword() { /** if calling process does't have crypt keeper or admin permissions, * throw the exception. */ if (checkCryptKeeperPermissions()) mContext.enforceCallingOrSelfPermission( android.Manifest.permission.MANAGE_DEVICE_ADMINS, "no crypt_keeper or admin permission to get the password"); return mSavePassword; } Loading services/core/java/com/android/server/MountService.java +15 −3 Original line number Diff line number Diff line Loading @@ -101,6 +101,7 @@ import com.android.internal.util.Preconditions; import com.android.server.NativeDaemonConnector.Command; import com.android.server.NativeDaemonConnector.SensitiveArg; import com.android.server.pm.PackageManagerService; import com.android.internal.widget.ILockSettings; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; Loading Loading @@ -2460,13 +2461,24 @@ class MountService extends IMountService.Stub Slog.i(TAG, "changing encryption password..."); } LockSettingsService lockSettings = new LockSettingsService(mContext); String currentPassword = lockSettings.getPassword(); ILockSettings lockSettings = ILockSettings.Stub.asInterface( ServiceManager.getService("lock_settings")); String currentPassword="default_password"; try { currentPassword = lockSettings.getPassword(); } catch (RemoteException e) { Slog.e(TAG, "Couldn't get password" + e); } try { NativeDaemonEvent event = mCryptConnector.execute("cryptfs", "changepw", CRYPTO_TYPES[type], new SensitiveArg(currentPassword), new SensitiveArg(password)); try { lockSettings.sanitizePassword(); } catch (RemoteException e) { Slog.e(TAG, "Couldn't sanitize password" + e); } return Integer.parseInt(event.getMessage()); } catch (NativeDaemonConnectorException e) { // Encryption failed Loading Loading
core/java/com/android/internal/widget/ILockSettings.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -40,4 +40,5 @@ interface ILockSettings { void registerStrongAuthTracker(in IStrongAuthTracker tracker); void unregisterStrongAuthTracker(in IStrongAuthTracker tracker); void requireStrongAuth(int strongAuthReason, int userId); String getPassword(); }
services/core/java/com/android/server/LockSettingsService.java +21 −1 Original line number Diff line number Diff line Loading @@ -388,7 +388,27 @@ public class LockSettingsService extends ILockSettings.Stub { } } private boolean checkCryptKeeperPermissions() { boolean permission_err = false; try { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.CRYPT_KEEPER, "no permission to get the password"); } catch (SecurityException e) { permission_err = true; } return permission_err; } public String getPassword() { /** if calling process does't have crypt keeper or admin permissions, * throw the exception. */ if (checkCryptKeeperPermissions()) mContext.enforceCallingOrSelfPermission( android.Manifest.permission.MANAGE_DEVICE_ADMINS, "no crypt_keeper or admin permission to get the password"); return mSavePassword; } Loading
services/core/java/com/android/server/MountService.java +15 −3 Original line number Diff line number Diff line Loading @@ -101,6 +101,7 @@ import com.android.internal.util.Preconditions; import com.android.server.NativeDaemonConnector.Command; import com.android.server.NativeDaemonConnector.SensitiveArg; import com.android.server.pm.PackageManagerService; import com.android.internal.widget.ILockSettings; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; Loading Loading @@ -2460,13 +2461,24 @@ class MountService extends IMountService.Stub Slog.i(TAG, "changing encryption password..."); } LockSettingsService lockSettings = new LockSettingsService(mContext); String currentPassword = lockSettings.getPassword(); ILockSettings lockSettings = ILockSettings.Stub.asInterface( ServiceManager.getService("lock_settings")); String currentPassword="default_password"; try { currentPassword = lockSettings.getPassword(); } catch (RemoteException e) { Slog.e(TAG, "Couldn't get password" + e); } try { NativeDaemonEvent event = mCryptConnector.execute("cryptfs", "changepw", CRYPTO_TYPES[type], new SensitiveArg(currentPassword), new SensitiveArg(password)); try { lockSettings.sanitizePassword(); } catch (RemoteException e) { Slog.e(TAG, "Couldn't sanitize password" + e); } return Integer.parseInt(event.getMessage()); } catch (NativeDaemonConnectorException e) { // Encryption failed Loading