Snap for 12630846 from 5a06b74ef1
to 25Q1-release
Change-Id: I8e800ed5dd76871a79714be11af493fe59950e98
This commit is contained in:
@@ -22,7 +22,8 @@
|
|||||||
|
|
||||||
<com.android.settingslib.widget.TopIntroPreference
|
<com.android.settingslib.widget.TopIntroPreference
|
||||||
android:key="captioning_intro"
|
android:key="captioning_intro"
|
||||||
android:title="@string/accessibility_captioning_preference_intro"/>
|
android:title="@string/accessibility_captioning_preference_intro"
|
||||||
|
settings:searchable="false"/>
|
||||||
|
|
||||||
<com.android.settingslib.widget.IllustrationPreference
|
<com.android.settingslib.widget.IllustrationPreference
|
||||||
android:key="captioning_preview"
|
android:key="captioning_preview"
|
||||||
@@ -44,7 +45,8 @@
|
|||||||
<Preference
|
<Preference
|
||||||
android:fragment="com.android.settings.accessibility.CaptioningMoreOptionsFragment"
|
android:fragment="com.android.settings.accessibility.CaptioningMoreOptionsFragment"
|
||||||
android:key="captioning_more_options"
|
android:key="captioning_more_options"
|
||||||
android:title="@string/captioning_more_options_title" />
|
android:title="@string/captioning_more_options_title"
|
||||||
|
settings:searchable="false" />
|
||||||
|
|
||||||
<com.android.settings.accessibility.AccessibilityFooterPreference
|
<com.android.settings.accessibility.AccessibilityFooterPreference
|
||||||
android:key="captioning_settings_footer"
|
android:key="captioning_settings_footer"
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
settings:allowDividerAbove="true"
|
settings:allowDividerAbove="true"
|
||||||
settings:keywords="@string/keywords_internet"
|
settings:keywords="@string/keywords_internet"
|
||||||
settings:useAdminDisabledSummary="true"
|
settings:useAdminDisabledSummary="true"
|
||||||
|
settings:userRestriction="no_config_wifi"
|
||||||
settings:controller="com.android.settings.network.InternetPreferenceControllerV2" />
|
settings:controller="com.android.settings.network.InternetPreferenceControllerV2" />
|
||||||
|
|
||||||
<com.android.settingslib.RestrictedPreference
|
<com.android.settingslib.RestrictedPreference
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.accessibility;
|
package com.android.settings.accessibility;
|
||||||
|
|
||||||
|
import android.annotation.Nullable;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
@@ -39,6 +40,7 @@ import java.util.List;
|
|||||||
public class CaptioningCustomController extends BasePreferenceController
|
public class CaptioningCustomController extends BasePreferenceController
|
||||||
implements LifecycleObserver, OnStart, OnStop {
|
implements LifecycleObserver, OnStart, OnStop {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
private Preference mCustom;
|
private Preference mCustom;
|
||||||
private final CaptionHelper mCaptionHelper;
|
private final CaptionHelper mCaptionHelper;
|
||||||
private final ContentResolver mContentResolver;
|
private final ContentResolver mContentResolver;
|
||||||
@@ -50,32 +52,41 @@ public class CaptioningCustomController extends BasePreferenceController
|
|||||||
);
|
);
|
||||||
|
|
||||||
public CaptioningCustomController(Context context, String preferenceKey) {
|
public CaptioningCustomController(Context context, String preferenceKey) {
|
||||||
super(context, preferenceKey);
|
this(context, preferenceKey, new CaptionHelper(context),
|
||||||
mCaptionHelper = new CaptionHelper(context);
|
new AccessibilitySettingsContentObserver(new Handler(Looper.getMainLooper())));
|
||||||
mContentResolver = context.getContentResolver();
|
|
||||||
mSettingsContentObserver = new AccessibilitySettingsContentObserver(
|
|
||||||
new Handler(Looper.getMainLooper()));
|
|
||||||
mSettingsContentObserver.registerKeysToObserverCallback(CAPTIONING_FEATURE_KEYS,
|
|
||||||
key -> refreshShowingCustom());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
CaptioningCustomController(Context context, String preferenceKey,
|
CaptioningCustomController(
|
||||||
|
Context context, String preferenceKey, CaptionHelper captionHelper,
|
||||||
AccessibilitySettingsContentObserver contentObserver) {
|
AccessibilitySettingsContentObserver contentObserver) {
|
||||||
this(context, preferenceKey);
|
super(context, preferenceKey);
|
||||||
|
mCaptionHelper = new CaptionHelper(context);
|
||||||
|
mContentResolver = context.getContentResolver();
|
||||||
mSettingsContentObserver = contentObserver;
|
mSettingsContentObserver = contentObserver;
|
||||||
|
mSettingsContentObserver.registerKeysToObserverCallback(CAPTIONING_FEATURE_KEYS, key -> {
|
||||||
|
if (mCustom != null) {
|
||||||
|
mCustom.setVisible(shouldShowPreference());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return AVAILABLE;
|
if (com.android.settings.accessibility.Flags.fixA11ySettingsSearch()) {
|
||||||
|
return (shouldShowPreference()) ? AVAILABLE : AVAILABLE_UNSEARCHABLE;
|
||||||
|
} else {
|
||||||
|
return AVAILABLE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void displayPreference(PreferenceScreen screen) {
|
public void displayPreference(PreferenceScreen screen) {
|
||||||
super.displayPreference(screen);
|
super.displayPreference(screen);
|
||||||
mCustom = screen.findPreference(getPreferenceKey());
|
mCustom = screen.findPreference(getPreferenceKey());
|
||||||
refreshShowingCustom();
|
if (mCustom != null) {
|
||||||
|
mCustom.setVisible(shouldShowPreference());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -88,9 +99,7 @@ public class CaptioningCustomController extends BasePreferenceController
|
|||||||
mSettingsContentObserver.unregister(mContentResolver);
|
mSettingsContentObserver.unregister(mContentResolver);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshShowingCustom() {
|
private boolean shouldShowPreference() {
|
||||||
final boolean isCustomPreset =
|
return mCaptionHelper.getRawUserStyle() == CaptioningManager.CaptionStyle.PRESET_CUSTOM;
|
||||||
mCaptionHelper.getRawUserStyle() == CaptioningManager.CaptionStyle.PRESET_CUSTOM;
|
|
||||||
mCustom.setVisible(isCustomPreset);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,10 +19,12 @@ package com.android.settings.accessibility;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.view.accessibility.CaptioningManager;
|
||||||
import android.view.accessibility.CaptioningManager.CaptionStyle;
|
import android.view.accessibility.CaptioningManager.CaptionStyle;
|
||||||
|
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.accessibility.ListDialogPreference.OnValueChangedListener;
|
import com.android.settings.accessibility.ListDialogPreference.OnValueChangedListener;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
@@ -34,14 +36,26 @@ public class CaptioningWindowColorController extends BasePreferenceController
|
|||||||
private final CaptionHelper mCaptionHelper;
|
private final CaptionHelper mCaptionHelper;
|
||||||
private int mCachedNonDefaultOpacity = CaptionStyle.COLOR_UNSPECIFIED;
|
private int mCachedNonDefaultOpacity = CaptionStyle.COLOR_UNSPECIFIED;
|
||||||
|
|
||||||
public CaptioningWindowColorController(Context context, String preferenceKey) {
|
@VisibleForTesting
|
||||||
|
CaptioningWindowColorController(Context context, String preferenceKey,
|
||||||
|
CaptionHelper captionHelper) {
|
||||||
super(context, preferenceKey);
|
super(context, preferenceKey);
|
||||||
mCaptionHelper = new CaptionHelper(context);
|
mCaptionHelper = captionHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CaptioningWindowColorController(Context context, String preferenceKey) {
|
||||||
|
this(context, preferenceKey, new CaptionHelper(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return AVAILABLE;
|
if (com.android.settings.accessibility.Flags.fixA11ySettingsSearch()) {
|
||||||
|
return (mCaptionHelper.getRawUserStyle()
|
||||||
|
== CaptioningManager.CaptionStyle.PRESET_CUSTOM)
|
||||||
|
? AVAILABLE : AVAILABLE_UNSEARCHABLE;
|
||||||
|
} else {
|
||||||
|
return AVAILABLE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -18,9 +18,11 @@ package com.android.settings.accessibility;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.view.accessibility.CaptioningManager;
|
||||||
|
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.accessibility.ListDialogPreference.OnValueChangedListener;
|
import com.android.settings.accessibility.ListDialogPreference.OnValueChangedListener;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
@@ -31,14 +33,26 @@ public class CaptioningWindowOpacityController extends BasePreferenceController
|
|||||||
|
|
||||||
private final CaptionHelper mCaptionHelper;
|
private final CaptionHelper mCaptionHelper;
|
||||||
|
|
||||||
public CaptioningWindowOpacityController(Context context, String preferenceKey) {
|
@VisibleForTesting
|
||||||
|
CaptioningWindowOpacityController(Context context, String preferenceKey,
|
||||||
|
CaptionHelper captionHelper) {
|
||||||
super(context, preferenceKey);
|
super(context, preferenceKey);
|
||||||
mCaptionHelper = new CaptionHelper(context);
|
mCaptionHelper = captionHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CaptioningWindowOpacityController(Context context, String preferenceKey) {
|
||||||
|
this(context, preferenceKey, new CaptionHelper(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return AVAILABLE;
|
if (com.android.settings.accessibility.Flags.fixA11ySettingsSearch()) {
|
||||||
|
return (mCaptionHelper.getRawUserStyle()
|
||||||
|
== CaptioningManager.CaptionStyle.PRESET_CUSTOM)
|
||||||
|
? AVAILABLE : AVAILABLE_UNSEARCHABLE;
|
||||||
|
} else {
|
||||||
|
return AVAILABLE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -20,6 +20,7 @@ package com.android.settings.accounts;
|
|||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
import android.accounts.AuthenticatorDescription;
|
import android.accounts.AuthenticatorDescription;
|
||||||
import android.content.ClipData;
|
import android.content.ClipData;
|
||||||
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
@@ -186,9 +187,9 @@ public class AccountTypePreferenceLoader {
|
|||||||
prefIntent, mUserHandle);
|
prefIntent, mUserHandle);
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG,
|
Log.e(TAG,
|
||||||
"Refusing to launch authenticator intent because"
|
"Refusing to launch authenticator intent because "
|
||||||
+ "it exploits Settings permissions: "
|
+ "it exploits Settings permissions: "
|
||||||
+ prefIntent);
|
+ prefIntent);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -242,13 +243,19 @@ public class AccountTypePreferenceLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if the supplied Intent is safe. A safe intent is one that is
|
* Determines if the supplied Intent is safe. A safe intent is one that
|
||||||
* will launch a exported=true activity or owned by the same uid as the
|
* will launch an exported=true activity or owned by the same uid as the
|
||||||
* authenticator supplying the intent.
|
* authenticator supplying the intent.
|
||||||
*/
|
*/
|
||||||
private boolean isSafeIntent(PackageManager pm, Intent intent, String acccountType) {
|
@VisibleForTesting
|
||||||
|
boolean isSafeIntent(PackageManager pm, Intent intent, String accountType) {
|
||||||
|
if (TextUtils.equals(intent.getScheme(), ContentResolver.SCHEME_CONTENT)) {
|
||||||
|
Log.e(TAG, "Intent with a content scheme is unsafe.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
AuthenticatorDescription authDesc =
|
AuthenticatorDescription authDesc =
|
||||||
mAuthenticatorHelper.getAccountTypeDescription(acccountType);
|
mAuthenticatorHelper.getAccountTypeDescription(accountType);
|
||||||
ResolveInfo resolveInfo = pm.resolveActivityAsUser(intent, 0, mUserHandle.getIdentifier());
|
ResolveInfo resolveInfo = pm.resolveActivityAsUser(intent, 0, mUserHandle.getIdentifier());
|
||||||
if (resolveInfo == null) {
|
if (resolveInfo == null) {
|
||||||
return false;
|
return false;
|
||||||
|
@@ -77,9 +77,9 @@ public class AvailableMediaBluetoothDeviceUpdater extends BluetoothDeviceUpdater
|
|||||||
// It would show in Available Devices group if the audio sharing flag is disabled or
|
// It would show in Available Devices group if the audio sharing flag is disabled or
|
||||||
// the device is not in the audio sharing session.
|
// the device is not in the audio sharing session.
|
||||||
if (cachedDevice.isConnectedLeAudioDevice()) {
|
if (cachedDevice.isConnectedLeAudioDevice()) {
|
||||||
if (BluetoothUtils.isAudioSharingEnabled()
|
if (BluetoothUtils.isAudioSharingUIAvailable(mContext)
|
||||||
&& BluetoothUtils.hasConnectedBroadcastSource(
|
&& BluetoothUtils.hasConnectedBroadcastSource(
|
||||||
cachedDevice, mLocalBtManager)) {
|
cachedDevice, mLocalBtManager)) {
|
||||||
Log.d(
|
Log.d(
|
||||||
TAG,
|
TAG,
|
||||||
"Filter out device : "
|
"Filter out device : "
|
||||||
|
@@ -228,19 +228,19 @@ public abstract class BluetoothDevicePairingDetailBase extends DeviceListPrefere
|
|||||||
final BluetoothDevice device = cachedDevice.getDevice();
|
final BluetoothDevice device = cachedDevice.getDevice();
|
||||||
if (device != null
|
if (device != null
|
||||||
&& mSelectedList.contains(device)) {
|
&& mSelectedList.contains(device)) {
|
||||||
if (!BluetoothUtils.isAudioSharingEnabled()) {
|
if (BluetoothUtils.isAudioSharingUIAvailable(getContext())) {
|
||||||
|
if (bluetoothProfile == BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT
|
||||||
|
&& state == BluetoothAdapter.STATE_CONNECTED
|
||||||
|
&& device.equals(mJustBonded)
|
||||||
|
&& mShouldTriggerAudioSharingShareThenPairFlow) {
|
||||||
|
Log.d(getLogTag(),
|
||||||
|
"onProfileConnectionStateChanged, assistant profile connected");
|
||||||
|
dismissConnectingDialog();
|
||||||
|
mHandler.removeMessages(AUTO_DISMISS_MESSAGE_ID);
|
||||||
|
finishFragmentWithResultForAudioSharing(device);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
finish();
|
finish();
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (bluetoothProfile == BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT
|
|
||||||
&& state == BluetoothAdapter.STATE_CONNECTED
|
|
||||||
&& device.equals(mJustBonded)
|
|
||||||
&& mShouldTriggerAudioSharingShareThenPairFlow) {
|
|
||||||
Log.d(getLogTag(),
|
|
||||||
"onProfileConnectionStateChanged, assistant profile connected");
|
|
||||||
dismissConnectingDialog();
|
|
||||||
mHandler.removeMessages(AUTO_DISMISS_MESSAGE_ID);
|
|
||||||
finishFragmentWithResultForAudioSharing(device);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
onDeviceDeleted(cachedDevice);
|
onDeviceDeleted(cachedDevice);
|
||||||
@@ -309,15 +309,17 @@ public abstract class BluetoothDevicePairingDetailBase extends DeviceListPrefere
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
boolean shouldTriggerAudioSharingShareThenPairFlow() {
|
boolean shouldTriggerAudioSharingShareThenPairFlow() {
|
||||||
if (!BluetoothUtils.isAudioSharingEnabled()) return false;
|
if (BluetoothUtils.isAudioSharingUIAvailable(getContext())) {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
Intent intent = activity == null ? null : activity.getIntent();
|
Intent intent = activity == null ? null : activity.getIntent();
|
||||||
Bundle args =
|
Bundle args =
|
||||||
intent == null ? null :
|
intent == null ? null :
|
||||||
intent.getBundleExtra(
|
intent.getBundleExtra(
|
||||||
SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS);
|
SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS);
|
||||||
return args != null
|
return args != null
|
||||||
&& args.getBoolean(EXTRA_PAIR_AND_JOIN_SHARING, false);
|
&& args.getBoolean(EXTRA_PAIR_AND_JOIN_SHARING, false);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addOnMetadataChangedListener(@Nullable BluetoothDevice device) {
|
private void addOnMetadataChangedListener(@Nullable BluetoothDevice device) {
|
||||||
|
@@ -179,7 +179,7 @@ public class AvailableMediaDeviceGroupController extends BasePreferenceControlle
|
|||||||
super(context, KEY);
|
super(context, KEY);
|
||||||
mBtManager = Utils.getLocalBtManager(mContext);
|
mBtManager = Utils.getLocalBtManager(mContext);
|
||||||
mExecutor = Executors.newSingleThreadExecutor();
|
mExecutor = Executors.newSingleThreadExecutor();
|
||||||
if (BluetoothUtils.isAudioSharingEnabled()) {
|
if (BluetoothUtils.isAudioSharingUIAvailable(mContext)) {
|
||||||
mBroadcast =
|
mBroadcast =
|
||||||
mBtManager == null
|
mBtManager == null
|
||||||
? null
|
? null
|
||||||
@@ -200,7 +200,7 @@ public class AvailableMediaDeviceGroupController extends BasePreferenceControlle
|
|||||||
Log.d(TAG, "onStart() Bluetooth is not supported on this device");
|
Log.d(TAG, "onStart() Bluetooth is not supported on this device");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (BluetoothUtils.isAudioSharingEnabled()) {
|
if (BluetoothUtils.isAudioSharingUIAvailable(mContext)) {
|
||||||
registerAudioSharingCallbacks();
|
registerAudioSharingCallbacks();
|
||||||
}
|
}
|
||||||
mBtManager.getEventManager().registerCallback(this);
|
mBtManager.getEventManager().registerCallback(this);
|
||||||
@@ -216,7 +216,7 @@ public class AvailableMediaDeviceGroupController extends BasePreferenceControlle
|
|||||||
Log.d(TAG, "onStop() Bluetooth is not supported on this device");
|
Log.d(TAG, "onStop() Bluetooth is not supported on this device");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (BluetoothUtils.isAudioSharingEnabled()) {
|
if (BluetoothUtils.isAudioSharingUIAvailable(mContext)) {
|
||||||
unregisterAudioSharingCallbacks();
|
unregisterAudioSharingCallbacks();
|
||||||
}
|
}
|
||||||
if (mBluetoothDeviceUpdater != null) {
|
if (mBluetoothDeviceUpdater != null) {
|
||||||
@@ -278,7 +278,7 @@ public class AvailableMediaDeviceGroupController extends BasePreferenceControlle
|
|||||||
public void onDeviceClick(Preference preference) {
|
public void onDeviceClick(Preference preference) {
|
||||||
final CachedBluetoothDevice cachedDevice =
|
final CachedBluetoothDevice cachedDevice =
|
||||||
((BluetoothDevicePreference) preference).getBluetoothDevice();
|
((BluetoothDevicePreference) preference).getBluetoothDevice();
|
||||||
if (BluetoothUtils.isAudioSharingEnabled() && mDialogHandler != null) {
|
if (BluetoothUtils.isAudioSharingUIAvailable(mContext) && mDialogHandler != null) {
|
||||||
mDialogHandler.handleDeviceConnected(cachedDevice, /* userTriggered= */ true);
|
mDialogHandler.handleDeviceConnected(cachedDevice, /* userTriggered= */ true);
|
||||||
FeatureFactory.getFeatureFactory().getMetricsFeatureProvider()
|
FeatureFactory.getFeatureFactory().getMetricsFeatureProvider()
|
||||||
.action(mContext, SettingsEnums.ACTION_MEDIA_DEVICE_CLICK);
|
.action(mContext, SettingsEnums.ACTION_MEDIA_DEVICE_CLICK);
|
||||||
@@ -294,7 +294,7 @@ public class AvailableMediaDeviceGroupController extends BasePreferenceControlle
|
|||||||
fragment.getContext(),
|
fragment.getContext(),
|
||||||
AvailableMediaDeviceGroupController.this,
|
AvailableMediaDeviceGroupController.this,
|
||||||
fragment.getMetricsCategory());
|
fragment.getMetricsCategory());
|
||||||
if (BluetoothUtils.isAudioSharingEnabled()) {
|
if (BluetoothUtils.isAudioSharingUIAvailable(mContext)) {
|
||||||
mDialogHandler = new AudioSharingDialogHandler(mContext, fragment);
|
mDialogHandler = new AudioSharingDialogHandler(mContext, fragment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -341,7 +341,7 @@ public class AvailableMediaDeviceGroupController extends BasePreferenceControlle
|
|||||||
if (isAudioModeOngoingCall(mContext)) {
|
if (isAudioModeOngoingCall(mContext)) {
|
||||||
// in phone call
|
// in phone call
|
||||||
titleResId = R.string.connected_device_call_device_title;
|
titleResId = R.string.connected_device_call_device_title;
|
||||||
} else if (BluetoothUtils.isAudioSharingEnabled()
|
} else if (BluetoothUtils.isAudioSharingUIAvailable(mContext)
|
||||||
&& BluetoothUtils.isBroadcasting(mBtManager)) {
|
&& BluetoothUtils.isBroadcasting(mBtManager)) {
|
||||||
// without phone call, in audio sharing
|
// without phone call, in audio sharing
|
||||||
titleResId = R.string.audio_sharing_media_device_group_title;
|
titleResId = R.string.audio_sharing_media_device_group_title;
|
||||||
|
@@ -80,7 +80,7 @@ public class ConnectedDeviceDashboardFragment extends DashboardFragment {
|
|||||||
+ ", action : "
|
+ ", action : "
|
||||||
+ action);
|
+ action);
|
||||||
}
|
}
|
||||||
if (BluetoothUtils.isAudioSharingEnabled()) {
|
if (BluetoothUtils.isAudioSharingUIAvailable(context)) {
|
||||||
use(AudioSharingDevicePreferenceController.class).init(this);
|
use(AudioSharingDevicePreferenceController.class).init(this);
|
||||||
}
|
}
|
||||||
use(AvailableMediaDeviceGroupController.class).init(this);
|
use(AvailableMediaDeviceGroupController.class).init(this);
|
||||||
|
@@ -54,10 +54,8 @@ public class PreviouslyConnectedDevicePreferenceController extends BasePreferenc
|
|||||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||||
|
|
||||||
private static final int MAX_DEVICE_NUM = 3;
|
private static final int MAX_DEVICE_NUM = 3;
|
||||||
private static final int DOCK_DEVICE_INDEX = 9;
|
|
||||||
private static final String KEY_SEE_ALL = "previously_connected_devices_see_all";
|
private static final String KEY_SEE_ALL = "previously_connected_devices_see_all";
|
||||||
|
|
||||||
private final List<Preference> mDevicesList = new ArrayList<>();
|
|
||||||
private final List<Preference> mDockDevicesList = new ArrayList<>();
|
private final List<Preference> mDockDevicesList = new ArrayList<>();
|
||||||
private final Map<BluetoothDevice, Preference> mDevicePreferenceMap = new HashMap<>();
|
private final Map<BluetoothDevice, Preference> mDevicePreferenceMap = new HashMap<>();
|
||||||
private final BluetoothAdapter mBluetoothAdapter;
|
private final BluetoothAdapter mBluetoothAdapter;
|
||||||
@@ -118,6 +116,8 @@ public class PreviouslyConnectedDevicePreferenceController extends BasePreferenc
|
|||||||
mContext.registerReceiver(mReceiver, mIntentFilter,
|
mContext.registerReceiver(mReceiver, mIntentFilter,
|
||||||
Context.RECEIVER_EXPORTED_UNAUDITED);
|
Context.RECEIVER_EXPORTED_UNAUDITED);
|
||||||
mBluetoothDeviceUpdater.refreshPreference();
|
mBluetoothDeviceUpdater.refreshPreference();
|
||||||
|
Log.d(TAG, "Updating preference group by onStart on thread "
|
||||||
|
+ Thread.currentThread().getName());
|
||||||
updatePreferenceGroup();
|
updatePreferenceGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,55 +146,11 @@ public class PreviouslyConnectedDevicePreferenceController extends BasePreferenc
|
|||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "onDeviceAdded() " + preference.getTitle());
|
Log.d(TAG, "onDeviceAdded() " + preference.getTitle());
|
||||||
}
|
}
|
||||||
|
Log.d(TAG, "Updating preference group by onDeviceAdded on thread "
|
||||||
|
+ Thread.currentThread().getName());
|
||||||
updatePreferenceGroup();
|
updatePreferenceGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPreference(int index, Preference preference) {
|
|
||||||
if (preference instanceof BluetoothDevicePreference) {
|
|
||||||
if (index >= 0 && mDevicesList.size() >= index) {
|
|
||||||
mDevicesList.add(index, preference);
|
|
||||||
} else {
|
|
||||||
mDevicesList.add(preference);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mDockDevicesList.add(preference);
|
|
||||||
}
|
|
||||||
addPreference();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addPreference() {
|
|
||||||
mPreferenceGroup.removeAll();
|
|
||||||
mPreferenceGroup.addPreference(mSeeAllPreference);
|
|
||||||
final int size = getDeviceListSize();
|
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
if (DEBUG) {
|
|
||||||
Log.d(TAG, "addPreference() add device : " + mDevicesList.get(i).getTitle());
|
|
||||||
}
|
|
||||||
mDevicesList.get(i).setOrder(i);
|
|
||||||
mPreferenceGroup.addPreference(mDevicesList.get(i));
|
|
||||||
}
|
|
||||||
if (mDockDevicesList.size() > 0) {
|
|
||||||
for (int i = 0; i < getDockDeviceListSize(MAX_DEVICE_NUM - size); i++) {
|
|
||||||
if (DEBUG) {
|
|
||||||
Log.d(TAG, "addPreference() add dock device : "
|
|
||||||
+ mDockDevicesList.get(i).getTitle());
|
|
||||||
}
|
|
||||||
mDockDevicesList.get(i).setOrder(DOCK_DEVICE_INDEX);
|
|
||||||
mPreferenceGroup.addPreference(mDockDevicesList.get(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getDeviceListSize() {
|
|
||||||
return mDevicesList.size() >= MAX_DEVICE_NUM
|
|
||||||
? MAX_DEVICE_NUM : mDevicesList.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getDockDeviceListSize(int availableSize) {
|
|
||||||
return mDockDevicesList.size() >= availableSize
|
|
||||||
? availableSize : mDockDevicesList.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDeviceRemoved(Preference preference) {
|
public void onDeviceRemoved(Preference preference) {
|
||||||
if (preference instanceof BluetoothDevicePreference) {
|
if (preference instanceof BluetoothDevicePreference) {
|
||||||
@@ -207,19 +163,22 @@ public class PreviouslyConnectedDevicePreferenceController extends BasePreferenc
|
|||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "onDeviceRemoved() " + preference.getTitle());
|
Log.d(TAG, "onDeviceRemoved() " + preference.getTitle());
|
||||||
}
|
}
|
||||||
|
Log.d(TAG, "Updating preference group by onDeviceRemoved on thread "
|
||||||
|
+ Thread.currentThread().getName());
|
||||||
updatePreferenceGroup();
|
updatePreferenceGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Sort the preferenceGroup by most recently used. */
|
/** Sort the preferenceGroup by most recently used. */
|
||||||
public void updatePreferenceGroup() {
|
public void updatePreferenceGroup() {
|
||||||
mPreferenceGroup.removeAll();
|
mPreferenceGroup.removeAll();
|
||||||
mPreferenceGroup.addPreference(mSeeAllPreference);
|
|
||||||
if (mBluetoothAdapter != null && mBluetoothAdapter.isEnabled()) {
|
if (mBluetoothAdapter != null && mBluetoothAdapter.isEnabled()) {
|
||||||
// Bluetooth is supported
|
// Bluetooth is supported
|
||||||
int order = 0;
|
int order = 0;
|
||||||
for (BluetoothDevice device : mBluetoothAdapter.getMostRecentlyConnectedDevices()) {
|
for (BluetoothDevice device : mBluetoothAdapter.getMostRecentlyConnectedDevices()) {
|
||||||
Preference preference = mDevicePreferenceMap.getOrDefault(device, null);
|
Preference preference = mDevicePreferenceMap.getOrDefault(device, null);
|
||||||
if (preference != null) {
|
if (preference != null) {
|
||||||
|
Log.d(TAG, "Adding preference with order " + order + " when there are "
|
||||||
|
+ mPreferenceGroup.getPreferenceCount());
|
||||||
preference.setOrder(order);
|
preference.setOrder(order);
|
||||||
mPreferenceGroup.addPreference(preference);
|
mPreferenceGroup.addPreference(preference);
|
||||||
order += 1;
|
order += 1;
|
||||||
@@ -237,6 +196,7 @@ public class PreviouslyConnectedDevicePreferenceController extends BasePreferenc
|
|||||||
order += 1;
|
order += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mPreferenceGroup.addPreference(mSeeAllPreference);
|
||||||
updatePreferenceVisibility();
|
updatePreferenceVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -25,7 +25,7 @@ public class AudioSharingActivity extends SettingsActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedState) {
|
protected void onCreate(Bundle savedState) {
|
||||||
super.onCreate(savedState);
|
super.onCreate(savedState);
|
||||||
if (!BluetoothUtils.isAudioSharingEnabled()) {
|
if (!BluetoothUtils.isAudioSharingUIAvailable(this)) {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -55,7 +55,8 @@ public abstract class AudioSharingBasePreferenceController extends BasePreferenc
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return BluetoothUtils.isAudioSharingEnabled() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
return (BluetoothUtils.isAudioSharingUIAvailable(mContext))
|
||||||
|
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -55,7 +55,7 @@ public class AudioSharingBluetoothDeviceUpdater extends BluetoothDeviceUpdater
|
|||||||
if (isDeviceConnected(cachedDevice) && isDeviceInCachedDevicesList(cachedDevice)) {
|
if (isDeviceConnected(cachedDevice) && isDeviceInCachedDevicesList(cachedDevice)) {
|
||||||
// If device is LE audio device and has a broadcast source,
|
// If device is LE audio device and has a broadcast source,
|
||||||
// it would show in audio sharing devices group.
|
// it would show in audio sharing devices group.
|
||||||
if (BluetoothUtils.isAudioSharingEnabled()
|
if (BluetoothUtils.isAudioSharingUIAvailable(mContext)
|
||||||
&& cachedDevice.isConnectedLeAudioDevice()
|
&& cachedDevice.isConnectedLeAudioDevice()
|
||||||
&& BluetoothUtils.hasConnectedBroadcastSource(cachedDevice, mLocalBtManager)) {
|
&& BluetoothUtils.hasConnectedBroadcastSource(cachedDevice, mLocalBtManager)) {
|
||||||
isFilterMatched = true;
|
isFilterMatched = true;
|
||||||
|
@@ -65,27 +65,32 @@ public class AudioSharingCallAudioDialogFragment extends InstrumentedDialogFragm
|
|||||||
* @param listener The callback to handle the user action on this dialog.
|
* @param listener The callback to handle the user action on this dialog.
|
||||||
*/
|
*/
|
||||||
public static void show(
|
public static void show(
|
||||||
@NonNull Fragment host,
|
@Nullable Fragment host,
|
||||||
@NonNull List<AudioSharingDeviceItem> deviceItems,
|
@NonNull List<AudioSharingDeviceItem> deviceItems,
|
||||||
int checkedItemIndex,
|
int checkedItemIndex,
|
||||||
@NonNull DialogEventListener listener) {
|
@NonNull DialogEventListener listener) {
|
||||||
if (!BluetoothUtils.isAudioSharingEnabled()) return;
|
if (host == null) {
|
||||||
final FragmentManager manager;
|
Log.d(TAG, "Fail to show dialog, host is null");
|
||||||
try {
|
|
||||||
manager = host.getChildFragmentManager();
|
|
||||||
} catch (IllegalStateException e) {
|
|
||||||
Log.d(TAG, "Fail to show dialog: " + e.getMessage());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sListener = listener;
|
if (BluetoothUtils.isAudioSharingUIAvailable(host.getContext())) {
|
||||||
if (manager.findFragmentByTag(TAG) == null) {
|
final FragmentManager manager;
|
||||||
final Bundle bundle = new Bundle();
|
try {
|
||||||
bundle.putParcelableList(BUNDLE_KEY_DEVICE_ITEMS, deviceItems);
|
manager = host.getChildFragmentManager();
|
||||||
bundle.putInt(BUNDLE_KEY_CHECKED_ITEM_INDEX, checkedItemIndex);
|
} catch (IllegalStateException e) {
|
||||||
final AudioSharingCallAudioDialogFragment dialog =
|
Log.d(TAG, "Fail to show dialog: " + e.getMessage());
|
||||||
new AudioSharingCallAudioDialogFragment();
|
return;
|
||||||
dialog.setArguments(bundle);
|
}
|
||||||
dialog.show(manager, TAG);
|
sListener = listener;
|
||||||
|
if (manager.findFragmentByTag(TAG) == null) {
|
||||||
|
final Bundle bundle = new Bundle();
|
||||||
|
bundle.putParcelableList(BUNDLE_KEY_DEVICE_ITEMS, deviceItems);
|
||||||
|
bundle.putInt(BUNDLE_KEY_CHECKED_ITEM_INDEX, checkedItemIndex);
|
||||||
|
final AudioSharingCallAudioDialogFragment dialog =
|
||||||
|
new AudioSharingCallAudioDialogFragment();
|
||||||
|
dialog.setArguments(bundle);
|
||||||
|
dialog.show(manager, TAG);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -155,7 +155,8 @@ public class AudioSharingCompatibilityPreferenceController extends TogglePrefere
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return BluetoothUtils.isAudioSharingEnabled() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
return BluetoothUtils.isAudioSharingUIAvailable(mContext) ? AVAILABLE
|
||||||
|
: UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -44,23 +44,28 @@ public class AudioSharingConfirmDialogFragment extends InstrumentedDialogFragmen
|
|||||||
*
|
*
|
||||||
* @param host The Fragment this dialog will be hosted.
|
* @param host The Fragment this dialog will be hosted.
|
||||||
*/
|
*/
|
||||||
public static void show(Fragment host) {
|
public static void show(@Nullable Fragment host) {
|
||||||
if (!BluetoothUtils.isAudioSharingEnabled()) return;
|
if (host == null) {
|
||||||
final FragmentManager manager;
|
Log.d(TAG, "Fail to show dialog, host is null");
|
||||||
try {
|
|
||||||
manager = host.getChildFragmentManager();
|
|
||||||
} catch (IllegalStateException e) {
|
|
||||||
Log.d(TAG, "Fail to show dialog: " + e.getMessage());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AlertDialog dialog = AudioSharingDialogHelper.getDialogIfShowing(manager, TAG);
|
if (BluetoothUtils.isAudioSharingUIAvailable(host.getContext())) {
|
||||||
if (dialog != null) {
|
final FragmentManager manager;
|
||||||
Log.d(TAG, "Dialog is showing, return.");
|
try {
|
||||||
return;
|
manager = host.getChildFragmentManager();
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
Log.d(TAG, "Fail to show dialog: " + e.getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AlertDialog dialog = AudioSharingDialogHelper.getDialogIfShowing(manager, TAG);
|
||||||
|
if (dialog != null) {
|
||||||
|
Log.d(TAG, "Dialog is showing, return.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Log.d(TAG, "Show up the confirm dialog.");
|
||||||
|
AudioSharingConfirmDialogFragment dialogFrag = new AudioSharingConfirmDialogFragment();
|
||||||
|
dialogFrag.show(manager, TAG);
|
||||||
}
|
}
|
||||||
Log.d(TAG, "Show up the confirm dialog.");
|
|
||||||
AudioSharingConfirmDialogFragment dialogFrag = new AudioSharingConfirmDialogFragment();
|
|
||||||
dialogFrag.show(manager, TAG);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -45,6 +45,7 @@ public class AudioSharingDashboardFragment extends DashboardFragment
|
|||||||
public static final int SHARE_THEN_PAIR_REQUEST_CODE = 1002;
|
public static final int SHARE_THEN_PAIR_REQUEST_CODE = 1002;
|
||||||
|
|
||||||
SettingsMainSwitchBar mMainSwitchBar;
|
SettingsMainSwitchBar mMainSwitchBar;
|
||||||
|
private Context mContext;
|
||||||
private AudioSharingDeviceVolumeGroupController mAudioSharingDeviceVolumeGroupController;
|
private AudioSharingDeviceVolumeGroupController mAudioSharingDeviceVolumeGroupController;
|
||||||
private AudioSharingCallAudioPreferenceController mAudioSharingCallAudioPreferenceController;
|
private AudioSharingCallAudioPreferenceController mAudioSharingCallAudioPreferenceController;
|
||||||
private AudioSharingPlaySoundPreferenceController mAudioSharingPlaySoundPreferenceController;
|
private AudioSharingPlaySoundPreferenceController mAudioSharingPlaySoundPreferenceController;
|
||||||
@@ -78,6 +79,7 @@ public class AudioSharingDashboardFragment extends DashboardFragment
|
|||||||
@Override
|
@Override
|
||||||
public void onAttach(Context context) {
|
public void onAttach(Context context) {
|
||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
|
mContext = context;
|
||||||
mAudioSharingDeviceVolumeGroupController =
|
mAudioSharingDeviceVolumeGroupController =
|
||||||
use(AudioSharingDeviceVolumeGroupController.class);
|
use(AudioSharingDeviceVolumeGroupController.class);
|
||||||
mAudioSharingDeviceVolumeGroupController.init(this);
|
mAudioSharingDeviceVolumeGroupController.init(this);
|
||||||
@@ -107,23 +109,25 @@ public class AudioSharingDashboardFragment extends DashboardFragment
|
|||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
if (!BluetoothUtils.isAudioSharingEnabled()) return;
|
if (BluetoothUtils.isAudioSharingUIAvailable(mContext)) {
|
||||||
// In share then pair flow, after users be routed to pair new device page and successfully
|
// In share then pair flow, after users be routed to pair new device page and
|
||||||
// pair and connect an LEA headset, the pair fragment will be finished with RESULT_OK
|
// successfully pair and connect an LEA headset, the pair fragment will be finished with
|
||||||
// and EXTRA_BT_DEVICE_TO_AUTO_ADD_SOURCE, pass the BT device to switch bar controller,
|
// RESULT_OK and EXTRA_BT_DEVICE_TO_AUTO_ADD_SOURCE, pass the BT device to switch bar
|
||||||
// which is responsible for adding source to the device with loading indicator.
|
// controller, which is responsible for adding source to the device with loading
|
||||||
if (requestCode == SHARE_THEN_PAIR_REQUEST_CODE) {
|
// indicator.
|
||||||
if (resultCode == Activity.RESULT_OK) {
|
if (requestCode == SHARE_THEN_PAIR_REQUEST_CODE) {
|
||||||
BluetoothDevice btDevice =
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
data != null
|
BluetoothDevice btDevice =
|
||||||
? data.getParcelableExtra(EXTRA_BT_DEVICE_TO_AUTO_ADD_SOURCE,
|
data != null
|
||||||
BluetoothDevice.class)
|
? data.getParcelableExtra(EXTRA_BT_DEVICE_TO_AUTO_ADD_SOURCE,
|
||||||
: null;
|
BluetoothDevice.class)
|
||||||
Log.d(TAG, "onActivityResult: RESULT_OK with device = " + btDevice);
|
: null;
|
||||||
if (btDevice != null) {
|
Log.d(TAG, "onActivityResult: RESULT_OK with device = " + btDevice);
|
||||||
var unused = ThreadUtils.postOnBackgroundThread(
|
if (btDevice != null) {
|
||||||
() -> mAudioSharingSwitchBarController.handleAutoAddSourceAfterPair(
|
var unused = ThreadUtils.postOnBackgroundThread(
|
||||||
btDevice));
|
() -> mAudioSharingSwitchBarController.handleAutoAddSourceAfterPair(
|
||||||
|
btDevice));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -308,7 +308,8 @@ public class AudioSharingDevicePreferenceController extends BasePreferenceContro
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return BluetoothUtils.isAudioSharingEnabled() && mBluetoothDeviceUpdater != null
|
return (BluetoothUtils.isAudioSharingUIAvailable(mContext)
|
||||||
|
&& mBluetoothDeviceUpdater != null)
|
||||||
? AVAILABLE_UNSEARCHABLE
|
? AVAILABLE_UNSEARCHABLE
|
||||||
: UNSUPPORTED_ON_DEVICE;
|
: UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
@@ -84,37 +84,42 @@ public class AudioSharingDialogFragment extends InstrumentedDialogFragment {
|
|||||||
* @param eventData The eventData to log with for dialog onClick events.
|
* @param eventData The eventData to log with for dialog onClick events.
|
||||||
*/
|
*/
|
||||||
public static void show(
|
public static void show(
|
||||||
@NonNull Fragment host,
|
@Nullable Fragment host,
|
||||||
@NonNull List<AudioSharingDeviceItem> deviceItems,
|
@NonNull List<AudioSharingDeviceItem> deviceItems,
|
||||||
@NonNull DialogEventListener listener,
|
@NonNull DialogEventListener listener,
|
||||||
@NonNull Pair<Integer, Object>[] eventData) {
|
@NonNull Pair<Integer, Object>[] eventData) {
|
||||||
if (!BluetoothUtils.isAudioSharingEnabled()) return;
|
if (host == null) {
|
||||||
final FragmentManager manager;
|
Log.d(TAG, "Fail to show dialog, host is null");
|
||||||
try {
|
|
||||||
manager = host.getChildFragmentManager();
|
|
||||||
} catch (IllegalStateException e) {
|
|
||||||
Log.d(TAG, "Fail to show dialog: " + e.getMessage());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Lifecycle.State currentState = host.getLifecycle().getCurrentState();
|
if (BluetoothUtils.isAudioSharingUIAvailable(host.getContext())) {
|
||||||
if (!currentState.isAtLeast(Lifecycle.State.STARTED)) {
|
final FragmentManager manager;
|
||||||
Log.d(TAG, "Fail to show dialog with state: " + currentState);
|
try {
|
||||||
return;
|
manager = host.getChildFragmentManager();
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
Log.d(TAG, "Fail to show dialog: " + e.getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Lifecycle.State currentState = host.getLifecycle().getCurrentState();
|
||||||
|
if (!currentState.isAtLeast(Lifecycle.State.STARTED)) {
|
||||||
|
Log.d(TAG, "Fail to show dialog with state: " + currentState);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sHost = host;
|
||||||
|
sListener = listener;
|
||||||
|
sEventData = eventData;
|
||||||
|
AlertDialog dialog = AudioSharingDialogHelper.getDialogIfShowing(manager, TAG);
|
||||||
|
if (dialog != null) {
|
||||||
|
Log.d(TAG, "Dialog is showing, return.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Log.d(TAG, "Show up the dialog.");
|
||||||
|
final Bundle bundle = new Bundle();
|
||||||
|
bundle.putParcelableList(BUNDLE_KEY_DEVICE_ITEMS, deviceItems);
|
||||||
|
AudioSharingDialogFragment dialogFrag = new AudioSharingDialogFragment();
|
||||||
|
dialogFrag.setArguments(bundle);
|
||||||
|
dialogFrag.show(manager, TAG);
|
||||||
}
|
}
|
||||||
sHost = host;
|
|
||||||
sListener = listener;
|
|
||||||
sEventData = eventData;
|
|
||||||
AlertDialog dialog = AudioSharingDialogHelper.getDialogIfShowing(manager, TAG);
|
|
||||||
if (dialog != null) {
|
|
||||||
Log.d(TAG, "Dialog is showing, return.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Log.d(TAG, "Show up the dialog.");
|
|
||||||
final Bundle bundle = new Bundle();
|
|
||||||
bundle.putParcelableList(BUNDLE_KEY_DEVICE_ITEMS, deviceItems);
|
|
||||||
AudioSharingDialogFragment dialogFrag = new AudioSharingDialogFragment();
|
|
||||||
dialogFrag.setArguments(bundle);
|
|
||||||
dialogFrag.show(manager, TAG);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return the tag of {@link AudioSharingDialogFragment} dialog. */
|
/** Return the tag of {@link AudioSharingDialogFragment} dialog. */
|
||||||
|
@@ -80,72 +80,67 @@ public class AudioSharingDisconnectDialogFragment extends InstrumentedDialogFrag
|
|||||||
* @param eventData The eventData to log with for dialog onClick events.
|
* @param eventData The eventData to log with for dialog onClick events.
|
||||||
*/
|
*/
|
||||||
public static void show(
|
public static void show(
|
||||||
@NonNull Fragment host,
|
@Nullable Fragment host,
|
||||||
@NonNull List<AudioSharingDeviceItem> deviceItems,
|
@NonNull List<AudioSharingDeviceItem> deviceItems,
|
||||||
@NonNull CachedBluetoothDevice newDevice,
|
@NonNull CachedBluetoothDevice newDevice,
|
||||||
@NonNull DialogEventListener listener,
|
@NonNull DialogEventListener listener,
|
||||||
@NonNull Pair<Integer, Object>[] eventData) {
|
@NonNull Pair<Integer, Object>[] eventData) {
|
||||||
if (!BluetoothUtils.isAudioSharingEnabled()) return;
|
if (host == null) {
|
||||||
final FragmentManager manager;
|
Log.d(TAG, "Fail to show dialog, host is null");
|
||||||
try {
|
|
||||||
manager = host.getChildFragmentManager();
|
|
||||||
} catch (IllegalStateException e) {
|
|
||||||
Log.d(TAG, "Fail to show dialog: " + e.getMessage());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Lifecycle.State currentState = host.getLifecycle().getCurrentState();
|
if (BluetoothUtils.isAudioSharingUIAvailable(host.getContext())) {
|
||||||
if (!currentState.isAtLeast(Lifecycle.State.STARTED)) {
|
final FragmentManager manager;
|
||||||
Log.d(TAG, "Fail to show dialog with state: " + currentState);
|
try {
|
||||||
return;
|
manager = host.getChildFragmentManager();
|
||||||
}
|
} catch (IllegalStateException e) {
|
||||||
AlertDialog dialog = AudioSharingDialogHelper.getDialogIfShowing(manager, TAG);
|
Log.d(TAG, "Fail to show dialog: " + e.getMessage());
|
||||||
if (dialog != null) {
|
|
||||||
int newGroupId = BluetoothUtils.getGroupId(newDevice);
|
|
||||||
if (sNewDevice != null && newGroupId == BluetoothUtils.getGroupId(sNewDevice)) {
|
|
||||||
Log.d(
|
|
||||||
TAG,
|
|
||||||
String.format(
|
|
||||||
Locale.US,
|
|
||||||
"Dialog is showing for the same device group %d, "
|
|
||||||
+ "update the content.",
|
|
||||||
newGroupId));
|
|
||||||
sListener = listener;
|
|
||||||
sNewDevice = newDevice;
|
|
||||||
sEventData = eventData;
|
|
||||||
return;
|
return;
|
||||||
} else {
|
|
||||||
Log.d(
|
|
||||||
TAG,
|
|
||||||
String.format(
|
|
||||||
Locale.US,
|
|
||||||
"Dialog is showing for new device group %d, "
|
|
||||||
+ "dismiss current dialog.",
|
|
||||||
newGroupId));
|
|
||||||
dialog.dismiss();
|
|
||||||
var unused =
|
|
||||||
ThreadUtils.postOnBackgroundThread(
|
|
||||||
() ->
|
|
||||||
FeatureFactory.getFeatureFactory()
|
|
||||||
.getMetricsFeatureProvider()
|
|
||||||
.action(
|
|
||||||
dialog.getContext(),
|
|
||||||
SettingsEnums
|
|
||||||
.ACTION_AUDIO_SHARING_DIALOG_AUTO_DISMISS,
|
|
||||||
SettingsEnums
|
|
||||||
.DIALOG_AUDIO_SHARING_SWITCH_DEVICE));
|
|
||||||
}
|
}
|
||||||
|
Lifecycle.State currentState = host.getLifecycle().getCurrentState();
|
||||||
|
if (!currentState.isAtLeast(Lifecycle.State.STARTED)) {
|
||||||
|
Log.d(TAG, "Fail to show dialog with state: " + currentState);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AlertDialog dialog = AudioSharingDialogHelper.getDialogIfShowing(manager, TAG);
|
||||||
|
if (dialog != null) {
|
||||||
|
int newGroupId = BluetoothUtils.getGroupId(newDevice);
|
||||||
|
if (sNewDevice != null && newGroupId == BluetoothUtils.getGroupId(sNewDevice)) {
|
||||||
|
Log.d(
|
||||||
|
TAG,
|
||||||
|
String.format(
|
||||||
|
Locale.US,
|
||||||
|
"Dialog is showing for the same device group %d, "
|
||||||
|
+ "update the content.",
|
||||||
|
newGroupId));
|
||||||
|
sListener = listener;
|
||||||
|
sNewDevice = newDevice;
|
||||||
|
sEventData = eventData;
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
Log.d(
|
||||||
|
TAG,
|
||||||
|
String.format(
|
||||||
|
Locale.US,
|
||||||
|
"Dialog is showing for new device group %d, "
|
||||||
|
+ "dismiss current dialog.",
|
||||||
|
newGroupId));
|
||||||
|
dialog.dismiss();
|
||||||
|
logDialogAutoDismiss(dialog);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sListener = listener;
|
||||||
|
sNewDevice = newDevice;
|
||||||
|
sEventData = eventData;
|
||||||
|
Log.d(TAG, "Show up the dialog.");
|
||||||
|
final Bundle bundle = new Bundle();
|
||||||
|
bundle.putParcelableList(BUNDLE_KEY_DEVICE_TO_DISCONNECT_ITEMS, deviceItems);
|
||||||
|
bundle.putString(BUNDLE_KEY_NEW_DEVICE_NAME, newDevice.getName());
|
||||||
|
AudioSharingDisconnectDialogFragment dialogFrag =
|
||||||
|
new AudioSharingDisconnectDialogFragment();
|
||||||
|
dialogFrag.setArguments(bundle);
|
||||||
|
dialogFrag.show(manager, TAG);
|
||||||
}
|
}
|
||||||
sListener = listener;
|
|
||||||
sNewDevice = newDevice;
|
|
||||||
sEventData = eventData;
|
|
||||||
Log.d(TAG, "Show up the dialog.");
|
|
||||||
final Bundle bundle = new Bundle();
|
|
||||||
bundle.putParcelableList(BUNDLE_KEY_DEVICE_TO_DISCONNECT_ITEMS, deviceItems);
|
|
||||||
bundle.putString(BUNDLE_KEY_NEW_DEVICE_NAME, newDevice.getName());
|
|
||||||
AudioSharingDisconnectDialogFragment dialogFrag =
|
|
||||||
new AudioSharingDisconnectDialogFragment();
|
|
||||||
dialogFrag.setArguments(bundle);
|
|
||||||
dialogFrag.show(manager, TAG);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return the tag of {@link AudioSharingDisconnectDialogFragment} dialog. */
|
/** Return the tag of {@link AudioSharingDisconnectDialogFragment} dialog. */
|
||||||
@@ -216,4 +211,17 @@ public class AudioSharingDisconnectDialogFragment extends InstrumentedDialogFrag
|
|||||||
AudioSharingDeviceAdapter.ActionType.REMOVE));
|
AudioSharingDeviceAdapter.ActionType.REMOVE));
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void logDialogAutoDismiss(AlertDialog dialog) {
|
||||||
|
var unused =
|
||||||
|
ThreadUtils.postOnBackgroundThread(
|
||||||
|
() -> FeatureFactory.getFeatureFactory()
|
||||||
|
.getMetricsFeatureProvider()
|
||||||
|
.action(
|
||||||
|
dialog.getContext(),
|
||||||
|
SettingsEnums
|
||||||
|
.ACTION_AUDIO_SHARING_DIALOG_AUTO_DISMISS,
|
||||||
|
SettingsEnums
|
||||||
|
.DIALOG_AUDIO_SHARING_SWITCH_DEVICE));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -46,27 +46,32 @@ public class AudioSharingErrorDialogFragment extends InstrumentedDialogFragment
|
|||||||
* @param host The Fragment this dialog will be hosted.
|
* @param host The Fragment this dialog will be hosted.
|
||||||
*/
|
*/
|
||||||
public static void show(@Nullable Fragment host) {
|
public static void show(@Nullable Fragment host) {
|
||||||
if (host == null || !BluetoothUtils.isAudioSharingEnabled()) return;
|
if (host == null) {
|
||||||
final FragmentManager manager;
|
Log.d(TAG, "Fail to show dialog, host is null");
|
||||||
try {
|
|
||||||
manager = host.getChildFragmentManager();
|
|
||||||
} catch (IllegalStateException e) {
|
|
||||||
Log.d(TAG, "Fail to show dialog: " + e.getMessage());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Lifecycle.State currentState = host.getLifecycle().getCurrentState();
|
if (BluetoothUtils.isAudioSharingUIAvailable(host.getContext())) {
|
||||||
if (!currentState.isAtLeast(Lifecycle.State.STARTED)) {
|
final FragmentManager manager;
|
||||||
Log.d(TAG, "Fail to show dialog with state: " + currentState);
|
try {
|
||||||
return;
|
manager = host.getChildFragmentManager();
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
Log.d(TAG, "Fail to show dialog: " + e.getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Lifecycle.State currentState = host.getLifecycle().getCurrentState();
|
||||||
|
if (!currentState.isAtLeast(Lifecycle.State.STARTED)) {
|
||||||
|
Log.d(TAG, "Fail to show dialog with state: " + currentState);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AlertDialog dialog = AudioSharingDialogHelper.getDialogIfShowing(manager, TAG);
|
||||||
|
if (dialog != null) {
|
||||||
|
Log.d(TAG, "Dialog is showing, return.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Log.d(TAG, "Show up the error dialog.");
|
||||||
|
AudioSharingErrorDialogFragment dialogFrag = new AudioSharingErrorDialogFragment();
|
||||||
|
dialogFrag.show(manager, TAG);
|
||||||
}
|
}
|
||||||
AlertDialog dialog = AudioSharingDialogHelper.getDialogIfShowing(manager, TAG);
|
|
||||||
if (dialog != null) {
|
|
||||||
Log.d(TAG, "Dialog is showing, return.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Log.d(TAG, "Show up the error dialog.");
|
|
||||||
AudioSharingErrorDialogFragment dialogFrag = new AudioSharingErrorDialogFragment();
|
|
||||||
dialogFrag.show(manager, TAG);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -62,32 +62,37 @@ public class AudioSharingIncompatibleDialogFragment extends InstrumentedDialogFr
|
|||||||
*/
|
*/
|
||||||
public static void show(@Nullable Fragment host, @NonNull String deviceName,
|
public static void show(@Nullable Fragment host, @NonNull String deviceName,
|
||||||
@NonNull DialogEventListener listener) {
|
@NonNull DialogEventListener listener) {
|
||||||
if (host == null || !BluetoothUtils.isAudioSharingEnabled()) return;
|
if (host == null) {
|
||||||
final FragmentManager manager;
|
Log.d(TAG, "Fail to show dialog, host is null");
|
||||||
try {
|
|
||||||
manager = host.getChildFragmentManager();
|
|
||||||
} catch (IllegalStateException e) {
|
|
||||||
Log.d(TAG, "Fail to show dialog: " + e.getMessage());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Lifecycle.State currentState = host.getLifecycle().getCurrentState();
|
if (BluetoothUtils.isAudioSharingUIAvailable(host.getContext())) {
|
||||||
if (!currentState.isAtLeast(Lifecycle.State.STARTED)) {
|
final FragmentManager manager;
|
||||||
Log.d(TAG, "Fail to show dialog with state: " + currentState);
|
try {
|
||||||
return;
|
manager = host.getChildFragmentManager();
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
Log.d(TAG, "Fail to show dialog: " + e.getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Lifecycle.State currentState = host.getLifecycle().getCurrentState();
|
||||||
|
if (!currentState.isAtLeast(Lifecycle.State.STARTED)) {
|
||||||
|
Log.d(TAG, "Fail to show dialog with state: " + currentState);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sListener = listener;
|
||||||
|
AlertDialog dialog = AudioSharingDialogHelper.getDialogIfShowing(manager, TAG);
|
||||||
|
if (dialog != null) {
|
||||||
|
Log.d(TAG, "Dialog is showing, return.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Log.d(TAG, "Show up the incompatible device dialog.");
|
||||||
|
final Bundle bundle = new Bundle();
|
||||||
|
bundle.putString(BUNDLE_KEY_DEVICE_NAME, deviceName);
|
||||||
|
AudioSharingIncompatibleDialogFragment dialogFrag =
|
||||||
|
new AudioSharingIncompatibleDialogFragment();
|
||||||
|
dialogFrag.setArguments(bundle);
|
||||||
|
dialogFrag.show(manager, TAG);
|
||||||
}
|
}
|
||||||
sListener = listener;
|
|
||||||
AlertDialog dialog = AudioSharingDialogHelper.getDialogIfShowing(manager, TAG);
|
|
||||||
if (dialog != null) {
|
|
||||||
Log.d(TAG, "Dialog is showing, return.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Log.d(TAG, "Show up the incompatible device dialog.");
|
|
||||||
final Bundle bundle = new Bundle();
|
|
||||||
bundle.putString(BUNDLE_KEY_DEVICE_NAME, deviceName);
|
|
||||||
AudioSharingIncompatibleDialogFragment dialogFrag =
|
|
||||||
new AudioSharingIncompatibleDialogFragment();
|
|
||||||
dialogFrag.setArguments(bundle);
|
|
||||||
dialogFrag.show(manager, TAG);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -77,39 +77,45 @@ public class AudioSharingJoinDialogFragment extends InstrumentedDialogFragment {
|
|||||||
* @param eventData The eventData to log with for dialog onClick events.
|
* @param eventData The eventData to log with for dialog onClick events.
|
||||||
*/
|
*/
|
||||||
public static void show(
|
public static void show(
|
||||||
@NonNull Fragment host,
|
@Nullable Fragment host,
|
||||||
@NonNull List<AudioSharingDeviceItem> deviceItems,
|
@NonNull List<AudioSharingDeviceItem> deviceItems,
|
||||||
@NonNull CachedBluetoothDevice newDevice,
|
@NonNull CachedBluetoothDevice newDevice,
|
||||||
@NonNull DialogEventListener listener,
|
@NonNull DialogEventListener listener,
|
||||||
@NonNull Pair<Integer, Object>[] eventData) {
|
@NonNull Pair<Integer, Object>[] eventData) {
|
||||||
if (!BluetoothUtils.isAudioSharingEnabled()) return;
|
if (host == null) {
|
||||||
final FragmentManager manager;
|
Log.d(TAG, "Fail to show dialog, host is null");
|
||||||
try {
|
|
||||||
manager = host.getChildFragmentManager();
|
|
||||||
} catch (IllegalStateException e) {
|
|
||||||
Log.d(TAG, "Fail to show dialog: " + e.getMessage());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Lifecycle.State currentState = host.getLifecycle().getCurrentState();
|
if (BluetoothUtils.isAudioSharingUIAvailable(host.getContext())) {
|
||||||
if (!currentState.isAtLeast(Lifecycle.State.STARTED)) {
|
final FragmentManager manager;
|
||||||
Log.d(TAG, "Fail to show dialog with state: " + currentState);
|
try {
|
||||||
return;
|
manager = host.getChildFragmentManager();
|
||||||
}
|
} catch (IllegalStateException e) {
|
||||||
sListener = listener;
|
Log.d(TAG, "Fail to show dialog: " + e.getMessage());
|
||||||
sNewDevice = newDevice;
|
return;
|
||||||
sEventData = eventData;
|
}
|
||||||
AlertDialog dialog = AudioSharingDialogHelper.getDialogIfShowing(manager, TAG);
|
Lifecycle.State currentState = host.getLifecycle().getCurrentState();
|
||||||
if (dialog != null) {
|
if (!currentState.isAtLeast(Lifecycle.State.STARTED)) {
|
||||||
Log.d(TAG, "Dialog is showing, update the content.");
|
Log.d(TAG, "Fail to show dialog with state: " + currentState);
|
||||||
updateDialog(deviceItems, newDevice.getName(), dialog);
|
return;
|
||||||
} else {
|
}
|
||||||
Log.d(TAG, "Show up the dialog.");
|
sListener = listener;
|
||||||
final Bundle bundle = new Bundle();
|
sNewDevice = newDevice;
|
||||||
bundle.putParcelableList(BUNDLE_KEY_DEVICE_ITEMS, deviceItems);
|
sEventData = eventData;
|
||||||
bundle.putString(BUNDLE_KEY_NEW_DEVICE_NAME, newDevice.getName());
|
AlertDialog dialog = AudioSharingDialogHelper.getDialogIfShowing(manager, TAG);
|
||||||
final AudioSharingJoinDialogFragment dialogFrag = new AudioSharingJoinDialogFragment();
|
if (dialog != null) {
|
||||||
dialogFrag.setArguments(bundle);
|
Log.d(TAG, "Dialog is showing, update the content.");
|
||||||
dialogFrag.show(manager, TAG);
|
updateDialog(deviceItems, newDevice.getName(), dialog);
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "Show up the dialog.");
|
||||||
|
final Bundle bundle = new Bundle();
|
||||||
|
bundle.putParcelableList(BUNDLE_KEY_DEVICE_ITEMS, deviceItems);
|
||||||
|
bundle.putString(BUNDLE_KEY_NEW_DEVICE_NAME, newDevice.getName());
|
||||||
|
final AudioSharingJoinDialogFragment dialogFrag =
|
||||||
|
new AudioSharingJoinDialogFragment();
|
||||||
|
dialogFrag.setArguments(bundle);
|
||||||
|
dialogFrag.show(manager, TAG);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -174,7 +174,8 @@ public class AudioSharingNamePreferenceController extends BasePreferenceControll
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return BluetoothUtils.isAudioSharingEnabled() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
return BluetoothUtils.isAudioSharingUIAvailable(mContext) ? AVAILABLE
|
||||||
|
: UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -113,7 +113,8 @@ public class AudioSharingPasswordPreferenceController extends BasePreferenceCont
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return BluetoothUtils.isAudioSharingEnabled() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
return BluetoothUtils.isAudioSharingUIAvailable(mContext) ? AVAILABLE
|
||||||
|
: UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -57,7 +57,7 @@ public class AudioSharingPlaySoundPreferenceController
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return (mRingtone != null && BluetoothUtils.isAudioSharingEnabled())
|
return (mRingtone != null && BluetoothUtils.isAudioSharingUIAvailable(mContext))
|
||||||
? AVAILABLE
|
? AVAILABLE
|
||||||
: UNSUPPORTED_ON_DEVICE;
|
: UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
@@ -135,7 +135,8 @@ public class AudioSharingPreferenceController extends BasePreferenceController
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return BluetoothUtils.isAudioSharingEnabled() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
return BluetoothUtils.isAudioSharingUIAvailable(mContext) ? AVAILABLE
|
||||||
|
: UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -65,55 +65,66 @@ public class AudioSharingProgressDialogFragment extends InstrumentedDialogFragme
|
|||||||
* @param message The content to be shown on the dialog.
|
* @param message The content to be shown on the dialog.
|
||||||
*/
|
*/
|
||||||
public static void show(@Nullable Fragment host, @NonNull String message) {
|
public static void show(@Nullable Fragment host, @NonNull String message) {
|
||||||
if (host == null || !BluetoothUtils.isAudioSharingEnabled()) return;
|
if (host == null) {
|
||||||
final FragmentManager manager;
|
Log.d(TAG, "Fail to show dialog, host is null");
|
||||||
try {
|
|
||||||
manager = host.getChildFragmentManager();
|
|
||||||
} catch (IllegalStateException e) {
|
|
||||||
Log.d(TAG, "Fail to show dialog: " + e.getMessage());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Lifecycle.State currentState = host.getLifecycle().getCurrentState();
|
if (BluetoothUtils.isAudioSharingUIAvailable(host.getContext())) {
|
||||||
if (!currentState.isAtLeast(Lifecycle.State.STARTED)) {
|
final FragmentManager manager;
|
||||||
Log.d(TAG, "Fail to show dialog with state: " + currentState);
|
try {
|
||||||
return;
|
manager = host.getChildFragmentManager();
|
||||||
}
|
} catch (IllegalStateException e) {
|
||||||
AlertDialog dialog = AudioSharingDialogHelper.getDialogIfShowing(manager, TAG);
|
Log.d(TAG, "Fail to show dialog: " + e.getMessage());
|
||||||
if (dialog != null) {
|
return;
|
||||||
if (!sMessage.equals(message)) {
|
|
||||||
Log.d(TAG, "Update dialog message.");
|
|
||||||
TextView messageView = dialog.findViewById(R.id.message);
|
|
||||||
if (messageView != null) {
|
|
||||||
messageView.setText(message);
|
|
||||||
}
|
|
||||||
sMessage = message;
|
|
||||||
}
|
}
|
||||||
Log.d(TAG, "Dialog is showing, return.");
|
Lifecycle.State currentState = host.getLifecycle().getCurrentState();
|
||||||
return;
|
if (!currentState.isAtLeast(Lifecycle.State.STARTED)) {
|
||||||
|
Log.d(TAG, "Fail to show dialog with state: " + currentState);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AlertDialog dialog = AudioSharingDialogHelper.getDialogIfShowing(manager, TAG);
|
||||||
|
if (dialog != null) {
|
||||||
|
if (!sMessage.equals(message)) {
|
||||||
|
Log.d(TAG, "Update dialog message.");
|
||||||
|
TextView messageView = dialog.findViewById(R.id.message);
|
||||||
|
if (messageView != null) {
|
||||||
|
messageView.setText(message);
|
||||||
|
}
|
||||||
|
sMessage = message;
|
||||||
|
}
|
||||||
|
Log.d(TAG, "Dialog is showing, return.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sMessage = message;
|
||||||
|
Log.d(TAG, "Show up the progress dialog.");
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putString(BUNDLE_KEY_MESSAGE, message);
|
||||||
|
AudioSharingProgressDialogFragment dialogFrag =
|
||||||
|
new AudioSharingProgressDialogFragment();
|
||||||
|
dialogFrag.setArguments(args);
|
||||||
|
dialogFrag.show(manager, TAG);
|
||||||
}
|
}
|
||||||
sMessage = message;
|
|
||||||
Log.d(TAG, "Show up the progress dialog.");
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putString(BUNDLE_KEY_MESSAGE, message);
|
|
||||||
AudioSharingProgressDialogFragment dialogFrag = new AudioSharingProgressDialogFragment();
|
|
||||||
dialogFrag.setArguments(args);
|
|
||||||
dialogFrag.show(manager, TAG);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Dismiss the {@link AudioSharingProgressDialogFragment} dialog. */
|
/** Dismiss the {@link AudioSharingProgressDialogFragment} dialog. */
|
||||||
public static void dismiss(@Nullable Fragment host) {
|
public static void dismiss(@Nullable Fragment host) {
|
||||||
if (host == null || !BluetoothUtils.isAudioSharingEnabled()) return;
|
if (host == null) {
|
||||||
final FragmentManager manager;
|
Log.d(TAG, "Fail to dismiss dialog, host is null");
|
||||||
try {
|
|
||||||
manager = host.getChildFragmentManager();
|
|
||||||
} catch (IllegalStateException e) {
|
|
||||||
Log.d(TAG, "Fail to dismiss dialog: " + e.getMessage());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AlertDialog dialog = AudioSharingDialogHelper.getDialogIfShowing(manager, TAG);
|
if (BluetoothUtils.isAudioSharingUIAvailable(host.getContext())) {
|
||||||
if (dialog != null) {
|
final FragmentManager manager;
|
||||||
Log.d(TAG, "Dialog is showing, dismiss.");
|
try {
|
||||||
dialog.dismiss();
|
manager = host.getChildFragmentManager();
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
Log.d(TAG, "Fail to dismiss dialog: " + e.getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AlertDialog dialog = AudioSharingDialogHelper.getDialogIfShowing(manager, TAG);
|
||||||
|
if (dialog != null) {
|
||||||
|
Log.d(TAG, "Dialog is showing, dismiss.");
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -62,7 +62,7 @@ public class AudioSharingReceiver extends BroadcastReceiver {
|
|||||||
intent.getIntExtra(
|
intent.getIntExtra(
|
||||||
LocalBluetoothLeBroadcast.EXTRA_LE_AUDIO_SHARING_STATE, -1);
|
LocalBluetoothLeBroadcast.EXTRA_LE_AUDIO_SHARING_STATE, -1);
|
||||||
if (state == LocalBluetoothLeBroadcast.BROADCAST_STATE_ON) {
|
if (state == LocalBluetoothLeBroadcast.BROADCAST_STATE_ON) {
|
||||||
if (!BluetoothUtils.isAudioSharingEnabled()) {
|
if (!BluetoothUtils.isAudioSharingUIAvailable(context)) {
|
||||||
Log.w(TAG, "Skip showSharingNotification, feature disabled.");
|
Log.w(TAG, "Skip showSharingNotification, feature disabled.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ public class AudioSharingReceiver extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ACTION_LE_AUDIO_SHARING_STOP:
|
case ACTION_LE_AUDIO_SHARING_STOP:
|
||||||
if (BluetoothUtils.isAudioSharingEnabled()) {
|
if (BluetoothUtils.isAudioSharingUIAvailable(context)) {
|
||||||
LocalBluetoothManager manager = Utils.getLocalBtManager(context);
|
LocalBluetoothManager manager = Utils.getLocalBtManager(context);
|
||||||
if (BluetoothUtils.isBroadcasting(manager)) {
|
if (BluetoothUtils.isBroadcasting(manager)) {
|
||||||
AudioSharingUtils.stopBroadcasting(manager);
|
AudioSharingUtils.stopBroadcasting(manager);
|
||||||
|
@@ -77,70 +77,66 @@ public class AudioSharingStopDialogFragment extends InstrumentedDialogFragment {
|
|||||||
* @param eventData The eventData to log with for dialog onClick events.
|
* @param eventData The eventData to log with for dialog onClick events.
|
||||||
*/
|
*/
|
||||||
public static void show(
|
public static void show(
|
||||||
@NonNull Fragment host,
|
@Nullable Fragment host,
|
||||||
@NonNull List<AudioSharingDeviceItem> deviceItems,
|
@NonNull List<AudioSharingDeviceItem> deviceItems,
|
||||||
@NonNull CachedBluetoothDevice newDevice,
|
@NonNull CachedBluetoothDevice newDevice,
|
||||||
@NonNull DialogEventListener listener,
|
@NonNull DialogEventListener listener,
|
||||||
@NonNull Pair<Integer, Object>[] eventData) {
|
@NonNull Pair<Integer, Object>[] eventData) {
|
||||||
if (!BluetoothUtils.isAudioSharingEnabled()) return;
|
if (host == null) {
|
||||||
final FragmentManager manager;
|
Log.d(TAG, "Fail to show dialog, host is null");
|
||||||
try {
|
|
||||||
manager = host.getChildFragmentManager();
|
|
||||||
} catch (IllegalStateException e) {
|
|
||||||
Log.d(TAG, "Fail to show dialog: " + e.getMessage());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Lifecycle.State currentState = host.getLifecycle().getCurrentState();
|
if (BluetoothUtils.isAudioSharingUIAvailable(host.getContext())) {
|
||||||
if (!currentState.isAtLeast(Lifecycle.State.STARTED)) {
|
final FragmentManager manager;
|
||||||
Log.d(TAG, "Fail to show dialog with state: " + currentState);
|
try {
|
||||||
return;
|
manager = host.getChildFragmentManager();
|
||||||
}
|
} catch (IllegalStateException e) {
|
||||||
AlertDialog dialog = AudioSharingDialogHelper.getDialogIfShowing(manager, TAG);
|
Log.d(TAG, "Fail to show dialog: " + e.getMessage());
|
||||||
if (dialog != null) {
|
|
||||||
int newGroupId = BluetoothUtils.getGroupId(newDevice);
|
|
||||||
if (sCachedDevice != null
|
|
||||||
&& newGroupId == BluetoothUtils.getGroupId(sCachedDevice)) {
|
|
||||||
Log.d(
|
|
||||||
TAG,
|
|
||||||
String.format(
|
|
||||||
Locale.US,
|
|
||||||
"Dialog is showing for the same device group %d, return.",
|
|
||||||
newGroupId));
|
|
||||||
sListener = listener;
|
|
||||||
sCachedDevice = newDevice;
|
|
||||||
sEventData = eventData;
|
|
||||||
return;
|
return;
|
||||||
} else {
|
|
||||||
Log.d(
|
|
||||||
TAG,
|
|
||||||
String.format(
|
|
||||||
Locale.US,
|
|
||||||
"Dialog is showing for new device group %d, "
|
|
||||||
+ "dismiss current dialog.",
|
|
||||||
newGroupId));
|
|
||||||
dialog.dismiss();
|
|
||||||
var unused =
|
|
||||||
ThreadUtils.postOnBackgroundThread(
|
|
||||||
() ->
|
|
||||||
FeatureFactory.getFeatureFactory()
|
|
||||||
.getMetricsFeatureProvider()
|
|
||||||
.action(
|
|
||||||
dialog.getContext(),
|
|
||||||
SettingsEnums
|
|
||||||
.ACTION_AUDIO_SHARING_DIALOG_AUTO_DISMISS,
|
|
||||||
SettingsEnums.DIALOG_STOP_AUDIO_SHARING));
|
|
||||||
}
|
}
|
||||||
|
Lifecycle.State currentState = host.getLifecycle().getCurrentState();
|
||||||
|
if (!currentState.isAtLeast(Lifecycle.State.STARTED)) {
|
||||||
|
Log.d(TAG, "Fail to show dialog with state: " + currentState);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AlertDialog dialog = AudioSharingDialogHelper.getDialogIfShowing(manager, TAG);
|
||||||
|
if (dialog != null) {
|
||||||
|
int newGroupId = BluetoothUtils.getGroupId(newDevice);
|
||||||
|
if (sCachedDevice != null
|
||||||
|
&& newGroupId == BluetoothUtils.getGroupId(sCachedDevice)) {
|
||||||
|
Log.d(
|
||||||
|
TAG,
|
||||||
|
String.format(
|
||||||
|
Locale.US,
|
||||||
|
"Dialog is showing for the same device group %d, return.",
|
||||||
|
newGroupId));
|
||||||
|
sListener = listener;
|
||||||
|
sCachedDevice = newDevice;
|
||||||
|
sEventData = eventData;
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
Log.d(
|
||||||
|
TAG,
|
||||||
|
String.format(
|
||||||
|
Locale.US,
|
||||||
|
"Dialog is showing for new device group %d, "
|
||||||
|
+ "dismiss current dialog.",
|
||||||
|
newGroupId));
|
||||||
|
dialog.dismiss();
|
||||||
|
logDialogAutoDismiss(dialog);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sListener = listener;
|
||||||
|
sCachedDevice = newDevice;
|
||||||
|
sEventData = eventData;
|
||||||
|
Log.d(TAG, "Show up the dialog.");
|
||||||
|
final Bundle bundle = new Bundle();
|
||||||
|
bundle.putParcelableList(BUNDLE_KEY_DEVICE_TO_DISCONNECT_ITEMS, deviceItems);
|
||||||
|
bundle.putString(BUNDLE_KEY_NEW_DEVICE_NAME, newDevice.getName());
|
||||||
|
AudioSharingStopDialogFragment dialogFrag = new AudioSharingStopDialogFragment();
|
||||||
|
dialogFrag.setArguments(bundle);
|
||||||
|
dialogFrag.show(manager, TAG);
|
||||||
}
|
}
|
||||||
sListener = listener;
|
|
||||||
sCachedDevice = newDevice;
|
|
||||||
sEventData = eventData;
|
|
||||||
Log.d(TAG, "Show up the dialog.");
|
|
||||||
final Bundle bundle = new Bundle();
|
|
||||||
bundle.putParcelableList(BUNDLE_KEY_DEVICE_TO_DISCONNECT_ITEMS, deviceItems);
|
|
||||||
bundle.putString(BUNDLE_KEY_NEW_DEVICE_NAME, newDevice.getName());
|
|
||||||
AudioSharingStopDialogFragment dialogFrag = new AudioSharingStopDialogFragment();
|
|
||||||
dialogFrag.setArguments(bundle);
|
|
||||||
dialogFrag.show(manager, TAG);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return the tag of {@link AudioSharingStopDialogFragment} dialog. */
|
/** Return the tag of {@link AudioSharingStopDialogFragment} dialog. */
|
||||||
@@ -221,4 +217,16 @@ public class AudioSharingStopDialogFragment extends InstrumentedDialogFragment {
|
|||||||
AudioSharingDialogHelper.updateMessageStyle(dialog);
|
AudioSharingDialogHelper.updateMessageStyle(dialog);
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void logDialogAutoDismiss(AlertDialog dialog) {
|
||||||
|
var unused =
|
||||||
|
ThreadUtils.postOnBackgroundThread(
|
||||||
|
() -> FeatureFactory.getFeatureFactory()
|
||||||
|
.getMetricsFeatureProvider()
|
||||||
|
.action(
|
||||||
|
dialog.getContext(),
|
||||||
|
SettingsEnums
|
||||||
|
.ACTION_AUDIO_SHARING_DIALOG_AUTO_DISMISS,
|
||||||
|
SettingsEnums.DIALOG_STOP_AUDIO_SHARING));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -426,9 +426,7 @@ public class AudioSharingSwitchBarController extends BasePreferenceController
|
|||||||
() -> {
|
() -> {
|
||||||
mSwitchBar.setEnabled(true);
|
mSwitchBar.setEnabled(true);
|
||||||
mSwitchBar.setChecked(false);
|
mSwitchBar.setChecked(false);
|
||||||
if (mFragment != null) {
|
AudioSharingConfirmDialogFragment.show(mFragment);
|
||||||
AudioSharingConfirmDialogFragment.show(mFragment);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -447,7 +445,8 @@ public class AudioSharingSwitchBarController extends BasePreferenceController
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return BluetoothUtils.isAudioSharingEnabled() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
return BluetoothUtils.isAudioSharingUIAvailable(mContext) ? AVAILABLE
|
||||||
|
: UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -733,13 +732,8 @@ public class AudioSharingSwitchBarController extends BasePreferenceController
|
|||||||
};
|
};
|
||||||
AudioSharingUtils.postOnMainThread(
|
AudioSharingUtils.postOnMainThread(
|
||||||
mContext,
|
mContext,
|
||||||
() -> {
|
() -> AudioSharingDialogFragment.show(
|
||||||
// Check nullability to pass NullAway check
|
mFragment, mDeviceItemsForSharing, listener, eventData));
|
||||||
if (mFragment != null) {
|
|
||||||
AudioSharingDialogFragment.show(
|
|
||||||
mFragment, mDeviceItemsForSharing, listener, eventData);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showErrorDialog() {
|
private void showErrorDialog() {
|
||||||
|
@@ -91,7 +91,8 @@ public class StreamSettingsCategoryController extends BasePreferenceController
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return BluetoothUtils.isAudioSharingEnabled() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
return BluetoothUtils.isAudioSharingUIAvailable(mContext) ? AVAILABLE
|
||||||
|
: UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -214,15 +214,16 @@ public class AudioStreamConfirmDialog extends InstrumentedDialogFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int getDialogId(boolean hasMetadata, boolean hasConnectedDevice) {
|
private int getDialogId(boolean hasMetadata, boolean hasConnectedDevice) {
|
||||||
if (!BluetoothUtils.isAudioSharingEnabled()) {
|
if (BluetoothUtils.isAudioSharingUIAvailable(mContext)) {
|
||||||
|
if (!hasConnectedDevice) {
|
||||||
|
return SettingsEnums.DIALOG_AUDIO_STREAM_CONFIRM_NO_LE_DEVICE;
|
||||||
|
}
|
||||||
|
return hasMetadata
|
||||||
|
? SettingsEnums.DIALOG_AUDIO_STREAM_CONFIRM_LISTEN
|
||||||
|
: SettingsEnums.DIALOG_AUDIO_STREAM_CONFIRM_DATA_ERROR;
|
||||||
|
} else {
|
||||||
return SettingsEnums.DIALOG_AUDIO_STREAM_CONFIRM_FEATURE_UNSUPPORTED;
|
return SettingsEnums.DIALOG_AUDIO_STREAM_CONFIRM_FEATURE_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
if (!hasConnectedDevice) {
|
|
||||||
return SettingsEnums.DIALOG_AUDIO_STREAM_CONFIRM_NO_LE_DEVICE;
|
|
||||||
}
|
|
||||||
return hasMetadata
|
|
||||||
? SettingsEnums.DIALOG_AUDIO_STREAM_CONFIRM_LISTEN
|
|
||||||
: SettingsEnums.DIALOG_AUDIO_STREAM_CONFIRM_DATA_ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@@ -50,7 +50,7 @@ public class AudioStreamConfirmDialogActivity extends SettingsActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void createUiFromIntent(@Nullable Bundle savedState, Intent intent) {
|
protected void createUiFromIntent(@Nullable Bundle savedState, Intent intent) {
|
||||||
if (BluetoothUtils.isAudioSharingEnabled()
|
if (BluetoothUtils.isAudioSharingUIAvailable(this)
|
||||||
&& !AudioSharingUtils.isAudioSharingProfileReady(mProfileManager)) {
|
&& !AudioSharingUtils.isAudioSharingProfileReady(mProfileManager)) {
|
||||||
Log.d(TAG, "createUiFromIntent() : supported but not ready, skip createUiFromIntent");
|
Log.d(TAG, "createUiFromIntent() : supported but not ready, skip createUiFromIntent");
|
||||||
mSavedState = savedState;
|
mSavedState = savedState;
|
||||||
@@ -67,7 +67,7 @@ public class AudioStreamConfirmDialogActivity extends SettingsActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
if (BluetoothUtils.isAudioSharingEnabled()
|
if (BluetoothUtils.isAudioSharingUIAvailable(this)
|
||||||
&& !AudioSharingUtils.isAudioSharingProfileReady(mProfileManager)) {
|
&& !AudioSharingUtils.isAudioSharingProfileReady(mProfileManager)) {
|
||||||
Log.d(TAG, "onStart() : supported but not ready, listen to service ready");
|
Log.d(TAG, "onStart() : supported but not ready, listen to service ready");
|
||||||
if (mProfileManager != null) {
|
if (mProfileManager != null) {
|
||||||
@@ -87,7 +87,7 @@ public class AudioStreamConfirmDialogActivity extends SettingsActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onServiceConnected() {
|
public void onServiceConnected() {
|
||||||
if (BluetoothUtils.isAudioSharingEnabled()
|
if (BluetoothUtils.isAudioSharingUIAvailable(this)
|
||||||
&& AudioSharingUtils.isAudioSharingProfileReady(mProfileManager)) {
|
&& AudioSharingUtils.isAudioSharingProfileReady(mProfileManager)) {
|
||||||
if (mProfileManager != null) {
|
if (mProfileManager != null) {
|
||||||
mProfileManager.removeServiceListener(this);
|
mProfileManager.removeServiceListener(this);
|
||||||
|
@@ -122,7 +122,7 @@ public class AudioStreamMediaService extends Service {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
if (!BluetoothUtils.isAudioSharingEnabled()) {
|
if (!BluetoothUtils.isAudioSharingUIAvailable(this)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log.d(TAG, "onCreate()");
|
Log.d(TAG, "onCreate()");
|
||||||
@@ -181,32 +181,32 @@ public class AudioStreamMediaService extends Service {
|
|||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
Log.d(TAG, "onDestroy()");
|
Log.d(TAG, "onDestroy()");
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
if (!BluetoothUtils.isAudioSharingEnabled()) {
|
if (BluetoothUtils.isAudioSharingUIAvailable(this)) {
|
||||||
return;
|
if (mDevices != null) {
|
||||||
}
|
mDevices.clear();
|
||||||
if (mDevices != null) {
|
mDevices = null;
|
||||||
mDevices.clear();
|
|
||||||
mDevices = null;
|
|
||||||
}
|
|
||||||
synchronized (mLocalSessionLock) {
|
|
||||||
if (mLocalSession != null) {
|
|
||||||
mLocalSession.release();
|
|
||||||
mLocalSession = null;
|
|
||||||
}
|
}
|
||||||
|
synchronized (mLocalSessionLock) {
|
||||||
|
if (mLocalSession != null) {
|
||||||
|
mLocalSession.release();
|
||||||
|
mLocalSession = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mExecutor.execute(
|
||||||
|
() -> {
|
||||||
|
if (mLocalBtManager != null) {
|
||||||
|
mLocalBtManager.getEventManager().unregisterCallback(
|
||||||
|
mBluetoothCallback);
|
||||||
|
}
|
||||||
|
if (mLeBroadcastAssistant != null && mBroadcastAssistantCallback != null) {
|
||||||
|
mLeBroadcastAssistant.unregisterServiceCallBack(
|
||||||
|
mBroadcastAssistantCallback);
|
||||||
|
}
|
||||||
|
if (mVolumeControl != null && mVolumeControlCallback != null) {
|
||||||
|
mVolumeControl.unregisterCallback(mVolumeControlCallback);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
mExecutor.execute(
|
|
||||||
() -> {
|
|
||||||
if (mLocalBtManager != null) {
|
|
||||||
mLocalBtManager.getEventManager().unregisterCallback(mBluetoothCallback);
|
|
||||||
}
|
|
||||||
if (mLeBroadcastAssistant != null && mBroadcastAssistantCallback != null) {
|
|
||||||
mLeBroadcastAssistant.unregisterServiceCallBack(
|
|
||||||
mBroadcastAssistantCallback);
|
|
||||||
}
|
|
||||||
if (mVolumeControl != null && mVolumeControlCallback != null) {
|
|
||||||
mVolumeControl.unregisterCallback(mVolumeControlCallback);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
package com.android.settings.network
|
package com.android.settings.network
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.os.UserManager
|
||||||
|
import com.android.settings.PreferenceRestrictionMixin
|
||||||
import com.android.settings.R
|
import com.android.settings.R
|
||||||
import com.android.settings.flags.Flags
|
import com.android.settings.flags.Flags
|
||||||
import com.android.settingslib.metadata.ProvidePreferenceScreen
|
import com.android.settingslib.metadata.ProvidePreferenceScreen
|
||||||
@@ -23,7 +25,7 @@ import com.android.settingslib.metadata.preferenceHierarchy
|
|||||||
import com.android.settingslib.preference.PreferenceScreenCreator
|
import com.android.settingslib.preference.PreferenceScreenCreator
|
||||||
|
|
||||||
@ProvidePreferenceScreen
|
@ProvidePreferenceScreen
|
||||||
class MobileNetworkListScreen : PreferenceScreenCreator {
|
class MobileNetworkListScreen : PreferenceScreenCreator, PreferenceRestrictionMixin {
|
||||||
override val key: String
|
override val key: String
|
||||||
get() = KEY
|
get() = KEY
|
||||||
|
|
||||||
@@ -36,6 +38,11 @@ class MobileNetworkListScreen : PreferenceScreenCreator {
|
|||||||
override val keywords: Int
|
override val keywords: Int
|
||||||
get() = R.string.keywords_more_mobile_networks
|
get() = R.string.keywords_more_mobile_networks
|
||||||
|
|
||||||
|
override fun isEnabled(context: Context) = super<PreferenceRestrictionMixin>.isEnabled(context)
|
||||||
|
|
||||||
|
override val restrictionKey: String
|
||||||
|
get() = UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS
|
||||||
|
|
||||||
override fun isFlagEnabled(context: Context) = Flags.catalystMobileNetworkList()
|
override fun isFlagEnabled(context: Context) = Flags.catalystMobileNetworkList()
|
||||||
|
|
||||||
override fun hasCompleteHierarchy() = false
|
override fun hasCompleteHierarchy() = false
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
package com.android.settings.network
|
package com.android.settings.network
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.os.UserManager
|
||||||
|
import com.android.settings.PreferenceRestrictionMixin
|
||||||
import com.android.settings.R
|
import com.android.settings.R
|
||||||
import com.android.settings.flags.Flags
|
import com.android.settings.flags.Flags
|
||||||
import com.android.settingslib.metadata.PreferenceAvailabilityProvider
|
import com.android.settingslib.metadata.PreferenceAvailabilityProvider
|
||||||
@@ -24,7 +26,8 @@ import com.android.settingslib.metadata.preferenceHierarchy
|
|||||||
import com.android.settingslib.preference.PreferenceScreenCreator
|
import com.android.settingslib.preference.PreferenceScreenCreator
|
||||||
|
|
||||||
@ProvidePreferenceScreen
|
@ProvidePreferenceScreen
|
||||||
class NetworkProviderScreen : PreferenceScreenCreator, PreferenceAvailabilityProvider {
|
class NetworkProviderScreen :
|
||||||
|
PreferenceScreenCreator, PreferenceAvailabilityProvider, PreferenceRestrictionMixin {
|
||||||
override val key: String
|
override val key: String
|
||||||
get() = KEY
|
get() = KEY
|
||||||
|
|
||||||
@@ -40,6 +43,11 @@ class NetworkProviderScreen : PreferenceScreenCreator, PreferenceAvailabilityPro
|
|||||||
override fun isAvailable(context: Context) =
|
override fun isAvailable(context: Context) =
|
||||||
context.resources.getBoolean(R.bool.config_show_internet_settings)
|
context.resources.getBoolean(R.bool.config_show_internet_settings)
|
||||||
|
|
||||||
|
override fun isEnabled(context: Context) = super<PreferenceRestrictionMixin>.isEnabled(context)
|
||||||
|
|
||||||
|
override val restrictionKey: String
|
||||||
|
get() = UserManager.DISALLOW_CONFIG_WIFI
|
||||||
|
|
||||||
override fun isFlagEnabled(context: Context) = Flags.catalystInternetSettings()
|
override fun isFlagEnabled(context: Context) = Flags.catalystInternetSettings()
|
||||||
|
|
||||||
override fun hasCompleteHierarchy() = false
|
override fun hasCompleteHierarchy() = false
|
||||||
|
@@ -17,6 +17,8 @@ package com.android.settings.network.tether
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.TetheringManager
|
import android.net.TetheringManager
|
||||||
|
import android.os.UserManager
|
||||||
|
import com.android.settings.PreferenceRestrictionMixin
|
||||||
import com.android.settings.R
|
import com.android.settings.R
|
||||||
import com.android.settings.flags.Flags
|
import com.android.settings.flags.Flags
|
||||||
import com.android.settings.network.TetherPreferenceController
|
import com.android.settings.network.TetherPreferenceController
|
||||||
@@ -28,7 +30,8 @@ import com.android.settingslib.metadata.preferenceHierarchy
|
|||||||
import com.android.settingslib.preference.PreferenceScreenCreator
|
import com.android.settingslib.preference.PreferenceScreenCreator
|
||||||
|
|
||||||
@ProvidePreferenceScreen
|
@ProvidePreferenceScreen
|
||||||
class TetherScreen : PreferenceScreenCreator, PreferenceAvailabilityProvider {
|
class TetherScreen :
|
||||||
|
PreferenceScreenCreator, PreferenceAvailabilityProvider, PreferenceRestrictionMixin {
|
||||||
|
|
||||||
override val key: String
|
override val key: String
|
||||||
get() = KEY
|
get() = KEY
|
||||||
@@ -49,6 +52,11 @@ class TetherScreen : PreferenceScreenCreator, PreferenceAvailabilityProvider {
|
|||||||
|
|
||||||
override fun isAvailable(context: Context) = TetherUtil.isTetherAvailable(context)
|
override fun isAvailable(context: Context) = TetherUtil.isTetherAvailable(context)
|
||||||
|
|
||||||
|
override fun isEnabled(context: Context) = super<PreferenceRestrictionMixin>.isEnabled(context)
|
||||||
|
|
||||||
|
override val restrictionKey: String
|
||||||
|
get() = UserManager.DISALLOW_CONFIG_TETHERING
|
||||||
|
|
||||||
override fun isFlagEnabled(context: Context) = Flags.catalystTetherSettings()
|
override fun isFlagEnabled(context: Context) = Flags.catalystTetherSettings()
|
||||||
|
|
||||||
override fun hasCompleteHierarchy() = false
|
override fun hasCompleteHierarchy() = false
|
||||||
|
@@ -23,6 +23,9 @@ import static org.mockito.Mockito.when;
|
|||||||
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.platform.test.annotations.DisableFlags;
|
||||||
|
import android.platform.test.annotations.EnableFlags;
|
||||||
|
import android.platform.test.flag.junit.SetFlagsRule;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.view.accessibility.CaptioningManager.CaptionStyle;
|
import android.view.accessibility.CaptioningManager.CaptionStyle;
|
||||||
|
|
||||||
@@ -49,6 +52,8 @@ public class CaptioningCustomControllerTest {
|
|||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
|
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
|
||||||
|
@Rule
|
||||||
|
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||||
@Mock
|
@Mock
|
||||||
private PreferenceScreen mScreen;
|
private PreferenceScreen mScreen;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -57,22 +62,43 @@ public class CaptioningCustomControllerTest {
|
|||||||
private ContentResolver mContentResolver;
|
private ContentResolver mContentResolver;
|
||||||
private CaptioningCustomController mController;
|
private CaptioningCustomController mController;
|
||||||
private Preference mPreference;
|
private Preference mPreference;
|
||||||
|
private CaptionHelper mCaptionHelper;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mContentResolver = mContext.getContentResolver();
|
mContentResolver = mContext.getContentResolver();
|
||||||
mController = new CaptioningCustomController(mContext, PREF_KEY,
|
mCaptionHelper = new CaptionHelper(mContext);
|
||||||
|
mController = new CaptioningCustomController(mContext, PREF_KEY, mCaptionHelper,
|
||||||
mAccessibilitySettingsContentObserver);
|
mAccessibilitySettingsContentObserver);
|
||||||
mPreference = new Preference(mContext);
|
mPreference = new Preference(mContext);
|
||||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@DisableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
|
||||||
public void getAvailabilityStatus_shouldReturnAvailable() {
|
public void getAvailabilityStatus_shouldReturnAvailable() {
|
||||||
assertThat(mController.getAvailabilityStatus())
|
assertThat(mController.getAvailabilityStatus())
|
||||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
.isEqualTo(BasePreferenceController.AVAILABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@EnableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
|
||||||
|
public void getAvailabilityStatus_customCaption_shouldReturnAvailable() {
|
||||||
|
mCaptionHelper.setRawUserStyle(CaptionStyle.PRESET_CUSTOM);
|
||||||
|
|
||||||
|
assertThat(mController.getAvailabilityStatus())
|
||||||
|
.isEqualTo(BasePreferenceController.AVAILABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@EnableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
|
||||||
|
public void getAvailabilityStatus_notCustom_shouldReturnUnsearchable() {
|
||||||
|
mCaptionHelper.setRawUserStyle(0);
|
||||||
|
|
||||||
|
assertThat(mController.getAvailabilityStatus())
|
||||||
|
.isEqualTo(BasePreferenceController.AVAILABLE_UNSEARCHABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void displayPreference_byDefault_shouldIsInvisible() {
|
public void displayPreference_byDefault_shouldIsInvisible() {
|
||||||
|
@@ -24,6 +24,9 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.platform.test.annotations.DisableFlags;
|
||||||
|
import android.platform.test.annotations.EnableFlags;
|
||||||
|
import android.platform.test.flag.junit.SetFlagsRule;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.accessibility.CaptioningManager;
|
import android.view.accessibility.CaptioningManager;
|
||||||
@@ -53,16 +56,21 @@ public class CaptioningWindowColorControllerTest {
|
|||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
|
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
|
||||||
|
@Rule
|
||||||
|
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||||
@Mock
|
@Mock
|
||||||
private PreferenceScreen mScreen;
|
private PreferenceScreen mScreen;
|
||||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||||
private CaptioningWindowColorController mController;
|
private CaptioningWindowColorController mController;
|
||||||
private ColorPreference mPreference;
|
private ColorPreference mPreference;
|
||||||
private ShadowCaptioningManager mShadowCaptioningManager;
|
private ShadowCaptioningManager mShadowCaptioningManager;
|
||||||
|
private CaptionHelper mCaptionHelper;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mController = new CaptioningWindowColorController(mContext, "captioning_window_color");
|
mCaptionHelper = new CaptionHelper(mContext);
|
||||||
|
mController = new CaptioningWindowColorController(
|
||||||
|
mContext, "captioning_window_color", mCaptionHelper);
|
||||||
final AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
|
final AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
|
||||||
mPreference = new ColorPreference(mContext, attributeSet);
|
mPreference = new ColorPreference(mContext, attributeSet);
|
||||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||||
@@ -71,11 +79,30 @@ public class CaptioningWindowColorControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@DisableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
|
||||||
public void getAvailabilityStatus_shouldReturnAvailable() {
|
public void getAvailabilityStatus_shouldReturnAvailable() {
|
||||||
assertThat(mController.getAvailabilityStatus())
|
assertThat(mController.getAvailabilityStatus())
|
||||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
.isEqualTo(BasePreferenceController.AVAILABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@EnableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
|
||||||
|
public void getAvailabilityStatus_customCaption_shouldReturnAvailable() {
|
||||||
|
mCaptionHelper.setRawUserStyle(CaptionStyle.PRESET_CUSTOM);
|
||||||
|
|
||||||
|
assertThat(mController.getAvailabilityStatus())
|
||||||
|
.isEqualTo(BasePreferenceController.AVAILABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@EnableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
|
||||||
|
public void getAvailabilityStatus_noCustom_shouldReturnUnsearchable() {
|
||||||
|
mCaptionHelper.setRawUserStyle(0);
|
||||||
|
|
||||||
|
assertThat(mController.getAvailabilityStatus())
|
||||||
|
.isEqualTo(BasePreferenceController.AVAILABLE_UNSEARCHABLE);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSummary_defaultValue_shouldReturnNone() {
|
public void getSummary_defaultValue_shouldReturnNone() {
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
|
@@ -24,6 +24,9 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.platform.test.annotations.DisableFlags;
|
||||||
|
import android.platform.test.annotations.EnableFlags;
|
||||||
|
import android.platform.test.flag.junit.SetFlagsRule;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.accessibility.CaptioningManager;
|
import android.view.accessibility.CaptioningManager;
|
||||||
@@ -48,19 +51,24 @@ import org.robolectric.shadows.ShadowCaptioningManager;
|
|||||||
/** Tests for {@link CaptioningWindowOpacityController}. */
|
/** Tests for {@link CaptioningWindowOpacityController}. */
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
public class CaptioningWindowOpacityControllerTest {
|
public class CaptioningWindowOpacityControllerTest {
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
|
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
|
||||||
|
@Rule
|
||||||
|
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private PreferenceScreen mScreen;
|
private PreferenceScreen mScreen;
|
||||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||||
private CaptioningWindowOpacityController mController;
|
private CaptioningWindowOpacityController mController;
|
||||||
private ColorPreference mPreference;
|
private ColorPreference mPreference;
|
||||||
private ShadowCaptioningManager mShadowCaptioningManager;
|
private ShadowCaptioningManager mShadowCaptioningManager;
|
||||||
|
private CaptionHelper mCaptionHelper;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mController = new CaptioningWindowOpacityController(mContext, "captioning_window_opacity");
|
mCaptionHelper = new CaptionHelper(mContext);
|
||||||
|
mController = new CaptioningWindowOpacityController(
|
||||||
|
mContext, "captioning_window_opacity", mCaptionHelper);
|
||||||
final AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
|
final AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
|
||||||
mPreference = new ColorPreference(mContext, attributeSet);
|
mPreference = new ColorPreference(mContext, attributeSet);
|
||||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||||
@@ -69,11 +77,30 @@ public class CaptioningWindowOpacityControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@DisableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
|
||||||
public void getAvailabilityStatus_shouldReturnAvailable() {
|
public void getAvailabilityStatus_shouldReturnAvailable() {
|
||||||
assertThat(mController.getAvailabilityStatus())
|
assertThat(mController.getAvailabilityStatus())
|
||||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
.isEqualTo(BasePreferenceController.AVAILABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@EnableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
|
||||||
|
public void getAvailabilityStatus_customCaption_shouldReturnAvailable() {
|
||||||
|
mCaptionHelper.setRawUserStyle(CaptioningManager.CaptionStyle.PRESET_CUSTOM);
|
||||||
|
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(
|
||||||
|
BasePreferenceController.AVAILABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@EnableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
|
||||||
|
public void getAvailabilityStatus_notCustom_shouldReturnUnsearchable() {
|
||||||
|
mCaptionHelper.setRawUserStyle(0);
|
||||||
|
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(
|
||||||
|
BasePreferenceController.AVAILABLE_UNSEARCHABLE);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSummary_defaultValue_shouldReturnNonTransparent() {
|
public void getSummary_defaultValue_shouldReturnNonTransparent() {
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
|
@@ -30,8 +30,11 @@ import static org.mockito.Mockito.when;
|
|||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
import android.accounts.AccountManager;
|
import android.accounts.AccountManager;
|
||||||
import android.accounts.AuthenticatorDescription;
|
import android.accounts.AuthenticatorDescription;
|
||||||
|
import android.content.ClipData;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
|
|
||||||
import androidx.collection.ArraySet;
|
import androidx.collection.ArraySet;
|
||||||
@@ -250,4 +253,13 @@ public class AccountTypePreferenceLoaderTest {
|
|||||||
mPrefLoader.filterBlockedFragments(parent, Set.of("nomatch", "other"));
|
mPrefLoader.filterBlockedFragments(parent, Set.of("nomatch", "other"));
|
||||||
verify(pref).setOnPreferenceClickListener(any());
|
verify(pref).setOnPreferenceClickListener(any());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isSafeIntent_hasContextScheme_returnFalse() {
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.setClipData(ClipData.newRawUri(null,
|
||||||
|
Uri.parse("content://com.android.settings.files/my_cache/NOTICE.html")));
|
||||||
|
|
||||||
|
assertThat(mPrefLoader.isSafeIntent(mPackageManager, intent, mAccount.type)).isFalse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user