Loading include/input/IInputFlinger.h +5 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,9 @@ public: DECLARE_META_INTERFACE(InputFlinger) virtual void setInputWindows(const Vector<InputWindowInfo>& inputHandles) = 0; virtual void registerInputChannel(const sp<InputChannel>& channel) = 0; virtual void unregisterInputChannel(const sp<InputChannel>& channel) = 0; }; Loading @@ -46,6 +49,8 @@ class BnInputFlinger : public BnInterface<IInputFlinger> { public: enum { SET_INPUT_WINDOWS_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, REGISTER_INPUT_CHANNEL_TRANSACTION, UNREGISTER_INPUT_CHANNEL_TRANSACTION }; virtual status_t onTransact(uint32_t code, const Parcel& data, Loading include/input/Input.h +7 −2 Original line number Diff line number Diff line Loading @@ -244,7 +244,12 @@ struct PointerCoords { float getAxisValue(int32_t axis) const; status_t setAxisValue(int32_t axis, float value); void scale(float scale); void scale(float globalScale); // Scale the pointer coordinates according to a global scale and a // window scale. The global scale will be applied to TOUCH/TOOL_MAJOR/MINOR // axes, however the window scaling will not. void scale(float globalScale, float windowXScale, float windowYScale); void applyOffset(float xOffset, float yOffset); inline float getX() const { Loading Loading @@ -595,7 +600,7 @@ public: void offsetLocation(float xOffset, float yOffset); void scale(float scaleFactor); void scale(float globalScaleFactor); // Apply 3x3 perspective matrix transformation. // Matrix is in row-major form and compatible with SkMatrix. Loading include/input/InputApplication.h +11 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,9 @@ #include <string> #include <binder/IBinder.h> #include <binder/Parcel.h> #include <input/Input.h> #include <utils/RefBase.h> #include <utils/Timers.h> Loading @@ -29,8 +32,12 @@ namespace android { * Describes the properties of an application that can receive input. */ struct InputApplicationInfo { sp<IBinder> token; std::string name; nsecs_t dispatchingTimeout; status_t write(Parcel& output) const; static InputApplicationInfo read(const Parcel& from); }; Loading @@ -54,6 +61,10 @@ public: return mInfo ? mInfo->dispatchingTimeout : defaultValue; } inline sp<IBinder> getApplicationToken() const { return mInfo ? mInfo->token : nullptr; } /** * Requests that the state of this object be updated to reflect * the most current available information about the application. Loading include/input/InputWindow.h +37 −8 Original line number Diff line number Diff line Loading @@ -117,16 +117,41 @@ struct InputWindowInfo { INPUT_FEATURE_DISABLE_USER_ACTIVITY = 0x00000004, }; sp<InputChannel> inputChannel; /* These values are filled in by the WM and passed through SurfaceFlinger * unless specified otherwise. */ sp<IBinder> token; std::string name; int32_t layoutParamsFlags; int32_t layoutParamsType; nsecs_t dispatchingTimeout; /* These values are filled in by SurfaceFlinger. */ int32_t frameLeft; int32_t frameTop; int32_t frameRight; int32_t frameBottom; float scaleFactor; /* * SurfaceFlinger consumes this value to shrink the computed frame. This is * different from shrinking the touchable region in that it DOES shift the coordinate * space where-as the touchable region does not and is more like "cropping". This * is used for window shadows. */ int32_t surfaceInset = 0; // A global scaling factor for all windows. Unlike windowScaleX/Y this results // in scaling of the TOUCH_MAJOR/TOUCH_MINOR axis. float globalScaleFactor; // Scaling factors applied to individual windows. float windowXScale = 1.0f; float windowYScale = 1.0f; /* * This is filled in by the WM relative to the frame and then translated * to absolute coordinates by SurfaceFlinger once the frame is computed. */ Region touchableRegion; bool visible; bool canReceiveKeys; Loading @@ -138,6 +163,7 @@ struct InputWindowInfo { int32_t ownerUid; int32_t inputFeatures; int32_t displayId; InputApplicationInfo applicationInfo; void addTouchableRegion(const Rect& region); Loading Loading @@ -168,20 +194,23 @@ struct InputWindowInfo { */ class InputWindowHandle : public RefBase { public: const sp<InputApplicationHandle> inputApplicationHandle; inline const InputWindowInfo* getInfo() const { return &mInfo; } sp<InputChannel> getInputChannel() const; sp<IBinder> getToken() const; sp<IBinder> getApplicationToken() { return mInfo.applicationInfo.token; } inline std::string getName() const { return mInfo.inputChannel ? mInfo.name : "<invalid>"; return mInfo.token ? mInfo.name : "<invalid>"; } inline nsecs_t getDispatchingTimeout(nsecs_t defaultValue) const { return mInfo.inputChannel? mInfo.dispatchingTimeout : defaultValue; return mInfo.token ? mInfo.dispatchingTimeout : defaultValue; } /** Loading @@ -202,7 +231,7 @@ public: void releaseChannel(); protected: explicit InputWindowHandle(const sp<InputApplicationHandle>& inputApplicationHandle); explicit InputWindowHandle(); virtual ~InputWindowHandle(); InputWindowInfo mInfo; Loading libs/binder/IPCThreadState.cpp +32 −6 Original line number Diff line number Diff line Loading @@ -109,9 +109,7 @@ static const char *kCommandStrings[] = { "BC_DEAD_BINDER_DONE" }; // The work source represents the UID of the process we should attribute the transaction to. // We use -1 to specify that the work source was not set using #setWorkSource. static const int kUnsetWorkSource = -1; static const int64_t kWorkSourcePropagatedBitIndex = 32; static const char* getReturnString(uint32_t cmd) { Loading Loading @@ -389,12 +387,29 @@ int32_t IPCThreadState::getStrictModePolicy() const int64_t IPCThreadState::setCallingWorkSourceUid(uid_t uid) { // Note: we currently only use half of the int64. We return an int64 for extensibility. int64_t token = mWorkSource; int64_t token = setCallingWorkSourceUidWithoutPropagation(uid); mPropagateWorkSource = true; return token; } int64_t IPCThreadState::setCallingWorkSourceUidWithoutPropagation(uid_t uid) { const int64_t propagatedBit = ((int64_t)mPropagateWorkSource) << kWorkSourcePropagatedBitIndex; int64_t token = propagatedBit | mWorkSource; mWorkSource = uid; return token; } void IPCThreadState::clearPropagateWorkSource() { mPropagateWorkSource = false; } bool IPCThreadState::shouldPropagateWorkSource() const { return mPropagateWorkSource; } uid_t IPCThreadState::getCallingWorkSourceUid() const { return mWorkSource; Loading @@ -408,7 +423,8 @@ int64_t IPCThreadState::clearCallingWorkSource() void IPCThreadState::restoreCallingWorkSource(int64_t token) { uid_t uid = (int)token; setCallingWorkSourceUid(uid); setCallingWorkSourceUidWithoutPropagation(uid); mPropagateWorkSource = ((token >> kWorkSourcePropagatedBitIndex) & 1) == 1; } void IPCThreadState::setLastTransactionBinderFlags(int32_t flags) Loading Loading @@ -765,6 +781,7 @@ status_t IPCThreadState::clearDeathNotification(int32_t handle, BpBinder* proxy) IPCThreadState::IPCThreadState() : mProcess(ProcessState::self()), mWorkSource(kUnsetWorkSource), mPropagateWorkSource(false), mStrictModePolicy(0), mLastTransactionBinderFlags(0) { Loading Loading @@ -1127,6 +1144,13 @@ status_t IPCThreadState::executeCommand(int32_t cmd) const uid_t origUid = mCallingUid; const int32_t origStrictModePolicy = mStrictModePolicy; const int32_t origTransactionBinderFlags = mLastTransactionBinderFlags; const int32_t origWorkSource = mWorkSource; const bool origPropagateWorkSet = mPropagateWorkSource; // Calling work source will be set by Parcel#enforceInterface. Parcel#enforceInterface // is only guaranteed to be called for AIDL-generated stubs so we reset the work source // here to never propagate it. clearCallingWorkSource(); clearPropagateWorkSource(); mCallingPid = tr.sender_pid; mCallingUid = tr.sender_euid; Loading Loading @@ -1179,6 +1203,8 @@ status_t IPCThreadState::executeCommand(int32_t cmd) mCallingUid = origUid; mStrictModePolicy = origStrictModePolicy; mLastTransactionBinderFlags = origTransactionBinderFlags; mWorkSource = origWorkSource; mPropagateWorkSource = origPropagateWorkSet; IF_LOG_TRANSACTIONS() { TextOutput::Bundle _b(alog); Loading Loading
include/input/IInputFlinger.h +5 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,9 @@ public: DECLARE_META_INTERFACE(InputFlinger) virtual void setInputWindows(const Vector<InputWindowInfo>& inputHandles) = 0; virtual void registerInputChannel(const sp<InputChannel>& channel) = 0; virtual void unregisterInputChannel(const sp<InputChannel>& channel) = 0; }; Loading @@ -46,6 +49,8 @@ class BnInputFlinger : public BnInterface<IInputFlinger> { public: enum { SET_INPUT_WINDOWS_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, REGISTER_INPUT_CHANNEL_TRANSACTION, UNREGISTER_INPUT_CHANNEL_TRANSACTION }; virtual status_t onTransact(uint32_t code, const Parcel& data, Loading
include/input/Input.h +7 −2 Original line number Diff line number Diff line Loading @@ -244,7 +244,12 @@ struct PointerCoords { float getAxisValue(int32_t axis) const; status_t setAxisValue(int32_t axis, float value); void scale(float scale); void scale(float globalScale); // Scale the pointer coordinates according to a global scale and a // window scale. The global scale will be applied to TOUCH/TOOL_MAJOR/MINOR // axes, however the window scaling will not. void scale(float globalScale, float windowXScale, float windowYScale); void applyOffset(float xOffset, float yOffset); inline float getX() const { Loading Loading @@ -595,7 +600,7 @@ public: void offsetLocation(float xOffset, float yOffset); void scale(float scaleFactor); void scale(float globalScaleFactor); // Apply 3x3 perspective matrix transformation. // Matrix is in row-major form and compatible with SkMatrix. Loading
include/input/InputApplication.h +11 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,9 @@ #include <string> #include <binder/IBinder.h> #include <binder/Parcel.h> #include <input/Input.h> #include <utils/RefBase.h> #include <utils/Timers.h> Loading @@ -29,8 +32,12 @@ namespace android { * Describes the properties of an application that can receive input. */ struct InputApplicationInfo { sp<IBinder> token; std::string name; nsecs_t dispatchingTimeout; status_t write(Parcel& output) const; static InputApplicationInfo read(const Parcel& from); }; Loading @@ -54,6 +61,10 @@ public: return mInfo ? mInfo->dispatchingTimeout : defaultValue; } inline sp<IBinder> getApplicationToken() const { return mInfo ? mInfo->token : nullptr; } /** * Requests that the state of this object be updated to reflect * the most current available information about the application. Loading
include/input/InputWindow.h +37 −8 Original line number Diff line number Diff line Loading @@ -117,16 +117,41 @@ struct InputWindowInfo { INPUT_FEATURE_DISABLE_USER_ACTIVITY = 0x00000004, }; sp<InputChannel> inputChannel; /* These values are filled in by the WM and passed through SurfaceFlinger * unless specified otherwise. */ sp<IBinder> token; std::string name; int32_t layoutParamsFlags; int32_t layoutParamsType; nsecs_t dispatchingTimeout; /* These values are filled in by SurfaceFlinger. */ int32_t frameLeft; int32_t frameTop; int32_t frameRight; int32_t frameBottom; float scaleFactor; /* * SurfaceFlinger consumes this value to shrink the computed frame. This is * different from shrinking the touchable region in that it DOES shift the coordinate * space where-as the touchable region does not and is more like "cropping". This * is used for window shadows. */ int32_t surfaceInset = 0; // A global scaling factor for all windows. Unlike windowScaleX/Y this results // in scaling of the TOUCH_MAJOR/TOUCH_MINOR axis. float globalScaleFactor; // Scaling factors applied to individual windows. float windowXScale = 1.0f; float windowYScale = 1.0f; /* * This is filled in by the WM relative to the frame and then translated * to absolute coordinates by SurfaceFlinger once the frame is computed. */ Region touchableRegion; bool visible; bool canReceiveKeys; Loading @@ -138,6 +163,7 @@ struct InputWindowInfo { int32_t ownerUid; int32_t inputFeatures; int32_t displayId; InputApplicationInfo applicationInfo; void addTouchableRegion(const Rect& region); Loading Loading @@ -168,20 +194,23 @@ struct InputWindowInfo { */ class InputWindowHandle : public RefBase { public: const sp<InputApplicationHandle> inputApplicationHandle; inline const InputWindowInfo* getInfo() const { return &mInfo; } sp<InputChannel> getInputChannel() const; sp<IBinder> getToken() const; sp<IBinder> getApplicationToken() { return mInfo.applicationInfo.token; } inline std::string getName() const { return mInfo.inputChannel ? mInfo.name : "<invalid>"; return mInfo.token ? mInfo.name : "<invalid>"; } inline nsecs_t getDispatchingTimeout(nsecs_t defaultValue) const { return mInfo.inputChannel? mInfo.dispatchingTimeout : defaultValue; return mInfo.token ? mInfo.dispatchingTimeout : defaultValue; } /** Loading @@ -202,7 +231,7 @@ public: void releaseChannel(); protected: explicit InputWindowHandle(const sp<InputApplicationHandle>& inputApplicationHandle); explicit InputWindowHandle(); virtual ~InputWindowHandle(); InputWindowInfo mInfo; Loading
libs/binder/IPCThreadState.cpp +32 −6 Original line number Diff line number Diff line Loading @@ -109,9 +109,7 @@ static const char *kCommandStrings[] = { "BC_DEAD_BINDER_DONE" }; // The work source represents the UID of the process we should attribute the transaction to. // We use -1 to specify that the work source was not set using #setWorkSource. static const int kUnsetWorkSource = -1; static const int64_t kWorkSourcePropagatedBitIndex = 32; static const char* getReturnString(uint32_t cmd) { Loading Loading @@ -389,12 +387,29 @@ int32_t IPCThreadState::getStrictModePolicy() const int64_t IPCThreadState::setCallingWorkSourceUid(uid_t uid) { // Note: we currently only use half of the int64. We return an int64 for extensibility. int64_t token = mWorkSource; int64_t token = setCallingWorkSourceUidWithoutPropagation(uid); mPropagateWorkSource = true; return token; } int64_t IPCThreadState::setCallingWorkSourceUidWithoutPropagation(uid_t uid) { const int64_t propagatedBit = ((int64_t)mPropagateWorkSource) << kWorkSourcePropagatedBitIndex; int64_t token = propagatedBit | mWorkSource; mWorkSource = uid; return token; } void IPCThreadState::clearPropagateWorkSource() { mPropagateWorkSource = false; } bool IPCThreadState::shouldPropagateWorkSource() const { return mPropagateWorkSource; } uid_t IPCThreadState::getCallingWorkSourceUid() const { return mWorkSource; Loading @@ -408,7 +423,8 @@ int64_t IPCThreadState::clearCallingWorkSource() void IPCThreadState::restoreCallingWorkSource(int64_t token) { uid_t uid = (int)token; setCallingWorkSourceUid(uid); setCallingWorkSourceUidWithoutPropagation(uid); mPropagateWorkSource = ((token >> kWorkSourcePropagatedBitIndex) & 1) == 1; } void IPCThreadState::setLastTransactionBinderFlags(int32_t flags) Loading Loading @@ -765,6 +781,7 @@ status_t IPCThreadState::clearDeathNotification(int32_t handle, BpBinder* proxy) IPCThreadState::IPCThreadState() : mProcess(ProcessState::self()), mWorkSource(kUnsetWorkSource), mPropagateWorkSource(false), mStrictModePolicy(0), mLastTransactionBinderFlags(0) { Loading Loading @@ -1127,6 +1144,13 @@ status_t IPCThreadState::executeCommand(int32_t cmd) const uid_t origUid = mCallingUid; const int32_t origStrictModePolicy = mStrictModePolicy; const int32_t origTransactionBinderFlags = mLastTransactionBinderFlags; const int32_t origWorkSource = mWorkSource; const bool origPropagateWorkSet = mPropagateWorkSource; // Calling work source will be set by Parcel#enforceInterface. Parcel#enforceInterface // is only guaranteed to be called for AIDL-generated stubs so we reset the work source // here to never propagate it. clearCallingWorkSource(); clearPropagateWorkSource(); mCallingPid = tr.sender_pid; mCallingUid = tr.sender_euid; Loading Loading @@ -1179,6 +1203,8 @@ status_t IPCThreadState::executeCommand(int32_t cmd) mCallingUid = origUid; mStrictModePolicy = origStrictModePolicy; mLastTransactionBinderFlags = origTransactionBinderFlags; mWorkSource = origWorkSource; mPropagateWorkSource = origPropagateWorkSet; IF_LOG_TRANSACTIONS() { TextOutput::Bundle _b(alog); Loading