OSDN Git Service

Add config option for permanent dpad presence.
authorMichael Wright <michaelwr@google.com>
Sun, 14 Sep 2014 21:55:16 +0000 (14:55 -0700)
committerMichael Wright <michaelwr@google.com>
Mon, 15 Sep 2014 21:24:59 +0000 (14:24 -0700)
Since all TV devices are required to have a DPad as a form of
navigation we should suppress any configuration instances where it
claims one doesn't exist just because it isn't currently connected.

This prevents applications from going through a configuration change
and potentially an app restart when a remote disconnects to save
battery.

Bug: 17493314
Change-Id: Ice87b7056984afe02917ccba9196fdbcac9985fc

core/res/res/values/config.xml
core/res/res/values/symbols.xml
services/core/java/com/android/server/wm/WindowManagerService.java

index 0e4f965..02913c8 100644 (file)
          2 - The device DOES NOT have a permanent menu key; ignore autodetection. -->
     <integer name="config_overrideHasPermanentMenuKey">0</integer>
 
+    <!-- Override the DPad detection behavior for configuration purposes -->
+    <bool name="config_hasPermanentDpad">false</bool>
+
     <!-- default window inset isRound property -->
     <bool name="config_windowIsRound">false</bool>
 
index e4ca36d..7469772 100644 (file)
   <java-symbol type="integer" name="config_volte_replacement_rat"/>
   <java-symbol type="integer" name="config_valid_wappush_index" />
   <java-symbol type="integer" name="config_overrideHasPermanentMenuKey" />
+  <java-symbol type="bool" name="config_hasPermanentDpad" />
 
   <java-symbol type="color" name="tab_indicator_text_v4" />
 
index 9033f30..a3da1e6 100644 (file)
@@ -333,6 +333,8 @@ public class WindowManagerService extends IWindowManager.Stub
 
     final boolean mHaveInputMethods;
 
+    final boolean mHasPermanentDpad;
+
     final boolean mAllowBootMessages;
 
     final boolean mLimitedAlphaCompositing;
@@ -804,6 +806,8 @@ public class WindowManagerService extends IWindowManager.Stub
         mOnlyCore = onlyCore;
         mLimitedAlphaCompositing = context.getResources().getBoolean(
                 com.android.internal.R.bool.config_sf_limitedAlpha);
+        mHasPermanentDpad = context.getResources().getBoolean(
+                com.android.internal.R.bool.config_hasPermanentDpad);
         mInputManager = inputManager; // Must be before createDisplayContentLocked.
         mDisplayManagerInternal = LocalServices.getService(DisplayManagerInternal.class);
         mDisplaySettings = new DisplaySettings(context);
@@ -7182,6 +7186,11 @@ public class WindowManagerService extends IWindowManager.Stub
                 }
             }
 
+            if (config.navigation == Configuration.NAVIGATION_NONAV && mHasPermanentDpad) {
+                config.navigation = Configuration.NAVIGATION_DPAD;
+                navigationPresence |= WindowManagerPolicy.PRESENCE_INTERNAL;
+            }
+
             // Determine whether a hard keyboard is available and enabled.
             boolean hardKeyboardAvailable = config.keyboard != Configuration.KEYBOARD_NOKEYS;
             if (hardKeyboardAvailable != mHardKeyboardAvailable) {
@@ -10976,6 +10985,7 @@ public class WindowManagerService extends IWindowManager.Stub
         }
         pw.println();
         pw.print("  mCurConfiguration="); pw.println(this.mCurConfiguration);
+        pw.print("  mHasPermanentDpad="); pw.println(mHasPermanentDpad);
         pw.print("  mCurrentFocus="); pw.println(mCurrentFocus);
         if (mLastFocus != mCurrentFocus) {
             pw.print("  mLastFocus="); pw.println(mLastFocus);