Snap for 12313714 from c43be041f5 to 24Q4-release

Change-Id: I3facf14c54947ba358db46adb8432360a913b011
This commit is contained in:
Android Build Coastguard Worker
2024-09-03 23:21:19 +00:00
35 changed files with 266 additions and 114 deletions

View File

@@ -758,8 +758,16 @@
<string name="audio_streams_dialog_no_le_device_subtitle" product="default">To listen to an audio stream, first connect headphones that support LE Audio to this phone.</string> <string name="audio_streams_dialog_no_le_device_subtitle" product="default">To listen to an audio stream, first connect headphones that support LE Audio to this phone.</string>
<string name="audio_streams_dialog_no_le_device_subtitle" product="tablet">To listen to an audio stream, first connect headphones that support LE Audio to this tablet.</string> <string name="audio_streams_dialog_no_le_device_subtitle" product="tablet">To listen to an audio stream, first connect headphones that support LE Audio to this tablet.</string>
<string name="audio_streams_dialog_no_le_device_subtitle" product="device">To listen to an audio stream, first connect headphones that support LE Audio to this device.</string> <string name="audio_streams_dialog_no_le_device_subtitle" product="device">To listen to an audio stream, first connect headphones that support LE Audio to this device.</string>
<!-- Le audio streams no le device dialog subtitle with learn more link [CHAR LIMIT=NONE] -->
<string name="audio_streams_dialog_no_le_device_subtitle_with_link" product="default">To listen to an audio stream, first connect headphones that support LE Audio to this phone. <annotation id="link">Learn more</annotation></string>
<string name="audio_streams_dialog_no_le_device_subtitle_with_link" product="tablet">To listen to an audio stream, first connect headphones that support LE Audio to this tablet. <annotation id="link">Learn more</annotation></string>
<string name="audio_streams_dialog_no_le_device_subtitle_with_link" product="device">To listen to an audio stream, first connect headphones that support LE Audio to this device. <annotation id="link">Learn more</annotation></string>
<!-- Le audio streams unsupported device subtitle [CHAR LIMIT=NONE] --> <!-- Le audio streams unsupported device subtitle [CHAR LIMIT=NONE] -->
<string name="audio_streams_dialog_unsupported_device_subtitle" product="default">This phone doesn\'t support LE Audio, which is needed to listen to audio streams.</string> <string name="audio_streams_dialog_unsupported_device_subtitle" product="default">This phone doesn\'t support LE Audio, which is needed to listen to audio streams.</string>
<string name="audio_streams_dialog_unsupported_device_subtitle" product="tablet">This tablet doesn\'t support LE Audio, which is needed to listen to audio streams.</string> <string name="audio_streams_dialog_unsupported_device_subtitle" product="tablet">This tablet doesn\'t support LE Audio, which is needed to listen to audio streams.</string>
<string name="audio_streams_dialog_unsupported_device_subtitle" product="device">This device doesn\'t support LE Audio, which is needed to listen to audio streams.</string> <string name="audio_streams_dialog_unsupported_device_subtitle" product="device">This device doesn\'t support LE Audio, which is needed to listen to audio streams.</string>
<!-- Content for audio sharing confirm dialog with learn more link [CHAR LIMIT=none]-->
<string name="audio_sharing_confirm_dialog_content_with_link" product="default">To start sharing audio, first connect LE Audio headphones to your phone. <annotation id="link">Learn more about compatible devices</annotation></string>
<string name="audio_sharing_confirm_dialog_content_with_link" product="tablet">To start sharing audio, first connect LE Audio headphones to your tablet. <annotation id="link">Learn more about compatible devices</annotation></string>
<string name="audio_sharing_confirm_dialog_content_with_link" product="device">To start sharing audio, first connect LE Audio headphones to your device. <annotation id="link">Learn more about compatible devices</annotation></string>
</resources> </resources>

View File

@@ -13749,6 +13749,8 @@
<string name="audio_sharing_confirm_dialog_title">Connect a compatible device</string> <string name="audio_sharing_confirm_dialog_title">Connect a compatible device</string>
<!-- Content for audio sharing confirm dialog [CHAR LIMIT=none]--> <!-- Content for audio sharing confirm dialog [CHAR LIMIT=none]-->
<string name="audio_sharing_comfirm_dialog_content">To start sharing audio, first connect LE Audio headphones to your phone</string> <string name="audio_sharing_comfirm_dialog_content">To start sharing audio, first connect LE Audio headphones to your phone</string>
<!-- Text for audio sharing switch active device button [CHAR LIMIT=none]-->
<string name="audio_sharing_switch_active_button_label">Switch to <xliff:g example="My buds" id="device_name">%1$s</xliff:g></string>
<!-- Title for audio streams preference category [CHAR LIMIT=none]--> <!-- Title for audio streams preference category [CHAR LIMIT=none]-->
<string name="audio_streams_category_title">Connect to a LE audio stream</string> <string name="audio_streams_category_title">Connect to a LE audio stream</string>
@@ -13838,6 +13840,8 @@
<string name="audio_streams_main_page_password_dialog_cannot_edit">Can\u0027t edit password while sharing. To change the password, first turn off audio sharing.</string> <string name="audio_streams_main_page_password_dialog_cannot_edit">Can\u0027t edit password while sharing. To change the password, first turn off audio sharing.</string>
<!-- Text for audio sharing qrcode scanner [CHAR LIMIT=none]--> <!-- Text for audio sharing qrcode scanner [CHAR LIMIT=none]-->
<string name="audio_streams_qr_code_scanner_label">QR code scanner</string> <string name="audio_streams_qr_code_scanner_label">QR code scanner</string>
<!-- Learn more link for audio sharing qrcode [CHAR LIMIT=none]-->
<string name="audio_streams_qr_code_help_with_link"><annotation id="link">Need help?</annotation></string>
<!-- url for learning more about bluetooth audio sharing --> <!-- url for learning more about bluetooth audio sharing -->

View File

@@ -25,6 +25,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.flags.Flags; import com.android.internal.telephony.flags.Flags;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController; import com.android.settings.core.TogglePreferenceController;
import com.android.settings.overlay.FeatureFactory;
/** Preference controller for Hearing Aid Compatibility (HAC) settings */ /** Preference controller for Hearing Aid Compatibility (HAC) settings */
public class HearingAidCompatibilityPreferenceController extends TogglePreferenceController { public class HearingAidCompatibilityPreferenceController extends TogglePreferenceController {
@@ -73,6 +74,8 @@ public class HearingAidCompatibilityPreferenceController extends TogglePreferenc
@Override @Override
public boolean setChecked(boolean isChecked) { public boolean setChecked(boolean isChecked) {
FeatureFactory.getFeatureFactory().getMetricsFeatureProvider().changed(
getMetricsCategory(), getPreferenceKey(), isChecked ? 1 : 0);
setAudioParameterHacEnabled(isChecked); setAudioParameterHacEnabled(isChecked);
return Settings.System.putInt(mContext.getContentResolver(), Settings.System.HEARING_AID, return Settings.System.putInt(mContext.getContentResolver(), Settings.System.HEARING_AID,
(isChecked ? HAC_ENABLED : HAC_DISABLED)); (isChecked ? HAC_ENABLED : HAC_DISABLED));

View File

@@ -27,6 +27,7 @@ import android.content.Context;
import android.database.ContentObserver; import android.database.ContentObserver;
import android.net.Uri; import android.net.Uri;
import android.os.Handler; import android.os.Handler;
import android.os.Looper;
import android.os.VibrationAttributes; import android.os.VibrationAttributes;
import android.os.Vibrator; import android.os.Vibrator;
import android.provider.Settings; import android.provider.Settings;
@@ -69,7 +70,8 @@ public class KeyboardVibrationTogglePreferenceController extends TogglePreferenc
public KeyboardVibrationTogglePreferenceController(Context context, String preferenceKey) { public KeyboardVibrationTogglePreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey); super(context, preferenceKey);
mVibrator = context.getSystemService(Vibrator.class); mVibrator = context.getSystemService(Vibrator.class);
mContentObserver = new ContentObserver(new Handler(/* async= */ true)) { Handler handler = Looper.myLooper() != null ? new Handler(/* async= */ true) : null;
mContentObserver = new ContentObserver(handler) {
@Override @Override
public void onChange(boolean selfChange, Uri uri) { public void onChange(boolean selfChange, Uri uri) {
if (uri.equals(MAIN_VIBRATION_SWITCH_URI)) { if (uri.equals(MAIN_VIBRATION_SWITCH_URI)) {

View File

@@ -23,6 +23,7 @@ import android.content.Context;
import android.database.ContentObserver; import android.database.ContentObserver;
import android.net.Uri; import android.net.Uri;
import android.os.Handler; import android.os.Handler;
import android.os.Looper;
import android.os.VibrationAttributes; import android.os.VibrationAttributes;
import android.os.Vibrator; import android.os.Vibrator;
import android.provider.Settings; import android.provider.Settings;
@@ -49,7 +50,8 @@ public class VibrationMainSwitchPreferenceController extends SettingsMainSwitchP
public VibrationMainSwitchPreferenceController(Context context, String preferenceKey) { public VibrationMainSwitchPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey); super(context, preferenceKey);
mVibrator = context.getSystemService(Vibrator.class); mVibrator = context.getSystemService(Vibrator.class);
mSettingObserver = new ContentObserver(new Handler(/* async= */ true)) { Handler handler = Looper.myLooper() != null ? new Handler(/* async= */ true) : null;
mSettingObserver = new ContentObserver(handler) {
@Override @Override
public void onChange(boolean selfChange, Uri uri) { public void onChange(boolean selfChange, Uri uri) {
updateState(mSwitchPreference); updateState(mSwitchPreference);

View File

@@ -27,6 +27,7 @@ import android.database.ContentObserver;
import android.media.AudioManager; import android.media.AudioManager;
import android.net.Uri; import android.net.Uri;
import android.os.Handler; import android.os.Handler;
import android.os.Looper;
import android.os.VibrationAttributes; import android.os.VibrationAttributes;
import android.os.VibrationEffect; import android.os.VibrationEffect;
import android.os.Vibrator; import android.os.Vibrator;
@@ -165,7 +166,7 @@ public abstract class VibrationPreferenceConfig {
/** Creates observer for given preference. */ /** Creates observer for given preference. */
public SettingObserver(VibrationPreferenceConfig preferenceConfig) { public SettingObserver(VibrationPreferenceConfig preferenceConfig) {
super(new Handler(/* async= */ true)); super(Looper.myLooper() != null ? new Handler(/* async= */ true) : null);
mUri = Settings.System.getUriFor(preferenceConfig.getSettingKey()); mUri = Settings.System.getUriFor(preferenceConfig.getSettingKey());
if (preferenceConfig.isRestrictedByRingerModeSilent()) { if (preferenceConfig.isRestrictedByRingerModeSilent()) {

View File

@@ -21,6 +21,7 @@ import android.database.ContentObserver;
import android.media.AudioManager; import android.media.AudioManager;
import android.net.Uri; import android.net.Uri;
import android.os.Handler; import android.os.Handler;
import android.os.Looper;
import android.os.Vibrator; import android.os.Vibrator;
import android.provider.DeviceConfig; import android.provider.DeviceConfig;
import android.provider.Settings; import android.provider.Settings;
@@ -74,7 +75,8 @@ public class VibrationRampingRingerTogglePreferenceController
mRingVibrationPreferenceConfig = new RingVibrationPreferenceConfig(context); mRingVibrationPreferenceConfig = new RingVibrationPreferenceConfig(context);
mRingSettingObserver = new VibrationPreferenceConfig.SettingObserver( mRingSettingObserver = new VibrationPreferenceConfig.SettingObserver(
mRingVibrationPreferenceConfig); mRingVibrationPreferenceConfig);
mSettingObserver = new ContentObserver(new Handler(/* async= */ true)) { Handler handler = Looper.myLooper() != null ? new Handler(/* async= */ true) : null;
mSettingObserver = new ContentObserver(handler) {
@Override @Override
public void onChange(boolean selfChange, Uri uri) { public void onChange(boolean selfChange, Uri uri) {
updateState(mPreference); updateState(mPreference);

View File

@@ -26,6 +26,7 @@ import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
import com.android.settings.core.BasePreferenceController; import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.SubSettingLauncher; import com.android.settings.core.SubSettingLauncher;
import com.android.settings.dashboard.DashboardFragment; import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.overlay.FeatureFactory;
/** Preference controller for all bluetooth device preference. */ /** Preference controller for all bluetooth device preference. */
public class ViewAllBluetoothDevicesPreferenceController extends BasePreferenceController { public class ViewAllBluetoothDevicesPreferenceController extends BasePreferenceController {
@@ -52,6 +53,8 @@ public class ViewAllBluetoothDevicesPreferenceController extends BasePreferenceC
@Override @Override
public boolean handlePreferenceTreeClick(Preference preference) { public boolean handlePreferenceTreeClick(Preference preference) {
if (TextUtils.equals(preference.getKey(), getPreferenceKey())) { if (TextUtils.equals(preference.getKey(), getPreferenceKey())) {
FeatureFactory.getFeatureFactory().getMetricsFeatureProvider().clicked(
getMetricsCategory(), getPreferenceKey());
launchConnectedDevicePage(); launchConnectedDevicePage();
return true; return true;
} }

View File

@@ -38,6 +38,7 @@ import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.bluetooth.CachedBluetoothDevice; import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.HapClientProfile; import com.android.settingslib.bluetooth.HapClientProfile;
import com.android.settingslib.bluetooth.LocalBluetoothManager; import com.android.settingslib.bluetooth.LocalBluetoothManager;
@@ -111,6 +112,7 @@ public class BluetoothDetailsHearingAidsPresetsController extends
final int index = listPreference.findIndexOfValue(value); final int index = listPreference.findIndexOfValue(value);
final String presetName = listPreference.getEntries()[index].toString(); final String presetName = listPreference.getEntries()[index].toString();
final int presetIndex = Integer.parseInt(value); final int presetIndex = Integer.parseInt(value);
logPresetChangedIfNeeded();
listPreference.setSummary(presetName); listPreference.setSummary(presetName);
if (DEBUG) { if (DEBUG) {
Log.d(TAG, "onPreferenceChange" Log.d(TAG, "onPreferenceChange"
@@ -373,4 +375,15 @@ public class BluetoothDetailsHearingAidsPresetsController extends
mHapClientProfile.selectPreset(memberDevice.getDevice(), presetIndex); mHapClientProfile.selectPreset(memberDevice.getDevice(), presetIndex);
} }
} }
private void logPresetChangedIfNeeded() {
if (mPreference == null || mPreference.getEntries() == null) {
return;
}
if (mFragment instanceof BluetoothDeviceDetailsFragment) {
int category = ((BluetoothDeviceDetailsFragment) mFragment).getMetricsCategory();
FeatureFactory.getFeatureFactory().getMetricsFeatureProvider().changed(category,
getPreferenceKey(), mPreference.getEntries().length);
}
}
} }

View File

@@ -158,7 +158,11 @@ public class AudioSharingJoinDialogFragment extends InstrumentedDialogFragment {
dismiss(); dismiss();
}) })
.setCustomNegativeButton( .setCustomNegativeButton(
R.string.audio_sharing_no_thanks_button_label, getMetricsCategory() == SettingsEnums.DIALOG_START_AUDIO_SHARING
? getString(
R.string.audio_sharing_switch_active_button_label,
newDeviceName)
: getString(R.string.audio_sharing_no_thanks_button_label),
v -> { v -> {
if (sListener != null) { if (sListener != null) {
sListener.onCancelClick(); sListener.onCancelClick();

View File

@@ -14,7 +14,7 @@
* limitations under the License * limitations under the License
*/ */
package com.android.settings.security; package com.android.settings.development;
import android.content.Context; import android.content.Context;
import android.text.TextUtils; import android.text.TextUtils;

View File

@@ -27,6 +27,7 @@ import android.telephony.ims.ImsStateCallback
import android.telephony.ims.RegistrationManager import android.telephony.ims.RegistrationManager
import android.telephony.ims.feature.MmTelFeature import android.telephony.ims.feature.MmTelFeature
import android.util.Log import android.util.Log
import androidx.annotation.VisibleForTesting
import kotlin.coroutines.resume import kotlin.coroutines.resume
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.asExecutor import kotlinx.coroutines.asExecutor
@@ -53,11 +54,6 @@ interface ImsMmTelRepository {
@AccessNetworkConstants.TransportType transportType: Int, @AccessNetworkConstants.TransportType transportType: Int,
): Flow<Boolean> ): Flow<Boolean>
suspend fun isSupported(
@MmTelFeature.MmTelCapabilities.MmTelCapability capability: Int,
@AccessNetworkConstants.TransportType transportType: Int,
): Boolean
suspend fun setCrossSimCallingEnabled(enabled: Boolean) suspend fun setCrossSimCallingEnabled(enabled: Boolean)
} }
@@ -143,7 +139,8 @@ class ImsMmTelRepositoryImpl(
override fun isSupportedFlow(capability: Int, transportType: Int): Flow<Boolean> = override fun isSupportedFlow(capability: Int, transportType: Int): Flow<Boolean> =
imsReadyFlow().map { imsReady -> imsReady && isSupported(capability, transportType) } imsReadyFlow().map { imsReady -> imsReady && isSupported(capability, transportType) }
override suspend fun isSupported( @VisibleForTesting
suspend fun isSupported(
@MmTelFeature.MmTelCapabilities.MmTelCapability capability: Int, @MmTelFeature.MmTelCapabilities.MmTelCapability capability: Int,
@AccessNetworkConstants.TransportType transportType: Int, @AccessNetworkConstants.TransportType transportType: Int,
): Boolean = withContext(Dispatchers.Default) { ): Boolean = withContext(Dispatchers.Default) {

View File

@@ -21,6 +21,7 @@ import android.app.settings.SettingsEnums
import android.telephony.CarrierConfigManager import android.telephony.CarrierConfigManager
import android.telephony.SubscriptionManager import android.telephony.SubscriptionManager
import android.telephony.TelephonyManager import android.telephony.TelephonyManager
import android.util.Log
import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import com.android.settings.R import com.android.settings.R
@@ -34,6 +35,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.conflate
import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.flowOf
@@ -43,9 +45,8 @@ import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.plus import kotlinx.coroutines.plus
@OptIn(ExperimentalCoroutinesApi::class) @OptIn(ExperimentalCoroutinesApi::class)
class CrossSimCallingViewModel( class CrossSimCallingViewModel(private val application: Application) :
private val application: Application, AndroidViewModel(application) {
) : AndroidViewModel(application) {
private val subscriptionRepository = SubscriptionRepository(application) private val subscriptionRepository = SubscriptionRepository(application)
private val dataSubscriptionRepository = DataSubscriptionRepository(application) private val dataSubscriptionRepository = DataSubscriptionRepository(application)
@@ -61,38 +62,45 @@ class CrossSimCallingViewModel(
subscriptionRepository.activeSubscriptionIdListFlow(), subscriptionRepository.activeSubscriptionIdListFlow(),
dataSubscriptionRepository.defaultDataSubscriptionIdFlow(), dataSubscriptionRepository.defaultDataSubscriptionIdFlow(),
) { activeSubIds, defaultDataSubId -> ) { activeSubIds, defaultDataSubId ->
activeSubIds to crossSimCallNewEnabled(activeSubIds, defaultDataSubId) updatableSubIdsFlow(activeSubIds) to
crossSimCallNewEnabledFlow(activeSubIds, defaultDataSubId)
} }
.flatMapLatest { (activeSubIds, newEnabledFlow) -> .flatMapLatest { (updatableSubIdsFlow, crossSimCallNewEnabledFlow) ->
newEnabledFlow.map { newEnabled -> activeSubIds to newEnabled } combine(updatableSubIdsFlow, crossSimCallNewEnabledFlow) {
updatableSubIds,
newEnabled ->
updatableSubIds to newEnabled
}
} }
.distinctUntilChanged() .distinctUntilChanged()
.onEach { (activeSubIds, newEnabled) -> .conflate()
updateCrossSimCalling(activeSubIds, newEnabled) .onEach { (updatableSubIds, newEnabled) ->
Log.d(TAG, "updatableSubIds: $updatableSubIds newEnabled: $newEnabled")
updateCrossSimCalling(updatableSubIds, newEnabled)
} }
.launchIn(scope) .launchIn(scope)
} }
} }
private suspend fun updateCrossSimCalling(activeSubIds: List<Int>, newEnabled: Boolean) { private fun updatableSubIdsFlow(activeSubIds: List<Int>): Flow<List<Int>> {
metricsFeatureProvider.action( val updatableSubIdFlows =
application, activeSubIds.map { subId ->
SettingsEnums.ACTION_UPDATE_CROSS_SIM_CALLING_ON_AUTO_DATA_SWITCH_EVENT, WifiCallingRepository(application, subId).wifiCallingReadyFlow().map { isReady ->
newEnabled, subId.takeIf { isReady && isCrossSimImsAvailable(subId) }
) }
activeSubIds
.filter { subId -> crossSimAvailable(subId) }
.forEach { subId ->
ImsMmTelRepositoryImpl(application, subId).setCrossSimCallingEnabled(newEnabled)
} }
return combine(updatableSubIdFlows) { subIds -> subIds.filterNotNull() }
.distinctUntilChanged()
.conflate()
} }
private suspend fun crossSimAvailable(subId: Int): Boolean = private fun isCrossSimImsAvailable(subId: Int) =
WifiCallingRepository(application, subId).isWifiCallingSupported() && carrierConfigRepository.getBoolean(
carrierConfigRepository.getBoolean( subId,
subId, CarrierConfigManager.KEY_CARRIER_CROSS_SIM_IMS_AVAILABLE_BOOL) CarrierConfigManager.KEY_CARRIER_CROSS_SIM_IMS_AVAILABLE_BOOL,
)
private fun crossSimCallNewEnabled( private fun crossSimCallNewEnabledFlow(
activeSubscriptionIdList: List<Int>, activeSubscriptionIdList: List<Int>,
defaultDataSubId: Int, defaultDataSubId: Int,
): Flow<Boolean> { ): Flow<Boolean> {
@@ -102,8 +110,27 @@ class CrossSimCallingViewModel(
.filter { subId -> subId != defaultDataSubId } .filter { subId -> subId != defaultDataSubId }
.map { subId -> .map { subId ->
mobileDataRepository.isMobileDataPolicyEnabledFlow( mobileDataRepository.isMobileDataPolicyEnabledFlow(
subId, TelephonyManager.MOBILE_DATA_POLICY_AUTO_DATA_SWITCH) subId,
TelephonyManager.MOBILE_DATA_POLICY_AUTO_DATA_SWITCH,
)
} }
return combine(isMobileDataPolicyEnabledFlows) { true in it } return combine(isMobileDataPolicyEnabledFlows) { true in it }
.distinctUntilChanged()
.conflate()
}
private suspend fun updateCrossSimCalling(subIds: List<Int>, newEnabled: Boolean) {
metricsFeatureProvider.action(
application,
SettingsEnums.ACTION_UPDATE_CROSS_SIM_CALLING_ON_AUTO_DATA_SWITCH_EVENT,
newEnabled,
)
for (subId in subIds) {
ImsMmTelRepositoryImpl(application, subId).setCrossSimCallingEnabled(newEnabled)
}
}
companion object {
private const val TAG = "CrossSimCallingVM"
} }
} }

View File

@@ -29,9 +29,7 @@ import com.android.settings.network.telephony.ims.ImsMmTelRepository
import com.android.settings.network.telephony.ims.ImsMmTelRepositoryImpl import com.android.settings.network.telephony.ims.ImsMmTelRepositoryImpl
import com.android.settings.network.telephony.telephonyManager import com.android.settings.network.telephony.telephonyManager
import com.android.settingslib.spa.framework.util.collectLatestWithLifecycle import com.android.settingslib.spa.framework.util.collectLatestWithLifecycle
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.withContext
interface IWifiCallingRepository { interface IWifiCallingRepository {
/** TODO: Move this to UI layer, when UI layer migrated to Kotlin. */ /** TODO: Move this to UI layer, when UI layer migrated to Kotlin. */
@@ -75,11 +73,4 @@ constructor(
tech = ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN, tech = ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN,
transportType = AccessNetworkConstants.TRANSPORT_TYPE_WLAN, transportType = AccessNetworkConstants.TRANSPORT_TYPE_WLAN,
) )
suspend fun isWifiCallingSupported(): Boolean = withContext(Dispatchers.Default) {
imsMmTelRepository.isSupported(
capability = MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
transportType = AccessNetworkConstants.TRANSPORT_TYPE_WLAN,
)
}
} }

View File

@@ -44,8 +44,8 @@ class InterruptionFilterPreferenceController extends AbstractZenModePreferenceCo
@Override @Override
public void updateState(Preference preference, @NonNull ZenMode zenMode) { public void updateState(Preference preference, @NonNull ZenMode zenMode) {
preference.setEnabled(zenMode.isEnabled()); preference.setEnabled(zenMode.isEnabled() && zenMode.canEditPolicy());
boolean allowingAll = zenMode.getRule().getInterruptionFilter() == INTERRUPTION_FILTER_ALL; boolean allowingAll = zenMode.getInterruptionFilter() == INTERRUPTION_FILTER_ALL;
((TwoStatePreference) preference).setChecked(allowingAll); ((TwoStatePreference) preference).setChecked(allowingAll);
preference.setSummary(allowingAll preference.setSummary(allowingAll
@@ -57,7 +57,7 @@ class InterruptionFilterPreferenceController extends AbstractZenModePreferenceCo
public boolean onPreferenceChange(@NonNull Preference preference, Object newValue) { public boolean onPreferenceChange(@NonNull Preference preference, Object newValue) {
final boolean allowAll = ((Boolean) newValue); final boolean allowAll = ((Boolean) newValue);
return saveMode(zenMode -> { return saveMode(zenMode -> {
zenMode.getRule().setInterruptionFilter(allowAll zenMode.setInterruptionFilter(allowAll
? INTERRUPTION_FILTER_ALL ? INTERRUPTION_FILTER_ALL
: INTERRUPTION_FILTER_PRIORITY); : INTERRUPTION_FILTER_PRIORITY);
return zenMode; return zenMode;

View File

@@ -228,7 +228,7 @@ public class SetupInterstitialActivity extends FragmentActivity {
return false; return false;
} }
modeToUpdate.getRule().setEnabled(true); modeToUpdate.setEnabled(true);
mBackend.updateMode(modeToUpdate); mBackend.updateMode(modeToUpdate);
return true; return true;
} }

View File

@@ -92,7 +92,7 @@ class ZenModeAppsLinkPreferenceController extends AbstractZenModePreferenceContr
@Override @Override
public boolean isAvailable(ZenMode zenMode) { public boolean isAvailable(ZenMode zenMode) {
return zenMode.getRule().getInterruptionFilter() != INTERRUPTION_FILTER_ALL; return zenMode.getInterruptionFilter() != INTERRUPTION_FILTER_ALL;
} }
@Override @Override
@@ -102,7 +102,7 @@ class ZenModeAppsLinkPreferenceController extends AbstractZenModePreferenceContr
preference.setIntent( preference.setIntent(
ZenSubSettingLauncher.forModeFragment(mContext, ZenModeAppsFragment.class, ZenSubSettingLauncher.forModeFragment(mContext, ZenModeAppsFragment.class,
zenMode.getId(), SettingsEnums.ZEN_PRIORITY_MODE).toIntent()); zenMode.getId(), SettingsEnums.ZEN_PRIORITY_MODE).toIntent());
preference.setEnabled(zenMode.isEnabled()); preference.setEnabled(zenMode.isEnabled() && zenMode.canEditPolicy());
mZenMode = zenMode; mZenMode = zenMode;
mPreference = (CircularIconsPreference) preference; mPreference = (CircularIconsPreference) preference;

View File

@@ -74,7 +74,7 @@ class ZenModeDisplayEffectPreferenceController extends AbstractZenModePreference
updatedEffects.setShouldUseNightMode(allow); updatedEffects.setShouldUseNightMode(allow);
break; break;
} }
zenMode.getRule().setDeviceEffects(updatedEffects.build()); zenMode.setDeviceEffects(updatedEffects.build());
return zenMode; return zenMode;
}); });
} }

View File

@@ -45,7 +45,7 @@ class ZenModeDisplayLinkPreferenceController extends AbstractZenModePreferenceCo
preference.setIntent( preference.setIntent(
ZenSubSettingLauncher.forModeFragment(mContext, ZenModeDisplayFragment.class, ZenSubSettingLauncher.forModeFragment(mContext, ZenModeDisplayFragment.class,
zenMode.getId(), SettingsEnums.ZEN_PRIORITY_MODE).toIntent()); zenMode.getId(), SettingsEnums.ZEN_PRIORITY_MODE).toIntent());
preference.setEnabled(zenMode.isEnabled()); preference.setEnabled(zenMode.isEnabled() && zenMode.canEditPolicy());
} }
@Override @Override

View File

@@ -50,7 +50,8 @@ class ZenModeExitAtAlarmPreferenceController extends
if (mSchedule.exitAtAlarm != exitAtAlarm) { if (mSchedule.exitAtAlarm != exitAtAlarm) {
mSchedule.exitAtAlarm = exitAtAlarm; mSchedule.exitAtAlarm = exitAtAlarm;
return saveMode(mode -> { return saveMode(mode -> {
mode.getRule().setConditionId(ZenModeConfig.toScheduleConditionId(mSchedule)); mode.setCustomModeConditionId(mContext,
ZenModeConfig.toScheduleConditionId(mSchedule));
return mode; return mode;
}); });
} }

View File

@@ -171,7 +171,7 @@ public class ZenModeFragment extends ZenModeFragmentBase {
} else if (menuItem.getItemId() == DELETE_MODE) { } else if (menuItem.getItemId() == DELETE_MODE) {
new AlertDialog.Builder(mContext) new AlertDialog.Builder(mContext)
.setTitle(mContext.getString(R.string.zen_mode_delete_mode_confirmation, .setTitle(mContext.getString(R.string.zen_mode_delete_mode_confirmation,
mZenMode.getRule().getName())) mZenMode.getName()))
.setPositiveButton(R.string.zen_mode_schedule_delete, .setPositiveButton(R.string.zen_mode_schedule_delete,
(dialog, which) -> { (dialog, which) -> {
// start finishing before calling removeMode() so that we // start finishing before calling removeMode() so that we

View File

@@ -41,7 +41,7 @@ class ZenModeNotifVisLinkPreferenceController extends AbstractZenModePreferenceC
@Override @Override
public boolean isAvailable(ZenMode zenMode) { public boolean isAvailable(ZenMode zenMode) {
return zenMode.getRule().getInterruptionFilter() != INTERRUPTION_FILTER_ALL; return zenMode.getInterruptionFilter() != INTERRUPTION_FILTER_ALL;
} }
@Override @Override

View File

@@ -61,7 +61,7 @@ class ZenModeOtherLinkPreferenceController extends AbstractZenModePreferenceCont
@Override @Override
public boolean isAvailable(ZenMode zenMode) { public boolean isAvailable(ZenMode zenMode) {
return zenMode.getRule().getInterruptionFilter() != INTERRUPTION_FILTER_ALL; return zenMode.getInterruptionFilter() != INTERRUPTION_FILTER_ALL;
} }
@Override @Override
@@ -70,7 +70,7 @@ class ZenModeOtherLinkPreferenceController extends AbstractZenModePreferenceCont
ZenSubSettingLauncher.forModeFragment(mContext, ZenModeOtherFragment.class, ZenSubSettingLauncher.forModeFragment(mContext, ZenModeOtherFragment.class,
zenMode.getId(), SettingsEnums.ZEN_PRIORITY_MODE).toIntent()); zenMode.getId(), SettingsEnums.ZEN_PRIORITY_MODE).toIntent());
preference.setEnabled(zenMode.isEnabled()); preference.setEnabled(zenMode.isEnabled() && zenMode.canEditPolicy());
preference.setSummary(mSummaryHelper.getOtherSoundCategoriesSummary(zenMode)); preference.setSummary(mSummaryHelper.getOtherSoundCategoriesSummary(zenMode));
((CircularIconsPreference) preference).setIcons(getSoundIcons(zenMode.getPolicy())); ((CircularIconsPreference) preference).setIcons(getSoundIcons(zenMode.getPolicy()));
} }

View File

@@ -84,7 +84,7 @@ class ZenModePeopleLinkPreferenceController extends AbstractZenModePreferenceCon
@Override @Override
public boolean isAvailable(ZenMode zenMode) { public boolean isAvailable(ZenMode zenMode) {
return zenMode.getRule().getInterruptionFilter() != INTERRUPTION_FILTER_ALL; return zenMode.getInterruptionFilter() != INTERRUPTION_FILTER_ALL;
} }
@Override @Override
@@ -94,7 +94,7 @@ class ZenModePeopleLinkPreferenceController extends AbstractZenModePreferenceCon
ZenSubSettingLauncher.forModeFragment(mContext, ZenModePeopleFragment.class, ZenSubSettingLauncher.forModeFragment(mContext, ZenModePeopleFragment.class,
zenMode.getId(), SettingsEnums.ZEN_PRIORITY_MODE).toIntent()); zenMode.getId(), SettingsEnums.ZEN_PRIORITY_MODE).toIntent());
preference.setEnabled(zenMode.isEnabled()); preference.setEnabled(zenMode.isEnabled() && zenMode.canEditPolicy());
preference.setSummary(mSummaryHelper.getPeopleSummary(zenMode.getPolicy())); preference.setSummary(mSummaryHelper.getPeopleSummary(zenMode.getPolicy()));
((CircularIconsPreference) preference).setIcons(getPeopleIcons(zenMode.getPolicy()), ((CircularIconsPreference) preference).setIcons(getPeopleIcons(zenMode.getPolicy()),
PEOPLE_ITEM_EQUIVALENCE); PEOPLE_ITEM_EQUIVALENCE);

View File

@@ -209,48 +209,46 @@ class ZenModeSummaryHelper {
boolean isFirst = true; boolean isFirst = true;
List<String> enabledEffects = new ArrayList<>(); List<String> enabledEffects = new ArrayList<>();
if (!zenMode.getPolicy().shouldShowAllVisualEffects() if (!zenMode.getPolicy().shouldShowAllVisualEffects()
&& zenMode.getRule().getInterruptionFilter() != INTERRUPTION_FILTER_ALL) { && zenMode.getInterruptionFilter() != INTERRUPTION_FILTER_ALL) {
enabledEffects.add(getBlockedEffectsSummary(zenMode)); enabledEffects.add(getBlockedEffectsSummary(zenMode));
isFirst = false; isFirst = false;
} }
ZenDeviceEffects currEffects = zenMode.getRule().getDeviceEffects(); ZenDeviceEffects currEffects = zenMode.getDeviceEffects();
if (currEffects != null) { if (currEffects.shouldDisplayGrayscale()) {
if (currEffects.shouldDisplayGrayscale()) { if (isFirst) {
if (isFirst) { enabledEffects.add(mContext.getString(R.string.mode_grayscale_title));
enabledEffects.add(mContext.getString(R.string.mode_grayscale_title)); } else {
} else { enabledEffects.add(mContext.getString(
enabledEffects.add(mContext.getString( R.string.mode_grayscale_title_secondary_list));
R.string.mode_grayscale_title_secondary_list));
}
isFirst = false;
} }
if (currEffects.shouldSuppressAmbientDisplay()) { isFirst = false;
if (isFirst) { }
enabledEffects.add(mContext.getString(R.string.mode_aod_title)); if (currEffects.shouldSuppressAmbientDisplay()) {
} else { if (isFirst) {
enabledEffects.add(mContext.getString( enabledEffects.add(mContext.getString(R.string.mode_aod_title));
R.string.mode_aod_title_secondary_list)); } else {
} enabledEffects.add(mContext.getString(
isFirst = false; R.string.mode_aod_title_secondary_list));
} }
if (currEffects.shouldDimWallpaper()) { isFirst = false;
if (isFirst) { }
enabledEffects.add(mContext.getString(R.string.mode_wallpaper_title)); if (currEffects.shouldDimWallpaper()) {
} else { if (isFirst) {
enabledEffects.add(mContext.getString( enabledEffects.add(mContext.getString(R.string.mode_wallpaper_title));
R.string.mode_wallpaper_title_secondary_list)); } else {
} enabledEffects.add(mContext.getString(
isFirst = false; R.string.mode_wallpaper_title_secondary_list));
} }
if (currEffects.shouldUseNightMode()) { isFirst = false;
if (isFirst) { }
enabledEffects.add(mContext.getString(R.string.mode_dark_theme_title)); if (currEffects.shouldUseNightMode()) {
} else { if (isFirst) {
enabledEffects.add(mContext.getString( enabledEffects.add(mContext.getString(R.string.mode_dark_theme_title));
R.string.mode_dark_theme_title_secondary_list)); } else {
} enabledEffects.add(mContext.getString(
isFirst = false; R.string.mode_dark_theme_title_secondary_list));
} }
isFirst = false;
} }
int numCategories = enabledEffects.size(); int numCategories = enabledEffects.size();

View File

@@ -87,7 +87,7 @@ class ZenModeTriggerUpdatePreferenceController extends AbstractZenModePreference
mModeName = zenMode.getName(); mModeName = zenMode.getName();
PrimarySwitchPreference triggerPref = (PrimarySwitchPreference) preference; PrimarySwitchPreference triggerPref = (PrimarySwitchPreference) preference;
triggerPref.setChecked(zenMode.getRule().isEnabled()); triggerPref.setChecked(zenMode.isEnabled());
triggerPref.setOnPreferenceChangeListener(mSwitchChangeListener); triggerPref.setOnPreferenceChangeListener(mSwitchChangeListener);
if (zenMode.isSystemOwned()) { if (zenMode.isSystemOwned()) {
setUpForSystemOwnedTrigger(triggerPref, zenMode); setUpForSystemOwnedTrigger(triggerPref, zenMode);
@@ -213,7 +213,7 @@ class ZenModeTriggerUpdatePreferenceController extends AbstractZenModePreference
private void setModeEnabled(boolean enabled) { private void setModeEnabled(boolean enabled) {
saveMode((zenMode) -> { saveMode((zenMode) -> {
if (enabled != zenMode.getRule().isEnabled()) { if (enabled != zenMode.isEnabled()) {
zenMode.getRule().setEnabled(enabled); zenMode.getRule().setEnabled(enabled);
} }
return zenMode; return zenMode;

View File

@@ -118,7 +118,7 @@ class ZenModesListPreferenceController extends BasePreferenceController
for (ZenMode mode : mBackend.getModes()) { for (ZenMode mode : mBackend.getModes()) {
SearchIndexableRaw data = new SearchIndexableRaw(mContext); SearchIndexableRaw data = new SearchIndexableRaw(mContext);
data.key = mode.getId(); data.key = mode.getId();
data.title = mode.getRule().getName(); data.title = mode.getName();
data.screenTitle = res.getString(R.string.zen_modes_list_title); data.screenTitle = res.getString(R.string.zen_modes_list_title);
rawData.add(data); rawData.add(data);
} }

View File

@@ -31,6 +31,7 @@ import android.content.Context;
import android.platform.test.flag.junit.SetFlagsRule; import android.platform.test.flag.junit.SetFlagsRule;
import android.util.Pair; import android.util.Pair;
import android.view.View; import android.view.View;
import android.widget.Button;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
@@ -180,6 +181,7 @@ public class AudioSharingJoinDialogFragmentTest {
@Test @Test
public void onCreateDialog_flagOn_dialogShowTextForSingleDevice() { public void onCreateDialog_flagOn_dialogShowTextForSingleDevice() {
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING); mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
when(mBroadcast.isEnabled(null)).thenReturn(true);
AudioSharingJoinDialogFragment.show( AudioSharingJoinDialogFragment.show(
mParent, mParent,
new ArrayList<>(), new ArrayList<>(),
@@ -192,6 +194,10 @@ public class AudioSharingJoinDialogFragmentTest {
assertThat(dialog.isShowing()).isTrue(); assertThat(dialog.isShowing()).isTrue();
ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog); ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getMessage().toString()).isEqualTo(TEST_DEVICE_NAME2); assertThat(shadowDialog.getMessage().toString()).isEqualTo(TEST_DEVICE_NAME2);
Button btnView = dialog.findViewById(R.id.negative_btn);
assertThat(btnView).isNotNull();
assertThat(btnView.getText().toString())
.isEqualTo(mParent.getString(R.string.audio_sharing_no_thanks_button_label));
} }
@Test @Test
@@ -212,6 +218,13 @@ public class AudioSharingJoinDialogFragmentTest {
R.string.audio_sharing_share_dialog_subtitle, R.string.audio_sharing_share_dialog_subtitle,
TEST_DEVICE_NAME1, TEST_DEVICE_NAME1,
TEST_DEVICE_NAME2)); TEST_DEVICE_NAME2));
Button btnView = dialog.findViewById(R.id.negative_btn);
assertThat(btnView).isNotNull();
assertThat(btnView.getText().toString())
.isEqualTo(
mParent.getString(
R.string.audio_sharing_switch_active_button_label,
TEST_DEVICE_NAME2));
} }
@Test @Test

View File

@@ -17,6 +17,7 @@
package com.android.settings.notification.modes; package com.android.settings.notification.modes;
import static android.app.NotificationManager.INTERRUPTION_FILTER_ALL; import static android.app.NotificationManager.INTERRUPTION_FILTER_ALL;
import static android.app.NotificationManager.INTERRUPTION_FILTER_NONE;
import static android.app.NotificationManager.INTERRUPTION_FILTER_PRIORITY; import static android.app.NotificationManager.INTERRUPTION_FILTER_PRIORITY;
import static android.service.notification.ZenPolicy.STATE_DISALLOW; import static android.service.notification.ZenPolicy.STATE_DISALLOW;
@@ -67,6 +68,26 @@ public final class InterruptionFilterPreferenceControllerTest {
mController = new InterruptionFilterPreferenceController(mContext, "something", mBackend); mController = new InterruptionFilterPreferenceController(mContext, "something", mBackend);
} }
@Test
public void updateState_dnd_enabled() {
TwoStatePreference preference = mock(TwoStatePreference.class);
ZenMode dnd = TestModeBuilder.MANUAL_DND_ACTIVE;
mController.updateState(preference, dnd);
verify(preference).setEnabled(true);
}
@Test
public void updateState_specialDnd_disabled() {
TwoStatePreference preference = mock(TwoStatePreference.class);
ZenMode specialDnd = TestModeBuilder.manualDnd(INTERRUPTION_FILTER_NONE, true);
mController.updateState(preference, specialDnd);
verify(preference).setEnabled(false);
}
@Test @Test
public void testUpdateState_disabled() { public void testUpdateState_disabled() {
TwoStatePreference preference = mock(TwoStatePreference.class); TwoStatePreference preference = mock(TwoStatePreference.class);

View File

@@ -16,6 +16,7 @@
package com.android.settings.notification.modes; package com.android.settings.notification.modes;
import static android.app.NotificationManager.INTERRUPTION_FILTER_NONE;
import static android.app.NotificationManager.INTERRUPTION_FILTER_PRIORITY; import static android.app.NotificationManager.INTERRUPTION_FILTER_PRIORITY;
import static android.provider.Settings.EXTRA_AUTOMATIC_ZEN_RULE_ID; import static android.provider.Settings.EXTRA_AUTOMATIC_ZEN_RULE_ID;
@@ -149,6 +150,20 @@ public final class ZenModeAppsLinkPreferenceControllerTest {
assertThat(mController.isAvailable()).isTrue(); assertThat(mController.isAvailable()).isTrue();
} }
@Test
public void updateState_dnd_enabled() {
ZenMode dnd = TestModeBuilder.MANUAL_DND_ACTIVE;
mController.updateState(mPreference, dnd);
assertThat(mPreference.isEnabled()).isTrue();
}
@Test
public void updateState_specialDnd_disabled() {
ZenMode specialDnd = TestModeBuilder.manualDnd(INTERRUPTION_FILTER_NONE, true);
mController.updateState(mPreference, specialDnd);
assertThat(mPreference.isEnabled()).isFalse();
}
@Test @Test
public void testUpdateState_disabled() { public void testUpdateState_disabled() {
ZenMode zenMode = new TestModeBuilder() ZenMode zenMode = new TestModeBuilder()

View File

@@ -16,6 +16,8 @@
package com.android.settings.notification.modes; package com.android.settings.notification.modes;
import static android.app.NotificationManager.INTERRUPTION_FILTER_NONE;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
@@ -63,6 +65,26 @@ public final class ZenModeDisplayLinkPreferenceControllerTest {
mContext, "something", mBackend, mHelperBackend); mContext, "something", mBackend, mHelperBackend);
} }
@Test
public void updateState_dnd_enabled() {
Preference preference = mock(Preference.class);
ZenMode dnd = TestModeBuilder.MANUAL_DND_ACTIVE;
mController.updateState(preference, dnd);
verify(preference).setEnabled(true);
}
@Test
public void updateState_specialDnd_disabled() {
Preference preference = mock(Preference.class);
ZenMode specialDnd = TestModeBuilder.manualDnd(INTERRUPTION_FILTER_NONE, true);
mController.updateState(preference, specialDnd);
verify(preference).setEnabled(false);
}
@Test @Test
public void testUpdateState_disabled() { public void testUpdateState_disabled() {
Preference preference = mock(Preference.class); Preference preference = mock(Preference.class);

View File

@@ -16,6 +16,8 @@
package com.android.settings.notification.modes; package com.android.settings.notification.modes;
import static android.service.notification.SystemZenRules.PACKAGE_ANDROID;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
@@ -77,6 +79,7 @@ public class ZenModeExitAtAlarmPreferenceControllerTest {
scheduleInfo.exitAtAlarm = false; scheduleInfo.exitAtAlarm = false;
ZenMode mode = new TestModeBuilder() ZenMode mode = new TestModeBuilder()
.setPackage(PACKAGE_ANDROID)
.setConditionId(ZenModeConfig.toScheduleConditionId(scheduleInfo)) .setConditionId(ZenModeConfig.toScheduleConditionId(scheduleInfo))
.build(); .build();
@@ -105,6 +108,7 @@ public class ZenModeExitAtAlarmPreferenceControllerTest {
scheduleInfo.exitAtAlarm = true; scheduleInfo.exitAtAlarm = true;
ZenMode mode = new TestModeBuilder() ZenMode mode = new TestModeBuilder()
.setPackage(PACKAGE_ANDROID)
.setConditionId(ZenModeConfig.toScheduleConditionId(scheduleInfo)) .setConditionId(ZenModeConfig.toScheduleConditionId(scheduleInfo))
.build(); .build();
mPrefController.updateZenMode(preference, mode); mPrefController.updateZenMode(preference, mode);

View File

@@ -16,6 +16,8 @@
package com.android.settings.notification.modes; package com.android.settings.notification.modes;
import static android.app.NotificationManager.INTERRUPTION_FILTER_NONE;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
@@ -61,6 +63,26 @@ public final class ZenModeOtherLinkPreferenceControllerTest {
mContext, "something", mHelperBackend); mContext, "something", mHelperBackend);
} }
@Test
public void updateState_dnd_enabled() {
CircularIconsPreference preference = mock(CircularIconsPreference.class);
ZenMode dnd = TestModeBuilder.MANUAL_DND_ACTIVE;
mController.updateState(preference, dnd);
verify(preference).setEnabled(true);
}
@Test
public void updateState_specialDnd_disabled() {
CircularIconsPreference preference = mock(CircularIconsPreference.class);
ZenMode specialDnd = TestModeBuilder.manualDnd(INTERRUPTION_FILTER_NONE, true);
mController.updateState(preference, specialDnd);
verify(preference).setEnabled(false);
}
@Test @Test
public void updateState_disabled() { public void updateState_disabled() {
CircularIconsPreference pref = mock(CircularIconsPreference.class); CircularIconsPreference pref = mock(CircularIconsPreference.class);

View File

@@ -16,6 +16,7 @@
package com.android.settings.notification.modes; package com.android.settings.notification.modes;
import static android.app.NotificationManager.INTERRUPTION_FILTER_NONE;
import static android.service.notification.ZenPolicy.CONVERSATION_SENDERS_IMPORTANT; import static android.service.notification.ZenPolicy.CONVERSATION_SENDERS_IMPORTANT;
import static android.service.notification.ZenPolicy.PEOPLE_TYPE_ANYONE; import static android.service.notification.ZenPolicy.PEOPLE_TYPE_ANYONE;
import static android.service.notification.ZenPolicy.PEOPLE_TYPE_CONTACTS; import static android.service.notification.ZenPolicy.PEOPLE_TYPE_CONTACTS;
@@ -116,6 +117,20 @@ public final class ZenModePeopleLinkPreferenceControllerTest {
anyBoolean())).thenReturn(new ColorDrawable(Color.BLACK)); anyBoolean())).thenReturn(new ColorDrawable(Color.BLACK));
} }
@Test
public void updateState_dnd_enabled() {
ZenMode dnd = TestModeBuilder.MANUAL_DND_ACTIVE;
mController.updateState(mPreference, dnd);
assertThat(mPreference.isEnabled()).isTrue();
}
@Test
public void updateState_specialDnd_disabled() {
ZenMode specialDnd = TestModeBuilder.manualDnd(INTERRUPTION_FILTER_NONE, true);
mController.updateState(mPreference, specialDnd);
assertThat(mPreference.isEnabled()).isFalse();
}
@Test @Test
public void updateState_disabled() { public void updateState_disabled() {
ZenMode zenMode = new TestModeBuilder() ZenMode zenMode = new TestModeBuilder()

View File

@@ -102,22 +102,6 @@ class WifiCallingRepositoryTest {
assertThat(wiFiCallingMode).isEqualTo(ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED) assertThat(wiFiCallingMode).isEqualTo(ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED)
} }
@Test
fun isWifiCallingSupported() = runBlocking {
mockImsMmTelRepository.stub {
onBlocking {
isSupported(
capability = MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
transportType = AccessNetworkConstants.TRANSPORT_TYPE_WLAN,
)
} doReturn true
}
val isSupported = repository.isWifiCallingSupported()
assertThat(isSupported).isTrue()
}
private fun mockUseWfcHomeModeForRoaming(config: Boolean) { private fun mockUseWfcHomeModeForRoaming(config: Boolean) {
mockCarrierConfigManager.stub { mockCarrierConfigManager.stub {
on { on {