Removing support for adding legacy shortcuts.
All existing legacy shortcuts will be migrated one-time to deep shortcuts This shortcuts are pinned under the Launcher package, with custom badging Bug: 275875209 Test: Updated unit tests Flag: N/A Change-Id: I7da001f724776ad8d6c807517b7e4e259de626c2
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.android.launcher3.util;
|
||||
|
||||
import android.app.AppOpsManager;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
@@ -30,7 +29,6 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.graphics.Rect;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.text.TextUtils;
|
||||
@@ -139,48 +137,6 @@ public class PackageManagerHelper {
|
||||
return (info.flags & ApplicationInfo.FLAG_SUSPENDED) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if {@param srcPackage} has the permission required to start the activity from
|
||||
* {@param intent}. If {@param srcPackage} is null, then the activity should not need
|
||||
* any permissions
|
||||
*/
|
||||
public boolean hasPermissionForActivity(Intent intent, String srcPackage) {
|
||||
ResolveInfo target = mPm.resolveActivity(intent, 0);
|
||||
if (target == null) {
|
||||
// Not a valid target
|
||||
return false;
|
||||
}
|
||||
if (TextUtils.isEmpty(target.activityInfo.permission)) {
|
||||
// No permission is needed
|
||||
return true;
|
||||
}
|
||||
if (TextUtils.isEmpty(srcPackage)) {
|
||||
// The activity requires some permission but there is no source.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Source does not have sufficient permissions.
|
||||
if(mPm.checkPermission(target.activityInfo.permission, srcPackage) !=
|
||||
PackageManager.PERMISSION_GRANTED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// On M and above also check AppOpsManager for compatibility mode permissions.
|
||||
if (TextUtils.isEmpty(AppOpsManager.permissionToOp(target.activityInfo.permission))) {
|
||||
// There is no app-op for this permission, which could have been disabled.
|
||||
return true;
|
||||
}
|
||||
|
||||
// There is no direct way to check if the app-op is allowed for a particular app. Since
|
||||
// app-op is only enabled for apps running in compatibility mode, simply block such apps.
|
||||
|
||||
try {
|
||||
return mPm.getApplicationInfo(srcPackage, 0).targetSdkVersion >= Build.VERSION_CODES.M;
|
||||
} catch (NameNotFoundException e) { }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public Intent getMarketIntent(String packageName) {
|
||||
return new Intent(Intent.ACTION_VIEW)
|
||||
.setData(new Uri.Builder()
|
||||
|
||||
Reference in New Issue
Block a user