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.os.Build; | 7 import android.os.Build; |
8 | 8 |
9 import com.google.vr.ndk.base.Version; | 9 import com.google.vr.ndk.base.Version; |
10 import com.google.vr.vrcore.base.api.VrCoreNotAvailableException; | 10 import com.google.vr.vrcore.base.api.VrCoreNotAvailableException; |
11 import com.google.vr.vrcore.base.api.VrCoreUtils; | 11 import com.google.vr.vrcore.base.api.VrCoreUtils; |
12 | 12 |
13 import org.chromium.base.ContextUtils; | 13 import org.chromium.base.ContextUtils; |
14 import org.chromium.base.Log; | 14 import org.chromium.base.Log; |
15 import org.chromium.base.PackageUtils; | 15 import org.chromium.base.PackageUtils; |
16 | |
17 import org.chromium.chrome.browser.ChromeFeatureList; | 16 import org.chromium.chrome.browser.ChromeFeatureList; |
18 | 17 |
19 /** | 18 /** |
20 * Helper class to check if VrCore version is compatible with Chromium. | 19 * Helper class to check if VrCore version is compatible with Chromium. |
21 */ | 20 */ |
22 public class VrCoreVersionCheckerImpl implements VrCoreVersionChecker { | 21 public class VrCoreVersionCheckerImpl implements VrCoreVersionChecker { |
23 private static final String TAG = "VrCoreVersionChecker"; | 22 private static final String TAG = "VrCoreVersionChecker"; |
24 | 23 |
25 private static final String MIN_SDK_VERSION_PARAM_NAME = "min_sdk_version"; | 24 private static final String MIN_SDK_VERSION_PARAM_NAME = "min_sdk_version"; |
26 | 25 |
27 @Override | 26 @Override |
28 public int getVrCoreCompatibility() { | 27 public VrCoreInfo getVrCoreInfo() { |
29 // Supported Build version is determined by the webvr cardboard support feature. | 28 // Supported Build version is determined by the webvr cardboard support feature. |
30 // Default is KITKAT unless specified via server side finch config. | 29 // Default is KITKAT unless specified via server side finch config. |
31 if (Build.VERSION.SDK_INT < ChromeFeatureList.getFieldTrialParamByFeatur eAsInt( | 30 if (Build.VERSION.SDK_INT < ChromeFeatureList.getFieldTrialParamByFeatur eAsInt( |
32 ChromeFeatureList.WEBVR_CARDBOARD_SU PPORT, | 31 ChromeFeatureList.WEBVR_CARDBOARD_SU PPORT, |
33 MIN_SDK_VERSION_PARAM_NAME, | 32 MIN_SDK_VERSION_PARAM_NAME, |
34 Build.VERSION_CODES.KITKAT)) { | 33 Build.VERSION_CODES.KITKAT)) { |
35 return VrCoreVersionChecker.VR_NOT_SUPPORTED; | 34 return new VrCoreInfo(null, VrCoreVersionChecker.VR_NOT_SUPPORTED); |
ddorwin
2017/05/05 20:29:59
OOC, why aren't these in an enum instead of ints.
amp
2017/05/05 23:51:54
I was just following the existing patterns. I ass
ddorwin
2017/05/16 00:15:50
mthiesse@, do you know?
mthiesse
2017/05/16 00:53:41
One of the bizarre quirks of Android/Java is that
| |
36 } | 35 } |
37 try { | 36 try { |
38 String vrCoreSdkLibraryVersionString = VrCoreUtils.getVrCoreSdkLibra ryVersion( | 37 String vrCoreSdkLibraryVersionString = VrCoreUtils.getVrCoreSdkLibra ryVersion( |
39 ContextUtils.getApplicationContext()); | 38 ContextUtils.getApplicationContext()); |
40 Version vrCoreSdkLibraryVersion = Version.parse(vrCoreSdkLibraryVers ionString); | 39 Version vrCoreSdkLibraryVersion = Version.parse(vrCoreSdkLibraryVers ionString); |
41 Version targetSdkLibraryVersion = | 40 Version targetSdkLibraryVersion = |
42 Version.parse(com.google.vr.ndk.base.BuildConstants.VERSION) ; | 41 Version.parse(com.google.vr.ndk.base.BuildConstants.VERSION) ; |
43 if (!vrCoreSdkLibraryVersion.isAtLeast(targetSdkLibraryVersion)) { | 42 if (!vrCoreSdkLibraryVersion.isAtLeast(targetSdkLibraryVersion)) { |
44 return VrCoreVersionChecker.VR_OUT_OF_DATE; | 43 return new VrCoreInfo(vrCoreSdkLibraryVersion, VrCoreVersionChec ker.VR_OUT_OF_DATE); |
45 } | 44 } |
46 return VrCoreVersionChecker.VR_READY; | 45 return new VrCoreInfo(vrCoreSdkLibraryVersion, VrCoreVersionChecker. VR_READY); |
47 } catch (VrCoreNotAvailableException e) { | 46 } catch (VrCoreNotAvailableException e) { |
48 Log.i(TAG, "Unable to find VrCore."); | 47 Log.i(TAG, "Unable to find VrCore."); |
49 // Old versions of VrCore are not integrated with the sdk library ve rsion check and will | 48 // Old versions of VrCore are not integrated with the sdk library ve rsion check and will |
50 // trigger this exception even though VrCore is installed. | 49 // trigger this exception even though VrCore is installed. |
51 // Double check package manager to make sure we are not telling user to install | 50 // Double check package manager to make sure we are not telling user to install |
52 // when it should just be an update. | 51 // when it should just be an update. |
53 if (PackageUtils.getPackageVersion( | 52 if (PackageUtils.getPackageVersion( |
54 ContextUtils.getApplicationContext(), VR_CORE_PACKAGE_ID ) | 53 ContextUtils.getApplicationContext(), VR_CORE_PACKAGE_ID ) |
55 != -1) { | 54 != -1) { |
56 return VrCoreVersionChecker.VR_OUT_OF_DATE; | 55 return new VrCoreInfo(null, VrCoreVersionChecker.VR_OUT_OF_DATE) ; |
57 } | 56 } |
58 return VrCoreVersionChecker.VR_NOT_AVAILABLE; | 57 return new VrCoreInfo(null, VrCoreVersionChecker.VR_NOT_AVAILABLE); |
59 } | 58 } |
60 } | 59 } |
61 } | 60 } |
OLD | NEW |