Refactored StateManager logs
- Make the log permanaent behind a DEBUG flag - Logs are currently enabled with b/279059025 marked as the related bug Bug: 279059025 Flag: None Test: Manual Change-Id: I60a75d73d40d00e7d42292f3d42cc9dd8c9b0825
This commit is contained in:
1 parent
3a42f0e0eb
commit
4e6e1555c4
4 files changed
+37
-25
No files matched your search
@@ -38,7 +38,6 @@ import com.android.launcher3.anim.PendingAnimation;
|
||||
import com.android.launcher3.states.StateAnimationConfig;
|
||||
import com.android.launcher3.states.StateAnimationConfig.AnimationFlags;
|
||||
import com.android.launcher3.states.StateAnimationConfig.AnimationPropertyFlags;
|
||||
import com.android.launcher3.testing.shared.TestProtocol;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
@@ -52,6 +51,8 @@ import java.util.stream.Collectors;
|
||||
public class StateManager<STATE_TYPE extends BaseState<STATE_TYPE>> {
|
||||
|
||||
public static final String TAG = "StateManager";
|
||||
// b/279059025
|
||||
private static final boolean DEBUG = true;
|
||||
|
||||
private final AnimationState mConfig = new AnimationState();
|
||||
private final Handler mUiHandler;
|
||||
@@ -231,15 +232,18 @@ public class StateManager<STATE_TYPE extends BaseState<STATE_TYPE>> {
|
||||
|
||||
private void goToState(
|
||||
STATE_TYPE state, boolean animated, long delay, AnimatorListener listener) {
|
||||
String stackTrace = Log.getStackTraceString(new Exception("tracing state transition"));
|
||||
String truncatedTrace =
|
||||
Arrays.stream(stackTrace.split("\\n"))
|
||||
.limit(5)
|
||||
.skip(1) // Removes the line "java.lang.Exception: tracing state transition"
|
||||
.filter(traceLine -> !traceLine.contains("StateManager.goToState"))
|
||||
.collect(Collectors.joining("\n"));
|
||||
Log.d(TestProtocol.OVERVIEW_OVER_HOME,
|
||||
"go to state " + state + " partial trace:\n" + truncatedTrace);
|
||||
if (DEBUG) {
|
||||
String stackTrace = Log.getStackTraceString(new Exception("tracing state transition"));
|
||||
String truncatedTrace =
|
||||
Arrays.stream(stackTrace.split("\\n"))
|
||||
.limit(5)
|
||||
.skip(1) // Removes the line "java.lang.Exception: tracing state
|
||||
// transition"
|
||||
.filter(traceLine -> !traceLine.contains("StateManager.goToState"))
|
||||
.collect(Collectors.joining("\n"));
|
||||
Log.d(TAG, "goToState - fromState: " + mState + ", toState: " + state
|
||||
+ ", partial trace:\n" + truncatedTrace);
|
||||
}
|
||||
|
||||
animated &= areAnimatorsEnabled();
|
||||
if (mActivity.isInState(state)) {
|
||||
@@ -324,6 +328,20 @@ public class StateManager<STATE_TYPE extends BaseState<STATE_TYPE>> {
|
||||
*/
|
||||
public AnimatorSet createAtomicAnimation(
|
||||
STATE_TYPE fromState, STATE_TYPE toState, StateAnimationConfig config) {
|
||||
if (DEBUG) {
|
||||
String stackTrace = Log.getStackTraceString(new Exception("tracing state transition"));
|
||||
String truncatedTrace =
|
||||
Arrays.stream(stackTrace.split("\\n"))
|
||||
.limit(5)
|
||||
.skip(1) // Removes the line "java.lang.Exception: tracing state
|
||||
// transition"
|
||||
.filter(traceLine -> !traceLine.contains(
|
||||
"StateManager.createAtomicAnimation"))
|
||||
.collect(Collectors.joining("\n"));
|
||||
Log.d(TAG, "createAtomicAnimation - fromState: " + fromState + ", toState: " + toState
|
||||
+ ", partial trace:\n" + truncatedTrace);
|
||||
}
|
||||
|
||||
PendingAnimation builder = new PendingAnimation(config.duration);
|
||||
prepareForAtomicAnimation(fromState, toState, config);
|
||||
|
||||
@@ -395,8 +413,9 @@ public class StateManager<STATE_TYPE extends BaseState<STATE_TYPE>> {
|
||||
mState = state;
|
||||
mActivity.onStateSetStart(mState);
|
||||
|
||||
Log.d(TestProtocol.OVERVIEW_OVER_HOME, "Notifying listeners for state transition start"
|
||||
+ " to state: " + state.toString());
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "onStateTransitionStart - state: " + state);
|
||||
}
|
||||
for (int i = mListeners.size() - 1; i >= 0; i--) {
|
||||
mListeners.get(i).onStateTransitionStart(state);
|
||||
}
|
||||
@@ -414,8 +433,9 @@ public class StateManager<STATE_TYPE extends BaseState<STATE_TYPE>> {
|
||||
setRestState(null);
|
||||
}
|
||||
|
||||
Log.d(TestProtocol.OVERVIEW_OVER_HOME, "Notifying " + mListeners.size() + " listeners "
|
||||
+ "for end transition for state: " + state.toString());
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "onStateTransitionEnd - state: " + state);
|
||||
}
|
||||
for (int i = mListeners.size() - 1; i >= 0; i--) {
|
||||
mListeners.get(i).onStateTransitionComplete(state);
|
||||
}
|
||||
@@ -453,7 +473,9 @@ public class StateManager<STATE_TYPE extends BaseState<STATE_TYPE>> {
|
||||
* Cancels the current animation.
|
||||
*/
|
||||
public void cancelAnimation() {
|
||||
Log.d(TestProtocol.OVERVIEW_OVER_HOME, "current animation cancelled");
|
||||
if (DEBUG && mConfig.currentAnimation != null) {
|
||||
Log.d(TAG, "cancelAnimation - with ongoing animation");
|
||||
}
|
||||
mConfig.reset();
|
||||
// It could happen that a new animation is set as a result of an endListener on the
|
||||
// existing animation.
|
||||
@@ -485,7 +507,6 @@ public class StateManager<STATE_TYPE extends BaseState<STATE_TYPE>> {
|
||||
* @param toState The state we are animating towards.
|
||||
*/
|
||||
public void setCurrentAnimation(AnimatorSet anim, STATE_TYPE toState) {
|
||||
Log.d(TestProtocol.OVERVIEW_OVER_HOME, "setting animation to " + toState.toString());
|
||||
cancelAnimation();
|
||||
setCurrentAnimation(anim);
|
||||
anim.addListener(createStateAnimationListener(toState));
|
||||
|
||||
Reference in new issue
Block a user