| 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 import android.os.StrictMode; | |
| 9 | |
| 10 import com.google.vr.ndk.base.GvrLayout; | |
| 11 | |
| 12 import org.chromium.base.Log; | |
| 13 import org.chromium.base.annotations.CalledByNative; | |
| 14 import org.chromium.base.annotations.JNINamespace; | |
| 15 | |
| 16 /** | |
| 17 * This is the implementation of the C++ counterpart GvrDeviceProvider. | |
| 18 */ | |
| 19 @JNINamespace("device") | |
| 20 class GvrDeviceProvider { | |
| 21 private static final String TAG = "GvrDeviceProvider"; | |
| 22 private final GvrLayout mLayout; | |
| 23 | |
| 24 private GvrDeviceProvider(Context context) { | |
| 25 mLayout = new GvrLayout(context); | |
| 26 } | |
| 27 | |
| 28 @CalledByNative | |
| 29 private static GvrDeviceProvider create(Context context) { | |
| 30 return new GvrDeviceProvider(context); | |
| 31 } | |
| 32 | |
| 33 @CalledByNative | |
| 34 private long getNativeContext() { | |
| 35 long nativeGvrContext = 0; | |
| 36 | |
| 37 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); | |
| 38 | |
| 39 try { | |
| 40 nativeGvrContext = mLayout.getGvrApi().getNativeGvrContext(); | |
| 41 } catch (Exception ex) { | |
| 42 Log.e(TAG, "Unable to instantiate GvrApi", ex); | |
| 43 return 0; | |
| 44 } finally { | |
| 45 StrictMode.setThreadPolicy(oldPolicy); | |
| 46 } | |
| 47 | |
| 48 return nativeGvrContext; | |
| 49 } | |
| 50 | |
| 51 @CalledByNative | |
| 52 private void shutdown() { | |
| 53 mLayout.shutdown(); | |
| 54 } | |
| 55 } | |
| OLD | NEW |