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

Commit 9d590229 authored by Charles Chen's avatar Charles Chen Committed by Automerger Merge Worker
Browse files

Merge changes from topic "ime_migration" into sc-v2-dev am: 235a0bf9 am: d5b2c15a

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14716057

Change-Id: I4303a7207004eb8d8611ef594c107f1fc16d5932
parents d51e70f2 d5b2c15a
Loading
Loading
Loading
Loading
+0 −15
Original line number Diff line number Diff line
@@ -96,7 +96,6 @@ import android.graphics.Canvas;
import android.graphics.HardwareRenderer;
import android.graphics.Typeface;
import android.hardware.display.DisplayManagerGlobal;
import android.inputmethodservice.InputMethodService;
import android.media.MediaFrameworkInitializer;
import android.media.MediaFrameworkPlatformInitializer;
import android.media.MediaServiceManager;
@@ -5779,9 +5778,6 @@ public final class ActivityThread extends ClientTransactionHandler
            final int NSVC = mServices.size();
            for (int i=0; i<NSVC; i++) {
                final Service service = mServices.valueAt(i);
                if (service instanceof InputMethodService) {
                    mHasImeComponent = true;
                }
                // If {@code includeUiContext} is set to false, WindowProviderService should not be
                // collected because WindowProviderService is a UI Context.
                if (includeUiContexts || !(service instanceof WindowProviderService)) {
@@ -7524,12 +7520,6 @@ public final class ActivityThread extends ClientTransactionHandler

        ViewRootImpl.ConfigChangedCallback configChangedCallback = (Configuration globalConfig) -> {
            synchronized (mResourcesManager) {
                // TODO (b/135719017): Temporary log for debugging IME service.
                if (Build.IS_DEBUGGABLE && mHasImeComponent) {
                    Log.d(TAG, "ViewRootImpl.ConfigChangedCallback for IME, "
                            + "config=" + globalConfig);
                }

                // We need to apply this change to the resources immediately, because upon returning
                // the view hierarchy will be informed about it.
                if (mResourcesManager.applyConfigurationToResources(globalConfig,
@@ -7884,11 +7874,6 @@ public final class ActivityThread extends ClientTransactionHandler
        return mDensityCompatMode;
    }

    @Override
    public boolean hasImeComponent() {
        return mHasImeComponent;
    }

    // ------------------ Regular JNI ------------------------
    private native void nPurgePendingResources();
    private native void nDumpGraphicsInfo(FileDescriptor fd);
+0 −2
Original line number Diff line number Diff line
@@ -32,8 +32,6 @@ interface ActivityThreadInternal {

    boolean isInDensityCompatMode();

    boolean hasImeComponent();

    boolean isCachedProcessState();

    Application getApplication();
+0 −21
Original line number Diff line number Diff line
@@ -28,12 +28,9 @@ import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.HardwareRenderer;
import android.inputmethodservice.InputMethodService;
import android.os.Build;
import android.os.LocaleList;
import android.os.Trace;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.Slog;
import android.view.ContextThemeWrapper;
import android.view.WindowManagerGlobal;
@@ -168,12 +165,7 @@ class ConfigurationController {
                mPendingConfiguration = null;
            }

            final boolean hasIme = mActivityThread.hasImeComponent();
            if (config == null) {
                // TODO (b/135719017): Temporary log for debugging IME service.
                if (Build.IS_DEBUGGABLE && hasIme) {
                    Log.w(TAG, "handleConfigurationChanged for IME app but config is null");
                }
                return;
            }

@@ -204,12 +196,6 @@ class ConfigurationController {
                mConfiguration = new Configuration();
            }
            if (!mConfiguration.isOtherSeqNewer(config) && compat == null) {
                // TODO (b/135719017): Temporary log for debugging IME service.
                if (Build.IS_DEBUGGABLE && hasIme) {
                    Log.w(TAG, "handleConfigurationChanged for IME app but config seq is obsolete "
                            + ", config=" + config
                            + ", mConfiguration=" + mConfiguration);
                }
                return;
            }

@@ -237,13 +223,6 @@ class ConfigurationController {
                ComponentCallbacks2 cb = callbacks.get(i);
                if (!equivalent) {
                    performConfigurationChanged(cb, config);
                } else {
                    // TODO (b/135719017): Temporary log for debugging IME service.
                    if (Build.IS_DEBUGGABLE && cb instanceof InputMethodService) {
                        Log.w(TAG, "performConfigurationChanged didn't callback to IME "
                                + ", configDiff=" + configDiff
                                + ", mConfiguration=" + mConfiguration);
                    }
                }
            }
        }
+23 −0
Original line number Diff line number Diff line
@@ -26,8 +26,11 @@ import android.app.IWindowToken;
import android.app.ResourcesManager;
import android.content.Context;
import android.content.res.Configuration;
import android.inputmethodservice.AbstractInputMethodService;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;

import java.lang.ref.WeakReference;

@@ -43,6 +46,8 @@ import java.lang.ref.WeakReference;
 * @hide
 */
public class WindowTokenClient extends IWindowToken.Stub {
    private static final String TAG = WindowTokenClient.class.getSimpleName();

    /**
     * Attached {@link Context} for this window token to update configuration and resources.
     * Initialized by {@link #attachContext(Context)}.
@@ -53,6 +58,8 @@ public class WindowTokenClient extends IWindowToken.Stub {

    private final Configuration mConfiguration = new Configuration();

    private boolean mShouldDumpConfigForIme;

    /**
     * Attaches {@code context} to this {@link WindowTokenClient}. Each {@link WindowTokenClient}
     * can only attach one {@link Context}.
@@ -69,6 +76,8 @@ public class WindowTokenClient extends IWindowToken.Stub {
        }
        mContextRef = new WeakReference<>(context);
        mConfiguration.setTo(context.getResources().getConfiguration());
        mShouldDumpConfigForIme = Build.IS_DEBUGGABLE
                && context instanceof AbstractInputMethodService;
    }

    @Override
@@ -82,6 +91,13 @@ public class WindowTokenClient extends IWindowToken.Stub {
                newConfig, newConfig /* overrideConfig */, displayChanged,
                null /* configChanged */);

        if (!shouldUpdateResources && mShouldDumpConfigForIme) {
            Log.d(TAG, "Configuration not dispatch to IME because configuration is up"
                    + " to date. Current config=" + context.getResources().getConfiguration()
                    + ", reported config=" + mConfiguration
                    + ", updated config=" + newConfig);
        }

        if (shouldUpdateResources) {
            // TODO(ag/9789103): update resource manager logic to track non-activity tokens
            mResourcesManager.updateResourcesForActivity(this, newConfig, newDisplayId);
@@ -104,6 +120,13 @@ public class WindowTokenClient extends IWindowToken.Stub {
                        ((WindowProviderService) context).onConfigurationChanged(newConfig));
            }
            freeTextLayoutCachesIfNeeded(diff);
            if (diff == 0 && mShouldDumpConfigForIme) {
                Log.d(TAG, "Configuration not dispatch to IME because configuration has no "
                        + " public difference with updated config. "
                        + " Current config=" + context.getResources().getConfiguration()
                        + ", reported config=" + mConfiguration
                        + ", updated config=" + newConfig);
            }
            mConfiguration.setTo(newConfig);
        }
        if (displayChanged) {