blob: 35b6ad3079a55ba2e9ae406eb36d690ac766271e [file] [log] [blame]
Ruben Brunke24b9a62016-02-16 21:38:24 -08001/**
Ruben Brunkdd18a0b2015-12-04 16:16:31 -08002 * 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
Ruben Brunke24b9a62016-02-16 21:38:24 -080018import android.annotation.NonNull;
Karthik Ravi Shankar2b9aaed2017-05-01 01:34:19 -070019import android.app.Vr2dDisplayProperties;
Ruben Brunke24b9a62016-02-16 21:38:24 -080020import android.content.ComponentName;
Steven Thomasb70845c2017-03-16 14:32:37 -070021import android.service.vr.IPersistentVrStateCallbacks;
Ruben Brunke24b9a62016-02-16 21:38:24 -080022
Ruben Brunkdd18a0b2015-12-04 16:16:31 -080023/**
Ruben Brunke24b9a62016-02-16 21:38:24 -080024 * Service for accessing the VR mode manager.
Ruben Brunkdd18a0b2015-12-04 16:16:31 -080025 *
26 * @hide Only for use within system server.
27 */
28public abstract class VrManagerInternal {
29
30 /**
Ruben Brunke24b9a62016-02-16 21:38:24 -080031 * The error code returned on success.
32 */
33 public static final int NO_ERROR = 0;
34
35 /**
Ruben Brunk8f1d5cb2016-03-22 18:08:41 -070036 * 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 Brunkdd18a0b2015-12-04 16:16:31 -080047 * Set the current VR mode state.
Ruben Brunkaf9f0042016-06-15 17:08:35 -070048 * <p/>
49 * This may delay the mode change slightly during application transitions to avoid frequently
50 * tearing down VrListenerServices unless necessary.
Ruben Brunkdd18a0b2015-12-04 16:16:31 -080051 *
52 * @param enabled {@code true} to enable VR mode.
Ruben Brunke24b9a62016-02-16 21:38:24 -080053 * @param packageName The package name of the requested VrListenerService to bind.
54 * @param userId the user requesting the VrListenerService component.
Albert Chaulk16d23972017-07-14 12:32:57 -040055 * @param processId the process the component is running in.
Ruben Brunkc7354fe2016-03-07 23:37:12 -080056 * @param calling the component currently using VR mode, or null to leave unchanged.
Ruben Brunkdd18a0b2015-12-04 16:16:31 -080057 */
Ruben Brunke24b9a62016-02-16 21:38:24 -080058 public abstract void setVrMode(boolean enabled, @NonNull ComponentName packageName,
Albert Chaulk16d23972017-07-14 12:32:57 -040059 int userId, int processId, @NonNull ComponentName calling);
Ruben Brunkdd18a0b2015-12-04 16:16:31 -080060
Ruben Brunkaf9f0042016-06-15 17:08:35 -070061 /**
Ruben Brunkfecb6152016-10-28 20:18:57 -070062 * Set whether the display used for VR output is on.
63 *
64 * @param isScreenOn is {@code true} if the display is on and can receive commands,
65 * or {@code false} otherwise.
66 */
67 public abstract void onScreenStateChanged(boolean isScreenOn);
Ruben Brunkaf9f0042016-06-15 17:08:35 -070068
Ruben Brunkfecb6152016-10-28 20:18:57 -070069 /**
70 * Return NO_ERROR if the given package is installed on the device and enabled as a
71 * VrListenerService for the given current user, or a negative error code indicating a failure.
72 *
73 * @param packageName the name of the package to check, or null to select the default package.
74 * @return NO_ERROR if the given package is installed and is enabled, or a negative error code
75 * given in {@link android.service.vr.VrModeException} on failure.
76 */
Ruben Brunke24b9a62016-02-16 21:38:24 -080077 public abstract int hasVrPackage(@NonNull ComponentName packageName, int userId);
Zak Cohen56345f42017-01-26 13:54:28 -080078
79 /**
Karthik Ravi Shankar2b9aaed2017-05-01 01:34:19 -070080 * Sets the resolution and DPI of the vr2d virtual display used to display
Karthik Ravi Shankarcdf9ce72017-04-12 15:31:20 -070081 * 2D applications in VR mode.
82 *
83 * <p>Requires {@link android.Manifest.permission#ACCESS_VR_MANAGER} permission.</p>
84 *
Karthik Ravi Shankar2b9aaed2017-05-01 01:34:19 -070085 * @param vr2dDisplayProp Properties of the virtual display for 2D applications
Karthik Ravi Shankarcdf9ce72017-04-12 15:31:20 -070086 * in VR mode.
87 */
Karthik Ravi Shankar2b9aaed2017-05-01 01:34:19 -070088 public abstract void setVr2dDisplayProperties(
89 Vr2dDisplayProperties vr2dDisplayProp);
Karthik Ravi Shankarcdf9ce72017-04-12 15:31:20 -070090
91 /**
Zak Cohen56345f42017-01-26 13:54:28 -080092 * Sets the persistent VR mode state of a device. When a device is in persistent VR mode it will
93 * remain in VR mode even if the foreground does not specify Vr mode being enabled. Mainly used
94 * by VR viewers to indicate that a device is placed in a VR viewer.
95 *
96 * @param enabled true if the device should be placed in persistent VR mode.
97 */
98 public abstract void setPersistentVrModeEnabled(boolean enabled);
Zak Cohen732aeb02017-01-29 14:19:52 -080099
100 /**
Karthik Ravi Shankar3a47ec22017-03-08 18:09:35 -0800101 * Return {@link android.view.Display.INVALID_DISPLAY} if there exists no virtual display
102 * currently or the display id of the current virtual display.
103 *
104 * @return {@link android.view.Display.INVALID_DISPLAY} if there is no virtual display
105 * currently, else return the display id of the virtual display
106 */
Karthik Ravi Shankar2b9aaed2017-05-01 01:34:19 -0700107 public abstract int getVr2dDisplayId();
Karthik Ravi Shankar3a47ec22017-03-08 18:09:35 -0800108
109 /**
Zak Cohen732aeb02017-01-29 14:19:52 -0800110 * Adds listener that reports state changes to persistent VR mode.
111 */
Steven Thomasb70845c2017-03-16 14:32:37 -0700112 public abstract void addPersistentVrModeStateListener(IPersistentVrStateCallbacks listener);
Ruben Brunkdd18a0b2015-12-04 16:16:31 -0800113}