diff options
| author | 2016-04-01 20:01:58 +0000 | |
|---|---|---|
| committer | 2016-04-01 20:02:00 +0000 | |
| commit | bb5e52f928c2215256ea46bc2592fa3c077c15b0 (patch) | |
| tree | e523b552abec716c5091455543391fe3c85c0961 | |
| parent | b38fa4e7244f0fe831b416a1a3da27bd60379b3f (diff) | |
| parent | 51b651aea178fcfca8a3219141f0ecfda1504887 (diff) | |
Merge "introduce GET_PASSWORD_PRIVILEDGED permission." into nyc-dev
| -rw-r--r-- | api/current.txt | 1 | ||||
| -rw-r--r-- | api/system-current.txt | 1 | ||||
| -rw-r--r-- | api/test-current.txt | 1 | ||||
| -rw-r--r-- | core/java/android/accounts/AccountManager.java | 11 | ||||
| -rw-r--r-- | core/res/AndroidManifest.xml | 5 | ||||
| -rw-r--r-- | services/core/java/com/android/server/accounts/AccountManagerService.java | 46 |
6 files changed, 56 insertions, 9 deletions
diff --git a/api/current.txt b/api/current.txt index 67f4c1fa6059..22958859d89c 100644 --- a/api/current.txt +++ b/api/current.txt @@ -71,6 +71,7 @@ package android { field public static final java.lang.String GET_ACCOUNTS = "android.permission.GET_ACCOUNTS"; field public static final java.lang.String GET_ACCOUNTS_PRIVILEGED = "android.permission.GET_ACCOUNTS_PRIVILEGED"; field public static final java.lang.String GET_PACKAGE_SIZE = "android.permission.GET_PACKAGE_SIZE"; + field public static final java.lang.String GET_PASSWORD_PRIVILEGED = "android.permission.GET_PASSWORD_PRIVILEGED"; field public static final deprecated java.lang.String GET_TASKS = "android.permission.GET_TASKS"; field public static final java.lang.String GLOBAL_SEARCH = "android.permission.GLOBAL_SEARCH"; field public static final java.lang.String INSTALL_LOCATION_PROVIDER = "android.permission.INSTALL_LOCATION_PROVIDER"; diff --git a/api/system-current.txt b/api/system-current.txt index 3ccd7e0a0553..8beb796cac41 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -103,6 +103,7 @@ package android { field public static final java.lang.String GET_APP_OPS_STATS = "android.permission.GET_APP_OPS_STATS"; field public static final java.lang.String GET_PACKAGE_IMPORTANCE = "android.permission.GET_PACKAGE_IMPORTANCE"; field public static final java.lang.String GET_PACKAGE_SIZE = "android.permission.GET_PACKAGE_SIZE"; + field public static final java.lang.String GET_PASSWORD_PRIVILEGED = "android.permission.GET_PASSWORD_PRIVILEGED"; field public static final java.lang.String GET_PROCESS_STATE_AND_OOM_SCORE = "android.permission.GET_PROCESS_STATE_AND_OOM_SCORE"; field public static final deprecated java.lang.String GET_TASKS = "android.permission.GET_TASKS"; field public static final java.lang.String GET_TOP_ACTIVITY_INFO = "android.permission.GET_TOP_ACTIVITY_INFO"; diff --git a/api/test-current.txt b/api/test-current.txt index 3be562d0b352..dee2f551a27d 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -71,6 +71,7 @@ package android { field public static final java.lang.String GET_ACCOUNTS = "android.permission.GET_ACCOUNTS"; field public static final java.lang.String GET_ACCOUNTS_PRIVILEGED = "android.permission.GET_ACCOUNTS_PRIVILEGED"; field public static final java.lang.String GET_PACKAGE_SIZE = "android.permission.GET_PACKAGE_SIZE"; + field public static final java.lang.String GET_PASSWORD_PRIVILEGED = "android.permission.GET_PASSWORD_PRIVILEGED"; field public static final deprecated java.lang.String GET_TASKS = "android.permission.GET_TASKS"; field public static final java.lang.String GLOBAL_SEARCH = "android.permission.GLOBAL_SEARCH"; field public static final java.lang.String INSTALL_LOCATION_PROVIDER = "android.permission.INSTALL_LOCATION_PROVIDER"; diff --git a/core/java/android/accounts/AccountManager.java b/core/java/android/accounts/AccountManager.java index e520b406656b..7465ed92e469 100644 --- a/core/java/android/accounts/AccountManager.java +++ b/core/java/android/accounts/AccountManager.java @@ -2798,6 +2798,15 @@ public class AccountManager { if (account == null) { throw new IllegalArgumentException("account is null"); } + + // Always include the calling package name. This just makes life easier + // down stream. + final Bundle optionsIn = new Bundle(); + if (options != null) { + optionsIn.putAll(options); + } + optionsIn.putString(KEY_ANDROID_PACKAGE_NAME, mContext.getPackageName()); + return new AmsTask(activity, handler, callback) { @Override public void doWork() throws RemoteException { @@ -2806,7 +2815,7 @@ public class AccountManager { account, authTokenType, activity != null, - options); + optionsIn); } }.start(); } diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index e03183b216f1..6aa0dcf083df 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -2004,6 +2004,11 @@ <permission android:name="android.permission.GET_ACCOUNTS_PRIVILEGED" android:protectionLevel="signature|privileged" /> + <!-- @SystemApi Allows but does not guarantee access to user passwords at the conclusion of add + account --> + <permission android:name="android.permission.GET_PASSWORD_PRIVILEGED" + android:protectionLevel="signature|privileged" /> + <!-- @SystemApi Allows applications to RW to diagnostic resources. <p>Not for use by third-party applications. --> <permission android:name="android.permission.DIAGNOSTIC" diff --git a/services/core/java/com/android/server/accounts/AccountManagerService.java b/services/core/java/com/android/server/accounts/AccountManagerService.java index bb323031c011..b8b763886a51 100644 --- a/services/core/java/com/android/server/accounts/AccountManagerService.java +++ b/services/core/java/com/android/server/accounts/AccountManagerService.java @@ -2500,21 +2500,31 @@ public class AccountManagerService userId); return; } - final int pid = Binder.getCallingPid(); final Bundle options = (optionsIn == null) ? new Bundle() : optionsIn; options.putInt(AccountManager.KEY_CALLER_UID, uid); options.putInt(AccountManager.KEY_CALLER_PID, pid); + // Check to see if the Password should be included to the caller. + String callerPkg = optionsIn.getString(AccountManager.KEY_ANDROID_PACKAGE_NAME); + boolean isPasswordForwardingAllowed = isPermitted( + callerPkg, uid, Manifest.permission.GET_PASSWORD_PRIVILEGED); + int usrId = UserHandle.getCallingUserId(); long identityToken = clearCallingIdentity(); try { UserAccounts accounts = getUserAccounts(usrId); logRecordWithUid(accounts, DebugDbHelper.ACTION_CALLED_START_ACCOUNT_ADD, TABLE_ACCOUNTS, uid); - new StartAccountSession(accounts, response, accountType, expectActivityLaunch, - null /* accountName */, false /* authDetailsRequired */, - true /* updateLastAuthenticationTime */) { + new StartAccountSession( + accounts, + response, + accountType, + expectActivityLaunch, + null /* accountName */, + false /* authDetailsRequired */, + true /* updateLastAuthenticationTime */, + isPasswordForwardingAllowed) { @Override public void run() throws RemoteException { mAuthenticator.startAddAccountSession(this, mAccountType, authTokenType, @@ -2537,12 +2547,21 @@ public class AccountManagerService /** Session that will encrypt the KEY_ACCOUNT_SESSION_BUNDLE in result. */ private abstract class StartAccountSession extends Session { - public StartAccountSession(UserAccounts accounts, IAccountManagerResponse response, - String accountType, boolean expectActivityLaunch, String accountName, - boolean authDetailsRequired, boolean updateLastAuthenticationTime) { + private final boolean mIsPasswordForwardingAllowed; + + public StartAccountSession( + UserAccounts accounts, + IAccountManagerResponse response, + String accountType, + boolean expectActivityLaunch, + String accountName, + boolean authDetailsRequired, + boolean updateLastAuthenticationTime, + boolean isPasswordForwardingAllowed) { super(accounts, response, accountType, expectActivityLaunch, true /* stripAuthTokenFromResult */, accountName, authDetailsRequired, updateLastAuthenticationTime); + mIsPasswordForwardingAllowed = isPasswordForwardingAllowed; } @Override @@ -2555,6 +2574,10 @@ public class AccountManagerService checkKeyIntent( Binder.getCallingUid(), intent); + // Omit passwords if the caller isn't permitted to see them. + if (!mIsPasswordForwardingAllowed) { + result.remove(AccountManager.KEY_PASSWORD); + } } IAccountManagerResponse response; if (mExpectActivityLaunch && result != null @@ -2901,6 +2924,12 @@ public class AccountManagerService } int userId = UserHandle.getCallingUserId(); + + // Check to see if the Password should be included to the caller. + String callerPkg = loginOptions.getString(AccountManager.KEY_ANDROID_PACKAGE_NAME); + boolean isPasswordForwardingAllowed = isPermitted( + callerPkg, uid, Manifest.permission.GET_PASSWORD_PRIVILEGED); + long identityToken = clearCallingIdentity(); try { UserAccounts accounts = getUserAccounts(userId); @@ -2911,7 +2940,8 @@ public class AccountManagerService expectActivityLaunch, account.name, false /* authDetailsRequired */, - true /* updateLastCredentialTime */) { + true /* updateLastCredentialTime */, + isPasswordForwardingAllowed) { @Override public void run() throws RemoteException { mAuthenticator.startUpdateCredentialsSession(this, account, authTokenType, |