Refactor shortcut updating, and do it on BOOT_COMPLETE

This CL shuffles quite a bit of code around, but the effective differences are:
* Unified shortcut updating code (language switch & backup restoration).
* Shortcuts are also updated on boot (flagged by MODES_UI which will need this).
* Removed usage of (long obsolete) AsyncTask.

A further CL will add some special-casing for the DND->Modes shortcut transition.

Bug: 365545604
Test: atest com.android.settings.shortcut + manual (switch language, reboot)
Flag: android.app.modes_ui
Change-Id: I30450d13cb05008d2a71ed89d4781eb81e5532b9
This commit is contained in:
Matías Hernández
2024-09-11 18:36:47 +02:00
parent b979edf1f8
commit 939189bde8
10 changed files with 298 additions and 161 deletions

View File

@@ -16,17 +16,19 @@
package com.android.settings.backup;
import android.app.backup.BackupAgentHelper;
import android.util.Log;
import com.android.settings.flags.Flags;
import com.android.settings.onboarding.OnboardingFeatureProvider;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.shortcut.CreateShortcutPreferenceController;
import com.android.settings.shortcut.ShortcutsUpdater;
import com.android.settingslib.datastore.BackupRestoreStorageManager;
/** Backup agent for Settings APK */
public class SettingsBackupHelper extends BackupAgentHelper {
private static final String TAG = "SettingsBackupHelper";
public static final String SOUND_BACKUP_HELPER = "SoundSettingsBackup";
public static final String ACCESSIBILITY_APPEARANCE_BACKUP_HELPER =
"AccessibilityAppearanceSettingsBackup";
@@ -58,6 +60,10 @@ public class SettingsBackupHelper extends BackupAgentHelper {
public void onRestoreFinished() {
super.onRestoreFinished();
BackupRestoreStorageManager.getInstance(this).onRestoreFinished();
CreateShortcutPreferenceController.updateRestoredShortcuts(this);
try {
ShortcutsUpdater.updatePinnedShortcuts(this);
} catch (Exception e) {
Log.e(TAG, "Error updating shortcuts after restoring backup", e);
}
}
}