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

Commit c7be3bec authored by Ruben Brunk's avatar Ruben Brunk
Browse files

Add VrManager AIDL interface for use by system apps.

Bug: 27884853
Change-Id: I6de0d291deafe5003070d60866c60d6599312e79
parent ca94f293
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -244,6 +244,8 @@ LOCAL_SRC_FILES += \
	core/java/android/service/notification/IConditionListener.aidl \
	core/java/android/service/notification/IConditionProvider.aidl \
	core/java/android/service/vr/IVrListener.aidl \
	core/java/android/service/vr/IVrManager.aidl \
	core/java/android/service/vr/IVrStateCallbacks.aidl \
	core/java/android/print/ILayoutResultCallback.aidl \
	core/java/android/print/IPrinterDiscoveryObserver.aidl \
	core/java/android/print/IPrintDocumentAdapter.aidl \
+46 −0
Original line number Diff line number Diff line
/**
 * Copyright (c) 2016, 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.service.vr;

import android.service.vr.IVrStateCallbacks;

/** @hide */
interface IVrManager {

    /**
     * Add a callback to be notified when VR mode state changes.
     *
     * @param cb the callback instance to add.
     */
    void registerListener(in IVrStateCallbacks cb);

    /**
     * Remove the callack from the current set of registered callbacks.
     *
     * @param cb the callback to remove.
     */
    void unregisterListener(in IVrStateCallbacks cb);

    /**
     * Return current VR mode state.
     *
     * @return {@code true} if VR mode is enabled.
     */
    boolean getVrModeState();

}
+24 −0
Original line number Diff line number Diff line
/**
 * Copyright (c) 2016, 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.service.vr;

/** @hide */
oneway interface IVrStateCallbacks {

    void onVrStateChanged(in boolean enabled);

}
+5 −0
Original line number Diff line number Diff line
@@ -2991,6 +2991,11 @@
    <permission android:name="android.permission.BIND_VR_LISTENER_SERVICE"
        android:protectionLevel="signature" />

    <!-- Required to make calls to {@link android.service.vr.IVrManager}.
         @hide -->
    <permission android:name="android.permission.ACCESS_VR_MANAGER"
            android:protectionLevel="signature" />

    <!-- Allows an application to whitelist tasks during lock task mode
         @hide <p>Not for use by third-party applications.</p> -->
    <permission android:name="android.permission.UPDATE_LOCK_TASK_PACKAGES"
+14 −3
Original line number Diff line number Diff line
@@ -18,12 +18,17 @@ package com.android.server.lights;

import com.android.server.SystemService;
import com.android.server.vr.VrManagerInternal;
import com.android.server.vr.VrManagerService;
import com.android.server.vr.VrStateListener;

import android.content.Context;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.RemoteException;
import android.os.Trace;
import android.service.vr.IVrManager;
import android.service.vr.IVrStateCallbacks;
import android.util.Slog;

public class LightsService extends SystemService {
@@ -164,13 +169,19 @@ public class LightsService extends SystemService {
    @Override
    public void onBootPhase(int phase) {
        if (phase == PHASE_SYSTEM_SERVICES_READY) {
            getLocalService(VrManagerInternal.class).registerListener(mVrStateListener);
            IVrManager vrManager =
                    (IVrManager) getBinderService(VrManagerService.VR_MANAGER_BINDER_SERVICE);
            try {
                vrManager.registerListener(mVrStateCallbacks);
            } catch (RemoteException e) {
                Slog.e(TAG, "Failed to register VR mode state listener: " + e);
            }
        }
    }

    private final VrStateListener mVrStateListener = new VrStateListener() {
    private final IVrStateCallbacks mVrStateCallbacks = new IVrStateCallbacks.Stub() {
        @Override
        public void onVrStateChanged(boolean enabled) {
        public void onVrStateChanged(boolean enabled) throws RemoteException {
            LightImpl l = mLights[LightsManager.LIGHT_ID_BACKLIGHT];
            if (enabled) {
                if (DEBUG) Slog.v(TAG, "VR mode enabled, setting brightness to low persistence");
Loading