Merge "Add ProtoLog to Vibrator Service with vibrator state."
This commit is contained in:
committed by
Android (Google) Code Review
commit
4afff3d6be
66
core/proto/android/server/vibratorservice.proto
Normal file
66
core/proto/android/server/vibratorservice.proto
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
syntax = "proto2";
|
||||
package com.android.server;
|
||||
|
||||
option java_multiple_files = true;
|
||||
|
||||
import "frameworks/base/core/proto/android/privacy.proto";
|
||||
|
||||
message WaveformProto {
|
||||
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
|
||||
repeated int32 timings = 1;
|
||||
repeated int32 amplitudes = 2;
|
||||
required bool repeat = 3;
|
||||
}
|
||||
|
||||
message PrebakedProto {
|
||||
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
|
||||
optional int32 effect_id = 1;
|
||||
optional int32 effect_strength = 2;
|
||||
optional int32 fallback = 3;
|
||||
}
|
||||
|
||||
// A com.android.os.VibrationEffect object.
|
||||
message VibrationEffectProto {
|
||||
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
|
||||
optional WaveformProto waveform = 1;
|
||||
optional PrebakedProto prebaked = 2;
|
||||
}
|
||||
|
||||
message VibrationProto {
|
||||
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
|
||||
optional int64 start_time = 1;
|
||||
optional VibrationEffectProto effect = 2;
|
||||
optional VibrationEffectProto origin_effect = 3;
|
||||
}
|
||||
|
||||
message VibratorServiceDumpProto {
|
||||
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
|
||||
optional VibrationProto current_vibration = 1;
|
||||
optional bool is_vibrating = 2;
|
||||
optional VibrationProto current_external_vibration = 3;
|
||||
optional bool vibrator_under_external_control = 4;
|
||||
optional bool low_power_mode = 5;
|
||||
optional int32 haptic_feedback_intensity = 6;
|
||||
optional int32 notification_intensity = 7;
|
||||
optional int32 ring_intensity = 8;
|
||||
repeated VibrationProto previous_ring_vibrations = 9;
|
||||
repeated VibrationProto previous_notification_vibrations = 10;
|
||||
repeated VibrationProto previous_alarm_vibrations = 11;
|
||||
repeated VibrationProto previous_vibrations = 12;
|
||||
}
|
||||
@@ -66,6 +66,7 @@ import android.util.DebugUtils;
|
||||
import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
import android.util.StatsLog;
|
||||
import android.util.proto.ProtoOutputStream;
|
||||
import android.view.InputDevice;
|
||||
|
||||
import com.android.internal.annotations.GuardedBy;
|
||||
@@ -165,6 +166,7 @@ public class VibratorService extends IVibratorService.Stub
|
||||
private ExternalVibration mCurrentExternalVibration;
|
||||
private boolean mVibratorUnderExternalControl;
|
||||
private boolean mLowPowerMode;
|
||||
private boolean mIsVibrating;
|
||||
private int mHapticFeedbackIntensity;
|
||||
private int mNotificationIntensity;
|
||||
private int mRingIntensity;
|
||||
@@ -327,6 +329,14 @@ public class VibratorService extends IVibratorService.Stub
|
||||
.append(mReason)
|
||||
.toString();
|
||||
}
|
||||
|
||||
void dumpProto(ProtoOutputStream proto, long fieldId) {
|
||||
synchronized (this) {
|
||||
final long token = proto.start(fieldId);
|
||||
proto.write(VibrationProto.START_TIME, mStartTimeDebug);
|
||||
proto.end(token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final class ScaleLevel {
|
||||
@@ -1363,6 +1373,7 @@ public class VibratorService extends IVibratorService.Stub
|
||||
StatsLog.write_non_chained(StatsLog.VIBRATOR_STATE_CHANGED, uid, null,
|
||||
StatsLog.VIBRATOR_STATE_CHANGED__STATE__ON, millis);
|
||||
mCurVibUid = uid;
|
||||
mIsVibrating = true;
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
@@ -1376,6 +1387,7 @@ public class VibratorService extends IVibratorService.Stub
|
||||
} catch (RemoteException e) { }
|
||||
mCurVibUid = -1;
|
||||
}
|
||||
mIsVibrating = false;
|
||||
}
|
||||
|
||||
private void setVibratorUnderExternalControl(boolean externalControl) {
|
||||
@@ -1390,6 +1402,93 @@ public class VibratorService extends IVibratorService.Stub
|
||||
vibratorSetExternalControl(externalControl);
|
||||
}
|
||||
|
||||
private void dumpInternal(PrintWriter pw) {
|
||||
pw.println("Vibrator Service:");
|
||||
synchronized (mLock) {
|
||||
pw.print(" mCurrentVibration=");
|
||||
if (mCurrentVibration != null) {
|
||||
pw.println(mCurrentVibration.toInfo().toString());
|
||||
} else {
|
||||
pw.println("null");
|
||||
}
|
||||
pw.print(" mCurrentExternalVibration=" + mCurrentExternalVibration);
|
||||
pw.println(" mVibratorUnderExternalControl=" + mVibratorUnderExternalControl);
|
||||
pw.println(" mIsVibrating=" + mIsVibrating);
|
||||
pw.println(" mLowPowerMode=" + mLowPowerMode);
|
||||
pw.println(" mHapticFeedbackIntensity=" + mHapticFeedbackIntensity);
|
||||
pw.println(" mNotificationIntensity=" + mNotificationIntensity);
|
||||
pw.println(" mRingIntensity=" + mRingIntensity);
|
||||
pw.println(" mSupportedEffects=" + mSupportedEffects);
|
||||
pw.println();
|
||||
pw.println(" Previous ring vibrations:");
|
||||
for (VibrationInfo info : mPreviousRingVibrations) {
|
||||
pw.print(" ");
|
||||
pw.println(info.toString());
|
||||
}
|
||||
|
||||
pw.println(" Previous notification vibrations:");
|
||||
for (VibrationInfo info : mPreviousNotificationVibrations) {
|
||||
pw.println(" " + info);
|
||||
}
|
||||
|
||||
pw.println(" Previous alarm vibrations:");
|
||||
for (VibrationInfo info : mPreviousAlarmVibrations) {
|
||||
pw.println(" " + info);
|
||||
}
|
||||
|
||||
pw.println(" Previous vibrations:");
|
||||
for (VibrationInfo info : mPreviousVibrations) {
|
||||
pw.println(" " + info);
|
||||
}
|
||||
|
||||
pw.println(" Previous external vibrations:");
|
||||
for (ExternalVibration vib : mPreviousExternalVibrations) {
|
||||
pw.println(" " + vib);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dumpProto(FileDescriptor fd) {
|
||||
final ProtoOutputStream proto = new ProtoOutputStream(fd);
|
||||
|
||||
synchronized (mLock) {
|
||||
if (mCurrentVibration != null) {
|
||||
mCurrentVibration.toInfo().dumpProto(proto,
|
||||
VibratorServiceDumpProto.CURRENT_VIBRATION);
|
||||
}
|
||||
proto.write(VibratorServiceDumpProto.IS_VIBRATING, mIsVibrating);
|
||||
proto.write(VibratorServiceDumpProto.VIBRATOR_UNDER_EXTERNAL_CONTROL,
|
||||
mVibratorUnderExternalControl);
|
||||
proto.write(VibratorServiceDumpProto.LOW_POWER_MODE, mLowPowerMode);
|
||||
proto.write(VibratorServiceDumpProto.HAPTIC_FEEDBACK_INTENSITY,
|
||||
mHapticFeedbackIntensity);
|
||||
proto.write(VibratorServiceDumpProto.NOTIFICATION_INTENSITY,
|
||||
mNotificationIntensity);
|
||||
proto.write(VibratorServiceDumpProto.RING_INTENSITY, mRingIntensity);
|
||||
|
||||
for (VibrationInfo info : mPreviousRingVibrations) {
|
||||
info.dumpProto(proto,
|
||||
VibratorServiceDumpProto.PREVIOUS_RING_VIBRATIONS);
|
||||
}
|
||||
|
||||
for (VibrationInfo info : mPreviousNotificationVibrations) {
|
||||
info.dumpProto(proto,
|
||||
VibratorServiceDumpProto.PREVIOUS_NOTIFICATION_VIBRATIONS);
|
||||
}
|
||||
|
||||
for (VibrationInfo info : mPreviousAlarmVibrations) {
|
||||
info.dumpProto(proto,
|
||||
VibratorServiceDumpProto.PREVIOUS_ALARM_VIBRATIONS);
|
||||
}
|
||||
|
||||
for (VibrationInfo info : mPreviousVibrations) {
|
||||
info.dumpProto(proto,
|
||||
VibratorServiceDumpProto.PREVIOUS_VIBRATIONS);
|
||||
}
|
||||
}
|
||||
proto.flush();
|
||||
}
|
||||
|
||||
private class VibrateThread extends Thread {
|
||||
private final VibrationEffect.Waveform mWaveform;
|
||||
private final int mUid;
|
||||
@@ -1556,47 +1655,22 @@ public class VibratorService extends IVibratorService.Stub
|
||||
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
||||
if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;
|
||||
|
||||
pw.println("Vibrator Service:");
|
||||
synchronized (mLock) {
|
||||
pw.print(" mCurrentVibration=");
|
||||
if (mCurrentVibration != null) {
|
||||
pw.println(mCurrentVibration.toInfo().toString());
|
||||
final long ident = Binder.clearCallingIdentity();
|
||||
|
||||
boolean isDumpProto = false;
|
||||
for (String arg : args) {
|
||||
if (arg.equals("--proto")) {
|
||||
isDumpProto = true;
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (isDumpProto) {
|
||||
dumpProto(fd);
|
||||
} else {
|
||||
pw.println("null");
|
||||
}
|
||||
pw.print(" mCurrentExternalVibration=" + mCurrentExternalVibration);
|
||||
pw.println(" mVibratorUnderExternalControl=" + mVibratorUnderExternalControl);
|
||||
pw.println(" mLowPowerMode=" + mLowPowerMode);
|
||||
pw.println(" mHapticFeedbackIntensity=" + mHapticFeedbackIntensity);
|
||||
pw.println(" mNotificationIntensity=" + mNotificationIntensity);
|
||||
pw.println(" mRingIntensity=" + mRingIntensity);
|
||||
pw.println(" mSupportedEffects=" + mSupportedEffects);
|
||||
pw.println();
|
||||
pw.println(" Previous ring vibrations:");
|
||||
for (VibrationInfo info : mPreviousRingVibrations) {
|
||||
pw.print(" ");
|
||||
pw.println(info.toString());
|
||||
}
|
||||
|
||||
pw.println(" Previous notification vibrations:");
|
||||
for (VibrationInfo info : mPreviousNotificationVibrations) {
|
||||
pw.println(" " + info);
|
||||
}
|
||||
|
||||
pw.println(" Previous alarm vibrations:");
|
||||
for (VibrationInfo info : mPreviousAlarmVibrations) {
|
||||
pw.println(" " + info);
|
||||
}
|
||||
|
||||
pw.println(" Previous vibrations:");
|
||||
for (VibrationInfo info : mPreviousVibrations) {
|
||||
pw.println(" " + info);
|
||||
}
|
||||
|
||||
pw.println(" Previous external vibrations:");
|
||||
for (ExternalVibration vib : mPreviousExternalVibrations) {
|
||||
pw.println(" " + vib);
|
||||
dumpInternal(pw);
|
||||
}
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(ident);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user