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

Commit 7961be75 authored by Svetoslav Ganov's avatar Svetoslav Ganov
Browse files

AccessibilityNodeInfo bounds inconsistent with compatibility mode.

1. In compatibility mode a window wide scaling is applied to stretch
   the content. However, AccessibilityNodeInfos retrieved from that
   window contain bounds in application's view of the world and need
   to be scaled to properly relect what a sighted user sees.

Change-Id: Iebbb99526fc327f45b5cede89ba8c32e6ebd8845
parent c9507ac7
Loading
Loading
Loading
Loading
+25 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.database.ContentObserver;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Binder;
import android.os.Handler;
@@ -814,6 +815,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub

        final AtomicInteger mInteractionIdCounter = new AtomicInteger();

        final Rect mTempBounds = new Rect();

        // the events pending events to be dispatched to this service
        final SparseArray<AccessibilityEvent> mPendingEvents =
            new SparseArray<AccessibilityEvent>();
@@ -932,9 +935,10 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
                AccessibilityNodeInfo info = mCallback.getFindAccessibilityNodeInfoResultAndClear(
                        interactionId);
                if (info != null) {
                    applyCompatibilityScaleIfNeeded(info);
                    info.setConnection(this);
                }
                    info.setSealed(true);
                }
                return info;
            } catch (RemoteException re) {
                if (DEBUG) {
@@ -979,6 +983,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
                    final int infoCount = infos.size();
                    for (int i = 0; i < infoCount; i++) {
                        AccessibilityNodeInfo info = infos.get(i);
                        applyCompatibilityScaleIfNeeded(info);
                        info.setConnection(this);
                        info.setSealed(true);
                    }
@@ -1019,6 +1024,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
                AccessibilityNodeInfo info =
                     mCallback.getFindAccessibilityNodeInfoResultAndClear(interactionId);
                if (info != null) {
                    applyCompatibilityScaleIfNeeded(info);
                    info.setConnection(this);
                    info.setSealed(true);
                }
@@ -1093,6 +1099,24 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
            }
            return mWindowIdToInteractionConnectionMap.get(windowId);
        }

        private void applyCompatibilityScaleIfNeeded(AccessibilityNodeInfo info) {
            IBinder windowToken = mWindowIdToWindowTokenMap.get(info.getWindowId());
            final float scale = mWindowManagerService.getWindowCompatibilityScale(windowToken);

            if (Float.compare(scale, 1.0f) == 0) {
                return;
            }

            Rect bounds = mTempBounds;
            info.getBoundsInParent(bounds);
            bounds.scale(scale);
            info.setBoundsInParent(bounds);

            info.getBoundsInScreen(bounds);
            bounds.scale(scale);
            info.setBoundsInScreen(bounds);
        }
    }

    final class SecurityPolicy {
+7 −0
Original line number Diff line number Diff line
@@ -2776,6 +2776,13 @@ public class WindowManagerService extends IWindowManager.Stub
        Binder.restoreCallingIdentity(origId);
    }

    public float getWindowCompatibilityScale(IBinder windowToken) {
        synchronized (mWindowMap) {
            WindowState windowState = mWindowMap.get(windowToken);
            return (windowState != null) ? windowState.mGlobalScale : 1.0f;
        }
    }

    private AttributeCache.Entry getCachedAnimations(WindowManager.LayoutParams lp) {
        if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: layout params pkg="
                + (lp != null ? lp.packageName : null)