Merge "Fixes metrics collection in RRMS." into sc-dev

This commit is contained in:
Yi Jiang
2021-04-19 06:25:54 +00:00
committed by Android (Google) Code Review
2 changed files with 34 additions and 13 deletions

View File

@@ -21,8 +21,8 @@ import static android.content.Context.BIND_INCLUDE_CAPABILITIES;
import static android.service.rotationresolver.RotationResolverService.ROTATION_RESULT_FAILURE_CANCELLED;
import static android.service.rotationresolver.RotationResolverService.ROTATION_RESULT_FAILURE_TIMED_OUT;
import static com.android.server.rotationresolver.RotationResolverManagerService.RESOLUTION_FAILURE;
import static com.android.server.rotationresolver.RotationResolverManagerService.logRotationStats;
import static com.android.server.rotationresolver.RotationResolverManagerService.errorCodeToProto;
import static com.android.server.rotationresolver.RotationResolverManagerService.surfaceRotationToProto;
import android.annotation.NonNull;
import android.content.ComponentName;
@@ -173,8 +173,10 @@ class RemoteRotationResolverService extends ServiceConnector.Impl<IRotationResol
request.mCallbackInternal.onSuccess(rotation);
final long timeToCalculate =
SystemClock.elapsedRealtime() - request.mRequestStartTimeMillis;
logRotationStats(request.mRemoteRequest.getProposedRotation(),
request.mRemoteRequest.getCurrentRotation(), rotation, timeToCalculate);
RotationResolverManagerService.logRotationStatsWithTimeToCalculate(
request.mRemoteRequest.getProposedRotation(),
request.mRemoteRequest.getCurrentRotation(),
surfaceRotationToProto(rotation), timeToCalculate);
Slog.d(TAG, "onSuccess:" + rotation);
Slog.d(TAG, "timeToCalculate:" + timeToCalculate);
}
@@ -192,8 +194,9 @@ class RemoteRotationResolverService extends ServiceConnector.Impl<IRotationResol
request.mCallbackInternal.onFailure(error);
final long timeToCalculate =
SystemClock.elapsedRealtime() - request.mRequestStartTimeMillis;
logRotationStats(request.mRemoteRequest.getProposedRotation(),
request.mRemoteRequest.getCurrentRotation(), RESOLUTION_FAILURE,
RotationResolverManagerService.logRotationStatsWithTimeToCalculate(
request.mRemoteRequest.getProposedRotation(),
request.mRemoteRequest.getCurrentRotation(), errorCodeToProto(error),
timeToCalculate);
Slog.d(TAG, "onFailure:" + error);
Slog.d(TAG, "timeToCalculate:" + timeToCalculate);

View File

@@ -18,6 +18,9 @@ package com.android.server.rotationresolver;
import static android.provider.DeviceConfig.NAMESPACE_ROTATION_RESOLVER;
import static android.service.rotationresolver.RotationResolverService.ROTATION_RESULT_FAILURE_CANCELLED;
import static android.service.rotationresolver.RotationResolverService.ROTATION_RESULT_FAILURE_NOT_SUPPORTED;
import static android.service.rotationresolver.RotationResolverService.ROTATION_RESULT_FAILURE_PREEMPTED;
import static android.service.rotationresolver.RotationResolverService.ROTATION_RESULT_FAILURE_TIMED_OUT;
import static com.android.internal.util.FrameworkStatsLog.AUTO_ROTATE_REPORTED__PROPOSED_ORIENTATION__ROTATION_0;
import static com.android.internal.util.FrameworkStatsLog.AUTO_ROTATE_REPORTED__PROPOSED_ORIENTATION__ROTATION_180;
@@ -37,6 +40,7 @@ import android.os.UserHandle;
import android.provider.DeviceConfig;
import android.rotationresolver.RotationResolverInternal;
import android.service.rotationresolver.RotationResolutionRequest;
import android.service.rotationresolver.RotationResolverService;
import android.text.TextUtils;
import android.util.IndentingPrintWriter;
import android.util.Slog;
@@ -217,24 +221,37 @@ public class RotationResolverManagerService extends
}
}
static void logRotationStats(int proposedRotation, int currentRotation,
int resolvedRotation, long timeToCalculate) {
static void logRotationStatsWithTimeToCalculate(int proposedRotation, int currentRotation,
int result, long timeToCalculate) {
FrameworkStatsLog.write(FrameworkStatsLog.AUTO_ROTATE_REPORTED,
/* previous_orientation= */ surfaceRotationToProto(currentRotation),
/* proposed_orientation= */ surfaceRotationToProto(proposedRotation),
/* resolved_orientation= */ surfaceRotationToProto(resolvedRotation),
result,
/* process_duration_millis= */ timeToCalculate);
}
static void logRotationStats(int proposedRotation, int currentRotation,
int resolvedRotation) {
int result) {
FrameworkStatsLog.write(FrameworkStatsLog.AUTO_ROTATE_REPORTED,
/* previous_orientation= */ surfaceRotationToProto(currentRotation),
/* proposed_orientation= */ surfaceRotationToProto(proposedRotation),
/* resolved_orientation= */ surfaceRotationToProto(resolvedRotation));
result);
}
private static int surfaceRotationToProto(@Surface.Rotation int rotationPoseResult) {
static int errorCodeToProto(@RotationResolverService.FailureCodes int error) {
switch (error) {
case ROTATION_RESULT_FAILURE_NOT_SUPPORTED:
return RESOLUTION_UNAVAILABLE;
case ROTATION_RESULT_FAILURE_TIMED_OUT:
case ROTATION_RESULT_FAILURE_PREEMPTED:
case ROTATION_RESULT_FAILURE_CANCELLED:
return ORIENTATION_UNKNOWN;
default:
return RESOLUTION_FAILURE;
}
}
static int surfaceRotationToProto(@Surface.Rotation int rotationPoseResult) {
switch (rotationPoseResult) {
case Surface.ROTATION_0:
return AUTO_ROTATE_REPORTED__PROPOSED_ORIENTATION__ROTATION_0;
@@ -245,7 +262,8 @@ public class RotationResolverManagerService extends
case Surface.ROTATION_270:
return AUTO_ROTATE_REPORTED__PROPOSED_ORIENTATION__ROTATION_270;
default:
return ORIENTATION_UNKNOWN;
// Should not reach here.
return RESOLUTION_FAILURE;
}
}
}