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

Commit 79a4bd63 authored by Hongbo Zeng's avatar Hongbo Zeng Committed by Automerger Merge Worker
Browse files

Merge changes from topic "revert-2907830-SXLQUSWOVC" into main am: 7f54af45

parents 2eb7fd23 7f54af45
Loading
Loading
Loading
Loading
+16 −39
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))
@@ -582,31 +572,15 @@ 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(contentIntent)
                            .setContentIntent(PendingIntent.getBroadcast(mContext, 0,
                                    new Intent(baseIntent).setAction(
                                            Constants.ACTION_INCOMING_FILE_CONFIRM),
                                    PendingIntent.FLAG_IMMUTABLE))
                            .setDeleteIntent(PendingIntent.getBroadcast(mContext, 0,
                                    new Intent(baseIntent).setAction(Constants.ACTION_HIDE),
                                    PendingIntent.FLAG_IMMUTABLE))
@@ -630,7 +604,10 @@ class BluetoothOppNotification {
                            true)
                            .setOngoing(true)
                            .setWhen(info.mTimeStamp)
                            .setContentIntent(contentIntent)
                            .setContentIntent(PendingIntent.getBroadcast(mContext, 0,
                                    new Intent(baseIntent).setAction(
                                            Constants.ACTION_INCOMING_FILE_CONFIRM),
                                    PendingIntent.FLAG_IMMUTABLE))
                            .setDeleteIntent(PendingIntent.getBroadcast(mContext, 0,
                                    new Intent(baseIntent).setAction(Constants.ACTION_HIDE),
                                    PendingIntent.FLAG_IMMUTABLE))
+25 −29
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;
@@ -76,7 +75,6 @@ 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");
            }
@@ -86,7 +84,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");
@@ -141,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.");
            }
@@ -150,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.");
            }
@@ -161,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 −17
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;

@@ -121,12 +119,7 @@ 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"));
@@ -159,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"));
@@ -177,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"));