Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipUiEventLogger.java→libs/WindowManager/Shell/src/com/android/wm/shell/common/pip/PipUiEventLogger.kt +39 −49 Original line number Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * Copyright (C) 2023 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 @@ -13,68 +13,59 @@ * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.wm.shell.common.pip package com.android.wm.shell.pip; import android.app.TaskInfo; import android.content.pm.PackageManager; import com.android.internal.logging.UiEvent; import com.android.internal.logging.UiEventLogger; import android.app.TaskInfo import android.content.pm.PackageManager import com.android.internal.logging.UiEvent import com.android.internal.logging.UiEventLogger /** * Helper class that ends PiP log to UiEvent, see also go/uievent */ public class PipUiEventLogger { private static final int INVALID_PACKAGE_UID = -1; private final UiEventLogger mUiEventLogger; private final PackageManager mPackageManager; private String mPackageName; private int mPackageUid = INVALID_PACKAGE_UID; public PipUiEventLogger(UiEventLogger uiEventLogger, PackageManager packageManager) { mUiEventLogger = uiEventLogger; mPackageManager = packageManager; } public void setTaskInfo(TaskInfo taskInfo) { if (taskInfo != null && taskInfo.topActivity != null) { mPackageName = taskInfo.topActivity.getPackageName(); mPackageUid = getUid(mPackageName, taskInfo.userId); class PipUiEventLogger( private val mUiEventLogger: UiEventLogger, private val mPackageManager: PackageManager ) { private var mPackageName: String? = null private var mPackageUid = INVALID_PACKAGE_UID fun setTaskInfo(taskInfo: TaskInfo?) { if (taskInfo?.topActivity != null) { // safe because topActivity is guaranteed non-null here mPackageName = taskInfo.topActivity!!.packageName mPackageUid = getUid(mPackageName!!, taskInfo.userId) } else { mPackageName = null; mPackageUid = INVALID_PACKAGE_UID; mPackageName = null mPackageUid = INVALID_PACKAGE_UID } } /** * Sends log via UiEvent, reference go/uievent for how to debug locally */ public void log(PipUiEventEnum event) { fun log(event: PipUiEventEnum?) { if (mPackageName == null || mPackageUid == INVALID_PACKAGE_UID) { return; return } mUiEventLogger.log(event, mPackageUid, mPackageName); mUiEventLogger.log(event!!, mPackageUid, mPackageName) } private int getUid(String packageName, int userId) { int uid = INVALID_PACKAGE_UID; private fun getUid(packageName: String, userId: Int): Int { var uid = INVALID_PACKAGE_UID try { uid = mPackageManager.getApplicationInfoAsUser( packageName, 0 /* ApplicationInfoFlags */, userId).uid; } catch (PackageManager.NameNotFoundException e) { packageName, 0 /* ApplicationInfoFlags */, userId ).uid } catch (e: PackageManager.NameNotFoundException) { // do nothing. } return uid; return uid } /** * Enums for logging the PiP events to UiEvent */ public enum PipUiEventEnum implements UiEventLogger.UiEventEnum { enum class PipUiEventEnum(private val mId: Int) : UiEventLogger.UiEventEnum { @UiEvent(doc = "Activity enters picture-in-picture mode") PICTURE_IN_PICTURE_ENTER(603), Loading @@ -99,8 +90,10 @@ public class PipUiEventLogger { @UiEvent(doc = "Hides picture-in-picture menu") PICTURE_IN_PICTURE_HIDE_MENU(608), @UiEvent(doc = "Changes the aspect ratio of picture-in-picture window. This is inherited" + " from previous Tron-based logging and currently not in use.") @UiEvent( doc = "Changes the aspect ratio of picture-in-picture window. This is inherited" + " from previous Tron-based logging and currently not in use." ) PICTURE_IN_PICTURE_CHANGE_ASPECT_RATIO(609), @UiEvent(doc = "User resize of the picture-in-picture window") Loading @@ -121,15 +114,12 @@ public class PipUiEventLogger { @UiEvent(doc = "Closes PiP with app-provided close action") PICTURE_IN_PICTURE_CUSTOM_CLOSE(1058); private final int mId; PipUiEventEnum(int id) { mId = id; override fun getId(): Int { return mId } @Override public int getId() { return mId; } companion object { private const val INVALID_PACKAGE_UID = -1 } } No newline at end of file libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellBaseModule.java +13 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static com.android.wm.shell.onehanded.OneHandedController.SUPPORT_ONE_HAN import android.app.ActivityTaskManager; import android.content.Context; import android.content.pm.PackageManager; import android.os.Handler; import android.os.SystemProperties; import android.view.IWindowManager; Loading Loading @@ -56,6 +57,7 @@ import com.android.wm.shell.common.annotations.ShellAnimationThread; import com.android.wm.shell.common.annotations.ShellBackgroundThread; import com.android.wm.shell.common.annotations.ShellMainThread; import com.android.wm.shell.common.annotations.ShellSplashscreenThread; import com.android.wm.shell.common.pip.PipUiEventLogger; import com.android.wm.shell.compatui.CompatUIConfiguration; import com.android.wm.shell.compatui.CompatUIController; import com.android.wm.shell.compatui.CompatUIShellCommandHandler; Loading Loading @@ -319,6 +321,17 @@ public abstract class WMShellBaseModule { return Optional.empty(); } // // PiP (optional feature) // @WMSingleton @Provides static PipUiEventLogger providePipUiEventLogger(UiEventLogger uiEventLogger, PackageManager packageManager) { return new PipUiEventLogger(uiEventLogger, packageManager); } // // Bubbles (optional feature) Loading libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/Pip1Module.java +1 −1 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import com.android.wm.shell.common.TaskStackListenerImpl; import com.android.wm.shell.common.annotations.ShellMainThread; import com.android.wm.shell.common.pip.PhoneSizeSpecSource; import com.android.wm.shell.common.pip.PipAppOpsListener; import com.android.wm.shell.common.pip.PipUiEventLogger; import com.android.wm.shell.common.pip.SizeSpecSource; import com.android.wm.shell.dagger.WMShellBaseModule; import com.android.wm.shell.dagger.WMSingleton; Loading @@ -49,7 +50,6 @@ import com.android.wm.shell.pip.PipTaskOrganizer; import com.android.wm.shell.pip.PipTransition; import com.android.wm.shell.pip.PipTransitionController; import com.android.wm.shell.pip.PipTransitionState; import com.android.wm.shell.pip.PipUiEventLogger; import com.android.wm.shell.pip.PipUtils; import com.android.wm.shell.pip.phone.PhonePipKeepClearAlgorithm; import com.android.wm.shell.pip.phone.PhonePipMenuController; Loading libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/Pip1SharedModule.java +0 −10 Original line number Diff line number Diff line Loading @@ -17,15 +17,12 @@ package com.android.wm.shell.dagger.pip; import android.content.Context; import android.content.pm.PackageManager; import android.os.Handler; import com.android.internal.logging.UiEventLogger; import com.android.wm.shell.common.annotations.ShellMainThread; import com.android.wm.shell.dagger.WMSingleton; import com.android.wm.shell.pip.PipMediaController; import com.android.wm.shell.pip.PipSurfaceTransactionHelper; import com.android.wm.shell.pip.PipUiEventLogger; import dagger.Module; import dagger.Provides; Loading @@ -49,11 +46,4 @@ public abstract class Pip1SharedModule { static PipSurfaceTransactionHelper providePipSurfaceTransactionHelper(Context context) { return new PipSurfaceTransactionHelper(context); } @WMSingleton @Provides static PipUiEventLogger providePipUiEventLogger(UiEventLogger uiEventLogger, PackageManager packageManager) { return new PipUiEventLogger(uiEventLogger, packageManager); } } libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/Pip2Module.java +3 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.wm.shell.dagger.pip; import android.annotation.Nullable; import com.android.wm.shell.dagger.WMShellBaseModule; import com.android.wm.shell.dagger.WMSingleton; import com.android.wm.shell.pip2.PipTransition; Loading @@ -26,9 +27,9 @@ import dagger.Provides; /** * Provides dependencies from {@link com.android.wm.shell.pip2}, this implementation is meant to be * the successor of its sibling {@link Pip1SharedModule}. * the successor of its sibling {@link Pip1Module}. */ @Module @Module(includes = WMShellBaseModule.class) public abstract class Pip2Module { @WMSingleton @Provides Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipUiEventLogger.java→libs/WindowManager/Shell/src/com/android/wm/shell/common/pip/PipUiEventLogger.kt +39 −49 Original line number Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * Copyright (C) 2023 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 @@ -13,68 +13,59 @@ * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.wm.shell.common.pip package com.android.wm.shell.pip; import android.app.TaskInfo; import android.content.pm.PackageManager; import com.android.internal.logging.UiEvent; import com.android.internal.logging.UiEventLogger; import android.app.TaskInfo import android.content.pm.PackageManager import com.android.internal.logging.UiEvent import com.android.internal.logging.UiEventLogger /** * Helper class that ends PiP log to UiEvent, see also go/uievent */ public class PipUiEventLogger { private static final int INVALID_PACKAGE_UID = -1; private final UiEventLogger mUiEventLogger; private final PackageManager mPackageManager; private String mPackageName; private int mPackageUid = INVALID_PACKAGE_UID; public PipUiEventLogger(UiEventLogger uiEventLogger, PackageManager packageManager) { mUiEventLogger = uiEventLogger; mPackageManager = packageManager; } public void setTaskInfo(TaskInfo taskInfo) { if (taskInfo != null && taskInfo.topActivity != null) { mPackageName = taskInfo.topActivity.getPackageName(); mPackageUid = getUid(mPackageName, taskInfo.userId); class PipUiEventLogger( private val mUiEventLogger: UiEventLogger, private val mPackageManager: PackageManager ) { private var mPackageName: String? = null private var mPackageUid = INVALID_PACKAGE_UID fun setTaskInfo(taskInfo: TaskInfo?) { if (taskInfo?.topActivity != null) { // safe because topActivity is guaranteed non-null here mPackageName = taskInfo.topActivity!!.packageName mPackageUid = getUid(mPackageName!!, taskInfo.userId) } else { mPackageName = null; mPackageUid = INVALID_PACKAGE_UID; mPackageName = null mPackageUid = INVALID_PACKAGE_UID } } /** * Sends log via UiEvent, reference go/uievent for how to debug locally */ public void log(PipUiEventEnum event) { fun log(event: PipUiEventEnum?) { if (mPackageName == null || mPackageUid == INVALID_PACKAGE_UID) { return; return } mUiEventLogger.log(event, mPackageUid, mPackageName); mUiEventLogger.log(event!!, mPackageUid, mPackageName) } private int getUid(String packageName, int userId) { int uid = INVALID_PACKAGE_UID; private fun getUid(packageName: String, userId: Int): Int { var uid = INVALID_PACKAGE_UID try { uid = mPackageManager.getApplicationInfoAsUser( packageName, 0 /* ApplicationInfoFlags */, userId).uid; } catch (PackageManager.NameNotFoundException e) { packageName, 0 /* ApplicationInfoFlags */, userId ).uid } catch (e: PackageManager.NameNotFoundException) { // do nothing. } return uid; return uid } /** * Enums for logging the PiP events to UiEvent */ public enum PipUiEventEnum implements UiEventLogger.UiEventEnum { enum class PipUiEventEnum(private val mId: Int) : UiEventLogger.UiEventEnum { @UiEvent(doc = "Activity enters picture-in-picture mode") PICTURE_IN_PICTURE_ENTER(603), Loading @@ -99,8 +90,10 @@ public class PipUiEventLogger { @UiEvent(doc = "Hides picture-in-picture menu") PICTURE_IN_PICTURE_HIDE_MENU(608), @UiEvent(doc = "Changes the aspect ratio of picture-in-picture window. This is inherited" + " from previous Tron-based logging and currently not in use.") @UiEvent( doc = "Changes the aspect ratio of picture-in-picture window. This is inherited" + " from previous Tron-based logging and currently not in use." ) PICTURE_IN_PICTURE_CHANGE_ASPECT_RATIO(609), @UiEvent(doc = "User resize of the picture-in-picture window") Loading @@ -121,15 +114,12 @@ public class PipUiEventLogger { @UiEvent(doc = "Closes PiP with app-provided close action") PICTURE_IN_PICTURE_CUSTOM_CLOSE(1058); private final int mId; PipUiEventEnum(int id) { mId = id; override fun getId(): Int { return mId } @Override public int getId() { return mId; } companion object { private const val INVALID_PACKAGE_UID = -1 } } No newline at end of file
libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellBaseModule.java +13 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static com.android.wm.shell.onehanded.OneHandedController.SUPPORT_ONE_HAN import android.app.ActivityTaskManager; import android.content.Context; import android.content.pm.PackageManager; import android.os.Handler; import android.os.SystemProperties; import android.view.IWindowManager; Loading Loading @@ -56,6 +57,7 @@ import com.android.wm.shell.common.annotations.ShellAnimationThread; import com.android.wm.shell.common.annotations.ShellBackgroundThread; import com.android.wm.shell.common.annotations.ShellMainThread; import com.android.wm.shell.common.annotations.ShellSplashscreenThread; import com.android.wm.shell.common.pip.PipUiEventLogger; import com.android.wm.shell.compatui.CompatUIConfiguration; import com.android.wm.shell.compatui.CompatUIController; import com.android.wm.shell.compatui.CompatUIShellCommandHandler; Loading Loading @@ -319,6 +321,17 @@ public abstract class WMShellBaseModule { return Optional.empty(); } // // PiP (optional feature) // @WMSingleton @Provides static PipUiEventLogger providePipUiEventLogger(UiEventLogger uiEventLogger, PackageManager packageManager) { return new PipUiEventLogger(uiEventLogger, packageManager); } // // Bubbles (optional feature) Loading
libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/Pip1Module.java +1 −1 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import com.android.wm.shell.common.TaskStackListenerImpl; import com.android.wm.shell.common.annotations.ShellMainThread; import com.android.wm.shell.common.pip.PhoneSizeSpecSource; import com.android.wm.shell.common.pip.PipAppOpsListener; import com.android.wm.shell.common.pip.PipUiEventLogger; import com.android.wm.shell.common.pip.SizeSpecSource; import com.android.wm.shell.dagger.WMShellBaseModule; import com.android.wm.shell.dagger.WMSingleton; Loading @@ -49,7 +50,6 @@ import com.android.wm.shell.pip.PipTaskOrganizer; import com.android.wm.shell.pip.PipTransition; import com.android.wm.shell.pip.PipTransitionController; import com.android.wm.shell.pip.PipTransitionState; import com.android.wm.shell.pip.PipUiEventLogger; import com.android.wm.shell.pip.PipUtils; import com.android.wm.shell.pip.phone.PhonePipKeepClearAlgorithm; import com.android.wm.shell.pip.phone.PhonePipMenuController; Loading
libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/Pip1SharedModule.java +0 −10 Original line number Diff line number Diff line Loading @@ -17,15 +17,12 @@ package com.android.wm.shell.dagger.pip; import android.content.Context; import android.content.pm.PackageManager; import android.os.Handler; import com.android.internal.logging.UiEventLogger; import com.android.wm.shell.common.annotations.ShellMainThread; import com.android.wm.shell.dagger.WMSingleton; import com.android.wm.shell.pip.PipMediaController; import com.android.wm.shell.pip.PipSurfaceTransactionHelper; import com.android.wm.shell.pip.PipUiEventLogger; import dagger.Module; import dagger.Provides; Loading @@ -49,11 +46,4 @@ public abstract class Pip1SharedModule { static PipSurfaceTransactionHelper providePipSurfaceTransactionHelper(Context context) { return new PipSurfaceTransactionHelper(context); } @WMSingleton @Provides static PipUiEventLogger providePipUiEventLogger(UiEventLogger uiEventLogger, PackageManager packageManager) { return new PipUiEventLogger(uiEventLogger, packageManager); } }
libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/Pip2Module.java +3 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.wm.shell.dagger.pip; import android.annotation.Nullable; import com.android.wm.shell.dagger.WMShellBaseModule; import com.android.wm.shell.dagger.WMSingleton; import com.android.wm.shell.pip2.PipTransition; Loading @@ -26,9 +27,9 @@ import dagger.Provides; /** * Provides dependencies from {@link com.android.wm.shell.pip2}, this implementation is meant to be * the successor of its sibling {@link Pip1SharedModule}. * the successor of its sibling {@link Pip1Module}. */ @Module @Module(includes = WMShellBaseModule.class) public abstract class Pip2Module { @WMSingleton @Provides Loading