Skip to content

Commit

Permalink
libcameraservice: Remove restrictions for faceunlock service
Browse files Browse the repository at this point in the history
Change-Id: I6248937629cd8190f46503eef31a1db7c5d54510
  • Loading branch information
jhenrique09 authored and NurKeinNeid committed Apr 17, 2021
1 parent 35bfdce commit 03cbd83
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions services/camera/libcameraservice/CameraService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2870,6 +2870,10 @@ String16 CameraService::BasicClient::getPackageName() const {
return mClientPackageName;
}

bool CameraService::BasicClient::isFaceUnlockPackage() const {
std::string cpn = String8(mClientPackageName).string();
return cpn.compare("org.pixelexperience.faceunlock") == 0;
}

int CameraService::BasicClient::getClientPid() const {
return mClientPid;
Expand Down Expand Up @@ -2930,15 +2934,15 @@ status_t CameraService::BasicClient::startCameraOps() {
mClientPackageName, /*startIfModeDefault*/ false, mClientFeatureId,
String16("start camera ") + String16(mCameraIdStr));

if (res == AppOpsManager::MODE_ERRORED) {
if (!isFaceUnlockPackage() && res == AppOpsManager::MODE_ERRORED) {
ALOGI("Camera %s: Access for \"%s\" has been revoked",
mCameraIdStr.string(), String8(mClientPackageName).string());
return PERMISSION_DENIED;
}

// If the calling Uid is trusted (a native service), the AppOpsManager could
// return MODE_IGNORED. Do not treat such case as error.
if (!mUidIsTrusted && res == AppOpsManager::MODE_IGNORED) {
if (!isFaceUnlockPackage() && !mUidIsTrusted && res == AppOpsManager::MODE_IGNORED) {
ALOGI("Camera %s: Access for \"%s\" has been restricted",
mCameraIdStr.string(), String8(mClientPackageName).string());
// Return the same error as for device policy manager rejection
Expand Down
3 changes: 3 additions & 0 deletions services/camera/libcameraservice/CameraService.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ class CameraService :
// Override rotate-and-crop AUTO behavior
virtual status_t setRotateAndCropOverride(uint8_t rotateAndCrop) = 0;

// Return if current package is face unlock
virtual bool isFaceUnlockPackage() const;

protected:
BasicClient(const sp<CameraService>& cameraService,
const sp<IBinder>& remoteCallback,
Expand Down

0 comments on commit 03cbd83

Please sign in to comment.