Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/SharedCoordinatorLogger.kt→packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityManagerKt.kt +32 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading @@ -14,33 +14,19 @@ * limitations under the License. */ package com.android.systemui.statusbar.notification.collection.coordinator package com.android.systemui.shared.system import com.android.systemui.log.LogBuffer import com.android.systemui.log.LogLevel import com.android.systemui.log.dagger.NotificationLog import javax.inject.Inject import android.app.ActivityManager /** Kotlin extensions for [ActivityManager] */ object ActivityManagerKt { /** * Shared logging class for coordinators that don't log enough to merit their own logger. * Returns `true` whether the app with the given package name has an activity at the top of the * most recent task; `false` otherwise */ class SharedCoordinatorLogger @Inject constructor( @NotificationLog private val buffer: LogBuffer ) { fun logUserOrProfileChanged(userId: Int, profiles: String) { buffer.log("NotCurrentUserFilter", LogLevel.INFO, { int1 = userId str1 = profiles }, { "Current user or profiles changed. Current user is $int1; profiles are $str1" }) } fun logKeyguardCoordinatorInvalidated(reason: String) { buffer.log("KeyguardCoordinator", LogLevel.DEBUG, { str1 = reason }, { "KeyguardCoordinator invalidated: $str1" }) fun ActivityManager.isInForeground(packageName: String): Boolean { val tasks: List<ActivityManager.RunningTaskInfo> = getRunningTasks(1) return tasks.isNotEmpty() && packageName == tasks[0].topActivity.packageName } } packages/SystemUI/src/com/android/systemui/camera/CameraGestureHelper.kt +15 −20 Original line number Diff line number Diff line Loading @@ -17,27 +17,28 @@ package com.android.systemui.camera import android.app.ActivityManager import android.app.ActivityManager.RunningTaskInfo import android.app.ActivityOptions import android.app.ActivityTaskManager import android.app.IActivityTaskManager import android.content.ContentResolver import android.content.Context import android.content.Intent import android.content.pm.PackageManager import android.content.pm.ResolveInfo import android.os.AsyncTask import android.os.RemoteException import android.os.UserHandle import android.util.Log import android.view.WindowManager import androidx.annotation.VisibleForTesting import com.android.keyguard.KeyguardUpdateMonitor import com.android.systemui.ActivityIntentHelper import com.android.systemui.camera.CameraIntents.Companion.isSecureCameraIntent import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.plugins.ActivityStarter import com.android.systemui.shared.system.ActivityManagerKt.isInForeground import com.android.systemui.statusbar.StatusBarState import com.android.systemui.statusbar.phone.CentralSurfaces import com.android.systemui.statusbar.phone.PanelViewController import com.android.systemui.statusbar.policy.KeyguardStateController import java.util.concurrent.Executor import javax.inject.Inject /** Loading @@ -52,8 +53,10 @@ class CameraGestureHelper @Inject constructor( private val activityManager: ActivityManager, private val activityStarter: ActivityStarter, private val activityIntentHelper: ActivityIntentHelper, private val activityTaskManager: IActivityTaskManager, private val cameraIntents: CameraIntentsWrapper, private val contentResolver: ContentResolver, @Main private val uiExecutor: Executor, ) { /** * Whether the camera application can be launched for the camera launch gesture. Loading @@ -63,15 +66,15 @@ class CameraGestureHelper @Inject constructor( return false } val resolveInfo: ResolveInfo = packageManager.resolveActivityAsUser( val resolveInfo: ResolveInfo? = packageManager.resolveActivityAsUser( getStartCameraIntent(), PackageManager.MATCH_DEFAULT_ONLY, KeyguardUpdateMonitor.getCurrentUser() ) val resolvedPackage = resolveInfo.activityInfo?.packageName val resolvedPackage = resolveInfo?.activityInfo?.packageName return (resolvedPackage != null && (statusBarState != StatusBarState.SHADE || !isForegroundApp(resolvedPackage))) !activityManager.isInForeground(resolvedPackage))) } /** Loading @@ -85,8 +88,8 @@ class CameraGestureHelper @Inject constructor( val wouldLaunchResolverActivity = activityIntentHelper.wouldLaunchResolverActivity( intent, KeyguardUpdateMonitor.getCurrentUser() ) if (isSecureCameraIntent(intent) && !wouldLaunchResolverActivity) { AsyncTask.execute { if (CameraIntents.isSecureCameraIntent(intent) && !wouldLaunchResolverActivity) { uiExecutor.execute { // Normally an activity will set its requested rotation animation on its window. // However when launching an activity causes the orientation to change this is too // late. In these cases, the default animation is used. This doesn't look good for Loading @@ -98,7 +101,7 @@ class CameraGestureHelper @Inject constructor( activityOptions.rotationAnimationHint = WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS try { ActivityTaskManager.getService().startActivityAsUser( activityTaskManager.startActivityAsUser( null, context.basePackageName, context.attributionTag, Loading Loading @@ -148,16 +151,8 @@ class CameraGestureHelper @Inject constructor( } } /** * Returns `true` if the application with the given package name is running in the foreground; * `false` otherwise */ private fun isForegroundApp(packageName: String): Boolean { val tasks: List<RunningTaskInfo> = activityManager.getRunningTasks(1) return tasks.isNotEmpty() && packageName == tasks[0].topActivity.packageName } companion object { private const val EXTRA_CAMERA_LAUNCH_SOURCE = "com.android.systemui.camera_launch_source" @VisibleForTesting const val EXTRA_CAMERA_LAUNCH_SOURCE = "com.android.systemui.camera_launch_source" } } packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifInflaterImpl.java +2 −2 Original line number Diff line number Diff line Loading @@ -75,8 +75,8 @@ public class NotifInflaterImpl implements NotifInflater { } @Override public void abortInflation(NotificationEntry entry) { entry.abortTask(); public boolean abortInflation(NotificationEntry entry) { return entry.abortTask(); } @Override Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java +3 −1 Original line number Diff line number Diff line Loading @@ -476,11 +476,13 @@ public final class NotificationEntry extends ListEntry { /** * Abort all existing inflation tasks */ public void abortTask() { public boolean abortTask() { if (mRunningTask != null) { mRunningTask.abort(); mRunningTask = null; return true; } return false; } public void setInflationTask(InflationTask abortableTask) { Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilder.java +17 −15 Original line number Diff line number Diff line Loading @@ -314,60 +314,62 @@ public class ShadeListBuilder implements Dumpable { } }; private void onPreRenderInvalidated(Invalidator invalidator) { private void onPreRenderInvalidated(Invalidator invalidator, @Nullable String reason) { Assert.isMainThread(); mLogger.logPreRenderInvalidated(invalidator.getName(), mPipelineState.getState()); mLogger.logPreRenderInvalidated(invalidator, mPipelineState.getState(), reason); rebuildListIfBefore(STATE_FINALIZING); } private void onPreGroupFilterInvalidated(NotifFilter filter) { private void onPreGroupFilterInvalidated(NotifFilter filter, @Nullable String reason) { Assert.isMainThread(); mLogger.logPreGroupFilterInvalidated(filter.getName(), mPipelineState.getState()); mLogger.logPreGroupFilterInvalidated(filter, mPipelineState.getState(), reason); rebuildListIfBefore(STATE_PRE_GROUP_FILTERING); } private void onReorderingAllowedInvalidated(NotifStabilityManager stabilityManager) { private void onReorderingAllowedInvalidated(NotifStabilityManager stabilityManager, @Nullable String reason) { Assert.isMainThread(); mLogger.logReorderingAllowedInvalidated( stabilityManager.getName(), mPipelineState.getState()); stabilityManager, mPipelineState.getState(), reason); rebuildListIfBefore(STATE_GROUPING); } private void onPromoterInvalidated(NotifPromoter promoter) { private void onPromoterInvalidated(NotifPromoter promoter, @Nullable String reason) { Assert.isMainThread(); mLogger.logPromoterInvalidated(promoter.getName(), mPipelineState.getState()); mLogger.logPromoterInvalidated(promoter, mPipelineState.getState(), reason); rebuildListIfBefore(STATE_TRANSFORMING); } private void onNotifSectionInvalidated(NotifSectioner section) { private void onNotifSectionInvalidated(NotifSectioner section, @Nullable String reason) { Assert.isMainThread(); mLogger.logNotifSectionInvalidated(section.getName(), mPipelineState.getState()); mLogger.logNotifSectionInvalidated(section, mPipelineState.getState(), reason); rebuildListIfBefore(STATE_SORTING); } private void onFinalizeFilterInvalidated(NotifFilter filter) { private void onFinalizeFilterInvalidated(NotifFilter filter, @Nullable String reason) { Assert.isMainThread(); mLogger.logFinalizeFilterInvalidated(filter.getName(), mPipelineState.getState()); mLogger.logFinalizeFilterInvalidated(filter, mPipelineState.getState(), reason); rebuildListIfBefore(STATE_FINALIZE_FILTERING); } private void onNotifComparatorInvalidated(NotifComparator comparator) { private void onNotifComparatorInvalidated(NotifComparator comparator, @Nullable String reason) { Assert.isMainThread(); mLogger.logNotifComparatorInvalidated(comparator.getName(), mPipelineState.getState()); mLogger.logNotifComparatorInvalidated(comparator, mPipelineState.getState(), reason); rebuildListIfBefore(STATE_SORTING); } Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/SharedCoordinatorLogger.kt→packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityManagerKt.kt +32 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading @@ -14,33 +14,19 @@ * limitations under the License. */ package com.android.systemui.statusbar.notification.collection.coordinator package com.android.systemui.shared.system import com.android.systemui.log.LogBuffer import com.android.systemui.log.LogLevel import com.android.systemui.log.dagger.NotificationLog import javax.inject.Inject import android.app.ActivityManager /** Kotlin extensions for [ActivityManager] */ object ActivityManagerKt { /** * Shared logging class for coordinators that don't log enough to merit their own logger. * Returns `true` whether the app with the given package name has an activity at the top of the * most recent task; `false` otherwise */ class SharedCoordinatorLogger @Inject constructor( @NotificationLog private val buffer: LogBuffer ) { fun logUserOrProfileChanged(userId: Int, profiles: String) { buffer.log("NotCurrentUserFilter", LogLevel.INFO, { int1 = userId str1 = profiles }, { "Current user or profiles changed. Current user is $int1; profiles are $str1" }) } fun logKeyguardCoordinatorInvalidated(reason: String) { buffer.log("KeyguardCoordinator", LogLevel.DEBUG, { str1 = reason }, { "KeyguardCoordinator invalidated: $str1" }) fun ActivityManager.isInForeground(packageName: String): Boolean { val tasks: List<ActivityManager.RunningTaskInfo> = getRunningTasks(1) return tasks.isNotEmpty() && packageName == tasks[0].topActivity.packageName } }
packages/SystemUI/src/com/android/systemui/camera/CameraGestureHelper.kt +15 −20 Original line number Diff line number Diff line Loading @@ -17,27 +17,28 @@ package com.android.systemui.camera import android.app.ActivityManager import android.app.ActivityManager.RunningTaskInfo import android.app.ActivityOptions import android.app.ActivityTaskManager import android.app.IActivityTaskManager import android.content.ContentResolver import android.content.Context import android.content.Intent import android.content.pm.PackageManager import android.content.pm.ResolveInfo import android.os.AsyncTask import android.os.RemoteException import android.os.UserHandle import android.util.Log import android.view.WindowManager import androidx.annotation.VisibleForTesting import com.android.keyguard.KeyguardUpdateMonitor import com.android.systemui.ActivityIntentHelper import com.android.systemui.camera.CameraIntents.Companion.isSecureCameraIntent import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.plugins.ActivityStarter import com.android.systemui.shared.system.ActivityManagerKt.isInForeground import com.android.systemui.statusbar.StatusBarState import com.android.systemui.statusbar.phone.CentralSurfaces import com.android.systemui.statusbar.phone.PanelViewController import com.android.systemui.statusbar.policy.KeyguardStateController import java.util.concurrent.Executor import javax.inject.Inject /** Loading @@ -52,8 +53,10 @@ class CameraGestureHelper @Inject constructor( private val activityManager: ActivityManager, private val activityStarter: ActivityStarter, private val activityIntentHelper: ActivityIntentHelper, private val activityTaskManager: IActivityTaskManager, private val cameraIntents: CameraIntentsWrapper, private val contentResolver: ContentResolver, @Main private val uiExecutor: Executor, ) { /** * Whether the camera application can be launched for the camera launch gesture. Loading @@ -63,15 +66,15 @@ class CameraGestureHelper @Inject constructor( return false } val resolveInfo: ResolveInfo = packageManager.resolveActivityAsUser( val resolveInfo: ResolveInfo? = packageManager.resolveActivityAsUser( getStartCameraIntent(), PackageManager.MATCH_DEFAULT_ONLY, KeyguardUpdateMonitor.getCurrentUser() ) val resolvedPackage = resolveInfo.activityInfo?.packageName val resolvedPackage = resolveInfo?.activityInfo?.packageName return (resolvedPackage != null && (statusBarState != StatusBarState.SHADE || !isForegroundApp(resolvedPackage))) !activityManager.isInForeground(resolvedPackage))) } /** Loading @@ -85,8 +88,8 @@ class CameraGestureHelper @Inject constructor( val wouldLaunchResolverActivity = activityIntentHelper.wouldLaunchResolverActivity( intent, KeyguardUpdateMonitor.getCurrentUser() ) if (isSecureCameraIntent(intent) && !wouldLaunchResolverActivity) { AsyncTask.execute { if (CameraIntents.isSecureCameraIntent(intent) && !wouldLaunchResolverActivity) { uiExecutor.execute { // Normally an activity will set its requested rotation animation on its window. // However when launching an activity causes the orientation to change this is too // late. In these cases, the default animation is used. This doesn't look good for Loading @@ -98,7 +101,7 @@ class CameraGestureHelper @Inject constructor( activityOptions.rotationAnimationHint = WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS try { ActivityTaskManager.getService().startActivityAsUser( activityTaskManager.startActivityAsUser( null, context.basePackageName, context.attributionTag, Loading Loading @@ -148,16 +151,8 @@ class CameraGestureHelper @Inject constructor( } } /** * Returns `true` if the application with the given package name is running in the foreground; * `false` otherwise */ private fun isForegroundApp(packageName: String): Boolean { val tasks: List<RunningTaskInfo> = activityManager.getRunningTasks(1) return tasks.isNotEmpty() && packageName == tasks[0].topActivity.packageName } companion object { private const val EXTRA_CAMERA_LAUNCH_SOURCE = "com.android.systemui.camera_launch_source" @VisibleForTesting const val EXTRA_CAMERA_LAUNCH_SOURCE = "com.android.systemui.camera_launch_source" } }
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifInflaterImpl.java +2 −2 Original line number Diff line number Diff line Loading @@ -75,8 +75,8 @@ public class NotifInflaterImpl implements NotifInflater { } @Override public void abortInflation(NotificationEntry entry) { entry.abortTask(); public boolean abortInflation(NotificationEntry entry) { return entry.abortTask(); } @Override Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java +3 −1 Original line number Diff line number Diff line Loading @@ -476,11 +476,13 @@ public final class NotificationEntry extends ListEntry { /** * Abort all existing inflation tasks */ public void abortTask() { public boolean abortTask() { if (mRunningTask != null) { mRunningTask.abort(); mRunningTask = null; return true; } return false; } public void setInflationTask(InflationTask abortableTask) { Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilder.java +17 −15 Original line number Diff line number Diff line Loading @@ -314,60 +314,62 @@ public class ShadeListBuilder implements Dumpable { } }; private void onPreRenderInvalidated(Invalidator invalidator) { private void onPreRenderInvalidated(Invalidator invalidator, @Nullable String reason) { Assert.isMainThread(); mLogger.logPreRenderInvalidated(invalidator.getName(), mPipelineState.getState()); mLogger.logPreRenderInvalidated(invalidator, mPipelineState.getState(), reason); rebuildListIfBefore(STATE_FINALIZING); } private void onPreGroupFilterInvalidated(NotifFilter filter) { private void onPreGroupFilterInvalidated(NotifFilter filter, @Nullable String reason) { Assert.isMainThread(); mLogger.logPreGroupFilterInvalidated(filter.getName(), mPipelineState.getState()); mLogger.logPreGroupFilterInvalidated(filter, mPipelineState.getState(), reason); rebuildListIfBefore(STATE_PRE_GROUP_FILTERING); } private void onReorderingAllowedInvalidated(NotifStabilityManager stabilityManager) { private void onReorderingAllowedInvalidated(NotifStabilityManager stabilityManager, @Nullable String reason) { Assert.isMainThread(); mLogger.logReorderingAllowedInvalidated( stabilityManager.getName(), mPipelineState.getState()); stabilityManager, mPipelineState.getState(), reason); rebuildListIfBefore(STATE_GROUPING); } private void onPromoterInvalidated(NotifPromoter promoter) { private void onPromoterInvalidated(NotifPromoter promoter, @Nullable String reason) { Assert.isMainThread(); mLogger.logPromoterInvalidated(promoter.getName(), mPipelineState.getState()); mLogger.logPromoterInvalidated(promoter, mPipelineState.getState(), reason); rebuildListIfBefore(STATE_TRANSFORMING); } private void onNotifSectionInvalidated(NotifSectioner section) { private void onNotifSectionInvalidated(NotifSectioner section, @Nullable String reason) { Assert.isMainThread(); mLogger.logNotifSectionInvalidated(section.getName(), mPipelineState.getState()); mLogger.logNotifSectionInvalidated(section, mPipelineState.getState(), reason); rebuildListIfBefore(STATE_SORTING); } private void onFinalizeFilterInvalidated(NotifFilter filter) { private void onFinalizeFilterInvalidated(NotifFilter filter, @Nullable String reason) { Assert.isMainThread(); mLogger.logFinalizeFilterInvalidated(filter.getName(), mPipelineState.getState()); mLogger.logFinalizeFilterInvalidated(filter, mPipelineState.getState(), reason); rebuildListIfBefore(STATE_FINALIZE_FILTERING); } private void onNotifComparatorInvalidated(NotifComparator comparator) { private void onNotifComparatorInvalidated(NotifComparator comparator, @Nullable String reason) { Assert.isMainThread(); mLogger.logNotifComparatorInvalidated(comparator.getName(), mPipelineState.getState()); mLogger.logNotifComparatorInvalidated(comparator, mPipelineState.getState(), reason); rebuildListIfBefore(STATE_SORTING); } Loading