summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Priyanka Advani <padvani@google.com> 2023-12-07 19:15:05 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-12-07 19:15:05 +0000
commitcfa96407ad75f4be14fa1f2ac4d69c619b0bebcf (patch)
tree9a054e28305cdf5e2d75e99a9f34dec3f7b237d3
parent31b1d0408d919f52ea5e101bda892e339fa82894 (diff)
parent93251b300ab2f39ed0faf854d227bf4f1460785a (diff)
Merge "Revert "Introducing VibratorControlService"" into main
-rw-r--r--core/java/android/os/vibrator/flags.aconfig7
-rw-r--r--services/core/Android.bp1
-rw-r--r--services/core/java/com/android/server/vibrator/VibratorControlService.java105
-rw-r--r--services/core/java/com/android/server/vibrator/VibratorControllerHolder.java70
-rw-r--r--services/core/java/com/android/server/vibrator/VibratorManagerService.java8
-rw-r--r--services/manifest_services.xml10
-rw-r--r--services/tests/vibrator/src/com/android/server/vibrator/VibratorControlServiceTest.java63
-rw-r--r--services/tests/vibrator/src/com/android/server/vibrator/VibratorControllerHolderTest.java72
-rw-r--r--services/tests/vibrator/src/com/android/server/vibrator/VibratorManagerServiceTest.java7
-rw-r--r--services/tests/vibrator/utils/com/android/server/vibrator/FakeVibratorController.java58
10 files changed, 3 insertions, 398 deletions
diff --git a/core/java/android/os/vibrator/flags.aconfig b/core/java/android/os/vibrator/flags.aconfig
index 437668c9a7de..69d86a6604ad 100644
--- a/core/java/android/os/vibrator/flags.aconfig
+++ b/core/java/android/os/vibrator/flags.aconfig
@@ -44,10 +44,3 @@ flag {
description: "Enables the independent keyboard vibration settings feature"
bug: "289107579"
}
-
-flag {
- namespace: "haptics"
- name: "adaptive_haptics_enabled"
- description: "Enables the adaptive haptics feature"
- bug: "305961689"
-}
diff --git a/services/core/Android.bp b/services/core/Android.bp
index b4cf34e00c53..20a3b9ada85d 100644
--- a/services/core/Android.bp
+++ b/services/core/Android.bp
@@ -154,7 +154,6 @@ java_library_static {
static_libs: [
"android.frameworks.location.altitude-V1-java", // AIDL
- "android.frameworks.vibrator-V1-java", // AIDL
"android.hardware.authsecret-V1.0-java",
"android.hardware.authsecret-V1-java",
"android.hardware.boot-V1.0-java", // HIDL
diff --git a/services/core/java/com/android/server/vibrator/VibratorControlService.java b/services/core/java/com/android/server/vibrator/VibratorControlService.java
deleted file mode 100644
index 2eeb903bb551..000000000000
--- a/services/core/java/com/android/server/vibrator/VibratorControlService.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (C) 2023 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 com.android.server.vibrator;
-
-import android.annotation.NonNull;
-import android.annotation.SuppressLint;
-import android.frameworks.vibrator.IVibratorControlService;
-import android.frameworks.vibrator.IVibratorController;
-import android.frameworks.vibrator.VibrationParam;
-import android.os.IBinder;
-import android.os.RemoteException;
-import android.util.Slog;
-
-import java.util.Objects;
-
-/**
- * Implementation of {@link IVibratorControlService} which allows the registration of
- * {@link IVibratorController} to set and receive vibration params.
- *
- * @hide
- */
-public final class VibratorControlService extends IVibratorControlService.Stub {
- private static final String TAG = "VibratorControlService";
-
- private final VibratorControllerHolder mVibratorControllerHolder;
- private final Object mLock;
-
- public VibratorControlService(VibratorControllerHolder vibratorControllerHolder, Object lock) {
- mVibratorControllerHolder = vibratorControllerHolder;
- mLock = lock;
- }
-
- @Override
- public void registerVibratorController(IVibratorController controller)
- throws RemoteException {
- synchronized (mLock) {
- mVibratorControllerHolder.setVibratorController(controller);
- }
- }
-
- @Override
- public void unregisterVibratorController(@NonNull IVibratorController controller)
- throws RemoteException {
- Objects.requireNonNull(controller);
-
- synchronized (mLock) {
- if (mVibratorControllerHolder.getVibratorController() == null) {
- Slog.w(TAG, "Received request to unregister IVibratorController = "
- + controller + ", but no controller was previously registered. Request "
- + "Ignored.");
- return;
- }
- if (!Objects.equals(mVibratorControllerHolder.getVibratorController().asBinder(),
- controller.asBinder())) {
- Slog.wtf(TAG, "Failed to unregister IVibratorController. The provided "
- + "controller doesn't match the registered one. " + this);
- return;
- }
- mVibratorControllerHolder.setVibratorController(null);
- }
- }
-
- @Override
- public void setVibrationParams(
- @SuppressLint("ArrayReturn") VibrationParam[] params, IVibratorController token)
- throws RemoteException {
- // TODO(b/305939964): Add set vibration implementation.
- }
-
- @Override
- public void clearVibrationParams(int types, IVibratorController token) throws RemoteException {
- // TODO(b/305939964): Add clear vibration implementation.
- }
-
- @Override
- public void onRequestVibrationParamsComplete(
- IBinder requestToken, @SuppressLint("ArrayReturn") VibrationParam[] result)
- throws RemoteException {
- // TODO(305942827): Cache the vibration params in VibrationScaler
- }
-
- @Override
- public int getInterfaceVersion() throws RemoteException {
- return this.VERSION;
- }
-
- @Override
- public String getInterfaceHash() throws RemoteException {
- return this.HASH;
- }
-}
diff --git a/services/core/java/com/android/server/vibrator/VibratorControllerHolder.java b/services/core/java/com/android/server/vibrator/VibratorControllerHolder.java
deleted file mode 100644
index 63e69db9480f..000000000000
--- a/services/core/java/com/android/server/vibrator/VibratorControllerHolder.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2023 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 com.android.server.vibrator;
-
-import android.annotation.NonNull;
-import android.frameworks.vibrator.IVibratorController;
-import android.os.IBinder;
-import android.os.RemoteException;
-import android.util.Slog;
-
-/**
- * Holder class for {@link IVibratorController}.
- *
- * @hide
- */
-public final class VibratorControllerHolder implements IBinder.DeathRecipient {
- private static final String TAG = "VibratorControllerHolder";
-
- private IVibratorController mVibratorController;
-
- public IVibratorController getVibratorController() {
- return mVibratorController;
- }
-
- /**
- * Sets the {@link IVibratorController} in {@link VibratorControllerHolder} to the new
- * controller. This will also take care of registering and unregistering death notifications
- * for the cached {@link IVibratorController}.
- */
- public void setVibratorController(IVibratorController controller) {
- try {
- if (mVibratorController != null) {
- mVibratorController.asBinder().unlinkToDeath(this, 0);
- }
- mVibratorController = controller;
- if (mVibratorController != null) {
- mVibratorController.asBinder().linkToDeath(this, 0);
- }
- } catch (RemoteException e) {
- Slog.wtf(TAG, "Failed to set IVibratorController: " + this, e);
- }
- }
-
- @Override
- public void binderDied(@NonNull IBinder deadBinder) {
- if (deadBinder == mVibratorController.asBinder()) {
- setVibratorController(null);
- }
- }
-
- @Override
- public void binderDied() {
- // Should not be used as binderDied(IBinder who) is overridden.
- Slog.wtf(TAG, "binderDied() called unexpectedly.");
- }
-}
diff --git a/services/core/java/com/android/server/vibrator/VibratorManagerService.java b/services/core/java/com/android/server/vibrator/VibratorManagerService.java
index d5044d9bc660..cf33cc5f43bd 100644
--- a/services/core/java/com/android/server/vibrator/VibratorManagerService.java
+++ b/services/core/java/com/android/server/vibrator/VibratorManagerService.java
@@ -53,7 +53,6 @@ import android.os.Trace;
import android.os.VibrationAttributes;
import android.os.VibrationEffect;
import android.os.VibratorInfo;
-import android.os.vibrator.Flags;
import android.os.vibrator.PrebakedSegment;
import android.os.vibrator.VibrationEffectSegment;
import android.os.vibrator.VibratorInfoFactory;
@@ -88,13 +87,10 @@ import java.util.Objects;
import java.util.function.Consumer;
import java.util.function.Function;
-
/** System implementation of {@link IVibratorManagerService}. */
public class VibratorManagerService extends IVibratorManagerService.Stub {
private static final String TAG = "VibratorManagerService";
private static final String EXTERNAL_VIBRATOR_SERVICE = "external_vibrator_service";
- private static final String VIBRATOR_CONTROL_SERVICE =
- "android.frameworks.vibrator.IVibratorControlService/default";
private static final boolean DEBUG = false;
private static final VibrationAttributes DEFAULT_ATTRIBUTES =
new VibrationAttributes.Builder().build();
@@ -273,10 +269,6 @@ public class VibratorManagerService extends IVibratorManagerService.Stub {
context.registerReceiver(mIntentReceiver, filter, Context.RECEIVER_NOT_EXPORTED);
injector.addService(EXTERNAL_VIBRATOR_SERVICE, new ExternalVibratorService());
- if (Flags.adaptiveHapticsEnabled()) {
- injector.addService(VIBRATOR_CONTROL_SERVICE,
- new VibratorControlService(new VibratorControllerHolder(), mLock));
- }
}
/** Finish initialization at boot phase {@link SystemService#PHASE_SYSTEM_SERVICES_READY}. */
diff --git a/services/manifest_services.xml b/services/manifest_services.xml
index e2fdfe9e8e47..76389154a885 100644
--- a/services/manifest_services.xml
+++ b/services/manifest_services.xml
@@ -4,14 +4,4 @@
<version>1</version>
<fqname>IAltitudeService/default</fqname>
</hal>
- <hal format="aidl">
- <name>android.frameworks.vibrator</name>
- <version>1</version>
- <fqname>IVibratorController/default</fqname>
- </hal>
- <hal format="aidl">
- <name>android.frameworks.vibrator</name>
- <version>1</version>
- <fqname>IVibratorControlService/default</fqname>
- </hal>
</manifest>
diff --git a/services/tests/vibrator/src/com/android/server/vibrator/VibratorControlServiceTest.java b/services/tests/vibrator/src/com/android/server/vibrator/VibratorControlServiceTest.java
deleted file mode 100644
index 49efd1bdd92a..000000000000
--- a/services/tests/vibrator/src/com/android/server/vibrator/VibratorControlServiceTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2021 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 com.android.server.vibrator;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.os.RemoteException;
-
-import org.junit.Before;
-import org.junit.Test;
-
-public class VibratorControlServiceTest {
-
- private VibratorControlService mVibratorControlService;
- private final Object mLock = new Object();
-
- @Before
- public void setUp() throws Exception {
- mVibratorControlService = new VibratorControlService(new VibratorControllerHolder(), mLock);
- }
-
- @Test
- public void testRegisterVibratorController() throws RemoteException {
- FakeVibratorController fakeController = new FakeVibratorController();
- mVibratorControlService.registerVibratorController(fakeController);
-
- assertThat(fakeController.isLinkedToDeath).isTrue();
- }
-
- @Test
- public void testUnregisterVibratorController_providingTheRegisteredController_performsRequest()
- throws RemoteException {
- FakeVibratorController fakeController = new FakeVibratorController();
- mVibratorControlService.registerVibratorController(fakeController);
- mVibratorControlService.unregisterVibratorController(fakeController);
- assertThat(fakeController.isLinkedToDeath).isFalse();
- }
-
- @Test
- public void testUnregisterVibratorController_providingAnInvalidController_ignoresRequest()
- throws RemoteException {
- FakeVibratorController fakeController1 = new FakeVibratorController();
- FakeVibratorController fakeController2 = new FakeVibratorController();
- mVibratorControlService.registerVibratorController(fakeController1);
-
- mVibratorControlService.unregisterVibratorController(fakeController2);
- assertThat(fakeController1.isLinkedToDeath).isTrue();
- }
-}
diff --git a/services/tests/vibrator/src/com/android/server/vibrator/VibratorControllerHolderTest.java b/services/tests/vibrator/src/com/android/server/vibrator/VibratorControllerHolderTest.java
deleted file mode 100644
index 79abe21a301d..000000000000
--- a/services/tests/vibrator/src/com/android/server/vibrator/VibratorControllerHolderTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2021 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 com.android.server.vibrator;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.os.RemoteException;
-
-import org.junit.Before;
-import org.junit.Test;
-
-public class VibratorControllerHolderTest {
-
- private final FakeVibratorController mFakeVibratorController = new FakeVibratorController();
- private VibratorControllerHolder mVibratorControllerHolder;
-
- @Before
- public void setUp() throws Exception {
- mVibratorControllerHolder = new VibratorControllerHolder();
- }
-
- @Test
- public void testSetVibratorController_linksVibratorControllerToDeath() throws RemoteException {
- mVibratorControllerHolder.setVibratorController(mFakeVibratorController);
- assertThat(mVibratorControllerHolder.getVibratorController())
- .isEqualTo(mFakeVibratorController);
- assertThat(mFakeVibratorController.isLinkedToDeath).isTrue();
- }
-
- @Test
- public void testSetVibratorController_setControllerToNull_unlinksVibratorControllerToDeath()
- throws RemoteException {
- mVibratorControllerHolder.setVibratorController(mFakeVibratorController);
- mVibratorControllerHolder.setVibratorController(null);
- assertThat(mFakeVibratorController.isLinkedToDeath).isFalse();
- assertThat(mVibratorControllerHolder.getVibratorController()).isNull();
- }
-
- @Test
- public void testBinderDied_withValidController_unlinksVibratorControllerToDeath()
- throws RemoteException {
- mVibratorControllerHolder.setVibratorController(mFakeVibratorController);
- mVibratorControllerHolder.binderDied(mFakeVibratorController);
- assertThat(mFakeVibratorController.isLinkedToDeath).isFalse();
- assertThat(mVibratorControllerHolder.getVibratorController()).isNull();
- }
-
- @Test
- public void testBinderDied_withInvalidController_ignoresRequest()
- throws RemoteException {
- mVibratorControllerHolder.setVibratorController(mFakeVibratorController);
- FakeVibratorController imposterVibratorController = new FakeVibratorController();
- mVibratorControllerHolder.binderDied(imposterVibratorController);
- assertThat(mFakeVibratorController.isLinkedToDeath).isTrue();
- assertThat(mVibratorControllerHolder.getVibratorController())
- .isEqualTo(mFakeVibratorController);
- }
-}
diff --git a/services/tests/vibrator/src/com/android/server/vibrator/VibratorManagerServiceTest.java b/services/tests/vibrator/src/com/android/server/vibrator/VibratorManagerServiceTest.java
index a105649c9b5b..3fce9e7a83ef 100644
--- a/services/tests/vibrator/src/com/android/server/vibrator/VibratorManagerServiceTest.java
+++ b/services/tests/vibrator/src/com/android/server/vibrator/VibratorManagerServiceTest.java
@@ -307,10 +307,9 @@ public class VibratorManagerServiceTest {
@Override
void addService(String name, IBinder service) {
- if (service instanceof VibratorManagerService.ExternalVibratorService) {
- mExternalVibratorService =
- (VibratorManagerService.ExternalVibratorService) service;
- }
+ Object serviceInstance = service;
+ mExternalVibratorService =
+ (VibratorManagerService.ExternalVibratorService) serviceInstance;
}
HapticFeedbackVibrationProvider createHapticFeedbackVibrationProvider(
diff --git a/services/tests/vibrator/utils/com/android/server/vibrator/FakeVibratorController.java b/services/tests/vibrator/utils/com/android/server/vibrator/FakeVibratorController.java
deleted file mode 100644
index 7e235870cedc..000000000000
--- a/services/tests/vibrator/utils/com/android/server/vibrator/FakeVibratorController.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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 com.android.server.vibrator;
-
-import android.annotation.NonNull;
-import android.frameworks.vibrator.IVibratorController;
-import android.os.IBinder;
-import android.os.RemoteException;
-
-/**
- * Provides a fake implementation of {@link android.frameworks.vibrator.IVibratorController} for
- * testing.
- */
-public final class FakeVibratorController extends IVibratorController.Stub {
-
- public boolean isLinkedToDeath = false;
-
- @Override
- public void requestVibrationParams(int i, long l, IBinder iBinder) throws RemoteException {
-
- }
-
- @Override
- public int getInterfaceVersion() throws RemoteException {
- return 0;
- }
-
- @Override
- public String getInterfaceHash() throws RemoteException {
- return null;
- }
-
- @Override
- public void linkToDeath(@NonNull DeathRecipient recipient, int flags) {
- super.linkToDeath(recipient, flags);
- isLinkedToDeath = true;
- }
-
- @Override
- public boolean unlinkToDeath(@NonNull DeathRecipient recipient, int flags) {
- isLinkedToDeath = false;
- return super.unlinkToDeath(recipient, flags);
- }
-}