summaryrefslogtreecommitdiffstats
path: root/telephony
diff options
context:
space:
mode:
authorJohn Wang <johnwang@google.com>2011-01-18 11:43:53 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-01-18 11:43:53 -0800
commit8d48c3d21f78cc2bc94682731d64b23ec0899824 (patch)
treee7d4c388b4788cdc5a0d0bb24a4cbcff0504051c /telephony
parent3a4d547c588dc3a1abb48988595dc17874660bb8 (diff)
parent759aca9d20e76a99df556304caf9171da18c7f51 (diff)
downloadframeworks_base-8d48c3d21f78cc2bc94682731d64b23ec0899824.zip
frameworks_base-8d48c3d21f78cc2bc94682731d64b23ec0899824.tar.gz
frameworks_base-8d48c3d21f78cc2bc94682731d64b23ec0899824.tar.bz2
Merge "Enable AUTO_TIME_ZONE settings." into honeycomb
Diffstat (limited to 'telephony')
-rwxr-xr-xtelephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java34
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java34
2 files changed, 55 insertions, 13 deletions
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
index 2c5aa3c..19e7fae 100755
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
@@ -152,9 +152,16 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
private ContentObserver mAutoTimeObserver = new ContentObserver(new Handler()) {
@Override
public void onChange(boolean selfChange) {
- Log.i("CdmaServiceStateTracker", "Auto time state called ...");
- revertToNitz();
+ Log.i("CdmaServiceStateTracker", "Auto time state changed");
+ revertToNitzTime();
+ }
+ };
+ private ContentObserver mAutoTimeZoneObserver = new ContentObserver(new Handler()) {
+ @Override
+ public void onChange(boolean selfChange) {
+ Log.i("CdmaServiceStateTracker", "Auto time zone state changed");
+ revertToNitzTimeZone();
}
};
@@ -194,6 +201,9 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
cr.registerContentObserver(
Settings.System.getUriFor(Settings.System.AUTO_TIME), true,
mAutoTimeObserver);
+ cr.registerContentObserver(
+ Settings.System.getUriFor(Settings.System.AUTO_TIME_ZONE), true,
+ mAutoTimeZoneObserver);
setSignalStrengthDefaultValues();
mNeedToRegForRuimLoaded = true;
@@ -212,6 +222,7 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
cm.unSetOnSignalStrengthUpdate(this);
cm.unSetOnNITZTime(this);
cr.unregisterContentObserver(this.mAutoTimeObserver);
+ cr.unregisterContentObserver(this.mAutoTimeZoneObserver);
}
@Override
@@ -1582,20 +1593,29 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
phone.getContext().sendStickyBroadcast(intent);
}
- private void revertToNitz() {
+ private void revertToNitzTime() {
if (Settings.System.getInt(cr, Settings.System.AUTO_TIME, 0) == 0) {
return;
}
- Log.d(LOG_TAG, "Reverting to NITZ: tz='" + mSavedTimeZone
- + "' mSavedTime=" + mSavedTime
+ Log.d(LOG_TAG, "Reverting to NITZ Time: mSavedTime=" + mSavedTime
+ " mSavedAtTime=" + mSavedAtTime);
- if (mSavedTimeZone != null && mSavedTime != 0 && mSavedAtTime != 0) {
- setAndBroadcastNetworkSetTimeZone(mSavedTimeZone);
+ if (mSavedTime != 0 && mSavedAtTime != 0) {
setAndBroadcastNetworkSetTime(mSavedTime
+ (SystemClock.elapsedRealtime() - mSavedAtTime));
}
}
+ private void revertToNitzTimeZone() {
+ if (Settings.System.getInt(phone.getContext().getContentResolver(),
+ Settings.System.AUTO_TIME_ZONE, 0) == 0) {
+ return;
+ }
+ Log.d(LOG_TAG, "Reverting to NITZ TimeZone: tz='" + mSavedTimeZone);
+ if (mSavedTimeZone != null) {
+ setAndBroadcastNetworkSetTimeZone(mSavedTimeZone);
+ }
+ }
+
private boolean isSidsAllZeros() {
if (mHomeSystemId != null) {
for (int i=0; i < mHomeSystemId.length; i++) {
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
index b04d4b9..c107d17 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
@@ -181,7 +181,15 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
@Override
public void onChange(boolean selfChange) {
Log.i("GsmServiceStateTracker", "Auto time state changed");
- revertToNitz();
+ revertToNitzTime();
+ }
+ };
+
+ private ContentObserver mAutoTimeZoneObserver = new ContentObserver(new Handler()) {
+ @Override
+ public void onChange(boolean selfChange) {
+ Log.i("GsmServiceStateTracker", "Auto time zone state changed");
+ revertToNitzTimeZone();
}
};
@@ -220,6 +228,10 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
cr.registerContentObserver(
Settings.System.getUriFor(Settings.System.AUTO_TIME), true,
mAutoTimeObserver);
+ cr.registerContentObserver(
+ Settings.System.getUriFor(Settings.System.AUTO_TIME_ZONE), true,
+ mAutoTimeZoneObserver);
+
setSignalStrengthDefaultValues();
mNeedToRegForSimLoaded = true;
@@ -244,6 +256,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
cm.unSetOnRestrictedStateChanged(this);
cm.unSetOnNITZTime(this);
cr.unregisterContentObserver(this.mAutoTimeObserver);
+ cr.unregisterContentObserver(this.mAutoTimeZoneObserver);
}
protected void finalize() {
@@ -1613,21 +1626,30 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
phone.getContext().sendStickyBroadcast(intent);
}
- private void revertToNitz() {
+ private void revertToNitzTime() {
if (Settings.System.getInt(phone.getContext().getContentResolver(),
Settings.System.AUTO_TIME, 0) == 0) {
return;
}
- Log.d(LOG_TAG, "Reverting to NITZ: tz='" + mSavedTimeZone
- + "' mSavedTime=" + mSavedTime
+ Log.d(LOG_TAG, "Reverting to NITZ Time: mSavedTime=" + mSavedTime
+ " mSavedAtTime=" + mSavedAtTime);
- if (mSavedTimeZone != null && mSavedTime != 0 && mSavedAtTime != 0) {
- setAndBroadcastNetworkSetTimeZone(mSavedTimeZone);
+ if (mSavedTime != 0 && mSavedAtTime != 0) {
setAndBroadcastNetworkSetTime(mSavedTime
+ (SystemClock.elapsedRealtime() - mSavedAtTime));
}
}
+ private void revertToNitzTimeZone() {
+ if (Settings.System.getInt(phone.getContext().getContentResolver(),
+ Settings.System.AUTO_TIME_ZONE, 0) == 0) {
+ return;
+ }
+ Log.d(LOG_TAG, "Reverting to NITZ TimeZone: tz='" + mSavedTimeZone);
+ if (mSavedTimeZone != null) {
+ setAndBroadcastNetworkSetTimeZone(mSavedTimeZone);
+ }
+ }
+
/**
* Post a notification to NotificationManager for restricted state
*