int32_t CameraService::isMagicVideoApp(pid_t pid, char *buf, size_t len) {
String16 StringMM("com.tencent.mm");
String16 StringQQ("com.tencent.mobileqq:video");
String16 StringSKYPE("com.skype.rover");
char filename[30];
int ret = 0;
FILE *f;
sprintf(filename, "/proc/%d/cmdline", pid);
f = fopen(filename, "r");
LOGE("zzb:%s:f = %d",__func__,f);
if (!f) { *buf = ' '; ret = -1; }
if (!fgets(buf, len, f)) { *buf = ' '; ret = -2; }
LOGE("zzb:gets string = %s",buf);
fclose(f);
String16 Stringtemp(buf);
if(Stringtemp == StringMM)
{
ret = MAGIC_VIDEO_MM;
}
else if(Stringtemp == StringQQ)
{
ret = MAGIC_VIDEO_QQ;
}
else if(Stringtemp == StringSKYPE)
{
ret = MAGIC_VIDEO_SKYPE;
}
else
{
ret = -3;
}
LOGE("zzb:%s:return ret = %d",__func__,ret);
return ret;
}
调用
status_t CameraService::getCameraInfo(int cameraId,struct CameraInfo* cameraInfo){
...
char buf[100] = {0};
int videoapp = isMagicVideoApp(getCallingPid(),buf,sizeof(buf));
}