Merge "Prevent unwanted keypress actions during TV Setup." into oc-dev

This commit is contained in:
TreeHugger Robot
2017-06-29 18:50:08 +00:00
committed by Android (Google) Code Review
2 changed files with 27 additions and 1 deletions

View File

@@ -3102,6 +3102,18 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
} }
} }
/**
* Check if Setup or Post-Setup update is completed on TV
* @return true if completed
*/
private boolean isTvUserSetupComplete() {
boolean isTvSetupComplete = Settings.Secure.getInt(getContext().getContentResolver(),
Settings.Secure.USER_SETUP_COMPLETE, 0) != 0;
isTvSetupComplete &= Settings.Secure.getInt(getContext().getContentResolver(),
Settings.Secure.TV_USER_SETUP_COMPLETE, 0) != 0;
return isTvSetupComplete;
}
/** /**
* Helper method for adding launch-search to most applications. Opens the * Helper method for adding launch-search to most applications. Opens the
* search window using default settings. * search window using default settings.
@@ -3109,6 +3121,11 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
* @return true if search window opened * @return true if search window opened
*/ */
private boolean launchDefaultSearch(KeyEvent event) { private boolean launchDefaultSearch(KeyEvent event) {
if (getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK)
&& !isTvUserSetupComplete()) {
// If we are in Setup or Post-Setup update mode on TV, consume the search key
return false;
}
boolean result; boolean result;
final Callback cb = getCallback(); final Callback cb = getCallback();
if (cb == null || isDestroyed()) { if (cb == null || isDestroyed()) {

View File

@@ -1689,8 +1689,17 @@ public class PhoneWindowManager implements WindowManagerPolicy {
} }
boolean isUserSetupComplete() { boolean isUserSetupComplete() {
return Settings.Secure.getIntForUser(mContext.getContentResolver(), boolean isSetupComplete = Settings.Secure.getIntForUser(mContext.getContentResolver(),
Settings.Secure.USER_SETUP_COMPLETE, 0, UserHandle.USER_CURRENT) != 0; Settings.Secure.USER_SETUP_COMPLETE, 0, UserHandle.USER_CURRENT) != 0;
if (mHasFeatureLeanback) {
isSetupComplete &= isTvUserSetupComplete();
}
return isSetupComplete;
}
private boolean isTvUserSetupComplete() {
return Settings.Secure.getIntForUser(mContext.getContentResolver(),
Settings.Secure.TV_USER_SETUP_COMPLETE, 0, UserHandle.USER_CURRENT) != 0;
} }
private void handleShortPressOnHome() { private void handleShortPressOnHome() {