summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Omair Kamil <okamil@google.com> 2024-12-27 20:08:23 -0800
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2024-12-27 20:08:23 -0800
commite9c1990be5cc644741f077b62d481ef82fdfa80e (patch)
treeb127245e8fb419140a060e73269c926dee550b8b
parentdf61d096dcf809d62535730abac6e9d2db7dd0a4 (diff)
parent5bac675c73b70e772af2cf4df625f51d095121f9 (diff)
Merge "Remove flag opp_start_activity_directly_from_notification" into main
-rw-r--r--android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java60
-rw-r--r--android/app/src/com/android/bluetooth/opp/BluetoothOppReceiver.java25
-rw-r--r--android/app/src/com/android/bluetooth/opp/BluetoothOppTransferHistory.java14
-rw-r--r--android/app/tests/unit/src/com/android/bluetooth/opp/BluetoothOppReceiverTest.java65
-rw-r--r--android/app/tests/unit/src/com/android/bluetooth/opp/BluetoothOppTransferHistoryTest.java13
-rw-r--r--flags/opp.aconfig7
6 files changed, 22 insertions, 162 deletions
diff --git a/android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java b/android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java
index 2a650ccabf..6efdb17d66 100644
--- a/android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java
+++ b/android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java
@@ -500,18 +500,11 @@ class BluetoothOppNotification {
BluetoothOppUtility.formatResultText(
outboundSuccNumber, outboundFailNumber, mContext);
- PendingIntent pi;
- if (Flags.oppStartActivityDirectlyFromNotification()) {
- Intent in = new Intent(Constants.ACTION_OPEN_OUTBOUND_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_OUTBOUND_TRANSFER)
- .setClassName(mContext, BluetoothOppReceiver.class.getName());
- pi = PendingIntent.getBroadcast(mContext, 0, in, PendingIntent.FLAG_IMMUTABLE);
- }
+ Intent in = new Intent(Constants.ACTION_OPEN_OUTBOUND_TRANSFER);
+ in.setClass(mContext, BluetoothOppTransferHistory.class);
+ in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ PendingIntent pi =
+ PendingIntent.getActivity(mContext, 0, in, PendingIntent.FLAG_IMMUTABLE);
Intent deleteIntent = new Intent(mContext, BluetoothOppReceiver.class);
deleteIntent.setAction(Constants.ACTION_HIDE_COMPLETED_OUTBOUND_TRANSFER);
@@ -583,18 +576,11 @@ class BluetoothOppNotification {
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 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);
+ PendingIntent pi =
+ PendingIntent.getActivity(mContext, 0, in, PendingIntent.FLAG_IMMUTABLE);
Intent deleteIntent = new Intent(mContext, BluetoothOppReceiver.class);
deleteIntent.setAction(Constants.ACTION_HIDE_COMPLETED_INBOUND_TRANSFER);
@@ -696,30 +682,18 @@ class BluetoothOppNotification {
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);
- }
+ Intent in = new Intent(mContext, BluetoothOppIncomingFileConfirmActivity.class);
+ in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ in.setDataAndNormalize(contentUri);
+ PendingIntent pi =
+ PendingIntent.getActivity(mContext, 0, in, PendingIntent.FLAG_IMMUTABLE);
Notification.Builder publicNotificationBuilder =
new Notification.Builder(mContext, OPP_NOTIFICATION_CHANNEL)
.setOnlyAlertOnce(true)
.setOngoing(true)
.setWhen(info.mTimeStamp)
- .setContentIntent(contentIntent)
+ .setContentIntent(pi)
.setDeleteIntent(
PendingIntent.getBroadcast(
mContext,
@@ -754,7 +728,7 @@ class BluetoothOppNotification {
.setOnlyAlertOnce(true)
.setOngoing(true)
.setWhen(info.mTimeStamp)
- .setContentIntent(contentIntent)
+ .setContentIntent(pi)
.setDeleteIntent(
PendingIntent.getBroadcast(
mContext,
diff --git a/android/app/src/com/android/bluetooth/opp/BluetoothOppReceiver.java b/android/app/src/com/android/bluetooth/opp/BluetoothOppReceiver.java
index ab8d18e18f..e0cade561d 100644
--- a/android/app/src/com/android/bluetooth/opp/BluetoothOppReceiver.java
+++ b/android/app/src/com/android/bluetooth/opp/BluetoothOppReceiver.java
@@ -100,15 +100,6 @@ public class BluetoothOppReceiver extends BroadcastReceiver {
toastMsg = context.getString(R.string.bt_toast_4, deviceName);
}
Toast.makeText(context, toastMsg, Toast.LENGTH_SHORT).show();
- } else if (action.equals(Constants.ACTION_INCOMING_FILE_CONFIRM)
- && !Flags.oppStartActivityDirectlyFromNotification()) {
- Log.v(TAG, "Receiver ACTION_INCOMING_FILE_CONFIRM");
-
- Uri uri = intent.getData();
- Intent in = new Intent(context, BluetoothOppIncomingFileConfirmActivity.class);
- in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- in.setDataAndNormalize(uri);
- context.startActivity(in);
} else if (action.equals(Constants.ACTION_DECLINE)) {
Log.v(TAG, "Receiver ACTION_DECLINE");
@@ -164,22 +155,6 @@ public class BluetoothOppReceiver extends BroadcastReceiver {
context.startActivity(in);
}
- } else if (action.equals(Constants.ACTION_OPEN_OUTBOUND_TRANSFER)
- && !Flags.oppStartActivityDirectlyFromNotification()) {
- Log.v(TAG, "Received ACTION_OPEN_OUTBOUND_TRANSFER.");
-
- Intent in = new Intent(context, BluetoothOppTransferHistory.class);
- 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)
- && !Flags.oppStartActivityDirectlyFromNotification()) {
- Log.v(TAG, "Received ACTION_OPEN_INBOUND_TRANSFER.");
-
- Intent in = new Intent(context, BluetoothOppTransferHistory.class);
- 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)) {
Log.v(TAG, "Receiver hide for " + intent.getData());
Cursor cursor =
diff --git a/android/app/src/com/android/bluetooth/opp/BluetoothOppTransferHistory.java b/android/app/src/com/android/bluetooth/opp/BluetoothOppTransferHistory.java
index c8ae64dd24..ae9283050e 100644
--- a/android/app/src/com/android/bluetooth/opp/BluetoothOppTransferHistory.java
+++ b/android/app/src/com/android/bluetooth/opp/BluetoothOppTransferHistory.java
@@ -113,18 +113,10 @@ public class BluetoothOppTransferHistory extends Activity
mListView = (ListView) findViewById(R.id.list);
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);
- }
+ boolean isOutbound =
+ Constants.ACTION_OPEN_OUTBOUND_TRANSFER.equals(getIntent().getAction());
+ String direction;
if (isOutbound) {
setTitle(getText(R.string.outbound_history_title));
direction =
diff --git a/android/app/tests/unit/src/com/android/bluetooth/opp/BluetoothOppReceiverTest.java b/android/app/tests/unit/src/com/android/bluetooth/opp/BluetoothOppReceiverTest.java
index 5f5a270335..9683a02fac 100644
--- a/android/app/tests/unit/src/com/android/bluetooth/opp/BluetoothOppReceiverTest.java
+++ b/android/app/tests/unit/src/com/android/bluetooth/opp/BluetoothOppReceiverTest.java
@@ -42,7 +42,6 @@ import android.content.ContextWrapper;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
-import android.platform.test.flag.junit.SetFlagsRule;
import android.sysprop.BluetoothProperties;
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;
@@ -71,8 +69,6 @@ import java.util.List;
@RunWith(AndroidJUnit4.class)
public class BluetoothOppReceiverTest {
- @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
-
Context mContext;
@Rule public MockitoRule mockitoRule = MockitoJUnit.rule();
@@ -132,24 +128,6 @@ public class BluetoothOppReceiverTest {
}
@Test
- public void onReceive_withActionIncomingFileConfirm_startsIncomingFileConfirmActivity() {
- mSetFlagsRule.disableFlags(Flags.FLAG_OPP_START_ACTIVITY_DIRECTLY_FROM_NOTIFICATION);
- try {
- BluetoothOppTestUtils.enableActivity(
- BluetoothOppIncomingFileConfirmActivity.class, true, mContext);
-
- Intent intent = new Intent();
- intent.setAction(Constants.ACTION_INCOMING_FILE_CONFIRM);
- intent.setData(Uri.parse("content:///not/important"));
- mReceiver.onReceive(mContext, intent);
- intended(hasComponent(BluetoothOppIncomingFileConfirmActivity.class.getName()));
- } finally {
- BluetoothOppTestUtils.enableActivity(
- BluetoothOppIncomingFileConfirmActivity.class, false, mContext);
- }
- }
-
- @Test
public void onReceive_withActionAccept_updatesContents() {
Uri uri = Uri.parse("content:///important");
Intent intent = new Intent();
@@ -190,49 +168,6 @@ public class BluetoothOppReceiverTest {
}
@Test
- public void onReceive_withActionOutboundTransfer_startsTransferHistoryActivity() {
- mSetFlagsRule.disableFlags(Flags.FLAG_OPP_START_ACTIVITY_DIRECTLY_FROM_NOTIFICATION);
- try {
- BluetoothOppTestUtils.enableActivity(BluetoothOppTransferHistory.class, true, mContext);
-
- Intent intent = new Intent();
- intent.setAction(Constants.ACTION_OPEN_OUTBOUND_TRANSFER);
- intent.setData(Uri.parse("content:///not/important"));
- intending(anyIntent())
- .respondWith(
- new Instrumentation.ActivityResult(Activity.RESULT_OK, new Intent()));
-
- mReceiver.onReceive(mContext, intent);
- intended(hasComponent(BluetoothOppTransferHistory.class.getName()));
- intended(hasExtra(Constants.EXTRA_DIRECTION, BluetoothShare.DIRECTION_OUTBOUND));
- } finally {
- BluetoothOppTestUtils.enableActivity(
- BluetoothOppTransferHistory.class, false, mContext);
- }
- }
-
- @Test
- public void onReceive_withActionInboundTransfer_startsTransferHistoryActivity() {
- mSetFlagsRule.disableFlags(Flags.FLAG_OPP_START_ACTIVITY_DIRECTLY_FROM_NOTIFICATION);
- try {
- BluetoothOppTestUtils.enableActivity(BluetoothOppTransferHistory.class, true, mContext);
-
- Intent intent = new Intent();
- intent.setAction(Constants.ACTION_OPEN_INBOUND_TRANSFER);
- intent.setData(Uri.parse("content:///not/important"));
- intending(anyIntent())
- .respondWith(
- new Instrumentation.ActivityResult(Activity.RESULT_OK, new Intent()));
- mReceiver.onReceive(mContext, intent);
- intended(hasComponent(BluetoothOppTransferHistory.class.getName()));
- intended(hasExtra(Constants.EXTRA_DIRECTION, BluetoothShare.DIRECTION_INBOUND));
- } finally {
- BluetoothOppTestUtils.enableActivity(
- BluetoothOppTransferHistory.class, false, mContext);
- }
- }
-
- @Test
public void onReceive_withActionHide_contentUpdate() {
List<BluetoothOppTestUtils.CursorMockData> cursorMockDataList;
Cursor cursor = mock(Cursor.class);
diff --git a/android/app/tests/unit/src/com/android/bluetooth/opp/BluetoothOppTransferHistoryTest.java b/android/app/tests/unit/src/com/android/bluetooth/opp/BluetoothOppTransferHistoryTest.java
index e336cd354b..69d01b2853 100644
--- a/android/app/tests/unit/src/com/android/bluetooth/opp/BluetoothOppTransferHistoryTest.java
+++ b/android/app/tests/unit/src/com/android/bluetooth/opp/BluetoothOppTransferHistoryTest.java
@@ -44,7 +44,6 @@ import androidx.test.runner.AndroidJUnit4;
import com.android.bluetooth.BluetoothMethodProxy;
import com.android.bluetooth.R;
import com.android.bluetooth.TestUtils;
-import com.android.bluetooth.flags.Flags;
import com.google.common.base.Objects;
@@ -155,11 +154,7 @@ public class BluetoothOppTransferHistoryTest {
mTargetContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH));
BluetoothOppTestUtils.setUpMockCursor(mCursor, mCursorMockDataList);
- if (Flags.oppStartActivityDirectlyFromNotification()) {
- mIntent.setAction(Constants.ACTION_OPEN_INBOUND_TRANSFER);
- } else {
- mIntent.putExtra(Constants.EXTRA_DIRECTION, BluetoothShare.DIRECTION_INBOUND);
- }
+ mIntent.setAction(Constants.ACTION_OPEN_INBOUND_TRANSFER);
ActivityScenario.launch(mIntent);
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
@@ -178,11 +173,7 @@ public class BluetoothOppTransferHistoryTest {
1,
new BluetoothOppTestUtils.CursorMockData(
BluetoothShare.DIRECTION, 2, BluetoothShare.DIRECTION_OUTBOUND));
- if (Flags.oppStartActivityDirectlyFromNotification()) {
- mIntent.setAction(Constants.ACTION_OPEN_OUTBOUND_TRANSFER);
- } else {
- mIntent.putExtra(Constants.EXTRA_DIRECTION, BluetoothShare.DIRECTION_OUTBOUND);
- }
+ mIntent.setAction(Constants.ACTION_OPEN_OUTBOUND_TRANSFER);
ActivityScenario.launch(mIntent);
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
diff --git a/flags/opp.aconfig b/flags/opp.aconfig
index 1015eaac89..bd0f380c45 100644
--- a/flags/opp.aconfig
+++ b/flags/opp.aconfig
@@ -2,13 +2,6 @@ package: "com.android.bluetooth.flags"
container: "com.android.btservices"
flag {
- name: "opp_start_activity_directly_from_notification"
- namespace: "bluetooth"
- description: "Make OPP notification start activities directly from it, not via OppReceiver"
- bug: "319050411"
-}
-
-flag {
name: "opp_ignore_content_observer_after_service_stop"
namespace: "bluetooth"
description: "When OppService.stop() is called, previously posted ContentObserver.onChange() should not run"