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

Commit 9cd2aaf9 authored by Yurii Zubrytskyi's avatar Yurii Zubrytskyi
Browse files

[res] Skip all actor logic when no actors are defined

Most devices don't define any actors, so the code that does
anything at all should only run if there's at least one named
actor defined - otherwise it would only waste CPU cycles

Test: build + boot + atest OverlayActorEnforcerTests
Flag: EXEMPT minor fix
Change-Id: Ibdac21607a755f478b0768dbb50a70063a2ce9c0
parent e4ddaa6c
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -50,6 +50,10 @@ public class OverlayActorEnforcer {
     */
    static Pair<String, ActorState> getPackageNameForActor(@NonNull String actorUriString,
            @NonNull Map<String, Map<String, String>> namedActors) {
        if (namedActors.isEmpty()) {
            return Pair.create(null, ActorState.NO_NAMED_ACTORS);
        }

        Uri actorUri = Uri.parse(actorUriString);

        String actorScheme = actorUri.getScheme();
@@ -58,10 +62,6 @@ public class OverlayActorEnforcer {
            return Pair.create(null, ActorState.INVALID_OVERLAYABLE_ACTOR_NAME);
        }

        if (namedActors.isEmpty()) {
            return Pair.create(null, ActorState.NO_NAMED_ACTORS);
        }

        String actorNamespace = actorUri.getAuthority();
        Map<String, String> namespace = namedActors.get(actorNamespace);
        if (ArrayUtils.isEmpty(namespace)) {
+2 −0
Original line number Diff line number Diff line
@@ -196,6 +196,8 @@ class OverlayActorEnforcerTests {
                },
                ActorState.INVALID_OVERLAYABLE_ACTOR_NAME withCases {
                    fun TestState.mockActor(actorUri: String) {
                        namedActorsMap = mapOf(VALID_NAMESPACE to
                                mapOf(VALID_ACTOR_NAME to VALID_ACTOR_PKG))
                        targetOverlayableInfo = OverlayableInfo(OVERLAYABLE_NAME, actorUri)
                    }
                    failure("wrongScheme") {