Loading core/java/android/widget/DateTimeView.java +49 −16 Original line number Diff line number Diff line Loading @@ -390,6 +390,18 @@ public class DateTimeView extends TextView { } } /** * @hide */ public static void setReceiverHandler(Handler handler) { ReceiverInfo ri = sReceiverInfo.get(); if (ri == null) { ri = new ReceiverInfo(); sReceiverInfo.set(ri); } ri.setHandler(handler); } private static class ReceiverInfo { private final ArrayList<DateTimeView> mAttachedViews = new ArrayList<DateTimeView>(); private final BroadcastReceiver mReceiver = new BroadcastReceiver() { Loading @@ -416,30 +428,40 @@ public class DateTimeView extends TextView { } }; private Handler mHandler = new Handler(); public void addView(DateTimeView v) { synchronized (mAttachedViews) { final boolean register = mAttachedViews.isEmpty(); mAttachedViews.add(v); if (register) { register(getApplicationContextIfAvailable(v.getContext())); } } } public void removeView(DateTimeView v) { synchronized (mAttachedViews) { mAttachedViews.remove(v); if (mAttachedViews.isEmpty()) { unregister(getApplicationContextIfAvailable(v.getContext())); } } } void updateAll() { synchronized (mAttachedViews) { final int count = mAttachedViews.size(); for (int i = 0; i < count; i++) { mAttachedViews.get(i).clearFormatAndUpdate(); DateTimeView view = mAttachedViews.get(i); view.post(() -> view.clearFormatAndUpdate()); } } } long getSoonestUpdateTime() { long result = Long.MAX_VALUE; synchronized (mAttachedViews) { final int count = mAttachedViews.size(); for (int i = 0; i < count; i++) { final long time = mAttachedViews.get(i).mUpdateTimeMillis; Loading @@ -447,6 +469,7 @@ public class DateTimeView extends TextView { result = time; } } } return result; } Loading @@ -461,11 +484,21 @@ public class DateTimeView extends TextView { filter.addAction(Intent.ACTION_TIME_CHANGED); filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); filter.addAction(Intent.ACTION_TIMEZONE_CHANGED); context.registerReceiver(mReceiver, filter); context.registerReceiver(mReceiver, filter, null, mHandler); } void unregister(Context context) { context.unregisterReceiver(mReceiver); } public void setHandler(Handler handler) { mHandler = handler; synchronized (mAttachedViews) { if (!mAttachedViews.isEmpty()) { unregister(mAttachedViews.get(0).getContext()); register(mAttachedViews.get(0).getContext()); } } } } } packages/SystemUI/plugin/src/com/android/systemui/plugins/PluginInstanceManager.java +0 −5 Original line number Diff line number Diff line Loading @@ -374,11 +374,6 @@ public class PluginInstanceManager<T extends Plugin> { } return getBaseContext().getSystemService(name); } @Override public Context getApplicationContext() { return this; } } static class PluginInfo<T> { Loading packages/SystemUI/src/com/android/systemui/qs/tiles/BatteryTile.java +4 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.content.IntentFilter; import android.graphics.PorterDuff.Mode; import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.Drawable; import android.os.Handler; import android.service.quicksettings.Tile; import android.text.SpannableStringBuilder; import android.text.Spanned; Loading @@ -44,6 +45,7 @@ import com.android.systemui.R; import com.android.systemui.plugins.qs.QS.DetailAdapter; import com.android.systemui.qs.QSTile; import com.android.systemui.qs.external.TileColorPicker; import com.android.systemui.statusbar.phone.PhoneStatusBar; import com.android.systemui.statusbar.policy.BatteryController; import java.text.NumberFormat; Loading Loading @@ -290,7 +292,8 @@ public class BatteryTile extends QSTile<QSTile.State> implements BatteryControll if (!mDetailShown) { mDetailShown = true; v.getContext().registerReceiver(mReceiver, new IntentFilter(Intent.ACTION_TIME_TICK)); new IntentFilter(Intent.ACTION_TIME_TICK), null, PhoneStatusBar.getTimeTickHandler(v.getContext())); } } Loading packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +8 −4 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import com.android.keyguard.KeyguardUpdateMonitorCallback; import com.android.systemui.R; import com.android.systemui.statusbar.phone.KeyguardIndicationTextView; import com.android.systemui.statusbar.phone.LockIcon; import com.android.systemui.statusbar.phone.PhoneStatusBar; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; /** Loading Loading @@ -107,7 +108,8 @@ public class KeyguardIndicationController { KeyguardUpdateMonitor.getInstance(context).registerCallback(mUpdateMonitor); context.registerReceiverAsUser(mTickReceiver, UserHandle.SYSTEM, new IntentFilter(Intent.ACTION_TIME_TICK), null, null); new IntentFilter(Intent.ACTION_TIME_TICK), null, PhoneStatusBar.getTimeTickHandler(mContext)); updateDisclosure(); } Loading Loading @@ -374,9 +376,11 @@ public class KeyguardIndicationController { BroadcastReceiver mTickReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { mHandler.post(() -> { if (mVisible) { updateIndication(); } }); } }; Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +23 −6 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.HandlerThread; import android.os.IBinder; import android.os.Looper; import android.os.Message; import android.os.PowerManager; import android.os.Process; Loading Loading @@ -116,6 +117,7 @@ import android.view.WindowManagerGlobal; import android.view.accessibility.AccessibilityEvent; import android.view.animation.AccelerateInterpolator; import android.view.animation.Interpolator; import android.widget.DateTimeView; import android.widget.ImageView; import android.widget.TextView; Loading @@ -136,6 +138,7 @@ import com.android.systemui.EventLogTags; import com.android.systemui.Interpolators; import com.android.systemui.Prefs; import com.android.systemui.R; import com.android.systemui.SystemUIApplication; import com.android.systemui.SystemUIFactory; import com.android.systemui.classifier.FalsingLog; import com.android.systemui.classifier.FalsingManager; Loading Loading @@ -426,6 +429,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, private int mNavigationIconHints = 0; private HandlerThread mHandlerThread; private HandlerThread mTimeTickThread; private Handler mTimeTickHandler; // ensure quick settings is disabled until the current user makes it through the setup wizard private boolean mUserSetup = false; Loading Loading @@ -689,6 +694,15 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, mScrimSrcModeEnabled = mContext.getResources().getBoolean( R.bool.config_status_bar_scrim_behind_use_src); // Background thread for any controllers that need it. mHandlerThread = new HandlerThread(TAG, Process.THREAD_PRIORITY_BACKGROUND); mHandlerThread.start(); mTimeTickThread = new HandlerThread("TimeTick"); mTimeTickThread.start(); mTimeTickHandler = new Handler(mTimeTickThread.getLooper()); DateTimeView.setReceiverHandler(mTimeTickHandler); putComponent(PhoneStatusBar.class, this); super.start(); // calls createAndAddWindows() mMediaSessionManager Loading Loading @@ -721,7 +735,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mUpdateCallback); mDozeServiceHost = new DozeServiceHost(); putComponent(DozeHost.class, mDozeServiceHost); putComponent(PhoneStatusBar.class, this); setControllerUsers(); Loading @@ -741,7 +754,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, // ================================================================================ protected PhoneStatusBarView makeStatusBarView() { final Context context = mContext; updateDisplaySize(); // populates mDisplayMetrics updateResources(); Loading Loading @@ -887,10 +899,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, mStatusBarView.setScrimController(mScrimController); mDozeScrimController = new DozeScrimController(mScrimController, context, mStackScroller); // Background thread for any controllers that need it. mHandlerThread = new HandlerThread(TAG, Process.THREAD_PRIORITY_BACKGROUND); mHandlerThread.start(); // Other icons mLocationController = new LocationControllerImpl(mContext, mHandlerThread.getLooper()); // will post a notification Loading Loading @@ -1034,6 +1042,15 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, return mStatusBarView; } public Handler getTimeTickHandler() { return mTimeTickHandler; } public static Handler getTimeTickHandler(Context context) { return ((SystemUIApplication) context.getApplicationContext()) .getComponent(PhoneStatusBar.class).getTimeTickHandler(); } private void initEmergencyCryptkeeperText() { View emergencyViewStub = mStatusBarWindow.findViewById(R.id.emergency_cryptkeeper_text); if (mNetworkController.hasEmergencyCryptKeeperText()) { Loading Loading
core/java/android/widget/DateTimeView.java +49 −16 Original line number Diff line number Diff line Loading @@ -390,6 +390,18 @@ public class DateTimeView extends TextView { } } /** * @hide */ public static void setReceiverHandler(Handler handler) { ReceiverInfo ri = sReceiverInfo.get(); if (ri == null) { ri = new ReceiverInfo(); sReceiverInfo.set(ri); } ri.setHandler(handler); } private static class ReceiverInfo { private final ArrayList<DateTimeView> mAttachedViews = new ArrayList<DateTimeView>(); private final BroadcastReceiver mReceiver = new BroadcastReceiver() { Loading @@ -416,30 +428,40 @@ public class DateTimeView extends TextView { } }; private Handler mHandler = new Handler(); public void addView(DateTimeView v) { synchronized (mAttachedViews) { final boolean register = mAttachedViews.isEmpty(); mAttachedViews.add(v); if (register) { register(getApplicationContextIfAvailable(v.getContext())); } } } public void removeView(DateTimeView v) { synchronized (mAttachedViews) { mAttachedViews.remove(v); if (mAttachedViews.isEmpty()) { unregister(getApplicationContextIfAvailable(v.getContext())); } } } void updateAll() { synchronized (mAttachedViews) { final int count = mAttachedViews.size(); for (int i = 0; i < count; i++) { mAttachedViews.get(i).clearFormatAndUpdate(); DateTimeView view = mAttachedViews.get(i); view.post(() -> view.clearFormatAndUpdate()); } } } long getSoonestUpdateTime() { long result = Long.MAX_VALUE; synchronized (mAttachedViews) { final int count = mAttachedViews.size(); for (int i = 0; i < count; i++) { final long time = mAttachedViews.get(i).mUpdateTimeMillis; Loading @@ -447,6 +469,7 @@ public class DateTimeView extends TextView { result = time; } } } return result; } Loading @@ -461,11 +484,21 @@ public class DateTimeView extends TextView { filter.addAction(Intent.ACTION_TIME_CHANGED); filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); filter.addAction(Intent.ACTION_TIMEZONE_CHANGED); context.registerReceiver(mReceiver, filter); context.registerReceiver(mReceiver, filter, null, mHandler); } void unregister(Context context) { context.unregisterReceiver(mReceiver); } public void setHandler(Handler handler) { mHandler = handler; synchronized (mAttachedViews) { if (!mAttachedViews.isEmpty()) { unregister(mAttachedViews.get(0).getContext()); register(mAttachedViews.get(0).getContext()); } } } } }
packages/SystemUI/plugin/src/com/android/systemui/plugins/PluginInstanceManager.java +0 −5 Original line number Diff line number Diff line Loading @@ -374,11 +374,6 @@ public class PluginInstanceManager<T extends Plugin> { } return getBaseContext().getSystemService(name); } @Override public Context getApplicationContext() { return this; } } static class PluginInfo<T> { Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/BatteryTile.java +4 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.content.IntentFilter; import android.graphics.PorterDuff.Mode; import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.Drawable; import android.os.Handler; import android.service.quicksettings.Tile; import android.text.SpannableStringBuilder; import android.text.Spanned; Loading @@ -44,6 +45,7 @@ import com.android.systemui.R; import com.android.systemui.plugins.qs.QS.DetailAdapter; import com.android.systemui.qs.QSTile; import com.android.systemui.qs.external.TileColorPicker; import com.android.systemui.statusbar.phone.PhoneStatusBar; import com.android.systemui.statusbar.policy.BatteryController; import java.text.NumberFormat; Loading Loading @@ -290,7 +292,8 @@ public class BatteryTile extends QSTile<QSTile.State> implements BatteryControll if (!mDetailShown) { mDetailShown = true; v.getContext().registerReceiver(mReceiver, new IntentFilter(Intent.ACTION_TIME_TICK)); new IntentFilter(Intent.ACTION_TIME_TICK), null, PhoneStatusBar.getTimeTickHandler(v.getContext())); } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +8 −4 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import com.android.keyguard.KeyguardUpdateMonitorCallback; import com.android.systemui.R; import com.android.systemui.statusbar.phone.KeyguardIndicationTextView; import com.android.systemui.statusbar.phone.LockIcon; import com.android.systemui.statusbar.phone.PhoneStatusBar; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; /** Loading Loading @@ -107,7 +108,8 @@ public class KeyguardIndicationController { KeyguardUpdateMonitor.getInstance(context).registerCallback(mUpdateMonitor); context.registerReceiverAsUser(mTickReceiver, UserHandle.SYSTEM, new IntentFilter(Intent.ACTION_TIME_TICK), null, null); new IntentFilter(Intent.ACTION_TIME_TICK), null, PhoneStatusBar.getTimeTickHandler(mContext)); updateDisclosure(); } Loading Loading @@ -374,9 +376,11 @@ public class KeyguardIndicationController { BroadcastReceiver mTickReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { mHandler.post(() -> { if (mVisible) { updateIndication(); } }); } }; Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +23 −6 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.HandlerThread; import android.os.IBinder; import android.os.Looper; import android.os.Message; import android.os.PowerManager; import android.os.Process; Loading Loading @@ -116,6 +117,7 @@ import android.view.WindowManagerGlobal; import android.view.accessibility.AccessibilityEvent; import android.view.animation.AccelerateInterpolator; import android.view.animation.Interpolator; import android.widget.DateTimeView; import android.widget.ImageView; import android.widget.TextView; Loading @@ -136,6 +138,7 @@ import com.android.systemui.EventLogTags; import com.android.systemui.Interpolators; import com.android.systemui.Prefs; import com.android.systemui.R; import com.android.systemui.SystemUIApplication; import com.android.systemui.SystemUIFactory; import com.android.systemui.classifier.FalsingLog; import com.android.systemui.classifier.FalsingManager; Loading Loading @@ -426,6 +429,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, private int mNavigationIconHints = 0; private HandlerThread mHandlerThread; private HandlerThread mTimeTickThread; private Handler mTimeTickHandler; // ensure quick settings is disabled until the current user makes it through the setup wizard private boolean mUserSetup = false; Loading Loading @@ -689,6 +694,15 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, mScrimSrcModeEnabled = mContext.getResources().getBoolean( R.bool.config_status_bar_scrim_behind_use_src); // Background thread for any controllers that need it. mHandlerThread = new HandlerThread(TAG, Process.THREAD_PRIORITY_BACKGROUND); mHandlerThread.start(); mTimeTickThread = new HandlerThread("TimeTick"); mTimeTickThread.start(); mTimeTickHandler = new Handler(mTimeTickThread.getLooper()); DateTimeView.setReceiverHandler(mTimeTickHandler); putComponent(PhoneStatusBar.class, this); super.start(); // calls createAndAddWindows() mMediaSessionManager Loading Loading @@ -721,7 +735,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mUpdateCallback); mDozeServiceHost = new DozeServiceHost(); putComponent(DozeHost.class, mDozeServiceHost); putComponent(PhoneStatusBar.class, this); setControllerUsers(); Loading @@ -741,7 +754,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, // ================================================================================ protected PhoneStatusBarView makeStatusBarView() { final Context context = mContext; updateDisplaySize(); // populates mDisplayMetrics updateResources(); Loading Loading @@ -887,10 +899,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, mStatusBarView.setScrimController(mScrimController); mDozeScrimController = new DozeScrimController(mScrimController, context, mStackScroller); // Background thread for any controllers that need it. mHandlerThread = new HandlerThread(TAG, Process.THREAD_PRIORITY_BACKGROUND); mHandlerThread.start(); // Other icons mLocationController = new LocationControllerImpl(mContext, mHandlerThread.getLooper()); // will post a notification Loading Loading @@ -1034,6 +1042,15 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, return mStatusBarView; } public Handler getTimeTickHandler() { return mTimeTickHandler; } public static Handler getTimeTickHandler(Context context) { return ((SystemUIApplication) context.getApplicationContext()) .getComponent(PhoneStatusBar.class).getTimeTickHandler(); } private void initEmergencyCryptkeeperText() { View emergencyViewStub = mStatusBarWindow.findViewById(R.id.emergency_cryptkeeper_text); if (mNetworkController.hasEmergencyCryptKeeperText()) { Loading