Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrCoreVersionCheckerImpl.java

Issue 2865463003: Tracks GVR version crossed with headset type using UMA. (Closed)
Patch Set: Fixed comments Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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;
17 import org.chromium.chrome.browser.vr_shell.VrCoreInfo.GvrVersion;
18 18
19 /** 19 /**
20 * Helper class to check if VrCore version is compatible with Chromium. 20 * Helper class to check if VrCore version is compatible with Chromium.
21 */ 21 */
22 public class VrCoreVersionCheckerImpl implements VrCoreVersionChecker { 22 public class VrCoreVersionCheckerImpl implements VrCoreVersionChecker {
23 private static final String TAG = "VrCoreVersionChecker"; 23 private static final String TAG = "VrCoreVersionChecker";
24 24
25 private static final String MIN_SDK_VERSION_PARAM_NAME = "min_sdk_version"; 25 private static final String MIN_SDK_VERSION_PARAM_NAME = "min_sdk_version";
26 26
27 @Override 27 @Override
28 public int getVrCoreCompatibility() { 28 public VrCoreInfo getVrCoreInfo() {
29 // Supported Build version is determined by the webvr cardboard support feature. 29 // Supported Build version is determined by the webvr cardboard support feature.
30 // Default is KITKAT unless specified via server side finch config. 30 // Default is KITKAT unless specified via server side finch config.
31 if (Build.VERSION.SDK_INT < ChromeFeatureList.getFieldTrialParamByFeatur eAsInt( 31 if (Build.VERSION.SDK_INT < ChromeFeatureList.getFieldTrialParamByFeatur eAsInt(
32 ChromeFeatureList.WEBVR_CARDBOARD_SU PPORT, 32 ChromeFeatureList.WEBVR_CARDBOARD_SU PPORT,
33 MIN_SDK_VERSION_PARAM_NAME, 33 MIN_SDK_VERSION_PARAM_NAME,
34 Build.VERSION_CODES.KITKAT)) { 34 Build.VERSION_CODES.KITKAT)) {
35 return VrCoreVersionChecker.VR_NOT_SUPPORTED; 35 return new VrCoreInfo(null, VrCoreCompatibility.VR_NOT_SUPPORTED);
36 } 36 }
37 try { 37 try {
38 String vrCoreSdkLibraryVersionString = VrCoreUtils.getVrCoreSdkLibra ryVersion( 38 String vrCoreSdkLibraryVersionString = VrCoreUtils.getVrCoreSdkLibra ryVersion(
39 ContextUtils.getApplicationContext()); 39 ContextUtils.getApplicationContext());
40 Version vrCoreSdkLibraryVersion = Version.parse(vrCoreSdkLibraryVers ionString); 40 Version vrCoreSdkLibraryVersion = Version.parse(vrCoreSdkLibraryVers ionString);
41 Version targetSdkLibraryVersion = 41 Version targetSdkLibraryVersion =
42 Version.parse(com.google.vr.ndk.base.BuildConstants.VERSION) ; 42 Version.parse(com.google.vr.ndk.base.BuildConstants.VERSION) ;
43 GvrVersion gvrVersion = new GvrVersion(vrCoreSdkLibraryVersion.major Version,
44 vrCoreSdkLibraryVersion.minorVersion, vrCoreSdkLibraryVersio n.patchVersion);
43 if (!vrCoreSdkLibraryVersion.isAtLeast(targetSdkLibraryVersion)) { 45 if (!vrCoreSdkLibraryVersion.isAtLeast(targetSdkLibraryVersion)) {
44 return VrCoreVersionChecker.VR_OUT_OF_DATE; 46 return new VrCoreInfo(gvrVersion, VrCoreCompatibility.VR_OUT_OF_ DATE);
45 } 47 }
46 return VrCoreVersionChecker.VR_READY; 48 return new VrCoreInfo(gvrVersion, VrCoreCompatibility.VR_READY);
47 } catch (VrCoreNotAvailableException e) { 49 } catch (VrCoreNotAvailableException e) {
48 Log.i(TAG, "Unable to find VrCore."); 50 Log.i(TAG, "Unable to find VrCore.");
49 // Old versions of VrCore are not integrated with the sdk library ve rsion check and will 51 // 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. 52 // trigger this exception even though VrCore is installed.
51 // Double check package manager to make sure we are not telling user to install 53 // Double check package manager to make sure we are not telling user to install
52 // when it should just be an update. 54 // when it should just be an update.
53 if (PackageUtils.getPackageVersion( 55 if (PackageUtils.getPackageVersion(
54 ContextUtils.getApplicationContext(), VR_CORE_PACKAGE_ID ) 56 ContextUtils.getApplicationContext(), VR_CORE_PACKAGE_ID )
55 != -1) { 57 != -1) {
56 return VrCoreVersionChecker.VR_OUT_OF_DATE; 58 return new VrCoreInfo(null, VrCoreCompatibility.VR_OUT_OF_DATE);
57 } 59 }
58 return VrCoreVersionChecker.VR_NOT_AVAILABLE; 60 return new VrCoreInfo(null, VrCoreCompatibility.VR_NOT_AVAILABLE);
59 } 61 }
60 } 62 }
61 } 63 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698