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

Commit ac0211a4 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Update JavaDoc for IMS#enableHardwareAcceleration

This makes it clear that on Android L+ devices IME developers basically
no longer need to call InputMethodService#enableHardwareAcceleration(),
because it is deprecated in Android L[1][2].  On L+ devices what IME
developers need to do is to make sure that their IMEs are compatible
with both hardware and software rendering so that the system can choose
the best rendering method.

This is basically a code clean-up that should not change any actual
behavior.

 [1]: I906d48cb07af50fa02dae4f4ecdb5e65211fc6ef
      5e1565ea
 [2]: I126ea823eb2eeabb29d30999dec9c9411b33b315
      e07b5955

Bug: 31202732
Change-Id: I416669b172737e3eb3d77165dcea50289d207514
parent e74adb80
Loading
Loading
Loading
Loading
+14 −18
Original line number Diff line number Diff line
@@ -266,7 +266,6 @@ public class InputMethodService extends AbstractInputMethodService {
    InputMethodManager mImm;
    
    int mTheme = 0;
    boolean mHardwareAccelerated = false;
    
    LayoutInflater mInflater;
    TypedArray mThemeAttrs;
@@ -752,27 +751,27 @@ public class InputMethodService extends AbstractInputMethodService {
    }

    /**
     * You can call this to try to enable hardware accelerated drawing for
     * your IME. This must be set before {@link #onCreate}, so you
     * will typically call it in your constructor.  It is not always possible
     * to use hardware accelerated drawing in an IME (for example on low-end
     * devices that do not have the resources to support this), so the call
     * returns true if it succeeds otherwise false if you will need to draw
     * in software.  You must be able to handle either case.
     * You can call this to try to enable accelerated drawing for your IME. This must be set before
     * {@link #onCreate()}, so you will typically call it in your constructor.  It is not always
     * possible to use hardware accelerated drawing in an IME (for example on low-end devices that
     * do not have the resources to support this), so the call {@code true} if it succeeds otherwise
     * {@code false} if you will need to draw in software.  You must be able to handle either case.
     *
     * @deprecated Starting in API 21, hardware acceleration is always enabled
     *             on capable devices.
     * <p>In API 21 and later, system may automatically enable hardware accelerated drawing for your
     * IME on capable devices even if this method is not explicitly called. Make sure that your IME
     * is able to handle either case.</p>
     *
     * @return {@code true} if accelerated drawing is successfully enabled otherwise {@code false}.
     *         On API 21 and later devices the return value is basically just a hint and your IME
     *         does not need to change the behavior based on the it
     * @deprecated Starting in API 21, hardware acceleration is always enabled on capable devices
     */
    @Deprecated
    public boolean enableHardwareAcceleration() {
        if (mWindow != null) {
            throw new IllegalStateException("Must be called before onCreate()");
        }
        if (ActivityManager.isHighEndGfx()) {
            mHardwareAccelerated = true;
            return true;
        }
        return false;
        return ActivityManager.isHighEndGfx();
    }

    @Override public void onCreate() {
@@ -793,9 +792,6 @@ public class InputMethodService extends AbstractInputMethodService {
                Context.LAYOUT_INFLATER_SERVICE);
        mWindow = new SoftInputWindow(this, "InputMethod", mTheme, null, null, mDispatcherState,
                WindowManager.LayoutParams.TYPE_INPUT_METHOD, Gravity.BOTTOM, false);
        if (mHardwareAccelerated) {
            mWindow.getWindow().addFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
        }
        initViews();
        mWindow.getWindow().setLayout(MATCH_PARENT, WRAP_CONTENT);
    }