Commit Graph

244 Commits

Author SHA1 Message Date
Alex Chau
e09067c2f4 Allow items to be added alongside smartspace
- Allow icons to be added to first row where search container does not occupy
- On upgrade, clean up first row of screen 0 which may have junk data, as we used to assume first forw of screen 0 is always occupied

Bug: 210127246
Test: manual
Change-Id: I835a321964984e02632c8a70474a6551b5e360f7
2022-01-10 18:24:15 +00:00
Andras Kloczl
953eb8041e Fix LauncherProvider newScreenId issue
Remove maxScreenId from LauncherProvider and whenever we need
a new screenId, query the database to calculate a new screenId.
Also converted and refactored AddWorkspaceItemsTaskTest
and added some extra test cases.

Test: manual & AddWorkspaceItemsTaskTest.kt
Bug: 199160559
Change-Id: I185f6823fed171d778af0130497f5ffaf89c0a70
2021-11-12 19:56:07 +00:00
Alex Chau
ac038434f0 Remove gap between screenIds when restoring from single display device
- In RestoreDbTask.sanitizeDb, add extra step to fill all screenIds gaps so that no empty pages are left in between
  e.g. [0, 3, 4, 6, 7] -> [0, 1, 2, 3, 4]

Fix: 201085524
Test: RestoreDbTaskTest
Change-Id: If0b577bf789347cc490ada0b22f2cd39ee1a33bb
2021-11-09 17:01:01 +00:00
Alex Chau
9b3dd6c0b9 Revert "Clear only workspace shortcut / widget related tests"
This reverts commit 22be1a47f4.

Reason for revert: Breaks another test
Bug: 202546679

Change-Id: I796c508a6d7c00ec8c1d48e3517453f9eca0616c
2021-10-18 17:52:12 +00:00
Alex Chau
22be1a47f4 Clear only workspace shortcut / widget related tests
- This ensure hotseat to be populated with default items, so it won't result in an empty taskbar which get stashed in apps
- Workspace needs to be cleared because shortcut / widget dragging won't always work if there are items in workspace. It only happens in test due to the way we drag items.

Fix: 202546679
Test: NexusLauncherTests:com.android.launcher3.ui.widget.RequestPinItemTest
Change-Id: Ib3ded6a685eaa1b169b75fd179c9e29ca4be1e72
2021-10-15 16:01:44 +01:00
Andras Kloczl
929e3a2742 Remove widget panel related leftover workspace items
Upgrade launcher DB version and remove items with
widget panel IDs from the database.

Test: follow test instructions (in CL comment)
Bug: 198254728
Change-Id: I077a5f70ee93b7eca738b38f6b0e788d49f7ce70
2021-09-06 11:58:32 +01:00
Sunny Goyal
68031ca3f9 Storing form factor as part of backup and disabling restore if form-factor is different
Bug: 195301649
Test: Manual
Change-Id: I9a9c4bc9246f40af2209cb914b3966319bc78bff
2021-08-04 09:51:04 -07:00
Sunny Goyal
278939fdf3 Removing GridMigrationTask-v1 since it has been disabled for a while
Also removing some data migration support

Bug: 194937047
Test: Presubmit
Change-Id: I392a5f6e49ec170f63056a7664de47229896f390
2021-07-28 15:55:43 -07:00
Sunny Goyal
12e3f1f2f7 Removing UI dependency from LauncherModel in case of 2-panel layout
Bug: 175939730
Bug: 192431856
Bug: 185515153
Test: Manual
Change-Id: I8baa1cf9e5a8a04d5b8bc38c1f4b0755265cd8a9
2021-07-22 10:34:25 -07:00
Yogisha Dixit
658c5dafd4 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
2021-06-30 17:48:14 +00:00
Tony Wickham
b87f3cdc1c Add support for having more hotseat icons in the DB than we show
Split InvariantDeviceProfile#numHotseatIcons into two variables:
numDatabaseHotseatIcons and numShownHotseatIcons. These are generally
the same, but different DisplayOptions within the same GridOption
can choose to show different numbers of hotseat icons while sharing
the same database.

numDatabaseHotseatIcons is used for all reading/writing/migrating
purposes, while numShownHotseatIcons determines how many Hotseat
icons to show in the UI.

Test: Existing tests pass, added two new migration tests
Bug: 184789479
Bug: 171917176

Change-Id: I54583504f61a47a4444b6a637ebb7e3ab31528b7
2021-04-12 16:08:15 -07:00
Yogisha Dixit
741fae9ea2 Move widget files into widget folder + add tests.
I will use the newly created LauncherAppWidgetProviderInfoTest in a follow-up CL to add tests for the newly added widget sizing APIs.

Test: Automatic: Ran all robolectric tests in launcher3,
      Manual: Added a widget, edited the widget, removed the widget
Bug: 179807199
Change-Id: I540b2dbe284c6eb5aa2466a1d13a9581ee59425b
2021-03-01 13:59:52 +00:00
TreeHugger Robot
a15b5a6760 Merge "Don't crash Launcher when attempting to endTransaction on an already-closed DB." 2020-12-16 22:35:06 +00:00
Pinyao Ting
0d97f8d19a Disable Database overwrite upon restore
Launcher overwrites user's favorites table (icons in WorkSpace) upon new
install session from Play Store with install reason being restore. The
overwrite was introduced in the attempt to mitigate failed restore
session due to asynchronous nature of user profile restore, but it has
been causing general instability in backup and restore. Going forward
Launcher should be moving away from table overwrite approach, this will
be implemented in b/148284747.

Bug: 171774227
Test: manual
Change-Id: I91221544dbaeb42224ce9f595906b6d9f0e4aa89
2020-12-05 07:05:12 -08:00
Pinyao Ting
0646dde219 Don't crash Launcher when attempting to endTransaction on an
already-closed DB.

Since the DB is already closed, if we can't end the
transaction, it should not put the code in a bad state.

Bug: 173162852
Test: manually tested backup and restore flow and existing tests
Change-Id: I2692d98f0a8efc8aeb6bfd826fe738e4436c6ee4
2020-11-24 15:16:10 -08:00
Pinyao Ting
af0391f9b2 Include more error logging for widget restore
Bug: 171774227
Test: manually tested complete backup & restore flow
Change-Id: Ieb4b39d80a24b4dff377ee74d24d9010acd0daca
(cherry picked from commit ae1997b9d5)
2020-11-11 19:36:09 +00:00
Pinyao Ting
0960b45dbc Fix the issue where shortcuts are removed in minimal device mode
When loading the workspace, Launcher pins/unpins shortcuts in comply
with the loaded workspace. Since minimal device mode creates a mostly
empty workspace, existing shortcuts are getting unpinned as a result.

To mitigate the issue this CL compares the db name and only invoke
sanitizeData when it matches the one defined in InvariantDeviceProfile.

Bug: 170611866
Test: manual
1. add some deep shortcut in workspace (e.g. long tap on chrome, drag
"incognito tab" to workspace)
2. opt-in to sunshine fishfood (g/sunshine-teamfood)
3. enable bedtime mode with minimal device in Settings -> Digital
Wellbeing -> Show Your Data -> Bedtime mode -> Customize -> minimal
device
4. toggle bedtime mode, wait for apps in minimal device to show, then
toggle off bedtime mode
5. verify the deep shortcut still exist

Change-Id: Ie18216ecb288e7481aa2404c4cb3ea418aee85cb
(cherry picked from commit 702ed27886)
2020-10-15 22:07:14 +00:00
Pinyao Ting
840ad8e8bb Minimal Phone Mode (part-3) am: 96186aff87
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/12219772

Change-Id: I27cb81fdb6cc1a5535aec3b259acda16106e084f
2020-08-20 02:03:17 +00:00
Pinyao Ting
96186aff87 Minimal Phone Mode (part-3)
Introduces a separate database for minimal device mode.

When minimal device mode is enabled/disabled:
1. WellbeingModel receives onChange event from ContentObserver
2. WellbeingModel called DWB's ContentProvider for latest state in
minimal device mode
3. Based on the state, WellbeingModel calls LauncherProvider to put
launcher into normal/minimal mode.
4. When going from normal -> minimal, Launcher switches to a different
database, namely minimal.db, then proceed to database initialization.
5. If the database hasn't been initialized yet, Launcher will call
ContentResolver#openInputStream with following uri:
content://com.google.android.apps.wellbeing.api/launcher_layout
to get the default layout xml.
6. The default layout is then saved in database, and the database is
considered initialized and doesn't need to go through step 5 again in
the future.
7. In case of minimal -> normal, Launcher switches back to its original
database (e.g. launcher.db if the grid size is 5x5), then reload launcher.

Bug: 161462256
Change-Id: I6bafa66440da23281f63454b698ea56b15960022
2020-08-19 14:58:20 -07:00
Sunny Goyal
eaf7a95546 Changing minimum supported Launcher version to 26
Change-Id: I49fcf874430ac53c3246371e179fbd828e14e4da
2020-07-29 17:30:19 -07:00
Samuel Fufa
f667a1352d Restore hotseat when user turns off suggestions immediately after migration
- Creates a backup table `hybrid_hotseat_restore` and copies current workspace layout before hotseat migration
- restores to back up when user turns off suggestions and launcher receives empty predicted items
- deletes hybrid_hotseat_restore table if there's a layout change

Test: Manual
Bug: 157688471
Change-Id: Iaf7ddb33799493d36dbcd12408b57224162221d9
2020-06-03 13:15:21 -07:00
Pinyao Ting
0807c946b6 Mitigate 10 minutes delay in launcher restore for work apps.
1. Instead of debouncing launcher restore when new install session
(triggered by Play Service due to restore) is created, it is now
throttled at once every 30 seconds. (i.e. Launcher restore is triggered
immediately, but cannot be triggered again within 30 seconds)
2. Removes the backup table when all items are restored. (i.e. no item
were removed as a result of sanitize db due to user didn't sign in to
their work profile)

Bug: 153648870
Change-Id: I32df371f8b47c60a72515876217fd83ac1e56f0a
Test: manually verified with deferred restore
2020-04-28 15:52:19 -07:00
Tracy Zhou
879d3ade68 Merge changes from topic "grid-size-migration" into ub-launcher3-rvc-dev
* changes:
  fix GridBackupTableTest in comply with grid size migration
  Turn on V2 migration algorithm feature flag
2020-04-24 19:26:44 +00:00
Pinyao Ting
26c4e23e9a fix GridBackupTableTest in comply with grid size migration
Bug: 154166808
Test: GridBackupTableTest
Change-Id: I7af35ceed7edb77ac0d9c443d7eccbcef19ae476
2020-04-23 09:18:46 -07:00
Tracy Zhou
ed5f3082b0 Special handling when a db for one grid option is not setup yet
- Init KEY_MIGRATION_SRC_WORKSPACE_SIZE and KEY_MIGRATION_SRC_HOTSEAT_COUNT
- Load default workspace only when default db is created, not when peeking into dbs of other grid options during grid preview / migration

Fixes: 154184711
Test: run grid preview and migration right after a cleared cache Pixel Launcher
Change-Id: I86c7072b8c4a9da76e289c55ab440071f192fc38
2020-04-22 18:13:42 -07:00
Tracy Zhou
c0000450b5 Support grid preview with v2 migration algorithm
The focus of ag/10346770 is around the actual algorithm, while in the meantime our preview logic has changed during the code review of ag/10100264.

GridSizeMigrationTaskV2 addresses both cases, the difference being preview passes in constructed IDP while actual migration uses IDP from the current Context.

When doing actual migration, we call METHOD_UPDATE_CURRENT_OPEN_HELPER to update the current db helper and copy the favorites table from the previous db into the current db in favorites_tmp table. Then we do migration from there.

When calculating preview, I added METHOD_PREP_FOR_PREVIEW in this change to copy the favorites table from the intended grid setting to the current grid setting in favorites_preview table. Then we calculate migration from the current favorites table to favorites_preview table and save into favorites_preview table.

Bug: 144052802
Fixes: 144052839

Test: Manual

Change-Id: I64a8b61a4e0bf8399c0ae1af4ef9d2bde0f1ee2f
2020-03-25 21:58:19 -07:00
Tracy Zhou
f601872a0a The new grid migration algorithm
go/grid-migration-v2

When changing grid from option 1 to option 2, we calculate the diff and add the icons that are in option 1 but not option 2, to option 2's workspace, according to the reading order.

Test: manual and unit tests
Fixes: 144052802

Change-Id: Id01f69e90ce656a9b7c9051fed499807ee9ac0f7
2020-03-13 14:56:38 -07:00
Zak Cohen
3eeb41de9a Rename flag IS_DOGFOOD to IS_STUDIO.
The flag is only set when building from Android Studio... and is never
used for dogfood.

Test: local
Change-Id: I898d585f4558c2437f0152ef102bea59c351f80b
2020-02-14 14:19:59 -08:00
Tracy Zhou
7df93d28d4 Setup infrastructure (multi-db support) for the new grid migration algorithm
We'll have a db for each grid option and a db for back up / restore.

TODO(pinyaoting): support back up / restore using the new infrastructure, particularly calls to GridBackupTable should use different DBs when the feature flag (NEW_GRID_MIGRATION_ALGORITHM) is on.

Bug: 144052802
Test: N/A

Change-Id: I644a3e70148bd78204a747a337446a3c038f616f
2020-02-05 19:55:05 -08:00
Pinyao Ting
ad5f24072c hook database restore with restore session
1. Create feature flag for new backup & restore flow.
2. For each restore session (install reason is restore),
   if its creation time is newer than the one we have in
   SharedPreference, we update the entry and restores
   favorite table from backup.
3. The restore operation is debounced so that when
   multiple restore session is created within a small
   amount of time, only the last invocation will get
   executed.

Bug: 141472083
Change-Id: I7b5b63ec28741ba2b02ccfd13f591c961362ba36
Test:
1. apply on master, build & flash on physical device.
2. factory reset the device.
3. go through SuW, perform restore, exit without
   adding work profile.
4. settings -> account -> add work profile account.
5. finish work profile setup, verify work profiles
   is restored as well.
2020-01-16 16:01:54 -08:00
Pinyao Ting
ba9c557108 Initial support for restore workspace from last stable db entry.
(see go/play-launcher-plan-launcher-implementation)

1. When Launcher launches for the first time, creates a backup
   of the workspace before sanitizing db entries.
2. Creates a new path in LauncherProvider that triggers workspace
   restore using last stable db entry of the same grid size.
3. When restore from backup created this way, the table will be
   sanitized afterward.

Test:
1. apply on master, build & refresh on physical device
2. factory reset, go through SuW and perform restore
3. exit SuW without signing into Work Profile
4. run following commands in console
adb root
adb remount
adb pull
/data/data/com.google.android.apps.nexuslauncher/databases/launcher.db
sqlite3 ./launcher.db
.tables
SELECT * FROM favorites_bakup;

Bug: 141472083
Change-Id: I8032866a97eb333946d4f62352595d180364126b
2020-01-16 12:23:45 -08:00
Sunny Goyal
337c81f664 Removing static instances of UserManagerCompat and AppWidgetManager
> Changing the lifecycle to follow other static objects in Launcher
> Removing compat interface and inlining everything to helpers

Bug: 141376165
Change-Id: I82bd5db1969101de9a7eac77f32728d70195bb35
2019-12-11 10:03:19 -08:00
Sunny Goyal
4b5b0eb60d Moving some tests to robolectric
> Adding support for simulating model load

Bug: 130562632
Change-Id: I1de8c0abe2e74d4e7e47e18914316c339920609a
2019-12-09 11:17:12 -08:00
Sunny Goyal
01615a69d2 Removing host deletion on startup and corresponding callbacks
> Launcher deletes the phantom widget ids in loader

Bug:141376165
Change-Id: Icf0542535f194f9abc67e7190f34cb60f69e9f66
2019-10-02 12:08:26 -07:00
Sunny Goyal
b1d7de25f8 Adding support for overlay and corresponding plugin to Launcher
Updating various task callbacks to handle overlays

Change-Id: I80077508ad35c31269c873f51f0105302a9e6a5d
2019-09-10 08:08:28 -07:00
Sunny Goyal
9dbb27c09c Moving some utilities methods to separate class
Change-Id: I5094b22ddc77c45590cea1a5f5dead0dc7580abf
2019-07-17 15:15:07 -07:00
Jon Miranda
c7206caf6e Ensure app widget ids are restored after database is sanitized.
Previously, it was possible for AppWidgetsRestoredReceiver to
start the restore process before work profile has finished restoring which
resulted in the work profile items being removed from the workspace.

Bug: 131315856
Change-Id: I2f295a1ca91f1996522bcc8052aa139979526e3b
2019-05-14 17:30:04 +00:00
Sunny Goyal
c0f03d9665 Adding support for loading the default layout from a content provider
The autority of the provider should be set in secure settings:
  launcher3.layout.provider

Bug: 127987071
Change-Id: Iccf2960aa6c0a5a8ff9621b13d8963d9daecb993
2019-04-10 12:06:17 -07:00
Jon Miranda
7143ba6fec Make QSB_ON_FIRST_SCREEN a boolean.
Bug: 118140522
Change-Id: Ic8e47e71f538b0b0caff6f630566665d05a65522
2019-03-15 09:11:54 -07:00
Jon Miranda
2bc6b934ac Add launcher support for restoring work profile items onto workspace.
Bug: 111301511
Change-Id: I40decf4c763401c97afcc2bfa7954a1f3a03f536
2019-03-07 18:55:16 -08:00
Sunny Goyal
8c48d8bea6 Changing min sdk to 25
Change-Id: I0d28069967854357ca755bf25dec19d4979bdecf
2019-01-29 11:29:52 -08:00
Sunny Goyal
161a214ede Adding support for backing up favorites table
Favorites table is copied as a separate table name during the first grid migration.
On subsequent migrations this backup table is used if it exists, otherwise new
backup is created. The backup table is also removed if there is any insert or
delete operation on the db (outside of the migration operation itself).

Bug: 111850268
Bug: 121048571
Change-Id: I6f02f4a355c369ee99d89430971be258f7516f6e
2019-01-03 10:25:44 -08:00
Sunny Goyal
c5939393a9 Bye bye workspace screens table
Removing a separate table for workspace screens. List of screens are
automatically parsed using the items in the favorites DB. Order of the
screen based on the screen id and rearranging screens is no longer
supported. In case the screens need to be rearranged, all the items
in the favorites db will need to be updated with new screen ids.

This makes backing up the DB (in the same database) easier as only
one table needs to be duplicates.

Change-Id: I8ba947a898f637d780e2f49925e78604263126e8
2018-12-10 11:43:35 -08:00
Sunny Goyal
4276e7b649 Moving autority definition to a separate file, so
that it can be easily customized using android studio

Change-Id: I17f4f4511c2af5d382727769d1b74413f233d500
Bug: 120079798
2018-11-27 23:20:32 +00:00
Ryan Lothian
fa530cd23f Make flags UI available on release build of launcher
The UI will only be shown on eng/userdebug platform builds.

Bug: 117223984
Change-Id: I27843f2d856a4a19f3fe53c4d306606eaa5714a2
2018-10-15 17:24:48 -04:00
Sunny Goyal
efb7e84242 Converting long item IDs to int
> Items ids were already being typecasted to int when being bound on the UI
> Using a consistent type allow better use of platform data-structures
> Adding IntArray and IntSet as a replacement for various Collection classes

Change-Id: Id3c650ed2420c2bfca3bd7671d2b705b56112371
2018-10-08 14:52:39 -07:00
Ryan Lothian
688e9896fa Groundwork for runtime-toggleable feature flags
This is the first step in adding a flag toggler UI to launcher.
The change migrates a single flag (QSB_ON_FIRST_SCREEN) from a
boolean constant to a boolean method. In future, that will allow
us to return different values at runtime.

Bug: 117223984
Change-Id: I1e62c91dd941b8145166021bc0aa157733e62ea0
2018-10-08 13:17:30 -04:00
Sunny Goyal
b959cfb44f Reverting some debug logs
Bug: 72481685
Change-Id: Ib9e52504d9513bd7fdede28f6c0798ca7873083d
2018-04-04 10:19:30 -07:00
Sunny Goyal
19026b2527 Using new APIs for disabling metaData table
Bug: 70863722
Change-Id: Ib6bb554212da2c5d5d23a51aa0eff52bae97bce1
2018-03-09 14:38:13 -08:00
TreeHugger Robot
909267996e Merge "Deprecate work folder" into ub-launcher3-master 2018-02-28 17:32:52 +00:00