DO NOT MERGE Create a setting for backup/restore agent timeouts

Part of push to make backup and restore agent timeouts configurable. Creates
a Global setting for the current static BackupManagerService timeouts so
that they can be overriden with P/H. We keep the current default values,
which will be updated once we investigate what more appropriate values are.

Remame the constants to better reflect what they're used
for. Next, we will update the framework to use these constants.

This depends on the refactor of how we observe changes to key value
backup settings (ag/3709997).

Bug: 70276070
Test: m -j RunFrameworksServicesRoboTests ROBOTEST_FILTER=BackupAgentTimeoutParametersTest
Change-Id: Id506314ce0c8bd5e4d1d8b4001b26cbad0056c99
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
index 6398858..da62d94 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
@@ -2938,7 +2938,7 @@
         }
 
         private final class UpgradeController {
-            private static final int SETTINGS_VERSION = 157;
+            private static final int SETTINGS_VERSION = 158;
 
             private final int mUserId;
 
@@ -3584,7 +3584,7 @@
                 }
 
                 if (currentVersion == 155) {
-                    // Version 155: Set the default value for CHARGING_STARTED_SOUND.
+                    // Version 156: Set the default value for CHARGING_STARTED_SOUND.
                     final SettingsState globalSettings = getGlobalSettingsLocked();
                     final String oldValue = globalSettings.getSettingLocked(
                             Global.CHARGING_STARTED_SOUND).getValue();
@@ -3605,7 +3605,7 @@
                 }
 
                 if (currentVersion == 156) {
-                    // Version 156: Set a default value for zen duration
+                    // Version 157: Set a default value for zen duration
                     final SettingsState globalSettings = getGlobalSettingsLocked();
                     final Setting currentSetting = globalSettings.getSettingLocked(
                             Global.ZEN_DURATION);
@@ -3616,9 +3616,26 @@
                                 Global.ZEN_DURATION, defaultZenDuration,
                                 null, true, SettingsState.SYSTEM_PACKAGE_NAME);
                     }
-
                     currentVersion = 157;
                 }
+
+                if (currentVersion == 157) {
+                    // Version 158: Set default value for BACKUP_AGENT_TIMEOUT_PARAMETERS.
+                    final SettingsState globalSettings = getGlobalSettingsLocked();
+                    final String oldValue = globalSettings.getSettingLocked(
+                            Settings.Global.BACKUP_AGENT_TIMEOUT_PARAMETERS).getValue();
+                    if (TextUtils.equals(null, oldValue)) {
+                        final String defaultValue = getContext().getResources().getString(
+                                R.string.def_backup_agent_timeout_parameters);
+                        if (!TextUtils.isEmpty(defaultValue)) {
+                            globalSettings.insertSettingLocked(
+                                    Settings.Global.BACKUP_AGENT_TIMEOUT_PARAMETERS, defaultValue,
+                                    null, true,
+                                    SettingsState.SYSTEM_PACKAGE_NAME);
+                        }
+                    }
+                    currentVersion = 158;
+                }
                 // vXXX: Add new settings above this point.
 
                 if (currentVersion != newVersion) {