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

Commit 7d27732f authored by Evan Chen's avatar Evan Chen
Browse files

Don't require MANAGE_ROLE_HOLDERS when removing CDM associatons

Bug: 260374250
Test: CTS test
Change-Id: I4478364cb1b7f295f6750d23bafe0c051a1119d3
parent f79a7ceb
Loading
Loading
Loading
Loading
+7 −1
Original line number Original line Diff line number Diff line
@@ -27,6 +27,7 @@ import android.annotation.UserIdInt;
import android.app.role.RoleManager;
import android.app.role.RoleManager;
import android.companion.AssociationInfo;
import android.companion.AssociationInfo;
import android.content.Context;
import android.content.Context;
import android.os.Binder;
import android.os.UserHandle;
import android.os.UserHandle;
import android.util.Log;
import android.util.Log;
import android.util.Slog;
import android.util.Slog;
@@ -84,6 +85,8 @@ final class RolesUtils {


        Slog.i(TAG, "Removing CDM role holder, role=" + deviceProfile
        Slog.i(TAG, "Removing CDM role holder, role=" + deviceProfile
                + ", package=u" + userId + "\\" + packageName);
                + ", package=u" + userId + "\\" + packageName);
        final long identity = Binder.clearCallingIdentity();
        try {
            roleManager.removeRoleHolderAsUser(deviceProfile, packageName,
            roleManager.removeRoleHolderAsUser(deviceProfile, packageName,
                MANAGE_HOLDERS_FLAG_DONT_KILL_APP, userHandle, context.getMainExecutor(),
                MANAGE_HOLDERS_FLAG_DONT_KILL_APP, userHandle, context.getMainExecutor(),
                success -> {
                success -> {
@@ -92,6 +95,9 @@ final class RolesUtils {
                                + " from the list of " + deviceProfile + " holders.");
                                + " from the list of " + deviceProfile + " holders.");
                    }
                    }
                });
                });
        } finally {
            Binder.restoreCallingIdentity(identity);
        }
    }
    }


    private RolesUtils() {};
    private RolesUtils() {};