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

Commit 658c5daf authored by Yogisha Dixit's avatar Yogisha Dixit
Browse files

Log widgets source.

Test: manual
(1) Upgrading to new DB version is successful (no errors thrown in logcat)
(2) Widgets that were added with the old DB version have CONTAINER_UNKNOWN as their source container
(3) Widgets that are added with the new DB version still log source container after reboot
Bug: 185778648
Change-Id: Iaa38f0be6bc4cb0d29842f9a2ea0d08de000c930
parent 814d644d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -141,6 +141,9 @@ enum Attribute {
  ALL_APPS_SEARCH_RESULT_NAVVYSITE = 25;
  ALL_APPS_SEARCH_RESULT_TIPS = 26;
  ALL_APPS_SEARCH_RESULT_PEOPLE_TILE = 27;

  WIDGETS_BOTTOM_TRAY = 28;
  WIDGETS_TRAY_PREDICTION = 29;
}

// Main app icons
+8 −2
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
 */
package com.android.launcher3.model;

import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_WIDGETS_PREDICTION;

import android.app.prediction.AppTarget;
import android.content.ComponentName;
import android.text.TextUtils;
@@ -73,7 +75,9 @@ public final class WidgetsPredictionUpdateTask extends BaseModelUpdateTask {
                    if (notAddedWidgets.size() > 0) {
                        // Even an apps have more than one widgets, we only include one widget.
                        fixedContainerItems.items.add(
                                new PendingAddWidgetInfo(notAddedWidgets.get(0).widgetInfo));
                                new PendingAddWidgetInfo(
                                        notAddedWidgets.get(0).widgetInfo,
                                        CONTAINER_WIDGETS_PREDICTION));
                    }
                }
            }
@@ -90,7 +94,9 @@ public final class WidgetsPredictionUpdateTask extends BaseModelUpdateTask {
                        new ComponentName(app.getPackageName(), app.getClassName()), app.getUser());
                if (widgetItems.containsKey(targetWidget)) {
                    fixedContainerItems.items.add(
                            new PendingAddWidgetInfo(widgetItems.get(targetWidget).widgetInfo));
                            new PendingAddWidgetInfo(widgetItems.get(
                                    targetWidget).widgetInfo,
                                    CONTAINER_WIDGETS_PREDICTION));
                }
            }
        }
+7 −1
Original line number Diff line number Diff line
@@ -2,8 +2,14 @@
  // Note: Comments are not supported in JSON schema, but android parser is lenient.

  // Maximum DB version supported by this schema
  "version" : 28,
  "version" : 29,

  "downgrade_to_28" : [
    "ALTER TABLE favorites RENAME TO temp_favorites;",
    "CREATE TABLE favorites(_id INTEGER PRIMARY KEY, title TEXT, intent TEXT, container INTEGER, screen INTEGER, cellX INTEGER, cellY INTEGER, spanX INTEGER, spanY INTEGER, itemType INTEGER, appWidgetId INTEGER NOT NULL DEFAULT - 1, iconPackage TEXT, iconResource TEXT, icon BLOB, appWidgetProvider TEXT, modified INTEGER NOT NULL DEFAULT 0, restored INTEGER NOT NULL DEFAULT 0, profileId INTEGER DEFAULT 0, rank INTEGER NOT NULL DEFAULT 0, options INTEGER NOT NULL DEFAULT 0);",
    "INSERT INTO favorites SELECT _id, title, intent, container, screen, cellX, cellY, spanX, spanY, itemType, appWidgetId, iconPackage, iconResource, icon, appWidgetProvider, modified, restored, profileId, rank, options FROM temp_favorites;",
    "DROP TABLE temp_favorites;"
  ],
  "downgrade_to_27" : [
    "CREATE TABLE workspaceScreens (_id INTEGER PRIMARY KEY,screenRank INTEGER,modified INTEGER NOT NULL DEFAULT 0)",
    "insert into workspaceScreens (_id, screenRank) select screen as _id, screen as screenRank from favorites where container = -100 group by screen order by screen"
+8 −1
Original line number Diff line number Diff line
@@ -1339,6 +1339,12 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
        launcherInfo.minSpanX = itemInfo.minSpanX;
        launcherInfo.minSpanY = itemInfo.minSpanY;
        launcherInfo.user = appWidgetInfo.getProfile();
        if (itemInfo instanceof PendingAddWidgetInfo) {
            launcherInfo.sourceContainer = ((PendingAddWidgetInfo) itemInfo).sourceContainer;
        } else if (itemInfo instanceof PendingRequestArgs) {
            launcherInfo.sourceContainer =
                    ((PendingRequestArgs) itemInfo).getWidgetSourceContainer();
        }

        getModelWriter().addItemToDatabase(launcherInfo,
                itemInfo.container, itemInfo.screenId, itemInfo.cellX, itemInfo.cellY);
@@ -2416,7 +2422,8 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche

                        // Also try to bind the widget. If the bind fails, the user will be shown
                        // a click to setup UI, which will ask for the bind permission.
                        PendingAddWidgetInfo pendingInfo = new PendingAddWidgetInfo(appWidgetInfo);
                        PendingAddWidgetInfo pendingInfo =
                                new PendingAddWidgetInfo(appWidgetInfo, item.sourceContainer);
                        pendingInfo.spanX = item.spanX;
                        pendingInfo.spanY = item.spanY;
                        pendingInfo.minSpanX = item.minSpanX;
+12 −2
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.logging.FileLog;
import com.android.launcher3.model.DbDowngradeHelper;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.pm.UserCache;
import com.android.launcher3.provider.LauncherDbUtils;
import com.android.launcher3.provider.LauncherDbUtils.SQLiteTransaction;
@@ -98,7 +99,7 @@ public class LauncherProvider extends ContentProvider {
     * 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 = 28;
    public static final int SCHEMA_VERSION = 29;

    public static final String AUTHORITY = BuildConfig.APPLICATION_ID + ".settings";
    public static final String KEY_LAYOUT_PROVIDER_AUTHORITY = "KEY_LAYOUT_PROVIDER_AUTHORITY";
@@ -879,10 +880,19 @@ public class LauncherProvider extends ContentProvider {
                    }
                    dropTable(db, "workspaceScreens");
                }
                case 28:
                case 28: {
                    boolean columnAdded = addIntegerColumn(
                            db, Favorites.APPWIDGET_SOURCE, Favorites.CONTAINER_UNKNOWN);
                    if (!columnAdded) {
                        // Old version remains, which means we wipe old data
                        break;
                    }
                }
                case 29: {
                    // DB Upgraded successfully
                    return;
                }
            }

            // DB was not upgraded
            Log.w(TAG, "Destroying all old data.");
Loading