packages/apps/Settings
修訂 | 4af8f912aa1ee714638d0f9694d6f856bc8166f3 (tree) |
---|---|
時間 | 2017-05-25 06:52:38 |
作者 | Dmitry Dementyev <dementyev@goog...> |
Commiter | android-build-team Robot |
resolve merge conflicts of 3964c51bf2 to nyc-dev
Bug: 33123882
Test: manual tests
Merged-In: If68343d155364654fa7db55ace3fb3c4db508c7e
Change-Id: I17ceca883819a161c4eab2a414abf0b64c320378
(cherry picked from commit 0f04a5a93f846d6f2d528ab6ae0c9e37d701e438)
@@ -36,6 +36,7 @@ import android.os.Bundle; | ||
36 | 36 | import android.os.UserHandle; |
37 | 37 | import android.support.v7.preference.Preference; |
38 | 38 | import android.support.v7.preference.Preference.OnPreferenceClickListener; |
39 | +import android.support.v7.preference.PreferenceGroup; | |
39 | 40 | import android.support.v7.preference.PreferenceScreen; |
40 | 41 | import android.util.Log; |
41 | 42 | import android.view.LayoutInflater; |
@@ -83,7 +84,7 @@ public class ManageAccountsSettings extends AccountPreferenceBase | ||
83 | 84 | |
84 | 85 | // If an account type is set, then show only accounts of that type |
85 | 86 | private String mAccountType; |
86 | - // Temporary hack, to deal with backward compatibility | |
87 | + // Temporary hack, to deal with backward compatibility | |
87 | 88 | // mFirstAccount is used for the injected preferences |
88 | 89 | private Account mFirstAccount; |
89 | 90 |
@@ -440,15 +441,18 @@ public class ManageAccountsSettings extends AccountPreferenceBase | ||
440 | 441 | } |
441 | 442 | |
442 | 443 | /** |
443 | - * Filters through the preference list provided by GoogleLoginService. | |
444 | + * Recursively filters through the preference list provided by GoogleLoginService. | |
444 | 445 | * |
445 | 446 | * This method removes all the invalid intent from the list, adds account name as extra into the |
446 | 447 | * intent, and hack the location settings to start it as a fragment. |
447 | 448 | */ |
448 | - private void updatePreferenceIntents(PreferenceScreen prefs) { | |
449 | + private void updatePreferenceIntents(PreferenceGroup prefs) { | |
449 | 450 | final PackageManager pm = getActivity().getPackageManager(); |
450 | 451 | for (int i = 0; i < prefs.getPreferenceCount();) { |
451 | 452 | Preference pref = prefs.getPreference(i); |
453 | + if (pref instanceof PreferenceGroup) { | |
454 | + updatePreferenceIntents((PreferenceGroup) pref); | |
455 | + } | |
452 | 456 | Intent intent = pref.getIntent(); |
453 | 457 | if (intent != null) { |
454 | 458 | // Hack. Launch "Location" as fragment instead of as activity. |
@@ -497,8 +501,8 @@ public class ManageAccountsSettings extends AccountPreferenceBase | ||
497 | 501 | } else { |
498 | 502 | Log.e(TAG, |
499 | 503 | "Refusing to launch authenticator intent because" |
500 | - + "it exploits Settings permissions: " | |
501 | - + prefIntent); | |
504 | + + " it exploits Settings permissions: " | |
505 | + + prefIntent); | |
502 | 506 | } |
503 | 507 | return true; |
504 | 508 | } |
@@ -518,20 +522,26 @@ public class ManageAccountsSettings extends AccountPreferenceBase | ||
518 | 522 | private boolean isSafeIntent(PackageManager pm, Intent intent) { |
519 | 523 | AuthenticatorDescription authDesc = |
520 | 524 | mAuthenticatorHelper.getAccountTypeDescription(mAccountType); |
521 | - ResolveInfo resolveInfo = pm.resolveActivity(intent, 0); | |
525 | + ResolveInfo resolveInfo = | |
526 | + pm.resolveActivityAsUser(intent, 0, mUserHandle.getIdentifier()); | |
522 | 527 | if (resolveInfo == null) { |
523 | 528 | return false; |
524 | 529 | } |
525 | 530 | ActivityInfo resolvedActivityInfo = resolveInfo.activityInfo; |
526 | 531 | ApplicationInfo resolvedAppInfo = resolvedActivityInfo.applicationInfo; |
527 | 532 | try { |
533 | + if (resolvedActivityInfo.exported) { | |
534 | + if (resolvedActivityInfo.permission == null) { | |
535 | + return true; // exported activity without permission. | |
536 | + } else if (pm.checkPermission(resolvedActivityInfo.permission, | |
537 | + authDesc.packageName) == PackageManager.PERMISSION_GRANTED) { | |
538 | + return true; | |
539 | + } | |
540 | + } | |
528 | 541 | ApplicationInfo authenticatorAppInf = pm.getApplicationInfo(authDesc.packageName, 0); |
529 | - return resolvedActivityInfo.exported | |
530 | - || resolvedAppInfo.uid == authenticatorAppInf.uid; | |
542 | + return resolvedAppInfo.uid == authenticatorAppInf.uid; | |
531 | 543 | } catch (NameNotFoundException e) { |
532 | - Log.e(TAG, | |
533 | - "Intent considered unsafe due to exception.", | |
534 | - e); | |
544 | + Log.e(TAG, "Intent considered unsafe due to exception.", e); | |
535 | 545 | return false; |
536 | 546 | } |
537 | 547 | } |