Loading packages/SystemUI/src/com/android/systemui/SystemUIBinder.java +7 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui; import com.android.systemui.keyguard.KeyguardViewMediator; import com.android.systemui.power.PowerUI; import dagger.Binds; import dagger.Module; Loading @@ -33,4 +34,10 @@ public abstract class SystemUIBinder { @IntoMap @ClassKey(KeyguardViewMediator.class) public abstract SystemUI bindKeyguardViewMediator(KeyguardViewMediator sysui); /** Inject into PowerUI. */ @Binds @IntoMap @ClassKey(PowerUI.class) public abstract SystemUI bindPowerUI(PowerUI sysui); } packages/SystemUI/src/com/android/systemui/broadcast/BroadcastDispatcher.kt +5 −3 Original line number Diff line number Diff line Loading @@ -75,7 +75,7 @@ open class BroadcastDispatcher @Inject constructor ( * @param filter A filter to determine what broadcasts should be dispatched to this receiver. * It will only take into account actions and categories for filtering. * @param handler A handler to dispatch [BroadcastReceiver.onReceive]. By default, it is the * main handler. * main handler. Pass `null` to use the default. * @param user A user handle to determine which broadcast should be dispatched to this receiver. * By default, it is the current user. */ Loading @@ -83,10 +83,12 @@ open class BroadcastDispatcher @Inject constructor ( fun registerReceiver( receiver: BroadcastReceiver, filter: IntentFilter, handler: Handler = mainHandler, handler: Handler? = mainHandler, user: UserHandle = context.user ) { this.handler.obtainMessage(MSG_ADD_RECEIVER, ReceiverData(receiver, filter, handler, user)) this.handler .obtainMessage(MSG_ADD_RECEIVER, ReceiverData(receiver, filter, handler ?: mainHandler, user)) .sendToTarget() } Loading packages/SystemUI/src/com/android/systemui/broadcast/UserBroadcastDispatcher.kt +5 −3 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ import java.util.concurrent.atomic.AtomicBoolean private const val MSG_REGISTER_RECEIVER = 0 private const val MSG_UNREGISTER_RECEIVER = 1 private const val TAG = "UniversalReceiver" private const val TAG = "UserBroadcastDispatcher" private const val DEBUG = false /** Loading Loading @@ -97,7 +97,7 @@ class UserBroadcastDispatcher( private val receiverToReceiverData = ArrayMap<BroadcastReceiver, MutableSet<ReceiverData>>() override fun onReceive(context: Context, intent: Intent) { bgHandler.post(HandleBroadcastRunnable(actionsToReceivers, context, intent)) bgHandler.post(HandleBroadcastRunnable(actionsToReceivers, context, intent, pendingResult)) } /** Loading Loading @@ -160,7 +160,8 @@ class UserBroadcastDispatcher( private class HandleBroadcastRunnable( val actionsToReceivers: Map<String, Set<ReceiverData>>, val context: Context, val intent: Intent val intent: Intent, val pendingResult: PendingResult ) : Runnable { override fun run() { if (DEBUG) Log.w(TAG, "Dispatching $intent") Loading @@ -171,6 +172,7 @@ class UserBroadcastDispatcher( ?.forEach { it.handler.post { if (DEBUG) Log.w(TAG, "Dispatching to ${it.receiver}") it.receiver.pendingResult = pendingResult it.receiver.onReceive(context, intent) } } Loading packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java +2 −1 Original line number Diff line number Diff line Loading @@ -90,6 +90,7 @@ import com.android.systemui.Dependency; import com.android.systemui.Interpolators; import com.android.systemui.MultiListLayout; import com.android.systemui.MultiListLayout.MultiListAdapter; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.plugins.GlobalActions.GlobalActionsManager; Loading Loading @@ -187,7 +188,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED); context.registerReceiver(mBroadcastReceiver, filter); Dependency.get(BroadcastDispatcher.class).registerReceiver(mBroadcastReceiver, filter); ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); Loading packages/SystemUI/src/com/android/systemui/power/PowerUI.java +10 −1 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import com.android.settingslib.utils.ThreadUtils; import com.android.systemui.Dependency; import com.android.systemui.R; import com.android.systemui.SystemUI; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.statusbar.phone.StatusBar; import java.io.FileDescriptor; Loading @@ -53,6 +54,8 @@ import java.time.Duration; import java.util.Arrays; import java.util.concurrent.Future; import javax.inject.Inject; public class PowerUI extends SystemUI { static final String TAG = "PowerUI"; Loading Loading @@ -97,6 +100,12 @@ public class PowerUI extends SystemUI { private IThermalEventListener mSkinThermalEventListener; private IThermalEventListener mUsbThermalEventListener; private final BroadcastDispatcher mBroadcastDispatcher; @Inject public PowerUI(BroadcastDispatcher broadcastDispatcher) { mBroadcastDispatcher = broadcastDispatcher; } public void start() { mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); Loading Loading @@ -211,7 +220,7 @@ public class PowerUI extends SystemUI { filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_USER_SWITCHED); mContext.registerReceiver(this, filter, null, mHandler); mBroadcastDispatcher.registerReceiver(this, filter, mHandler); } @Override Loading Loading
packages/SystemUI/src/com/android/systemui/SystemUIBinder.java +7 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui; import com.android.systemui.keyguard.KeyguardViewMediator; import com.android.systemui.power.PowerUI; import dagger.Binds; import dagger.Module; Loading @@ -33,4 +34,10 @@ public abstract class SystemUIBinder { @IntoMap @ClassKey(KeyguardViewMediator.class) public abstract SystemUI bindKeyguardViewMediator(KeyguardViewMediator sysui); /** Inject into PowerUI. */ @Binds @IntoMap @ClassKey(PowerUI.class) public abstract SystemUI bindPowerUI(PowerUI sysui); }
packages/SystemUI/src/com/android/systemui/broadcast/BroadcastDispatcher.kt +5 −3 Original line number Diff line number Diff line Loading @@ -75,7 +75,7 @@ open class BroadcastDispatcher @Inject constructor ( * @param filter A filter to determine what broadcasts should be dispatched to this receiver. * It will only take into account actions and categories for filtering. * @param handler A handler to dispatch [BroadcastReceiver.onReceive]. By default, it is the * main handler. * main handler. Pass `null` to use the default. * @param user A user handle to determine which broadcast should be dispatched to this receiver. * By default, it is the current user. */ Loading @@ -83,10 +83,12 @@ open class BroadcastDispatcher @Inject constructor ( fun registerReceiver( receiver: BroadcastReceiver, filter: IntentFilter, handler: Handler = mainHandler, handler: Handler? = mainHandler, user: UserHandle = context.user ) { this.handler.obtainMessage(MSG_ADD_RECEIVER, ReceiverData(receiver, filter, handler, user)) this.handler .obtainMessage(MSG_ADD_RECEIVER, ReceiverData(receiver, filter, handler ?: mainHandler, user)) .sendToTarget() } Loading
packages/SystemUI/src/com/android/systemui/broadcast/UserBroadcastDispatcher.kt +5 −3 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ import java.util.concurrent.atomic.AtomicBoolean private const val MSG_REGISTER_RECEIVER = 0 private const val MSG_UNREGISTER_RECEIVER = 1 private const val TAG = "UniversalReceiver" private const val TAG = "UserBroadcastDispatcher" private const val DEBUG = false /** Loading Loading @@ -97,7 +97,7 @@ class UserBroadcastDispatcher( private val receiverToReceiverData = ArrayMap<BroadcastReceiver, MutableSet<ReceiverData>>() override fun onReceive(context: Context, intent: Intent) { bgHandler.post(HandleBroadcastRunnable(actionsToReceivers, context, intent)) bgHandler.post(HandleBroadcastRunnable(actionsToReceivers, context, intent, pendingResult)) } /** Loading Loading @@ -160,7 +160,8 @@ class UserBroadcastDispatcher( private class HandleBroadcastRunnable( val actionsToReceivers: Map<String, Set<ReceiverData>>, val context: Context, val intent: Intent val intent: Intent, val pendingResult: PendingResult ) : Runnable { override fun run() { if (DEBUG) Log.w(TAG, "Dispatching $intent") Loading @@ -171,6 +172,7 @@ class UserBroadcastDispatcher( ?.forEach { it.handler.post { if (DEBUG) Log.w(TAG, "Dispatching to ${it.receiver}") it.receiver.pendingResult = pendingResult it.receiver.onReceive(context, intent) } } Loading
packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java +2 −1 Original line number Diff line number Diff line Loading @@ -90,6 +90,7 @@ import com.android.systemui.Dependency; import com.android.systemui.Interpolators; import com.android.systemui.MultiListLayout; import com.android.systemui.MultiListLayout.MultiListAdapter; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.plugins.GlobalActions.GlobalActionsManager; Loading Loading @@ -187,7 +188,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED); context.registerReceiver(mBroadcastReceiver, filter); Dependency.get(BroadcastDispatcher.class).registerReceiver(mBroadcastReceiver, filter); ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); Loading
packages/SystemUI/src/com/android/systemui/power/PowerUI.java +10 −1 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import com.android.settingslib.utils.ThreadUtils; import com.android.systemui.Dependency; import com.android.systemui.R; import com.android.systemui.SystemUI; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.statusbar.phone.StatusBar; import java.io.FileDescriptor; Loading @@ -53,6 +54,8 @@ import java.time.Duration; import java.util.Arrays; import java.util.concurrent.Future; import javax.inject.Inject; public class PowerUI extends SystemUI { static final String TAG = "PowerUI"; Loading Loading @@ -97,6 +100,12 @@ public class PowerUI extends SystemUI { private IThermalEventListener mSkinThermalEventListener; private IThermalEventListener mUsbThermalEventListener; private final BroadcastDispatcher mBroadcastDispatcher; @Inject public PowerUI(BroadcastDispatcher broadcastDispatcher) { mBroadcastDispatcher = broadcastDispatcher; } public void start() { mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); Loading Loading @@ -211,7 +220,7 @@ public class PowerUI extends SystemUI { filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_USER_SWITCHED); mContext.registerReceiver(this, filter, null, mHandler); mBroadcastDispatcher.registerReceiver(this, filter, mHandler); } @Override Loading