Loading core/java/android/os/vibrator/flags.aconfig +0 −7 Original line number Diff line number Diff line Loading @@ -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" } services/core/Android.bp +0 −1 Original line number Diff line number Diff line Loading @@ -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 Loading services/core/java/com/android/server/vibrator/VibratorControlService.javadeleted 100644 → 0 +0 −105 Original line number Diff line number Diff line /* * 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; } } services/core/java/com/android/server/vibrator/VibratorControllerHolder.javadeleted 100644 → 0 +0 −70 Original line number Diff line number Diff line /* * 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."); } } services/core/java/com/android/server/vibrator/VibratorManagerService.java +0 −5 Original line number Diff line number Diff line Loading @@ -91,8 +91,6 @@ import java.util.function.Function; 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(); Loading Loading @@ -271,9 +269,6 @@ public class VibratorManagerService extends IVibratorManagerService.Stub { context.registerReceiver(mIntentReceiver, filter, Context.RECEIVER_NOT_EXPORTED); injector.addService(EXTERNAL_VIBRATOR_SERVICE, new ExternalVibratorService()); injector.addService(VIBRATOR_CONTROL_SERVICE, new VibratorControlService(new VibratorControllerHolder(), mLock)); } /** Finish initialization at boot phase {@link SystemService#PHASE_SYSTEM_SERVICES_READY}. */ Loading Loading
core/java/android/os/vibrator/flags.aconfig +0 −7 Original line number Diff line number Diff line Loading @@ -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" }
services/core/Android.bp +0 −1 Original line number Diff line number Diff line Loading @@ -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 Loading
services/core/java/com/android/server/vibrator/VibratorControlService.javadeleted 100644 → 0 +0 −105 Original line number Diff line number Diff line /* * 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; } }
services/core/java/com/android/server/vibrator/VibratorControllerHolder.javadeleted 100644 → 0 +0 −70 Original line number Diff line number Diff line /* * 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."); } }
services/core/java/com/android/server/vibrator/VibratorManagerService.java +0 −5 Original line number Diff line number Diff line Loading @@ -91,8 +91,6 @@ import java.util.function.Function; 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(); Loading Loading @@ -271,9 +269,6 @@ public class VibratorManagerService extends IVibratorManagerService.Stub { context.registerReceiver(mIntentReceiver, filter, Context.RECEIVER_NOT_EXPORTED); injector.addService(EXTERNAL_VIBRATOR_SERVICE, new ExternalVibratorService()); injector.addService(VIBRATOR_CONTROL_SERVICE, new VibratorControlService(new VibratorControllerHolder(), mLock)); } /** Finish initialization at boot phase {@link SystemService#PHASE_SYSTEM_SERVICES_READY}. */ Loading