Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f8e0e727 authored by Sunny Goyal's avatar Sunny Goyal Committed by Android (Google) Code Review
Browse files

Merge "Removing support for adding legacy shortcuts." into udc-dev

parents 433d215c 84b48d8d
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -2,8 +2,11 @@
  // Note: Comments are not supported in JSON schema, but android parser is lenient.

  // Maximum DB version supported by this schema
  "version" : 31,

  "version" : 32,
  "downgrade_to_31" : [
    "ALTER TABLE favorites ADD COLUMN iconPackage TEXT;",
    "ALTER TABLE favorites ADD COLUMN iconResource TEXT;"
  ],
  "downgrade_to_30" : [],
  "downgrade_to_29" : [],
  "downgrade_to_28" : [
+0 −3
Original line number Diff line number Diff line
@@ -192,9 +192,6 @@
    <string name="permdesc_write_settings">Allows the app to change the settings and
        shortcuts in home.</string>

    <!-- Toast shown on clicking a direct call shortcut. [CHAR_LIMIT=80] -->
    <string name="msg_no_phone_permission"><xliff:g id="app_name" example="Launcher3">%1$s</xliff:g> is not allowed to make phone calls</string>

    <!-- Widgets: -->
    <skip />

+2 −69
Original line number Diff line number Diff line
@@ -82,7 +82,6 @@ import android.content.Context;
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.Build;
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.ViewTreeObserver.OnPreDrawListener;
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.InstanceIdSequence;
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.ComponentKey;
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 class Launcher extends StatefulActivity<LauncherState>
    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 @@ public class Launcher extends StatefulActivity<LauncherState>
        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,22 +1383,10 @@ public class Launcher extends StatefulActivity<LauncherState>

        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));
            Log.e(TAG, "Unable to parse a valid shortcut result");
            return;
        }
        }

        if (container < 0) {
            // Adding a shortcut to the Workspace.
@@ -2151,27 +2105,6 @@ public class Launcher extends StatefulActivity<LauncherState>
        }
    }

    @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()) {
+0 −14
Original line number Diff line number Diff line
@@ -130,18 +130,6 @@ public class LauncherSettings {
         */
        public static final int ITEM_TYPE_SEARCH_ACTION = 9;

        /**
         * The icon package name in Intent.ShortcutIconResource
         * <P>Type: TEXT</P>
         */
        public static final String ICON_PACKAGE = "iconPackage";

        /**
         * The icon resource name in Intent.ShortcutIconResource
         * <P>Type: TEXT</P>
         */
        public static final String ICON_RESOURCE = "iconResource";

        /**
         * The custom icon bitmap.
         * <P>Type: BLOB</P>
@@ -357,8 +345,6 @@ public class LauncherSettings {
                    "spanY INTEGER," +
                    "itemType INTEGER," +
                    "appWidgetId INTEGER NOT NULL DEFAULT -1," +
                    "iconPackage TEXT," +
                    "iconResource TEXT," +
                    "icon BLOB," +
                    "appWidgetProvider TEXT," +
                    "modified INTEGER NOT NULL DEFAULT 0," +
+5 −1
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ public class DatabaseHelper extends NoLocaleSQLiteHelper implements
     * Represents the schema of the database. Changes in scheme need not be backwards compatible.
     * When increasing the scheme version, ensure that downgrade_schema.json is updated
     */
    public static final int SCHEMA_VERSION = 31;
    public static final int SCHEMA_VERSION = 32;
    private static final String TAG = "DatabaseHelper";
    private static final boolean LOGD = false;

@@ -327,6 +327,10 @@ public class DatabaseHelper extends NoLocaleSQLiteHelper implements
                return;
            }
            case 31: {
                LauncherDbUtils.migrateLegacyShortcuts(mContext, db);
            }
            // Fall through
            case 32: {
                // DB Upgraded successfully
                return;
            }
Loading