Merge "Setup metrics collection in rotation resolver manager." into sc-dev
This commit is contained in:
@@ -21,6 +21,9 @@ 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 android.annotation.NonNull;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
@@ -29,6 +32,7 @@ import android.os.CancellationSignal;
|
||||
import android.os.Handler;
|
||||
import android.os.ICancellationSignal;
|
||||
import android.os.RemoteException;
|
||||
import android.os.SystemClock;
|
||||
import android.rotationresolver.RotationResolverInternal;
|
||||
import android.service.rotationresolver.IRotationResolverCallback;
|
||||
import android.service.rotationresolver.IRotationResolverService;
|
||||
@@ -112,6 +116,7 @@ class RemoteRotationResolverService extends ServiceConnector.Impl<IRotationResol
|
||||
|
||||
boolean mIsDispatched;
|
||||
private final Object mLock = new Object();
|
||||
private final long mRequestStartTimeMillis;
|
||||
|
||||
RotationRequest(
|
||||
@NonNull RotationResolverInternal.RotationResolverCallbackInternal
|
||||
@@ -125,6 +130,7 @@ class RemoteRotationResolverService extends ServiceConnector.Impl<IRotationResol
|
||||
mPackageName = packageName;
|
||||
mIRotationResolverCallback = new RotationResolverCallback();
|
||||
mCancellationSignalInternal = cancellationSignal;
|
||||
mRequestStartTimeMillis = SystemClock.elapsedRealtime();
|
||||
}
|
||||
|
||||
|
||||
@@ -164,7 +170,10 @@ class RemoteRotationResolverService extends ServiceConnector.Impl<IRotationResol
|
||||
}
|
||||
mIsFulfilled = true;
|
||||
mCallbackInternal.onSuccess(rotation);
|
||||
logStats(rotation);
|
||||
final long timeToCalculate =
|
||||
SystemClock.elapsedRealtime() - mRequestStartTimeMillis;
|
||||
logRotationStats(mProposedRotation, mCurrentRotation, rotation,
|
||||
timeToCalculate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,7 +186,10 @@ class RemoteRotationResolverService extends ServiceConnector.Impl<IRotationResol
|
||||
}
|
||||
mIsFulfilled = true;
|
||||
mCallbackInternal.onFailure(error);
|
||||
logStats(error);
|
||||
final long timeToCalculate =
|
||||
SystemClock.elapsedRealtime() - mRequestStartTimeMillis;
|
||||
logRotationStats(mProposedRotation, mCurrentRotation, RESOLUTION_FAILURE,
|
||||
timeToCalculate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,10 +208,6 @@ class RemoteRotationResolverService extends ServiceConnector.Impl<IRotationResol
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void logStats(int result) {
|
||||
// TODO FrameworkStatsLog
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,9 @@ package com.android.server.rotationresolver;
|
||||
|
||||
import static android.service.rotationresolver.RotationResolverService.ROTATION_RESULT_FAILURE_CANCELLED;
|
||||
|
||||
import static com.android.server.rotationresolver.RotationResolverManagerService.RESOLUTION_UNAVAILABLE;
|
||||
import static com.android.server.rotationresolver.RotationResolverManagerService.getServiceConfigPackage;
|
||||
import static com.android.server.rotationresolver.RotationResolverManagerService.logRotationStats;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.NonNull;
|
||||
@@ -98,6 +100,7 @@ final class RotationResolverManagerPerUserService extends
|
||||
if (!isServiceAvailableLocked()) {
|
||||
Slog.w(TAG, "Service is not available at this moment.");
|
||||
callbackInternal.onFailure(ROTATION_RESULT_FAILURE_CANCELLED);
|
||||
logRotationStats(proposedRotation, currentRotation, RESOLUTION_UNAVAILABLE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,11 @@ 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 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;
|
||||
import static com.android.internal.util.FrameworkStatsLog.AUTO_ROTATE_REPORTED__PROPOSED_ORIENTATION__ROTATION_270;
|
||||
import static com.android.internal.util.FrameworkStatsLog.AUTO_ROTATE_REPORTED__PROPOSED_ORIENTATION__ROTATION_90;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.UserIdInt;
|
||||
@@ -33,9 +38,11 @@ import android.rotationresolver.RotationResolverInternal;
|
||||
import android.text.TextUtils;
|
||||
import android.util.IndentingPrintWriter;
|
||||
import android.util.Slog;
|
||||
import android.view.Surface;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.internal.util.DumpUtils;
|
||||
import com.android.internal.util.FrameworkStatsLog;
|
||||
import com.android.server.SystemService;
|
||||
import com.android.server.infra.AbstractMasterSystemService;
|
||||
import com.android.server.infra.FrameworkResourcesServiceNameResolver;
|
||||
@@ -61,6 +68,15 @@ public class RotationResolverManagerService extends
|
||||
/** Default value in absence of {@link DeviceConfig} override. */
|
||||
private static final boolean DEFAULT_SERVICE_ENABLED = false;
|
||||
|
||||
static final int ORIENTATION_UNKNOWN =
|
||||
FrameworkStatsLog.AUTO_ROTATE_REPORTED__PROPOSED_ORIENTATION__UNKNOWN;
|
||||
static final int RESOLUTION_DISABLED =
|
||||
FrameworkStatsLog.AUTO_ROTATE_REPORTED__PROPOSED_ORIENTATION__DISABLED;
|
||||
static final int RESOLUTION_UNAVAILABLE =
|
||||
FrameworkStatsLog.AUTO_ROTATE_REPORTED__PROPOSED_ORIENTATION__UNAVAILABLE;
|
||||
static final int RESOLUTION_FAILURE =
|
||||
FrameworkStatsLog.AUTO_ROTATE_REPORTED__PROPOSED_ORIENTATION__FAILURE;
|
||||
|
||||
private final Context mContext;
|
||||
boolean mIsServiceEnabled;
|
||||
|
||||
@@ -147,6 +163,7 @@ public class RotationResolverManagerService extends
|
||||
} else {
|
||||
Slog.w(TAG, "Rotation Resolver service is disabled.");
|
||||
callbackInternal.onFailure(ROTATION_RESULT_FAILURE_CANCELLED);
|
||||
logRotationStats(proposedRotation, currentRotation, RESOLUTION_DISABLED);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -178,4 +195,36 @@ public class RotationResolverManagerService extends
|
||||
resultReceiver);
|
||||
}
|
||||
}
|
||||
|
||||
static void logRotationStats(int proposedRotation, int currentRotation,
|
||||
int resolvedRotation, long timeToCalculate) {
|
||||
FrameworkStatsLog.write(FrameworkStatsLog.AUTO_ROTATE_REPORTED,
|
||||
/* previous_orientation= */ surfaceRotationToProto(currentRotation),
|
||||
/* proposed_orientation= */ surfaceRotationToProto(proposedRotation),
|
||||
/* resolved_orientation= */ surfaceRotationToProto(resolvedRotation),
|
||||
/* process_duration_millis= */ timeToCalculate);
|
||||
}
|
||||
|
||||
static void logRotationStats(int proposedRotation, int currentRotation,
|
||||
int resolvedRotation) {
|
||||
FrameworkStatsLog.write(FrameworkStatsLog.AUTO_ROTATE_REPORTED,
|
||||
/* previous_orientation= */ surfaceRotationToProto(currentRotation),
|
||||
/* proposed_orientation= */ surfaceRotationToProto(proposedRotation),
|
||||
/* resolved_orientation= */ surfaceRotationToProto(resolvedRotation));
|
||||
}
|
||||
|
||||
private static int surfaceRotationToProto(@Surface.Rotation int rotationPoseResult) {
|
||||
switch (rotationPoseResult) {
|
||||
case Surface.ROTATION_0:
|
||||
return AUTO_ROTATE_REPORTED__PROPOSED_ORIENTATION__ROTATION_0;
|
||||
case Surface.ROTATION_90:
|
||||
return AUTO_ROTATE_REPORTED__PROPOSED_ORIENTATION__ROTATION_90;
|
||||
case Surface.ROTATION_180:
|
||||
return AUTO_ROTATE_REPORTED__PROPOSED_ORIENTATION__ROTATION_180;
|
||||
case Surface.ROTATION_270:
|
||||
return AUTO_ROTATE_REPORTED__PROPOSED_ORIENTATION__ROTATION_270;
|
||||
default:
|
||||
return ORIENTATION_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user