Skip to content

Commit

Permalink
VR: Restart Chrome after keyboard updates
Browse files Browse the repository at this point in the history
Bug: 818232
Change-Id: I735f717445cc4e7c1329af836b37b31f1be3612b
Reviewed-on: https://chromium-review.googlesource.com/946683
Commit-Queue: Yash Malik <ymalik@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Reviewed-by: Michael Thiessen <mthiesse@chromium.org>
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 <ymalik@chromium.org>
Cr-Commit-Position: refs/branch-heads/3359@{#54}
Cr-Branched-From: 66afc5e-refs/heads/master@{#540276}
  • Loading branch information
Yash Malik authored and Yash Malik committed Mar 7, 2018
1 parent af670aa commit 8c35ac9
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ public class VrShellDelegate
private static final String VR_CORE_MARKET_URI =
"market://details?id=" + VrCoreVersionChecker.VR_CORE_PACKAGE_ID;

private static final String GVR_KEYBOARD_PACKAGE_ID = "com.google.android.vr.inputmethod";
private static final String GVR_KEYBOARD_MARKET_URI =
"market://details?id=com.google.android.vr.inputmethod";
"market://details?id=" + GVR_KEYBOARD_PACKAGE_ID;

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

private @VrSupportLevel int mVrSupportLevel;
private int mCachedVrCorePackageVersion;
private int mCachedGvrKeyboardPackageVersion;

// How often to prompt the user to enter VR feedback.
private int mFeedbackFrequency;
Expand Down Expand Up @@ -328,6 +330,7 @@ public static boolean onActivityResultWithNative(int requestCode, int resultCode
}
// Handles the result of requesting to update GVR Keyboard.
if (requestCode == GVR_KEYBOARD_UPDATE_RESULT) {
if (sInstance != null) sInstance.onGvrKeyboardMaybeUpdated();
return true;
}
return false;
Expand Down Expand Up @@ -786,6 +789,11 @@ private int getVrCorePackageVersion() {
ContextUtils.getApplicationContext(), VrCoreVersionChecker.VR_CORE_PACKAGE_ID);
}

private int getGvrKeyboardPackageVersion() {
return PackageUtils.getPackageVersion(
ContextUtils.getApplicationContext(), GVR_KEYBOARD_PACKAGE_ID);
}

/**
* Updates mVrSupportLevel to the correct value. isVrCoreCompatible might return different value
* at runtime.
Expand Down Expand Up @@ -818,8 +826,12 @@ private void updateVrSupportLevel(Integer vrCorePackageVersion) {
}

private void onVrServicesMaybeUpdated() {
int vrCorePackageVersion = getVrCorePackageVersion();
if (mCachedVrCorePackageVersion == vrCorePackageVersion) return;
if (mCachedVrCorePackageVersion == getVrCorePackageVersion()) return;
ApplicationLifetime.terminate(true);
}

private void onGvrKeyboardMaybeUpdated() {
if (mCachedGvrKeyboardPackageVersion == getGvrKeyboardPackageVersion()) return;
ApplicationLifetime.terminate(true);
}

Expand Down Expand Up @@ -1785,6 +1797,7 @@ public boolean onInfoBarButtonClicked(boolean isPrimary) {
}

/* package */ void promptForKeyboardUpdate() {
mCachedGvrKeyboardPackageVersion = getGvrKeyboardPackageVersion();
mActivity.startActivityForResult(
new Intent(Intent.ACTION_VIEW, Uri.parse(GVR_KEYBOARD_MARKET_URI)),
GVR_KEYBOARD_UPDATE_RESULT);
Expand Down

0 comments on commit 8c35ac9

Please sign in to comment.