Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
View issue level access limits(Press Alt + Right arrow for more information)
Unintended behavior
View staffing
Description
(1) Steps to reproduce the problem:
Write a demo to create a new item in ChooseAccountActivity and set an Invalid intent in Bundle in addAccount method in the class which implenments AbstractAccountAuthenticator.(I have wrote one and the github link:
(2)Root cause:
In android N, the intent in Bundle got from addAccount will be checked in AccountManagerService$Session's onResult by the method checkKeyIntent
protected void checkKeyIntent(
int authUid,
Intent intent) throws SecurityException {
long bid = Binder.clearCallingIdentity();
try {
PackageManager pm = mContext.getPackageManager();
ResolveInfo resolveInfo = pm.resolveActivityAsUser(intent, 0, mAccounts.userId);
ActivityInfo targetActivityInfo = resolveInfo.activityInfo;
int targetUid = targetActivityInfo.applicationInfo.uid;
if (PackageManager.SIGNATURE_MATCH != pm.checkSignatures(authUid, targetUid)) {
String pkgName = targetActivityInfo.packageName;
String activityName = targetActivityInfo.name;
String tmpl = "KEY_INTENT resolved to an Activity (%s) in a package (%s) that "
+ "does not share a signature with the supplying authenticator (%s).";
throw new SecurityException(
String.format(tmpl, activityName, pkgName, mAccountType));
}
} finally {
Binder.restoreCallingIdentity(bid);
}
}
Invalid intent will lead to an null ResolveInfo object and NPE in the next line,the exception will be caught in execTransact.
try {
res = onTransact(code, data, reply, flags);
} catch (RemoteException|RuntimeException e) {
if (LOG_RUNTIME_EXCEPTION) {
Log.w(TAG, "Caught a RuntimeException from the binder stub implementation.", e);
}
if ((flags & FLAG_ONEWAY) != 0) {
if (e instanceof RemoteException) {
Log.w(TAG, "Binder call failed.", e);
} else {
Log.w(TAG, "Caught a RuntimeException from the binder stub implementation.", e); // here
}
} else {
reply.setDataPosition(0);
reply.writeException(e);
}
res = true;
}
I find (flags & FLAG_ONEWAY)==1, so it will not reply to client. AccountManager$AmsTask$Response will hold AddAccountSettings all the time due to the callback mentioned in 65322371 which leads to the memory leak.