Rework InputApplicationInfo
First we move it inside of InputWindowInfo instead of InputWindowHandle
so it is part of the data sent across binder. Second we give it a persistent
identity of an IBinder token and use this for comparisons.
Bug: 80101428
Bug: 113136004
Bug: 111440400
Test: EndToEndNativeInputTest. Existing tests pass.
Change-Id: Id89a40e66887d834020f8e645fd1fb48adb7ee2e
diff --git a/include/input/InputApplication.h b/include/input/InputApplication.h
index 9b365b9..71a8f20 100644
--- a/include/input/InputApplication.h
+++ b/include/input/InputApplication.h
@@ -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>
@@ -29,8 +32,12 @@
* 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);
};
@@ -54,6 +61,10 @@
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.
diff --git a/include/input/InputWindow.h b/include/input/InputWindow.h
index 6164aa6..1a46825 100644
--- a/include/input/InputWindow.h
+++ b/include/input/InputWindow.h
@@ -138,6 +138,7 @@
int32_t ownerUid;
int32_t inputFeatures;
int32_t displayId;
+ InputApplicationInfo applicationInfo;
void addTouchableRegion(const Rect& region);
@@ -168,7 +169,6 @@
*/
class InputWindowHandle : public RefBase {
public:
- const sp<InputApplicationHandle> inputApplicationHandle;
inline const InputWindowInfo* getInfo() const {
return &mInfo;
@@ -176,6 +176,10 @@
sp<IBinder> getToken() const;
+ sp<IBinder> getApplicationToken() {
+ return mInfo.applicationInfo.token;
+ }
+
inline std::string getName() const {
return mInfo.token ? mInfo.name : "<invalid>";
}
@@ -202,7 +206,7 @@
void releaseChannel();
protected:
- explicit InputWindowHandle(const sp<InputApplicationHandle>& inputApplicationHandle);
+ explicit InputWindowHandle();
virtual ~InputWindowHandle();
InputWindowInfo mInfo;