当前位置: 首页>>代码示例>>C++>>正文


C++ IPCThreadState::getCallingPid方法代码示例

本文整理汇总了C++中IPCThreadState::getCallingPid方法的典型用法代码示例。如果您正苦于以下问题:C++ IPCThreadState::getCallingPid方法的具体用法?C++ IPCThreadState::getCallingPid怎么用?C++ IPCThreadState::getCallingPid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPCThreadState的用法示例。


在下文中一共展示了IPCThreadState::getCallingPid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: checkCalling

bool Permission::checkCalling() const
{
    IPCThreadState* ipcState = IPCThreadState::self();
    pid_t pid = ipcState->getCallingPid();
    uid_t uid = ipcState->getCallingUid();
    return doCheckPermission(pid, uid);
}
开发者ID:Abhishekh-TEL,项目名称:pdroid,代码行数:7,代码来源:Permission.cpp

示例2: onTransact

status_t FakeSurfaceComposer::onTransact(uint32_t code, const Parcel& data,
                                         Parcel* reply, uint32_t flags)
{
    switch (code) {
        case CREATE_CONNECTION:
        case CREATE_DISPLAY:
        case SET_TRANSACTION_STATE:
        case CAPTURE_SCREEN:
        {
            // codes that require permission check
            IPCThreadState* ipc = IPCThreadState::self();
            const int pid = ipc->getCallingPid();
            const int uid = ipc->getCallingUid();
            // Accept request only when uid is root.
            if (uid != AID_ROOT) {
                ALOGE("Permission Denial: "
                        "can't access SurfaceFlinger pid=%d, uid=%d", pid, uid);
                return PERMISSION_DENIED;
            }
            break;
        }
    }

    return BnSurfaceComposer::onTransact(code, data, reply, flags);
}
开发者ID:rlr,项目名称:gecko-dev,代码行数:25,代码来源:FakeSurfaceComposer.cpp

示例3: onTransact

status_t BnQService::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    // IPC should be from mediaserver only
    IPCThreadState* ipc = IPCThreadState::self();
    const int callerPid = ipc->getCallingPid();
    const int callerUid = ipc->getCallingUid();

    const bool permission = (callerUid == AID_MEDIA);

    switch(code) {
        case CONNECT: {
            CHECK_INTERFACE(IQService, data, reply);

            sp<IQClient> client =
                interface_cast<IQClient>(data.readStrongBinder());
            connect(client);
            return NO_ERROR;
        } break;
		case SETMEM: {
            CHECK_INTERFACE(IQService, data, reply);

            sp<IMemory> sharedBuffer =
                interface_cast<IMemory>(data.readStrongBinder());
            setMemory(sharedBuffer);
            return NO_ERROR;
        } break;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}
开发者ID:yuguihu,项目名称:Binder_example,代码行数:31,代码来源:IQService.cpp

示例4: isProtectedCallAllowed

static bool isProtectedCallAllowed() {
    // M: migration these from ICS
    // TODO
    // Following implementation is just for reference.
    // Each OEM manufacturer should implement/replace with their own solutions.
    bool result = false;

    IPCThreadState* ipcState = IPCThreadState::self();
    uid_t uid = ipcState->getCallingUid();

    for (unsigned int i = 0; i < trustedUids.size(); ++i) {
        if (trustedUids[i] == uid) {
            result = true;
            break;
        }
    }

    // M:
    // for OMA DRM v1 implementation
    // if can't authorize the process by UID, then check the process name.
    if (!result) {
        pid_t pid = ipcState->getCallingPid();
        result = DrmTrustedClient::IsDrmTrustedClient(DrmMtkUtil::getProcessName(pid));
    }

    return result;
}
开发者ID:Jiangyi,项目名称:12055,代码行数:27,代码来源:DrmManagerService.cpp

示例5: checkCallingPermission

bool checkCallingPermission(const String16& permission, int32_t* outPid, int32_t* outUid)
{
    IPCThreadState* ipcState = IPCThreadState::self();
    pid_t pid = ipcState->getCallingPid();
    uid_t uid = ipcState->getCallingUid();
    if (outPid) *outPid = pid;
    if (outUid) *outUid = uid;
    return checkPermission(permission, pid, uid);
}
开发者ID:AOSP-JF,项目名称:platform_frameworks_native,代码行数:9,代码来源:IServiceManager.cpp

示例6: enroll

    virtual int enroll(uint32_t uid,
            const uint8_t *current_password_handle, uint32_t current_password_handle_length,
            const uint8_t *current_password, uint32_t current_password_length,
            const uint8_t *desired_password, uint32_t desired_password_length,
            uint8_t **enrolled_password_handle, uint32_t *enrolled_password_handle_length) {
        IPCThreadState* ipc = IPCThreadState::self();
        const int calling_pid = ipc->getCallingPid();
        const int calling_uid = ipc->getCallingUid();
        if (!PermissionCache::checkPermission(KEYGUARD_PERMISSION, calling_pid, calling_uid)) {
            return PERMISSION_DENIED;
        }

        // need a desired password to enroll
        if (desired_password_length == 0) return -EINVAL;

        int ret;
        if (device) {
            const gatekeeper::password_handle_t *handle =
                    reinterpret_cast<const gatekeeper::password_handle_t *>(current_password_handle);

            if (handle != NULL && handle->version != 0 && !handle->hardware_backed) {
                // handle is being re-enrolled from a software version. HAL probably won't accept
                // the handle as valid, so we nullify it and enroll from scratch
                current_password_handle = NULL;
                current_password_handle_length = 0;
                current_password = NULL;
                current_password_length = 0;
            }

            ret = device->enroll(device, uid, current_password_handle, current_password_handle_length,
                    current_password, current_password_length,
                    desired_password, desired_password_length,
                    enrolled_password_handle, enrolled_password_handle_length);
        } else {
            ret = soft_device->enroll(uid,
                    current_password_handle, current_password_handle_length,
                    current_password, current_password_length,
                    desired_password, desired_password_length,
                    enrolled_password_handle, enrolled_password_handle_length);
        }

        if (ret == 0) {
            gatekeeper::password_handle_t *handle =
                    reinterpret_cast<gatekeeper::password_handle_t *>(*enrolled_password_handle);
            store_sid(uid, handle->user_id);
            bool rr;

            // immediately verify this password so we don't ask the user to enter it again
            // if they just created it.
            verify(uid, *enrolled_password_handle, sizeof(password_handle_t), desired_password,
                    desired_password_length, &rr);
        }

        return ret;
    }
开发者ID:Hazy-legacy-zf2,项目名称:platform_system_core,代码行数:55,代码来源:gatekeeperd.cpp

示例7: dump

status_t BatteryPropertiesRegistrar::dump(int fd, const Vector<String16>& /*args*/) {
    IPCThreadState* self = IPCThreadState::self();
    const int pid = self->getCallingPid();
    const int uid = self->getCallingUid();
    if ((uid != AID_SHELL) &&
        !PermissionCache::checkPermission(
                String16("android.permission.DUMP"), pid, uid))
        return PERMISSION_DENIED;

    healthd_dump_battery_state(fd);
    return OK;
}
开发者ID:BORGROMz,项目名称:system_core,代码行数:12,代码来源:BatteryPropertiesRegistrar.cpp

示例8: clearSecureUserId

    virtual void clearSecureUserId(uint32_t uid) {
        IPCThreadState* ipc = IPCThreadState::self();
        const int calling_pid = ipc->getCallingPid();
        const int calling_uid = ipc->getCallingUid();
        if (!PermissionCache::checkPermission(KEYGUARD_PERMISSION, calling_pid, calling_uid)) {
            ALOGE("%s: permission denied for [%d:%d]", __func__, calling_pid, calling_uid);
            return;
        }
        clear_sid(uid);

        if (device != NULL && device->delete_user != NULL) {
            device->delete_user(device, uid);
        }
    }
开发者ID:Hazy-legacy-zf2,项目名称:platform_system_core,代码行数:14,代码来源:gatekeeperd.cpp

示例9: onTransact

status_t BnMediaAnalyticsService::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{


    // get calling pid/tid
    IPCThreadState *ipc = IPCThreadState::self();
    int clientPid = ipc->getCallingPid();
    // permission checking

    if(DEBUGGING_FLOW) {
        ALOGD("running in service, code %d, pid %d; called from pid %d",
            code, getpid(), clientPid);
    }

    switch (code) {

        case GENERATE_UNIQUE_SESSIONID: {
            CHECK_INTERFACE(IMediaAnalyticsService, data, reply);

            MediaAnalyticsItem::SessionID_t sessionid = generateUniqueSessionID();
            reply->writeInt64(sessionid);

            return NO_ERROR;
        } break;

        case SUBMIT_ITEM: {
            CHECK_INTERFACE(IMediaAnalyticsService, data, reply);

            bool forcenew;
            MediaAnalyticsItem *item = new MediaAnalyticsItem;

            data.readBool(&forcenew);
            item->readFromParcel(data);

            item->setPid(clientPid);

            // submit() takes over ownership of 'item'
            MediaAnalyticsItem::SessionID_t sessionid = submit(item, forcenew);
            reply->writeInt64(sessionid);

            return NO_ERROR;
        } break;

        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}
开发者ID:MIPS,项目名称:frameworks-av,代码行数:48,代码来源:IMediaAnalyticsService.cpp

示例10: dump

    virtual status_t dump(int fd, const Vector<String16> &) {
        IPCThreadState* ipc = IPCThreadState::self();
        const int pid = ipc->getCallingPid();
        const int uid = ipc->getCallingUid();
        if (!PermissionCache::checkPermission(DUMP_PERMISSION, pid, uid)) {
            return PERMISSION_DENIED;
        }

        if (device == NULL) {
            const char *result = "Device not available";
            write(fd, result, strlen(result) + 1);
        } else {
            const char *result = "OK";
            write(fd, result, strlen(result) + 1);
        }

        return NO_ERROR;
    }
开发者ID:Hazy-legacy-zf2,项目名称:platform_system_core,代码行数:18,代码来源:gatekeeperd.cpp

示例11: onTransact

status_t Client::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    // these must be checked
     IPCThreadState* ipc = IPCThreadState::self();
     const int pid = ipc->getCallingPid();
     const int uid = ipc->getCallingUid();
     const int self_pid = getpid();
     if (CC_UNLIKELY(pid != self_pid && uid != AID_GRAPHICS && uid != 0)) {
         // we're called from a different process, do the real check
         if (!PermissionCache::checkCallingPermission(sAccessSurfaceFlinger))
         {
             ALOGE("Permission Denial: "
                     "can't openGlobalTransaction pid=%d, uid=%d", pid, uid);
             return PERMISSION_DENIED;
         }
     }
     return BnSurfaceComposerClient::onTransact(code, data, reply, flags);
}
开发者ID:aurorarom,项目名称:JsonUtil,代码行数:19,代码来源:Client.cpp

示例12: onTransact

status_t LayerBaseClient::Surface::onTransact(
        uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    switch (code) {
        case REGISTER_BUFFERS:
        case UNREGISTER_BUFFERS:
        case CREATE_OVERLAY:
        {
            if (!mFlinger->mAccessSurfaceFlinger.checkCalling()) {
                IPCThreadState* ipc = IPCThreadState::self();
                const int pid = ipc->getCallingPid();
                const int uid = ipc->getCallingUid();
                LOGE("Permission Denial: "
                        "can't access SurfaceFlinger pid=%d, uid=%d", pid, uid);
                return PERMISSION_DENIED;
            }
        }
    }
    return BnSurface::onTransact(code, data, reply, flags);
}
开发者ID:DongheonKim,项目名称:android_frameworks_base,代码行数:20,代码来源:LayerBase.cpp

示例13:

int
GonkSchedulePolicyService::requestPriority(int32_t pid, int32_t tid, int32_t prio)
{
    // See SchedulingPolicyService.java
#define PRIORITY_MIN 1
#define PRIORITY_MAX 3

    IPCThreadState* ipcState = IPCThreadState::self();
    if (ipcState->getCallingUid() != AID_MEDIA ||
        prio < PRIORITY_MIN || prio > PRIORITY_MAX ||
        !tidBelongsToPid(tid, pid))
        return -1; /* PackageManager.PERMISSION_DENIED */

    set_sched_policy(tid, ipcState->getCallingPid() == pid ?
                          SP_AUDIO_SYS : SP_AUDIO_APP);
    struct sched_param param;
    param.sched_priority = prio;
    int rc = sched_setscheduler(tid, SCHED_FIFO, &param);
    if (rc)
        return -1;

    return 0; /* PackageManger.PERMISSION_GRANTED */
}
开发者ID:EricRahm,项目名称:gonk-misc,代码行数:23,代码来源:gonksched.cpp

示例14: onTransact

status_t Client::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    // these must be checked
     IPCThreadState* ipc = IPCThreadState::self();
     const int pid = ipc->getCallingPid();
     const int uid = ipc->getCallingUid();
     const int self_pid = getpid();
     // If we are called from another non root process without the GRAPHICS, SYSTEM, or ROOT
     // uid we require the sAccessSurfaceFlinger permission.
     // We grant an exception in the case that the Client has a "parent layer", as its
     // effects will be scoped to that layer.
     if (CC_UNLIKELY(pid != self_pid && uid != AID_GRAPHICS && uid != AID_SYSTEM && uid != 0)
             && (getParentLayer() == nullptr)) {
         // we're called from a different process, do the real check
         if (!PermissionCache::checkCallingPermission(sAccessSurfaceFlinger))
         {
             ALOGE("Permission Denial: "
                     "can't openGlobalTransaction pid=%d, uid<=%d", pid, uid);
             return PERMISSION_DENIED;
         }
     }
     return BnSurfaceComposerClient::onTransact(code, data, reply, flags);
}
开发者ID:MIPS,项目名称:frameworks-native,代码行数:24,代码来源:Client.cpp

示例15: onTransact

status_t BnMonzax::onTransact(
        uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{

    status_t status = BBinder::onTransact(code, data, reply, flags);
    if (status != UNKNOWN_TRANSACTION) {
        return status;
    }
    if (! reply) {
        ALOGE("Monzax::onTransact(): null reply parcel received.");
        return BAD_VALUE;
    }

    IPCThreadState *ipc = IPCThreadState::self();
    const int pid = ipc->getCallingPid();
    const int uid = ipc->getCallingUid();

    // dispatch to the appropriate method based on the transaction code.
    switch(code){
        case FILE_OPEN:
            {
                CHECK_INTERFACE(IMonzax, data, reply);
                ALOGI("BnMonzax: onTransact: FILE_OPEN"
                    "client to access MonzaxService from uid=%d pid=%d code: %d",
                    uid, pid, code);
                char *pName = (char *) data.readCString();
                int ret = file_open(pName);
                reply->writeInt32(ret);
                return NO_ERROR;
            }
            break;
        case FILE_CLOSE:
            {
                ALOGI("BnMonzax: onTransact: FILE_CLOSE"
                    "client to access MonzaxService from uid=%d pid=%d code: %d",
                    uid, pid, code);
                CHECK_INTERFACE(IMonzax, data, reply);
                int fd = data.readInt32();
                int ret = file_close(fd);
                reply->writeInt32(ret);
                return NO_ERROR;
            }
            break;
        case FILE_SEEK:
            {
                CHECK_INTERFACE(IMonzax, data, reply);
                int ret;

                int fd = data.readInt32();
                int offset = data.readInt32();
                int whence = data.readInt32();
                ret = file_seek(fd, offset, whence);
                reply->writeInt32(ret);
                return NO_ERROR;
            }
            break;
        case FILE_READ:
            {
                CHECK_INTERFACE(IMonzax, data, reply);
                char *pReadBuf;
                int ret;

                int fd = data.readInt32();
                int length = data.readInt32();
                pReadBuf = (char*) malloc(sizeof(char) * length);
                if (pReadBuf == NULL) {
                    ret = -1;
                    reply->writeInt32(ret);
                    ALOGE("onTransact File_Read malloc result failed.\n");
                    goto err_read;
                }
                ret = file_read(fd, pReadBuf, length);
                reply->writeInt32(ret);
                if(ret >0){
                    reply->write((char *) pReadBuf, ret);
                }
                free(pReadBuf);
                pReadBuf = NULL;
                return NO_ERROR;
err_read:
                ALOGE("onTransact File_Read ,ret =%d out\n",  (int)ret);
                return ret;
            }
            break;
        case FILE_WRITE:
            {
                CHECK_INTERFACE(IMonzax, data, reply);
                int ret;
                int fd = data.readInt32();
                int length = data.readInt32();
                char *pWriteBuf = (char*) malloc(sizeof(char) * length);
                if (pWriteBuf == NULL) {
                    ret = -1;
                    reply->writeInt32(ret);
                    ALOGE("onTransact File_Write malloc result failed.\n");
                    goto err_write;
                }
                if(length > 0){
                    const char *input = (const char *) data.readInplace(length);
                    if (input)
//.........这里部分代码省略.........
开发者ID:yutokt,项目名称:android_vendor_intel,代码行数:101,代码来源:IMonzax.cpp


注:本文中的IPCThreadState::getCallingPid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。