Skip to content

Commit 8c35ac9

Browse files
Yash MalikYash Malik
Yash Malik
authored and
Yash Malik
committed
VR: Restart Chrome after keyboard updates
Bug: 818232 Change-Id: I735f717445cc4e7c1329af836b37b31f1be3612b Reviewed-on: https://chromium-review.googlesource.com/946683 Commit-Queue: Yash Malik <[email protected]> Commit-Queue: Michael Thiessen <[email protected]> Reviewed-by: Michael Thiessen <[email protected]> Cr-Original-Commit-Position: refs/heads/master@{#540607}(cherry picked from commit 6a640bd) Reviewed-on: https://chromium-review.googlesource.com/952746 Reviewed-by: Yash Malik <[email protected]> Cr-Commit-Position: refs/branch-heads/3359@{#54} Cr-Branched-From: 66afc5e-refs/heads/master@{#540276}
1 parent af670aa commit 8c35ac9

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellDelegate.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ public class VrShellDelegate
114114
private static final String VR_CORE_MARKET_URI =
115115
"market://details?id=" + VrCoreVersionChecker.VR_CORE_PACKAGE_ID;
116116

117+
private static final String GVR_KEYBOARD_PACKAGE_ID = "com.google.android.vr.inputmethod";
117118
private static final String GVR_KEYBOARD_MARKET_URI =
118-
"market://details?id=com.google.android.vr.inputmethod";
119+
"market://details?id=" + GVR_KEYBOARD_PACKAGE_ID;
119120

120121
// This value is intentionally probably overkill. This is the time we need to wait from when
121122
// Chrome is resumed, to when Chrome actually renders a black frame, so that we can cancel the
@@ -136,6 +137,7 @@ public class VrShellDelegate
136137

137138
private @VrSupportLevel int mVrSupportLevel;
138139
private int mCachedVrCorePackageVersion;
140+
private int mCachedGvrKeyboardPackageVersion;
139141

140142
// How often to prompt the user to enter VR feedback.
141143
private int mFeedbackFrequency;
@@ -328,6 +330,7 @@ public static boolean onActivityResultWithNative(int requestCode, int resultCode
328330
}
329331
// Handles the result of requesting to update GVR Keyboard.
330332
if (requestCode == GVR_KEYBOARD_UPDATE_RESULT) {
333+
if (sInstance != null) sInstance.onGvrKeyboardMaybeUpdated();
331334
return true;
332335
}
333336
return false;
@@ -786,6 +789,11 @@ private int getVrCorePackageVersion() {
786789
ContextUtils.getApplicationContext(), VrCoreVersionChecker.VR_CORE_PACKAGE_ID);
787790
}
788791

792+
private int getGvrKeyboardPackageVersion() {
793+
return PackageUtils.getPackageVersion(
794+
ContextUtils.getApplicationContext(), GVR_KEYBOARD_PACKAGE_ID);
795+
}
796+
789797
/**
790798
* Updates mVrSupportLevel to the correct value. isVrCoreCompatible might return different value
791799
* at runtime.
@@ -818,8 +826,12 @@ private void updateVrSupportLevel(Integer vrCorePackageVersion) {
818826
}
819827

820828
private void onVrServicesMaybeUpdated() {
821-
int vrCorePackageVersion = getVrCorePackageVersion();
822-
if (mCachedVrCorePackageVersion == vrCorePackageVersion) return;
829+
if (mCachedVrCorePackageVersion == getVrCorePackageVersion()) return;
830+
ApplicationLifetime.terminate(true);
831+
}
832+
833+
private void onGvrKeyboardMaybeUpdated() {
834+
if (mCachedGvrKeyboardPackageVersion == getGvrKeyboardPackageVersion()) return;
823835
ApplicationLifetime.terminate(true);
824836
}
825837

@@ -1785,6 +1797,7 @@ public boolean onInfoBarButtonClicked(boolean isPrimary) {
17851797
}
17861798

17871799
/* package */ void promptForKeyboardUpdate() {
1800+
mCachedGvrKeyboardPackageVersion = getGvrKeyboardPackageVersion();
17881801
mActivity.startActivityForResult(
17891802
new Intent(Intent.ACTION_VIEW, Uri.parse(GVR_KEYBOARD_MARKET_URI)),
17901803
GVR_KEYBOARD_UPDATE_RESULT);

0 commit comments

Comments
 (0)