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

Commit 966945ab authored by Hongbo Zeng's avatar Hongbo Zeng
Browse files

Revert "Open activity directly from notification (inbound transfer)"

Revert submission 2907830

Reason for revert: reverted due to BluetoothOppTransferHistoryTest failed and these patches are the only intermediate CLs per b/320600377

Reverted changes: /q/submissionid:2907830

Change-Id: I7011e55fbfc19bd80196dacae624dd5d65c1b7a8
parent 91c535c7
Loading
Loading
Loading
Loading
+8 −18
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ class BluetoothOppNotification {
            WHERE_COMPLETED + " AND " + "(" + BluetoothShare.DIRECTION + " == "
                    + BluetoothShare.DIRECTION_INBOUND + ")";

    private static final String WHERE_CONFIRM_PENDING =
    static final String WHERE_CONFIRM_PENDING =
            BluetoothShare.USER_CONFIRMATION + " == '" + BluetoothShare.USER_CONFIRMATION_PENDING
                    + "'" + " AND " + VISIBLE;

@@ -433,9 +433,9 @@ class BluetoothOppNotification {

            PendingIntent pi;
            if (Flags.oppStartActivityDirectlyFromNotification()) {
                Intent in = new Intent(Constants.ACTION_OPEN_OUTBOUND_TRANSFER);
                in.setClass(mContext, BluetoothOppTransferHistory.class);
                Intent in = new Intent(mContext, BluetoothOppTransferHistory.class);
                in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
                in.putExtra(Constants.EXTRA_DIRECTION, BluetoothShare.DIRECTION_OUTBOUND);
                pi = PendingIntent.getActivity(mContext, 0, in, PendingIntent.FLAG_IMMUTABLE);
            } else {
                Intent in =
@@ -505,20 +505,8 @@ class BluetoothOppNotification {
        if (inboundNum > 0) {
            String caption = BluetoothOppUtility.formatResultText(inboundSuccNumber,
                    inboundFailNumber, mContext);

            PendingIntent pi;
            if (Flags.oppStartActivityDirectlyFromNotification()) {
                Intent in = new Intent(Constants.ACTION_OPEN_INBOUND_TRANSFER);
                in.setClass(mContext, BluetoothOppTransferHistory.class);
                in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
                pi = PendingIntent.getActivity(mContext, 0, in, PendingIntent.FLAG_IMMUTABLE);
            } else {
                Intent in =
                        new Intent(Constants.ACTION_OPEN_INBOUND_TRANSFER)
                                .setClassName(mContext, BluetoothOppReceiver.class.getName());
                pi = PendingIntent.getBroadcast(mContext, 0, in, PendingIntent.FLAG_IMMUTABLE);
            }

            Intent contentIntent = new Intent(Constants.ACTION_OPEN_INBOUND_TRANSFER).setClassName(
                    mContext, BluetoothOppReceiver.class.getName());
            Intent deleteIntent = new Intent(Constants.ACTION_COMPLETE_HIDE).setClassName(
                    mContext, BluetoothOppReceiver.class.getName());
            Notification inNoti =
@@ -533,7 +521,9 @@ class BluetoothOppNotification {
                                                    .system_notification_accent_color,
                                            mContext.getTheme()))

                            .setContentIntent(pi)
                            .setContentIntent(
                                    PendingIntent.getBroadcast(mContext, 0, contentIntent,
                                        PendingIntent.FLAG_IMMUTABLE))
                            .setDeleteIntent(
                                    PendingIntent.getBroadcast(mContext, 0, deleteIntent,
                                        PendingIntent.FLAG_IMMUTABLE))
+16 −19
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ import android.widget.Toast;
import com.android.bluetooth.BluetoothMethodProxy;
import com.android.bluetooth.R;
import com.android.bluetooth.Utils;
import com.android.bluetooth.flags.Flags;

/**
 * Receives and handles: system broadcasts; Intents from other applications;
@@ -140,7 +139,8 @@ public class BluetoothOppReceiver extends BroadcastReceiver {
            }

        } else if (action.equals(Constants.ACTION_OPEN_OUTBOUND_TRANSFER)) {
            if (!Flags.oppStartActivityDirectlyFromNotification()) {
            // TODO(b/319050411): Remove this if statement branch when the flag
            //                    oppStartActivityDirectlyFromNotification is cleaned up.
            if (V) {
                Log.v(TAG, "Received ACTION_OPEN_OUTBOUND_TRANSFER.");
            }
@@ -149,9 +149,7 @@ public class BluetoothOppReceiver extends BroadcastReceiver {
            in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
            in.putExtra(Constants.EXTRA_DIRECTION, BluetoothShare.DIRECTION_OUTBOUND);
            context.startActivity(in);
            }
        } else if (action.equals(Constants.ACTION_OPEN_INBOUND_TRANSFER)) {
            if (!Flags.oppStartActivityDirectlyFromNotification()) {
            if (V) {
                Log.v(TAG, "Received ACTION_OPEN_INBOUND_TRANSFER.");
            }
@@ -160,7 +158,6 @@ public class BluetoothOppReceiver extends BroadcastReceiver {
            in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
            in.putExtra(Constants.EXTRA_DIRECTION, BluetoothShare.DIRECTION_INBOUND);
            context.startActivity(in);
            }
        } else if (action.equals(Constants.ACTION_HIDE)) {
            if (V) {
                Log.v(TAG, "Receiver hide for " + intent.getData());
+2 −13
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@ import android.widget.ListView;

import com.android.bluetooth.BluetoothMethodProxy;
import com.android.bluetooth.R;
import com.android.bluetooth.flags.Flags;

/**
 * View showing the user's finished bluetooth opp transfers that the user does
@@ -76,18 +75,8 @@ public class BluetoothOppTransferHistory extends Activity
        mListView.setEmptyView(findViewById(R.id.empty));

        String direction;

        boolean isOutbound = false;

        if (Flags.oppStartActivityDirectlyFromNotification()) {
            String action = getIntent().getAction();
            isOutbound = Constants.ACTION_OPEN_OUTBOUND_TRANSFER.equals(action);
        } else {
        int dir = getIntent().getIntExtra(Constants.EXTRA_DIRECTION, 0);
            isOutbound = (dir == BluetoothShare.DIRECTION_OUTBOUND);
        }

        if (isOutbound) {
        if (dir == BluetoothShare.DIRECTION_OUTBOUND) {
            setTitle(getText(R.string.outbound_history_title));
            direction = "(" + BluetoothShare.DIRECTION + " == " + BluetoothShare.DIRECTION_OUTBOUND
                    + ")";
+0 −12
Original line number Diff line number Diff line
@@ -42,7 +42,6 @@ import android.content.ContextWrapper;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.platform.test.annotations.RequiresFlagsDisabled;

import androidx.test.core.app.ActivityScenario;
import androidx.test.espresso.intent.Intents;
@@ -51,7 +50,6 @@ import androidx.test.runner.AndroidJUnit4;

import com.android.bluetooth.BluetoothMethodProxy;
import com.android.bluetooth.TestUtils;
import com.android.bluetooth.flags.Flags;

import com.google.common.base.Objects;

@@ -154,12 +152,7 @@ public class BluetoothOppReceiverTest {
    }

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

        Intent intent = new Intent();
        intent.setAction(Constants.ACTION_OPEN_OUTBOUND_TRANSFER);
        intent.setData(Uri.parse("content:///not/important"));
@@ -172,12 +165,7 @@ public class BluetoothOppReceiverTest {
    }

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

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