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

Commit 28eae8e5 authored by Kevin Schoedel's avatar Kevin Schoedel
Browse files

Manage controller connection from VrCore to VrWindowManager.

Use VrManager as a proxy to pass the controller data file descriptor
from VrCore to VrWindowManager, since the latter is a purely native
service with no Java visibility.

This is intended to be replaced by moving the relevant parts of
VrWindowManager into VrCore (b/36506799).

Bug: 35619424
Test: manual on device
Change-Id: I9545349893ed9b23de4ba8d3cb61c7d403ad0b97
parent 0c60baf0
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -6,6 +6,8 @@ import android.content.ComponentName;
import android.os.RemoteException;
import android.service.vr.IVrManager;

import java.io.FileDescriptor;

/**
 * Used to control aspects of a devices Virtual Reality (VR) capabilities.
 * <p>
@@ -41,4 +43,32 @@ public class VrManager {
            e.rethrowFromSystemServer();
        }
    }

    /**
     * Initiate connection for system controller data.
     *
     * @param fd Controller data file descriptor.
     *
     * {@hide}
     */
    public void connectController(FileDescriptor fd) {
        try {
            mService.connectController(fd);
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
    }

    /**
     * Sever connection for system controller data.
     *
     * {@hide}
     */
    public void disconnectController() {
        try {
            mService.disconnectController();
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
    }
}
+12 −0
Original line number Diff line number Diff line
@@ -73,5 +73,17 @@ interface IVrManager {
     * currently, else return the display id of the virtual display
     */
    int getCompatibilityDisplayId();

    /**
     * Initiate connection for system controller data.
     *
     * @param fd Controller data file descriptor.
     */
    void connectController(in FileDescriptor fd);

    /**
     * Sever connection for system controller data.
     */
    void disconnectController();
}
+1 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ LOCAL_SRC_FILES += \
    ../../../../system/netd/server/binder/android/net/INetd.aidl \
    ../../../../system/netd/server/binder/android/net/metrics/INetdEventListener.aidl \
    ../../../native/cmds/installd/binder/android/os/IInstalld.aidl \
    ../../../native/services/vr/vr_window_manager/aidl/android/service/vr/IVrWindowManager.aidl \

LOCAL_AIDL_INCLUDES += \
    system/netd/server/binder
+30 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.os.Looper;
import android.os.Message;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.provider.Settings;
import android.service.notification.NotificationListenerService;
@@ -44,6 +45,7 @@ import android.service.vr.IPersistentVrStateCallbacks;
import android.service.vr.IVrListener;
import android.service.vr.IVrManager;
import android.service.vr.IVrStateCallbacks;
import android.service.vr.IVrWindowManager;
import android.service.vr.VrListenerService;
import android.text.TextUtils;
import android.util.ArrayMap;
@@ -426,6 +428,18 @@ public class VrManagerService extends SystemService implements EnabledComponentC
            return VrManagerService.this.getCompatibilityDisplayId();
        }

        @Override
        public void connectController(FileDescriptor fd) throws android.os.RemoteException {
            enforceCallerPermission(Manifest.permission.RESTRICTED_VR_ACCESS);
            VrManagerService.this.connectController(fd);
        }

        @Override
        public void disconnectController() throws android.os.RemoteException {
            enforceCallerPermission(Manifest.permission.RESTRICTED_VR_ACCESS);
            VrManagerService.this.disconnectController();
        }

        @Override
        protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
            if (getContext().checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
@@ -1151,4 +1165,20 @@ public class VrManagerService extends SystemService implements EnabledComponentC
            return mVrModeEnabled;
        }
    }

    private void connectController(FileDescriptor fd) throws android.os.RemoteException {
        // TODO(b/36506799): move vr_wm code to VrCore and remove this.
        IVrWindowManager remote =
                IVrWindowManager.Stub.asInterface(
                        ServiceManager.getService(IVrWindowManager.SERVICE_NAME));
        remote.connectController(fd);
    }

    private void disconnectController() throws android.os.RemoteException {
        // TODO(b/36506799): move vr_wm code to VrCore and remove this.
        IVrWindowManager remote =
                IVrWindowManager.Stub.asInterface(
                        ServiceManager.getService(IVrWindowManager.SERVICE_NAME));
        remote.disconnectController();
    }
}