Merge "Update the setOverrideDeadline in the legacy AnomalyDetectionJobService" into main
diff --git a/res/drawable/ic_audio_play_sample.xml b/res/drawable/ic_audio_play_sample.xml
new file mode 100644
index 0000000..3666c22
--- /dev/null
+++ b/res/drawable/ic_audio_play_sample.xml
@@ -0,0 +1,32 @@
+<!--
+ ~ Copyright (C) 2023 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:pathData="M14,8C9.6,8 6,11.6 6,16H8C8,12.7 10.7,10 14,10V8Z"
+ android:fillColor="#4E4639"/>
+ <path
+ android:pathData="M14,6V4C7.4,4 2,9.4 2,16H4C4,10.5 8.5,6 14,6Z"
+ android:fillColor="#4E4639"/>
+ <path
+ android:pathData="M16,4V12.6C15.4,12.3 14.7,12 14,12C11.8,12 10,13.8 10,16C10,18.2 11.8,20 14,20C16.2,20 18,18.2 18,16V7H22V4H16ZM14,18C12.9,18 12,17.1 12,16C12,14.9 12.9,14 14,14C15.1,14 16,14.9 16,16C16,17.1 15.1,18 14,18Z"
+ android:fillColor="#4E4639"/>
+</vector>
diff --git a/res/xml/bluetooth_audio_sharing.xml b/res/xml/bluetooth_audio_sharing.xml
index d5e08bb..9ffa2b2 100644
--- a/res/xml/bluetooth_audio_sharing.xml
+++ b/res/xml/bluetooth_audio_sharing.xml
@@ -31,6 +31,13 @@
android:title="@string/calls_and_alarms_device_title"
settings:controller="com.android.settings.connecteddevice.audiosharing.CallsAndAlarmsPreferenceController" />
+ <Preference
+ android:icon="@drawable/ic_audio_play_sample"
+ android:key="audio_sharing_play_sound"
+ android:summary="Everyone listening should hear it"
+ android:title="Play a test sound"
+ settings:controller="com.android.settings.connecteddevice.audiosharing.AudioSharingPlaySoundPreferenceController" />
+
<com.android.settings.connecteddevice.audiosharing.AudioSharingNamePreference
android:key="audio_sharing_stream_name"
android:summary="********"
diff --git a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDashboardFragment.java b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDashboardFragment.java
index 52a8f18..9105297 100644
--- a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDashboardFragment.java
+++ b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDashboardFragment.java
@@ -34,6 +34,7 @@
private AudioSharingSwitchBarController mSwitchBarController;
private AudioSharingDeviceVolumeGroupController mAudioSharingDeviceVolumeGroupController;
private CallsAndAlarmsPreferenceController mCallsAndAlarmsPreferenceController;
+ private AudioSharingPlaySoundPreferenceController mAudioSharingPlaySoundPreferenceController;
private AudioSharingNamePreferenceController mAudioSharingNamePreferenceController;
private AudioStreamsCategoryController mAudioStreamsCategoryController;
@@ -74,6 +75,8 @@
mAudioSharingDeviceVolumeGroupController.init(this);
mCallsAndAlarmsPreferenceController = use(CallsAndAlarmsPreferenceController.class);
mCallsAndAlarmsPreferenceController.init(this);
+ mAudioSharingPlaySoundPreferenceController =
+ use(AudioSharingPlaySoundPreferenceController.class);
mAudioSharingNamePreferenceController = use(AudioSharingNamePreferenceController.class);
mAudioStreamsCategoryController = use(AudioStreamsCategoryController.class);
}
@@ -100,6 +103,7 @@
private void updateVisibilityForAttachedPreferences() {
mAudioSharingDeviceVolumeGroupController.updateVisibility();
mCallsAndAlarmsPreferenceController.updateVisibility();
+ mAudioSharingPlaySoundPreferenceController.updateVisibility();
mAudioSharingNamePreferenceController.updateVisibility();
mAudioStreamsCategoryController.updateVisibility();
}
diff --git a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingPlaySoundPreferenceController.java b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingPlaySoundPreferenceController.java
new file mode 100644
index 0000000..6722219
--- /dev/null
+++ b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingPlaySoundPreferenceController.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.connecteddevice.audiosharing;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.media.AudioAttributes;
+import android.media.AudioManager;
+import android.media.Ringtone;
+import android.media.RingtoneManager;
+import android.net.Uri;
+import android.util.Log;
+
+import androidx.annotation.NonNull;
+import androidx.lifecycle.LifecycleOwner;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+
+public class AudioSharingPlaySoundPreferenceController
+ extends AudioSharingBasePreferenceController {
+
+ private static final String TAG = "AudioSharingPlaySoundPreferenceController";
+
+ private static final String PREF_KEY = "audio_sharing_play_sound";
+
+ private final Ringtone mRingtone;
+
+ public AudioSharingPlaySoundPreferenceController(Context context) {
+ super(context, PREF_KEY);
+ mRingtone = RingtoneManager.getRingtone(context, getMediaVolumeUri());
+ if (mRingtone != null) {
+ mRingtone.setStreamType(AudioManager.STREAM_MUSIC);
+ }
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreference.setVisible(mRingtone != null);
+ mPreference.setOnPreferenceClickListener(
+ (v) -> {
+ if (mRingtone == null) {
+ Log.d(TAG, "Skip onClick due to ringtone is null");
+ return true;
+ }
+ try {
+ mRingtone.setAudioAttributes(
+ new AudioAttributes.Builder(mRingtone.getAudioAttributes())
+ .setFlags(AudioAttributes.FLAG_BYPASS_MUTE)
+ .addTag("VX_AOSP_SAMPLESOUND")
+ .build());
+ if (!mRingtone.isPlaying()) {
+ mRingtone.play();
+ }
+ } catch (Throwable e) {
+ Log.w(TAG, "Fail to play sample, error = " + e);
+ }
+ return true;
+ });
+ }
+
+ @Override
+ public void onStop(@NonNull LifecycleOwner owner) {
+ super.onStop(owner);
+ if (mRingtone != null && mRingtone.isPlaying()) {
+ mRingtone.stop();
+ }
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return PREF_KEY;
+ }
+
+ private Uri getMediaVolumeUri() {
+ return Uri.parse(
+ ContentResolver.SCHEME_ANDROID_RESOURCE
+ + "://"
+ + mContext.getPackageName()
+ + "/"
+ + R.raw.media_volume);
+ }
+}
diff --git a/src/com/android/settings/network/apn/ApnEditPageProvider.kt b/src/com/android/settings/network/apn/ApnEditPageProvider.kt
index 52066a1..2600618 100644
--- a/src/com/android/settings/network/apn/ApnEditPageProvider.kt
+++ b/src/com/android/settings/network/apn/ApnEditPageProvider.kt
@@ -101,17 +101,19 @@
RegularScaffold(
title = if (apnDataInit.newApn) stringResource(id = R.string.apn_add) else stringResource(id = R.string.apn_edit),
actions = {
- IconButton(onClick = {
- if (!apnData.validEnabled) apnData = apnData.copy(validEnabled = true)
- val valid = validateAndSaveApnData(
- apnDataInit,
- apnData,
- context,
- uriInit,
- networkTypeSelectedOptionsState
- )
- if (valid) navController.navigateBack()
- }) { Icon(imageVector = Icons.Outlined.Done, contentDescription = null) }
+ if (!apnData.customizedConfig.readOnlyApn) {
+ IconButton(onClick = {
+ if (!apnData.validEnabled) apnData = apnData.copy(validEnabled = true)
+ val valid = validateAndSaveApnData(
+ apnDataInit,
+ apnData,
+ context,
+ uriInit,
+ networkTypeSelectedOptionsState
+ )
+ if (valid) navController.navigateBack()
+ }) { Icon(imageVector = Icons.Outlined.Done, contentDescription = null) }
+ }
},
) {
Column {
@@ -212,7 +214,9 @@
emptyVal = stringResource(R.string.network_type_unspecified),
enabled = apnData.networkTypeEnabled
) {}
- if (!apnData.newApn) {
+ if (!apnData.newApn && !apnData.customizedConfig.readOnlyApn
+ && apnData.customizedConfig.isAddApnAllowed
+ ) {
Preference(
object : PreferenceModel {
override val title = stringResource(R.string.menu_delete)