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

Commit 8c425097 authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by Andre Eisenbach
Browse files

Use getProfileParentId() in native permission helper (2/2)

getCredentialOwnerProfile() makes some additional unnecessary checks.

Test: cts-tradefed run cts-dev -m DevicePolicyManager --test
com.android.cts.devicepolicy.ManagedProfileTest#testBluetooth
Bug: 69284968
Change-Id: If9974e1af1e0cc0df29c39d47d3e262552294a85
parent e315abbb
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -47,6 +47,25 @@ class BpUserManager : public BpInterface<IUserManager> {

    return reply.readInt32();
  }

  virtual int32_t getProfileParentId(int32_t user_handle) {
    Parcel data, reply;
    data.writeInterfaceToken(IUserManager::getInterfaceDescriptor());
    data.writeInt32(user_handle);
    status_t rc = remote()->transact(GET_PROFILE_PARENT_ID, data, &reply, 0);
    if (rc != NO_ERROR) {
      ALOGE("%s: failed (%d)\n", __func__, rc);
      return -1;
    }

    int32_t exception = reply.readExceptionCode();
    if (exception != 0) {
      ALOGE("%s: got exception (%d)\n", __func__, exception);
      return -1;
    }

    return reply.readInt32();
  }
};

IMPLEMENT_META_INTERFACE(UserManager, "android.os.IUserManager");
+2 −0
Original line number Diff line number Diff line
@@ -33,9 +33,11 @@ class IUserManager : public IInterface {
  // must be kept in sync with IUserManager.aidl
  enum {
    GET_CREDENTIAL_OWNER_PROFILE = IBinder::FIRST_CALL_TRANSACTION + 0,
    GET_PROFILE_PARENT_ID,
  };

  virtual int32_t getCredentialOwnerProfile(int32_t user_id) = 0;
  virtual int32_t getProfileParentId(int32_t user_handle) = 0;

  DECLARE_META_INTERFACE(UserManager);
};
+1 −1
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ bool isCallerActiveUserOrManagedProfile() {
  if (um != NULL) {
    // Must use Bluetooth process identity when making call to get parent user
    int64_t ident = ipcState->clearCallingIdentity();
    parentUser = um->getCredentialOwnerProfile(callingUser);
    parentUser = um->getProfileParentId(callingUser);
    ipcState->restoreCallingIdentity(ident);
  }