diff options
author | Alexey Kuzmin <alexeykuzmin@google.com> | 2020-01-07 11:59:18 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2020-02-11 19:07:20 +0000 |
commit | 3484a2dd5c380c9ef7a2a6e6113a1ef01f2f7aed (patch) | |
tree | 11d339992e802992b073c6eb0ff48a7dddb25d16 | |
parent | 21b9dc78d6d441f51cc1635563d68cb15afd9e2b (diff) | |
download | base-3484a2dd5c380c9ef7a2a6e6113a1ef01f2f7aed.tar.gz |
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)
-rw-r--r-- | core/java/android/os/ExternalVibration.java | 1 | ||||
-rw-r--r-- | core/tests/coretests/src/android/os/ExternalVibrationTest.java | 47 |
2 files changed, 47 insertions, 1 deletions
diff --git a/core/java/android/os/ExternalVibration.java b/core/java/android/os/ExternalVibration.java index 37ca868598f5..041d21fabd6f 100644 --- a/core/java/android/os/ExternalVibration.java +++ b/core/java/android/os/ExternalVibration.java @@ -157,7 +157,6 @@ public class ExternalVibration implements Parcelable { out.writeInt(mUid); out.writeString(mPkg); writeAudioAttributes(mAttrs, out, flags); - out.writeParcelable(mAttrs, flags); out.writeStrongBinder(mController.asBinder()); out.writeStrongBinder(mToken); } diff --git a/core/tests/coretests/src/android/os/ExternalVibrationTest.java b/core/tests/coretests/src/android/os/ExternalVibrationTest.java new file mode 100644 index 000000000000..3b872d5a7ff1 --- /dev/null +++ b/core/tests/coretests/src/android/os/ExternalVibrationTest.java @@ -0,0 +1,47 @@ +/* + * 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. + */ + +package android.os; + +import static junit.framework.Assert.assertEquals; + +import static org.mockito.Mockito.mock; + +import android.media.AudioAttributes; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.junit.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class ExternalVibrationTest { + @Test + public void testSerialization() { + AudioAttributes audio = new AudioAttributes.Builder().build(); + IExternalVibrationController controller = mock(IExternalVibrationController.class); + ExternalVibration original = new ExternalVibration( + 123, // uid + "pkg", + audio, + controller); + Parcel p = Parcel.obtain(); + original.writeToParcel(p, 0); + p.setDataPosition(0); + ExternalVibration restored = ExternalVibration.CREATOR.createFromParcel(p); + assertEquals(original, restored); + } +} + |