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

Commit ee04a43b authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by android-build-merger
Browse files

Merge "Fix native permission helper local call handling"

am: e315abbb

Change-Id: Ie7bde996f2ab086d0438479ce53bc043682ee03f
parents ec1a1d03 e315abbb
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -48,20 +48,24 @@ Status checkPermission(const char* permission) {
}

bool isCallerActiveUser() {
  IPCThreadState* ipcState = IPCThreadState::self();
  IPCThreadState* ipcState = IPCThreadState::selfOrNull();
  if (!ipcState) return true;  // It's a local call

  uid_t callingUid = ipcState->getCallingUid();
  uid_t callingUser = callingUid / PER_USER_RANGE;
  if (!callingUid) return true;  // It's a local call
  if (callingUid == getuid()) return true;  // It's a local call

  return (foregroundUserId == callingUser) || (systemUiUid == callingUid) ||
         (SYSTEM_UID == callingUid);
}

bool isCallerActiveUserOrManagedProfile() {
  IPCThreadState* ipcState = IPCThreadState::self();
  IPCThreadState* ipcState = IPCThreadState::selfOrNull();
  if (!ipcState) return true;  // It's a local call

  uid_t callingUid = ipcState->getCallingUid();
  uid_t callingUser = callingUid / PER_USER_RANGE;
  // if (!callingUid) return true;  // It's a local call
  if (callingUid == getuid()) return true;  // It's a local call

  if ((foregroundUserId == callingUser) || (systemUiUid == callingUid) ||
      (SYSTEM_UID == callingUid))