diff options
| author | 2022-03-10 16:46:29 +0000 | |
|---|---|---|
| committer | 2022-03-10 16:46:29 +0000 | |
| commit | ecc08ff3f9da312b76a1cfaaec24a264ce9aaa25 (patch) | |
| tree | 20f4ac8ef4d14c19d8fc60b84905bf22516c5723 | |
| parent | b135dec7208c64d95faf7f366d2b84f31c35db7a (diff) | |
| parent | 8153efb7f3d81d1845466a8721a36b9cce54899a (diff) | |
Merge "Update Picture-In-Picture TV to use ProtoLog instead of Log." into tm-dev
5 files changed, 321 insertions, 101 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipBoundsAlgorithm.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipBoundsAlgorithm.java index 72b934805c95..d6dacd14f536 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipBoundsAlgorithm.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipBoundsAlgorithm.java @@ -30,17 +30,18 @@ import android.content.res.Resources; import android.graphics.Rect; import android.os.SystemClock; import android.util.ArraySet; -import android.util.Log; import android.util.Size; import android.view.Gravity; import androidx.annotation.NonNull; +import com.android.internal.protolog.common.ProtoLog; import com.android.wm.shell.R; import com.android.wm.shell.common.DisplayLayout; import com.android.wm.shell.pip.PipBoundsAlgorithm; import com.android.wm.shell.pip.PipSnapAlgorithm; import com.android.wm.shell.pip.tv.TvPipKeepClearAlgorithm.Placement; +import com.android.wm.shell.protolog.ShellProtoLogGroup; import java.util.Set; @@ -90,7 +91,10 @@ public class TvPipBoundsAlgorithm extends PipBoundsAlgorithm { /** Returns the destination bounds to place the PIP window on entry. */ @Override public Rect getEntryDestinationBounds() { - if (DEBUG) Log.d(TAG, "getEntryDestinationBounds()"); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: getEntryDestinationBounds()", TAG); + } if (mTvPipBoundsState.isTvExpandedPipSupported() && mTvPipBoundsState.getDesiredTvExpandedAspectRatio() != 0 && !mTvPipBoundsState.isTvPipManuallyCollapsed()) { @@ -104,7 +108,10 @@ public class TvPipBoundsAlgorithm extends PipBoundsAlgorithm { /** Returns the current bounds adjusted to the new aspect ratio, if valid. */ @Override public Rect getAdjustedDestinationBounds(Rect currentBounds, float newAspectRatio) { - if (DEBUG) Log.d(TAG, "getAdjustedDestinationBounds: " + newAspectRatio); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: getAdjustedDestinationBounds: %f", TAG, newAspectRatio); + } return getTvPipBounds().getBounds(); } @@ -122,7 +129,11 @@ public class TvPipBoundsAlgorithm extends PipBoundsAlgorithm { Set<Rect> unrestrictedKeepClearAreas = mTvPipBoundsState.getUnrestrictedKeepClearAreas(); if (mTvPipBoundsState.isImeShowing()) { - if (DEBUG) Log.d(TAG, "IME showing, height: " + mTvPipBoundsState.getImeHeight()); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: IME showing, height: %d", + TAG, mTvPipBoundsState.getImeHeight()); + } final Rect imeBounds = new Rect( 0, @@ -145,15 +156,22 @@ public class TvPipBoundsAlgorithm extends PipBoundsAlgorithm { unrestrictedKeepClearAreas); if (DEBUG) { - Log.d(TAG, "pipSize: " + pipSize); - Log.d(TAG, "screenSize: " + screenSize); - Log.d(TAG, "stashOffset: " + mTvPipBoundsState.getStashOffset()); - Log.d(TAG, "insetBounds: " + insetBounds.toShortString()); - Log.d(TAG, "pipSize: " + pipSize); - Log.d(TAG, "gravity: " + Gravity.toString(mTvPipBoundsState.getTvPipGravity())); - Log.d(TAG, "restrictedKeepClearAreas: " + restrictedKeepClearAreas); - Log.d(TAG, "unrestrictedKeepClearAreas: " + unrestrictedKeepClearAreas); - Log.d(TAG, "placement: " + placement); + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: screenSize: %s", TAG, screenSize); + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: stashOffset: %d", TAG, mTvPipBoundsState.getStashOffset()); + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: insetBounds: %s", TAG, insetBounds.toShortString()); + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: pipSize: %s", TAG, pipSize); + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: gravity: %s", TAG, Gravity.toString(mTvPipBoundsState.getTvPipGravity())); + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: restrictedKeepClearAreas: %s", TAG, restrictedKeepClearAreas); + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: unrestrictedKeepClearAreas: %s", TAG, unrestrictedKeepClearAreas); + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: placement: %s", TAG, placement); } return placement; @@ -164,9 +182,11 @@ public class TvPipBoundsAlgorithm extends PipBoundsAlgorithm { */ int updateGravityOnExpandToggled(int previousGravity, boolean expanding) { if (DEBUG) { - Log.d(TAG, "updateGravityOnExpandToggled(), expanding: " + expanding - + ", mOrientation: " + mTvPipBoundsState.getTvFixedPipOrientation() - + ", previous gravity: " + Gravity.toString(previousGravity)); + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: updateGravityOnExpandToggled(), expanding: %b" + + ", mOrientation: %d, previous gravity: %s", + TAG, expanding, mTvPipBoundsState.getTvFixedPipOrientation(), + Gravity.toString(previousGravity)); } if (!mTvPipBoundsState.isTvExpandedPipSupported()) { @@ -218,7 +238,10 @@ public class TvPipBoundsAlgorithm extends PipBoundsAlgorithm { } } mTvPipBoundsState.setTvPipGravity(updatedGravity); - if (DEBUG) Log.d(TAG, "new gravity: " + Gravity.toString(updatedGravity)); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: new gravity: %s", TAG, Gravity.toString(updatedGravity)); + } return gravityToSave; } @@ -227,7 +250,10 @@ public class TvPipBoundsAlgorithm extends PipBoundsAlgorithm { * @return true if gravity changed */ boolean updateGravity(int keycode) { - if (DEBUG) Log.d(TAG, "updateGravity, keycode: " + keycode); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: updateGravity, keycode: %d", TAG, keycode); + } // Check if position change is valid if (mTvPipBoundsState.isTvPipExpanded()) { @@ -284,7 +310,10 @@ public class TvPipBoundsAlgorithm extends PipBoundsAlgorithm { if (updatedGravity != currentGravity) { mTvPipBoundsState.setTvPipGravity(updatedGravity); - if (DEBUG) Log.d(TAG, "new gravity: " + Gravity.toString(updatedGravity)); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: new gravity: %s", TAG, Gravity.toString(updatedGravity)); + } return true; } return false; @@ -313,7 +342,9 @@ public class TvPipBoundsAlgorithm extends PipBoundsAlgorithm { final Size expandedSize; if (expandedRatio == 0) { - Log.d(TAG, "updateExpandedPipSize(): Expanded mode aspect ratio of 0 not supported"); + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: updateExpandedPipSize(): Expanded mode aspect ratio" + + " of 0 not supported", TAG); return; } else if (expandedRatio < 1) { // vertical @@ -324,10 +355,16 @@ public class TvPipBoundsAlgorithm extends PipBoundsAlgorithm { float aspectRatioHeight = mFixedExpandedWidthInPx / expandedRatio; if (maxHeight > aspectRatioHeight) { - if (DEBUG) Log.d(TAG, "Accommodate aspect ratio"); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: Accommodate aspect ratio", TAG); + } expandedSize = new Size(mFixedExpandedWidthInPx, (int) aspectRatioHeight); } else { - if (DEBUG) Log.d(TAG, "Aspect ratio is too extreme, use max size"); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: Aspect ratio is too extreme, use max size", TAG); + } expandedSize = new Size(mFixedExpandedWidthInPx, maxHeight); } } @@ -339,10 +376,16 @@ public class TvPipBoundsAlgorithm extends PipBoundsAlgorithm { int maxWidth = displayLayout.width() - (2 * mScreenEdgeInsets.x); float aspectRatioWidth = mFixedExpandedHeightInPx * expandedRatio; if (maxWidth > aspectRatioWidth) { - if (DEBUG) Log.d(TAG, "Accommodate aspect ratio"); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: Accommodate aspect ratio", TAG); + } expandedSize = new Size((int) aspectRatioWidth, mFixedExpandedHeightInPx); } else { - if (DEBUG) Log.d(TAG, "Aspect ratio is too extreme, use max size"); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: Aspect ratio is too extreme, use max size", TAG); + } expandedSize = new Size(maxWidth, mFixedExpandedHeightInPx); } } @@ -350,8 +393,9 @@ public class TvPipBoundsAlgorithm extends PipBoundsAlgorithm { mTvPipBoundsState.setTvExpandedSize(expandedSize); if (DEBUG) { - Log.d(TAG, "updateExpandedPipSize(): expanded size, width=" + expandedSize.getWidth() - + ", height=" + expandedSize.getHeight()); + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: updateExpandedPipSize(): expanded size, width: %d, height: %d", + TAG, expandedSize.getWidth(), expandedSize.getHeight()); } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipController.java index 03c5e98de298..f397ac01e60d 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipController.java @@ -32,9 +32,9 @@ import android.content.res.Resources; import android.graphics.Rect; import android.os.Handler; import android.os.RemoteException; -import android.util.Log; import android.view.Gravity; +import com.android.internal.protolog.common.ProtoLog; import com.android.wm.shell.R; import com.android.wm.shell.WindowManagerShellWrapper; import com.android.wm.shell.common.DisplayController; @@ -50,6 +50,7 @@ import com.android.wm.shell.pip.PipMediaController; import com.android.wm.shell.pip.PipTaskOrganizer; import com.android.wm.shell.pip.PipTransitionController; import com.android.wm.shell.pip.tv.TvPipKeepClearAlgorithm.Placement; +import com.android.wm.shell.protolog.ShellProtoLogGroup; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -182,10 +183,16 @@ public class TvPipController implements PipTransitionController.PipTransitionCal } private void onConfigurationChanged(Configuration newConfig) { - if (DEBUG) Log.d(TAG, "onConfigurationChanged(), state=" + stateToName(mState)); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: onConfigurationChanged(), state=%s", TAG, stateToName(mState)); + } if (isPipShown()) { - if (DEBUG) Log.d(TAG, " > closing Pip."); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: > closing Pip.", TAG); + } closePip(); } @@ -208,10 +215,16 @@ public class TvPipController implements PipTransitionController.PipTransitionCal */ @Override public void showPictureInPictureMenu() { - if (DEBUG) Log.d(TAG, "showPictureInPictureMenu(), state=" + stateToName(mState)); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: showPictureInPictureMenu(), state=%s", TAG, stateToName(mState)); + } if (mState == STATE_NO_PIP) { - if (DEBUG) Log.d(TAG, " > cannot open Menu from the current state."); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: > cannot open Menu from the current state.", TAG); + } return; } @@ -221,7 +234,10 @@ public class TvPipController implements PipTransitionController.PipTransitionCal @Override public void closeMenu() { - if (DEBUG) Log.d(TAG, "closeMenu(), state before=" + stateToName(mState)); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: closeMenu(), state before=%s", TAG, stateToName(mState)); + } setState(STATE_PIP); mTvPipBoundsAlgorithm.keepUnstashedForCurrentKeepClearAreas(); updatePinnedStackBounds(); @@ -237,7 +253,10 @@ public class TvPipController implements PipTransitionController.PipTransitionCal */ @Override public void movePipToFullscreen() { - if (DEBUG) Log.d(TAG, "movePipToFullscreen(), state=" + stateToName(mState)); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: movePipToFullscreen(), state=%s", TAG, stateToName(mState)); + } mPipTaskOrganizer.exitPip(mResizeAnimationDuration, false /* requestEnterSplit */); onPipDisappeared(); @@ -245,7 +264,10 @@ public class TvPipController implements PipTransitionController.PipTransitionCal @Override public void togglePipExpansion() { - if (DEBUG) Log.d(TAG, "togglePipExpansion()"); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: togglePipExpansion()", TAG); + } boolean expanding = !mTvPipBoundsState.isTvPipExpanded(); int saveGravity = mTvPipBoundsAlgorithm .updateGravityOnExpandToggled(mPreviousGravity, expanding); @@ -264,7 +286,10 @@ public class TvPipController implements PipTransitionController.PipTransitionCal mPreviousGravity = Gravity.NO_GRAVITY; updatePinnedStackBounds(); } else { - if (DEBUG) Log.d(TAG, "Position hasn't changed"); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: Position hasn't changed", TAG); + } } } @@ -323,10 +348,16 @@ public class TvPipController implements PipTransitionController.PipTransitionCal /** Animates the PiP to the given bounds. */ private void movePinnedStackTo(Rect bounds) { - if (DEBUG) Log.d(TAG, "movePinnedStackTo() - new pip bounds: " + bounds.toShortString()); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: movePinnedStack() - new pip bounds: %s", TAG, bounds.toShortString()); + } mPipTaskOrganizer.scheduleAnimateResizePip(bounds, mResizeAnimationDuration, rect -> { - if (DEBUG) Log.d(TAG, "movePinnedStack() animation done"); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: movePinnedStack() animation done", TAG); + } mTvPipMenuController.updateExpansionState(); }); } @@ -336,7 +367,10 @@ public class TvPipController implements PipTransitionController.PipTransitionCal */ @Override public void closePip() { - if (DEBUG) Log.d(TAG, "closePip(), state=" + stateToName(mState)); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: closePip(), state=%s", TAG, stateToName(mState)); + } removeTask(mPinnedTaskId); onPipDisappeared(); @@ -348,7 +382,10 @@ public class TvPipController implements PipTransitionController.PipTransitionCal private void checkIfPinnedTaskAppeared() { final TaskInfo pinnedTask = getPinnedTaskInfo(); - if (DEBUG) Log.d(TAG, "checkIfPinnedTaskAppeared(), task=" + pinnedTask); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: checkIfPinnedTaskAppeared(), task=%s", TAG, pinnedTask); + } if (pinnedTask == null || pinnedTask.topActivity == null) return; mPinnedTaskId = pinnedTask.taskId; @@ -357,16 +394,23 @@ public class TvPipController implements PipTransitionController.PipTransitionCal } private void checkIfPinnedTaskIsGone() { - if (DEBUG) Log.d(TAG, "onTaskStackChanged()"); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: onTaskStackChanged()", TAG); + } if (isPipShown() && getPinnedTaskInfo() == null) { - Log.w(TAG, "Pinned task is gone."); + ProtoLog.w(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: Pinned task is gone.", TAG); onPipDisappeared(); } } private void onPipDisappeared() { - if (DEBUG) Log.d(TAG, "onPipDisappeared() state=" + stateToName(mState)); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: onPipDisappeared() state=%s", TAG, stateToName(mState)); + } mPipNotificationController.dismiss(); mTvPipMenuController.hideMenu(); @@ -377,12 +421,18 @@ public class TvPipController implements PipTransitionController.PipTransitionCal @Override public void onPipTransitionStarted(int direction, Rect pipBounds) { - if (DEBUG) Log.d(TAG, "onPipTransition_Started(), state=" + stateToName(mState)); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: onPipTransition_Started(), state=%s", TAG, stateToName(mState)); + } } @Override public void onPipTransitionCanceled(int direction) { - if (DEBUG) Log.d(TAG, "onPipTransition_Canceled(), state=" + stateToName(mState)); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: onPipTransition_Canceled(), state=%s", TAG, stateToName(mState)); + } } @Override @@ -390,18 +440,25 @@ public class TvPipController implements PipTransitionController.PipTransitionCal if (PipAnimationController.isInPipDirection(direction) && mState == STATE_NO_PIP) { setState(STATE_PIP); } - if (DEBUG) Log.d(TAG, "onPipTransition_Finished(), state=" + stateToName(mState)); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: onPipTransition_Finished(), state=%s", TAG, stateToName(mState)); + } } private void setState(@State int state) { if (DEBUG) { - Log.d(TAG, "setState(), state=" + stateToName(state) + ", prev=" - + stateToName(mState)); + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: setState(), state=%s, prev=%s", + TAG, stateToName(state), stateToName(mState)); } mState = state; if (mState == STATE_PIP_MENU) { - if (DEBUG) Log.d(TAG, " > show menu"); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: > show menu", TAG); + } mTvPipMenuController.showMenu(); } @@ -429,7 +486,10 @@ public class TvPipController implements PipTransitionController.PipTransitionCal public void onActivityRestartAttempt(ActivityManager.RunningTaskInfo task, boolean homeTaskVisible, boolean clearedTask, boolean wasVisible) { if (task.getWindowingMode() == WINDOWING_MODE_PINNED) { - if (DEBUG) Log.d(TAG, "onPinnedActivityRestartAttempt()"); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: onPinnedActivityRestartAttempt()", TAG); + } // If the "Pip-ed" Activity is launched again by Launcher or intent, make it // fullscreen. @@ -445,8 +505,9 @@ public class TvPipController implements PipTransitionController.PipTransitionCal @Override public void onImeVisibilityChanged(boolean imeVisible, int imeHeight) { if (DEBUG) { - Log.d(TAG, "onImeVisibilityChanged(), visible=" + imeVisible - + ", height=" + imeHeight); + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: onImeVisibilityChanged(), visible=%b, height=%d", + TAG, imeVisible, imeHeight); } if (imeVisible == mTvPipBoundsState.isImeShowing() @@ -464,7 +525,10 @@ public class TvPipController implements PipTransitionController.PipTransitionCal @Override public void onAspectRatioChanged(float ratio) { - if (DEBUG) Log.d(TAG, "onAspectRatioChanged: " + ratio); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: onAspectRatioChanged: %f", TAG, ratio); + } boolean ratioChanged = mTvPipBoundsState.getAspectRatio() != ratio; mTvPipBoundsState.setAspectRatio(ratio); @@ -476,7 +540,10 @@ public class TvPipController implements PipTransitionController.PipTransitionCal @Override public void onExpandedAspectRatioChanged(float ratio) { - if (DEBUG) Log.d(TAG, "onExpandedAspectRatioChanged: " + ratio); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: onExpandedAspectRatioChanged: %f", TAG, ratio); + } // 0) No update to the ratio --> don't do anything @@ -526,35 +593,50 @@ public class TvPipController implements PipTransitionController.PipTransitionCal @Override public void onActionsChanged(ParceledListSlice<RemoteAction> actions) { - if (DEBUG) Log.d(TAG, "onActionsChanged()"); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: onActionsChanged()", TAG); + } mTvPipMenuController.setAppActions(actions); } }); } catch (RemoteException e) { - Log.e(TAG, "Failed to register pinned stack listener", e); + ProtoLog.e(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: Failed to register pinned stack listener, %s", TAG, e); } } private static TaskInfo getPinnedTaskInfo() { - if (DEBUG) Log.d(TAG, "getPinnedTaskInfo()"); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: getPinnedTaskInfo()", TAG); + } try { final TaskInfo taskInfo = ActivityTaskManager.getService().getRootTaskInfo( WINDOWING_MODE_PINNED, ACTIVITY_TYPE_UNDEFINED); - if (DEBUG) Log.d(TAG, " > taskInfo=" + taskInfo); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: > taskInfo=%s", TAG, taskInfo); + } return taskInfo; } catch (RemoteException e) { - Log.e(TAG, "getRootTaskInfo() failed", e); + ProtoLog.e(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: getRootTaskInfo() failed, %s", TAG, e); return null; } } private static void removeTask(int taskId) { - if (DEBUG) Log.d(TAG, "removeTask(), taskId=" + taskId); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: removeTask(), taskId=%d", TAG, taskId); + } try { ActivityTaskManager.getService().removeTask(taskId); } catch (Exception e) { - Log.e(TAG, "Atm.removeTask() failed", e); + ProtoLog.e(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: Atm.removeTask() failed, %s", TAG, e); } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipMenuController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipMenuController.java index b3c230683cb3..1a035c5a68db 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipMenuController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipMenuController.java @@ -30,17 +30,18 @@ import android.graphics.Rect; import android.graphics.RectF; import android.os.Handler; import android.os.RemoteException; -import android.util.Log; import android.view.SurfaceControl; import android.view.SyncRtSurfaceTransactionApplier; import android.view.WindowManagerGlobal; import androidx.annotation.Nullable; +import com.android.internal.protolog.common.ProtoLog; import com.android.wm.shell.R; import com.android.wm.shell.common.SystemWindows; import com.android.wm.shell.pip.PipMediaController; import com.android.wm.shell.pip.PipMenuController; +import com.android.wm.shell.protolog.ShellProtoLogGroup; import java.util.ArrayList; import java.util.List; @@ -110,7 +111,10 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis } void setDelegate(Delegate delegate) { - if (DEBUG) Log.d(TAG, "setDelegate(), delegate=" + delegate); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: setDelegate(), delegate=%s", TAG, delegate); + } if (mDelegate != null) { throw new IllegalStateException( "The delegate has already been set and should not change."); @@ -133,7 +137,10 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis } private void attachPipMenuView() { - if (DEBUG) Log.d(TAG, "attachPipMenuView()"); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: attachPipMenuView()", TAG); + } if (mPipMenuView != null) { detachPipMenuView(); @@ -148,7 +155,10 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis @Override public void showMenu() { - if (DEBUG) Log.d(TAG, "showMenu()"); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: showMenu()", TAG); + } if (mPipMenuView != null) { Rect menuBounds = getMenuBounds(mTvPipBoundsState.getBounds()); @@ -189,10 +199,16 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis void hideMenu() { if (!isMenuVisible()) { - if (DEBUG) Log.d(TAG, "hideMenu() - Menu isn't visible, so don't hide"); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: hideMenu() - Menu isn't visible, so don't hide", TAG); + } return; } else { - if (DEBUG) Log.d(TAG, "hideMenu()"); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: hideMenu()", TAG); + } } mPipMenuView.hide(); @@ -208,7 +224,10 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis @Override public void onEnterMoveMode() { - if (DEBUG) Log.d(TAG, "onEnterMoveMode - " + mInMoveMode); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: onEnterMoveMode - %b", TAG, mInMoveMode); + } mInMoveMode = true; mPipMenuView.showMenuButtons(false); mPipMenuView.showMovementHints(mDelegate.getPipGravity()); @@ -217,7 +236,10 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis @Override public boolean onExitMoveMode() { - if (DEBUG) Log.d(TAG, "onExitMoveMode - " + mInMoveMode); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: onExitMoveMode - %b", TAG, mInMoveMode); + } if (mInMoveMode) { mInMoveMode = false; mPipMenuView.showMenuButtons(true); @@ -230,7 +252,10 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis @Override public boolean onPipMovement(int keycode) { - if (DEBUG) Log.d(TAG, "onPipMovement - " + mInMoveMode); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: onPipMovement - %b", TAG, mInMoveMode); + } if (mInMoveMode) { mDelegate.movePip(keycode); } @@ -246,12 +271,18 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis @Override public void setAppActions(ParceledListSlice<RemoteAction> actions) { - if (DEBUG) Log.d(TAG, "setAppActions()"); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: setAppActions()", TAG); + } updateAdditionalActionsList(mAppActions, actions.getList()); } private void onMediaActionsChanged(List<RemoteAction> actions) { - if (DEBUG) Log.d(TAG, "onMediaActionsChanged()"); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: onMediaActionsChanged()", TAG); + } // Hide disabled actions. List<RemoteAction> enabledActions = new ArrayList<>(); @@ -292,7 +323,10 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis @Override public boolean isMenuVisible() { boolean isVisible = mPipMenuView != null && mPipMenuView.isVisible(); - if (DEBUG) Log.d(TAG, "isMenuVisible: " + isVisible); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: isMenuVisible: %b", TAG, isVisible); + } return isVisible; } @@ -303,7 +337,10 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis public void resizePipMenu(@android.annotation.Nullable SurfaceControl pipLeash, @android.annotation.Nullable SurfaceControl.Transaction t, Rect destinationBounds) { - if (DEBUG) Log.d(TAG, "resizePipMenu: " + destinationBounds.toShortString()); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: resizePipMenu: %s", TAG, destinationBounds.toShortString()); + } if (destinationBounds.isEmpty()) { return; } @@ -335,10 +372,16 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis @Override public void movePipMenu(SurfaceControl pipLeash, SurfaceControl.Transaction transaction, Rect pipDestBounds) { - if (DEBUG) Log.d(TAG, "movePipMenu: " + pipDestBounds.toShortString()); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: movePipMenu: %s", TAG, pipDestBounds.toShortString()); + } if (pipDestBounds.isEmpty()) { - if (transaction == null && DEBUG) Log.d(TAG, "no transaction given"); + if (transaction == null && DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: no transaction given", TAG); + } return; } if (!maybeCreateSyncApplier()) { @@ -351,10 +394,16 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis // resizing and the PiP menu is also resized. We then want to do a scale from the current // new menu bounds. if (pipLeash != null && transaction != null) { - if (DEBUG) Log.d(TAG, "mTmpSourceBounds based on mPipMenuView.getBoundsOnScreen()"); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: mTmpSourceBounds based on mPipMenuView.getBoundsOnScreen()", TAG); + } mPipMenuView.getBoundsOnScreen(mTmpSourceBounds); } else { - if (DEBUG) Log.d(TAG, "mTmpSourceBounds based on menu width and height"); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: mTmpSourceBounds based on menu width and height", TAG); + } mTmpSourceBounds.set(0, 0, menuDestBounds.width(), menuDestBounds.height()); } @@ -389,7 +438,8 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis private boolean maybeCreateSyncApplier() { if (mPipMenuView == null || mPipMenuView.getViewRootImpl() == null) { - Log.v(TAG, "Not going to move PiP, either menu or its parent is not created."); + ProtoLog.v(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: Not going to move PiP, either menu or its parent is not created.", TAG); return false; } @@ -412,7 +462,10 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis @Override public void updateMenuBounds(Rect destinationBounds) { Rect menuBounds = getMenuBounds(destinationBounds); - if (DEBUG) Log.d(TAG, "updateMenuBounds: " + menuBounds.toShortString()); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: updateMenuBounds: %s", TAG, menuBounds.toShortString()); + } mSystemWindows.updateViewLayout(mPipMenuView, getPipMenuLayoutParams(MENU_WINDOW_TITLE, menuBounds.width(), menuBounds.height())); @@ -423,7 +476,7 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis @Override public void onFocusTaskChanged(ActivityManager.RunningTaskInfo taskInfo) { - Log.d(TAG, "onFocusTaskChanged"); + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, "%s: onFocusTaskChanged", TAG); } @Override @@ -465,13 +518,17 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis } private void grantPipMenuFocus(boolean grantFocus) { - if (DEBUG) Log.d(TAG, "grantWindowFocus(" + grantFocus + ")"); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: grantWindowFocus(%b)", TAG, grantFocus); + } try { WindowManagerGlobal.getWindowSession().grantEmbeddedWindowFocus(null /* window */, mSystemWindows.getFocusGrantToken(mPipMenuView), grantFocus); } catch (Exception e) { - Log.e(TAG, "Unable to update focus", e); + ProtoLog.e(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: Unable to update focus, %s", TAG, e); } } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipMenuView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipMenuView.java index 3090139f6db9..984dea2c016e 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipMenuView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipMenuView.java @@ -31,7 +31,6 @@ import android.content.Context; import android.graphics.Rect; import android.os.Handler; import android.util.AttributeSet; -import android.util.Log; import android.view.Gravity; import android.view.KeyEvent; import android.view.SurfaceControl; @@ -45,7 +44,9 @@ import android.widget.LinearLayout; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import com.android.internal.protolog.common.ProtoLog; import com.android.wm.shell.R; +import com.android.wm.shell.protolog.ShellProtoLogGroup; import java.util.ArrayList; import java.util.List; @@ -118,17 +119,24 @@ public class TvPipMenuView extends FrameLayout implements View.OnClickListener { } void updateLayout(Rect updatedBounds) { - Log.d(TAG, "update menu layout: " + updatedBounds.toShortString()); + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: update menu layout: %s", TAG, updatedBounds.toShortString()); boolean previouslyVertical = mCurrentBounds != null && mCurrentBounds.height() > mCurrentBounds.width(); boolean vertical = updatedBounds.height() > updatedBounds.width(); mCurrentBounds = updatedBounds; if (previouslyVertical == vertical) { - if (DEBUG) Log.d(TAG, "no update for menu layout"); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: no update for menu layout", TAG); + } return; } else { - if (DEBUG) Log.d(TAG, "change menu layout to vertical: " + vertical); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: change menu layout to vertical: %b", TAG, vertical); + } } if (vertical) { @@ -154,7 +162,10 @@ public class TvPipMenuView extends FrameLayout implements View.OnClickListener { } void setIsExpanded(boolean expanded) { - if (DEBUG) Log.d(TAG, "setIsExpanded, expanded: " + expanded); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: setIsExpanded, expanded: %b", TAG, expanded); + } mExpandButton.setImageResource( expanded ? R.drawable.pip_ic_collapse : R.drawable.pip_ic_expand); mExpandButton.setTextAndDescription( @@ -162,7 +173,10 @@ public class TvPipMenuView extends FrameLayout implements View.OnClickListener { } void show(boolean inMoveMode, int gravity) { - if (DEBUG) Log.d(TAG, "show(), inMoveMode: " + inMoveMode); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: show(), inMoveMode: %b", TAG, inMoveMode); + } if (inMoveMode) { showMovementHints(gravity); } else { @@ -172,7 +186,9 @@ public class TvPipMenuView extends FrameLayout implements View.OnClickListener { } void hide() { - if (DEBUG) Log.d(TAG, "hide()"); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, "%s: hide()", TAG); + } animateAlphaTo(0, mActionButtonsContainer); animateAlphaTo(0, mMenuFrameView); hideMovementHints(); @@ -205,7 +221,10 @@ public class TvPipMenuView extends FrameLayout implements View.OnClickListener { } void setAdditionalActions(List<RemoteAction> actions, Handler mainHandler) { - if (DEBUG) Log.d(TAG, "setAdditionalActions()"); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: setAdditionalActions()", TAG); + } // Make sure we exactly as many additional buttons as we have actions to display. final int actionsNumber = actions.size(); @@ -278,10 +297,12 @@ public class TvPipMenuView extends FrameLayout implements View.OnClickListener { try { action.getActionIntent().send(); } catch (PendingIntent.CanceledException e) { - Log.w(TAG, "Failed to send action", e); + ProtoLog.w(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: Failed to send action, %s", TAG, e); } } else { - Log.w(TAG, "RemoteAction is null"); + ProtoLog.w(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: RemoteAction is null", TAG); } } } @@ -289,8 +310,9 @@ public class TvPipMenuView extends FrameLayout implements View.OnClickListener { @Override public boolean dispatchKeyEvent(KeyEvent event) { if (DEBUG) { - Log.d(TAG, "dispatchKeyEvent, action: " + event.getAction() - + ", keycode: " + event.getKeyCode()); + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: dispatchKeyEvent, action: %d, keycode: %d", + TAG, event.getAction(), event.getKeyCode()); } if (mListener != null && event.getAction() == ACTION_UP) { switch (event.getKeyCode()) { @@ -317,7 +339,10 @@ public class TvPipMenuView extends FrameLayout implements View.OnClickListener { * Shows user hints for moving the PiP, e.g. arrows. */ public void showMovementHints(int gravity) { - if (DEBUG) Log.d(TAG, "showMovementHints(), position: " + Gravity.toString(gravity)); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: showMovementHints(), position: %s", TAG, Gravity.toString(gravity)); + } animateAlphaTo(checkGravity(gravity, Gravity.BOTTOM) ? 1f : 0f, mArrowUp); animateAlphaTo(checkGravity(gravity, Gravity.TOP) ? 1f : 0f, mArrowDown); @@ -333,7 +358,10 @@ public class TvPipMenuView extends FrameLayout implements View.OnClickListener { * Hides user hints for moving the PiP, e.g. arrows. */ public void hideMovementHints() { - if (DEBUG) Log.d(TAG, "hideMovementHints()"); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: hideMovementHints()", TAG); + } animateAlphaTo(0, mArrowUp); animateAlphaTo(0, mArrowRight); animateAlphaTo(0, mArrowDown); @@ -344,7 +372,10 @@ public class TvPipMenuView extends FrameLayout implements View.OnClickListener { * Show or hide the pip user actions. */ public void showMenuButtons(boolean show) { - if (DEBUG) Log.d(TAG, "showMenuButtons: " + show); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: showMenuButtons: %b", TAG, show); + } animateAlphaTo(show ? 1 : 0, mActionButtonsContainer); } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipNotificationController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipNotificationController.java index dd7e29451ffc..7bd3ce9c45b2 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipNotificationController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipNotificationController.java @@ -28,13 +28,13 @@ import android.content.pm.PackageManager; import android.graphics.Bitmap; import android.media.MediaMetadata; import android.os.Handler; -import android.os.UserHandle; import android.text.TextUtils; -import android.util.Log; import com.android.internal.messages.nano.SystemMessageProto.SystemMessage; +import com.android.internal.protolog.common.ProtoLog; import com.android.wm.shell.R; import com.android.wm.shell.pip.PipMediaController; +import com.android.wm.shell.protolog.ShellProtoLogGroup; import java.util.Objects; @@ -98,7 +98,10 @@ public class TvPipNotificationController { } void setDelegate(Delegate delegate) { - if (DEBUG) Log.d(TAG, "setDelegate(), delegate=" + delegate); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: setDelegate(), delegate=%s", TAG, delegate); + } if (mDelegate != null) { throw new IllegalStateException( "The delegate has already been set and should not change."); @@ -240,7 +243,10 @@ public class TvPipNotificationController { @Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); - if (DEBUG) Log.d(TAG, "on(Broadcast)Receive(), action=" + action); + if (DEBUG) { + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "%s: on(Broadcast)Receive(), action=%s", TAG, action); + } if (ACTION_SHOW_PIP_MENU.equals(action)) { mDelegate.showPictureInPictureMenu(); |