frameworks/base
Revision | 3484a2dd5c380c9ef7a2a6e6113a1ef01f2f7aed (tree) |
---|---|
Time | 2020-02-12 04:07:20 |
Author | Alexey Kuzmin <alexeykuzmin@goog...> |
Commiter | android-build-team Robot |
Fix serialization issue of ExternalVibration
Remove excessive serialization of Audio Attributes
Bug: 140417434
Test: atest ExternalVibrationTest#testSerialization
Change-Id: Ib7ceaed875889126a53f874eec64fab4817e48d1
(cherry picked from commit b1a33a8b4fd4b1603c0465a904be29f0c4a07e64)
@@ -157,7 +157,6 @@ public class ExternalVibration implements Parcelable { | ||
157 | 157 | out.writeInt(mUid); |
158 | 158 | out.writeString(mPkg); |
159 | 159 | writeAudioAttributes(mAttrs, out, flags); |
160 | - out.writeParcelable(mAttrs, flags); | |
161 | 160 | out.writeStrongBinder(mController.asBinder()); |
162 | 161 | out.writeStrongBinder(mToken); |
163 | 162 | } |
@@ -0,0 +1,47 @@ | ||
1 | +/* | |
2 | + * Copyright (C) 2020 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; | |
18 | + | |
19 | +import static junit.framework.Assert.assertEquals; | |
20 | + | |
21 | +import static org.mockito.Mockito.mock; | |
22 | + | |
23 | +import android.media.AudioAttributes; | |
24 | + | |
25 | +import org.junit.Test; | |
26 | +import org.junit.runner.RunWith; | |
27 | +import org.mockito.junit.MockitoJUnitRunner; | |
28 | + | |
29 | +@RunWith(MockitoJUnitRunner.class) | |
30 | +public class ExternalVibrationTest { | |
31 | + @Test | |
32 | + public void testSerialization() { | |
33 | + AudioAttributes audio = new AudioAttributes.Builder().build(); | |
34 | + IExternalVibrationController controller = mock(IExternalVibrationController.class); | |
35 | + ExternalVibration original = new ExternalVibration( | |
36 | + 123, // uid | |
37 | + "pkg", | |
38 | + audio, | |
39 | + controller); | |
40 | + Parcel p = Parcel.obtain(); | |
41 | + original.writeToParcel(p, 0); | |
42 | + p.setDataPosition(0); | |
43 | + ExternalVibration restored = ExternalVibration.CREATOR.createFromParcel(p); | |
44 | + assertEquals(original, restored); | |
45 | + } | |
46 | +} | |
47 | + |