Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d4c67613 authored by Yohei Yukawa's avatar Yohei Yukawa Committed by Android (Google) Code Review
Browse files

Merge "Add an overlayable config for IME switcher visibility." into nyc-dev

parents 696dc4d8 fa0e47e0
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -2507,4 +2507,17 @@

    <!-- True if the device supports Sustained Performance Mode-->
    <bool name="config_sustainedPerformanceModeSupported">false</bool>

    <!-- Controls how we deal with externally connected physical keyboards.
         0 - When using this device, it is not clear for users to recognize when the physical
             keyboard is (should be) connected and when it is (should be) disconnected.  Most of
             phones and tablets with Bluetooth keyboard would fall into this category because the
             connected Bluetooth keyboard may or may not be nearby the host device.
         1 - When using this device, it is clear for users to recognize when the physical
             keyboard is (should be) connected and when it is (should be) disconnected.
             Devices with wired USB keyboard is one clear example.  Some 2-in-1 convertible
             tablets with dedicated keyboards may have the same affordance to wired USB keyboard.
    -->
    <integer name="config_externalHardKeyboardBehavior">0</integer>

</resources>
+1 −0
Original line number Diff line number Diff line
@@ -1744,6 +1744,7 @@
  <java-symbol type="integer" name="config_defaultNotificationLedOff" />
  <java-symbol type="integer" name="config_defaultNotificationLedOn" />
  <java-symbol type="integer" name="config_deskDockKeepsScreenOn" />
  <java-symbol type="integer" name="config_externalHardKeyboardBehavior" />
  <java-symbol type="integer" name="config_lightSensorWarmupTime" />
  <java-symbol type="integer" name="config_lowBatteryCloseWarningBump" />
  <java-symbol type="integer" name="config_lowBatteryWarningLevel" />
+21 −5
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@

package com.android.server;

import static java.lang.annotation.RetentionPolicy.SOURCE;

import com.android.internal.content.PackageMonitor;
import com.android.internal.inputmethod.InputMethodSubtypeSwitchingController;
import com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem;
@@ -37,6 +39,7 @@ import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlSerializer;

import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
@@ -133,6 +136,7 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.annotation.Retention;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
@@ -178,6 +182,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
    private static final int NOT_A_SUBTYPE_ID = InputMethodUtils.NOT_A_SUBTYPE_ID;
    private static final String TAG_TRY_SUPPRESSING_IME_SWITCHER = "TrySuppressingImeSwitcher";

    @Retention(SOURCE)
    @IntDef({HardKeyboardBehavior.WIRELESS_AFFORDANCE, HardKeyboardBehavior.WIRED_AFFORDANCE})
    private @interface  HardKeyboardBehavior {
        int WIRELESS_AFFORDANCE = 0;
        int WIRED_AFFORDANCE = 1;
    }

    final Context mContext;
    final Resources mRes;
@@ -462,6 +472,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
    private final MyPackageMonitor mMyPackageMonitor = new MyPackageMonitor();
    private final IPackageManager mIPackageManager;
    private final String mSlotIme;
    @HardKeyboardBehavior
    private final int mHardKeyboardBehavior;

    class SettingsObserver extends ContentObserver {
        int mUserId;
@@ -854,6 +866,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        mHasFeature = context.getPackageManager().hasSystemFeature(
                PackageManager.FEATURE_INPUT_METHODS);
        mSlotIme = mContext.getString(com.android.internal.R.string.status_bar_ime);
        mHardKeyboardBehavior = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_externalHardKeyboardBehavior);

        Bundle extras = new Bundle();
        extras.putBoolean(Notification.EXTRA_ALLOW_DURING_SETUP, true);
@@ -1712,11 +1726,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        if (isScreenLocked()) return false;
        if ((visibility & InputMethodService.IME_ACTIVE) == 0) return false;
        if (mWindowManagerInternal.isHardKeyboardAvailable()) {
            if (mHardKeyboardBehavior == HardKeyboardBehavior.WIRELESS_AFFORDANCE) {
                // When physical keyboard is attached, we show the ime switcher (or notification if
                // NavBar is not available) because SHOW_IME_WITH_HARD_KEYBOARD settings currently
                // exists in the IME switcher dialog.  Might be OK to remove this condition once
                // SHOW_IME_WITH_HARD_KEYBOARD settings finds a good place to live.
                return true;
            }
        } else if ((visibility & InputMethodService.IME_VISIBLE) == 0) {
            return false;
        }