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

Commit 95af0c14 authored by Jeff Brown's avatar Jeff Brown Committed by Android (Google) Code Review
Browse files

Merge "Add support for the PointerLocation overlay." into gingerbread

parents bd1c082c a41ca77f
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -180,6 +180,11 @@ public class Looper {
        return mThread;
    }
    
    /** @hide */
    public MessageQueue getQueue() {
        return mQueue;
    }
    
    public void dump(Printer pw, String prefix) {
        pw.println(prefix + this);
        pw.println(prefix + "mRun=" + mRun);
+2 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.view.IWindowSession;
import android.view.KeyEvent;
import android.view.InputEvent;
import android.view.MotionEvent;
import android.view.InputChannel;

/**
 * System private interface to the window manager.
@@ -119,6 +120,7 @@ interface IWindowManager
    int getKeycodeStateForDevice(int devid, int sw);
    int getTrackballKeycodeState(int sw);
    int getDPadKeycodeState(int sw);
    InputChannel monitorInput(String inputChannelName);
    
    // Report whether the hardware supports the given keys; returns true if successful
    boolean hasKeys(in int[] keycodes, inout boolean[] keyExists);
+0 −5
Original line number Diff line number Diff line
@@ -779,11 +779,6 @@ public interface WindowManagerPolicy {
     */
    public void enableScreenAfterBoot();
    
    /**
     * Called every time the window manager is dispatching a pointer event.
     */
    public void dispatchedPointerEventLw(MotionEvent ev, int targetX, int targetY);
    
    public void setCurrentOrientationLw(int newOrientation);
    
    /**
+2 −1
Original line number Diff line number Diff line
@@ -171,7 +171,8 @@ public:
            status_t            append(const char* other);
            status_t            append(const char* other, size_t numChars);

            status_t            appendFormat(const char* fmt, ...);
            status_t            appendFormat(const char* fmt, ...)
                    __attribute__((format (printf, 2, 3)));

            // Note that this function takes O(N) time to calculate the value.
            // No cache value is stored.
+35 −14
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.graphics.Rect;
import android.os.Handler;
import android.os.IBinder;
import android.os.LocalPowerManager;
import android.os.Looper;
import android.os.PowerManager;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -48,15 +49,20 @@ import android.provider.Settings;
import com.android.internal.policy.PolicyManager;
import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.telephony.ITelephony;
import com.android.internal.view.BaseInputHandler;
import com.android.internal.widget.PointerLocationView;

import android.util.Config;
import android.util.EventLog;
import android.util.Log;
import android.util.Slog;
import android.view.Display;
import android.view.Gravity;
import android.view.HapticFeedbackConstants;
import android.view.IWindowManager;
import android.view.InputChannel;
import android.view.InputQueue;
import android.view.InputHandler;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.WindowOrientationListener;
@@ -220,6 +226,17 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    
    int mPointerLocationMode = 0;
    PointerLocationView mPointerLocationView = null;
    InputChannel mPointerLocationInputChannel;
    
    private final InputHandler mPointerLocationInputHandler = new BaseInputHandler() {
        @Override
        public void handleMotion(MotionEvent event, Runnable finishedCallback) {
            finishedCallback.run();
            synchronized (mLock) {
                mPointerLocationView.addTouchEvent(event);
            }
        }
    };
    
    // The current size of the screen.
    int mW, mH;
@@ -613,8 +630,26 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            WindowManagerImpl wm = (WindowManagerImpl)
                    mContext.getSystemService(Context.WINDOW_SERVICE);
            wm.addView(addView, lp);
            
            if (mPointerLocationInputChannel == null) {
                try {
                    mPointerLocationInputChannel =
                        mWindowManager.monitorInput("PointerLocationView");
                    InputQueue.registerInputChannel(mPointerLocationInputChannel,
                            mPointerLocationInputHandler, mHandler.getLooper().getQueue());
                } catch (RemoteException ex) {
                    Slog.e(TAG, "Could not set up input monitoring channel for PointerLocation.",
                            ex);
                }
            }
        }
        if (removeView != null) {
            if (mPointerLocationInputChannel != null) {
                InputQueue.unregisterInputChannel(mPointerLocationInputChannel);
                mPointerLocationInputChannel.dispose();
                mPointerLocationInputChannel = null;
            }
            
            WindowManagerImpl wm = (WindowManagerImpl)
                    mContext.getSystemService(Context.WINDOW_SERVICE);
            wm.removeView(removeView);
@@ -728,20 +763,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                : Configuration.KEYBOARDHIDDEN_YES;
    }
    
    public void dispatchedPointerEventLw(MotionEvent ev, int targetX, int targetY) {
        if (mPointerLocationView == null) {
            return;
        }
        synchronized (mLock) {
            if (mPointerLocationView == null) {
                return;
            }
            ev.offsetLocation(targetX, targetY);
            mPointerLocationView.addTouchEvent(ev);
            ev.offsetLocation(-targetX, -targetY);
        }
    }
    
    /** {@inheritDoc} */
    public int windowTypeToLayerLw(int type) {
        if (type >= FIRST_APPLICATION_WINDOW && type <= LAST_APPLICATION_WINDOW) {
Loading