Ruben Brunk | e24b9a6 | 2016-02-16 21:38:24 -0800 | [diff] [blame] | 1 | /** |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 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 | */ |
| 16 | package com.android.server.vr; |
| 17 | |
Ruben Brunk | e24b9a6 | 2016-02-16 21:38:24 -0800 | [diff] [blame] | 18 | import android.annotation.NonNull; |
Karthik Ravi Shankar | 2b9aaed | 2017-05-01 01:34:19 -0700 | [diff] [blame] | 19 | import android.app.Vr2dDisplayProperties; |
Ruben Brunk | e24b9a6 | 2016-02-16 21:38:24 -0800 | [diff] [blame] | 20 | import android.content.ComponentName; |
Steven Thomas | b70845c | 2017-03-16 14:32:37 -0700 | [diff] [blame] | 21 | import android.service.vr.IPersistentVrStateCallbacks; |
Ruben Brunk | e24b9a6 | 2016-02-16 21:38:24 -0800 | [diff] [blame] | 22 | |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 23 | /** |
Ruben Brunk | e24b9a6 | 2016-02-16 21:38:24 -0800 | [diff] [blame] | 24 | * Service for accessing the VR mode manager. |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 25 | * |
| 26 | * @hide Only for use within system server. |
| 27 | */ |
| 28 | public abstract class VrManagerInternal { |
| 29 | |
| 30 | /** |
Ruben Brunk | e24b9a6 | 2016-02-16 21:38:24 -0800 | [diff] [blame] | 31 | * The error code returned on success. |
| 32 | */ |
| 33 | public static final int NO_ERROR = 0; |
| 34 | |
| 35 | /** |
Ruben Brunk | 8f1d5cb | 2016-03-22 18:08:41 -0700 | [diff] [blame] | 36 | * Return {@code true} if the given package is the currently bound VrListenerService for the |
| 37 | * given user. |
| 38 | * |
| 39 | * @param packageName The package name to check. |
| 40 | * @param userId the user ID to check the package name for. |
| 41 | * |
| 42 | * @return {@code true} if the given package is the currently bound VrListenerService. |
| 43 | */ |
| 44 | public abstract boolean isCurrentVrListener(String packageName, int userId); |
| 45 | |
| 46 | /** |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 47 | * Set the current VR mode state. |
Ruben Brunk | af9f004 | 2016-06-15 17:08:35 -0700 | [diff] [blame] | 48 | * <p/> |
| 49 | * This may delay the mode change slightly during application transitions to avoid frequently |
| 50 | * tearing down VrListenerServices unless necessary. |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 51 | * |
| 52 | * @param enabled {@code true} to enable VR mode. |
Ruben Brunk | e24b9a6 | 2016-02-16 21:38:24 -0800 | [diff] [blame] | 53 | * @param packageName The package name of the requested VrListenerService to bind. |
| 54 | * @param userId the user requesting the VrListenerService component. |
Ruben Brunk | c7354fe | 2016-03-07 23:37:12 -0800 | [diff] [blame] | 55 | * @param calling the component currently using VR mode, or null to leave unchanged. |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 56 | */ |
Ruben Brunk | e24b9a6 | 2016-02-16 21:38:24 -0800 | [diff] [blame] | 57 | public abstract void setVrMode(boolean enabled, @NonNull ComponentName packageName, |
Ruben Brunk | c7354fe | 2016-03-07 23:37:12 -0800 | [diff] [blame] | 58 | int userId, @NonNull ComponentName calling); |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 59 | |
Ruben Brunk | af9f004 | 2016-06-15 17:08:35 -0700 | [diff] [blame] | 60 | /** |
Ruben Brunk | fecb615 | 2016-10-28 20:18:57 -0700 | [diff] [blame] | 61 | * Set whether the system has acquired a sleep token. |
Ruben Brunk | af9f004 | 2016-06-15 17:08:35 -0700 | [diff] [blame] | 62 | * |
Ruben Brunk | fecb615 | 2016-10-28 20:18:57 -0700 | [diff] [blame] | 63 | * @param isAsleep is {@code true} if the device is asleep, or {@code false} otherwise. |
Ruben Brunk | af9f004 | 2016-06-15 17:08:35 -0700 | [diff] [blame] | 64 | */ |
Ruben Brunk | fecb615 | 2016-10-28 20:18:57 -0700 | [diff] [blame] | 65 | public abstract void onSleepStateChanged(boolean isAsleep); |
Ruben Brunk | af9f004 | 2016-06-15 17:08:35 -0700 | [diff] [blame] | 66 | |
Ruben Brunk | fecb615 | 2016-10-28 20:18:57 -0700 | [diff] [blame] | 67 | /** |
| 68 | * Set whether the display used for VR output is on. |
| 69 | * |
| 70 | * @param isScreenOn is {@code true} if the display is on and can receive commands, |
| 71 | * or {@code false} otherwise. |
| 72 | */ |
| 73 | public abstract void onScreenStateChanged(boolean isScreenOn); |
Ruben Brunk | af9f004 | 2016-06-15 17:08:35 -0700 | [diff] [blame] | 74 | |
Ruben Brunk | fecb615 | 2016-10-28 20:18:57 -0700 | [diff] [blame] | 75 | /** |
| 76 | * Return NO_ERROR if the given package is installed on the device and enabled as a |
| 77 | * VrListenerService for the given current user, or a negative error code indicating a failure. |
| 78 | * |
| 79 | * @param packageName the name of the package to check, or null to select the default package. |
| 80 | * @return NO_ERROR if the given package is installed and is enabled, or a negative error code |
| 81 | * given in {@link android.service.vr.VrModeException} on failure. |
| 82 | */ |
Ruben Brunk | e24b9a6 | 2016-02-16 21:38:24 -0800 | [diff] [blame] | 83 | public abstract int hasVrPackage(@NonNull ComponentName packageName, int userId); |
Zak Cohen | 56345f4 | 2017-01-26 13:54:28 -0800 | [diff] [blame] | 84 | |
| 85 | /** |
Karthik Ravi Shankar | 2b9aaed | 2017-05-01 01:34:19 -0700 | [diff] [blame] | 86 | * Sets the resolution and DPI of the vr2d virtual display used to display |
Karthik Ravi Shankar | cdf9ce7 | 2017-04-12 15:31:20 -0700 | [diff] [blame] | 87 | * 2D applications in VR mode. |
| 88 | * |
| 89 | * <p>Requires {@link android.Manifest.permission#ACCESS_VR_MANAGER} permission.</p> |
| 90 | * |
Karthik Ravi Shankar | 2b9aaed | 2017-05-01 01:34:19 -0700 | [diff] [blame] | 91 | * @param vr2dDisplayProp Properties of the virtual display for 2D applications |
Karthik Ravi Shankar | cdf9ce7 | 2017-04-12 15:31:20 -0700 | [diff] [blame] | 92 | * in VR mode. |
| 93 | */ |
Karthik Ravi Shankar | 2b9aaed | 2017-05-01 01:34:19 -0700 | [diff] [blame] | 94 | public abstract void setVr2dDisplayProperties( |
| 95 | Vr2dDisplayProperties vr2dDisplayProp); |
Karthik Ravi Shankar | cdf9ce7 | 2017-04-12 15:31:20 -0700 | [diff] [blame] | 96 | |
| 97 | /** |
Zak Cohen | 56345f4 | 2017-01-26 13:54:28 -0800 | [diff] [blame] | 98 | * Sets the persistent VR mode state of a device. When a device is in persistent VR mode it will |
| 99 | * remain in VR mode even if the foreground does not specify Vr mode being enabled. Mainly used |
| 100 | * by VR viewers to indicate that a device is placed in a VR viewer. |
| 101 | * |
| 102 | * @param enabled true if the device should be placed in persistent VR mode. |
| 103 | */ |
| 104 | public abstract void setPersistentVrModeEnabled(boolean enabled); |
Zak Cohen | 732aeb0 | 2017-01-29 14:19:52 -0800 | [diff] [blame] | 105 | |
| 106 | /** |
Karthik Ravi Shankar | 3a47ec2 | 2017-03-08 18:09:35 -0800 | [diff] [blame] | 107 | * Return {@link android.view.Display.INVALID_DISPLAY} if there exists no virtual display |
| 108 | * currently or the display id of the current virtual display. |
| 109 | * |
| 110 | * @return {@link android.view.Display.INVALID_DISPLAY} if there is no virtual display |
| 111 | * currently, else return the display id of the virtual display |
| 112 | */ |
Karthik Ravi Shankar | 2b9aaed | 2017-05-01 01:34:19 -0700 | [diff] [blame] | 113 | public abstract int getVr2dDisplayId(); |
Karthik Ravi Shankar | 3a47ec2 | 2017-03-08 18:09:35 -0800 | [diff] [blame] | 114 | |
| 115 | /** |
Zak Cohen | 732aeb0 | 2017-01-29 14:19:52 -0800 | [diff] [blame] | 116 | * Adds listener that reports state changes to persistent VR mode. |
| 117 | */ |
Steven Thomas | b70845c | 2017-03-16 14:32:37 -0700 | [diff] [blame] | 118 | public abstract void addPersistentVrModeStateListener(IPersistentVrStateCallbacks listener); |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 119 | } |