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

Commit 5b856587 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 4613997 from c1d316f4 to pi-release

Change-Id: I0f7843d555a23224a8dba14fdabb2f404ca1fb42
parents d23f8efc c1d316f4
Loading
Loading
Loading
Loading
+1 −13
Original line number Diff line number Diff line
@@ -56,7 +56,6 @@ using pdx::default_transport::ServiceUtility;
using std::string;

#define MAX_SYS_FILES 10
#define MAX_PACKAGES 16

const char* k_traceTagsProperty = "debug.atrace.tags.enableflags";

@@ -600,12 +599,6 @@ static bool setTagsProperty(uint64_t tags)

static void clearAppProperties()
{
    for (int i = 0; i < MAX_PACKAGES; i++) {
        std::string key = android::base::StringPrintf(k_traceAppsPropertyTemplate, i);
        if (!android::base::SetProperty(key, "")) {
            fprintf(stderr, "failed to clear system property: %s\n", key.c_str());
        }
    }
    if (!android::base::SetProperty(k_traceAppsNumberProperty, "")) {
        fprintf(stderr, "failed to clear system property: %s",
              k_traceAppsNumberProperty);
@@ -619,11 +612,6 @@ static bool setAppCmdlineProperty(char* cmdline)
    int i = 0;
    char* start = cmdline;
    while (start != NULL) {
        if (i == MAX_PACKAGES) {
            fprintf(stderr, "error: only 16 packages could be traced at once\n");
            clearAppProperties();
            return false;
        }
        char* end = strchr(start, ',');
        if (end != NULL) {
            *end = '\0';
@@ -1061,7 +1049,7 @@ static void showHelp(const char *cmd)
    fprintf(stderr, "usage: %s [options] [categories...]\n", cmd);
    fprintf(stderr, "options include:\n"
                    "  -a appname      enable app-level tracing for a comma "
                        "separated list of cmdlines\n"
                        "separated list of cmdlines; * is a wildcard matching any process\n"
                    "  -b N            use a trace buffer size of N KB\n"
                    "  -c              trace into a circular buffer\n"
                    "  -f filename     use the categories written in a file as space-separated\n"
+3 −0
Original line number Diff line number Diff line
@@ -6,6 +6,9 @@ on post-fs
    chmod 0222 /sys/kernel/debug/tracing/trace_marker
    chmod 0222 /sys/kernel/tracing/trace_marker

# Scheduler tracepoints require schedstats=enable
    write /proc/sys/kernel/sched_schedstats 1

# Grant unix world read/write permissions to kernel tracepoints.
# Access control to these files is now entirely in selinux policy.
    chmod 0666 /sys/kernel/debug/tracing/trace_clock
+3 −3
Original line number Diff line number Diff line
@@ -352,7 +352,7 @@ private:

        std::string preopted_boot_art_path = StringPrintf("/system/framework/%s/boot.art", isa);
        if (access(preopted_boot_art_path.c_str(), F_OK) == 0) {
          return PatchoatBootImage(art_path, isa);
          return PatchoatBootImage(isa_path, isa);
        } else {
          // No preopted boot image. Try to compile.
          return Dex2oatBootImage(boot_classpath_, art_path, oat_path, isa);
@@ -421,14 +421,14 @@ private:
        CHECK_EQ(0, closedir(c_dir)) << "Unable to close directory.";
    }

    bool PatchoatBootImage(const std::string& art_path, const char* isa) const {
    bool PatchoatBootImage(const std::string& output_dir, const char* isa) const {
        // This needs to be kept in sync with ART, see art/runtime/gc/space/image_space.cc.

        std::vector<std::string> cmd;
        cmd.push_back("/system/bin/patchoat");

        cmd.push_back("--input-image-location=/system/framework/boot.art");
        cmd.push_back(StringPrintf("--output-image-file=%s", art_path.c_str()));
        cmd.push_back(StringPrintf("--output-image-directory=%s", output_dir.c_str()));

        cmd.push_back(StringPrintf("--instruction-set=%s", isa));

+13 −1
Original line number Diff line number Diff line
@@ -380,6 +380,18 @@ private:
            }
        }

        void initializeFrom(const History& other) {
            eventTime = other.eventTime;
            idBits = other.idBits; // temporary copy
            for (size_t i = 0; i < other.idBits.count(); i++) {
                uint32_t id = idBits.clearFirstMarkedBit();
                int32_t index = other.idToIndex[id];
                idToIndex[id] = index;
                pointers[index].copyFrom(other.pointers[index]);
            }
            idBits = other.idBits; // final copy
        }

        const PointerCoords& getPointerById(uint32_t id) const {
            return pointers[idToIndex[id]];
        }
@@ -462,7 +474,7 @@ private:

    status_t sendUnchainedFinishedSignal(uint32_t seq, bool handled);

    static bool rewriteMessage(const TouchState& state, InputMessage& msg);
    static void rewriteMessage(TouchState& state, InputMessage& msg);
    static void initializeKeyEvent(KeyEvent* event, const InputMessage* msg);
    static void initializeMotionEvent(MotionEvent* event, const InputMessage* msg);
    static void addSample(MotionEvent* event, const InputMessage* msg);
+36 −23
Original line number Diff line number Diff line
@@ -614,10 +614,7 @@ void InputConsumer::updateTouchState(InputMessage& msg) {
        if (index >= 0) {
            TouchState& touchState = mTouchStates.editItemAt(index);
            touchState.addHistory(msg);
            bool messageRewritten = rewriteMessage(touchState, msg);
            if (!messageRewritten) {
                touchState.lastResample.idBits.clear();
            }
            rewriteMessage(touchState, msg);
        }
        break;
    }
@@ -645,7 +642,7 @@ void InputConsumer::updateTouchState(InputMessage& msg) {
    case AMOTION_EVENT_ACTION_SCROLL: {
        ssize_t index = findTouchState(deviceId, source);
        if (index >= 0) {
            const TouchState& touchState = mTouchStates.itemAt(index);
            TouchState& touchState = mTouchStates.editItemAt(index);
            rewriteMessage(touchState, msg);
        }
        break;
@@ -655,7 +652,7 @@ void InputConsumer::updateTouchState(InputMessage& msg) {
    case AMOTION_EVENT_ACTION_CANCEL: {
        ssize_t index = findTouchState(deviceId, source);
        if (index >= 0) {
            const TouchState& touchState = mTouchStates.itemAt(index);
            TouchState& touchState = mTouchStates.editItemAt(index);
            rewriteMessage(touchState, msg);
            mTouchStates.removeAt(index);
        }
@@ -664,28 +661,38 @@ void InputConsumer::updateTouchState(InputMessage& msg) {
    }
}

bool InputConsumer::rewriteMessage(const TouchState& state, InputMessage& msg) {
    bool messageRewritten = false;
/**
 * Replace the coordinates in msg with the coordinates in lastResample, if necessary.
 *
 * If lastResample is no longer valid for a specific pointer (i.e. the lastResample time
 * is in the past relative to msg and the past two events do not contain identical coordinates),
 * then invalidate the lastResample data for that pointer.
 * If the two past events have identical coordinates, then lastResample data for that pointer will
 * remain valid, and will be used to replace these coordinates. Thus, if a certain coordinate x0 is
 * resampled to the new value x1, then x1 will always be used to replace x0 until some new value
 * not equal to x0 is received.
 */
void InputConsumer::rewriteMessage(TouchState& state, InputMessage& msg) {
    nsecs_t eventTime = msg.body.motion.eventTime;
    for (uint32_t i = 0; i < msg.body.motion.pointerCount; i++) {
        uint32_t id = msg.body.motion.pointers[i].properties.id;
        if (state.lastResample.idBits.hasBit(id)) {
            PointerCoords& msgCoords = msg.body.motion.pointers[i].coords;
            const PointerCoords& resampleCoords = state.lastResample.getPointerById(id);
            if (eventTime < state.lastResample.eventTime ||
                    state.recentCoordinatesAreIdentical(id)) {
                msgCoords.setAxisValue(AMOTION_EVENT_AXIS_X, resampleCoords.getX());
                msgCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, resampleCoords.getY());
                PointerCoords& msgCoords = msg.body.motion.pointers[i].coords;
                const PointerCoords& resampleCoords = state.lastResample.getPointerById(id);
#if DEBUG_RESAMPLING
                ALOGD("[%d] - rewrite (%0.3f, %0.3f), old (%0.3f, %0.3f)", id,
                        resampleCoords.getX(), resampleCoords.getY(),
                        msgCoords.getX(), msgCoords.getY());
#endif
                messageRewritten = true;
                msgCoords.setAxisValue(AMOTION_EVENT_AXIS_X, resampleCoords.getX());
                msgCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, resampleCoords.getY());
            } else {
                state.lastResample.idBits.clearBit(id);
            }
        }
    }
    return messageRewritten;
}

void InputConsumer::resampleTouchState(nsecs_t sampleTime, MotionEvent* event,
@@ -713,7 +720,6 @@ void InputConsumer::resampleTouchState(nsecs_t sampleTime, MotionEvent* event,
    }

    // Ensure that the current sample has all of the pointers that need to be reported.
    // Also ensure that the past two "real" touch events do not contain duplicate coordinates
    const History* current = touchState.getHistory(0);
    size_t pointerCount = event->getPointerCount();
    for (size_t i = 0; i < pointerCount; i++) {
@@ -721,12 +727,6 @@ void InputConsumer::resampleTouchState(nsecs_t sampleTime, MotionEvent* event,
        if (!current->idBits.hasBit(id)) {
#if DEBUG_RESAMPLING
            ALOGD("Not resampled, missing id %d", id);
#endif
            return;
        }
        if (touchState.recentCoordinatesAreIdentical(id)) {
#if DEBUG_RESAMPLING
            ALOGD("Not resampled, past two historical events have duplicate coordinates");
#endif
            return;
        }
@@ -783,18 +783,32 @@ void InputConsumer::resampleTouchState(nsecs_t sampleTime, MotionEvent* event,
    }

    // Resample touch coordinates.
    History oldLastResample;
    oldLastResample.initializeFrom(touchState.lastResample);
    touchState.lastResample.eventTime = sampleTime;
    touchState.lastResample.idBits.clear();
    for (size_t i = 0; i < pointerCount; i++) {
        uint32_t id = event->getPointerId(i);
        touchState.lastResample.idToIndex[id] = i;
        touchState.lastResample.idBits.markBit(id);
        if (oldLastResample.hasPointerId(id) && touchState.recentCoordinatesAreIdentical(id)) {
            // We maintain the previously resampled value for this pointer (stored in
            // oldLastResample) when the coordinates for this pointer haven't changed since then.
            // This way we don't introduce artificial jitter when pointers haven't actually moved.

            // We know here that the coordinates for the pointer haven't changed because we
            // would've cleared the resampled bit in rewriteMessage if they had. We can't modify
            // lastResample in place becasue the mapping from pointer ID to index may have changed.
            touchState.lastResample.pointers[i].copyFrom(oldLastResample.getPointerById(id));
            continue;
        }

        PointerCoords& resampledCoords = touchState.lastResample.pointers[i];
        const PointerCoords& currentCoords = current->getPointerById(id);
        resampledCoords.copyFrom(currentCoords);
        if (other->idBits.hasBit(id)
                && shouldResampleTool(event->getToolType(i))) {
            const PointerCoords& otherCoords = other->getPointerById(id);
            resampledCoords.copyFrom(currentCoords);
            resampledCoords.setAxisValue(AMOTION_EVENT_AXIS_X,
                    lerp(currentCoords.getX(), otherCoords.getX(), alpha));
            resampledCoords.setAxisValue(AMOTION_EVENT_AXIS_Y,
@@ -808,7 +822,6 @@ void InputConsumer::resampleTouchState(nsecs_t sampleTime, MotionEvent* event,
                    alpha);
#endif
        } else {
            resampledCoords.copyFrom(currentCoords);
#if DEBUG_RESAMPLING
            ALOGD("[%d] - out (%0.3f, %0.3f), cur (%0.3f, %0.3f)",
                    id, resampledCoords.getX(), resampledCoords.getY(),