resolve merge conflicts of 75ae46d035
to lmp-mr1-dev
Change-Id: Ib80d006bbd7b76396b4941e001f5c69fb7b643fa Bug: 33123882 Test: manual tests:
This commit is contained in:
@@ -36,6 +36,7 @@ import android.os.Bundle;
|
|||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.Preference.OnPreferenceClickListener;
|
import android.preference.Preference.OnPreferenceClickListener;
|
||||||
|
import android.preference.PreferenceGroup;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -432,15 +433,18 @@ public class ManageAccountsSettings extends AccountPreferenceBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters through the preference list provided by GoogleLoginService.
|
* Recursively filters through the preference list provided by GoogleLoginService.
|
||||||
*
|
*
|
||||||
* This method removes all the invalid intent from the list, adds account name as extra into the
|
* This method removes all the invalid intent from the list, adds account name as extra into the
|
||||||
* intent, and hack the location settings to start it as a fragment.
|
* intent, and hack the location settings to start it as a fragment.
|
||||||
*/
|
*/
|
||||||
private void updatePreferenceIntents(PreferenceScreen prefs) {
|
private void updatePreferenceIntents(PreferenceGroup prefs) {
|
||||||
final PackageManager pm = getActivity().getPackageManager();
|
final PackageManager pm = getActivity().getPackageManager();
|
||||||
for (int i = 0; i < prefs.getPreferenceCount();) {
|
for (int i = 0; i < prefs.getPreferenceCount();) {
|
||||||
Preference pref = prefs.getPreference(i);
|
Preference pref = prefs.getPreference(i);
|
||||||
|
if (pref instanceof PreferenceGroup) {
|
||||||
|
updatePreferenceIntents((PreferenceGroup) pref);
|
||||||
|
}
|
||||||
Intent intent = pref.getIntent();
|
Intent intent = pref.getIntent();
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
// Hack. Launch "Location" as fragment instead of as activity.
|
// Hack. Launch "Location" as fragment instead of as activity.
|
||||||
@@ -489,8 +493,8 @@ public class ManageAccountsSettings extends AccountPreferenceBase
|
|||||||
} else {
|
} else {
|
||||||
Log.e(TAG,
|
Log.e(TAG,
|
||||||
"Refusing to launch authenticator intent because"
|
"Refusing to launch authenticator intent because"
|
||||||
+ "it exploits Settings permissions: "
|
+ " it exploits Settings permissions: "
|
||||||
+ prefIntent);
|
+ prefIntent);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -510,20 +514,26 @@ public class ManageAccountsSettings extends AccountPreferenceBase
|
|||||||
private boolean isSafeIntent(PackageManager pm, Intent intent) {
|
private boolean isSafeIntent(PackageManager pm, Intent intent) {
|
||||||
AuthenticatorDescription authDesc =
|
AuthenticatorDescription authDesc =
|
||||||
mAuthenticatorHelper.getAccountTypeDescription(mAccountType);
|
mAuthenticatorHelper.getAccountTypeDescription(mAccountType);
|
||||||
ResolveInfo resolveInfo = pm.resolveActivity(intent, 0);
|
ResolveInfo resolveInfo =
|
||||||
|
pm.resolveActivityAsUser(intent, 0, mUserHandle.getIdentifier());
|
||||||
if (resolveInfo == null) {
|
if (resolveInfo == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ActivityInfo resolvedActivityInfo = resolveInfo.activityInfo;
|
ActivityInfo resolvedActivityInfo = resolveInfo.activityInfo;
|
||||||
ApplicationInfo resolvedAppInfo = resolvedActivityInfo.applicationInfo;
|
ApplicationInfo resolvedAppInfo = resolvedActivityInfo.applicationInfo;
|
||||||
try {
|
try {
|
||||||
|
if (resolvedActivityInfo.exported) {
|
||||||
|
if (resolvedActivityInfo.permission == null) {
|
||||||
|
return true; // exported activity without permission.
|
||||||
|
} else if (pm.checkPermission(resolvedActivityInfo.permission,
|
||||||
|
authDesc.packageName) == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
ApplicationInfo authenticatorAppInf = pm.getApplicationInfo(authDesc.packageName, 0);
|
ApplicationInfo authenticatorAppInf = pm.getApplicationInfo(authDesc.packageName, 0);
|
||||||
return resolvedActivityInfo.exported
|
return resolvedAppInfo.uid == authenticatorAppInf.uid;
|
||||||
|| resolvedAppInfo.uid == authenticatorAppInf.uid;
|
|
||||||
} catch (NameNotFoundException e) {
|
} catch (NameNotFoundException e) {
|
||||||
Log.e(TAG,
|
Log.e(TAG, "Intent considered unsafe due to exception.", e);
|
||||||
"Intent considered unsafe due to exception.",
|
|
||||||
e);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user