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

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

Snap for 13945711 from 0f06a82b to 25Q4-release

Change-Id: Ic5f8b5781259221407bf7c37e7e901bdec67898a
parents 840f84c2 0f06a82b
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -1087,7 +1087,6 @@ cc_library {
    name: "libprocessinfoservice_aidl",
    name: "libprocessinfoservice_aidl",
    host_supported: true,
    host_supported: true,
    srcs: [
    srcs: [
        "IProcessInfoService.cpp",
        "ProcessInfoService.cpp",
        "ProcessInfoService.cpp",
    ],
    ],
    export_include_dirs: ["include_processinfo"],
    export_include_dirs: ["include_processinfo"],
@@ -1095,6 +1094,7 @@ cc_library {
        "libbinder",
        "libbinder",
        "libutils",
        "libutils",
        "liblog",
        "liblog",
        "process_info_service_aidl-cpp",
    ],
    ],
}
}


+0 −91
Original line number Original line Diff line number Diff line
/*
 * Copyright 2015 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.
 */

#include <processinfo/IProcessInfoService.h>
#include <binder/Parcel.h>
#include <utils/Errors.h>
#include <sys/types.h>

namespace android {

// ----------------------------------------------------------------------

class BpProcessInfoService : public BpInterface<IProcessInfoService> {
public:
    explicit BpProcessInfoService(const sp<IBinder>& impl)
        : BpInterface<IProcessInfoService>(impl) {}

    virtual status_t getProcessStatesFromPids(size_t length, /*in*/ int32_t* pids,
            /*out*/ int32_t* states)
    {
        Parcel data, reply;
        data.writeInterfaceToken(IProcessInfoService::getInterfaceDescriptor());
        data.writeInt32Array(length, pids);
        data.writeInt32(length); // write length of output array, used by java AIDL stubs
        status_t err = remote()->transact(GET_PROCESS_STATES_FROM_PIDS, data, &reply);
        if (err != NO_ERROR || ((err = reply.readExceptionCode()) != NO_ERROR)) {
            return err;
        }
        int32_t replyLen = reply.readInt32();
        if (static_cast<size_t>(replyLen) != length) {
            return NOT_ENOUGH_DATA;
        }
        if (replyLen > 0 && (err = reply.read(states, length * sizeof(*states))) != NO_ERROR) {
            return err;
        }
        return reply.readInt32();
    }

    virtual status_t getProcessStatesAndOomScoresFromPids(size_t length,
            /*in*/ int32_t* pids, /*out*/ int32_t* states, /*out*/ int32_t* scores)
    {
        Parcel data, reply;
        data.writeInterfaceToken(IProcessInfoService::getInterfaceDescriptor());
        data.writeInt32Array(length, pids);
        // write length of output arrays, used by java AIDL stubs
        data.writeInt32(length);
        data.writeInt32(length);
        status_t err = remote()->transact(
                GET_PROCESS_STATES_AND_OOM_SCORES_FROM_PIDS, data, &reply);
        if (err != NO_ERROR
                || ((err = reply.readExceptionCode()) != NO_ERROR)) {
            return err;
        }
        int32_t replyLen = reply.readInt32();
        if (static_cast<size_t>(replyLen) != length) {
            return NOT_ENOUGH_DATA;
        }
        if (replyLen > 0 && (err = reply.read(
                states, length * sizeof(*states))) != NO_ERROR) {
            return err;
        }
        replyLen = reply.readInt32();
        if (static_cast<size_t>(replyLen) != length) {
            return NOT_ENOUGH_DATA;
        }
        if (replyLen > 0 && (err = reply.read(
                scores, length * sizeof(*scores))) != NO_ERROR) {
            return err;
        }
        return reply.readInt32();
    }
};

IMPLEMENT_META_INTERFACE(ProcessInfoService, "android.os.IProcessInfoService")

// ----------------------------------------------------------------------

} // namespace android
+24 −6
Original line number Original line Diff line number Diff line
@@ -14,14 +14,17 @@
 * limitations under the License.
 * limitations under the License.
 */
 */


#include <processinfo/ProcessInfoService.h>
#include <android/os/IProcessInfoService.h>
#include <binder/IServiceManager.h>
#include <binder/IServiceManager.h>
#include <processinfo/ProcessInfoService.h>


#include <utils/Log.h>
#include <utils/Log.h>
#include <utils/String16.h>
#include <utils/String16.h>


namespace android {
namespace android {


using os::IProcessInfoService;

ProcessInfoService::ProcessInfoService() {
ProcessInfoService::ProcessInfoService() {
    updateBinderLocked();
    updateBinderLocked();
}
}
@@ -37,8 +40,15 @@ status_t ProcessInfoService::getProcessStatesImpl(size_t length, /*in*/ int32_t*
    for (int i = 0; i < BINDER_ATTEMPT_LIMIT; i++) {
    for (int i = 0; i < BINDER_ATTEMPT_LIMIT; i++) {


        if (pis != nullptr) {
        if (pis != nullptr) {
            err = pis->getProcessStatesFromPids(length, /*in*/ pids, /*out*/ states);
            std::vector<int32_t> pidVector(pids, pids + length);
            if (err == NO_ERROR) return NO_ERROR; // success
            std::vector<int32_t> statesVector(states, states + length);

            auto status = pis->getProcessStatesFromPids(pidVector, &statesVector);
            err = status.exceptionCode();
            if (err == NO_ERROR) {
                memcpy(states, statesVector.data(), length * sizeof(*states));
                return NO_ERROR; // success
            }
            if (IInterface::asBinder(pis)->isBinderAlive()) return err;
            if (IInterface::asBinder(pis)->isBinderAlive()) return err;
        }
        }
        sleep(1);
        sleep(1);
@@ -69,9 +79,17 @@ status_t ProcessInfoService::getProcessStatesScoresImpl(size_t length,
    for (int i = 0; i < BINDER_ATTEMPT_LIMIT; i++) {
    for (int i = 0; i < BINDER_ATTEMPT_LIMIT; i++) {


        if (pis != nullptr) {
        if (pis != nullptr) {
            err = pis->getProcessStatesAndOomScoresFromPids(length,
            std::vector<int32_t> pidVector(pids, pids + length);
                    /*in*/ pids, /*out*/ states, /*out*/ scores);
            std::vector<int32_t> statesVector(states, states + length);
            if (err == NO_ERROR) return NO_ERROR; // success
            std::vector<int32_t> scoresVector(scores, scores + length);
            auto status = pis->getProcessStatesAndOomScoresFromPids(pidVector, &statesVector,
                                                                    &scoresVector);
            err = status.exceptionCode();
            if (err == NO_ERROR) {
                memcpy(states, statesVector.data(), length * sizeof(*states));
                memcpy(scores, scoresVector.data(), length * sizeof(*scores));
                return NO_ERROR; // success
            }
            if (IInterface::asBinder(pis)->isBinderAlive()) return err;
            if (IInterface::asBinder(pis)->isBinderAlive()) return err;
        }
        }
        sleep(1);
        sleep(1);
+0 −1
Original line number Original line Diff line number Diff line
@@ -254,7 +254,6 @@ constexpr const char* const kManualInterfaces[] = {
        "android.media.IRemoteDisplay",
        "android.media.IRemoteDisplay",
        "android.media.IRemoteDisplayClient",
        "android.media.IRemoteDisplayClient",
        "android.os.IPermissionController",
        "android.os.IPermissionController",
        "android.os.IProcessInfoService",
        "android.os.ISchedulingPolicyService",
        "android.os.ISchedulingPolicyService",
        "android.os.storage.IObbActionListener",
        "android.os.storage.IObbActionListener",
        "android.os.storage.IStorageEventListener",
        "android.os.storage.IStorageEventListener",
+0 −52
Original line number Original line Diff line number Diff line
/*
 * Copyright 2015 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

#ifndef __ANDROID_VNDK__

#include <binder/IInterface.h>

namespace android {

// ----------------------------------------------------------------------

class IProcessInfoService : public IInterface {
public:
    DECLARE_META_INTERFACE(ProcessInfoService)

    virtual status_t    getProcessStatesFromPids( size_t length,
                                                  /*in*/ int32_t* pids,
                                                  /*out*/ int32_t* states) = 0;

    virtual status_t    getProcessStatesAndOomScoresFromPids( size_t length,
                                                  /*in*/ int32_t* pids,
                                                  /*out*/ int32_t* states,
                                                  /*out*/ int32_t* scores) = 0;

    enum {
        GET_PROCESS_STATES_FROM_PIDS = IBinder::FIRST_CALL_TRANSACTION,
        GET_PROCESS_STATES_AND_OOM_SCORES_FROM_PIDS,
    };
};

// ----------------------------------------------------------------------

} // namespace android

#else // __ANDROID_VNDK__
#error "This header is not visible to vendors"
#endif // __ANDROID_VNDK__
Loading