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

Commit ff3d7d3c authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Fix native permission helper local call handling"

parents 58cbe21a eb6705b8
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))