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

Commit 22b5c5da authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix NPE when convo parent is deleted" into main

parents cbc81126 c1cc5751
Loading
Loading
Loading
Loading
+18 −15
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.settings.notification.app;
import static com.android.settings.widget.EntityHeaderController.PREF_KEY_APP_HEADER;

import android.app.Activity;
import android.app.NotificationChannel;
import android.content.Context;
import android.text.BidiFormatter;
import android.text.SpannableStringBuilder;
@@ -101,8 +102,10 @@ public class ConversationHeaderPreferenceController extends NotificationPreferen
    @Override
    public CharSequence getSummary() {
        if (mChannel != null && !isDefaultChannel()) {
            CharSequence parentChannelLabel = mBackend.getChannel(mAppRow.pkg, mAppRow.uid,
                    mChannel.getParentChannelId()).getName();
            NotificationChannel parent = mBackend.getChannel(mAppRow.pkg, mAppRow.uid,
                    mChannel.getParentChannelId());
            if (parent != null) {
                CharSequence parentChannelLabel = parent.getName();
                if (mChannelGroup != null
                        && !TextUtils.isEmpty(mChannelGroup.getName())) {
                    final SpannableStringBuilder summary = new SpannableStringBuilder();
@@ -115,10 +118,10 @@ public class ConversationHeaderPreferenceController extends NotificationPreferen
                } else {
                    return parentChannelLabel;
                }
        } else {
            return "";
            }
        }
        return "";
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_START)
    public void onStart() {
+4 −0
Original line number Diff line number Diff line
@@ -163,5 +163,9 @@ public class ConversationHeaderPreferenceControllerTest {
                NotificationChannel.DEFAULT_CHANNEL_ID, "", IMPORTANCE_NONE);
        mController.onResume(appRow, defaultChannel, null, null, null, null, null);
        assertEquals("", mController.getSummary());

        when(mBackend.getChannel(appRow.pkg, appRow.uid, "parent")).thenReturn(null);
        mController.onResume(appRow, channel, group, null, null, null, null);
        assertEquals("", mController.getSummary());
    }
}