Loading core/java/com/android/internal/widget/DigitalClock.java +63 −40 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.res.Resources; import android.database.ContentObserver; import android.graphics.Typeface; import android.os.Handler; Loading @@ -33,6 +32,7 @@ import android.view.View; import android.widget.LinearLayout; import android.widget.TextView; import java.lang.ref.WeakReference; import java.text.DateFormatSymbols; import java.util.Calendar; Loading @@ -49,24 +49,39 @@ public class DigitalClock extends LinearLayout { private TextView mTimeDisplay; private AmPm mAmPm; private ContentObserver mFormatChangeObserver; private boolean mLive = true; private boolean mAttached; private int mAttached = 0; // for debugging - tells us whether attach/detach is unbalanced /* called by system on minute ticks */ private final Handler mHandler = new Handler(); private final BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { private BroadcastReceiver mIntentReceiver; private static class TimeChangedReceiver extends BroadcastReceiver { private WeakReference<DigitalClock> mClock; private Context mContext; public TimeChangedReceiver(DigitalClock clock) { mClock = new WeakReference<DigitalClock>(clock); mContext = clock.getContext(); } @Override public void onReceive(Context context, Intent intent) { if (mLive && intent.getAction().equals( Intent.ACTION_TIMEZONE_CHANGED)) { mCalendar = Calendar.getInstance(); } // Post a runnable to avoid blocking the broadcast. mHandler.post(new Runnable() { final boolean timezoneChanged = intent.getAction().equals(Intent.ACTION_TIMEZONE_CHANGED); final DigitalClock clock = mClock.get(); if (clock != null) { clock.mHandler.post(new Runnable() { public void run() { updateTime(); if (timezoneChanged) { clock.mCalendar = Calendar.getInstance(); } clock.updateTime(); } }); } else { mContext.unregisterReceiver(this); } } }; Loading Loading @@ -94,14 +109,23 @@ public class DigitalClock extends LinearLayout { } } private class FormatChangeObserver extends ContentObserver { public FormatChangeObserver() { private static class FormatChangeObserver extends ContentObserver { private WeakReference<DigitalClock> mClock; private Context mContext; public FormatChangeObserver(DigitalClock clock) { super(new Handler()); mClock = new WeakReference<DigitalClock>(clock); mContext = clock.getContext(); } @Override public void onChange(boolean selfChange) { setDateFormat(); updateTime(); DigitalClock digitalClock = mClock.get(); if (digitalClock != null) { digitalClock.setDateFormat(); digitalClock.updateTime(); } else { mContext.getContentResolver().unregisterContentObserver(this); } } } Loading Loading @@ -129,11 +153,11 @@ public class DigitalClock extends LinearLayout { protected void onAttachedToWindow() { super.onAttachedToWindow(); if (mAttached) return; mAttached = true; mAttached++; if (mLive) { /* monitor time ticks, time changed, timezone */ if (mIntentReceiver == null) { mIntentReceiver = new TimeChangedReceiver(this); IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_TIME_TICK); filter.addAction(Intent.ACTION_TIME_CHANGED); Loading @@ -142,9 +166,11 @@ public class DigitalClock extends LinearLayout { } /* monitor 12/24-hour display preference */ mFormatChangeObserver = new FormatChangeObserver(); if (mFormatChangeObserver == null) { mFormatChangeObserver = new FormatChangeObserver(this); mContext.getContentResolver().registerContentObserver( Settings.System.CONTENT_URI, true, mFormatChangeObserver); } updateTime(); } Loading @@ -153,16 +179,19 @@ public class DigitalClock extends LinearLayout { protected void onDetachedFromWindow() { super.onDetachedFromWindow(); if (!mAttached) return; mAttached = false; mAttached--; if (mLive) { if (mIntentReceiver != null) { mContext.unregisterReceiver(mIntentReceiver); } if (mFormatChangeObserver != null) { mContext.getContentResolver().unregisterContentObserver( mFormatChangeObserver); } mFormatChangeObserver = null; mIntentReceiver = null; } void updateTime(Calendar c) { mCalendar = c; Loading @@ -170,9 +199,7 @@ public class DigitalClock extends LinearLayout { } private void updateTime() { if (mLive) { mCalendar.setTimeInMillis(System.currentTimeMillis()); } CharSequence newTime = DateFormat.format(mFormat, mCalendar); mTimeDisplay.setText(newTime); Loading @@ -184,8 +211,4 @@ public class DigitalClock extends LinearLayout { ? M24 : M12; mAmPm.setShowAmPm(mFormat.equals(M12)); } void setLive(boolean live) { mLive = live; } } policy/src/com/android/internal/policy/impl/AccountUnlockScreen.java +6 −3 Original line number Diff line number Diff line Loading @@ -62,8 +62,8 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree */ private static final int AWAKE_POKE_MILLIS = 30000; private final KeyguardScreenCallback mCallback; private final LockPatternUtils mLockPatternUtils; private KeyguardScreenCallback mCallback; private LockPatternUtils mLockPatternUtils; private KeyguardUpdateMonitor mUpdateMonitor; private TextView mTopHeader; Loading Loading @@ -159,7 +159,10 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree if (mCheckingDialog != null) { mCheckingDialog.hide(); } mUpdateMonitor.removeCallback(this); mUpdateMonitor.removeCallback(this); // this must be first mCallback = null; mLockPatternUtils = null; mUpdateMonitor = null; } /** {@inheritDoc} */ Loading policy/src/com/android/internal/policy/impl/KeyguardViewManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -223,8 +223,8 @@ public class KeyguardViewManager implements KeyguardWindowController { mKeyguardHost.postDelayed(new Runnable() { public void run() { synchronized (KeyguardViewManager.this) { mKeyguardHost.removeView(lastView); lastView.cleanUp(); mKeyguardHost.removeView(lastView); } } }, 500); Loading policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java +2 −0 Original line number Diff line number Diff line Loading @@ -495,8 +495,10 @@ public class LockPatternKeyguardView extends KeyguardViewBase { public void cleanUp() { ((KeyguardScreen) mLockScreen).onPause(); ((KeyguardScreen) mLockScreen).cleanUp(); this.removeView(mLockScreen); ((KeyguardScreen) mUnlockScreen).onPause(); ((KeyguardScreen) mUnlockScreen).cleanUp(); this.removeView(mUnlockScreen); } private boolean isSecure() { Loading policy/src/com/android/internal/policy/impl/LockScreen.java +9 −6 Original line number Diff line number Diff line Loading @@ -55,9 +55,9 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM private Status mStatus = Status.Normal; private final LockPatternUtils mLockPatternUtils; private final KeyguardUpdateMonitor mUpdateMonitor; private final KeyguardScreenCallback mCallback; private LockPatternUtils mLockPatternUtils; private KeyguardUpdateMonitor mUpdateMonitor; private KeyguardScreenCallback mCallback; private TextView mCarrier; private SlidingTab mSelector; Loading Loading @@ -225,8 +225,8 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM setFocusableInTouchMode(true); setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); updateMonitor.registerInfoCallback(this); updateMonitor.registerSimStateCallback(this); mUpdateMonitor.registerInfoCallback(this); mUpdateMonitor.registerSimStateCallback(this); mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE); mSilentMode = isSilentMode(); Loading Loading @@ -668,7 +668,10 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM /** {@inheritDoc} */ public void cleanUp() { mUpdateMonitor.removeCallback(this); mUpdateMonitor.removeCallback(this); // this must be first mLockPatternUtils = null; mUpdateMonitor = null; mCallback = null; } /** {@inheritDoc} */ Loading Loading
core/java/com/android/internal/widget/DigitalClock.java +63 −40 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.res.Resources; import android.database.ContentObserver; import android.graphics.Typeface; import android.os.Handler; Loading @@ -33,6 +32,7 @@ import android.view.View; import android.widget.LinearLayout; import android.widget.TextView; import java.lang.ref.WeakReference; import java.text.DateFormatSymbols; import java.util.Calendar; Loading @@ -49,24 +49,39 @@ public class DigitalClock extends LinearLayout { private TextView mTimeDisplay; private AmPm mAmPm; private ContentObserver mFormatChangeObserver; private boolean mLive = true; private boolean mAttached; private int mAttached = 0; // for debugging - tells us whether attach/detach is unbalanced /* called by system on minute ticks */ private final Handler mHandler = new Handler(); private final BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { private BroadcastReceiver mIntentReceiver; private static class TimeChangedReceiver extends BroadcastReceiver { private WeakReference<DigitalClock> mClock; private Context mContext; public TimeChangedReceiver(DigitalClock clock) { mClock = new WeakReference<DigitalClock>(clock); mContext = clock.getContext(); } @Override public void onReceive(Context context, Intent intent) { if (mLive && intent.getAction().equals( Intent.ACTION_TIMEZONE_CHANGED)) { mCalendar = Calendar.getInstance(); } // Post a runnable to avoid blocking the broadcast. mHandler.post(new Runnable() { final boolean timezoneChanged = intent.getAction().equals(Intent.ACTION_TIMEZONE_CHANGED); final DigitalClock clock = mClock.get(); if (clock != null) { clock.mHandler.post(new Runnable() { public void run() { updateTime(); if (timezoneChanged) { clock.mCalendar = Calendar.getInstance(); } clock.updateTime(); } }); } else { mContext.unregisterReceiver(this); } } }; Loading Loading @@ -94,14 +109,23 @@ public class DigitalClock extends LinearLayout { } } private class FormatChangeObserver extends ContentObserver { public FormatChangeObserver() { private static class FormatChangeObserver extends ContentObserver { private WeakReference<DigitalClock> mClock; private Context mContext; public FormatChangeObserver(DigitalClock clock) { super(new Handler()); mClock = new WeakReference<DigitalClock>(clock); mContext = clock.getContext(); } @Override public void onChange(boolean selfChange) { setDateFormat(); updateTime(); DigitalClock digitalClock = mClock.get(); if (digitalClock != null) { digitalClock.setDateFormat(); digitalClock.updateTime(); } else { mContext.getContentResolver().unregisterContentObserver(this); } } } Loading Loading @@ -129,11 +153,11 @@ public class DigitalClock extends LinearLayout { protected void onAttachedToWindow() { super.onAttachedToWindow(); if (mAttached) return; mAttached = true; mAttached++; if (mLive) { /* monitor time ticks, time changed, timezone */ if (mIntentReceiver == null) { mIntentReceiver = new TimeChangedReceiver(this); IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_TIME_TICK); filter.addAction(Intent.ACTION_TIME_CHANGED); Loading @@ -142,9 +166,11 @@ public class DigitalClock extends LinearLayout { } /* monitor 12/24-hour display preference */ mFormatChangeObserver = new FormatChangeObserver(); if (mFormatChangeObserver == null) { mFormatChangeObserver = new FormatChangeObserver(this); mContext.getContentResolver().registerContentObserver( Settings.System.CONTENT_URI, true, mFormatChangeObserver); } updateTime(); } Loading @@ -153,16 +179,19 @@ public class DigitalClock extends LinearLayout { protected void onDetachedFromWindow() { super.onDetachedFromWindow(); if (!mAttached) return; mAttached = false; mAttached--; if (mLive) { if (mIntentReceiver != null) { mContext.unregisterReceiver(mIntentReceiver); } if (mFormatChangeObserver != null) { mContext.getContentResolver().unregisterContentObserver( mFormatChangeObserver); } mFormatChangeObserver = null; mIntentReceiver = null; } void updateTime(Calendar c) { mCalendar = c; Loading @@ -170,9 +199,7 @@ public class DigitalClock extends LinearLayout { } private void updateTime() { if (mLive) { mCalendar.setTimeInMillis(System.currentTimeMillis()); } CharSequence newTime = DateFormat.format(mFormat, mCalendar); mTimeDisplay.setText(newTime); Loading @@ -184,8 +211,4 @@ public class DigitalClock extends LinearLayout { ? M24 : M12; mAmPm.setShowAmPm(mFormat.equals(M12)); } void setLive(boolean live) { mLive = live; } }
policy/src/com/android/internal/policy/impl/AccountUnlockScreen.java +6 −3 Original line number Diff line number Diff line Loading @@ -62,8 +62,8 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree */ private static final int AWAKE_POKE_MILLIS = 30000; private final KeyguardScreenCallback mCallback; private final LockPatternUtils mLockPatternUtils; private KeyguardScreenCallback mCallback; private LockPatternUtils mLockPatternUtils; private KeyguardUpdateMonitor mUpdateMonitor; private TextView mTopHeader; Loading Loading @@ -159,7 +159,10 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree if (mCheckingDialog != null) { mCheckingDialog.hide(); } mUpdateMonitor.removeCallback(this); mUpdateMonitor.removeCallback(this); // this must be first mCallback = null; mLockPatternUtils = null; mUpdateMonitor = null; } /** {@inheritDoc} */ Loading
policy/src/com/android/internal/policy/impl/KeyguardViewManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -223,8 +223,8 @@ public class KeyguardViewManager implements KeyguardWindowController { mKeyguardHost.postDelayed(new Runnable() { public void run() { synchronized (KeyguardViewManager.this) { mKeyguardHost.removeView(lastView); lastView.cleanUp(); mKeyguardHost.removeView(lastView); } } }, 500); Loading
policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java +2 −0 Original line number Diff line number Diff line Loading @@ -495,8 +495,10 @@ public class LockPatternKeyguardView extends KeyguardViewBase { public void cleanUp() { ((KeyguardScreen) mLockScreen).onPause(); ((KeyguardScreen) mLockScreen).cleanUp(); this.removeView(mLockScreen); ((KeyguardScreen) mUnlockScreen).onPause(); ((KeyguardScreen) mUnlockScreen).cleanUp(); this.removeView(mUnlockScreen); } private boolean isSecure() { Loading
policy/src/com/android/internal/policy/impl/LockScreen.java +9 −6 Original line number Diff line number Diff line Loading @@ -55,9 +55,9 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM private Status mStatus = Status.Normal; private final LockPatternUtils mLockPatternUtils; private final KeyguardUpdateMonitor mUpdateMonitor; private final KeyguardScreenCallback mCallback; private LockPatternUtils mLockPatternUtils; private KeyguardUpdateMonitor mUpdateMonitor; private KeyguardScreenCallback mCallback; private TextView mCarrier; private SlidingTab mSelector; Loading Loading @@ -225,8 +225,8 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM setFocusableInTouchMode(true); setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); updateMonitor.registerInfoCallback(this); updateMonitor.registerSimStateCallback(this); mUpdateMonitor.registerInfoCallback(this); mUpdateMonitor.registerSimStateCallback(this); mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE); mSilentMode = isSilentMode(); Loading Loading @@ -668,7 +668,10 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM /** {@inheritDoc} */ public void cleanUp() { mUpdateMonitor.removeCallback(this); mUpdateMonitor.removeCallback(this); // this must be first mLockPatternUtils = null; mUpdateMonitor = null; mCallback = null; } /** {@inheritDoc} */ Loading