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

Commit 70c57a49 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Don't crash system process on empty onTuneFailed" into qt-qpr1-dev am:...

Merge "Don't crash system process on empty onTuneFailed" into qt-qpr1-dev am: 7b19135c am: 04d36129

Change-Id: I335481eff45455d75c63253b28f0d4a83baaa658
parents d60e103d 04d36129
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -274,8 +274,18 @@ class Convert {
        return hwSel;
    }

    static @NonNull ProgramSelector programSelectorFromHal(
    private static boolean isEmpty(
            @NonNull android.hardware.broadcastradio.V2_0.ProgramSelector sel) {
        if (sel.primaryId.type != 0) return false;
        if (sel.primaryId.value != 0) return false;
        if (sel.secondaryIds.size() != 0) return false;
        return true;
    }

    static @Nullable ProgramSelector programSelectorFromHal(
            @NonNull android.hardware.broadcastradio.V2_0.ProgramSelector sel) {
        if (isEmpty(sel)) return null;

        ProgramSelector.Identifier[] secondaryIds = sel.secondaryIds.stream().
                map(Convert::programIdentifierFromHal).map(Objects::requireNonNull).
                toArray(ProgramSelector.Identifier[]::new);
@@ -363,7 +373,7 @@ class Convert {
                collect(Collectors.toList());

        return new RadioManager.ProgramInfo(
                programSelectorFromHal(info.selector),
                Objects.requireNonNull(programSelectorFromHal(info.selector)),
                programIdentifierFromHal(info.logicallyTunedTo),
                programIdentifierFromHal(info.physicallyTunedTo),
                relatedContent,
@@ -401,7 +411,7 @@ class Convert {
    public static @NonNull android.hardware.radio.Announcement announcementFromHal(
            @NonNull Announcement hwAnnouncement) {
        return new android.hardware.radio.Announcement(
            programSelectorFromHal(hwAnnouncement.selector),
            Objects.requireNonNull(programSelectorFromHal(hwAnnouncement.selector)),
            hwAnnouncement.type,
            vendorInfoFromHal(hwAnnouncement.vendorInfo)
        );