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

Commit 34ed3398 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6691283 from 8cb95a92 to rvc-qpr1-release

Change-Id: I9215e4d7d615bab6e2748162675106adec9ad200
parents 593890aa 8cb95a92
Loading
Loading
Loading
Loading
+11 −6
Original line number Original line Diff line number Diff line
@@ -456,7 +456,7 @@ public class AppStandbyController implements AppStandbyInternal {
            mSystemServicesReady = true;
            mSystemServicesReady = true;


            // Offload to handler thread to avoid boot time impact.
            // Offload to handler thread to avoid boot time impact.
            mHandler.post(mInjector::updatePowerWhitelistCache);
            mHandler.post(AppStandbyController.this::updatePowerWhitelistCache);


            boolean userFileExists;
            boolean userFileExists;
            synchronized (mAppIdleLock) {
            synchronized (mAppIdleLock) {
@@ -1684,6 +1684,14 @@ public class AppStandbyController implements AppStandbyInternal {
        }
        }
    }
    }


    private void updatePowerWhitelistCache() {
        if (mInjector.getBootPhase() < PHASE_SYSTEM_SERVICES_READY) {
            return;
        }
        mInjector.updatePowerWhitelistCache();
        postCheckIdleStates(UserHandle.USER_ALL);
    }

    private class PackageReceiver extends BroadcastReceiver {
    private class PackageReceiver extends BroadcastReceiver {
        @Override
        @Override
        public void onReceive(Context context, Intent intent) {
        public void onReceive(Context context, Intent intent) {
@@ -1999,10 +2007,7 @@ public class AppStandbyController implements AppStandbyInternal {
            }
            }
        }
        }


        private void updatePowerWhitelistCache() {
        void updatePowerWhitelistCache() {
            if (mBootPhase < PHASE_SYSTEM_SERVICES_READY) {
                return;
            }
            try {
            try {
                // Don't call out to DeviceIdleController with the lock held.
                // Don't call out to DeviceIdleController with the lock held.
                final String[] whitelistedPkgs =
                final String[] whitelistedPkgs =
@@ -2204,7 +2209,7 @@ public class AppStandbyController implements AppStandbyInternal {
                    break;
                    break;
                case PowerManager.ACTION_POWER_SAVE_WHITELIST_CHANGED:
                case PowerManager.ACTION_POWER_SAVE_WHITELIST_CHANGED:
                    if (mSystemServicesReady) {
                    if (mSystemServicesReady) {
                        mHandler.post(mInjector::updatePowerWhitelistCache);
                        mHandler.post(AppStandbyController.this::updatePowerWhitelistCache);
                    }
                    }
                    break;
                    break;
            }
            }
+27 −0
Original line number Original line Diff line number Diff line
@@ -60,6 +60,19 @@ import java.util.Set;
 * notified of the completion of the initialization.<br>
 * notified of the completion of the initialization.<br>
 * When you are done using the TextToSpeech instance, call the {@link #shutdown()} method
 * When you are done using the TextToSpeech instance, call the {@link #shutdown()} method
 * to release the native resources used by the TextToSpeech engine.
 * to release the native resources used by the TextToSpeech engine.
 *
 * Apps targeting Android 11 that use text-to-speech should declare {@link
 * TextToSpeech.Engine#INTENT_ACTION_TTS_SERVICE} in the <code><queries></code> elements of their
 * manifest:
 *
 * <code>
 * <queries>
 *   ...
 *  <intent>
 *      <action android:name="android.intent.action.TTS_SERVICE" />
 *  </intent>
 * </queries>
 * </code>
 */
 */
public class TextToSpeech {
public class TextToSpeech {


@@ -239,6 +252,20 @@ public class TextToSpeech {
     *         through {@link TextToSpeech#getFeatures(java.util.Locale)}.
     *         through {@link TextToSpeech#getFeatures(java.util.Locale)}.
     *     </li>
     *     </li>
     * </ul>
     * </ul>
     *
     * Apps targeting Android 11 that use text-to-speech should declare {@link
     * #INTENT_ACTION_TTS_SERVICE} in the <code><queries></code> elements of their
     * manifest:
     *
     * <code>
     * <queries>
     *   ...
     *  <intent>
     *      <action android:name="android.intent.action.TTS_SERVICE" />
     *  </intent>
     * </queries>
     * </code>

     */
     */
    public class Engine {
    public class Engine {


+5 −5
Original line number Original line Diff line number Diff line
@@ -125,10 +125,10 @@ public final class ImeFocusController {
        final View viewForWindowFocus = focusedView != null ? focusedView : mViewRootImpl.mView;
        final View viewForWindowFocus = focusedView != null ? focusedView : mViewRootImpl.mView;
        onViewFocusChanged(viewForWindowFocus, true);
        onViewFocusChanged(viewForWindowFocus, true);


        // Starting new input when the next focused view is same as served view but the
        // Starting new input when the next focused view is same as served view but the currently
        // editor is not aligned with the same editor or editor is inactive.
        // active connection (if any) is not associated with it.
        final boolean nextFocusIsServedView = mServedView != null && mServedView == focusedView;
        final boolean nextFocusIsServedView = mServedView == viewForWindowFocus;
        if (nextFocusIsServedView && !immDelegate.isSameEditorAndAcceptingText(focusedView)) {
        if (nextFocusIsServedView && !immDelegate.hasActiveConnection(viewForWindowFocus)) {
            forceFocus = true;
            forceFocus = true;
        }
        }


@@ -254,7 +254,7 @@ public final class ImeFocusController {
        void setCurrentRootView(ViewRootImpl rootView);
        void setCurrentRootView(ViewRootImpl rootView);
        boolean isCurrentRootView(ViewRootImpl rootView);
        boolean isCurrentRootView(ViewRootImpl rootView);
        boolean isRestartOnNextWindowFocus(boolean reset);
        boolean isRestartOnNextWindowFocus(boolean reset);
        boolean isSameEditorAndAcceptingText(View view);
        boolean hasActiveConnection(View view);
    }
    }


    public View getServedView() {
    public View getServedView() {
+26 −31
Original line number Original line Diff line number Diff line
@@ -19,8 +19,8 @@ package android.view.inputmethod;
import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
import static android.Manifest.permission.WRITE_SECURE_SETTINGS;
import static android.Manifest.permission.WRITE_SECURE_SETTINGS;


import static com.android.internal.inputmethod.StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITHOUT_EDITOR;
import static com.android.internal.inputmethod.StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITHOUT_CONNECTION;
import static com.android.internal.inputmethod.StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR;
import static com.android.internal.inputmethod.StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITH_CONNECTION;


import android.annotation.DrawableRes;
import android.annotation.DrawableRes;
import android.annotation.NonNull;
import android.annotation.NonNull;
@@ -89,6 +89,7 @@ import com.android.internal.view.InputBindResult;


import java.io.FileDescriptor;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.io.PrintWriter;
import java.lang.ref.WeakReference;
import java.lang.reflect.Proxy;
import java.lang.reflect.Proxy;
import java.util.Arrays;
import java.util.Arrays;
import java.util.Collections;
import java.util.Collections;
@@ -610,14 +611,13 @@ public final class InputMethodManager {
        @Override
        @Override
        public void startInputAsyncOnWindowFocusGain(View focusedView,
        public void startInputAsyncOnWindowFocusGain(View focusedView,
                @SoftInputModeFlags int softInputMode, int windowFlags, boolean forceNewFocus) {
                @SoftInputModeFlags int softInputMode, int windowFlags, boolean forceNewFocus) {
            final boolean forceNewFocus1 = forceNewFocus;
            final int startInputFlags = getStartInputFlags(focusedView, 0);
            final int startInputFlags = getStartInputFlags(focusedView, 0);


            final ImeFocusController controller = getFocusController();
            final ImeFocusController controller = getFocusController();
            if (controller == null) {
            if (controller == null) {
                return;
                return;
            }
            }
            if (controller.checkFocus(forceNewFocus1, false)) {
            if (controller.checkFocus(forceNewFocus, false)) {
                // We need to restart input on the current focus view.  This
                // We need to restart input on the current focus view.  This
                // should be done in conjunction with telling the system service
                // should be done in conjunction with telling the system service
                // about the window gaining focus, to help make the transition
                // about the window gaining focus, to help make the transition
@@ -633,15 +633,15 @@ public final class InputMethodManager {
                // we'll just do a window focus gain and call it a day.
                // we'll just do a window focus gain and call it a day.
                try {
                try {
                    View servedView = controller.getServedView();
                    View servedView = controller.getServedView();
                    boolean nextFocusSameEditor = servedView != null && servedView == focusedView
                    boolean nextFocusHasConnection = servedView != null && servedView == focusedView
                            && isSameEditorAndAcceptingText(focusedView);
                            && hasActiveConnection(focusedView);
                    if (DEBUG) {
                    if (DEBUG) {
                        Log.v(TAG, "Reporting focus gain, without startInput"
                        Log.v(TAG, "Reporting focus gain, without startInput"
                                + ", nextFocusIsServedView=" + nextFocusSameEditor);
                                + ", nextFocusIsServedView=" + nextFocusHasConnection);
                    }
                    }
                    final int startInputReason =
                    final int startInputReason =
                            nextFocusSameEditor ? WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR
                            nextFocusHasConnection ? WINDOW_FOCUS_GAIN_REPORT_WITH_CONNECTION
                                    : WINDOW_FOCUS_GAIN_REPORT_WITHOUT_EDITOR;
                                    : WINDOW_FOCUS_GAIN_REPORT_WITHOUT_CONNECTION;
                    mService.startInputOrWindowGainedFocus(
                    mService.startInputOrWindowGainedFocus(
                            startInputReason, mClient,
                            startInputReason, mClient,
                            focusedView.getWindowToken(), startInputFlags, softInputMode,
                            focusedView.getWindowToken(), startInputFlags, softInputMode,
@@ -701,33 +701,24 @@ public final class InputMethodManager {
        }
        }


        /**
        /**
         * For {@link ImeFocusController} to check if the given focused view aligns with the same
         * Checks whether the active input connection (if any) is for the given view.
         * editor and the editor is active to accept the text input.
         *
         *
         * TODO(b/160968797): Remove this method and move mCurrentTextBoxAttritube to
         * TODO(b/160968797): Remove this method and move mServedInputConnectionWrapper to
         *  ImeFocusController.
         *  ImeFocusController.
         * In the long-term, we should make mCurrentTextBoxAtrtribue as per-window base instance,
         * so that we we can directly check if the current focused view aligned with the same editor
         * in the window without using this checking.
         *
         *
         * Note that this method is only use for fixing start new input may ignored issue
         * Note that this method is only intended for restarting input after focus gain
         * (e.g. b/160391516), DO NOT leverage this method to do another check.
         * (e.g. b/160391516), DO NOT leverage this method to do another check.
         */
         */
        public boolean isSameEditorAndAcceptingText(View view) {
        @Override
        public boolean hasActiveConnection(View view) {
            synchronized (mH) {
            synchronized (mH) {
                if (!hasServedByInputMethodLocked(view) || mCurrentTextBoxAttribute == null) {
                if (!hasServedByInputMethodLocked(view)) {
                    return false;
                    return false;
                }
                }


                final EditorInfo ic = mCurrentTextBoxAttribute;
                return mServedInputConnectionWrapper != null
                // This sameEditor checking is based on using object hash comparison to check if
                        && mServedInputConnectionWrapper.isActive()
                // some fields of the current EditorInfo (e.g. autoFillId, OpPackageName) the
                        && mServedInputConnectionWrapper.mServedView.get() == view;
                // hash code is same as the given focused view.
                final boolean sameEditor = view.onCheckIsTextEditor() && view.getId() == ic.fieldId
                        && view.getAutofillId() == ic.autofillId
                        && view.getContext().getOpPackageName() == ic.packageName;
                return sameEditor && mServedInputConnectionWrapper != null
                        && mServedInputConnectionWrapper.isActive();
            }
            }
        }
        }
    }
    }
@@ -980,11 +971,13 @@ public final class InputMethodManager {


    private static class ControlledInputConnectionWrapper extends IInputConnectionWrapper {
    private static class ControlledInputConnectionWrapper extends IInputConnectionWrapper {
        private final InputMethodManager mParentInputMethodManager;
        private final InputMethodManager mParentInputMethodManager;
        private final WeakReference<View> mServedView;


        public ControlledInputConnectionWrapper(final Looper mainLooper, final InputConnection conn,
        ControlledInputConnectionWrapper(Looper mainLooper, InputConnection conn,
                final InputMethodManager inputMethodManager) {
                InputMethodManager inputMethodManager, View servedView) {
            super(mainLooper, conn);
            super(mainLooper, conn);
            mParentInputMethodManager = inputMethodManager;
            mParentInputMethodManager = inputMethodManager;
            mServedView = new WeakReference<>(servedView);
        }
        }


        @Override
        @Override
@@ -1007,6 +1000,7 @@ public final class InputMethodManager {
                    + "connection=" + getInputConnection()
                    + "connection=" + getInputConnection()
                    + " finished=" + isFinished()
                    + " finished=" + isFinished()
                    + " mParentInputMethodManager.mActive=" + mParentInputMethodManager.mActive
                    + " mParentInputMethodManager.mActive=" + mParentInputMethodManager.mActive
                    + " mServedView=" + mServedView.get()
                    + "}";
                    + "}";
        }
        }
    }
    }
@@ -1187,7 +1181,8 @@ public final class InputMethodManager {
        mMainLooper = looper;
        mMainLooper = looper;
        mH = new H(looper);
        mH = new H(looper);
        mDisplayId = displayId;
        mDisplayId = displayId;
        mIInputContext = new ControlledInputConnectionWrapper(looper, mDummyInputConnection, this);
        mIInputContext = new ControlledInputConnectionWrapper(looper, mDummyInputConnection, this,
                null);
    }
    }


    /**
    /**
@@ -1968,7 +1963,7 @@ public final class InputMethodManager {
                    icHandler = ic.getHandler();
                    icHandler = ic.getHandler();
                }
                }
                servedContext = new ControlledInputConnectionWrapper(
                servedContext = new ControlledInputConnectionWrapper(
                        icHandler != null ? icHandler.getLooper() : vh.getLooper(), ic, this);
                        icHandler != null ? icHandler.getLooper() : vh.getLooper(), ic, this, view);
            } else {
            } else {
                servedContext = null;
                servedContext = null;
                missingMethodFlags = 0;
                missingMethodFlags = 0;
+4 −4
Original line number Original line Diff line number Diff line
@@ -46,10 +46,10 @@ public final class InputMethodDebug {
                return "UNSPECIFIED";
                return "UNSPECIFIED";
            case StartInputReason.WINDOW_FOCUS_GAIN:
            case StartInputReason.WINDOW_FOCUS_GAIN:
                return "WINDOW_FOCUS_GAIN";
                return "WINDOW_FOCUS_GAIN";
            case StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR:
            case StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITH_CONNECTION:
                return "WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR";
                return "WINDOW_FOCUS_GAIN_REPORT_WITH_CONNECTION";
            case StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITHOUT_EDITOR:
            case StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITHOUT_CONNECTION:
                return "WINDOW_FOCUS_GAIN_REPORT_WITHOUT_EDITOR";
                return "WINDOW_FOCUS_GAIN_REPORT_WITHOUT_CONNECTION";
            case StartInputReason.APP_CALLED_RESTART_INPUT_API:
            case StartInputReason.APP_CALLED_RESTART_INPUT_API:
                return "APP_CALLED_RESTART_INPUT_API";
                return "APP_CALLED_RESTART_INPUT_API";
            case StartInputReason.CHECK_FOCUS:
            case StartInputReason.CHECK_FOCUS:
Loading