OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.vr_shell; | 5 package org.chromium.chrome.browser.vr_shell; |
6 | 6 |
7 import android.content.ActivityNotFoundException; | 7 import android.content.ActivityNotFoundException; |
8 import android.content.ComponentName; | 8 import android.content.ComponentName; |
9 import android.content.Context; | 9 import android.content.Context; |
10 import android.content.Intent; | 10 import android.content.Intent; |
(...skipping 24 matching lines...) Expand all Loading... |
35 private static final String RESERVED_KEY = "google.vr/rsvd"; | 35 private static final String RESERVED_KEY = "google.vr/rsvd"; |
36 private static final String VERSION_KEY = "google.vr/ver"; | 36 private static final String VERSION_KEY = "google.vr/ver"; |
37 private static final String DATA_KEY = "google.vr/data"; | 37 private static final String DATA_KEY = "google.vr/data"; |
38 private static final ByteOrder BYTE_ORDER = ByteOrder.BIG_ENDIAN; | 38 private static final ByteOrder BYTE_ORDER = ByteOrder.BIG_ENDIAN; |
39 private static final int VIEWER_ID = 3; | 39 private static final int VIEWER_ID = 3; |
40 private static final int VERSION = 123; | 40 private static final int VERSION = 123; |
41 private static final int RESERVED = 456; | 41 private static final int RESERVED = 456; |
42 | 42 |
43 /** | 43 /** |
44 * Forces the browser into VR mode via a VrShellDelegate call. | 44 * Forces the browser into VR mode via a VrShellDelegate call. |
45 * @param vrDelegate The VRShellDelegate associated with this activity. | |
46 */ | 45 */ |
47 public static void forceEnterVr(final VrShellDelegate vrDelegate) { | 46 public static void forceEnterVr() { |
48 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 47 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
49 @Override | 48 @Override |
50 public void run() { | 49 public void run() { |
51 vrDelegate.enterVRIfNecessary(); | 50 VrShellDelegate.enterVRIfNecessary(); |
52 } | 51 } |
53 }); | 52 }); |
54 } | 53 } |
55 | 54 |
56 /** | 55 /** |
57 * Forces the browser out of VR mode via a VrShellDelegate call. | 56 * Forces the browser out of VR mode via a VrShellDelegate call. |
58 * @param vrDelegate The VRShellDelegate associated with this activity. | 57 * @param vrDelegate The VRShellDelegate associated with this activity. |
59 */ | 58 */ |
60 public static void forceExitVr(final VrShellDelegate vrDelegate) { | 59 public static void forceExitVr(final VrShellDelegate vrDelegate) { |
61 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 60 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 try { | 106 try { |
108 context.startActivity(nfcIntent); | 107 context.startActivity(nfcIntent); |
109 } catch (ActivityNotFoundException e) { | 108 } catch (ActivityNotFoundException e) { |
110 // On unsupported devices, won't find VrCore -> Do nothing | 109 // On unsupported devices, won't find VrCore -> Do nothing |
111 } | 110 } |
112 } | 111 } |
113 | 112 |
114 /** | 113 /** |
115 * Waits until the given VrShellDelegate's isInVR() returns true. Should | 114 * Waits until the given VrShellDelegate's isInVR() returns true. Should |
116 * only be used when VR Shell support is expected. | 115 * only be used when VR Shell support is expected. |
117 * @param delegate The delegate whose VR status will be polled | |
118 */ | 116 */ |
119 public static void waitForVrSupported(final VrShellDelegate delegate) { | 117 public static void waitForVrSupported() { |
120 // If VR Shell is supported, mInVr should eventually go to true | 118 // If VR Shell is supported, mInVr should eventually go to true |
121 // Relatively long timeout because sometimes GVR takes a while to enter
VR | 119 // Relatively long timeout because sometimes GVR takes a while to enter
VR |
122 CriteriaHelper.pollUiThread(Criteria.equals(true, new Callable<Boolean>(
) { | 120 CriteriaHelper.pollUiThread(Criteria.equals(true, new Callable<Boolean>(
) { |
123 @Override | 121 @Override |
124 public Boolean call() { | 122 public Boolean call() { |
125 return delegate.isInVR(); | 123 return VrShellDelegate.isInVR(); |
126 } | 124 } |
127 }), 10000, 50); | 125 }), 10000, 50); |
128 } | 126 } |
129 } | 127 } |
OLD | NEW |