VrManagerInternal.java revision 3a47ec2edd04546d82ba1df331c7af778858a281
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; 20 21/** 22 * Service for accessing the VR mode manager. 23 * 24 * @hide Only for use within system server. 25 */ 26public abstract class VrManagerInternal { 27 28 /** 29 * The error code returned on success. 30 */ 31 public static final int NO_ERROR = 0; 32 33 /** 34 * Return {@code true} if the given package is the currently bound VrListenerService for the 35 * given user. 36 * 37 * @param packageName The package name to check. 38 * @param userId the user ID to check the package name for. 39 * 40 * @return {@code true} if the given package is the currently bound VrListenerService. 41 */ 42 public abstract boolean isCurrentVrListener(String packageName, int userId); 43 44 /** 45 * Set the current VR mode state. 46 * <p/> 47 * This may delay the mode change slightly during application transitions to avoid frequently 48 * tearing down VrListenerServices unless necessary. 49 * 50 * @param enabled {@code true} to enable VR mode. 51 * @param packageName The package name of the requested VrListenerService to bind. 52 * @param userId the user requesting the VrListenerService component. 53 * @param calling the component currently using VR mode, or null to leave unchanged. 54 */ 55 public abstract void setVrMode(boolean enabled, @NonNull ComponentName packageName, 56 int userId, @NonNull ComponentName calling); 57 58 /** 59 * Set whether the system has acquired a sleep token. 60 * 61 * @param isAsleep is {@code true} if the device is asleep, or {@code false} otherwise. 62 */ 63 public abstract void onSleepStateChanged(boolean isAsleep); 64 65 /** 66 * Set whether the display used for VR output is on. 67 * 68 * @param isScreenOn is {@code true} if the display is on and can receive commands, 69 * or {@code false} otherwise. 70 */ 71 public abstract void onScreenStateChanged(boolean isScreenOn); 72 73 /** 74 * Return NO_ERROR if the given package is installed on the device and enabled as a 75 * VrListenerService for the given current user, or a negative error code indicating a failure. 76 * 77 * @param packageName the name of the package to check, or null to select the default package. 78 * @return NO_ERROR if the given package is installed and is enabled, or a negative error code 79 * given in {@link android.service.vr.VrModeException} on failure. 80 */ 81 public abstract int hasVrPackage(@NonNull ComponentName packageName, int userId); 82 83 /** 84 * Sets the persistent VR mode state of a device. When a device is in persistent VR mode it will 85 * remain in VR mode even if the foreground does not specify Vr mode being enabled. Mainly used 86 * by VR viewers to indicate that a device is placed in a VR viewer. 87 * 88 * @param enabled true if the device should be placed in persistent VR mode. 89 */ 90 public abstract void setPersistentVrModeEnabled(boolean enabled); 91 92 /** 93 * Return {@link android.view.Display.INVALID_DISPLAY} if there exists no virtual display 94 * currently or the display id of the current virtual display. 95 * 96 * @return {@link android.view.Display.INVALID_DISPLAY} if there is no virtual display 97 * currently, else return the display id of the virtual display 98 */ 99 public abstract int getCompatibilityDisplayId(); 100 101 /** 102 * Adds listener that reports state changes to persistent VR mode. 103 */ 104 public abstract void addPersistentVrModeStateListener(PersistentVrStateListener listener); 105} 106