Fixes metrics collection in RRMS.

The current metrics collection in RRMS is incorrect. Here is the desired
behavior:

- Successfully got resolution: log the rotation result.
- Feature is disabled: log RESOLUTION_DISABLED.
- Remote service is not available: log RESOLUTION_UNAVAILABLE.
- Request timed out or no face detected: log ORIENTATION_UNKNOWN.
- All other failures: log RESOLTUION FAILURE.

Test: none.
Bug: 185512682
Change-Id: Iae94122840a3078a93b34e38fe15f9da902144cb
This commit is contained in:
Yi Jiang
2021-04-15 14:00:52 -07:00
parent 6ea16de99d
commit 1e4d75a06b
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;
}
}
}