Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6b4eed8a authored by Priyanka Advani's avatar Priyanka Advani Committed by Android (Google) Code Review
Browse files

Revert "Introducing VibratorControlService"

Revert submission 25585969-add-ivibratorcontrolservice

Reason for revert: b/315507984

Reverted changes: /q/submissionid:25585969-add-ivibratorcontrolservice

Change-Id: I0ba4110b2e5a9d7ad69ee57099221833491b1346
parent cbb1ea75
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -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"
}
+0 −1
Original line number Diff line number Diff line
@@ -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
+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;
    }
}
+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.");
    }
}
+0 −5
Original line number Diff line number Diff line
@@ -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();
@@ -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