• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.os.vibrator;
18 
19 import java.util.Objects;
20 
21 /**
22  * A {@link PwlePoint} represents a single point in an envelope vibration effect. Defined by its
23  * amplitude, frequency and time to transition to this point from the previous one in the envelope.
24  *
25  * @hide
26  */
27 public final class PwlePoint {
28     private final float mAmplitude;
29     private final float mFrequencyHz;
30     private final int mTimeMillis;
31 
32     /** @hide */
PwlePoint(float amplitude, float frequencyHz, int timeMillis)33     public PwlePoint(float amplitude, float frequencyHz, int timeMillis) {
34         mAmplitude = amplitude;
35         mFrequencyHz = frequencyHz;
36         mTimeMillis = timeMillis;
37     }
38 
getAmplitude()39     public float getAmplitude() {
40         return mAmplitude;
41     }
42 
getFrequencyHz()43     public float getFrequencyHz() {
44         return mFrequencyHz;
45     }
46 
getTimeMillis()47     public int getTimeMillis() {
48         return mTimeMillis;
49     }
50 
51     @Override
equals(Object obj)52     public boolean equals(Object obj) {
53         if (!(obj instanceof PwlePoint)) {
54             return false;
55         }
56         PwlePoint other = (PwlePoint) obj;
57         return Float.compare(mAmplitude, other.mAmplitude) == 0
58                 && Float.compare(mFrequencyHz, other.mFrequencyHz) == 0
59                 && mTimeMillis == other.mTimeMillis;
60     }
61 
62     @Override
hashCode()63     public int hashCode() {
64         return Objects.hash(mAmplitude, mFrequencyHz, mTimeMillis);
65     }
66 
67     @Override
toString()68     public String toString() {
69         return "PwlePoint{amplitude=" + mAmplitude
70                 + ", frequency=" + mFrequencyHz
71                 + ", time=" + mTimeMillis
72                 + "}";
73     }
74 }
75