Use enum class for InputMessage type
InputMessage type was converted to enum class. Update the usage here.
Bug: 70668286
Test: atest Poc19_03
Change-Id: Ib821647e62f7cce82303e1ae4dfd2148240b56ea
diff --git a/hostsidetests/securitybulletin/securityPatch/Bug-115739809/poc.cpp b/hostsidetests/securitybulletin/securityPatch/Bug-115739809/poc.cpp
index 73251cd..d98dc19 100755
--- a/hostsidetests/securitybulletin/securityPatch/Bug-115739809/poc.cpp
+++ b/hostsidetests/securitybulletin/securityPatch/Bug-115739809/poc.cpp
@@ -46,7 +46,7 @@
// Write the body
switch(msg.header.type) {
- case InputMessage::TYPE_KEY: {
+ case InputMessage::Type::KEY: {
// uint32_t seq
outMsg->body.key.seq = msg.body.key.seq;
// nsecs_t eventTime
@@ -73,7 +73,7 @@
outMsg->body.key.downTime = msg.body.key.downTime;
break;
}
- case InputMessage::TYPE_MOTION: {
+ case InputMessage::Type::MOTION: {
// uint32_t seq
outMsg->body.motion.seq = msg.body.motion.seq;
// nsecs_t eventTime
@@ -131,7 +131,7 @@
}
break;
}
- case InputMessage::TYPE_FINISHED: {
+ case InputMessage::Type::FINISHED: {
outMsg->body.finished.seq = msg.body.finished.seq;
outMsg->body.finished.handled = msg.body.finished.handled;
break;
@@ -142,13 +142,13 @@
/**
* Return false if vulnerability is found for a given message type
*/
-static bool checkMessage(sp<InputChannel> server, sp<InputChannel> client, int type) {
+static bool checkMessage(sp<InputChannel> server, sp<InputChannel> client, InputMessage::Type type) {
InputMessage serverMsg;
// Set all potentially uninitialized bytes to 1, for easier comparison
memset(&serverMsg, 1, sizeof(serverMsg));
serverMsg.header.type = type;
- if (type == InputMessage::TYPE_MOTION) {
+ if (type == InputMessage::Type::MOTION) {
serverMsg.body.motion.pointerCount = MAX_POINTERS;
}
status_t result = server->sendMessage(&serverMsg);
@@ -202,8 +202,12 @@
return 0;
}
- int types[] = {InputMessage::TYPE_KEY, InputMessage::TYPE_MOTION, InputMessage::TYPE_FINISHED};
- for (int type : types) {
+ InputMessage::Type types[] = {
+ InputMessage::Type::KEY,
+ InputMessage::Type::MOTION,
+ InputMessage::Type::FINISHED
+ };
+ for (InputMessage::Type type : types) {
bool success = checkMessage(server, client, type);
if (!success) {
ALOGE("Check message failed for type %i", type);