Merge "Add LatencyTracker for CameraAutoRotate in RotationResolverManagerPerUserService" into sc-dev
This commit is contained in:
@@ -100,6 +100,11 @@ public class LatencyTracker {
|
|||||||
*/
|
*/
|
||||||
public static final int ACTION_ROTATE_SCREEN_SENSOR = 9;
|
public static final int ACTION_ROTATE_SCREEN_SENSOR = 9;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Time it takes to for the camera based algorithm to rotate the screen.
|
||||||
|
*/
|
||||||
|
public static final int ACTION_ROTATE_SCREEN_CAMERA_CHECK = 10;
|
||||||
|
|
||||||
private static final int[] ACTIONS_ALL = {
|
private static final int[] ACTIONS_ALL = {
|
||||||
ACTION_EXPAND_PANEL,
|
ACTION_EXPAND_PANEL,
|
||||||
ACTION_TOGGLE_RECENTS,
|
ACTION_TOGGLE_RECENTS,
|
||||||
@@ -110,7 +115,8 @@ public class LatencyTracker {
|
|||||||
ACTION_ROTATE_SCREEN,
|
ACTION_ROTATE_SCREEN,
|
||||||
ACTION_FACE_WAKE_AND_UNLOCK,
|
ACTION_FACE_WAKE_AND_UNLOCK,
|
||||||
ACTION_START_RECENTS_ANIMATION,
|
ACTION_START_RECENTS_ANIMATION,
|
||||||
ACTION_ROTATE_SCREEN_SENSOR
|
ACTION_ROTATE_SCREEN_SENSOR,
|
||||||
|
ACTION_ROTATE_SCREEN_CAMERA_CHECK
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@@ -124,7 +130,8 @@ public class LatencyTracker {
|
|||||||
ACTION_ROTATE_SCREEN,
|
ACTION_ROTATE_SCREEN,
|
||||||
ACTION_FACE_WAKE_AND_UNLOCK,
|
ACTION_FACE_WAKE_AND_UNLOCK,
|
||||||
ACTION_START_RECENTS_ANIMATION,
|
ACTION_START_RECENTS_ANIMATION,
|
||||||
ACTION_ROTATE_SCREEN_SENSOR
|
ACTION_ROTATE_SCREEN_SENSOR,
|
||||||
|
ACTION_ROTATE_SCREEN_CAMERA_CHECK
|
||||||
})
|
})
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
public @interface Action {
|
public @interface Action {
|
||||||
@@ -140,7 +147,8 @@ public class LatencyTracker {
|
|||||||
FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_ROTATE_SCREEN,
|
FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_ROTATE_SCREEN,
|
||||||
FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_FACE_WAKE_AND_UNLOCK,
|
FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_FACE_WAKE_AND_UNLOCK,
|
||||||
FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_START_RECENTS_ANIMATION,
|
FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_START_RECENTS_ANIMATION,
|
||||||
FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_ROTATE_SCREEN_SENSOR
|
FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_ROTATE_SCREEN_SENSOR,
|
||||||
|
FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_ROTATE_SCREEN_CAMERA_CHECK
|
||||||
};
|
};
|
||||||
|
|
||||||
private static LatencyTracker sLatencyTracker;
|
private static LatencyTracker sLatencyTracker;
|
||||||
@@ -217,6 +225,8 @@ public class LatencyTracker {
|
|||||||
return "ACTION_FACE_WAKE_AND_UNLOCK";
|
return "ACTION_FACE_WAKE_AND_UNLOCK";
|
||||||
case 9:
|
case 9:
|
||||||
return "ACTION_START_RECENTS_ANIMATION";
|
return "ACTION_START_RECENTS_ANIMATION";
|
||||||
|
case 10:
|
||||||
|
return "ACTION_ROTATE_SCREEN_CAMERA_CHECK";
|
||||||
case 11:
|
case 11:
|
||||||
return "ACTION_ROTATE_SCREEN_SENSOR";
|
return "ACTION_ROTATE_SCREEN_SENSOR";
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package com.android.server.rotationresolver;
|
|||||||
|
|
||||||
import static android.service.rotationresolver.RotationResolverService.ROTATION_RESULT_FAILURE_CANCELLED;
|
import static android.service.rotationresolver.RotationResolverService.ROTATION_RESULT_FAILURE_CANCELLED;
|
||||||
|
|
||||||
|
import static com.android.internal.util.LatencyTracker.ACTION_ROTATE_SCREEN_CAMERA_CHECK;
|
||||||
import static com.android.server.rotationresolver.RotationResolverManagerService.RESOLUTION_UNAVAILABLE;
|
import static com.android.server.rotationresolver.RotationResolverManagerService.RESOLUTION_UNAVAILABLE;
|
||||||
import static com.android.server.rotationresolver.RotationResolverManagerService.logRotationStats;
|
import static com.android.server.rotationresolver.RotationResolverManagerService.logRotationStats;
|
||||||
|
|
||||||
@@ -38,6 +39,7 @@ import android.util.Slog;
|
|||||||
|
|
||||||
import com.android.internal.annotations.GuardedBy;
|
import com.android.internal.annotations.GuardedBy;
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
|
import com.android.internal.util.LatencyTracker;
|
||||||
import com.android.server.infra.AbstractPerUserSystemService;
|
import com.android.server.infra.AbstractPerUserSystemService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,10 +64,13 @@ final class RotationResolverManagerPerUserService extends
|
|||||||
RemoteRotationResolverService mRemoteService;
|
RemoteRotationResolverService mRemoteService;
|
||||||
|
|
||||||
private ComponentName mComponentName;
|
private ComponentName mComponentName;
|
||||||
|
@GuardedBy("mLock")
|
||||||
|
private LatencyTracker mLatencyTracker;
|
||||||
|
|
||||||
RotationResolverManagerPerUserService(@NonNull RotationResolverManagerService main,
|
RotationResolverManagerPerUserService(@NonNull RotationResolverManagerService main,
|
||||||
@NonNull Object lock, @UserIdInt int userId) {
|
@NonNull Object lock, @UserIdInt int userId) {
|
||||||
super(main, lock, userId);
|
super(main, lock, userId);
|
||||||
|
mLatencyTracker = LatencyTracker.getInstance(getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
@@ -108,7 +113,33 @@ final class RotationResolverManagerPerUserService extends
|
|||||||
cancelLocked();
|
cancelLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
mCurrentRequest = new RemoteRotationResolverService.RotationRequest(callbackInternal,
|
synchronized (mLock) {
|
||||||
|
mLatencyTracker.onActionStart(ACTION_ROTATE_SCREEN_CAMERA_CHECK);
|
||||||
|
}
|
||||||
|
/** Need to wrap RotationResolverCallbackInternal since there was no other way to hook
|
||||||
|
into the success/failure callback **/
|
||||||
|
final RotationResolverInternal.RotationResolverCallbackInternal wrapper =
|
||||||
|
new RotationResolverInternal.RotationResolverCallbackInternal() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(int result) {
|
||||||
|
synchronized (mLock) {
|
||||||
|
mLatencyTracker
|
||||||
|
.onActionEnd(ACTION_ROTATE_SCREEN_CAMERA_CHECK);
|
||||||
|
}
|
||||||
|
callbackInternal.onSuccess(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(int error) {
|
||||||
|
synchronized (mLock) {
|
||||||
|
mLatencyTracker
|
||||||
|
.onActionEnd(ACTION_ROTATE_SCREEN_CAMERA_CHECK);
|
||||||
|
}
|
||||||
|
callbackInternal.onFailure(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
mCurrentRequest = new RemoteRotationResolverService.RotationRequest(wrapper,
|
||||||
request, cancellationSignalInternal);
|
request, cancellationSignalInternal);
|
||||||
|
|
||||||
cancellationSignalInternal.setOnCancelListener(() -> {
|
cancellationSignalInternal.setOnCancelListener(() -> {
|
||||||
|
|||||||
Reference in New Issue
Block a user