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.app.Activity; | 7 import android.app.Activity; |
8 import android.app.ActivityManager; | 8 import android.app.ActivityManager; |
9 import android.app.PendingIntent; | 9 import android.app.PendingIntent; |
10 import android.content.BroadcastReceiver; | 10 import android.content.BroadcastReceiver; |
(...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
994 int exitCount = VrFeedbackStatus.getUserExitedAndEntered2DCount(); | 994 int exitCount = VrFeedbackStatus.getUserExitedAndEntered2DCount(); |
995 VrFeedbackStatus.setUserExitedAndEntered2DCount((exitCount + 1) % mFeedb
ackFrequency); | 995 VrFeedbackStatus.setUserExitedAndEntered2DCount((exitCount + 1) % mFeedb
ackFrequency); |
996 | 996 |
997 if (exitCount > 0) return; | 997 if (exitCount > 0) return; |
998 | 998 |
999 promptForFeedback(mActivity.getActivityTab()); | 999 promptForFeedback(mActivity.getActivityTab()); |
1000 } | 1000 } |
1001 | 1001 |
1002 private static boolean isVrCoreCompatible( | 1002 private static boolean isVrCoreCompatible( |
1003 VrCoreVersionChecker versionChecker, Tab tabToShowInfobarIn) { | 1003 VrCoreVersionChecker versionChecker, Tab tabToShowInfobarIn) { |
1004 int vrCoreCompatibility = versionChecker.getVrCoreCompatibility(); | 1004 int vrCoreCompatibility = versionChecker.getVrCoreInfo().compatibility; |
1005 | 1005 |
1006 if (vrCoreCompatibility == VrCoreVersionChecker.VR_NOT_AVAILABLE | 1006 if (vrCoreCompatibility == VrCoreCompatibility.VR_NOT_AVAILABLE |
1007 || vrCoreCompatibility == VrCoreVersionChecker.VR_OUT_OF_DATE) { | 1007 || vrCoreCompatibility == VrCoreCompatibility.VR_OUT_OF_DATE) { |
1008 promptToUpdateVrServices(vrCoreCompatibility, tabToShowInfobarIn); | 1008 promptToUpdateVrServices(vrCoreCompatibility, tabToShowInfobarIn); |
1009 } | 1009 } |
1010 | 1010 |
1011 return vrCoreCompatibility == VrCoreVersionChecker.VR_READY; | 1011 return vrCoreCompatibility == VrCoreCompatibility.VR_READY; |
1012 } | 1012 } |
1013 | 1013 |
1014 private static void promptToUpdateVrServices(int vrCoreCompatibility, Tab ta
b) { | 1014 private static void promptToUpdateVrServices(int vrCoreCompatibility, Tab ta
b) { |
1015 if (tab == null) { | 1015 if (tab == null) { |
1016 return; | 1016 return; |
1017 } | 1017 } |
1018 final Activity activity = tab.getActivity(); | 1018 final Activity activity = tab.getActivity(); |
1019 String infobarText; | 1019 String infobarText; |
1020 String buttonText; | 1020 String buttonText; |
1021 if (vrCoreCompatibility == VrCoreVersionChecker.VR_NOT_AVAILABLE) { | 1021 if (vrCoreCompatibility == VrCoreCompatibility.VR_NOT_AVAILABLE) { |
1022 // Supported, but not installed. Ask user to install instead of upgr
ade. | 1022 // Supported, but not installed. Ask user to install instead of upgr
ade. |
1023 infobarText = activity.getString(R.string.vr_services_check_infobar_
install_text); | 1023 infobarText = activity.getString(R.string.vr_services_check_infobar_
install_text); |
1024 buttonText = activity.getString(R.string.vr_services_check_infobar_i
nstall_button); | 1024 buttonText = activity.getString(R.string.vr_services_check_infobar_i
nstall_button); |
1025 } else if (vrCoreCompatibility == VrCoreVersionChecker.VR_OUT_OF_DATE) { | 1025 } else if (vrCoreCompatibility == VrCoreCompatibility.VR_OUT_OF_DATE) { |
1026 infobarText = activity.getString(R.string.vr_services_check_infobar_
update_text); | 1026 infobarText = activity.getString(R.string.vr_services_check_infobar_
update_text); |
1027 buttonText = activity.getString(R.string.vr_services_check_infobar_u
pdate_button); | 1027 buttonText = activity.getString(R.string.vr_services_check_infobar_u
pdate_button); |
1028 } else { | 1028 } else { |
1029 Log.e(TAG, "Unknown VrCore compatibility: " + vrCoreCompatibility); | 1029 Log.e(TAG, "Unknown VrCore compatibility: " + vrCoreCompatibility); |
1030 return; | 1030 return; |
1031 } | 1031 } |
1032 | 1032 |
1033 SimpleConfirmInfoBarBuilder.Listener listener = new SimpleConfirmInfoBar
Builder.Listener() { | 1033 SimpleConfirmInfoBarBuilder.Listener listener = new SimpleConfirmInfoBar
Builder.Listener() { |
1034 @Override | 1034 @Override |
1035 public void onInfoBarDismissed() {} | 1035 public void onInfoBarDismissed() {} |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1142 } | 1142 } |
1143 | 1143 |
1144 /** | 1144 /** |
1145 * @return Pointer to the native VrShellDelegate object. | 1145 * @return Pointer to the native VrShellDelegate object. |
1146 */ | 1146 */ |
1147 @CalledByNative | 1147 @CalledByNative |
1148 private long getNativePointer() { | 1148 private long getNativePointer() { |
1149 return mNativeVrShellDelegate; | 1149 return mNativeVrShellDelegate; |
1150 } | 1150 } |
1151 | 1151 |
| 1152 @CalledByNative |
| 1153 private long getVrCoreInfo() { |
| 1154 assert mVrCoreVersionChecker != null; |
| 1155 return mVrCoreVersionChecker.getVrCoreInfo().makeNativeVrCoreInfo(); |
| 1156 } |
| 1157 |
1152 private void destroy() { | 1158 private void destroy() { |
1153 if (sInstance == null) return; | 1159 if (sInstance == null) return; |
1154 shutdownVr(false /* disableVrMode */, false /* canReenter */, false /* s
tayingInChrome */); | 1160 shutdownVr(false /* disableVrMode */, false /* canReenter */, false /* s
tayingInChrome */); |
1155 if (mNativeVrShellDelegate != 0) nativeDestroy(mNativeVrShellDelegate); | 1161 if (mNativeVrShellDelegate != 0) nativeDestroy(mNativeVrShellDelegate); |
1156 mNativeVrShellDelegate = 0; | 1162 mNativeVrShellDelegate = 0; |
1157 ApplicationStatus.unregisterActivityStateListener(this); | 1163 ApplicationStatus.unregisterActivityStateListener(this); |
1158 sInstance = null; | 1164 sInstance = null; |
1159 } | 1165 } |
1160 | 1166 |
1161 private native long nativeInit(); | 1167 private native long nativeInit(); |
1162 private static native void nativeOnLibraryAvailable(); | 1168 private static native void nativeOnLibraryAvailable(); |
1163 private native void nativeSetPresentResult(long nativeVrShellDelegate, boole
an result); | 1169 private native void nativeSetPresentResult(long nativeVrShellDelegate, boole
an result); |
1164 private native void nativeDisplayActivate(long nativeVrShellDelegate); | 1170 private native void nativeDisplayActivate(long nativeVrShellDelegate); |
1165 private native void nativeUpdateVSyncInterval(long nativeVrShellDelegate, lo
ng timebaseNanos, | 1171 private native void nativeUpdateVSyncInterval(long nativeVrShellDelegate, lo
ng timebaseNanos, |
1166 double intervalSeconds); | 1172 double intervalSeconds); |
1167 private native void nativeOnPause(long nativeVrShellDelegate); | 1173 private native void nativeOnPause(long nativeVrShellDelegate); |
1168 private native void nativeOnResume(long nativeVrShellDelegate); | 1174 private native void nativeOnResume(long nativeVrShellDelegate); |
1169 private native void nativeUpdateNonPresentingContext(long nativeVrShellDeleg
ate, long context); | 1175 private native void nativeUpdateNonPresentingContext(long nativeVrShellDeleg
ate, long context); |
1170 private native void nativeDestroy(long nativeVrShellDelegate); | 1176 private native void nativeDestroy(long nativeVrShellDelegate); |
1171 } | 1177 } |
OLD | NEW |