Merge "Take into account default app for default grants"
This commit is contained in:
@@ -20,6 +20,7 @@ import android.Manifest;
|
||||
import android.app.DownloadManager;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManagerInternal.PackagesProvider;
|
||||
@@ -585,7 +586,6 @@ final class DefaultPermissionGrantPolicy {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void grantDefaultPermissionsToDefaultSystemSmsAppLPr(
|
||||
PackageParser.Package smsPackage, int userId) {
|
||||
if (doesPackageSupportRuntimePermissions(smsPackage)) {
|
||||
@@ -595,7 +595,6 @@ final class DefaultPermissionGrantPolicy {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void grantDefaultPermissionsToDefaultSmsAppLPr(String packageName, int userId) {
|
||||
Log.i(TAG, "Granting permissions to default sms app for user:" + userId);
|
||||
if (packageName == null) {
|
||||
@@ -673,29 +672,23 @@ final class DefaultPermissionGrantPolicy {
|
||||
|
||||
private PackageParser.Package getDefaultSystemHandlerActivityPackageLPr(
|
||||
Intent intent, int userId) {
|
||||
List<ResolveInfo> handlers = mService.mActivities.queryIntent(intent,
|
||||
intent.resolveType(mService.mContext.getContentResolver()),
|
||||
PackageManager.GET_DISABLED_COMPONENTS, userId);
|
||||
if (handlers == null) {
|
||||
ResolveInfo handler = mService.resolveIntent(intent,
|
||||
intent.resolveType(mService.mContext.getContentResolver()), 0, userId);
|
||||
if (handler == null || handler.activityInfo == null) {
|
||||
return null;
|
||||
}
|
||||
final int handlerCount = handlers.size();
|
||||
for (int i = 0; i < handlerCount; i++) {
|
||||
ResolveInfo handler = handlers.get(i);
|
||||
PackageParser.Package handlerPackage = getSystemPackageLPr(
|
||||
handler.activityInfo.packageName);
|
||||
if (handlerPackage != null) {
|
||||
return handlerPackage;
|
||||
}
|
||||
ActivityInfo activityInfo = handler.activityInfo;
|
||||
if (activityInfo.packageName.equals(mService.mResolveActivity.packageName)
|
||||
&& activityInfo.name.equals(mService.mResolveActivity.name)) {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
return getSystemPackageLPr(handler.activityInfo.packageName);
|
||||
}
|
||||
|
||||
private PackageParser.Package getDefaultSystemHandlerServicePackageLPr(
|
||||
Intent intent, int userId) {
|
||||
List<ResolveInfo> handlers = mService.queryIntentServices(intent,
|
||||
intent.resolveType(mService.mContext.getContentResolver()),
|
||||
PackageManager.GET_DISABLED_COMPONENTS, userId);
|
||||
intent.resolveType(mService.mContext.getContentResolver()), 0, userId);
|
||||
if (handlers == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -721,10 +714,9 @@ final class DefaultPermissionGrantPolicy {
|
||||
for (String syncAdapterPackageName : syncAdapterPackageNames) {
|
||||
homeIntent.setPackage(syncAdapterPackageName);
|
||||
|
||||
List<ResolveInfo> homeActivities = mService.mActivities.queryIntent(homeIntent,
|
||||
homeIntent.resolveType(mService.mContext.getContentResolver()),
|
||||
PackageManager.GET_DISABLED_COMPONENTS, userId);
|
||||
if (!homeActivities.isEmpty()) {
|
||||
ResolveInfo homeActivity = mService.resolveIntent(homeIntent,
|
||||
homeIntent.resolveType(mService.mContext.getContentResolver()), 0, userId);
|
||||
if (homeActivity != null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user