Merge "Merging from ub-launcher3-rvc-dev @ build 6621659" into rvc-dev am: 738b1af342 am: f7897465e3
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/11975976 Change-Id: I795eccf1029827847fbec7ec3599649713aad372
This commit is contained in:
@@ -18,9 +18,12 @@ package com.android.launcher3.testing;
|
||||
|
||||
import static android.graphics.Bitmap.Config.ARGB_8888;
|
||||
|
||||
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.os.Binder;
|
||||
import android.os.Bundle;
|
||||
import android.os.Debug;
|
||||
import android.system.Os;
|
||||
@@ -28,6 +31,9 @@ import android.view.View;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.LauncherSettings;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
@@ -165,6 +171,19 @@ public class DebugTestInformationHandler extends TestInformationHandler {
|
||||
return response;
|
||||
}
|
||||
|
||||
case TestProtocol.REQUEST_CLEAR_DATA: {
|
||||
final long identity = Binder.clearCallingIdentity();
|
||||
try {
|
||||
LauncherSettings.Settings.call(mContext.getContentResolver(),
|
||||
LauncherSettings.Settings.METHOD_CREATE_EMPTY_DB);
|
||||
MAIN_EXECUTOR.submit(() ->
|
||||
LauncherAppState.getInstance(mContext).getModel().forceReload());
|
||||
return response;
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(identity);
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
return super.call(method);
|
||||
}
|
||||
|
||||
@@ -71,6 +71,15 @@ message PredictionContainer {
|
||||
|
||||
// Represents the apps container within search results.
|
||||
message SearchResultContainer {
|
||||
|
||||
// Length of search term.
|
||||
optional int32 query_length = 1;
|
||||
|
||||
// Container from where search was invoked.
|
||||
oneof ParentContainer {
|
||||
WorkspaceContainer workspace = 2;
|
||||
AllAppsContainer all_apps_container = 3;
|
||||
}
|
||||
}
|
||||
|
||||
// Container for package specific shortcuts to deep links and notifications.
|
||||
|
||||
@@ -90,6 +90,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:text="@string/hotseat_edu_dismiss"
|
||||
android:layout_gravity="start|center_vertical"
|
||||
android:textColor="@android:color/white"/>
|
||||
</FrameLayout>
|
||||
<FrameLayout
|
||||
@@ -102,7 +103,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="end"
|
||||
android:layout_gravity="end|center_vertical"
|
||||
android:text="@string/hotseat_edu_accept"
|
||||
android:textColor="@android:color/white"/>
|
||||
</FrameLayout>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.android.quickstep.logging;
|
||||
|
||||
import static com.android.launcher3.logger.LauncherAtom.ContainerInfo.ContainerCase.FOLDER;
|
||||
import static com.android.launcher3.logger.LauncherAtom.ContainerInfo.ContainerCase.PREDICTED_HOTSEAT_CONTAINER;
|
||||
import static com.android.launcher3.logger.LauncherAtom.ContainerInfo.ContainerCase.SEARCH_RESULT_CONTAINER;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WORKSPACE_SNAPSHOT;
|
||||
import static com.android.systemui.shared.system.SysUiStatsLog.LAUNCHER_UICHANGED__DST_STATE__ALLAPPS;
|
||||
import static com.android.systemui.shared.system.SysUiStatsLog.LAUNCHER_UICHANGED__DST_STATE__BACKGROUND;
|
||||
@@ -75,6 +75,7 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||
// from nano to lite, bake constant to prevent robo test failure.
|
||||
private static final int DEFAULT_PAGE_INDEX = -2;
|
||||
private static final int FOLDER_HIERARCHY_OFFSET = 100;
|
||||
private static final int SEARCH_RESULT_HIERARCHY_OFFSET = 200;
|
||||
|
||||
public StatsLogCompatManager(Context context) {
|
||||
sContext = context;
|
||||
@@ -156,10 +157,10 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||
getComponentName(info) /* component_name */,
|
||||
getGridX(info, false) /* grid_x */,
|
||||
getGridY(info, false) /* grid_y */,
|
||||
getPageId(info, false) /* page_id */,
|
||||
getPageId(info) /* page_id */,
|
||||
getGridX(info, true) /* grid_x_parent */,
|
||||
getGridY(info, true) /* grid_y_parent */,
|
||||
getPageId(info, true) /* page_id_parent */,
|
||||
getParentPageId(info) /* page_id_parent */,
|
||||
getHierarchy(info) /* hierarchy */,
|
||||
info.getIsWork() /* is_work_profile */,
|
||||
info.getAttribute().getNumber() /* origin */,
|
||||
@@ -321,10 +322,10 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||
getComponentName(atomInfo) /* component_name */,
|
||||
getGridX(atomInfo, false) /* grid_x */,
|
||||
getGridY(atomInfo, false) /* grid_y */,
|
||||
getPageId(atomInfo, false) /* page_id */,
|
||||
getPageId(atomInfo) /* page_id */,
|
||||
getGridX(atomInfo, true) /* grid_x_parent */,
|
||||
getGridY(atomInfo, true) /* grid_y_parent */,
|
||||
getPageId(atomInfo, true) /* page_id_parent */,
|
||||
getParentPageId(atomInfo) /* page_id_parent */,
|
||||
getHierarchy(atomInfo) /* hierarchy */,
|
||||
atomInfo.getIsWork() /* is_work_profile */,
|
||||
atomInfo.getRank() /* rank */,
|
||||
@@ -336,9 +337,14 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||
}
|
||||
|
||||
private static int getCardinality(LauncherAtom.ItemInfo info) {
|
||||
return info.getContainerInfo().getContainerCase().equals(PREDICTED_HOTSEAT_CONTAINER)
|
||||
? info.getContainerInfo().getPredictedHotseatContainer().getCardinality()
|
||||
: info.getFolderIcon().getCardinality();
|
||||
switch (info.getContainerInfo().getContainerCase()){
|
||||
case PREDICTED_HOTSEAT_CONTAINER:
|
||||
return info.getContainerInfo().getPredictedHotseatContainer().getCardinality();
|
||||
case SEARCH_RESULT_CONTAINER:
|
||||
return info.getContainerInfo().getSearchResultContainer().getQueryLength();
|
||||
default:
|
||||
return info.getFolderIcon().getCardinality();
|
||||
}
|
||||
}
|
||||
|
||||
private static String getPackageName(LauncherAtom.ItemInfo info) {
|
||||
@@ -395,15 +401,24 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||
}
|
||||
}
|
||||
|
||||
private static int getPageId(LauncherAtom.ItemInfo info, boolean parent) {
|
||||
if (info.getContainerInfo().getContainerCase() == FOLDER) {
|
||||
if (parent) {
|
||||
return info.getContainerInfo().getFolder().getWorkspace().getPageIndex();
|
||||
} else {
|
||||
private static int getPageId(LauncherAtom.ItemInfo info) {
|
||||
switch (info.getContainerInfo().getContainerCase()) {
|
||||
case FOLDER:
|
||||
return info.getContainerInfo().getFolder().getPageIndex();
|
||||
}
|
||||
} else {
|
||||
return info.getContainerInfo().getWorkspace().getPageIndex();
|
||||
default:
|
||||
return info.getContainerInfo().getWorkspace().getPageIndex();
|
||||
}
|
||||
}
|
||||
|
||||
private static int getParentPageId(LauncherAtom.ItemInfo info) {
|
||||
switch (info.getContainerInfo().getContainerCase()) {
|
||||
case FOLDER:
|
||||
return info.getContainerInfo().getFolder().getWorkspace().getPageIndex();
|
||||
case SEARCH_RESULT_CONTAINER:
|
||||
return info.getContainerInfo().getSearchResultContainer().getWorkspace()
|
||||
.getPageIndex();
|
||||
default:
|
||||
return info.getContainerInfo().getWorkspace().getPageIndex();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,6 +426,9 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||
if (info.getContainerInfo().getContainerCase() == FOLDER) {
|
||||
return info.getContainerInfo().getFolder().getParentContainerCase().getNumber()
|
||||
+ FOLDER_HIERARCHY_OFFSET;
|
||||
} else if (info.getContainerInfo().getContainerCase() == SEARCH_RESULT_CONTAINER) {
|
||||
return info.getContainerInfo().getSearchResultContainer().getParentContainerCase()
|
||||
.getNumber() + SEARCH_RESULT_HIERARCHY_OFFSET;
|
||||
} else {
|
||||
return info.getContainerInfo().getContainerCase().getNumber();
|
||||
}
|
||||
|
||||
@@ -248,10 +248,10 @@ public class GridSizeMigrationTaskV2 {
|
||||
/** Return what's in the src but not in the dest */
|
||||
private static List<DbEntry> calcDiff(List<DbEntry> src, List<DbEntry> dest) {
|
||||
Set<String> destIntentSet = new HashSet<>();
|
||||
Set<Set<String>> destFolderIntentSet = new HashSet<>();
|
||||
Set<Map<String, Integer>> destFolderIntentSet = new HashSet<>();
|
||||
for (DbEntry entry : dest) {
|
||||
if (entry.itemType == LauncherSettings.Favorites.ITEM_TYPE_FOLDER) {
|
||||
destFolderIntentSet.add(entry.mFolderItems.keySet());
|
||||
destFolderIntentSet.add(getFolderIntents(entry));
|
||||
} else {
|
||||
destIntentSet.add(entry.mIntent);
|
||||
}
|
||||
@@ -259,7 +259,7 @@ public class GridSizeMigrationTaskV2 {
|
||||
List<DbEntry> diff = new ArrayList<>();
|
||||
for (DbEntry entry : src) {
|
||||
if (entry.itemType == LauncherSettings.Favorites.ITEM_TYPE_FOLDER) {
|
||||
if (!destFolderIntentSet.contains(entry.mFolderItems.keySet())) {
|
||||
if (!destFolderIntentSet.contains(getFolderIntents(entry))) {
|
||||
diff.add(entry);
|
||||
}
|
||||
} else {
|
||||
@@ -271,13 +271,23 @@ public class GridSizeMigrationTaskV2 {
|
||||
return diff;
|
||||
}
|
||||
|
||||
private static Map<String, Integer> getFolderIntents(DbEntry entry) {
|
||||
Map<String, Integer> folder = new HashMap<>();
|
||||
for (String intent : entry.mFolderItems.keySet()) {
|
||||
folder.put(intent, entry.mFolderItems.get(intent).size());
|
||||
}
|
||||
return folder;
|
||||
}
|
||||
|
||||
private static void insertEntryInDb(SQLiteDatabase db, Context context, DbEntry entry,
|
||||
String srcTableName, String destTableName) {
|
||||
int id = copyEntryAndUpdate(db, context, entry, srcTableName, destTableName);
|
||||
|
||||
if (entry.itemType == LauncherSettings.Favorites.ITEM_TYPE_FOLDER) {
|
||||
for (int itemId : entry.mFolderItems.values()) {
|
||||
copyEntryAndUpdate(db, context, itemId, id, srcTableName, destTableName);
|
||||
for (Set<Integer> itemIds : entry.mFolderItems.values()) {
|
||||
for (int itemId : itemIds) {
|
||||
copyEntryAndUpdate(db, context, itemId, id, srcTableName, destTableName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -675,7 +685,10 @@ public class GridSizeMigrationTaskV2 {
|
||||
String intent = c.getString(1);
|
||||
verifyIntent(intent);
|
||||
total++;
|
||||
entry.mFolderItems.put(intent, id);
|
||||
if (!entry.mFolderItems.containsKey(intent)) {
|
||||
entry.mFolderItems.put(intent, new HashSet<>());
|
||||
}
|
||||
entry.mFolderItems.get(intent).add(id);
|
||||
} catch (Exception e) {
|
||||
removeEntryFromDb(mDb, mTableName, IntArray.wrap(c.getInt(0)));
|
||||
}
|
||||
@@ -714,7 +727,7 @@ public class GridSizeMigrationTaskV2 {
|
||||
|
||||
private String mIntent;
|
||||
private String mProvider;
|
||||
private Map<String, Integer> mFolderItems = new HashMap<>();
|
||||
private Map<String, Set<Integer>> mFolderItems = new HashMap<>();
|
||||
|
||||
/** Comparator according to the reading order */
|
||||
@Override
|
||||
@@ -748,9 +761,5 @@ public class GridSizeMigrationTaskV2 {
|
||||
values.put(LauncherSettings.Favorites.SPANX, spanX);
|
||||
values.put(LauncherSettings.Favorites.SPANY, spanY);
|
||||
}
|
||||
|
||||
public String getIntentStr() {
|
||||
return mIntent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -344,7 +344,7 @@ public class ItemInfo {
|
||||
return itemBuilder;
|
||||
}
|
||||
|
||||
ContainerInfo getContainerInfo() {
|
||||
protected ContainerInfo getContainerInfo() {
|
||||
switch (container) {
|
||||
case CONTAINER_HOTSEAT:
|
||||
return ContainerInfo.newBuilder()
|
||||
|
||||
@@ -91,6 +91,7 @@ public final class TestProtocol {
|
||||
public static final String REQUEST_START_EVENT_LOGGING = "start-event-logging";
|
||||
public static final String REQUEST_GET_TEST_EVENTS = "get-test-events";
|
||||
public static final String REQUEST_STOP_EVENT_LOGGING = "stop-event-logging";
|
||||
public static final String REQUEST_CLEAR_DATA = "clear-data";
|
||||
|
||||
public static boolean sDebugTracing = false;
|
||||
public static final String REQUEST_ENABLE_DEBUG_TRACING = "enable-debug-tracing";
|
||||
|
||||
@@ -300,17 +300,9 @@ public abstract class AbstractLauncherUiTest {
|
||||
checkDetectedLeaks(mLauncher);
|
||||
}
|
||||
|
||||
protected void clearLauncherData() throws IOException, InterruptedException {
|
||||
if (TestHelpers.isInLauncherProcess()) {
|
||||
LauncherSettings.Settings.call(mTargetContext.getContentResolver(),
|
||||
LauncherSettings.Settings.METHOD_CREATE_EMPTY_DB);
|
||||
resetLoaderState();
|
||||
} else {
|
||||
clearPackageData(mDevice.getLauncherPackageName());
|
||||
mLauncher.enableDebugTracing();
|
||||
mLauncherPid = mLauncher.getPid();
|
||||
mLauncher.waitForLauncherInitialized();
|
||||
}
|
||||
protected void clearLauncherData() {
|
||||
mLauncher.clearLauncherData();
|
||||
mLauncher.waitForLauncherInitialized();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1335,6 +1335,10 @@ public final class LauncherInstrumentation {
|
||||
return tasks;
|
||||
}
|
||||
|
||||
public void clearLauncherData() {
|
||||
getTestInfo(TestProtocol.REQUEST_CLEAR_DATA);
|
||||
}
|
||||
|
||||
public Closable eventsCheck() {
|
||||
Assert.assertTrue("Nested event checking", mEventChecker == null);
|
||||
disableSensorRotation();
|
||||
|
||||
Reference in New Issue
Block a user