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

Commit d399a528 authored by Ashwini Oruganti's avatar Ashwini Oruganti
Browse files

Don't leak input events to dumpsys on user builds

Add a check for ro.debuggable in before adding the details of KeyEvent and MotionEvent to logs.

Bug: 139945049
Test: Tested on a device, the input functions work as expected and input
event logs are not leaked to dumpsys on user builds.

Change-Id: I98c9c375f18963177bf0c1d8829a217b4ad4acc6
parent e676761d
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -18,10 +18,12 @@

#include "Connection.h"

#include <android-base/properties.h>
#include <android-base/stringprintf.h>
#include <cutils/atomic.h>
#include <inttypes.h>

using android::base::GetBoolProperty;
using android::base::StringPrintf;

namespace android::inputdispatcher {
@@ -133,7 +135,11 @@ KeyEntry::KeyEntry(uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId, ui
KeyEntry::~KeyEntry() {}

void KeyEntry::appendDescription(std::string& msg) const {
    msg += StringPrintf("KeyEvent(deviceId=%d, source=0x%08x, displayId=%" PRId32 ", action=%s, "
    msg += StringPrintf("KeyEvent");
    if (!GetBoolProperty("ro.debuggable", false)) {
        return;
    }
    msg += StringPrintf("(deviceId=%d, source=0x%08x, displayId=%" PRId32 ", action=%s, "
                        "flags=0x%08x, keyCode=%d, scanCode=%d, metaState=0x%08x, "
                        "repeatCount=%d), policyFlags=0x%08x",
                        deviceId, source, displayId, keyActionToString(action).c_str(), flags,
@@ -189,7 +195,11 @@ MotionEntry::MotionEntry(uint32_t sequenceNum, nsecs_t eventTime, int32_t device
MotionEntry::~MotionEntry() {}

void MotionEntry::appendDescription(std::string& msg) const {
    msg += StringPrintf("MotionEvent(deviceId=%d, source=0x%08x, displayId=%" PRId32
    msg += StringPrintf("MotionEvent");
    if (!GetBoolProperty("ro.debuggable", false)) {
        return;
    }
    msg += StringPrintf("(deviceId=%d, source=0x%08x, displayId=%" PRId32
                        ", action=%s, actionButton=0x%08x, flags=0x%08x, metaState=0x%08x, "
                        "buttonState=0x%08x, "
                        "classification=%s, edgeFlags=0x%08x, xPrecision=%.1f, yPrecision=%.1f, "