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

Commit 93ccdae2 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou Committed by Android (Google) Code Review
Browse files

Merge changes from topic "presubmit-am-c81762ef3b084d75afdf183d012bec54" into tm-dev

* changes:
  Add PreferStylusOverTouchBlocker and handle multiple devices
  Remove PreferStylusOverTouchBlocker
  Block touches when stylus is down
parents f64f13e0 814ace3f
Loading
Loading
Loading
Loading
+61 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once

#include <map>
#include <set>
#include <string>

namespace android {

template <typename T>
std::string constToString(const T& v) {
    return std::to_string(v);
}

/**
 * Convert a set of integral types to string.
 */
template <typename T>
std::string dumpSet(const std::set<T>& v, std::string (*toString)(const T&) = constToString) {
    std::string out;
    for (const T& entry : v) {
        out += out.empty() ? "{" : ", ";
        out += toString(entry);
    }
    return out.empty() ? "{}" : (out + "}");
}

/**
 * Convert a map to string. Both keys and values of the map should be integral type.
 */
template <typename K, typename V>
std::string dumpMap(const std::map<K, V>& map, std::string (*keyToString)(const K&) = constToString,
                    std::string (*valueToString)(const V&) = constToString) {
    std::string out;
    for (const auto& [k, v] : map) {
        if (!out.empty()) {
            out += "\n";
        }
        out += keyToString(k) + ":" + valueToString(v);
    }
    return out;
}

const char* toString(bool value);

} // namespace android
 No newline at end of file
+4 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ cc_library {
        "Keyboard.cpp",
        "KeyCharacterMap.cpp",
        "KeyLayoutMap.cpp",
        "PrintTools.cpp",
        "PropertyMap.cpp",
        "TouchVideoFrame.cpp",
        "VelocityControl.cpp",
@@ -102,6 +103,9 @@ cc_library {

            sanitize: {
                misc_undefined: ["integer"],
                diag: {
                    misc_undefined: ["integer"],
                },
            },
        },
        host: {
+27 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#define LOG_TAG "PrintTools"

#include <input/PrintTools.h>

namespace android {

const char* toString(bool value) {
    return value ? "true" : "false";
}

} // namespace android
+1 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ filegroup {
    srcs: [
        "InputClassifier.cpp",
        "InputCommonConverter.cpp",
        "PreferStylusOverTouchBlocker.cpp",
        "UnwantedInteractionBlocker.cpp",
        "InputManager.cpp",
    ],
+4 −2
Original line number Diff line number Diff line
@@ -202,9 +202,11 @@ std::string NotifyMotionArgs::dump() const {
        coords += "}";
    }
    return StringPrintf("NotifyMotionArgs(id=%" PRId32 ", eventTime=%" PRId64 ", deviceId=%" PRId32
                        ", source=%s, action=%s, pointerCount=%" PRIu32 " pointers=%s)",
                        ", source=%s, action=%s, pointerCount=%" PRIu32
                        " pointers=%s, flags=0x%08x)",
                        id, eventTime, deviceId, inputEventSourceToString(source).c_str(),
                        MotionEvent::actionToString(action).c_str(), pointerCount, coords.c_str());
                        MotionEvent::actionToString(action).c_str(), pointerCount, coords.c_str(),
                        flags);
}

void NotifyMotionArgs::notify(InputListenerInterface& listener) const {
Loading