Loading core/proto/android/server/vibratorservice.proto 0 → 100644 +66 −0 Original line number Diff line number Diff line /* * 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; } No newline at end of file services/core/java/com/android/server/VibratorService.java +112 −38 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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 { Loading Loading @@ -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) { } } Loading @@ -1376,6 +1387,7 @@ public class VibratorService extends IVibratorService.Stub } catch (RemoteException e) { } mCurVibUid = -1; } mIsVibrating = false; } private void setVibratorUnderExternalControl(boolean externalControl) { Loading @@ -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; Loading Loading @@ -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()); } 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()); } final long ident = Binder.clearCallingIdentity(); pw.println(" Previous notification vibrations:"); for (VibrationInfo info : mPreviousNotificationVibrations) { pw.println(" " + info); } pw.println(" Previous alarm vibrations:"); for (VibrationInfo info : mPreviousAlarmVibrations) { pw.println(" " + info); boolean isDumpProto = false; for (String arg : args) { if (arg.equals("--proto")) { isDumpProto = true; } pw.println(" Previous vibrations:"); for (VibrationInfo info : mPreviousVibrations) { pw.println(" " + info); } pw.println(" Previous external vibrations:"); for (ExternalVibration vib : mPreviousExternalVibrations) { pw.println(" " + vib); try { if (isDumpProto) { dumpProto(fd); } else { dumpInternal(pw); } } finally { Binder.restoreCallingIdentity(ident); } } Loading Loading
core/proto/android/server/vibratorservice.proto 0 → 100644 +66 −0 Original line number Diff line number Diff line /* * 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; } No newline at end of file
services/core/java/com/android/server/VibratorService.java +112 −38 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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 { Loading Loading @@ -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) { } } Loading @@ -1376,6 +1387,7 @@ public class VibratorService extends IVibratorService.Stub } catch (RemoteException e) { } mCurVibUid = -1; } mIsVibrating = false; } private void setVibratorUnderExternalControl(boolean externalControl) { Loading @@ -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; Loading Loading @@ -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()); } 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()); } final long ident = Binder.clearCallingIdentity(); pw.println(" Previous notification vibrations:"); for (VibrationInfo info : mPreviousNotificationVibrations) { pw.println(" " + info); } pw.println(" Previous alarm vibrations:"); for (VibrationInfo info : mPreviousAlarmVibrations) { pw.println(" " + info); boolean isDumpProto = false; for (String arg : args) { if (arg.equals("--proto")) { isDumpProto = true; } pw.println(" Previous vibrations:"); for (VibrationInfo info : mPreviousVibrations) { pw.println(" " + info); } pw.println(" Previous external vibrations:"); for (ExternalVibration vib : mPreviousExternalVibrations) { pw.println(" " + vib); try { if (isDumpProto) { dumpProto(fd); } else { dumpInternal(pw); } } finally { Binder.restoreCallingIdentity(ident); } } Loading