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

Commit ec8f725b authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Prefer std::string over String8

String8 is deprecated, so use proper C++ std::string instead.
Change DisplayViewport.uniqueId to std::string.
The current usage of String8 in
DisplayViewport hinders refactoring of the code to use viewport types
inside the viewports themselves.
Most of the dependency on String8 is now removed. Once the xml for
properties patch is added, almost all String8 should be gone from the
input system.

Test: atest libinput_tests inputflinger_tests
Bug: 111108021
Change-Id: I580dc27b0449e664a7c9db2cdec1a0c18bf71a09
parent 24d971f4
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -39,13 +39,13 @@ struct DisplayViewport {
    int32_t physicalBottom;
    int32_t deviceWidth;
    int32_t deviceHeight;
    String8 uniqueId;
    std::string uniqueId;

    DisplayViewport() :
            displayId(ADISPLAY_ID_NONE), orientation(DISPLAY_ORIENTATION_0),
            logicalLeft(0), logicalTop(0), logicalRight(0), logicalBottom(0),
            physicalLeft(0), physicalTop(0), physicalRight(0), physicalBottom(0),
            deviceWidth(0), deviceHeight(0) {
            deviceWidth(0), deviceHeight(0), uniqueId() {
    }

    bool operator==(const DisplayViewport& other) const {
+0 −1
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@
#include <utils/BitSet.h>
#include <utils/KeyedVector.h>
#include <utils/RefBase.h>
#include <utils/String8.h>
#include <utils/Timers.h>
#include <utils/Vector.h>
#include <stdint.h>
+12 −12
Original line number Diff line number Diff line
@@ -31,9 +31,9 @@ struct InputDeviceIdentifier {
    }

    // Information provided by the kernel.
    String8 name;
    String8 location;
    String8 uniqueId;
    std::string name;
    std::string location;
    std::string uniqueId;
    uint16_t bus;
    uint16_t vendor;
    uint16_t product;
@@ -45,7 +45,7 @@ struct InputDeviceIdentifier {
    // It is hashed from whatever kernel provided information is available.
    // Ideally, the way this value is computed should not change between Android releases
    // because that would invalidate persistent settings that rely on it.
    String8 descriptor;
    std::string descriptor;

    // A value added to uniquely identify a device in the absence of a unique id. This
    // is intended to be a minimum way to distinguish from other active devices and may
@@ -73,16 +73,16 @@ public:
    };

    void initialize(int32_t id, int32_t generation, int32_t controllerNumber,
            const InputDeviceIdentifier& identifier, const String8& alias, bool isExternal,
            const InputDeviceIdentifier& identifier, const std::string& alias, bool isExternal,
            bool hasMic);

    inline int32_t getId() const { return mId; }
    inline int32_t getControllerNumber() const { return mControllerNumber; }
    inline int32_t getGeneration() const { return mGeneration; }
    inline const InputDeviceIdentifier& getIdentifier() const { return mIdentifier; }
    inline const String8& getAlias() const { return mAlias; }
    inline const String8& getDisplayName() const {
        return mAlias.isEmpty() ? mIdentifier.name : mAlias;
    inline const std::string& getAlias() const { return mAlias; }
    inline const std::string& getDisplayName() const {
        return mAlias.empty() ? mIdentifier.name : mAlias;
    }
    inline bool isExternal() const { return mIsExternal; }
    inline bool hasMic() const { return mHasMic; }
@@ -121,7 +121,7 @@ private:
    int32_t mGeneration;
    int32_t mControllerNumber;
    InputDeviceIdentifier mIdentifier;
    String8 mAlias;
    std::string mAlias;
    bool mIsExternal;
    bool mHasMic;
    uint32_t mSources;
@@ -149,7 +149,7 @@ enum InputDeviceConfigurationFileType {
 *
 * Returns an empty string if not found.
 */
extern String8 getInputDeviceConfigurationFilePathByDeviceIdentifier(
extern std::string getInputDeviceConfigurationFilePathByDeviceIdentifier(
        const InputDeviceIdentifier& deviceIdentifier,
        InputDeviceConfigurationFileType type);

@@ -162,8 +162,8 @@ extern String8 getInputDeviceConfigurationFilePathByDeviceIdentifier(
 *
 * Returns an empty string if not found.
 */
extern String8 getInputDeviceConfigurationFilePathByName(
        const String8& name, InputDeviceConfigurationFileType type);
extern std::string getInputDeviceConfigurationFilePathByName(
        const std::string& name, InputDeviceConfigurationFileType type);

} // namespace android

+2 −0
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@
 * The InputConsumer is used by the application to receive events from the input dispatcher.
 */

#include <string>

#include <input/Input.h>
#include <utils/Errors.h>
#include <utils/Timers.h>
+3 −4
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@
#include <utils/Errors.h>
#include <utils/KeyedVector.h>
#include <utils/Tokenizer.h>
#include <utils/String8.h>
#include <utils/Unicode.h>
#include <utils/RefBase.h>

@@ -75,10 +74,10 @@ public:
    };

    /* Loads a key character map from a file. */
    static status_t load(const String8& filename, Format format, sp<KeyCharacterMap>* outMap);
    static status_t load(const std::string& filename, Format format, sp<KeyCharacterMap>* outMap);

    /* Loads a key character map from its string contents. */
    static status_t loadContents(const String8& filename,
    static status_t loadContents(const std::string& filename,
            const char* contents, Format format, sp<KeyCharacterMap>* outMap);

    /* Combines a base key character map and an overlay. */
@@ -221,7 +220,7 @@ private:
        status_t parseKey();
        status_t parseKeyProperty();
        status_t finishKey(Key* key);
        status_t parseModifier(const String8& token, int32_t* outMetaState);
        status_t parseModifier(const std::string& token, int32_t* outMetaState);
        status_t parseCharacterLiteral(char16_t* outCharacter);
    };

Loading