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

Commit 6c6d6f50 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8573193 from c129dcd8 to tm-qpr1-release

Change-Id: Ifc8ff3ee84ff17d4c9669522b6ae5614ef15ae3f
parents d708a549 c129dcd8
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;
+1 −1
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ void generateEOTF(ui::Dataspace dataspace, std::string& shader) {
            shader.append(R"(

                float EOTF_sRGB(float srgb) {
                    return srgb <= 0.08125 ? srgb / 4.50 : pow((srgb + 0.099) / 1.099, 0.45);
                    return srgb <= 0.08125 ? srgb / 4.50 : pow((srgb + 0.099) / 1.099, 1 / 0.45);
                }

                float3 EOTF_sRGB(float3 srgb) {
+35 −16
Original line number Diff line number Diff line
@@ -80,22 +80,33 @@ void traceExpensiveRendering(bool enabled) {

} // namespace

PowerAdvisor::PowerAdvisor(SurfaceFlinger& flinger)
      : mFlinger(flinger),
        mUseScreenUpdateTimer(getUpdateTimeout() > 0),
        mScreenUpdateTimer(
                "UpdateImminentTimer", OneShotTimer::Interval(getUpdateTimeout()),
                /* resetCallback */ [this] { mSendUpdateImminent.store(false); },
PowerAdvisor::PowerAdvisor(SurfaceFlinger& flinger) : mFlinger(flinger) {
    if (getUpdateTimeout()) {
        mScreenUpdateTimer.emplace("UpdateImminentTimer",
                                   OneShotTimer::Interval(getUpdateTimeout()),
                                   /* resetCallback */ nullptr,
                                   /* timeoutCallback */
                                   [this] {
                                       const nsecs_t timeSinceLastUpdate =
                                               systemTime() - mLastScreenUpdatedTime.load();
                                       if (timeSinceLastUpdate < getUpdateTimeout()) {
                                           // We may try to disable expensive rendering and allow
                                           // for sending DISPLAY_UPDATE_IMMINENT hints too early if
                                           // we idled very shortly after updating the screen, so
                                           // make sure we wait enough time.
                                           std::this_thread::sleep_for(std::chrono::nanoseconds(
                                                   getUpdateTimeout() - timeSinceLastUpdate));
                                       }
                                       mSendUpdateImminent.store(true);
                                       mFlinger.disableExpensiveRendering();
                }) {}
                                   });
    }
}

void PowerAdvisor::init() {
    // Defer starting the screen update timer until SurfaceFlinger finishes construction.
    if (mUseScreenUpdateTimer) {
        mScreenUpdateTimer.start();
    if (mScreenUpdateTimer) {
        mScreenUpdateTimer->start();
    }
}

@@ -135,7 +146,7 @@ void PowerAdvisor::notifyDisplayUpdateImminent() {
        return;
    }

    if (mSendUpdateImminent.load()) {
    if (mSendUpdateImminent.exchange(false)) {
        std::lock_guard lock(mPowerHalMutex);
        HalWrapper* const halWrapper = getPowerHal();
        if (halWrapper == nullptr) {
@@ -147,10 +158,18 @@ void PowerAdvisor::notifyDisplayUpdateImminent() {
            mReconnectPowerHal = true;
            return;
        }

        if (mScreenUpdateTimer) {
            mScreenUpdateTimer->reset();
        } else {
            // If we don't have a screen update timer, then we don't throttle power hal calls so
            // flip this bit back to allow for calling into power hal again.
            mSendUpdateImminent.store(true);
        }
    }

    if (mUseScreenUpdateTimer) {
        mScreenUpdateTimer.reset();
    if (mScreenUpdateTimer) {
        mLastScreenUpdatedTime.store(systemTime());
    }
}

+2 −2
Original line number Diff line number Diff line
@@ -160,9 +160,9 @@ private:
    bool mNotifiedExpensiveRendering = false;

    SurfaceFlinger& mFlinger;
    const bool mUseScreenUpdateTimer;
    std::atomic_bool mSendUpdateImminent = true;
    scheduler::OneShotTimer mScreenUpdateTimer;
    std::atomic<nsecs_t> mLastScreenUpdatedTime = 0;
    std::optional<scheduler::OneShotTimer> mScreenUpdateTimer;

    // Higher-level timing data used for estimation
    struct DisplayTimeline {