Commit Graph

273 Commits

Author SHA1 Message Date
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
Sunny Goyal
2bba1900e0 Adding temporary logs to capture configuration changes and item deletions
Bug: 72481685
Bug: 73814840
Change-Id: I1e30632647ad08a08d84c49875bc7b6cac3be1fb
2018-02-27 13:20:57 -08:00
Tony Mak
1b6826c53c Deprecate work folder
FIX: 73876183

Change-Id: I9d15df247eed3500c679cba085c680b75581cffb
2018-02-27 17:47:22 +00:00
Sunny Goyal
66f2b35320 Adding a utility class to simplify main process initialization.
Change-Id: I796cf758d2a25cf8fd5f9a9b78a7977fd54ca451
2018-02-13 17:08:09 -08:00
Sunny Goyal
85525173ce Rearranging the code structure to allow replacing state logic.
Change-Id: I6f83d0f77045ba189f02dd465bf70ffc2a239aa1
2017-11-06 14:57:50 -08:00
TreeHugger Robot
8838b8e0e5 Merge "Removing extraction service and palette api dependency" into ub-launcher3-master 2017-10-03 20:56:02 +00:00
Sunny Goyal
fca6bc9dce Adding a utility method to simplify method tracing
Change-Id: I79ef0aa5d65b933f4b7f0520fc8bac26e366da2d
2017-10-02 13:47:42 -07:00
Sunny Goyal
f2dd4216c1 Removing extraction service and palette api dependency
Change-Id: I30ad1a1462a97b6bc03f8e386ae3058c7fe022e5
2017-09-29 10:40:08 -07:00
Android Build Merger (Role)
ea1212a38a [automerger] Demo mode default layout support am: 2782449da6
Change-Id: I0d03e760f97c6f9984ad0bf9e8f9e8c7a8a8b5c7
2017-09-29 15:49:43 +00:00
Adam Cohen
2782449da6 Demo mode default layout support
67062454

Change-Id: Ic060d3d7dba4fffe688dddf7cd04c48e4baaf813
2017-09-29 15:49:34 +00:00
Sunny Goyal
64a75aa305 Adding A feature flag to disable widgets and a corresponding build
target Launcher3Go without widgets support

Bug: 62353159
Change-Id: Ia03d2235a9bcf75f9ef191924f81630e63a2c684
2017-07-21 14:10:13 -07:00
Jonathan Miranda
36be1d3674 Revert "Update existing Folder items' ranks to match their pre-permutation layouts."
This reverts commit c4b296a50e.

Change-Id: Ieff7873edc3cb300fe454b0ad97d6f0b4f0cb5a9
2017-07-13 18:00:52 +00:00
Jon Miranda
c4b296a50e Update existing Folder items' ranks to match their pre-permutation layouts.
With the new Folder permutation logic, we change the position of the items
when they are added to a Folder. This means that existing Folders will
now appear in a different order than the user arranged them in.

This change makes sure that when a user upgrades, their existing Folders
will appear untouched.

Note: We decided to priotize restoring the original layout of the Folder,
      as opposed to making sure the preview items remain the same. This
      is less destructive of users' data (we're changing the window into
      the Folder, but not the location of items when the Folder is open).

Bug: 63115141
Bug: 35064148

Change-Id: Ib0a28b4b50be089878ffc3e40bced89832e125bc
2017-06-28 19:10:53 -07:00
Sunny Goyal
22ca9ec137 Removing various reflection calls with final APIs
Change-Id: Ibf48d6015d808f86bc79ccf64e3077eb5b6ccaff
2017-05-22 11:00:29 -07:00
Sunny Goyal
05f30889d6 Adding support for DB downgrade
Adding a schema file for handling DB downgrade. This schema file is part of
the backup/restore set, and hence is available on a device with lower app version.

Bug: 37257575
Change-Id: I69c8ef5f28d5209be6e6679412c7459d4eeda5d0
2017-05-09 12:59:04 -07:00
Sunny Goyal
f7d9b70700 Do not delete chost widgets when opening DB.
am: 57266aa2bd

Change-Id: Iab767b7b7c60db60322151cc5c2ab6a65706a553
2017-05-05 19:55:31 +00:00
Sunny Goyal
57266aa2bd Do not delete chost widgets when opening DB.
During restore, the data can be in inconsistant state, as the
system is yet to give us the widget map. Deleting the widget during
open would cause the AppWidgetRestoredReceiver to store the widget id
after it has been deleted.

Bug: 37935101
Bug: 38029633
Change-Id: Id3b8766229718239ae784794e848dcfbc74658ac
2017-05-05 10:55:21 -07:00
Sunny Goyal
9205a3035d Merge "Initializing the Add To Homescreen setting by reading it from market app" into ub-launcher3-dorval
am: f436478b02

Change-Id: I0f322aeb37c7ba35b2d2f97b1802f1c657a790b4
2017-05-03 20:11:57 +00:00
Sunny Goyal
3e443a2457 Initializing the Add To Homescreen setting by reading it from market app
> Also enabling add to home-to-homescreen feature based on install reason

Bug: 36588249
Change-Id: Icfc1edd4c31ed7eb50086f8ffb1a7858a9641b41
2017-05-03 11:24:54 -07:00
Sunny Goyal
dbfc9014fe Simplifying some DB managed logic
> Adding SQLiteTransaction to make it easier to manage DB transactions
> Using try-with resource for better resource handling
> Defining utility method for iterating over cursor

Change-Id: I20b1a62d61798342825ecfeb971e1a0c63c9b6d7
2017-04-19 13:26:10 -07:00
Sunny Goyal
581a69e6d4 Merge "Deleting any ghost widget from system service:" into ub-launcher3-dorval
am: f2d8b65775

Change-Id: I1d9b7a5a532bf504aabac69691e3f83e2f181a04
2017-04-18 22:20:19 +00:00
Sunny Goyal
55fddc825b Deleting any ghost widget from system service:
> A one-time DB update for removing any existing ghost widgets
> Handling widget cleanup when we bulk delete workspace items during loader
> Simplifying external delete

Bug: 35634653
Change-Id: Id0c520f57aee6d75d9c0e7bcd5786a464bf9f39f
2017-04-17 15:28:39 -07:00