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

Commit 63eab596 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8572535 from ceb84d05 to tm-release

Change-Id: I096a3c47c55ddbd0e8d3964f887977d80fd2ce6c
parents 7305dc4f ceb84d05
Loading
Loading
Loading
Loading
+28 −2
Original line number Diff line number Diff line
@@ -1957,17 +1957,43 @@ binder::Status InstalldNativeService::freeCache(const std::optional<std::string>
#endif // GRANULAR_LOCKS
            FTS *fts;
            FTSENT *p;

            // Create a list of data paths whose children have cache directories
            auto ce_path = create_data_user_ce_path(uuid_, userId);
            auto de_path = create_data_user_de_path(uuid_, userId);
            auto media_path = findDataMediaPath(uuid, userId) + "/Android/data/";
            char *argv[] = { (char*) ce_path.c_str(), (char*) de_path.c_str(),
                    (char*) media_path.c_str(), nullptr };
            auto ce_sdk_path = create_data_misc_sdk_sandbox_path(uuid_, /*isCeData=*/true, userId);
            auto de_sdk_path = create_data_misc_sdk_sandbox_path(uuid_, /*isCeData=*/false, userId);

            std::vector<std::string> dataPaths = {ce_path, de_path, media_path};
            foreach_subdir(ce_sdk_path, [&ce_sdk_path, &dataPaths](const std::string subDir) {
                const auto fullpath = ce_sdk_path + "/" + subDir;
                dataPaths.push_back(fullpath);
            });
            foreach_subdir(de_sdk_path, [&de_sdk_path, &dataPaths](const std::string subDir) {
                const auto fullpath = de_sdk_path + "/" + subDir;
                dataPaths.push_back((char*)fullpath.c_str());
            });

            char* argv[dataPaths.size() + 1];
            for (unsigned int i = 0; i < dataPaths.size(); i++) {
                argv[i] = (char*)dataPaths[i].c_str();
            }
            argv[dataPaths.size()] = nullptr;

            if (!(fts = fts_open(argv, FTS_PHYSICAL | FTS_NOCHDIR | FTS_XDEV, nullptr))) {
                return error("Failed to fts_open");
            }
            while ((p = fts_read(fts)) != nullptr) {
                if (p->fts_info == FTS_D && p->fts_level == 1) {
                    uid_t uid = p->fts_statp->st_uid;

                    // If uid belongs to sdk sandbox, then the cache should be attributed to the
                    // original client app.
                    const auto client_uid = multiuser_convert_sdk_sandbox_to_app_uid(uid);
                    const bool isSandboxUid = (client_uid != (uid_t)-1);
                    if (isSandboxUid) uid = client_uid;

                    if (multiuser_get_app_id(uid) == AID_MEDIA_RW) {
                        uid = (multiuser_get_app_id(p->fts_statp->st_gid) - AID_EXT_GID_START)
                                + AID_APP_START;
+2 −3
Original line number Diff line number Diff line
@@ -29,9 +29,8 @@ enum InputEventInjectionResult {
    /* Injection succeeded. */
    SUCCEEDED = 0,

    /* Injection failed because the injector did not have permission to inject
     * into the application with input focus. */
    PERMISSION_DENIED = 1,
    /* Injection failed because the injected event did not target the appropriate window. */
    TARGET_MISMATCH = 1,

    /* Injection failed because there were no available input targets. */
    FAILED = 2,
+10 −12
Original line number Diff line number Diff line
@@ -31,11 +31,11 @@ using android::os::InputEventInjectionSync;
namespace android::inputdispatcher {

// An arbitrary device id.
static const int32_t DEVICE_ID = 1;
constexpr int32_t DEVICE_ID = 1;

// An arbitrary injector pid / uid pair that has permission to inject events.
static const int32_t INJECTOR_PID = 999;
static const int32_t INJECTOR_UID = 1001;
// The default pid and uid for windows created by the test.
constexpr int32_t WINDOW_PID = 999;
constexpr int32_t WINDOW_UID = 1001;

static constexpr std::chrono::duration INJECT_EVENT_TIMEOUT = 5s;
static constexpr std::chrono::nanoseconds DISPATCHING_TIMEOUT = 100ms;
@@ -108,8 +108,6 @@ private:

    void pokeUserActivity(nsecs_t, int32_t, int32_t) override {}

    bool checkInjectEventsPermissionNonReentrant(int32_t, int32_t) override { return false; }

    void onPointerDownOutsideFocus(const sp<IBinder>& newToken) override {}

    void setPointerCapture(const PointerCaptureRequest&) override {}
@@ -196,8 +194,8 @@ public:
        mInfo.globalScaleFactor = 1.0;
        mInfo.touchableRegion.clear();
        mInfo.addTouchableRegion(mFrame);
        mInfo.ownerPid = INJECTOR_PID;
        mInfo.ownerUid = INJECTOR_UID;
        mInfo.ownerPid = WINDOW_PID;
        mInfo.ownerUid = WINDOW_UID;
        mInfo.displayId = ADISPLAY_ID_DEFAULT;
    }

@@ -310,14 +308,14 @@ static void benchmarkInjectMotion(benchmark::State& state) {
    for (auto _ : state) {
        MotionEvent event = generateMotionEvent();
        // Send ACTION_DOWN
        dispatcher.injectInputEvent(&event, INJECTOR_PID, INJECTOR_UID,
                                    InputEventInjectionSync::NONE, INJECT_EVENT_TIMEOUT,
        dispatcher.injectInputEvent(&event, {} /*targetUid*/, InputEventInjectionSync::NONE,
                                    INJECT_EVENT_TIMEOUT,
                                    POLICY_FLAG_FILTERED | POLICY_FLAG_PASS_TO_USER);

        // Send ACTION_UP
        event.setAction(AMOTION_EVENT_ACTION_UP);
        dispatcher.injectInputEvent(&event, INJECTOR_PID, INJECTOR_UID,
                                    InputEventInjectionSync::NONE, INJECT_EVENT_TIMEOUT,
        dispatcher.injectInputEvent(&event, {} /*targetUid*/, InputEventInjectionSync::NONE,
                                    INJECT_EVENT_TIMEOUT,
                                    POLICY_FLAG_FILTERED | POLICY_FLAG_PASS_TO_USER);

        window->consumeEvent();
+2 −3
Original line number Diff line number Diff line
@@ -20,10 +20,9 @@

namespace android::inputdispatcher {

InjectionState::InjectionState(int32_t injectorPid, int32_t injectorUid)
InjectionState::InjectionState(const std::optional<int32_t>& targetUid)
      : refCount(1),
        injectorPid(injectorPid),
        injectorUid(injectorUid),
        targetUid(targetUid),
        injectionResult(android::os::InputEventInjectionResult::PENDING),
        injectionIsAsync(false),
        pendingForegroundDispatches(0) {}
+2 −3
Original line number Diff line number Diff line
@@ -27,13 +27,12 @@ namespace inputdispatcher {
struct InjectionState {
    mutable int32_t refCount;

    int32_t injectorPid;
    int32_t injectorUid;
    std::optional<int32_t> targetUid;
    android::os::InputEventInjectionResult injectionResult; // initially PENDING
    bool injectionIsAsync;               // set to true if injection is not waiting for the result
    int32_t pendingForegroundDispatches; // the number of foreground dispatches in progress

    InjectionState(int32_t injectorPid, int32_t injectorUid);
    explicit InjectionState(const std::optional<int32_t>& targetUid);
    void release();

private:
Loading