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

Commit 95daa14e authored by Hyundo Moon's avatar Hyundo Moon
Browse files

Open activity directly from notification (incoming file confirm)

Bug: 319050411
Bug: 318610752
Test: atest BluetoothOppReceiverTest
Test: manual, when an another device tries to send a file via BT,
      click the notification titled "Incoming file".
      There should be no lag when opening the activity titled
      "Accept incoming file?".
Change-Id: I24ad7d5968c576063266996db3ac76a2d6149b63
parent b0ced317
Loading
Loading
Loading
Loading
+21 −8
Original line number Diff line number Diff line
@@ -582,15 +582,31 @@ class BluetoothOppNotification {
                    PendingIntent.getBroadcast(mContext, 0,
                            new Intent(baseIntent).setAction(Constants.ACTION_ACCEPT),
                            PendingIntent.FLAG_IMMUTABLE)).build();

            PendingIntent contentIntent;
            if (Flags.oppStartActivityDirectlyFromNotification()) {
                Intent intent = new Intent(mContext, BluetoothOppIncomingFileConfirmActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                intent.setDataAndNormalize(contentUri);
                contentIntent =
                        PendingIntent.getActivity(
                                mContext, 0, intent, PendingIntent.FLAG_IMMUTABLE);
            } else {
                contentIntent =
                        PendingIntent.getBroadcast(
                                mContext,
                                0,
                                new Intent(baseIntent)
                                        .setAction(Constants.ACTION_INCOMING_FILE_CONFIRM),
                                PendingIntent.FLAG_IMMUTABLE);
            }

            Notification public_n =
                    new Notification.Builder(mContext, OPP_NOTIFICATION_CHANNEL).setOnlyAlertOnce(
                            true)
                            .setOngoing(true)
                            .setWhen(info.mTimeStamp)
                            .setContentIntent(PendingIntent.getBroadcast(mContext, 0,
                                    new Intent(baseIntent).setAction(
                                            Constants.ACTION_INCOMING_FILE_CONFIRM),
                                    PendingIntent.FLAG_IMMUTABLE))
                            .setContentIntent(contentIntent)
                            .setDeleteIntent(PendingIntent.getBroadcast(mContext, 0,
                                    new Intent(baseIntent).setAction(Constants.ACTION_HIDE),
                                    PendingIntent.FLAG_IMMUTABLE))
@@ -614,10 +630,7 @@ class BluetoothOppNotification {
                            true)
                            .setOngoing(true)
                            .setWhen(info.mTimeStamp)
                            .setContentIntent(PendingIntent.getBroadcast(mContext, 0,
                                    new Intent(baseIntent).setAction(
                                            Constants.ACTION_INCOMING_FILE_CONFIRM),
                                    PendingIntent.FLAG_IMMUTABLE))
                            .setContentIntent(contentIntent)
                            .setDeleteIntent(PendingIntent.getBroadcast(mContext, 0,
                                    new Intent(baseIntent).setAction(Constants.ACTION_HIDE),
                                    PendingIntent.FLAG_IMMUTABLE))
+10 −9
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ public class BluetoothOppReceiver extends BroadcastReceiver {
            }
            Toast.makeText(context, toastMsg, Toast.LENGTH_SHORT).show();
        } else if (action.equals(Constants.ACTION_INCOMING_FILE_CONFIRM)) {
            if (!Flags.oppStartActivityDirectlyFromNotification()) {
                if (V) {
                    Log.v(TAG, "Receiver ACTION_INCOMING_FILE_CONFIRM");
                }
@@ -85,7 +86,7 @@ public class BluetoothOppReceiver extends BroadcastReceiver {
                in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                in.setDataAndNormalize(uri);
                context.startActivity(in);

            }
        } else if (action.equals(Constants.ACTION_DECLINE)) {
            if (V) {
                Log.v(TAG, "Receiver ACTION_DECLINE");
+5 −0
Original line number Diff line number Diff line
@@ -121,7 +121,12 @@ public class BluetoothOppReceiverTest {
    }

    @Test
    @RequiresFlagsDisabled(Flags.FLAG_OPP_START_ACTIVITY_DIRECTLY_FROM_NOTIFICATION)
    public void onReceive_withActionIncomingFileConfirm_startsIncomingFileConfirmActivity() {
        if (Flags.oppStartActivityDirectlyFromNotification()) {
            return;
        }

        Intent intent = new Intent();
        intent.setAction(Constants.ACTION_INCOMING_FILE_CONFIRM);
        intent.setData(Uri.parse("content:///not/important"));