Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrCoreVersionCheckerImpl.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrCoreVersionCheckerImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrCoreVersionCheckerImpl.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9528b124535dc2b7609055ec49b7a7ba5e25f767 |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrCoreVersionCheckerImpl.java |
| @@ -0,0 +1,46 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.chrome.browser.vr_shell; |
| + |
| +import android.content.Context; |
| + |
| +import com.google.vr.ndk.base.Version; |
| +import com.google.vr.vrcore.base.api.VrCoreNotAvailableException; |
| +import com.google.vr.vrcore.base.api.VrCoreUtils; |
| +import com.google.vr.vrcore.base.api.VrCoreUtils.ConnectionResult; |
| + |
| +import org.chromium.base.Log; |
| +import org.chromium.base.annotations.UsedByReflection; |
| + |
| +/** |
| + * Helper class to check if VrCore version is compatible with Chromium. |
| + */ |
| +@UsedByReflection("VrShellDelegate.java") |
| +public class VrCoreVersionCheckerImpl implements VrCoreVersionChecker { |
| + private static final String TAG = "VrCoreVersionChecker"; |
| + private Context mContext; |
| + |
| + @UsedByReflection("VrShellDelegate.java") |
| + public VrCoreVersionCheckerImpl(Context context) { |
|
agrieve
2016/11/10 19:16:29
Rather than pass in the context, I'd guess this co
bshe
2016/11/10 20:59:25
Done.
|
| + mContext = context; |
| + } |
| + |
| + @Override |
| + public boolean isVrCoreCompatible() { |
| + try { |
| + String vrCoreSdkLibraryVersionString = VrCoreUtils.getVrCoreSdkLibraryVersion(mContext); |
| + Version vrCoreSdkLibraryVersion = Version.parse(vrCoreSdkLibraryVersionString); |
| + Version targetSdkLibraryVersion = |
| + Version.parse(com.google.vr.ndk.base.BuildConstants.VERSION); |
| + if (!vrCoreSdkLibraryVersion.isAtLeast(targetSdkLibraryVersion)) { |
| + throw new VrCoreNotAvailableException(ConnectionResult.SERVICE_OBSOLETE); |
| + } |
| + return true; |
| + } catch (VrCoreNotAvailableException e) { |
| + Log.e(TAG, "Unable to find a compatible VrCore", e); |
| + return false; |
| + } |
| + } |
| +} |