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
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 4f7380a..59f56ff 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -82,7 +82,6 @@
import android.content.Intent;
import android.content.IntentSender;
import android.content.SharedPreferences;
-import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Color;
@@ -92,7 +91,6 @@
import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.Parcelable;
-import android.os.Process;
import android.os.StrictMode;
import android.os.SystemClock;
import android.os.Trace;
@@ -115,7 +113,6 @@
import android.view.WindowManager.LayoutParams;
import android.view.accessibility.AccessibilityEvent;
import android.view.animation.OvershootInterpolator;
-import android.widget.Toast;
import android.window.BackEvent;
import android.window.OnBackAnimationCallback;
@@ -160,7 +157,6 @@
import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.model.BgDataModel.Callbacks;
import com.android.launcher3.model.ItemInstallQueue;
-import com.android.launcher3.model.ModelUtils;
import com.android.launcher3.model.ModelWriter;
import com.android.launcher3.model.StringCache;
import com.android.launcher3.model.WidgetsModel;
@@ -192,7 +188,6 @@
import com.android.launcher3.util.IntArray;
import com.android.launcher3.util.IntSet;
import com.android.launcher3.util.OnboardingPrefs;
-import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.util.PackageUserKey;
import com.android.launcher3.util.PendingRequestArgs;
import com.android.launcher3.util.RunnableList;
@@ -263,8 +258,6 @@
public static final int REQUEST_BIND_PENDING_APPWIDGET = 12;
public static final int REQUEST_RECONFIGURE_APPWIDGET = 13;
- private static final int REQUEST_PERMISSION_CALL_PHONE = 14;
-
private static final float BOUNCE_ANIMATION_TENSION = 1.3f;
/**
@@ -975,33 +968,6 @@
handleActivityResult(requestCode, resultCode, data);
}
- @Override
- public void onRequestPermissionsResult(int requestCode, String[] permissions,
- int[] grantResults) {
- PendingRequestArgs pendingArgs = mPendingRequestArgs;
- if (requestCode == REQUEST_PERMISSION_CALL_PHONE && pendingArgs != null
- && pendingArgs.getRequestCode() == REQUEST_PERMISSION_CALL_PHONE) {
- setWaitingForResult(null);
-
- View v = null;
- CellPos cellPos = getCellPosMapper().mapModelToPresenter(pendingArgs);
- CellLayout layout = getCellLayout(pendingArgs.container, cellPos.screenId);
- if (layout != null) {
- v = layout.getChildAt(cellPos.cellX, cellPos.cellY);
- }
- Intent intent = pendingArgs.getPendingIntent();
-
- if (grantResults.length > 0
- && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
- startActivitySafely(v, intent, null);
- } else {
- // TODO: Show a snack bar with link to settings
- Toast.makeText(this, getString(R.string.msg_no_phone_permission,
- getString(R.string.derived_app_name)), Toast.LENGTH_SHORT).show();
- }
- }
- }
-
/**
* Check to see if a given screen id exists. If not, create it at the end, return the new id.
*
@@ -1417,21 +1383,9 @@
WorkspaceItemInfo info = PinRequestHelper.createWorkspaceItemFromPinItemRequest(
this, PinRequestHelper.getPinItemRequest(data), 0);
-
if (info == null) {
- // Legacy shortcuts are only supported for primary profile.
- info = Process.myUserHandle().equals(args.user)
- ? ModelUtils.fromLegacyShortcutIntent(this, data) : null;
-
- if (info == null) {
- Log.e(TAG, "Unable to parse a valid custom shortcut result");
- return;
- } else if (!new PackageManagerHelper(this).hasPermissionForActivity(
- info.intent, args.getPendingIntent().getComponent().getPackageName())) {
- // The app is trying to add a shortcut without sufficient permissions
- Log.e(TAG, "Ignoring malicious intent " + info.intent.toUri(0));
- return;
- }
+ Log.e(TAG, "Unable to parse a valid shortcut result");
+ return;
}
if (container < 0) {
@@ -2151,27 +2105,6 @@
}
}
- @TargetApi(Build.VERSION_CODES.M)
- @Override
- public boolean onErrorStartingShortcut(Intent intent, ItemInfo info) {
- // Due to legacy reasons, direct call shortcuts require Launchers to have the
- // corresponding permission. Show the appropriate permission prompt if that
- // is the case.
- if (intent.getComponent() == null
- && Intent.ACTION_CALL.equals(intent.getAction())
- && checkSelfPermission(android.Manifest.permission.CALL_PHONE) !=
- PackageManager.PERMISSION_GRANTED) {
-
- setWaitingForResult(PendingRequestArgs
- .forIntent(REQUEST_PERMISSION_CALL_PHONE, intent, info));
- requestPermissions(new String[]{android.Manifest.permission.CALL_PHONE},
- REQUEST_PERMISSION_CALL_PHONE);
- return true;
- } else {
- return false;
- }
- }
-
@Override
public boolean startActivitySafely(View v, Intent intent, ItemInfo item) {
if (!hasBeenResumed()) {