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="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>
<!-- 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] -->
<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="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>

View File

@@ -13749,6 +13749,8 @@
<string name="audio_sharing_confirm_dialog_title">Connect a compatible device</string>
<!-- 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>
<!-- 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]-->
<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>
<!-- Text for audio sharing qrcode scanner [CHAR LIMIT=none]-->
<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 -->

View File

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

View File

@@ -27,6 +27,7 @@ import android.content.Context;
import android.database.ContentObserver;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.os.VibrationAttributes;
import android.os.Vibrator;
import android.provider.Settings;
@@ -69,7 +70,8 @@ public class KeyboardVibrationTogglePreferenceController extends TogglePreferenc
public KeyboardVibrationTogglePreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
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
public void onChange(boolean selfChange, Uri uri) {
if (uri.equals(MAIN_VIBRATION_SWITCH_URI)) {

View File

@@ -23,6 +23,7 @@ import android.content.Context;
import android.database.ContentObserver;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.os.VibrationAttributes;
import android.os.Vibrator;
import android.provider.Settings;
@@ -49,7 +50,8 @@ public class VibrationMainSwitchPreferenceController extends SettingsMainSwitchP
public VibrationMainSwitchPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
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
public void onChange(boolean selfChange, Uri uri) {
updateState(mSwitchPreference);

View File

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

View File

@@ -21,6 +21,7 @@ import android.database.ContentObserver;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.os.Vibrator;
import android.provider.DeviceConfig;
import android.provider.Settings;
@@ -74,7 +75,8 @@ public class VibrationRampingRingerTogglePreferenceController
mRingVibrationPreferenceConfig = new RingVibrationPreferenceConfig(context);
mRingSettingObserver = new VibrationPreferenceConfig.SettingObserver(
mRingVibrationPreferenceConfig);
mSettingObserver = new ContentObserver(new Handler(/* async= */ true)) {
Handler handler = Looper.myLooper() != null ? new Handler(/* async= */ true) : null;
mSettingObserver = new ContentObserver(handler) {
@Override
public void onChange(boolean selfChange, Uri uri) {
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.SubSettingLauncher;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.overlay.FeatureFactory;
/** Preference controller for all bluetooth device preference. */
public class ViewAllBluetoothDevicesPreferenceController extends BasePreferenceController {
@@ -52,6 +53,8 @@ public class ViewAllBluetoothDevicesPreferenceController extends BasePreferenceC
@Override
public boolean handlePreferenceTreeClick(Preference preference) {
if (TextUtils.equals(preference.getKey(), getPreferenceKey())) {
FeatureFactory.getFeatureFactory().getMetricsFeatureProvider().clicked(
getMetricsCategory(), getPreferenceKey());
launchConnectedDevicePage();
return true;
}

View File

@@ -38,6 +38,7 @@ import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.HapClientProfile;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
@@ -111,6 +112,7 @@ public class BluetoothDetailsHearingAidsPresetsController extends
final int index = listPreference.findIndexOfValue(value);
final String presetName = listPreference.getEntries()[index].toString();
final int presetIndex = Integer.parseInt(value);
logPresetChangedIfNeeded();
listPreference.setSummary(presetName);
if (DEBUG) {
Log.d(TAG, "onPreferenceChange"
@@ -373,4 +375,15 @@ public class BluetoothDetailsHearingAidsPresetsController extends
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();
})
.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 -> {
if (sListener != null) {
sListener.onCancelClick();

View File

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

View File

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

View File

@@ -21,6 +21,7 @@ import android.app.settings.SettingsEnums
import android.telephony.CarrierConfigManager
import android.telephony.SubscriptionManager
import android.telephony.TelephonyManager
import android.util.Log
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.viewModelScope
import com.android.settings.R
@@ -34,6 +35,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.conflate
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf
@@ -43,9 +45,8 @@ import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.plus
@OptIn(ExperimentalCoroutinesApi::class)
class CrossSimCallingViewModel(
private val application: Application,
) : AndroidViewModel(application) {
class CrossSimCallingViewModel(private val application: Application) :
AndroidViewModel(application) {
private val subscriptionRepository = SubscriptionRepository(application)
private val dataSubscriptionRepository = DataSubscriptionRepository(application)
@@ -61,38 +62,45 @@ class CrossSimCallingViewModel(
subscriptionRepository.activeSubscriptionIdListFlow(),
dataSubscriptionRepository.defaultDataSubscriptionIdFlow(),
) { activeSubIds, defaultDataSubId ->
activeSubIds to crossSimCallNewEnabled(activeSubIds, defaultDataSubId)
updatableSubIdsFlow(activeSubIds) to
crossSimCallNewEnabledFlow(activeSubIds, defaultDataSubId)
}
.flatMapLatest { (updatableSubIdsFlow, crossSimCallNewEnabledFlow) ->
combine(updatableSubIdsFlow, crossSimCallNewEnabledFlow) {
updatableSubIds,
newEnabled ->
updatableSubIds to newEnabled
}
.flatMapLatest { (activeSubIds, newEnabledFlow) ->
newEnabledFlow.map { newEnabled -> activeSubIds to newEnabled }
}
.distinctUntilChanged()
.onEach { (activeSubIds, newEnabled) ->
updateCrossSimCalling(activeSubIds, newEnabled)
.conflate()
.onEach { (updatableSubIds, newEnabled) ->
Log.d(TAG, "updatableSubIds: $updatableSubIds newEnabled: $newEnabled")
updateCrossSimCalling(updatableSubIds, newEnabled)
}
.launchIn(scope)
}
}
private suspend fun updateCrossSimCalling(activeSubIds: List<Int>, newEnabled: Boolean) {
metricsFeatureProvider.action(
application,
SettingsEnums.ACTION_UPDATE_CROSS_SIM_CALLING_ON_AUTO_DATA_SWITCH_EVENT,
newEnabled,
)
activeSubIds
.filter { subId -> crossSimAvailable(subId) }
.forEach { subId ->
ImsMmTelRepositoryImpl(application, subId).setCrossSimCallingEnabled(newEnabled)
private fun updatableSubIdsFlow(activeSubIds: List<Int>): Flow<List<Int>> {
val updatableSubIdFlows =
activeSubIds.map { subId ->
WifiCallingRepository(application, subId).wifiCallingReadyFlow().map { isReady ->
subId.takeIf { isReady && isCrossSimImsAvailable(subId) }
}
}
return combine(updatableSubIdFlows) { subIds -> subIds.filterNotNull() }
.distinctUntilChanged()
.conflate()
}
private suspend fun crossSimAvailable(subId: Int): Boolean =
WifiCallingRepository(application, subId).isWifiCallingSupported() &&
private fun isCrossSimImsAvailable(subId: Int) =
carrierConfigRepository.getBoolean(
subId, CarrierConfigManager.KEY_CARRIER_CROSS_SIM_IMS_AVAILABLE_BOOL)
subId,
CarrierConfigManager.KEY_CARRIER_CROSS_SIM_IMS_AVAILABLE_BOOL,
)
private fun crossSimCallNewEnabled(
private fun crossSimCallNewEnabledFlow(
activeSubscriptionIdList: List<Int>,
defaultDataSubId: Int,
): Flow<Boolean> {
@@ -102,8 +110,27 @@ class CrossSimCallingViewModel(
.filter { subId -> subId != defaultDataSubId }
.map { subId ->
mobileDataRepository.isMobileDataPolicyEnabledFlow(
subId, TelephonyManager.MOBILE_DATA_POLICY_AUTO_DATA_SWITCH)
subId,
TelephonyManager.MOBILE_DATA_POLICY_AUTO_DATA_SWITCH,
)
}
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.telephonyManager
import com.android.settingslib.spa.framework.util.collectLatestWithLifecycle
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.withContext
interface IWifiCallingRepository {
/** TODO: Move this to UI layer, when UI layer migrated to Kotlin. */
@@ -75,11 +73,4 @@ constructor(
tech = ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN,
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
public void updateState(Preference preference, @NonNull ZenMode zenMode) {
preference.setEnabled(zenMode.isEnabled());
boolean allowingAll = zenMode.getRule().getInterruptionFilter() == INTERRUPTION_FILTER_ALL;
preference.setEnabled(zenMode.isEnabled() && zenMode.canEditPolicy());
boolean allowingAll = zenMode.getInterruptionFilter() == INTERRUPTION_FILTER_ALL;
((TwoStatePreference) preference).setChecked(allowingAll);
preference.setSummary(allowingAll
@@ -57,7 +57,7 @@ class InterruptionFilterPreferenceController extends AbstractZenModePreferenceCo
public boolean onPreferenceChange(@NonNull Preference preference, Object newValue) {
final boolean allowAll = ((Boolean) newValue);
return saveMode(zenMode -> {
zenMode.getRule().setInterruptionFilter(allowAll
zenMode.setInterruptionFilter(allowAll
? INTERRUPTION_FILTER_ALL
: INTERRUPTION_FILTER_PRIORITY);
return zenMode;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -209,12 +209,11 @@ class ZenModeSummaryHelper {
boolean isFirst = true;
List<String> enabledEffects = new ArrayList<>();
if (!zenMode.getPolicy().shouldShowAllVisualEffects()
&& zenMode.getRule().getInterruptionFilter() != INTERRUPTION_FILTER_ALL) {
&& zenMode.getInterruptionFilter() != INTERRUPTION_FILTER_ALL) {
enabledEffects.add(getBlockedEffectsSummary(zenMode));
isFirst = false;
}
ZenDeviceEffects currEffects = zenMode.getRule().getDeviceEffects();
if (currEffects != null) {
ZenDeviceEffects currEffects = zenMode.getDeviceEffects();
if (currEffects.shouldDisplayGrayscale()) {
if (isFirst) {
enabledEffects.add(mContext.getString(R.string.mode_grayscale_title));
@@ -251,7 +250,6 @@ class ZenModeSummaryHelper {
}
isFirst = false;
}
}
int numCategories = enabledEffects.size();
MessageFormat msgFormat = new MessageFormat(

View File

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

View File

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

View File

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

View File

@@ -17,6 +17,7 @@
package com.android.settings.notification.modes;
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.service.notification.ZenPolicy.STATE_DISALLOW;
@@ -67,6 +68,26 @@ public final class InterruptionFilterPreferenceControllerTest {
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
public void testUpdateState_disabled() {
TwoStatePreference preference = mock(TwoStatePreference.class);

View File

@@ -16,6 +16,7 @@
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.provider.Settings.EXTRA_AUTOMATIC_ZEN_RULE_ID;
@@ -149,6 +150,20 @@ public final class ZenModeAppsLinkPreferenceControllerTest {
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
public void testUpdateState_disabled() {
ZenMode zenMode = new TestModeBuilder()

View File

@@ -16,6 +16,8 @@
package com.android.settings.notification.modes;
import static android.app.NotificationManager.INTERRUPTION_FILTER_NONE;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -63,6 +65,26 @@ public final class ZenModeDisplayLinkPreferenceControllerTest {
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
public void testUpdateState_disabled() {
Preference preference = mock(Preference.class);

View File

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

View File

@@ -16,6 +16,8 @@
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.argThat;
import static org.mockito.Mockito.mock;
@@ -61,6 +63,26 @@ public final class ZenModeOtherLinkPreferenceControllerTest {
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
public void updateState_disabled() {
CircularIconsPreference pref = mock(CircularIconsPreference.class);

View File

@@ -16,6 +16,7 @@
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.PEOPLE_TYPE_ANYONE;
import static android.service.notification.ZenPolicy.PEOPLE_TYPE_CONTACTS;
@@ -116,6 +117,20 @@ public final class ZenModePeopleLinkPreferenceControllerTest {
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
public void updateState_disabled() {
ZenMode zenMode = new TestModeBuilder()

View File

@@ -102,22 +102,6 @@ class WifiCallingRepositoryTest {
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) {
mockCarrierConfigManager.stub {
on {