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 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
757 } | 757 } |
758 restoreWindowMode(); | 758 restoreWindowMode(); |
759 mVrShell.pause(); | 759 mVrShell.pause(); |
760 removeVrViews(); | 760 removeVrViews(); |
761 destroyVrShell(); | 761 destroyVrShell(); |
762 mActivity.getFullscreenManager().setPositionsForTabToNonFullscreen(); | 762 mActivity.getFullscreenManager().setPositionsForTabToNonFullscreen(); |
763 } | 763 } |
764 | 764 |
765 private static boolean isVrCoreCompatible( | 765 private static boolean isVrCoreCompatible( |
766 VrCoreVersionChecker versionChecker, Tab tabToShowInfobarIn) { | 766 VrCoreVersionChecker versionChecker, Tab tabToShowInfobarIn) { |
767 int vrCoreCompatibility = versionChecker.getVrCoreCompatibility(); | 767 int vrCoreCompatibility = versionChecker.getVrCoreInfo().compatibility; |
768 | 768 |
769 if (vrCoreCompatibility == VrCoreVersionChecker.VR_NOT_AVAILABLE | 769 if (vrCoreCompatibility == VrCoreCompatibility.VR_NOT_AVAILABLE |
770 || vrCoreCompatibility == VrCoreVersionChecker.VR_OUT_OF_DATE) { | 770 || vrCoreCompatibility == VrCoreCompatibility.VR_OUT_OF_DATE) { |
771 promptToUpdateVrServices(vrCoreCompatibility, tabToShowInfobarIn); | 771 promptToUpdateVrServices(vrCoreCompatibility, tabToShowInfobarIn); |
772 } | 772 } |
773 | 773 |
774 return vrCoreCompatibility == VrCoreVersionChecker.VR_READY; | 774 return vrCoreCompatibility == VrCoreCompatibility.VR_READY; |
775 } | 775 } |
776 | 776 |
777 private static void promptToUpdateVrServices(int vrCoreCompatibility, Tab ta b) { | 777 private static void promptToUpdateVrServices(int vrCoreCompatibility, Tab ta b) { |
778 if (tab == null) { | 778 if (tab == null) { |
779 return; | 779 return; |
780 } | 780 } |
781 final Activity activity = tab.getActivity(); | 781 final Activity activity = tab.getActivity(); |
782 String infobarText; | 782 String infobarText; |
783 String buttonText; | 783 String buttonText; |
784 if (vrCoreCompatibility == VrCoreVersionChecker.VR_NOT_AVAILABLE) { | 784 if (vrCoreCompatibility == VrCoreCompatibility.VR_NOT_AVAILABLE) { |
785 // Supported, but not installed. Ask user to install instead of upgr ade. | 785 // Supported, but not installed. Ask user to install instead of upgr ade. |
786 infobarText = activity.getString(R.string.vr_services_check_infobar_ install_text); | 786 infobarText = activity.getString(R.string.vr_services_check_infobar_ install_text); |
787 buttonText = activity.getString(R.string.vr_services_check_infobar_i nstall_button); | 787 buttonText = activity.getString(R.string.vr_services_check_infobar_i nstall_button); |
788 } else if (vrCoreCompatibility == VrCoreVersionChecker.VR_OUT_OF_DATE) { | 788 } else if (vrCoreCompatibility == VrCoreCompatibility.VR_OUT_OF_DATE) { |
789 infobarText = activity.getString(R.string.vr_services_check_infobar_ update_text); | 789 infobarText = activity.getString(R.string.vr_services_check_infobar_ update_text); |
790 buttonText = activity.getString(R.string.vr_services_check_infobar_u pdate_button); | 790 buttonText = activity.getString(R.string.vr_services_check_infobar_u pdate_button); |
791 } else { | 791 } else { |
792 Log.e(TAG, "Unknown VrCore compatibility: " + vrCoreCompatibility); | 792 Log.e(TAG, "Unknown VrCore compatibility: " + vrCoreCompatibility); |
793 return; | 793 return; |
794 } | 794 } |
795 | 795 |
796 SimpleConfirmInfoBarBuilder.Listener listener = new SimpleConfirmInfoBar Builder.Listener() { | 796 SimpleConfirmInfoBarBuilder.Listener listener = new SimpleConfirmInfoBar Builder.Listener() { |
797 @Override | 797 @Override |
798 public void onInfoBarDismissed() {} | 798 public void onInfoBarDismissed() {} |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
895 } | 895 } |
896 | 896 |
897 /** | 897 /** |
898 * @return Pointer to the native VrShellDelegate object. | 898 * @return Pointer to the native VrShellDelegate object. |
899 */ | 899 */ |
900 @CalledByNative | 900 @CalledByNative |
901 private long getNativePointer() { | 901 private long getNativePointer() { |
902 return mNativeVrShellDelegate; | 902 return mNativeVrShellDelegate; |
903 } | 903 } |
904 | 904 |
905 @CalledByNative | |
906 private long getVrCoreInfo() { | |
907 assert mVrCoreVersionChecker != null; | |
908 VrCoreInfo vrCoreInfo = mVrCoreVersionChecker.getVrCoreInfo(); | |
909 long nativeVrCoreInfo = (vrCoreInfo.gvrVersion != null) | |
ddorwin
2017/05/24 07:31:37
nit: It is generally clearer to use positive logic
tiborg
2017/05/25 00:06:02
Makes sense. Changed it.
| |
910 ? nativeMakeNativeVrCoreInfo(mNativeVrShellDelegate, | |
911 vrCoreInfo.gvrVersion.majorVersion, vrCoreInfo.gvrVers ion.minorVersion, | |
912 vrCoreInfo.gvrVersion.patchVersion, vrCoreInfo.compati bility) | |
913 : nativeMakeNativeVrCoreInfo( | |
914 mNativeVrShellDelegate, 0, 0, 0, vrCoreInfo.compatibil ity); | |
915 return nativeVrCoreInfo; | |
916 } | |
917 | |
905 private void destroy() { | 918 private void destroy() { |
906 if (sInstance == null) return; | 919 if (sInstance == null) return; |
907 shutdownVr(true, false); | 920 shutdownVr(true, false); |
908 if (mNativeVrShellDelegate != 0) nativeDestroy(mNativeVrShellDelegate); | 921 if (mNativeVrShellDelegate != 0) nativeDestroy(mNativeVrShellDelegate); |
909 mNativeVrShellDelegate = 0; | 922 mNativeVrShellDelegate = 0; |
910 ApplicationStatus.unregisterActivityStateListener(this); | 923 ApplicationStatus.unregisterActivityStateListener(this); |
911 sInstance = null; | 924 sInstance = null; |
912 } | 925 } |
913 | 926 |
914 private native long nativeInit(); | 927 private native long nativeInit(); |
915 private static native void nativeOnLibraryAvailable(); | 928 private static native void nativeOnLibraryAvailable(); |
916 private native void nativeSetPresentResult(long nativeVrShellDelegate, boole an result); | 929 private native void nativeSetPresentResult(long nativeVrShellDelegate, boole an result); |
917 private native void nativeDisplayActivate(long nativeVrShellDelegate); | 930 private native void nativeDisplayActivate(long nativeVrShellDelegate); |
918 private native void nativeUpdateVSyncInterval(long nativeVrShellDelegate, lo ng timebaseNanos, | 931 private native void nativeUpdateVSyncInterval(long nativeVrShellDelegate, lo ng timebaseNanos, |
919 double intervalSeconds); | 932 double intervalSeconds); |
920 private native void nativeOnPause(long nativeVrShellDelegate); | 933 private native void nativeOnPause(long nativeVrShellDelegate); |
921 private native void nativeOnResume(long nativeVrShellDelegate); | 934 private native void nativeOnResume(long nativeVrShellDelegate); |
922 private native void nativeDestroy(long nativeVrShellDelegate); | 935 private native void nativeDestroy(long nativeVrShellDelegate); |
936 private native long nativeMakeNativeVrCoreInfo(long nativeVrShellDelegate, i nt majorVersion, | |
937 int minorVersion, int patchVersion, int compatibility); | |
923 } | 938 } |
OLD | NEW |