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

Commit be69a3b6 authored by Ryan Lin's avatar Ryan Lin Committed by Android (Google) Code Review
Browse files

Merge "Added an interface between Sysui and system_server"

parents 4b01b414 2cc1d117
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -1444,6 +1444,29 @@ public final class AccessibilityManager {
        return null;
    }

    /**
     *
     * Sets an {@link IWindowMagnificationConnection} that manipulates window magnification.
     *
     * @param connection The connection that manipulates window magnification.
     * @hide
     */
    public void setWindowMagnificationConnection(@Nullable
            IWindowMagnificationConnection connection) {
        final IAccessibilityManager service;
        synchronized (mLock) {
            service = getServiceLocked();
            if (service == null) {
                return;
            }
        }
        try {
            service.setWindowMagnificationConnection(connection);
        } catch (RemoteException re) {
            Log.e(LOG_TAG, "Error setting window magnfication connection", re);
        }
    }

    private IAccessibilityManager getServiceLocked() {
        if (mService == null) {
            tryConnectToServiceLocked(null);
+2 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.IAccessibilityInteractionConnection;
import android.view.accessibility.IAccessibilityManagerClient;
import android.view.accessibility.IWindowMagnificationConnection;
import android.view.IWindow;

/**
@@ -86,4 +87,5 @@ interface IAccessibilityManager {

    oneway void registerSystemAction(in RemoteAction action, int actionId);
    oneway void unregisterSystemAction(int actionId);
    oneway void setWindowMagnificationConnection(in IWindowMagnificationConnection connection);
}
+75 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.view.accessibility;

import android.graphics.PointF;
import android.graphics.Rect;
import android.view.accessibility.IWindowMagnificationConnectionCallback;

/**
 * Interface for interaction between {@link AccessibilityManagerService}
 * and {@link WindowMagnification} in SystemUI.
 *
 * @hide
 */
oneway interface IWindowMagnificationConnection {

    /**
     * Enables window magnification on specifed display with specified center and scale.
     *
     * @param displayId The logical display id.
     * @param scale magnification scale.
     * @param centerX the screen-relative X coordinate around which to center,
     *                or {@link Float#NaN} to leave unchanged.
     * @param centerY the screen-relative Y coordinate around which to center,
     *                or {@link Float#NaN} to leave unchanged.
     */
    void enableWindowMagnification(int displayId, float scale, float centerX, float centerY);

    /**
     * Sets the scale of the window magnifier on specifed display.
     *
     * @param displayId The logical display id.
     * @param scale magnification scale.
     */
    void setScale(int displayId, float scale);

     /**
     * Disables window magnification on specifed display.
     *
     * @param displayId The logical display id.
     */
    void disableWindowMagnification(int displayId);

    /**
     * Moves the window magnifier on the specifed display.
     *
     * @param offsetX the amount in pixels to offset the window magnifier in the X direction, in
     *                current screen pixels.
     * @param offsetY the amount in pixels to offset the window magnifier in the Y direction, in
     *                current screen pixels.
     */
    void moveWindowMagnifier(int displayId, float offsetX, float offsetY);

    /**
     * Sets {@link IWindowMagnificationConnectionCallback} to receive the request or the callback.
     *
     *
     * @param callback the interface to be called.
     */
    void setConnectionCallback(in IWindowMagnificationConnectionCallback callback);
}
+44 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.view.accessibility;

import android.graphics.Rect;

/**
 * interface to notify the change of the window magnifier bounds and request to change
 * the magnification mode.
 *
 * @hide
 */
 oneway interface IWindowMagnificationConnectionCallback {

    /**
     * Called when the bounds of the window magnifier is changed.
     *
     * @param displayId The logical display id.
     * @param bounds The window magnifier bounds in screen coordinates.
     */
    void onWindowMagnifierBoundsChanged(int display, in Rect bounds);
    /**
     * Changes the magnification mode on specified display. It is invoked by System UI when the
     *  switch button is toggled.
     *
     * @param displayId The logical display id.
     * @param magnificationMode new magnification mode.
     */
    void onChangeMagnificationMode(int display, int magnificationMode);
}
+12 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;

import java.util.ArrayList;
@@ -193,4 +194,15 @@ public class AccessibilityManagerTest {
            }
        });
    }

    @Test
    public void testSetWindowMagnificationConnection() throws Exception {
        AccessibilityManager manager = createManager(WITH_A11Y_ENABLED);
        IWindowMagnificationConnection connection = Mockito.mock(
                IWindowMagnificationConnection.class);

        manager.setWindowMagnificationConnection(connection);

        verify(mMockService).setWindowMagnificationConnection(connection);
    }
}
Loading