diff options
author | Svet Ganov <svetoslavganov@google.com> | 2015-07-15 11:04:18 -0700 |
---|---|---|
committer | Svet Ganov <svetoslavganov@google.com> | 2015-07-15 14:46:23 -0700 |
commit | 50a8bf4da0fe1685bfe6a0ecd9a9677e363e2ee1 (patch) | |
tree | e38f81b99dfdabbe87460489059735674bdf029e /services/core/java | |
parent | 46d1864ceee7229cd7fe7bac80226c930539861d (diff) | |
download | frameworks_base-50a8bf4da0fe1685bfe6a0ecd9a9677e363e2ee1.zip frameworks_base-50a8bf4da0fe1685bfe6a0ecd9a9677e363e2ee1.tar.gz frameworks_base-50a8bf4da0fe1685bfe6a0ecd9a9677e363e2ee1.tar.bz2 |
Grant default permissions to the setup app robustly.
There is a zoo of components that handle the home intent and
have different priority. There is no reliable way to distinguish
the setup app from the other apps that handle home as some of
them have lower priority than the setup app and some higher.
This change adds a dedicated category to recognize the default
setup app.
Uncommented the code that grants accounts permissions as the
get_accounts permission is now a runtime permission and can be
granted.
bug:22471024
bug:22501463
Change-Id: I41726751fa2567cbcd7d09c7acfa7615b8aba577
Diffstat (limited to 'services/core/java')
-rw-r--r-- | services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java | 22 | ||||
-rw-r--r-- | services/core/java/com/android/server/pm/PackageManagerService.java | 2 |
2 files changed, 9 insertions, 15 deletions
diff --git a/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java b/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java index e3c6037..7fde68f 100644 --- a/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java +++ b/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java @@ -29,7 +29,6 @@ import android.content.pm.ProviderInfo; import android.content.pm.ResolveInfo; import android.net.Uri; import android.os.Build; -import android.os.Debug; import android.os.UserHandle; import android.provider.CalendarContract; import android.provider.ContactsContract; @@ -120,12 +119,7 @@ final class DefaultPermissionGrantPolicy { private static final Set<String> ACCOUNTS_PERMISSIONS = new ArraySet<>(); static { - //ACCOUNTS_PERMISSIONS.add(Manifest.permission.GET_ACCOUNTS); - } - - private static final Set<String> SETTINGS_PERMISSIONS = new ArraySet<>(); - static { - SETTINGS_PERMISSIONS.add(Manifest.permission.WRITE_SETTINGS); + ACCOUNTS_PERMISSIONS.add(Manifest.permission.GET_ACCOUNTS); } private final PackageManagerService mService; @@ -161,7 +155,7 @@ final class DefaultPermissionGrantPolicy { mDialerAppPackagesProvider = provider; } - public void setSyncAdapterPackagesProviderrLPw(SyncAdapterPackagesProvider provider) { + public void setSyncAdapterPackagesProviderLPw(SyncAdapterPackagesProvider provider) { mSyncAdapterPackagesProvider = provider; } @@ -256,7 +250,7 @@ final class DefaultPermissionGrantPolicy { // SetupWizard Intent setupIntent = new Intent(Intent.ACTION_MAIN); - setupIntent.addCategory(Intent.CATEGORY_HOME); + setupIntent.addCategory(Intent.CATEGORY_SETUP_WIZARD); PackageParser.Package setupPackage = getDefaultSystemHandlerActivityPackageLPr( setupIntent, userId); if (setupPackage != null @@ -374,8 +368,7 @@ final class DefaultPermissionGrantPolicy { // Calendar provider sync adapters List<PackageParser.Package> calendarSyncAdapters = getHeadlessSyncAdapterPackagesLPr( - calendarSyncAdapterPackages, - userId); + calendarSyncAdapterPackages, userId); final int calendarSyncAdapterCount = calendarSyncAdapters.size(); for (int i = 0; i < calendarSyncAdapterCount; i++) { PackageParser.Package calendarSyncAdapter = calendarSyncAdapters.get(i); @@ -398,8 +391,7 @@ final class DefaultPermissionGrantPolicy { // Contacts provider sync adapters List<PackageParser.Package> contactsSyncAdapters = getHeadlessSyncAdapterPackagesLPr( - contactsSyncAdapterPackages, - userId); + contactsSyncAdapterPackages, userId); final int contactsSyncAdapterCount = contactsSyncAdapters.size(); for (int i = 0; i < contactsSyncAdapterCount; i++) { PackageParser.Package contactsSyncAdapter = contactsSyncAdapters.get(i); @@ -628,10 +620,12 @@ final class DefaultPermissionGrantPolicy { List<ResolveInfo> handlers = mService.mActivities.queryIntent(intent, intent.resolveType(mService.mContext.getContentResolver()), PackageManager.GET_DISABLED_COMPONENTS, userId); + if (handlers == null) { + return null; + } final int handlerCount = handlers.size(); for (int i = 0; i < handlerCount; i++) { ResolveInfo handler = handlers.get(i); - // TODO: This is a temporary hack to figure out the setup app. PackageParser.Package handlerPackage = getSystemPackageLPr( handler.activityInfo.packageName); if (handlerPackage != null) { diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index ef9bc8b..4b2c1ff 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -16407,7 +16407,7 @@ public class PackageManagerService extends IPackageManager.Stub { @Override public void setSyncAdapterPackagesprovider(SyncAdapterPackagesProvider provider) { synchronized (mPackages) { - mDefaultPermissionPolicy.setSyncAdapterPackagesProviderrLPw(provider); + mDefaultPermissionPolicy.setSyncAdapterPackagesProviderLPw(provider); } } |