android Jelly Bean版本如何將camera service修改為強佔式

來源:互聯網
上載者:User

標籤:android   ar   檔案   sp   on   log   amp   bs   as   

實現強佔式camera service,當某些應用(如手電筒)在後台開啟camera後,當camera app open camera時可以強佔被後台應用佔有的camera.


1. 修改CameraService.cpp (frameworks/av/services/camera/libcameraservice/)
檔案的connect()方法,將
原來的
    Mutex::Autolock lock(mServiceLock);
    if (mClient[cameraId] != 0) {
        client = mClient[cameraId].promote();
        if (client != 0) {
            if (cameraClient->asBinder() == client->getCameraClient()->asBinder()) {
                LOG1("CameraService::connect X (pid %d) (the same client)",
                     callingPid);
                return client;
            } else {
                ALOGW("CameraService::connect X (pid %d) rejected (existing client).",
                      callingPid);
                return NULL;
            }
        }
        mClient[cameraId].clear();
    }
修改為:
   
    if (mClient[cameraId] != 0) {
        client = mClient[cameraId].promote();
        if (client != 0) {
                LOG1("CameraService::connect X (pid %d)  disconnect the old client", callingPid);
               client->disconnect();
        }
        mClient[cameraId].clear();
    }
   Mutex::Autolock lock(mServiceLock);
 
2. 修改CameraClient.cpp(frameworks/av/services/camera/libcameraservice/)
檔案的disconnect()方法:
將原來的:
    if (callingPid != mClientPid && callingPid != mServicePid) {
        ALOGW("different client - don‘t disconnect");
        return;
    }
修改為:
    if (callingPid != mClientPid && callingPid != mServicePid) {
        ALOGW("different client but  preemptive camera service! ");
        //return;
    }

android Jelly Bean版本如何將camera service修改為強佔式

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.