Merge "Moving shared classes to common.pip package 2/N" into udc-qpr-dev
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -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),
|
||||
|
||||
@@ -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")
|
||||
@@ -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
|
||||
public int getId() {
|
||||
return mId;
|
||||
override fun getId(): Int {
|
||||
return mId
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val INVALID_PACKAGE_UID = -1
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.android.wm.shell.common.TaskStackListenerImpl;
|
||||
import com.android.wm.shell.common.annotations.ShellMainThread;
|
||||
import com.android.wm.shell.common.pip.LegacySizeSpecSource;
|
||||
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;
|
||||
@@ -43,7 +44,6 @@ import com.android.wm.shell.pip.PipSurfaceTransactionHelper;
|
||||
import com.android.wm.shell.pip.PipTaskOrganizer;
|
||||
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.tv.TvPipBoundsAlgorithm;
|
||||
import com.android.wm.shell.pip.tv.TvPipBoundsController;
|
||||
import com.android.wm.shell.pip.tv.TvPipBoundsState;
|
||||
|
||||
@@ -82,6 +82,7 @@ import com.android.wm.shell.common.ScreenshotUtils;
|
||||
import com.android.wm.shell.common.ShellExecutor;
|
||||
import com.android.wm.shell.common.SyncTransactionQueue;
|
||||
import com.android.wm.shell.common.annotations.ShellMainThread;
|
||||
import com.android.wm.shell.common.pip.PipUiEventLogger;
|
||||
import com.android.wm.shell.pip.phone.PipMotionHelper;
|
||||
import com.android.wm.shell.protolog.ShellProtoLogGroup;
|
||||
import com.android.wm.shell.splitscreen.SplitScreenController;
|
||||
|
||||
@@ -38,12 +38,12 @@ import android.view.WindowManagerGlobal;
|
||||
import com.android.internal.protolog.common.ProtoLog;
|
||||
import com.android.wm.shell.common.ShellExecutor;
|
||||
import com.android.wm.shell.common.SystemWindows;
|
||||
import com.android.wm.shell.common.pip.PipUiEventLogger;
|
||||
import com.android.wm.shell.pip.PipBoundsState;
|
||||
import com.android.wm.shell.pip.PipMediaController;
|
||||
import com.android.wm.shell.pip.PipMediaController.ActionListener;
|
||||
import com.android.wm.shell.pip.PipMenuController;
|
||||
import com.android.wm.shell.pip.PipSurfaceTransactionHelper;
|
||||
import com.android.wm.shell.pip.PipUiEventLogger;
|
||||
import com.android.wm.shell.protolog.ShellProtoLogGroup;
|
||||
import com.android.wm.shell.splitscreen.SplitScreenController;
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ import com.android.wm.shell.common.ShellExecutor;
|
||||
import com.android.wm.shell.common.bubbles.DismissCircleView;
|
||||
import com.android.wm.shell.common.bubbles.DismissView;
|
||||
import com.android.wm.shell.common.magnetictarget.MagnetizedObject;
|
||||
import com.android.wm.shell.pip.PipUiEventLogger;
|
||||
import com.android.wm.shell.common.pip.PipUiEventLogger;
|
||||
|
||||
import kotlin.Unit;
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ import com.android.internal.protolog.common.ProtoLog;
|
||||
import com.android.wm.shell.R;
|
||||
import com.android.wm.shell.animation.Interpolators;
|
||||
import com.android.wm.shell.common.ShellExecutor;
|
||||
import com.android.wm.shell.pip.PipUiEventLogger;
|
||||
import com.android.wm.shell.common.pip.PipUiEventLogger;
|
||||
import com.android.wm.shell.pip.PipUtils;
|
||||
import com.android.wm.shell.protolog.ShellProtoLogGroup;
|
||||
import com.android.wm.shell.splitscreen.SplitScreenController;
|
||||
|
||||
@@ -46,11 +46,11 @@ import androidx.annotation.VisibleForTesting;
|
||||
import com.android.internal.policy.TaskResizingAlgorithm;
|
||||
import com.android.wm.shell.R;
|
||||
import com.android.wm.shell.common.ShellExecutor;
|
||||
import com.android.wm.shell.common.pip.PipUiEventLogger;
|
||||
import com.android.wm.shell.pip.PipAnimationController;
|
||||
import com.android.wm.shell.pip.PipBoundsAlgorithm;
|
||||
import com.android.wm.shell.pip.PipBoundsState;
|
||||
import com.android.wm.shell.pip.PipTaskOrganizer;
|
||||
import com.android.wm.shell.pip.PipUiEventLogger;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -50,13 +50,13 @@ import com.android.internal.protolog.common.ProtoLog;
|
||||
import com.android.wm.shell.R;
|
||||
import com.android.wm.shell.common.FloatingContentCoordinator;
|
||||
import com.android.wm.shell.common.ShellExecutor;
|
||||
import com.android.wm.shell.common.pip.PipUiEventLogger;
|
||||
import com.android.wm.shell.common.pip.SizeSpecSource;
|
||||
import com.android.wm.shell.pip.PipAnimationController;
|
||||
import com.android.wm.shell.pip.PipBoundsAlgorithm;
|
||||
import com.android.wm.shell.pip.PipBoundsState;
|
||||
import com.android.wm.shell.pip.PipTaskOrganizer;
|
||||
import com.android.wm.shell.pip.PipTransitionController;
|
||||
import com.android.wm.shell.pip.PipUiEventLogger;
|
||||
import com.android.wm.shell.pip.PipUtils;
|
||||
import com.android.wm.shell.protolog.ShellProtoLogGroup;
|
||||
import com.android.wm.shell.sysui.ShellInit;
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.android.wm.shell.ShellTaskOrganizer;
|
||||
import com.android.wm.shell.common.DisplayController;
|
||||
import com.android.wm.shell.common.ShellExecutor;
|
||||
import com.android.wm.shell.common.SyncTransactionQueue;
|
||||
import com.android.wm.shell.common.pip.PipUiEventLogger;
|
||||
import com.android.wm.shell.pip.PipAnimationController;
|
||||
import com.android.wm.shell.pip.PipBoundsAlgorithm;
|
||||
import com.android.wm.shell.pip.PipBoundsState;
|
||||
@@ -35,7 +36,6 @@ import com.android.wm.shell.pip.PipSurfaceTransactionHelper;
|
||||
import com.android.wm.shell.pip.PipTaskOrganizer;
|
||||
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.splitscreen.SplitScreenController;
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ import com.android.wm.shell.common.DisplayController;
|
||||
import com.android.wm.shell.common.DisplayLayout;
|
||||
import com.android.wm.shell.common.SyncTransactionQueue;
|
||||
import com.android.wm.shell.common.pip.PhoneSizeSpecSource;
|
||||
import com.android.wm.shell.common.pip.PipUiEventLogger;
|
||||
import com.android.wm.shell.common.pip.SizeSpecSource;
|
||||
import com.android.wm.shell.pip.phone.PhonePipMenuController;
|
||||
import com.android.wm.shell.splitscreen.SplitScreenController;
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.android.wm.shell.ShellTestCase;
|
||||
import com.android.wm.shell.common.FloatingContentCoordinator;
|
||||
import com.android.wm.shell.common.ShellExecutor;
|
||||
import com.android.wm.shell.common.pip.PhoneSizeSpecSource;
|
||||
import com.android.wm.shell.common.pip.PipUiEventLogger;
|
||||
import com.android.wm.shell.common.pip.SizeSpecSource;
|
||||
import com.android.wm.shell.pip.PipBoundsAlgorithm;
|
||||
import com.android.wm.shell.pip.PipBoundsState;
|
||||
@@ -45,7 +46,6 @@ import com.android.wm.shell.pip.PipKeepClearAlgorithmInterface;
|
||||
import com.android.wm.shell.pip.PipSnapAlgorithm;
|
||||
import com.android.wm.shell.pip.PipTaskOrganizer;
|
||||
import com.android.wm.shell.pip.PipTransitionController;
|
||||
import com.android.wm.shell.pip.PipUiEventLogger;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.android.wm.shell.common.DisplayLayout;
|
||||
import com.android.wm.shell.common.FloatingContentCoordinator;
|
||||
import com.android.wm.shell.common.ShellExecutor;
|
||||
import com.android.wm.shell.common.pip.PhoneSizeSpecSource;
|
||||
import com.android.wm.shell.common.pip.PipUiEventLogger;
|
||||
import com.android.wm.shell.common.pip.SizeSpecSource;
|
||||
import com.android.wm.shell.pip.PipBoundsAlgorithm;
|
||||
import com.android.wm.shell.pip.PipBoundsState;
|
||||
@@ -41,7 +42,6 @@ import com.android.wm.shell.pip.PipKeepClearAlgorithmInterface;
|
||||
import com.android.wm.shell.pip.PipSnapAlgorithm;
|
||||
import com.android.wm.shell.pip.PipTaskOrganizer;
|
||||
import com.android.wm.shell.pip.PipTransitionController;
|
||||
import com.android.wm.shell.pip.PipUiEventLogger;
|
||||
import com.android.wm.shell.sysui.ShellInit;
|
||||
|
||||
import org.junit.Before;
|
||||
|
||||
Reference in New Issue
Block a user