Files
packages_apps_Settings/src/com/android/settings/connecteddevice/audiosharing/AudioSharingJoinHandlerDashboardFragment.java
Yiyi Shen f23bda264a [Audiosharing] Refresh the dialog handling onNewIntent
If an instance of the activity already exists at the top of the current task, the system routes the intent to that instance through a call to its onNewIntent() method, rather than creating a new instance of the activity.

So we need manually trigger the handling logic in onNewIntent to refresh
the dialogs.

Test: atest
Flag: com.android.settingslib.flags.promote_audio_sharing_for_second_auto_connected_lea_device
Bug: 395786392
Change-Id: Iccb0ef649ee60cb97f7557943760f854d31ccc80
2025-03-03 13:12:10 +08:00

80 lines
2.6 KiB
Java

/*
* Copyright (C) 2025 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.connecteddevice.audiosharing;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settingslib.utils.ThreadUtils;
public class AudioSharingJoinHandlerDashboardFragment extends DashboardFragment {
private static final String TAG = "AudioSharingJoinHandlerFrag";
@Nullable private AudioSharingJoinHandlerController mController;
@Override
public int getMetricsCategory() {
// TODO: use real enum
return 0;
}
@Override
protected int getPreferenceScreenResId() {
return R.xml.bluetooth_le_audio_sharing_join_handler;
}
@Override
protected String getLogTag() {
return TAG;
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
mController = use(AudioSharingJoinHandlerController.class);
if (mController != null) {
Log.d(TAG, "onAttach, init controller");
mController.init(this);
}
}
/** Handle just connected device via intent. */
public void handleDeviceConnectedFromIntent(@NonNull Intent intent) {
var unused =
ThreadUtils.postOnBackgroundThread(
() -> {
if (mController != null) {
Log.d(TAG, "handleDeviceConnectedFromIntent");
mController.handleDeviceConnectedFromIntent(intent);
}
});
}
/** Test only: set mock controllers for the {@link AudioSharingJoinHandlerDashboardFragment} */
@VisibleForTesting
void setController(AudioSharingJoinHandlerController controller) {
mController = controller;
}
}