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

Commit e3e2883f authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android Git Automerger
Browse files

am e24a60aa: Merge "First stab at attaching native event dispatching." into gingerbread

Merge commit 'e24a60aa' into gingerbread-plus-aosp

* commit 'e24a60aa':
  First stab at attaching native event dispatching.
parents ca36e9ee e24a60aa
Loading
Loading
Loading
Loading
+84 −0
Original line number Diff line number Diff line
@@ -26306,6 +26306,8 @@
 deprecated="not deprecated"
 visibility="public"
>
<implements name="android.view.InputConsumer.Callback">
</implements>
<implements name="android.view.SurfaceHolder.Callback">
</implements>
<constructor name="NativeActivity"
@@ -26316,6 +26318,32 @@
 visibility="public"
>
</constructor>
<method name="onInputConsumerCreated"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="consumer" type="android.view.InputConsumer">
</parameter>
</method>
<method name="onInputConsumerDestroyed"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="consumer" type="android.view.InputConsumer">
</parameter>
</method>
<method name="surfaceChanged"
 return="void"
 abstract="false"
@@ -172813,6 +172841,49 @@
</parameter>
</constructor>
</class>
<class name="InputConsumer"
 extends="java.lang.Object"
 abstract="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</class>
<interface name="InputConsumer.Callback"
 abstract="true"
 static="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<method name="onInputConsumerCreated"
 return="void"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="consumer" type="android.view.InputConsumer">
</parameter>
</method>
<method name="onInputConsumerDestroyed"
 return="void"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="consumer" type="android.view.InputConsumer">
</parameter>
</method>
</interface>
<class name="KeyCharacterMap"
 extends="java.lang.Object"
 abstract="false"
@@ -187266,6 +187337,19 @@
<parameter name="event" type="android.view.MotionEvent">
</parameter>
</method>
<method name="takeInputChannel"
 return="void"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="callback" type="android.view.InputConsumer.Callback">
</parameter>
</method>
<method name="takeKeyEvents"
 return="void"
 abstract="true"
+15 −1
Original line number Diff line number Diff line
@@ -6,6 +6,8 @@ import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.InputChannel;
import android.view.InputConsumer;
import android.view.SurfaceHolder;

import java.io.File;
@@ -14,7 +16,8 @@ import java.io.File;
 * Convenience for implementing an activity that will be implemented
 * purely in native code.  That is, a game (or game-like thing).
 */
public class NativeActivity extends Activity implements SurfaceHolder.Callback {
public class NativeActivity extends Activity implements SurfaceHolder.Callback,
        InputConsumer.Callback {
    public static final String META_DATA_LIB_NAME = "android.app.lib_name";
    
    private int mNativeHandle;
@@ -33,6 +36,8 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback {
    private native void onSurfaceChangedNative(int handle, SurfaceHolder holder,
            int format, int width, int height);
    private native void onSurfaceDestroyedNative(int handle, SurfaceHolder holder);
    private native void onInputChannelCreatedNative(int handle, InputChannel channel);
    private native void onInputChannelDestroyedNative(int handle, InputChannel channel);
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
@@ -40,6 +45,7 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback {
        ActivityInfo ai;
        
        getWindow().takeSurface(this);
        getWindow().takeInputChannel(this);
        
        try {
            ai = getPackageManager().getActivityInfo(
@@ -138,4 +144,12 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback {
    public void surfaceDestroyed(SurfaceHolder holder) {
        onSurfaceDestroyedNative(mNativeHandle, holder);
    }
    
    public void onInputConsumerCreated(InputConsumer consumer) {
        onInputChannelCreatedNative(mNativeHandle, consumer.getInputChannel());
    }
    
    public void onInputConsumerDestroyed(InputConsumer consumer) {
        onInputChannelDestroyedNative(mNativeHandle, consumer.getInputChannel());
    }
}
+3 −2
Original line number Diff line number Diff line
@@ -22,8 +22,9 @@ import android.util.Slog;

/**
 * An input channel specifies the file descriptors used to send input events to
 * a window in another process.  It is Parcelable so that it can be transmitted
 * to the ViewRoot through a Binder transaction as part of registering the Window.
 * a window in another process.  It is Parcelable so that it can be sent
 * to the process that is to receive events.  Only one thread should be reading
 * from an InputChannel at a time.
 * @hide
 */
public final class InputChannel implements Parcelable {
+39 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2010 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;

/**
 * Handle for consuming raw input events.
 */
public class InputConsumer {
    public static interface Callback {
        void onInputConsumerCreated(InputConsumer consumer);
        void onInputConsumerDestroyed(InputConsumer consumer);
    }

    final InputChannel mChannel;
    
    /** @hide */
    public InputConsumer(InputChannel channel) {
        mChannel = channel;
    }
    
    /** @hide */
    public InputChannel getInputChannel() {
        return mChannel;
    }
}
+20 −4
Original line number Diff line number Diff line
@@ -154,6 +154,8 @@ public final class ViewRoot extends Handler implements ViewParent,

    final View.AttachInfo mAttachInfo;
    InputChannel mInputChannel;
    InputConsumer.Callback mInputConsumerCallback;
    InputConsumer mInputConsumer;
    
    final Rect mTempRect; // used in the transaction to not thrash the heap.
    final Rect mVisRect; // used to retrieve visible rect of focused view.
@@ -555,9 +557,18 @@ public final class ViewRoot extends Handler implements ViewParent,
                }

                if (WindowManagerPolicy.ENABLE_NATIVE_INPUT_DISPATCH) {
                    if (view instanceof RootViewSurfaceTaker) {
                        mInputConsumerCallback =
                            ((RootViewSurfaceTaker)view).willYouTakeTheInputConsumer();
                    }
                    if (mInputConsumerCallback != null) {
                        mInputConsumer = new InputConsumer(mInputChannel);
                        mInputConsumerCallback.onInputConsumerCreated(mInputConsumer);
                    } else {
                        InputQueue.registerInputChannel(mInputChannel, mInputHandler,
                                Looper.myQueue());
                    }
                }
                
                view.assignParent(this);
                mAddedTouchMode = (res&WindowManagerImpl.ADD_FLAG_IN_TOUCH_MODE) != 0;
@@ -1736,7 +1747,12 @@ public final class ViewRoot extends Handler implements ViewParent,

        if (WindowManagerPolicy.ENABLE_NATIVE_INPUT_DISPATCH) {
            if (mInputChannel != null) {
                if (mInputConsumerCallback != null) {
                    mInputConsumerCallback.onInputConsumerDestroyed(mInputConsumer);
                    mInputConsumerCallback = null;
                } else {
                    InputQueue.unregisterInputChannel(mInputChannel);
                }
                mInputChannel.dispose();
                mInputChannel = null;
            }
Loading