VrManagerInternal.java revision b70845c708a8c402219f05d26edaea38713e13c3
1/** 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16package com.android.server.vr; 17 18import android.annotation.NonNull; 19import android.content.ComponentName; 20import android.service.vr.IPersistentVrStateCallbacks; 21 22/** 23 * Service for accessing the VR mode manager. 24 * 25 * @hide Only for use within system server. 26 */ 27public abstract class VrManagerInternal { 28 29 /** 30 * The error code returned on success. 31 */ 32 public static final int NO_ERROR = 0; 33 34 /** 35 * Return {@code true} if the given package is the currently bound VrListenerService for the 36 * given user. 37 * 38 * @param packageName The package name to check. 39 * @param userId the user ID to check the package name for. 40 * 41 * @return {@code true} if the given package is the currently bound VrListenerService. 42 */ 43 public abstract boolean isCurrentVrListener(String packageName, int userId); 44 45 /** 46 * Set the current VR mode state. 47 * <p/> 48 * This may delay the mode change slightly during application transitions to avoid frequently 49 * tearing down VrListenerServices unless necessary. 50 * 51 * @param enabled {@code true} to enable VR mode. 52 * @param packageName The package name of the requested VrListenerService to bind. 53 * @param userId the user requesting the VrListenerService component. 54 * @param calling the component currently using VR mode, or null to leave unchanged. 55 */ 56 public abstract void setVrMode(boolean enabled, @NonNull ComponentName packageName, 57 int userId, @NonNull ComponentName calling); 58 59 /** 60 * Set whether the system has acquired a sleep token. 61 * 62 * @param isAsleep is {@code true} if the device is asleep, or {@code false} otherwise. 63 */ 64 public abstract void onSleepStateChanged(boolean isAsleep); 65 66 /** 67 * Set whether the display used for VR output is on. 68 * 69 * @param isScreenOn is {@code true} if the display is on and can receive commands, 70 * or {@code false} otherwise. 71 */ 72 public abstract void onScreenStateChanged(boolean isScreenOn); 73 74 /** 75 * Return NO_ERROR if the given package is installed on the device and enabled as a 76 * VrListenerService for the given current user, or a negative error code indicating a failure. 77 * 78 * @param packageName the name of the package to check, or null to select the default package. 79 * @return NO_ERROR if the given package is installed and is enabled, or a negative error code 80 * given in {@link android.service.vr.VrModeException} on failure. 81 */ 82 public abstract int hasVrPackage(@NonNull ComponentName packageName, int userId); 83 84 /** 85 * Sets the persistent VR mode state of a device. When a device is in persistent VR mode it will 86 * remain in VR mode even if the foreground does not specify Vr mode being enabled. Mainly used 87 * by VR viewers to indicate that a device is placed in a VR viewer. 88 * 89 * @param enabled true if the device should be placed in persistent VR mode. 90 */ 91 public abstract void setPersistentVrModeEnabled(boolean enabled); 92 93 /** 94 * Return {@link android.view.Display.INVALID_DISPLAY} if there exists no virtual display 95 * currently or the display id of the current virtual display. 96 * 97 * @return {@link android.view.Display.INVALID_DISPLAY} if there is no virtual display 98 * currently, else return the display id of the virtual display 99 */ 100 public abstract int getCompatibilityDisplayId(); 101 102 /** 103 * Adds listener that reports state changes to persistent VR mode. 104 */ 105 public abstract void addPersistentVrModeStateListener(IPersistentVrStateCallbacks listener); 106} 107