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

Commit ad450be7 authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Add an AUTO_TIME_ZONE setting so that we can switch timezones while keeping correct time.

Have the NITZ provider honor the new setting before updating the time zone.
parent 00ec8694
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -157268,6 +157268,17 @@
 visibility="public"
>
</field>
<field name="AUTO_TIME_ZONE"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;auto_time_zone&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="BLUETOOTH_DISCOVERABILITY"
 type="java.lang.String"
 transient="false"
+7 −0
Original line number Diff line number Diff line
@@ -1493,6 +1493,12 @@ public final class Settings {
         */
        public static final String AUTO_TIME = "auto_time";

        /**
         * Value to specify if the user prefers the time zone
         * to be automatically fetched from the network (NITZ). 1=yes, 0=no
         */
        public static final String AUTO_TIME_ZONE = "auto_time_zone";

        /**
         * Display times as 12 or 24 hours
         *   12
@@ -1775,6 +1781,7 @@ public final class Settings {
            TEXT_AUTO_PUNCTUATE,
            TEXT_SHOW_PASSWORD,
            AUTO_TIME,
            AUTO_TIME_ZONE,
            TIME_12_24,
            DATE_FORMAT,
            ACCELEROMETER_ROTATION,
+14 −13
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
    <string name="def_airplane_mode_radios" translatable="false">cell,bluetooth,wifi</string>
    <string name="airplane_mode_toggleable_radios" translatable="false">bluetooth,wifi</string>
    <bool name="def_auto_time">true</bool>
    <bool name="def_auto_time_zone">true</bool>
    <bool name="def_accelerometer_rotation">true</bool>
    <!-- Default screen brightness, from 0 to 255.  102 is 40%. -->
    <integer name="def_screen_brightness">102</integer>
+31 −10
Original line number Diff line number Diff line
@@ -16,6 +16,15 @@

package com.android.providers.settings;

import com.android.internal.content.PackageHelper;
import com.android.internal.telephony.RILConstants;
import com.android.internal.util.XmlUtils;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockPatternView;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import android.content.ComponentName;
import android.content.ContentValues;
import android.content.Context;
@@ -36,14 +45,6 @@ import android.provider.Settings.Secure;
import android.text.TextUtils;
import android.util.Log;

import com.android.internal.content.PackageHelper;
import com.android.internal.telephony.RILConstants;
import com.android.internal.util.XmlUtils;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockPatternView;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import java.io.IOException;
import java.util.HashSet;
import java.util.List;
@@ -60,7 +61,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
    // database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion'
    // is properly propagated through your change.  Not doing so will result in a loss of user
    // settings.
    private static final int DATABASE_VERSION = 58;
    private static final int DATABASE_VERSION = 59;

    private Context mContext;

@@ -757,6 +758,23 @@ public class DatabaseHelper extends SQLiteOpenHelper {
            upgradeVersion = 58;
        }

        if (upgradeVersion == 58) {
            /* Add default for new Auto Time Zone */
            db.beginTransaction();
            SQLiteStatement stmt = null;
            try {
                stmt = db.compileStatement("INSERT INTO secure(name,value)"
                        + " VALUES(?,?);");
                loadBooleanSetting(stmt, Settings.System.AUTO_TIME_ZONE,
                        R.bool.def_auto_time_zone); // Sync timezone to NITZ
                db.setTransactionSuccessful();
            } finally {
                db.endTransaction();
                if (stmt != null) stmt.close();
            }
            upgradeVersion = 59;
        }

        // *** Remember to update DATABASE_VERSION above!

        if (upgradeVersion != currentVersion) {
@@ -1068,6 +1086,9 @@ public class DatabaseHelper extends SQLiteOpenHelper {
            loadBooleanSetting(stmt, Settings.System.AUTO_TIME,
                    R.bool.def_auto_time); // Sync time to NITZ

            loadBooleanSetting(stmt, Settings.System.AUTO_TIME_ZONE,
                    R.bool.def_auto_time_zone); // Sync timezone to NITZ

            loadIntegerSetting(stmt, Settings.System.SCREEN_BRIGHTNESS,
                    R.integer.def_screen_brightness);
    
+20 −13
Original line number Diff line number Diff line
@@ -16,6 +16,16 @@

package com.android.internal.telephony.cdma;

import com.android.internal.telephony.CommandException;
import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.DataConnectionTracker;
import com.android.internal.telephony.EventLogTags;
import com.android.internal.telephony.IccCard;
import com.android.internal.telephony.MccTable;
import com.android.internal.telephony.ServiceStateTracker;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.TelephonyProperties;

import android.app.AlarmManager;
import android.content.ContentResolver;
import android.content.Context;
@@ -38,19 +48,8 @@ import android.telephony.cdma.CdmaCellLocation;
import android.text.TextUtils;
import android.util.EventLog;
import android.util.Log;
import android.util.Config;
import android.util.TimeUtils;

import com.android.internal.telephony.CommandException;
import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.DataConnectionTracker;
import com.android.internal.telephony.EventLogTags;
import com.android.internal.telephony.IccCard;
import com.android.internal.telephony.MccTable;
import com.android.internal.telephony.ServiceStateTracker;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.TelephonyProperties;

import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
@@ -987,7 +986,7 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
        mNeedFixZone = false;

        if (zone != null) {
            if (getAutoTime()) {
            if (getAutoTimeZone()) {
                setAndBroadcastNetworkSetTimeZone(zone.getID());
            }
            saveNitzTimeZone(zone.getID());
@@ -1439,7 +1438,7 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
            }

            if (zone != null) {
                if (getAutoTime()) {
                if (getAutoTimeZone()) {
                    setAndBroadcastNetworkSetTimeZone(zone.getID());
                }
                saveNitzTimeZone(zone.getID());
@@ -1529,6 +1528,14 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
        }
    }

    private boolean getAutoTimeZone() {
        try {
            return Settings.System.getInt(cr, Settings.System.AUTO_TIME_ZONE) > 0;
        } catch (SettingNotFoundException snfe) {
            return true;
        }
    }

    private void saveNitzTimeZone(String zoneId) {
        mSavedTimeZone = zoneId;
    }
Loading