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

Commit 0fd804bf authored by Steve Elliott's avatar Steve Elliott
Browse files

Fix bad cast when querying remote input history

Fixes: 171599307
Test: manual, atest
Change-Id: I1203e49365eb54b1cdcded653e0b0b51d221558b
parent a3e2def1
Loading
Loading
Loading
Loading
+14 −18
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.content.Intent;
import android.content.pm.UserInfo;
import android.net.Uri;
import android.os.Handler;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
@@ -69,8 +70,10 @@ import com.android.systemui.statusbar.policy.RemoteInputView;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Stream;

import dagger.Lazy;

@@ -630,24 +633,17 @@ public class NotificationRemoteInputManager implements Dumpable {
        Notification.Builder b = Notification.Builder
                .recoverBuilder(mContext, sbn.getNotification().clone());
        if (remoteInputText != null || uri != null) {
            RemoteInputHistoryItem[] oldHistoryItems = (RemoteInputHistoryItem[])
                    sbn.getNotification().extras.getParcelableArray(
                            Notification.EXTRA_REMOTE_INPUT_HISTORY_ITEMS);
            RemoteInputHistoryItem[] newHistoryItems;

            if (oldHistoryItems == null) {
                newHistoryItems = new RemoteInputHistoryItem[1];
            } else {
                newHistoryItems = new RemoteInputHistoryItem[oldHistoryItems.length + 1];
                System.arraycopy(oldHistoryItems, 0, newHistoryItems, 1, oldHistoryItems.length);
            }
            RemoteInputHistoryItem newItem;
            if (uri != null) {
                newItem = new RemoteInputHistoryItem(mimeType, uri, remoteInputText);
            } else {
                newItem = new RemoteInputHistoryItem(remoteInputText);
            }
            newHistoryItems[0] = newItem;
            RemoteInputHistoryItem newItem = uri != null
                    ? new RemoteInputHistoryItem(mimeType, uri, remoteInputText)
                    : new RemoteInputHistoryItem(remoteInputText);
            Parcelable[] oldHistoryItems = sbn.getNotification().extras
                    .getParcelableArray(Notification.EXTRA_REMOTE_INPUT_HISTORY_ITEMS);
            RemoteInputHistoryItem[] newHistoryItems = oldHistoryItems != null
                    ? Stream.concat(
                                Stream.of(newItem),
                                Arrays.stream(oldHistoryItems).map(p -> (RemoteInputHistoryItem) p))
                            .toArray(RemoteInputHistoryItem[]::new)
                    : new RemoteInputHistoryItem[] { newItem };
            b.setRemoteInputHistory(newHistoryItems);
        }
        b.setShowRemoteInputSpinner(showSpinner);
+3 −3
Original line number Diff line number Diff line
@@ -41,11 +41,11 @@ import android.app.NotificationChannel;
import android.app.NotificationManager.Policy;
import android.app.Person;
import android.app.RemoteInput;
import android.app.RemoteInputHistoryItem;
import android.content.Context;
import android.content.pm.ShortcutInfo;
import android.net.Uri;
import android.os.Bundle;
import android.os.Parcelable;
import android.os.SystemClock;
import android.service.notification.NotificationListenerService.Ranking;
import android.service.notification.SnoozeCriterion;
@@ -534,8 +534,8 @@ public final class NotificationEntry extends ListEntry {
            return false;
        }
        Bundle extras = mSbn.getNotification().extras;
        RemoteInputHistoryItem[] replyTexts = (RemoteInputHistoryItem[]) extras.getParcelableArray(
                Notification.EXTRA_REMOTE_INPUT_HISTORY_ITEMS);
        Parcelable[] replyTexts =
                extras.getParcelableArray(Notification.EXTRA_REMOTE_INPUT_HISTORY_ITEMS);
        if (!ArrayUtils.isEmpty(replyTexts)) {
            return true;
        }