[Audiosharing] Start creating view after service is connected in confirm dialog activity.
Test: atest Change-Id: If68621e0782c9639fc196385d0f42052d8f06798
This commit is contained in:
@@ -283,7 +283,7 @@ public class SettingsActivity extends SettingsBaseActivity
|
|||||||
createUiFromIntent(savedState, intent);
|
createUiFromIntent(savedState, intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createUiFromIntent(Bundle savedState, Intent intent) {
|
protected void createUiFromIntent(@Nullable Bundle savedState, Intent intent) {
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
final FeatureFactory factory = FeatureFactory.getFeatureFactory();
|
final FeatureFactory factory = FeatureFactory.getFeatureFactory();
|
||||||
|
@@ -16,17 +16,91 @@
|
|||||||
|
|
||||||
package com.android.settings.connecteddevice.audiosharing.audiostreams;
|
package com.android.settings.connecteddevice.audiosharing.audiostreams;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.android.settings.SettingsActivity;
|
import com.android.settings.SettingsActivity;
|
||||||
|
import com.android.settings.bluetooth.Utils;
|
||||||
|
import com.android.settings.connecteddevice.audiosharing.AudioSharingUtils;
|
||||||
|
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
||||||
|
|
||||||
public class AudioStreamConfirmDialogActivity extends SettingsActivity {
|
public class AudioStreamConfirmDialogActivity extends SettingsActivity
|
||||||
|
implements LocalBluetoothProfileManager.ServiceListener {
|
||||||
|
private static final String TAG = "AudioStreamConfirmDialogActivity";
|
||||||
|
@Nullable private LocalBluetoothProfileManager mProfileManager;
|
||||||
|
@Nullable private Bundle mSavedState;
|
||||||
|
@Nullable private Intent mIntent;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isToolbarEnabled() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedState) {
|
protected void onCreate(Bundle savedState) {
|
||||||
|
var localBluetoothManager = Utils.getLocalBluetoothManager(this);
|
||||||
|
mProfileManager =
|
||||||
|
localBluetoothManager == null ? null : localBluetoothManager.getProfileManager();
|
||||||
super.onCreate(savedState);
|
super.onCreate(savedState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void createUiFromIntent(@Nullable Bundle savedState, Intent intent) {
|
||||||
|
if (AudioSharingUtils.isFeatureEnabled()
|
||||||
|
&& !AudioSharingUtils.isAudioSharingProfileReady(mProfileManager)) {
|
||||||
|
Log.d(TAG, "createUiFromIntent() : supported but not ready, skip createUiFromIntent");
|
||||||
|
mSavedState = savedState;
|
||||||
|
mIntent = intent;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.d(
|
||||||
|
TAG,
|
||||||
|
"createUiFromIntent() : not supported or already connected, starting"
|
||||||
|
+ " createUiFromIntent");
|
||||||
|
super.createUiFromIntent(savedState, intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
if (AudioSharingUtils.isFeatureEnabled()
|
||||||
|
&& !AudioSharingUtils.isAudioSharingProfileReady(mProfileManager)) {
|
||||||
|
Log.d(TAG, "onStart() : supported but not ready, listen to service ready");
|
||||||
|
if (mProfileManager != null) {
|
||||||
|
mProfileManager.addServiceListener(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.onStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop() {
|
||||||
|
if (mProfileManager != null) {
|
||||||
|
mProfileManager.removeServiceListener(this);
|
||||||
|
}
|
||||||
|
super.onStop();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onServiceConnected() {
|
||||||
|
if (AudioSharingUtils.isFeatureEnabled()
|
||||||
|
&& AudioSharingUtils.isAudioSharingProfileReady(mProfileManager)) {
|
||||||
|
if (mProfileManager != null) {
|
||||||
|
mProfileManager.removeServiceListener(this);
|
||||||
|
}
|
||||||
|
if (mIntent != null) {
|
||||||
|
Log.d(TAG, "onServiceConnected() : service ready, starting createUiFromIntent");
|
||||||
|
super.createUiFromIntent(mSavedState, mIntent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onServiceDisconnected() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isValidFragment(String fragmentName) {
|
protected boolean isValidFragment(String fragmentName) {
|
||||||
return AudioStreamConfirmDialog.class.getName().equals(fragmentName);
|
return AudioStreamConfirmDialog.class.getName().equals(fragmentName);
|
||||||
|
Reference in New Issue
Block a user