Use unique_ptr for InputChannel
We are switching openInputChannelPair to return unique_ptr.
Bug: 142581626
Test: atest Poc19_03
Change-Id: I982208cc4e39f3aa288b2babcb2d0bff51b7db09
diff --git a/hostsidetests/securitybulletin/securityPatch/Bug-115739809/poc.cpp b/hostsidetests/securitybulletin/securityPatch/Bug-115739809/poc.cpp
index e53a7fa..c22fefc 100755
--- a/hostsidetests/securitybulletin/securityPatch/Bug-115739809/poc.cpp
+++ b/hostsidetests/securitybulletin/securityPatch/Bug-115739809/poc.cpp
@@ -161,8 +161,7 @@
/**
* Return false if vulnerability is found for a given message type
*/
-static bool checkMessage(std::shared_ptr<InputChannel> server, std::shared_ptr<InputChannel> client,
- InputMessage::Type type) {
+static bool checkMessage(InputChannel& server, InputChannel& client, InputMessage::Type type) {
InputMessage serverMsg;
// Set all potentially uninitialized bytes to 1, for easier comparison
@@ -171,14 +170,14 @@
if (type == InputMessage::Type::MOTION) {
serverMsg.body.motion.pointerCount = MAX_POINTERS;
}
- status_t result = server->sendMessage(&serverMsg);
+ status_t result = server.sendMessage(&serverMsg);
if (result != OK) {
ALOGE("Could not send message to the input channel");
return false;
}
InputMessage clientMsg;
- result = client->receiveMessage(&clientMsg);
+ result = client.receiveMessage(&clientMsg);
if (result != OK) {
ALOGE("Could not receive message from the input channel");
return false;
@@ -214,7 +213,7 @@
* Do this for all message types
*/
int main() {
- std::shared_ptr<InputChannel> server, client;
+ std::unique_ptr<InputChannel> server, client;
status_t result = InputChannel::openInputChannelPair("channel name", server, client);
if (result != OK) {
@@ -229,7 +228,7 @@
InputMessage::Type::FOCUS,
};
for (InputMessage::Type type : types) {
- bool success = checkMessage(server, client, type);
+ bool success = checkMessage(*server, *client, type);
if (!success) {
ALOGE("Check message failed for type %i", type);
return EXIT_VULNERABLE;