Commit Graph

30 Commits

Author SHA1 Message Date
Alex Chau
1c883d861e Add launcher grid spec for tablet
- Introduced device_category to allow grids to be only enabled for certain device types. By default grids are enabled for all device types, so old OEM device_profiles aren't affected
  - Removed device_profiles_split.xml as a result and merged with device_profiles.xml
- Added deviceType in InvariantDeviceProfile to replace isSplitDisplay and centralize the logic
- Only has 6x5 grid with new default layout that works better for tablets

Bug: 198575341
Test: manual
Change-Id: I03f6727ce837ffeee6321b6d7c53942338d0cf30
2021-12-08 18:22:34 +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
238aaee059 Allow 2x2 and 3x3 to be migrated after restore
- Allow disabled grid to be used during restore
- Remove all inactive grid dbFiles to allow grid migration to happen
- Set the proper grid after restore to trigger migration

Bug: 202125760
Test: Restore a 2x2,3x3 grid, icons and widgets are migrated to 4x4 grid
Test: Restore a 4x4 grid, icons and widgetse stays in original position
Change-Id: Ie59e1ca0ca56ed2de52d88cd5f51b980788afa52
2021-10-12 17:36:04 +01:00
Alex Chau
d63c58d7d1 Allow restore between TYPE_PHONE AND TYPE_MULTI_DISPLAY in RestoreDbTask
- Follow-up of ag/15795679: allow restore in RestoreDbTask as well

Bug: 199407109
Test: manual
Change-Id: I2a8e2d9c28ee777f53a6d3554e31f7318422401f
2021-09-10 15:16:36 +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
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
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
Sunny Goyal
e396abf502 Moving model data structures to a separate file
Change-Id: I77ad7a5219e72d2e0d6c1803de2ac3ed6a65a8f7
2020-04-09 13:20:39 -07:00
Tracy Zhou
02cb060775 Follow up change to GridBackupTable per V2 backup / restore (multi-db)
Removed the code to handle table copying across dbs. We don't really need this since per ag/10298497, we can just copy db files directly.

Bug: 149236106
Test: N/A
Change-Id: I90bd7b6779fcaa841c71f5d0f27ec91907f926fc
2020-02-12 18:08:06 -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
Pinyao Ting
71e53bba16 Fix the issue malformed SQL statement was provided during db
sanitization.

Bug: 147114476
Change-Id: I34459267cfacb168ec520856e90e5da0b83728f0
Test:
1. follow the verification step in ag/9891836
2. add the following line in Launcher#onResume
LauncherSettings.Settings.call(getContentResolver(),
        LauncherSettings.Settings.METHOD_RESTORE_BACKUP_TABLE);
3. build & flash on the device
4. verify sanitizeDb success without error message
2020-01-16 10:02:23 -08:00
Pinyao Ting
fb9b779e9d log number of items deleted even when no item was deleted at all
Bug: 137678815
Change-Id: I1cf23921f863a17433ba803158e489b54c1aa35d
2020-01-06 14:10:35 -08:00
Pinyao Ting
3c79804f28 include error log to determine root cause of sql statement failure when
restoring work profile

Bug: 147114476
Change-Id: I25e57413faa569a30e27a0cde1fc47233ff8b603
2020-01-06 11:21:41 -08:00
Sunny Goyal
71834aa186 Merge "Fix bug where we incorrectly change the default profile id of the database." into ub-launcher3-qt-qpr1-dev
am: a42681f6d2

Change-Id: I05ca0e24324272e06087221fbbb50a6dbef7ed4f
2019-09-03 11:17:14 -07:00
Jon Miranda
768cb139cc Fix bug where we incorrectly change the default profile id of the database.
Change-Id: I0fafc06f5e28c1fdff77003c984e686719a60cd2
2019-08-30 16:11:00 +00: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
Jon Miranda
df94de9343 Fix SDK check to use Utilities.ATLEAST_Q.
Bug: 131315856
Change-Id: Ie1d00d85dd01da7e57f28e16f51a49962d734927
2019-05-08 10:05:57 -07:00
Sunny Goyal
9589916418 ShortcutInfo renamed to WorkspaceItemInfo
Will get rid of ShortcutInfoCompat in a follow up cl

Change-Id: I7d7d9c938635f59b216290ba28bea9d0e0721a7d
2019-04-16 00:08:24 -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
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
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
Sunny Goyal
f5b4b80972 Fixing widget id restore broadcast.
Ignoring thw broadcast if its not for the main widget host, or if
the Launcher DB is already in use. Launcher already handles missing
widget-Id map broadcast, by binding a new widgetId at runtime.

Bug: 63389280
Change-Id: Iaa9774d6d7adde3711cba9615328020e2b2e66aa
2017-07-12 12:14:29 -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
Hyunyoung Song
3c7d9cbb20 Clean up around 1) Log.VERBOSE and 2) dump
b/31772480

Note: in the follow up CL, I will add the dump result of the bgDataModel
to a proto

Change-Id: I5261cff0fb29cedd1dd772b8b15f67095ad5b967
2017-02-01 15:11:08 -08:00
Sunny Goyal
49f19f0af9 Adding some logging around launcher restore
> Also enabling fileLog when the device is debug build (even when
launcher is not dogfood build)

Bug: 30735662
Change-Id: Ieab2c962d57f6f7f972f8111070d4ecbef06b3e7
2017-01-09 14:27:56 -08:00
Sunny Goyal
b05a00a441 Adding a debug flag to prevent broken downlodas from getting removed during
restore

After setting this flag apps do not need to have an active settion during restore
which would simplyfy debugging backup-restore bugs.

Change-Id: I89f2d3ec677281887f8bab8559ace991709caadc
2016-08-29 11:19:26 -07:00
Sunny Goyal
e8f7d5a67e Executing the DB migration during startup instead of restore.
This allows proper execution of DB.onUpgrade task if the app updates
after the restore

Change-Id: I4c40167b30e1d7040b3a38be70d834f7b215e540
2016-06-08 16:14:59 -07:00