Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f4740b36 authored by Abhijit Adsule's avatar Abhijit Adsule Committed by Android (Google) Code Review
Browse files

Merge "settings: migrate Wear auto time settings values" into main

parents e58088ca d4b2006d
Loading
Loading
Loading
Loading
+47 −1
Original line number Diff line number Diff line
@@ -4080,7 +4080,7 @@ public class SettingsProvider extends ContentProvider {

        @VisibleForTesting
        final class UpgradeController {
            private static final int SETTINGS_VERSION = 228;
            private static final int SETTINGS_VERSION = 229;

            private final int mUserId;

@@ -6336,6 +6336,52 @@ public class SettingsProvider extends ContentProvider {
                    currentVersion = 228;
                }

                // Version 228: Migrate WearOS time settings
                if (currentVersion == 228) {
                    if (getContext()
                            .getPackageManager()
                            .hasSystemFeature(PackageManager.FEATURE_WATCH)) {

                        SettingsState global = getGlobalSettingsLocked();

                        Setting cwAutoTime =
                                global.getSettingLocked(Global.Wearable.CLOCKWORK_AUTO_TIME);
                        if (!cwAutoTime.isNull()) {
                            boolean phone =
                                    String.valueOf(Global.Wearable.SYNC_TIME_FROM_PHONE)
                                            .equals(cwAutoTime.getValue());
                            boolean network =
                                    String.valueOf(Global.Wearable.SYNC_TIME_FROM_NETWORK)
                                            .equals(cwAutoTime.getValue());
                            global.insertSettingLocked(
                                    Global.AUTO_TIME,
                                    phone || network ? "1" : "0",
                                    null,
                                    true,
                                    SettingsState.SYSTEM_PACKAGE_NAME);
                        }

                        Setting cwAutoTimeZone =
                                global.getSettingLocked(Global.Wearable.CLOCKWORK_AUTO_TIME_ZONE);
                        if (!cwAutoTimeZone.isNull()) {
                            boolean phone =
                                    String.valueOf(Global.Wearable.SYNC_TIME_ZONE_FROM_PHONE)
                                            .equals(cwAutoTimeZone.getValue());
                            boolean network =
                                    String.valueOf(Global.Wearable.SYNC_TIME_ZONE_FROM_NETWORK)
                                            .equals(cwAutoTimeZone.getValue());
                            global.insertSettingLocked(
                                    Global.AUTO_TIME_ZONE,
                                    phone || network ? "1" : "0",
                                    null,
                                    true,
                                    SettingsState.SYSTEM_PACKAGE_NAME);
                        }
                    }

                    currentVersion = 229;
                }

                // vXXX: Add new settings above this point.

                if (currentVersion != newVersion) {