From 1b6ab7ec90f67a2d1d254779bddb870022ddf2cb Mon Sep 17 00:00:00 2001 From: Weiyue Huang Date: Tue, 21 Feb 2023 14:14:14 +0800 Subject: [PATCH 1/5] Prevent the screen reader box from unexpected scrolling in dream setting page. Bug: 228355186 Test: manual Change-Id: I66a70d6b12bd3a2766e6879cb27c68a851d1dd87 Merged-In: I66a70d6b12bd3a2766e6879cb27c68a851d1dd87 (cherry picked from commit edfd262be29fd9f1de5750145bf7b3f08adc7adc) --- src/com/android/settings/dream/DreamSettings.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/com/android/settings/dream/DreamSettings.java b/src/com/android/settings/dream/DreamSettings.java index acc69731d0d..99fcfb9fd3a 100644 --- a/src/com/android/settings/dream/DreamSettings.java +++ b/src/com/android/settings/dream/DreamSettings.java @@ -195,6 +195,10 @@ public class DreamSettings extends DashboardFragment implements OnMainSwitchChan mPreviewButton.setOnClickListener(v -> dreamBackend.preview(dreamBackend.getActiveDream())); mRecyclerView = super.onCreateRecyclerView(inflater, parent, bundle); + // The enable/disable status change of the nested RecyclerView(Dream Picker) causes the + // focus moving. Make the RecyclerView unfocusable to prevent the unexpected scrolling when + // the focus changes in the TalkBack mode. + mRecyclerView.setFocusable(false); updatePaddingForPreviewButton(); return mRecyclerView; } From 7be7ef9eccf1974398dda25ccb3ac17aaf9ec4f4 Mon Sep 17 00:00:00 2001 From: jasonwshsu Date: Wed, 15 Mar 2023 19:43:58 +0800 Subject: [PATCH 2/5] Update the exclamation icon can be announced by screen reader * In hearing deivce and flash notifications U features. Bug: 268144365 Test: open screen reader to read the footer preference Change-Id: Ifb0809c1e445aea4aeea9db9b4ec09cd6d0d4095 --- res/values/strings.xml | 10 +++++- res/xml/accessibility_hearing_aids.xml | 3 +- res/xml/bluetooth_audio_routing_fragment.xml | 3 +- res/xml/flash_notifications_settings.xml | 7 ++-- res/xml/hearing_device_pairing_detail.xml | 3 +- ...tificationsFooterPreferenceController.java | 35 ++++++++++++++++++ ...aringDeviceFooterPreferenceController.java | 35 ++++++++++++++++++ ...aringDeviceFooterPreferenceController.java | 35 ++++++++++++++++++ ...udioRoutingFooterPreferenceController.java | 36 +++++++++++++++++++ 9 files changed, 160 insertions(+), 7 deletions(-) create mode 100644 src/com/android/settings/accessibility/FlashNotificationsFooterPreferenceController.java create mode 100644 src/com/android/settings/accessibility/HearingDeviceFooterPreferenceController.java create mode 100644 src/com/android/settings/accessibility/PairHearingDeviceFooterPreferenceController.java create mode 100644 src/com/android/settings/bluetooth/BluetoothDetailsAudioRoutingFooterPreferenceController.java diff --git a/res/values/strings.xml b/res/values/strings.xml index d6c069f62c6..4b0eb63b23e 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -136,6 +136,8 @@ Hearing device shortcut, hearing aid compatibility Audio output + + About audio output Route sounds to your hearing device or phone speaker @@ -4611,6 +4613,8 @@ %1$s +1 more Pair new device + + About Pair new device Hearing devices @@ -4623,6 +4627,8 @@ Hearing aid compatibility Improves compatibility with telecoils and reduces unwanted noise + + About hearing devices Make sure your hearing device is turned on and ready to pair @@ -11822,8 +11828,10 @@ Fingerprint sensor - + Flash notifications + + About flash notifications Off diff --git a/res/xml/accessibility_hearing_aids.xml b/res/xml/accessibility_hearing_aids.xml index 7ff571d7fe9..e813cf2b47d 100644 --- a/res/xml/accessibility_hearing_aids.xml +++ b/res/xml/accessibility_hearing_aids.xml @@ -57,5 +57,6 @@ android:key="hearing_device_footer" android:title="@string/accessibility_hearing_device_footer_summary" android:selectable="false" - settings:searchable="false" /> + settings:searchable="false" + settings:controller="com.android.settings.accessibility.HearingDeviceFooterPreferenceController"/> \ No newline at end of file diff --git a/res/xml/bluetooth_audio_routing_fragment.xml b/res/xml/bluetooth_audio_routing_fragment.xml index 854ab3f2b41..5edf6cdca41 100644 --- a/res/xml/bluetooth_audio_routing_fragment.xml +++ b/res/xml/bluetooth_audio_routing_fragment.xml @@ -64,6 +64,7 @@ android:key="hearing_device_footer" android:title="@string/bluetooth_audio_routing_footer_summary" android:selectable="false" - settings:searchable="false" /> + settings:searchable="false" + settings:controller="com.android.settings.bluetooth.BluetoothDetailsAudioRoutingFooterPreferenceController"/> diff --git a/res/xml/flash_notifications_settings.xml b/res/xml/flash_notifications_settings.xml index 52f0b103031..749648614ae 100644 --- a/res/xml/flash_notifications_settings.xml +++ b/res/xml/flash_notifications_settings.xml @@ -46,10 +46,11 @@ android:title="@string/flash_notifications_preview" settings:controller="com.android.settings.accessibility.FlashNotificationsPreviewPreferenceController" /> - + android:selectable="false" + settings:searchable="false" + settings:controller="com.android.settings.accessibility.FlashNotificationsFooterPreferenceController"/> diff --git a/res/xml/hearing_device_pairing_detail.xml b/res/xml/hearing_device_pairing_detail.xml index 65cc6c72a13..29a611879a7 100644 --- a/res/xml/hearing_device_pairing_detail.xml +++ b/res/xml/hearing_device_pairing_detail.xml @@ -37,6 +37,7 @@ android:key="hearing_device_footer" android:title="@string/accessibility_hearing_device_footer_summary" android:selectable="false" - settings:searchable="false" /> + settings:searchable="false" + settings:controller="com.android.settings.accessibility.PairHearingDeviceFooterPreferenceController"/> \ No newline at end of file diff --git a/src/com/android/settings/accessibility/FlashNotificationsFooterPreferenceController.java b/src/com/android/settings/accessibility/FlashNotificationsFooterPreferenceController.java new file mode 100644 index 00000000000..0847c37aa1a --- /dev/null +++ b/src/com/android/settings/accessibility/FlashNotificationsFooterPreferenceController.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.accessibility; + +import android.content.Context; + +import com.android.settings.R; + +/** Preference controller for footer in flash notifications page. */ +public class FlashNotificationsFooterPreferenceController extends + AccessibilityFooterPreferenceController { + public FlashNotificationsFooterPreferenceController(Context context, + String key) { + super(context, key); + } + + @Override + protected String getIntroductionTitle() { + return mContext.getString(R.string.flash_notifications_about_title); + } +} diff --git a/src/com/android/settings/accessibility/HearingDeviceFooterPreferenceController.java b/src/com/android/settings/accessibility/HearingDeviceFooterPreferenceController.java new file mode 100644 index 00000000000..cd92448392a --- /dev/null +++ b/src/com/android/settings/accessibility/HearingDeviceFooterPreferenceController.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.accessibility; + +import android.content.Context; + +import com.android.settings.R; + +/** Preference controller for footer in hearing device page. */ +public class HearingDeviceFooterPreferenceController extends + AccessibilityFooterPreferenceController { + public HearingDeviceFooterPreferenceController(Context context, + String key) { + super(context, key); + } + + @Override + protected String getIntroductionTitle() { + return mContext.getString(R.string.accessibility_hearing_device_about_title); + } +} diff --git a/src/com/android/settings/accessibility/PairHearingDeviceFooterPreferenceController.java b/src/com/android/settings/accessibility/PairHearingDeviceFooterPreferenceController.java new file mode 100644 index 00000000000..09396ffd50d --- /dev/null +++ b/src/com/android/settings/accessibility/PairHearingDeviceFooterPreferenceController.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.accessibility; + +import android.content.Context; + +import com.android.settings.R; + +/** Preference controller for footer in pair hearing device page. */ +public class PairHearingDeviceFooterPreferenceController extends + AccessibilityFooterPreferenceController { + public PairHearingDeviceFooterPreferenceController(Context context, + String key) { + super(context, key); + } + + @Override + protected String getIntroductionTitle() { + return mContext.getString(R.string.accessibility_pair_hearing_device_about_title); + } +} diff --git a/src/com/android/settings/bluetooth/BluetoothDetailsAudioRoutingFooterPreferenceController.java b/src/com/android/settings/bluetooth/BluetoothDetailsAudioRoutingFooterPreferenceController.java new file mode 100644 index 00000000000..d6bd0da43ff --- /dev/null +++ b/src/com/android/settings/bluetooth/BluetoothDetailsAudioRoutingFooterPreferenceController.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.bluetooth; + +import android.content.Context; + +import com.android.settings.R; +import com.android.settings.accessibility.AccessibilityFooterPreferenceController; + +/** Preference controller for footer in bluetooth details audio routing page. */ +public class BluetoothDetailsAudioRoutingFooterPreferenceController extends + AccessibilityFooterPreferenceController { + public BluetoothDetailsAudioRoutingFooterPreferenceController(Context context, + String key) { + super(context, key); + } + + @Override + protected String getIntroductionTitle() { + return mContext.getString(R.string.bluetooth_audio_routing_about_title); + } +} From 07114a6d0076a63472c689215f45cf2c2bade4d5 Mon Sep 17 00:00:00 2001 From: SongFerngWang Date: Fri, 17 Mar 2023 12:37:29 +0800 Subject: [PATCH 3/5] Close the dialog activity when user click cancel or background Bug: 241346100 Test: local test Change-Id: Id9d931fc8b74ef566ffe3c6135aaf433cd9f770b --- .../settings/bluetooth/BluetoothBroadcastDialog.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/com/android/settings/bluetooth/BluetoothBroadcastDialog.java b/src/com/android/settings/bluetooth/BluetoothBroadcastDialog.java index b9cc29ef144..7fa63b06afc 100644 --- a/src/com/android/settings/bluetooth/BluetoothBroadcastDialog.java +++ b/src/com/android/settings/bluetooth/BluetoothBroadcastDialog.java @@ -19,6 +19,7 @@ package com.android.settings.bluetooth; import android.app.Dialog; import android.app.settings.SettingsEnums; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.text.TextUtils; @@ -27,6 +28,7 @@ import android.view.View; import android.widget.Button; import android.widget.TextView; +import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; import com.android.settings.R; @@ -128,6 +130,12 @@ public class BluetoothBroadcastDialog extends InstrumentedDialogFragment { return SettingsEnums.DIALOG_LE_AUDIO_BROADCAST; } + @Override + public void onCancel(@NonNull DialogInterface dialog) { + dismiss(); + getActivity().finish(); + } + private void launchFindBroadcastsActivity() { Bundle bundle = new Bundle(); bundle.putString(KEY_DEVICE_ADDRESS, mDeviceAddress); From 74dc069d16d569a0632675dd4db0b1626bfaf01b Mon Sep 17 00:00:00 2001 From: changbetty Date: Wed, 8 Mar 2023 06:14:23 +0000 Subject: [PATCH 4/5] [LE Audio] Set activity for result after scanning the QR code Bug: 263554347 Bug: 265281156 Bug: 248409874 Test: manual test Change-Id: Ia252f29ad9dfdc09266e91cc9ecaa32ed8c749c2 --- res/values/strings.xml | 3 +- .../BluetoothFindBroadcastsFragment.java | 39 ++++++++++++ ...uetoothFindBroadcastsHeaderController.java | 3 +- .../bluetooth/QrCodeScanModeController.java | 63 ------------------- .../bluetooth/QrCodeScanModeFragment.java | 14 +++-- 5 files changed, 51 insertions(+), 71 deletions(-) delete mode 100644 src/com/android/settings/bluetooth/QrCodeScanModeController.java diff --git a/res/values/strings.xml b/res/values/strings.xml index a79b1d4d877..7670cf4f814 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -11773,7 +11773,8 @@ Can\u2019t connect. Try again. Wrong password - + + Can\u2019t join the broadcast To start listening, center the QR code below diff --git a/src/com/android/settings/bluetooth/BluetoothFindBroadcastsFragment.java b/src/com/android/settings/bluetooth/BluetoothFindBroadcastsFragment.java index a365b42190a..05bc179ac26 100644 --- a/src/com/android/settings/bluetooth/BluetoothFindBroadcastsFragment.java +++ b/src/com/android/settings/bluetooth/BluetoothFindBroadcastsFragment.java @@ -19,6 +19,7 @@ package com.android.settings.bluetooth; import static android.bluetooth.BluetoothDevice.BOND_NONE; import static android.os.UserManager.DISALLOW_CONFIG_BLUETOOTH; +import android.app.Activity; import android.app.AlertDialog; import android.app.settings.SettingsEnums; import android.bluetooth.BluetoothDevice; @@ -27,6 +28,7 @@ import android.bluetooth.BluetoothLeBroadcastMetadata; import android.bluetooth.BluetoothLeBroadcastReceiveState; import android.bluetooth.le.ScanFilter; import android.content.Context; +import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; @@ -34,6 +36,7 @@ import android.view.View; import android.view.WindowManager; import android.widget.EditText; import android.widget.TextView; +import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; @@ -43,6 +46,7 @@ import com.android.settings.R; import com.android.settings.dashboard.RestrictedDashboardFragment; import com.android.settingslib.bluetooth.CachedBluetoothDevice; import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcastAssistant; +import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcastMetadata; import com.android.settingslib.bluetooth.LocalBluetoothManager; import com.android.settingslib.bluetooth.LocalBluetoothProfileManager; import com.android.settingslib.core.AbstractPreferenceController; @@ -65,6 +69,7 @@ public class BluetoothFindBroadcastsFragment extends RestrictedDashboardFragment public static final String KEY_DEVICE_ADDRESS = "device_address"; public static final String PREF_KEY_BROADCAST_SOURCE_LIST = "broadcast_source_list"; + public static final int REQUEST_SCAN_BT_BROADCAST_QR_CODE = 0; @VisibleForTesting String mDeviceAddress; @@ -79,6 +84,7 @@ public class BluetoothFindBroadcastsFragment extends RestrictedDashboardFragment BluetoothFindBroadcastsHeaderController mBluetoothFindBroadcastsHeaderController; private LocalBluetoothLeBroadcastAssistant mLeBroadcastAssistant; + private LocalBluetoothLeBroadcastMetadata mLocalBroadcastMetadata; private Executor mExecutor; private int mSourceId; @@ -183,6 +189,7 @@ public class BluetoothFindBroadcastsFragment extends RestrictedDashboardFragment mCachedDevice = getCachedDevice(mDeviceAddress); mLeBroadcastAssistant = getLeBroadcastAssistant(); mExecutor = Executors.newSingleThreadExecutor(); + mLocalBroadcastMetadata = new LocalBluetoothLeBroadcastMetadata(); super.onAttach(context); if (mCachedDevice == null || mLeBroadcastAssistant == null) { @@ -229,6 +236,34 @@ public class BluetoothFindBroadcastsFragment extends RestrictedDashboardFragment } } + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + Log.d(TAG, "onActivityResult: " + requestCode + ", resultCode: " + resultCode); + if (requestCode == REQUEST_SCAN_BT_BROADCAST_QR_CODE) { + if (resultCode == Activity.RESULT_OK) { + + //Get BroadcastMetadata + String broadcastMetadata = data.getStringExtra( + QrCodeScanModeFragment.KEY_BROADCAST_METADATA); + BluetoothLeBroadcastMetadata source = convertToBroadcastMetadata(broadcastMetadata); + + if (source != null) { + Log.d(TAG, "onActivityResult source Id = " + source.getBroadcastId()); + //Create preference for the broadcast source + updateListCategoryFromBroadcastMetadata(source, false); + //Add Source + addSource(mBroadcastSourceListCategory.findPreference( + Integer.toString(source.getBroadcastId()))); + } else { + Toast.makeText(getContext(), + R.string.find_broadcast_join_broadcast_error, Toast.LENGTH_SHORT).show(); + return; + } + } + } + } + @VisibleForTesting void finishFragmentIfNecessary() { if (mCachedDevice.getBondState() == BOND_NONE) { @@ -466,4 +501,8 @@ public class BluetoothFindBroadcastsFragment extends RestrictedDashboardFragment public void setSourceId(int sourceId) { mSourceId = sourceId; } + + private BluetoothLeBroadcastMetadata convertToBroadcastMetadata(String qrCodeString) { + return mLocalBroadcastMetadata.convertToBroadcastMetadata(qrCodeString); + } } diff --git a/src/com/android/settings/bluetooth/BluetoothFindBroadcastsHeaderController.java b/src/com/android/settings/bluetooth/BluetoothFindBroadcastsHeaderController.java index 1282abda18e..d34476bada5 100644 --- a/src/com/android/settings/bluetooth/BluetoothFindBroadcastsHeaderController.java +++ b/src/com/android/settings/bluetooth/BluetoothFindBroadcastsHeaderController.java @@ -137,7 +137,8 @@ public class BluetoothFindBroadcastsHeaderController extends BluetoothDetailsCon .putExtra(BluetoothBroadcastUtils.EXTRA_BLUETOOTH_SINK_IS_GROUP, true) .putExtra(BluetoothBroadcastUtils.EXTRA_BLUETOOTH_DEVICE_SINK, mCachedDevice.getDevice()); - mContext.startActivity(intent); + mBluetoothFindBroadcastsFragment.startActivityForResult(intent, + BluetoothFindBroadcastsFragment.REQUEST_SCAN_BT_BROADCAST_QR_CODE); } @Override diff --git a/src/com/android/settings/bluetooth/QrCodeScanModeController.java b/src/com/android/settings/bluetooth/QrCodeScanModeController.java deleted file mode 100644 index 4504b4b71aa..00000000000 --- a/src/com/android/settings/bluetooth/QrCodeScanModeController.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Copyright (C) 2022 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.settings.bluetooth; - -import android.bluetooth.BluetoothDevice; -import android.bluetooth.BluetoothLeBroadcastMetadata; -import android.content.Context; -import android.util.Log; - -import com.android.settingslib.bluetooth.BluetoothUtils; -import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager; -import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcastAssistant; -import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcastMetadata; -import com.android.settingslib.bluetooth.LocalBluetoothManager; -import com.android.settingslib.bluetooth.LocalBluetoothProfileManager; - -public class QrCodeScanModeController { - - private static final boolean DEBUG = BluetoothUtils.D; - private static final String TAG = "QrCodeScanModeController"; - - private LocalBluetoothLeBroadcastMetadata mLocalBroadcastMetadata; - private LocalBluetoothLeBroadcastAssistant mLocalBroadcastAssistant; - private LocalBluetoothManager mLocalBluetoothManager; - private LocalBluetoothProfileManager mProfileManager; - - public QrCodeScanModeController(Context context) { - if (DEBUG) { - Log.d(TAG, "QrCodeScanModeController constructor."); - } - mLocalBluetoothManager = Utils.getLocalBtManager(context); - mProfileManager = mLocalBluetoothManager.getProfileManager(); - mLocalBroadcastMetadata = new LocalBluetoothLeBroadcastMetadata(); - CachedBluetoothDeviceManager cachedDeviceManager = new CachedBluetoothDeviceManager(context, - mLocalBluetoothManager); - mLocalBroadcastAssistant = new LocalBluetoothLeBroadcastAssistant(context, - cachedDeviceManager, mProfileManager); - } - - private BluetoothLeBroadcastMetadata convertToBroadcastMetadata(String qrCodeString) { - return mLocalBroadcastMetadata.convertToBroadcastMetadata(qrCodeString); - } - - public void addSource(BluetoothDevice sink, String sourceMetadata, - boolean isGroupOp) { - mLocalBroadcastAssistant.addSource(sink, - convertToBroadcastMetadata(sourceMetadata), isGroupOp); - } -} diff --git a/src/com/android/settings/bluetooth/QrCodeScanModeFragment.java b/src/com/android/settings/bluetooth/QrCodeScanModeFragment.java index d53e2d42209..f89dac6f935 100644 --- a/src/com/android/settings/bluetooth/QrCodeScanModeFragment.java +++ b/src/com/android/settings/bluetooth/QrCodeScanModeFragment.java @@ -16,9 +16,11 @@ package com.android.settings.bluetooth; +import android.app.Activity; import android.app.settings.SettingsEnums; import android.bluetooth.BluetoothDevice; import android.content.Context; +import android.content.Intent; import android.graphics.Matrix; import android.graphics.Outline; import android.graphics.Rect; @@ -67,13 +69,14 @@ public class QrCodeScanModeFragment extends InstrumentedFragment implements private static final Duration VIBRATE_DURATION_QR_CODE_RECOGNITION = Duration.ofMillis(3); + public static final String KEY_BROADCAST_METADATA = "key_broadcast_metadata"; + private boolean mIsGroupOp; private int mCornerRadius; private BluetoothDevice mSink; private String mBroadcastMetadata; private Context mContext; private QrCamera mCamera; - private QrCodeScanModeController mController; private TextureView mTextureView; private TextView mSummary; private TextView mErrorMessage; @@ -87,7 +90,6 @@ public class QrCodeScanModeFragment extends InstrumentedFragment implements public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mContext = getContext(); - mController = new QrCodeScanModeController(mContext); } @Override @@ -215,10 +217,10 @@ public class QrCodeScanModeFragment extends InstrumentedFragment implements break; case MESSAGE_SCAN_BROADCAST_SUCCESS: - /* TODO(b/265281156) : Move the logic to BluetoothFindBroadcastsFragment. - * We only pass the QR code string to the previous page. - */ - mController.addSource(mSink, mBroadcastMetadata, mIsGroupOp); + Log.d(TAG, "scan success"); + final Intent resultIntent = new Intent(); + resultIntent.putExtra(KEY_BROADCAST_METADATA, mBroadcastMetadata); + getActivity().setResult(Activity.RESULT_OK, resultIntent); notifyUserForQrCodeRecognition(); break; default: From 12066c72f95a0ec0484370f00d216c6b870f4cef Mon Sep 17 00:00:00 2001 From: SongFerngWang Date: Fri, 17 Mar 2023 18:36:07 +0800 Subject: [PATCH 5/5] Update OpenNetworkSelect UI at main thread Bug: 270652395 Test: local test and atest AutoSelectPreferenceControllerTest Change-Id: Idfc7a07106d552c35a94414bb14eac0fbdc3974f --- .../telephony/gsm/AutoSelectPreferenceController.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java b/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java index f46a45232a7..c0b903df3c4 100644 --- a/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java +++ b/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java @@ -211,6 +211,7 @@ public class AutoSelectPreferenceController extends TelephonyTogglePreferenceCon mSwitchPreference.setChecked(isChecked()); } mRecursiveUpdate.decrementAndGet(); + updateListenerValue(); dismissProgressBar(); }); }); @@ -245,13 +246,13 @@ public class AutoSelectPreferenceController extends TelephonyTogglePreferenceCon ThreadUtils.postOnBackgroundThread(() -> { queryNetworkSelectionMode(INTERNAL_LOG_TAG_INIT); - //Update UI in UI thread mUiHandler.post(() -> { if (mSwitchPreference != null) { mRecursiveUpdate.getAndIncrement(); mSwitchPreference.setChecked(isChecked()); mRecursiveUpdate.decrementAndGet(); + updateListenerValue(); } }); }); @@ -267,7 +268,6 @@ public class AutoSelectPreferenceController extends TelephonyTogglePreferenceCon private void queryNetworkSelectionMode(String tag) { mCacheOfModeStatus = mTelephonyManager.getNetworkSelectionMode(); Log.d(LOG_TAG, tag + ": query commend done. mCacheOfModeStatus: " + mCacheOfModeStatus); - updateListenerValue(); } @VisibleForTesting @@ -284,12 +284,11 @@ public class AutoSelectPreferenceController extends TelephonyTogglePreferenceCon } mCacheOfModeStatus = networkSelectionMode; Log.d(LOG_TAG, "updateUiAutoSelectValue: mCacheOfModeStatus: " + mCacheOfModeStatus); - updateListenerValue(); mRecursiveUpdate.getAndIncrement(); updateState(mSwitchPreference); mRecursiveUpdate.decrementAndGet(); - + updateListenerValue(); } }