Loading packages/SystemUI/src/com/android/systemui/broadcast/BroadcastSender.kt +14 −13 Original line number Diff line number Diff line Loading @@ -24,16 +24,13 @@ class BroadcastSender @Inject constructor( @Background private val bgExecutor: Executor ) { private val WAKE_LOCK_TAG = "SysUI:BroadcastSender" private val WAKE_LOCK_SEND_REASON = "sendInBackground" /** * Sends broadcast via [Context.sendBroadcast] on background thread to avoid blocking * synchronous binder call. */ @AnyThread fun sendBroadcast(intent: Intent) { sendInBackground { sendInBackground("$intent") { context.sendBroadcast(intent) } } Loading @@ -44,7 +41,7 @@ class BroadcastSender @Inject constructor( */ @AnyThread fun sendBroadcast(intent: Intent, receiverPermission: String?) { sendInBackground { sendInBackground("$intent") { context.sendBroadcast(intent, receiverPermission) } } Loading @@ -55,7 +52,7 @@ class BroadcastSender @Inject constructor( */ @AnyThread fun sendBroadcastAsUser(intent: Intent, userHandle: UserHandle) { sendInBackground { sendInBackground("$intent") { context.sendBroadcastAsUser(intent, userHandle) } } Loading @@ -66,7 +63,7 @@ class BroadcastSender @Inject constructor( */ @AnyThread fun sendBroadcastAsUser(intent: Intent, userHandle: UserHandle, receiverPermission: String?) { sendInBackground { sendInBackground("$intent") { context.sendBroadcastAsUser(intent, userHandle, receiverPermission) } } Loading @@ -82,7 +79,7 @@ class BroadcastSender @Inject constructor( receiverPermission: String?, options: Bundle? ) { sendInBackground { sendInBackground("$intent") { context.sendBroadcastAsUser(intent, userHandle, receiverPermission, options) } } Loading @@ -98,7 +95,7 @@ class BroadcastSender @Inject constructor( receiverPermission: String?, appOp: Int ) { sendInBackground { sendInBackground("$intent") { context.sendBroadcastAsUser(intent, userHandle, receiverPermission, appOp) } } Loading @@ -108,7 +105,7 @@ class BroadcastSender @Inject constructor( */ @AnyThread fun closeSystemDialogs() { sendInBackground { sendInBackground("closeSystemDialogs") { context.closeSystemDialogs() } } Loading @@ -116,17 +113,21 @@ class BroadcastSender @Inject constructor( /** * Dispatches parameter on background executor while holding a wakelock. */ private fun sendInBackground(callable: () -> Unit) { private fun sendInBackground(reason: String, callable: () -> Unit) { val broadcastWakelock = wakeLockBuilder.setTag(WAKE_LOCK_TAG) .setMaxTimeout(5000) .build() broadcastWakelock.acquire(WAKE_LOCK_SEND_REASON) broadcastWakelock.acquire(reason) bgExecutor.execute { try { callable.invoke() } finally { broadcastWakelock.release(WAKE_LOCK_SEND_REASON) broadcastWakelock.release(reason) } } } companion object { private const val WAKE_LOCK_TAG = "SysUI:BroadcastSender" } } No newline at end of file packages/SystemUI/src/com/android/systemui/keyguard/KeyguardSliceProvider.java +5 −2 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ import com.android.systemui.statusbar.policy.NextAlarmController; import com.android.systemui.statusbar.policy.ZenModeController; import com.android.systemui.util.wakelock.SettableWakeLock; import com.android.systemui.util.wakelock.WakeLock; import com.android.systemui.util.wakelock.WakeLockLogger; import java.util.Date; import java.util.Locale; Loading Loading @@ -148,6 +149,8 @@ public class KeyguardSliceProvider extends SliceProvider implements private int mStatusBarState; private boolean mMediaIsVisible; private SystemUIAppComponentFactory.ContextAvailableCallback mContextAvailableCallback; @Inject WakeLockLogger mWakeLockLogger; /** * Receiver responsible for time ticking and updating the date format. Loading Loading @@ -305,8 +308,8 @@ public class KeyguardSliceProvider extends SliceProvider implements @Override public boolean onCreateSliceProvider() { mContextAvailableCallback.onContextAvailable(getContext()); mMediaWakeLock = new SettableWakeLock(WakeLock.createPartial(getContext(), "media"), "media"); mMediaWakeLock = new SettableWakeLock( WakeLock.createPartial(getContext(), mWakeLockLogger, "media"), "media"); synchronized (KeyguardSliceProvider.sInstanceLock) { KeyguardSliceProvider oldInstance = KeyguardSliceProvider.sInstance; if (oldInstance != null) { Loading packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java +9 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import com.android.systemui.plugins.log.LogcatEchoTrackerDebug; import com.android.systemui.plugins.log.LogcatEchoTrackerProd; import com.android.systemui.statusbar.notification.NotifPipelineFlags; import com.android.systemui.util.Compile; import com.android.systemui.util.wakelock.WakeLockLog; import dagger.Module; import dagger.Provides; Loading Loading @@ -168,6 +169,14 @@ public class LogModule { false /* systrace */); } /** Provides a logging buffer for {@link com.android.systemui.broadcast.BroadcastSender} */ @Provides @SysUISingleton @WakeLockLog public static LogBuffer provideWakeLockLog(LogBufferFactory factory) { return factory.create("WakeLockLog", 500 /* maxSize */, false /* systrace */); } /** Provides a logging buffer for all logs related to Toasts shown by SystemUI. */ @Provides @SysUISingleton Loading packages/SystemUI/src/com/android/systemui/util/wakelock/DelayedWakeLock.java +4 −2 Original line number Diff line number Diff line Loading @@ -62,6 +62,7 @@ public class DelayedWakeLock implements WakeLock { */ public static class Builder { private final Context mContext; private final WakeLockLogger mLogger; private String mTag; private Handler mHandler; Loading @@ -69,8 +70,9 @@ public class DelayedWakeLock implements WakeLock { * Constructor for DelayedWakeLock.Builder */ @Inject public Builder(Context context) { public Builder(Context context, WakeLockLogger logger) { mContext = context; mLogger = logger; } /** Loading @@ -95,7 +97,7 @@ public class DelayedWakeLock implements WakeLock { * Build the DelayedWakeLock. */ public DelayedWakeLock build() { return new DelayedWakeLock(mHandler, WakeLock.createPartial(mContext, mTag)); return new DelayedWakeLock(mHandler, WakeLock.createPartial(mContext, mLogger, mTag)); } } } packages/SystemUI/src/com/android/systemui/util/wakelock/KeepAwakeAnimationListener.java +1 −1 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ public class KeepAwakeAnimationListener extends AnimatorListenerAdapter public KeepAwakeAnimationListener(Context context) { Assert.isMainThread(); if (sWakeLock == null) { sWakeLock = WakeLock.createPartial(context, "animation"); sWakeLock = WakeLock.createPartial(context, null, "animation"); } } Loading Loading
packages/SystemUI/src/com/android/systemui/broadcast/BroadcastSender.kt +14 −13 Original line number Diff line number Diff line Loading @@ -24,16 +24,13 @@ class BroadcastSender @Inject constructor( @Background private val bgExecutor: Executor ) { private val WAKE_LOCK_TAG = "SysUI:BroadcastSender" private val WAKE_LOCK_SEND_REASON = "sendInBackground" /** * Sends broadcast via [Context.sendBroadcast] on background thread to avoid blocking * synchronous binder call. */ @AnyThread fun sendBroadcast(intent: Intent) { sendInBackground { sendInBackground("$intent") { context.sendBroadcast(intent) } } Loading @@ -44,7 +41,7 @@ class BroadcastSender @Inject constructor( */ @AnyThread fun sendBroadcast(intent: Intent, receiverPermission: String?) { sendInBackground { sendInBackground("$intent") { context.sendBroadcast(intent, receiverPermission) } } Loading @@ -55,7 +52,7 @@ class BroadcastSender @Inject constructor( */ @AnyThread fun sendBroadcastAsUser(intent: Intent, userHandle: UserHandle) { sendInBackground { sendInBackground("$intent") { context.sendBroadcastAsUser(intent, userHandle) } } Loading @@ -66,7 +63,7 @@ class BroadcastSender @Inject constructor( */ @AnyThread fun sendBroadcastAsUser(intent: Intent, userHandle: UserHandle, receiverPermission: String?) { sendInBackground { sendInBackground("$intent") { context.sendBroadcastAsUser(intent, userHandle, receiverPermission) } } Loading @@ -82,7 +79,7 @@ class BroadcastSender @Inject constructor( receiverPermission: String?, options: Bundle? ) { sendInBackground { sendInBackground("$intent") { context.sendBroadcastAsUser(intent, userHandle, receiverPermission, options) } } Loading @@ -98,7 +95,7 @@ class BroadcastSender @Inject constructor( receiverPermission: String?, appOp: Int ) { sendInBackground { sendInBackground("$intent") { context.sendBroadcastAsUser(intent, userHandle, receiverPermission, appOp) } } Loading @@ -108,7 +105,7 @@ class BroadcastSender @Inject constructor( */ @AnyThread fun closeSystemDialogs() { sendInBackground { sendInBackground("closeSystemDialogs") { context.closeSystemDialogs() } } Loading @@ -116,17 +113,21 @@ class BroadcastSender @Inject constructor( /** * Dispatches parameter on background executor while holding a wakelock. */ private fun sendInBackground(callable: () -> Unit) { private fun sendInBackground(reason: String, callable: () -> Unit) { val broadcastWakelock = wakeLockBuilder.setTag(WAKE_LOCK_TAG) .setMaxTimeout(5000) .build() broadcastWakelock.acquire(WAKE_LOCK_SEND_REASON) broadcastWakelock.acquire(reason) bgExecutor.execute { try { callable.invoke() } finally { broadcastWakelock.release(WAKE_LOCK_SEND_REASON) broadcastWakelock.release(reason) } } } companion object { private const val WAKE_LOCK_TAG = "SysUI:BroadcastSender" } } No newline at end of file
packages/SystemUI/src/com/android/systemui/keyguard/KeyguardSliceProvider.java +5 −2 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ import com.android.systemui.statusbar.policy.NextAlarmController; import com.android.systemui.statusbar.policy.ZenModeController; import com.android.systemui.util.wakelock.SettableWakeLock; import com.android.systemui.util.wakelock.WakeLock; import com.android.systemui.util.wakelock.WakeLockLogger; import java.util.Date; import java.util.Locale; Loading Loading @@ -148,6 +149,8 @@ public class KeyguardSliceProvider extends SliceProvider implements private int mStatusBarState; private boolean mMediaIsVisible; private SystemUIAppComponentFactory.ContextAvailableCallback mContextAvailableCallback; @Inject WakeLockLogger mWakeLockLogger; /** * Receiver responsible for time ticking and updating the date format. Loading Loading @@ -305,8 +308,8 @@ public class KeyguardSliceProvider extends SliceProvider implements @Override public boolean onCreateSliceProvider() { mContextAvailableCallback.onContextAvailable(getContext()); mMediaWakeLock = new SettableWakeLock(WakeLock.createPartial(getContext(), "media"), "media"); mMediaWakeLock = new SettableWakeLock( WakeLock.createPartial(getContext(), mWakeLockLogger, "media"), "media"); synchronized (KeyguardSliceProvider.sInstanceLock) { KeyguardSliceProvider oldInstance = KeyguardSliceProvider.sInstance; if (oldInstance != null) { Loading
packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java +9 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import com.android.systemui.plugins.log.LogcatEchoTrackerDebug; import com.android.systemui.plugins.log.LogcatEchoTrackerProd; import com.android.systemui.statusbar.notification.NotifPipelineFlags; import com.android.systemui.util.Compile; import com.android.systemui.util.wakelock.WakeLockLog; import dagger.Module; import dagger.Provides; Loading Loading @@ -168,6 +169,14 @@ public class LogModule { false /* systrace */); } /** Provides a logging buffer for {@link com.android.systemui.broadcast.BroadcastSender} */ @Provides @SysUISingleton @WakeLockLog public static LogBuffer provideWakeLockLog(LogBufferFactory factory) { return factory.create("WakeLockLog", 500 /* maxSize */, false /* systrace */); } /** Provides a logging buffer for all logs related to Toasts shown by SystemUI. */ @Provides @SysUISingleton Loading
packages/SystemUI/src/com/android/systemui/util/wakelock/DelayedWakeLock.java +4 −2 Original line number Diff line number Diff line Loading @@ -62,6 +62,7 @@ public class DelayedWakeLock implements WakeLock { */ public static class Builder { private final Context mContext; private final WakeLockLogger mLogger; private String mTag; private Handler mHandler; Loading @@ -69,8 +70,9 @@ public class DelayedWakeLock implements WakeLock { * Constructor for DelayedWakeLock.Builder */ @Inject public Builder(Context context) { public Builder(Context context, WakeLockLogger logger) { mContext = context; mLogger = logger; } /** Loading @@ -95,7 +97,7 @@ public class DelayedWakeLock implements WakeLock { * Build the DelayedWakeLock. */ public DelayedWakeLock build() { return new DelayedWakeLock(mHandler, WakeLock.createPartial(mContext, mTag)); return new DelayedWakeLock(mHandler, WakeLock.createPartial(mContext, mLogger, mTag)); } } }
packages/SystemUI/src/com/android/systemui/util/wakelock/KeepAwakeAnimationListener.java +1 −1 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ public class KeepAwakeAnimationListener extends AnimatorListenerAdapter public KeepAwakeAnimationListener(Context context) { Assert.isMainThread(); if (sWakeLock == null) { sWakeLock = WakeLock.createPartial(context, "animation"); sWakeLock = WakeLock.createPartial(context, null, "animation"); } } Loading