Merge "Init FloatingIconView properties before fetching drawable. & Make sure properties are reset when recycled."
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index a381787..dfe4bb0 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -250,11 +250,12 @@
* Reinitialize the current grid after a restore, where some grids might now be disabled.
*/
public void reinitializeAfterRestore(Context context) {
+ String currentGridName = getCurrentGridName(context);
String currentDbFile = dbFile;
- String gridName = getCurrentGridName(context);
- String newGridName = initGrid(context, gridName);
- if (!newGridName.equals(gridName)) {
- Log.d(TAG, "Restored grid is disabled : " + gridName
+ String newGridName = initGrid(context, currentGridName);
+ String newDbFile = dbFile;
+ if (!newDbFile.equals(currentDbFile)) {
+ Log.d(TAG, "Restored grid is disabled : " + currentGridName
+ ", migrating to: " + newGridName
+ ", removing all other grid db files");
for (String gridDbFile : LauncherFiles.GRID_DB_FILES) {
@@ -265,7 +266,7 @@
Log.d(TAG, "Removed old grid db file: " + gridDbFile);
}
}
- setCurrentGrid(context, gridName);
+ setCurrentGrid(context, newGridName);
}
}
diff --git a/src/com/android/launcher3/LauncherBackupAgent.java b/src/com/android/launcher3/LauncherBackupAgent.java
index dc533f0..3d2700d 100644
--- a/src/com/android/launcher3/LauncherBackupAgent.java
+++ b/src/com/android/launcher3/LauncherBackupAgent.java
@@ -8,8 +8,13 @@
import com.android.launcher3.logging.FileLog;
import com.android.launcher3.provider.RestoreDbTask;
+import java.io.File;
+import java.io.IOException;
+
public class LauncherBackupAgent extends BackupAgent {
+ private static final String TAG = "LauncherBackupAgent";
+
@Override
public void onCreate() {
super.onCreate();
@@ -24,6 +29,17 @@
}
@Override
+ public void onRestoreFile(ParcelFileDescriptor data, long size, File destination, int type,
+ long mode, long mtime) throws IOException {
+ // Remove old files which might contain obsolete attributes like idp_grid_name in shared
+ // preference that will obstruct backup's attribute from writing to shared preferences.
+ if (destination.delete()) {
+ FileLog.d("LauncherBackupAgent", "Removed obsolete file: " + destination);
+ }
+ super.onRestoreFile(data, size, destination, type, mode, mtime);
+ }
+
+ @Override
public void onBackup(
ParcelFileDescriptor oldState, BackupDataOutput data, ParcelFileDescriptor newState) {
// Doesn't do incremental backup/restore
diff --git a/src/com/android/launcher3/provider/RestoreDbTask.java b/src/com/android/launcher3/provider/RestoreDbTask.java
index d994dbe..48b3acf 100644
--- a/src/com/android/launcher3/provider/RestoreDbTask.java
+++ b/src/com/android/launcher3/provider/RestoreDbTask.java
@@ -79,11 +79,15 @@
helper.createEmptyDB(helper.getWritableDatabase());
}
+ // Obtain InvariantDeviceProfile first before setting pending to false, so
+ // InvariantDeviceProfile won't switch to new grid when initializing.
+ InvariantDeviceProfile idp = InvariantDeviceProfile.INSTANCE.get(context);
+
// Set is pending to false irrespective of the result, so that it doesn't get
// executed again.
Utilities.getPrefs(context).edit().remove(RESTORED_DEVICE_TYPE).commit();
- InvariantDeviceProfile.INSTANCE.get(context).reinitializeAfterRestore(context);
+ idp.reinitializeAfterRestore(context);
}
private static boolean performRestore(Context context, DatabaseHelper helper) {
diff --git a/tests/tapl/com/android/launcher3/tapl/Background.java b/tests/tapl/com/android/launcher3/tapl/Background.java
index d84d723..4333b27 100644
--- a/tests/tapl/com/android/launcher3/tapl/Background.java
+++ b/tests/tapl/com/android/launcher3/tapl/Background.java
@@ -80,7 +80,8 @@
protected void goToOverviewUnchecked() {
switch (mLauncher.getNavigationModel()) {
case ZERO_BUTTON: {
- sendDownPointerToEnterOverviewToLauncher();
+ final long downTime = SystemClock.uptimeMillis();
+ sendDownPointerToEnterOverviewToLauncher(downTime);
String swipeAndHoldToEnterOverviewActionName =
"swiping and holding to enter overview";
// If swiping from an app (e.g. Overview is in Background), we pause and hold on
@@ -89,16 +90,17 @@
// Workspace state where the below condition is true), there is no need to pause,
// and we will not test for an intermediate carousel as one will not exist.
if (zeroButtonToOverviewGestureStateTransitionWhileHolding()) {
- mLauncher.runToState(this::sendSwipeUpAndHoldToEnterOverviewGestureToLauncher,
+ mLauncher.runToState(
+ () -> sendSwipeUpAndHoldToEnterOverviewGestureToLauncher(downTime),
OVERVIEW_STATE_ORDINAL, swipeAndHoldToEnterOverviewActionName);
- sendUpPointerToEnterOverviewToLauncher();
+ sendUpPointerToEnterOverviewToLauncher(downTime);
} else {
// If swiping up from an app to overview, pause on intermediate carousel
// until snapshots are visible. No intermediate carousel when swiping from
// Home. The task swiped up is not a snapshot but the TaskViewSimulator. If
// only a single task exists, no snapshots will be available during swipe up.
mLauncher.executeAndWaitForLauncherEvent(
- this::sendSwipeUpAndHoldToEnterOverviewGestureToLauncher,
+ () -> sendSwipeUpAndHoldToEnterOverviewGestureToLauncher(downTime),
event -> TestProtocol.PAUSE_DETECTED_MESSAGE.equals(
event.getClassName().toString()),
() -> "Pause wasn't detected",
@@ -127,7 +129,7 @@
}
String upPointerToEnterOverviewActionName =
"sending UP pointer to enter overview";
- mLauncher.runToState(this::sendUpPointerToEnterOverviewToLauncher,
+ mLauncher.runToState(() -> sendUpPointerToEnterOverviewToLauncher(downTime),
OVERVIEW_STATE_ORDINAL, upPointerToEnterOverviewActionName);
}
}
@@ -153,21 +155,24 @@
private void expectSwitchToOverviewEvents() {
}
- private void sendDownPointerToEnterOverviewToLauncher() {
+ private void sendDownPointerToEnterOverviewToLauncher(long downTime) {
final int centerX = mLauncher.getDevice().getDisplayWidth() / 2;
final int startY = getSwipeStartY();
final Point start = new Point(centerX, startY);
- final long downTime = SystemClock.uptimeMillis();
final LauncherInstrumentation.GestureScope gestureScope =
zeroButtonToOverviewGestureStartsInLauncher()
? LauncherInstrumentation.GestureScope.INSIDE_TO_OUTSIDE
: LauncherInstrumentation.GestureScope.OUTSIDE_WITH_PILFER;
- mLauncher.sendPointer(
- downTime, downTime, MotionEvent.ACTION_DOWN, start, gestureScope);
+ mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, start, gestureScope);
+
+ if (!mLauncher.isLauncher3()) {
+ mLauncher.expectEvent(TestProtocol.SEQUENCE_PILFER,
+ LauncherInstrumentation.EVENT_PILFER_POINTERS);
+ }
}
- private void sendSwipeUpAndHoldToEnterOverviewGestureToLauncher() {
+ private void sendSwipeUpAndHoldToEnterOverviewGestureToLauncher(long downTime) {
final int centerX = mLauncher.getDevice().getDisplayWidth() / 2;
final int startY = getSwipeStartY();
final int swipeHeight = mLauncher.getTestInfo(getSwipeHeightRequestName()).getInt(
@@ -175,7 +180,6 @@
final Point start = new Point(centerX, startY);
final Point end =
new Point(centerX, startY - swipeHeight - mLauncher.getTouchSlop());
- final long downTime = SystemClock.uptimeMillis();
final LauncherInstrumentation.GestureScope gestureScope =
zeroButtonToOverviewGestureStartsInLauncher()
? LauncherInstrumentation.GestureScope.INSIDE_TO_OUTSIDE
@@ -190,18 +194,18 @@
gestureScope);
}
- private void sendUpPointerToEnterOverviewToLauncher() {
+ private void sendUpPointerToEnterOverviewToLauncher(long downTime) {
final int centerX = mLauncher.getDevice().getDisplayWidth() / 2;
final int startY = getSwipeStartY();
final int swipeHeight = mLauncher.getTestInfo(getSwipeHeightRequestName()).getInt(
TestProtocol.TEST_INFO_RESPONSE_FIELD);
final Point end =
new Point(centerX, startY - swipeHeight - mLauncher.getTouchSlop());
- final long downTime = SystemClock.uptimeMillis();
+
final LauncherInstrumentation.GestureScope gestureScope =
zeroButtonToOverviewGestureStartsInLauncher()
- ? LauncherInstrumentation.GestureScope.INSIDE_TO_OUTSIDE
- : LauncherInstrumentation.GestureScope.OUTSIDE_WITH_PILFER;
+ ? LauncherInstrumentation.GestureScope.INSIDE_TO_OUTSIDE_WITHOUT_PILFER
+ : LauncherInstrumentation.GestureScope.OUTSIDE_WITHOUT_PILFER;
mLauncher.sendPointer(downTime, SystemClock.uptimeMillis(),
MotionEvent.ACTION_UP, end, gestureScope);
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index c22b4da..12be54e 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -105,7 +105,7 @@
static final Pattern EVENT_TOUCH_DOWN = getTouchEventPattern("ACTION_DOWN");
static final Pattern EVENT_TOUCH_UP = getTouchEventPattern("ACTION_UP");
private static final Pattern EVENT_TOUCH_CANCEL = getTouchEventPattern("ACTION_CANCEL");
- private static final Pattern EVENT_PILFER_POINTERS = Pattern.compile("pilferPointers");
+ static final Pattern EVENT_PILFER_POINTERS = Pattern.compile("pilferPointers");
static final Pattern EVENT_START = Pattern.compile("start:");
static final Pattern EVENT_TOUCH_DOWN_TIS = getTouchEventPatternTIS("ACTION_DOWN");