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

Commit f512575c authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I7c2c9411,Ibc72c84d,Ib3968644 into oc-dev

* changes:
  No need to deal with windowTokens
  Persistable accessibility ID from ContextWrappers
  Check callbacks when operting on UI
parents 03e920f3 134cee27
Loading
Loading
Loading
Loading
+48 −43
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import com.android.internal.annotations.GuardedBy;
import com.android.internal.app.IVoiceInteractor;
import com.android.internal.app.ToolbarActionBar;
import com.android.internal.app.WindowDecorActionBar;
import com.android.internal.policy.DecorView;
import com.android.internal.policy.PhoneWindow;

import android.annotation.CallSuper;
@@ -3146,19 +3147,6 @@ public class Activity extends ContextThemeWrapper
    public void onWindowFocusChanged(boolean hasFocus) {
    }

    /**
     * Called before {@link #onAttachedToWindow}.
     *
     * @hide
     */
    @CallSuper
    public void onBeforeAttachedToWindow() {
        if (mAutoFillResetNeeded) {
            getAutofillManager().onAttachedToWindow(
                    getWindow().getDecorView().getRootView().getWindowToken());
        }
    }

    /**
     * Called when the main window associated with the activity has been
     * attached to the window manager.
@@ -7471,35 +7459,51 @@ public class Activity extends ContextThemeWrapper
    }

    /** @hide */
    @Override
    public boolean getViewVisibility(int viewId) {
        Window window = getWindow();
        if (window == null) {
            Log.i(TAG, "no window");
            return false;
    @NonNull public View[] findViewsByAccessibilityIdTraversal(@NonNull int[] viewIds) {
        final View[] views = new View[viewIds.length];
        final ArrayList<ViewRootImpl> roots =
                WindowManagerGlobal.getInstance().getRootViews(getActivityToken());

        for (int rootNum = 0; rootNum < roots.size(); rootNum++) {
            final View rootView = roots.get(rootNum).getView();

            if (rootView != null) {
                for (int viewNum = 0; viewNum < viewIds.length; viewNum++) {
                    if (views[viewNum] == null) {
                        views[viewNum] = rootView.findViewByAccessibilityIdTraversal(
                                viewIds[viewNum]);
                    }
                }
            }
        }

        View decorView = window.peekDecorView();
        if (decorView == null) {
            Log.i(TAG, "no decorView");
            return false;
        return views;
    }

        View view = decorView.findViewByAccessibilityIdTraversal(viewId);
    /** @hide */
    @Override
    @NonNull public boolean[] getViewVisibility(@NonNull int[] viewIds) {
        final boolean[] isVisible = new boolean[viewIds.length];
        final View views[] = findViewsByAccessibilityIdTraversal(viewIds);

        for (int i = 0; i < viewIds.length; i++) {
            View view = views[i];
            if (view == null) {
            Log.i(TAG, "cannot find view");
            return false;
                isVisible[i] = false;
                continue;
            }

            isVisible[i] = true;

            // Check if the view is visible by checking all parents
        while (view != null) {
            if (view == decorView) {
            while (true) {
                if (view instanceof DecorView && view.getViewRootImpl() == view.getParent()) {
                    break;
                }

                if (view.getVisibility() != View.VISIBLE) {
                Log.i(TAG, view + " is not visible");
                return false;
                    isVisible[i] = false;
                    break;
                }

                if (view.getParent() instanceof View) {
@@ -7508,8 +7512,9 @@ public class Activity extends ContextThemeWrapper
                    break;
                }
            }
        }

        return true;
        return isVisible;
    }

    /** @hide */
+8 −0
Original line number Diff line number Diff line
@@ -952,4 +952,12 @@ public class ContextWrapper extends Context {
    public Handler getMainThreadHandler() {
        return mBase.getMainThreadHandler();
    }

    /**
     * @hide
     */
    @Override
    public int getNextAccessibilityId() {
        return mBase.getNextAccessibilityId();
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -7706,7 +7706,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    }
    private boolean isAutofillable() {
        return getAutofillType() != AUTOFILL_TYPE_NONE && isImportantForAutofill();
        return getAutofillType() != AUTOFILL_TYPE_NONE && isImportantForAutofill()
                && getAccessibilityViewId() > LAST_APP_ACCESSIBILITY_ID;
    }
    private void populateVirtualStructure(ViewStructure structure,
+0 −7
Original line number Diff line number Diff line
@@ -479,13 +479,6 @@ public abstract class Window {
         */
        public void onWindowFocusChanged(boolean hasFocus);

        /**
         * @hide
         */
        default void onBeforeAttachedToWindow() {
            // empty
        }

        /**
         * Called when the window has been attached to the window manager.
         * See {@link View#onAttachedToWindow() View.onAttachedToWindow()}
+0 −5
Original line number Diff line number Diff line
@@ -108,11 +108,6 @@ public class WindowCallbackWrapper implements Window.Callback {
        mWrapped.onWindowFocusChanged(hasFocus);
    }

    @Override
    public void onBeforeAttachedToWindow() {
        mWrapped.onBeforeAttachedToWindow();
    }

    @Override
    public void onAttachedToWindow() {
        mWrapped.onAttachedToWindow();
Loading