Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 78c7be7c authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Clean up after VibratorManager feature introduced" into sc-dev

parents 0e588cc3 43bf4611
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
# Haptics
per-file CombinedVibrationEffect.aidl = michaelwr@google.com
per-file CombinedVibrationEffect.java = michaelwr@google.com
per-file ExternalVibration.aidl = michaelwr@google.com
per-file ExternalVibration.java = michaelwr@google.com
per-file IExternalVibrationController.aidl = michaelwr@google.com
@@ -6,9 +8,11 @@ per-file IExternalVibratorService.aidl = michaelwr@google.com
per-file IVibratorManagerService.aidl = michaelwr@google.com
per-file NullVibrator.java = michaelwr@google.com
per-file SystemVibrator.java = michaelwr@google.com
per-file SystemVibratorManager.java = michaelwr@google.com
per-file VibrationEffect.aidl = michaelwr@google.com
per-file VibrationEffect.java = michaelwr@google.com
per-file Vibrator.java = michaelwr@google.com
per-file VibratorManager.java = michaelwr@google.com

# PowerManager
per-file IPowerManager.aidl = michaelwr@google.com, santoscordon@google.com
+39 −25
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
 */

syntax = "proto2";
package com.android.server;
package com.android.server.vibrator;

option java_multiple_files = true;

@@ -51,12 +51,25 @@ message ComposedProto {
// A com.android.os.VibrationEffect object.
message VibrationEffectProto {
    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
    optional OneShotProto oneshot = 3;
    optional WaveformProto waveform = 1;
    optional PrebakedProto prebaked = 2;
    optional OneShotProto oneshot = 1;
    optional WaveformProto waveform = 2;
    optional PrebakedProto prebaked = 3;
    optional ComposedProto composed = 4;
}

message SyncVibrationEffectProto {
    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
    repeated VibrationEffectProto effects = 1;
    repeated int32 vibrator_ids = 2;
}

// A com.android.os.CombinedVibrationEffect object.
message CombinedVibrationEffectProto {
    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
    repeated SyncVibrationEffectProto effects = 1;
    repeated int32 delays = 2;
}

message VibrationAttributesProto {
    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
    optional int32 usage = 1;
@@ -68,30 +81,31 @@ message VibrationAttributesProto {
message VibrationProto {
    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
    optional int64 start_time = 1;
    optional int64 end_time = 4;
    optional VibrationEffectProto effect = 2;
    optional VibrationEffectProto original_effect = 3;
    optional int64 end_time = 2;
    optional CombinedVibrationEffectProto effect = 3;
    optional CombinedVibrationEffectProto original_effect = 4;
    optional VibrationAttributesProto attributes = 5;
    optional int32 status = 6;
}

// Next id: 17
message VibratorServiceDumpProto {
// Next id: 18
message VibratorManagerServiceDumpProto {
    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 haptic_feedback_default_intensity = 14;
    optional int32 notification_intensity = 7;
    optional int32 notification_default_intensity = 15;
    optional int32 ring_intensity = 8;
    optional int32 ring_default_intensity = 16;
    repeated VibrationProto previous_ring_vibrations = 9;
    repeated VibrationProto previous_notification_vibrations = 10;
    repeated VibrationProto previous_alarm_vibrations = 11;
    repeated VibrationProto previous_vibrations = 12;
    repeated VibrationProto previous_external_vibrations = 13;
    repeated int32 vibrator_ids = 1;
    optional VibrationProto current_vibration = 2;
    optional bool is_vibrating = 3;
    optional VibrationProto current_external_vibration = 4;
    optional bool vibrator_under_external_control = 5;
    optional bool low_power_mode = 6;
    optional int32 haptic_feedback_intensity = 7;
    optional int32 haptic_feedback_default_intensity = 8;
    optional int32 notification_intensity = 9;
    optional int32 notification_default_intensity = 10;
    optional int32 ring_intensity = 11;
    optional int32 ring_default_intensity = 12;
    repeated VibrationProto previous_ring_vibrations = 13;
    repeated VibrationProto previous_notification_vibrations = 14;
    repeated VibrationProto previous_alarm_vibrations = 15;
    repeated VibrationProto previous_vibrations = 16;
    repeated VibrationProto previous_external_vibrations = 17;
}
 No newline at end of file
+3 −0
Original line number Diff line number Diff line
@@ -2,8 +2,11 @@
per-file BrightnessLimit.java = michaelwr@google.com, santoscordon@google.com

# Haptics
per-file CombinedVibrationEffectTest.java = michaelwr@google.com
per-file ExternalVibrationTest.java = michaelwr@google.com
per-file VibrationEffectTest.java = michaelwr@google.com
per-file VibratorInfoTest.java = michaelwr@google.com
per-file VibratorTest.java = michaelwr@google.com

# Power
per-file PowerManager*.java = michaelwr@google.com, santoscordon@google.com
+2 −2
Original line number Diff line number Diff line
# Connectivity / Networking
per-file ConnectivityService.java,ConnectivityServiceInitializer.java,NetworkManagementService.java,NsdService.java = file:/services/core/java/com/android/server/net/OWNERS

# Vibrator / Threads
per-file VibratorManagerService.java, DisplayThread.java = michaelwr@google.com, ogunwale@google.com
# Threads
per-file DisplayThread.java = michaelwr@google.com, ogunwale@google.com

# Zram writeback
per-file ZramWriteback.java = minchan@google.com, rajekumar@google.com
+15 −27
Original line number Diff line number Diff line
@@ -21,16 +21,14 @@ import android.hardware.input.InputManager;
import android.os.CombinedVibrationEffect;
import android.os.Handler;
import android.os.VibrationAttributes;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.os.VibratorManager;
import android.util.SparseArray;
import android.view.InputDevice;

import com.android.internal.annotations.GuardedBy;

/** Delegates vibrations to all connected {@link InputDevice} with available {@link Vibrator}. */
// TODO(b/159207608): Make this package-private once vibrator services are moved to this package
public final class InputDeviceDelegate implements InputManager.InputDeviceListener {
/** Delegates vibrations to all connected {@link InputDevice} with one or more vibrators. */
final class InputDeviceDelegate implements InputManager.InputDeviceListener {
    private static final String TAG = "InputDeviceDelegate";

    private final Object mLock = new Object();
@@ -38,7 +36,7 @@ public final class InputDeviceDelegate implements InputManager.InputDeviceListen
    private final InputManager mInputManager;

    @GuardedBy("mLock")
    private final SparseArray<Vibrator> mInputDeviceVibrators = new SparseArray<>();
    private final SparseArray<VibratorManager> mInputDeviceVibrators = new SparseArray<>();

    /**
     * Flag updated via {@link #updateInputDeviceVibrators(boolean)}, holding the value of {@link
@@ -47,7 +45,7 @@ public final class InputDeviceDelegate implements InputManager.InputDeviceListen
    @GuardedBy("mLock")
    private boolean mShouldVibrateInputDevices;

    public InputDeviceDelegate(Context context, Handler handler) {
    InputDeviceDelegate(Context context, Handler handler) {
        mHandler = handler;
        mInputManager = context.getSystemService(InputManager.class);
    }
@@ -81,32 +79,22 @@ public final class InputDeviceDelegate implements InputManager.InputDeviceListen
    }

    /**
     * Vibrate all {@link InputDevice} with {@link Vibrator} available using given effect.
     * Vibrate all {@link InputDevice} with vibrators using given effect.
     *
     * @return {@link #isAvailable()}
     */
    public boolean vibrateIfAvailable(int uid, String opPkg, CombinedVibrationEffect effect,
            String reason, VibrationAttributes attrs) {
        synchronized (mLock) {
            // TODO(b/159207608): Pass on the combined vibration once InputManager is merged
            if (effect instanceof CombinedVibrationEffect.Mono) {
                VibrationEffect e = ((CombinedVibrationEffect.Mono) effect).getEffect();
                if (e instanceof VibrationEffect.Prebaked) {
                    VibrationEffect fallback = ((VibrationEffect.Prebaked) e).getFallbackEffect();
                    if (fallback != null) {
                        e = fallback;
                    }
                }
            for (int i = 0; i < mInputDeviceVibrators.size(); i++) {
                    mInputDeviceVibrators.valueAt(i).vibrate(uid, opPkg, e, reason, attrs);
                }
                mInputDeviceVibrators.valueAt(i).vibrate(uid, opPkg, effect, reason, attrs);
            }
            return mInputDeviceVibrators.size() > 0;
        }
    }

    /**
     * Cancel vibration on all {@link InputDevice} with {@link Vibrator} available.
     * Cancel vibration on all {@link InputDevice} with vibrators.
     *
     * @return {@link #isAvailable()}
     */
@@ -147,9 +135,9 @@ public final class InputDeviceDelegate implements InputManager.InputDeviceListen
                    if (device == null) {
                        continue;
                    }
                    Vibrator vibrator = device.getVibrator();
                    if (vibrator.hasVibrator()) {
                        mInputDeviceVibrators.put(device.getId(), vibrator);
                    VibratorManager vibratorManager = device.getVibratorManager();
                    if (vibratorManager.getVibratorIds().length > 0) {
                        mInputDeviceVibrators.put(device.getId(), vibratorManager);
                    }
                }
            } else {
@@ -171,9 +159,9 @@ public final class InputDeviceDelegate implements InputManager.InputDeviceListen
                mInputDeviceVibrators.remove(deviceId);
                return;
            }
            Vibrator vibrator = device.getVibrator();
            if (vibrator.hasVibrator()) {
                mInputDeviceVibrators.put(deviceId, vibrator);
            VibratorManager vibratorManager = device.getVibratorManager();
            if (vibratorManager.getVibratorIds().length > 0) {
                mInputDeviceVibrators.put(device.getId(), vibratorManager);
            } else {
                mInputDeviceVibrators.remove(deviceId);
            }
Loading