| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 package org.chromium.device.vr; | |
| 6 | |
| 7 import android.content.Context; | |
| 8 | |
| 9 import com.google.vr.ndk.base.GvrLayout; | |
| 10 | |
| 11 import org.chromium.base.annotations.CalledByNative; | |
| 12 import org.chromium.base.annotations.JNINamespace; | |
| 13 | |
| 14 /** | |
| 15 * This is the implementation of the C++ counterpart GvrDeviceProvider. | |
| 16 */ | |
| 17 @JNINamespace("device") | |
| 18 class GvrDeviceProvider { | |
| 19 private static final String TAG = "GvrDeviceProvider"; | |
| 20 private final GvrLayout mLayout; | |
| 21 private Thread mGvrInitThread; | |
| 22 | |
| 23 private GvrDeviceProvider(Context context) { | |
| 24 mLayout = new GvrLayout(context); | |
| 25 | |
| 26 // Initialize the GVR API on a separate thread to avoid strict mode | |
| 27 // violations. Note that this doesn't fix the underlying issue of | |
| 28 // blocking on disk reads here. | |
| 29 mGvrInitThread = new Thread(new Runnable() { | |
| 30 @Override | |
| 31 public void run() { | |
| 32 mLayout.getGvrApi(); | |
| 33 } | |
| 34 }); | |
| 35 mGvrInitThread.start(); | |
| 36 } | |
| 37 | |
| 38 @CalledByNative | |
| 39 private static GvrDeviceProvider create(Context context) { | |
| 40 return new GvrDeviceProvider(context); | |
| 41 } | |
| 42 | |
| 43 @CalledByNative | |
| 44 private long getNativeContext() { | |
| 45 try { | |
| 46 mGvrInitThread.join(); | |
| 47 } catch (Exception ex) { | |
| 48 } | |
| 49 return mLayout.getGvrApi().getNativeGvrContext(); | |
| 50 } | |
| 51 | |
| 52 @CalledByNative | |
| 53 private void shutdown() { | |
| 54 mLayout.shutdown(); | |
| 55 } | |
| 56 } | |
| OLD | NEW |