Snap for 10171451 from 4740720948 to udc-release

Change-Id: I293ca214fc3807529a5a626438147eb97d79604e
This commit is contained in:
Android Build Coastguard Worker
2023-05-20 01:32:32 +00:00
19 changed files with 160 additions and 83 deletions

View File

@@ -1444,6 +1444,9 @@
<!-- Title for the dialog to enter PIN. [CHAR LIMIT=40] -->
<string name="bluetooth_pairing_request">Pair with <xliff:g id="device_name">%1$s</xliff:g>?</string>
<!-- Message when a bluetooth device from a coordinated set is bonding late. [CHAR LIMIT=NONE] -->
<string name="bluetooth_pairing_group_late_bonding">Add new member to the existing coordinated set</string>
<!-- Message when bluetooth is informing the user of the pairing key. [CHAR LIMIT=NONE] -->
<string name="bluetooth_pairing_key_msg">Bluetooth pairing code</string>

View File

@@ -33,21 +33,6 @@
android:summary="@string/summary_placeholder"/>
</PreferenceCategory>
<PreferenceCategory
android:key="speech_category"
android:title="@string/speech_category_title">
<com.android.settings.widget.GearPreference
android:key="voice_input_settings"
android:title="@string/voice_input_settings_title"
android:fragment="com.android.settings.language.DefaultVoiceInputPicker" />
<Preference
android:key="tts_settings_summary"
android:title="@string/tts_settings_title"
android:fragment="com.android.settings.tts.TextToSpeechSettings"
settings:searchable="false"/>
</PreferenceCategory>
<PreferenceCategory
android:key="input_assistance_category"
android:title="@string/input_assistance">

View File

@@ -73,13 +73,6 @@
android:title="@string/voice_input_settings_title"
android:fragment="com.android.settings.language.DefaultVoiceInputPicker" />
<Preference
android:key="on_device_recognition_settings"
android:title="@string/on_device_recognition_settings_title"
android:summary="@string/on_device_recognition_settings_summary"
settings:controller=
"com.android.settings.language.OnDeviceRecognitionPreferenceController" />
<Preference
android:key="tts_settings_summary"
android:title="@string/tts_settings_title"

View File

@@ -46,4 +46,26 @@
settings:controller="com.android.settings.regionalpreferences.RegionalPreferencesController" />
</PreferenceCategory>
<PreferenceCategory
android:key="speech_category"
android:title="@string/speech_category_title">
<com.android.settings.widget.GearPreference
android:key="voice_input_settings"
android:title="@string/voice_input_settings_title"
android:fragment="com.android.settings.language.DefaultVoiceInputPicker" />
<Preference
android:key="on_device_recognition_settings"
android:title="@string/on_device_recognition_settings_title"
android:summary="@string/on_device_recognition_settings_summary"
settings:controller=
"com.android.settings.language.OnDeviceRecognitionPreferenceController" />
<Preference
android:key="tts_settings_summary"
android:title="@string/tts_settings_title"
android:fragment="com.android.settings.tts.TextToSpeechSettings"
settings:searchable="false"/>
</PreferenceCategory>
</PreferenceScreen>

View File

@@ -58,6 +58,11 @@ public class AppStateClonedAppsBridge extends AppStateBaseBridge{
mCloneProfileApps = mContext.getPackageManager()
.getInstalledPackagesAsUser(GET_ACTIVITIES,
mCloneUserId).stream().map(x -> x.packageName).toList();
} else if (!mCloneProfileApps.isEmpty()) {
// In case we remove clone profile (mCloneUserId becomes -1), the bridge state should
// reflect the same by setting cloneProfileApps as empty, without building the entire
// page.
mCloneProfileApps = new ArrayList<>();
}
final List<ApplicationsState.AppEntry> allApps = mAppSession.getAllApps();

View File

@@ -16,8 +16,6 @@
package com.android.settings.applications;
import static android.content.pm.PackageManager.GET_ACTIVITIES;
import static com.android.settings.Utils.PROPERTY_CLONED_APPS_ENABLED;
import android.content.Context;
@@ -87,8 +85,8 @@ public class ClonedAppsPreferenceController extends BasePreferenceController
mContext.getResources().getStringArray(
com.android.internal.R.array.cloneable_apps));
List<String> primaryUserApps = mContext.getPackageManager()
.getInstalledPackagesAsUser(GET_ACTIVITIES,
UserHandle.myUserId()).stream().map(x -> x.packageName).toList();
.getInstalledPackagesAsUser(/* flags*/ 0, UserHandle.myUserId()).stream()
.map(x -> x.packageName).toList();
// Count number of installed apps in system user.
int availableAppsCount = (int) cloneableApps.stream()
.filter(x -> primaryUserApps.contains(x)).count();
@@ -99,8 +97,8 @@ public class ClonedAppsPreferenceController extends BasePreferenceController
}
// Get all apps in clone profile if present.
List<String> cloneProfileApps = mContext.getPackageManager()
.getInstalledPackagesAsUser(GET_ACTIVITIES,
cloneUserId).stream().map(x -> x.packageName).toList();
.getInstalledPackagesAsUser(/* flags*/ 0, cloneUserId).stream()
.map(x -> x.packageName).toList();
// Count number of allowlisted app present in clone profile.
int clonedAppsCount = (int) cloneableApps.stream()
.filter(x -> cloneProfileApps.contains(x)).count();

View File

@@ -165,4 +165,13 @@ public class CloneBackend {
public int getCloneUserId() {
return mCloneUserId;
}
/**
* Resets {@link #mCloneUserId} to -1.
* Typically called after the cloneUser is removed, so that the obsolete clonedUserId present
* with the CloneBackend instance can be cleared.
*/
public void resetCloneUserId() {
mCloneUserId = -1;
}
}

View File

@@ -923,10 +923,15 @@ public class ManageApplications extends InstrumentedFragment
}
IUserManager um = IUserManager.Stub.asInterface(
ServiceManager.getService(Context.USER_SERVICE));
CloneBackend cloneBackend = CloneBackend.getInstance(getContext());
try {
// Warning: This removes all the data, media & images present in cloned user.
um.removeUser(clonedUserId);
mApplications.rebuild();
if (um.removeUser(clonedUserId)) {
cloneBackend.resetCloneUserId();
mApplications.rebuild();
} else if (ManageApplications.DEBUG) {
Log.e(TAG, "Failed to remove cloned user");
}
} catch (RemoteException e) {
Log.e(TAG, "Failed to remove cloned apps", e);
Toast.makeText(getContext(),

View File

@@ -16,10 +16,8 @@
package com.android.settings.applications.specialaccess.interactacrossprofiles;
import static android.app.admin.DevicePolicyResources.Strings.Settings.CONNECTED_WORK_AND_PERSONAL_APPS_TITLE;
import static android.content.pm.PackageManager.GET_ACTIVITIES;
import android.annotation.Nullable;
import android.app.admin.DevicePolicyManager;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.pm.ApplicationInfo;
@@ -157,9 +155,9 @@ public class InteractAcrossProfilesSettings extends EmptyTextSettings {
private static List<PackageInfo> getAllInstalledPackages(
PackageManager packageManager, UserHandle personalProfile, UserHandle workProfile) {
List<PackageInfo> personalPackages = packageManager.getInstalledPackagesAsUser(
GET_ACTIVITIES, personalProfile.getIdentifier());
/* flags= */ 0, personalProfile.getIdentifier());
List<PackageInfo> workPackages = packageManager.getInstalledPackagesAsUser(
GET_ACTIVITIES, workProfile.getIdentifier());
/* flags= */ 0, workProfile.getIdentifier());
List<PackageInfo> allPackages = new ArrayList<>(personalPackages);
for (PackageInfo workPackage : workPackages) {
if (allPackages.stream().noneMatch(

View File

@@ -319,7 +319,7 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
}
/**
* Disable the Le Audio profile, VCP, and CSIP for each of the Le Audio devices.
* Disable the Le Audio profile for each of the Le Audio devices.
*
* @param profile the LeAudio profile
*/
@@ -328,20 +328,12 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
Log.e(TAG, "There is no the LE profile or no device in mProfileDeviceMap. Do nothing.");
return;
}
LocalBluetoothProfile vcp = mProfileManager.getVolumeControlProfile();
LocalBluetoothProfile csip = mProfileManager.getCsipSetCoordinatorProfile();
for (CachedBluetoothDevice leAudioDevice : mProfileDeviceMap.get(profile.toString())) {
Log.d(TAG,
"device:" + leAudioDevice.getDevice().getAnonymizedAddress()
+ "disable LE profile");
profile.setEnabled(leAudioDevice.getDevice(), false);
if (vcp != null) {
vcp.setEnabled(leAudioDevice.getDevice(), false);
}
if (csip != null) {
csip.setEnabled(leAudioDevice.getDevice(), false);
}
}
if (!SystemProperties.getBoolean(ENABLE_DUAL_MODE_AUDIO, false)) {
@@ -352,7 +344,7 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
}
/**
* Enable the Le Audio profile, VCP, and CSIP for each of the Le Audio devices.
* Enable the Le Audio profile for each of the Le Audio devices.
*
* @param profile the LeAudio profile
*/
@@ -368,19 +360,11 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
disableProfileBeforeUserEnablesLeAudio(mProfileManager.getHeadsetProfile());
}
LocalBluetoothProfile vcp = mProfileManager.getVolumeControlProfile();
LocalBluetoothProfile csip = mProfileManager.getCsipSetCoordinatorProfile();
for (CachedBluetoothDevice leAudioDevice : mProfileDeviceMap.get(profile.toString())) {
Log.d(TAG,
"device:" + leAudioDevice.getDevice().getAnonymizedAddress()
+ "enable LE profile");
profile.setEnabled(leAudioDevice.getDevice(), true);
if (vcp != null) {
vcp.setEnabled(leAudioDevice.getDevice(), true);
}
if (csip != null) {
csip.setEnabled(leAudioDevice.getDevice(), true);
}
}
}

View File

@@ -72,6 +72,7 @@ public class BluetoothPairingController implements OnCheckedChangeListener,
private boolean mIsCoordinatedSetMember;
private boolean mIsLeAudio;
private boolean mIsLeContactSharingEnabled;
private boolean mIsLateBonding;
/**
* Creates an instance of a BluetoothPairingController.
@@ -98,6 +99,7 @@ public class BluetoothPairingController implements OnCheckedChangeListener,
mDeviceName = mBluetoothManager.getCachedDeviceManager().getName(mDevice);
mPbapClientProfile = mBluetoothManager.getProfileManager().getPbapClientProfile();
mPasskeyFormatted = formatKey(mPasskey);
mIsLateBonding = mBluetoothManager.getCachedDeviceManager().isLateBonding(mDevice);
final CachedBluetoothDevice cachedDevice =
mBluetoothManager.getCachedDeviceManager().findDevice(mDevice);
@@ -116,7 +118,10 @@ public class BluetoothPairingController implements OnCheckedChangeListener,
mIsLeContactSharingEnabled = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SETTINGS_UI,
SettingsUIDeviceConfig.BT_LE_AUDIO_CONTACT_SHARING_ENABLED, true);
Log.d(TAG, "BT_LE_AUDIO_CONTACT_SHARING_ENABLED is " + mIsLeContactSharingEnabled);
Log.d(TAG,
"BT_LE_AUDIO_CONTACT_SHARING_ENABLED is "
+ mIsLeContactSharingEnabled + " isCooridnatedSetMember "
+ mIsCoordinatedSetMember);
}
}
@@ -192,6 +197,15 @@ public class BluetoothPairingController implements OnCheckedChangeListener,
return mIsCoordinatedSetMember;
}
/**
* A method for querying if the bluetooth device from a coordinated set is bonding late.
*
* @return - A boolean indicating if the device is bonding late.
*/
public boolean isLateBonding() {
return mIsLateBonding;
}
/**
* A method for querying if the bluetooth device has a profile already set up on this device.
*

View File

@@ -357,8 +357,14 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i
pairingViewContent.setText(mPairingController.getPairingContent());
}
final TextView messagePairingSet = (TextView) view.findViewById(R.id.pairing_group_message);
messagePairingSet.setVisibility(mPairingController.isCoordinatedSetMemberDevice()
? View.VISIBLE : View.GONE);
if (mPairingController.isLateBonding()) {
messagePairingSet.setText(getString(R.string.bluetooth_pairing_group_late_bonding));
}
boolean setPairingMessage =
mPairingController.isCoordinatedSetMemberDevice() || mPairingController.isLateBonding();
messagePairingSet.setVisibility(setPairingMessage ? View.VISIBLE : View.GONE);
return view;
}
}

View File

@@ -26,6 +26,7 @@ import android.os.UserHandle;
import android.text.TextUtils;
import android.util.Log;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
/**
@@ -53,17 +54,28 @@ public final class BluetoothPairingRequest extends BroadcastReceiver {
boolean shouldShowDialog = LocalBluetoothPreferences.shouldShowDialogInForeground(
context, device);
// Skips consent pairing dialog if the device was recently associated with CDM
Log.d(TAG,
"Receive ACTION_PAIRING_REQUEST pairingVariant=" + pairingVariant
+ " canBondWithoutDialog=" + device.canBondWithoutDialog()
+ " isOngoingPairByCsip="
+ mBluetoothManager.getCachedDeviceManager().isOngoingPairByCsip(device)
+ " isLateBonding="
+ mBluetoothManager.getCachedDeviceManager().isLateBonding(device));
/* Skips consent pairing dialog if the device was recently associated with CDM
* or if the device is a member of the coordinated set and is not bonding late.
*/
if (pairingVariant == BluetoothDevice.PAIRING_VARIANT_CONSENT
&& (device.canBondWithoutDialog()
|| mBluetoothManager.getCachedDeviceManager().isOngoingPairByCsip(device))) {
&& (device.canBondWithoutDialog()
|| (mBluetoothManager.getCachedDeviceManager().isOngoingPairByCsip(device)
&& !mBluetoothManager.getCachedDeviceManager().isLateBonding(device)))) {
device.setPairingConfirmation(true);
} else if (powerManager.isInteractive() && shouldShowDialog) {
// Since the screen is on and the BT-related activity is in the foreground,
// just open the dialog
// convert broadcast intent into activity intent (same action string)
Intent pairingIntent = BluetoothPairingService.getPairingDialogIntent(context,
intent, BluetoothDevice.EXTRA_PAIRING_INITIATOR_FOREGROUND);
Intent pairingIntent = BluetoothPairingService.getPairingDialogIntent(
context, intent, BluetoothDevice.EXTRA_PAIRING_INITIATOR_FOREGROUND);
context.startActivityAsUser(pairingIntent, UserHandle.CURRENT);
} else {

View File

@@ -30,9 +30,7 @@ import androidx.annotation.Nullable;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.language.DefaultVoiceInputPreferenceController;
import com.android.settings.language.PointerSpeedController;
import com.android.settings.language.TtsPreferenceController;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.widget.PreferenceCategoryController;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -49,8 +47,6 @@ public class KeyboardSettings extends DashboardFragment {
private static final String TAG = "KeyboardSettings";
private static final String KEY_KEYBOARDS_CATEGORY = "keyboards_category";
private static final String KEY_SPEECH_CATEGORY = "speech_category";
private static final String KEY_TEXT_TO_SPEECH = "tts_settings_summary";
private static final String KEY_POINTER_CATEGORY = "pointer_category";
@Override
@@ -102,17 +98,6 @@ public class KeyboardSettings extends DashboardFragment {
Arrays.asList(virtualKeyboardPreferenceController,
physicalKeyboardPreferenceController)));
// Speech
final DefaultVoiceInputPreferenceController defaultVoiceInputPreferenceController =
new DefaultVoiceInputPreferenceController(context, lifecycle);
final TtsPreferenceController ttsPreferenceController =
new TtsPreferenceController(context, KEY_TEXT_TO_SPEECH);
controllers.add(defaultVoiceInputPreferenceController);
controllers.add(ttsPreferenceController);
controllers.add(new PreferenceCategoryController(context,
KEY_SPEECH_CATEGORY).setChildren(
Arrays.asList(defaultVoiceInputPreferenceController, ttsPreferenceController)));
// Pointer
final PointerSpeedController pointerController = new PointerSpeedController(context);
controllers.add(pointerController);

View File

@@ -21,14 +21,25 @@ import android.app.settings.SettingsEnums;
import android.content.Context;
import android.util.FeatureFlagUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.widget.PreferenceCategoryController;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.search.SearchIndexable;
import java.util.ArrayList;
import java.util.List;
@SearchIndexable
public class LanguageSettings extends DashboardFragment {
private static final String KEY_SPEECH_CATEGORY = "speech_category";
private static final String TAG = "LanguageSettings";
@Override
@@ -59,8 +70,43 @@ public class LanguageSettings extends DashboardFragment {
return R.xml.language_settings;
}
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
return buildPreferenceControllers(context, getSettingsLifecycle());
}
private static List<AbstractPreferenceController> buildPreferenceControllers(
@NonNull Context context, @Nullable Lifecycle lifecycle) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
final DefaultVoiceInputPreferenceController defaultVoiceInputPreferenceController =
new DefaultVoiceInputPreferenceController(context, lifecycle);
final TtsPreferenceController ttsPreferenceController =
new TtsPreferenceController(context);
final OnDeviceRecognitionPreferenceController onDeviceRecognitionPreferenceController =
new OnDeviceRecognitionPreferenceController(context);
controllers.add(defaultVoiceInputPreferenceController);
controllers.add(ttsPreferenceController);
List<AbstractPreferenceController> speechCategoryChildren = new ArrayList<>(
List.of(defaultVoiceInputPreferenceController, ttsPreferenceController));
if (onDeviceRecognitionPreferenceController.isAvailable()) {
controllers.add(onDeviceRecognitionPreferenceController);
speechCategoryChildren.add(onDeviceRecognitionPreferenceController);
}
controllers.add(new PreferenceCategoryController(context, KEY_SPEECH_CATEGORY)
.setChildren(speechCategoryChildren));
return controllers;
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.language_settings) {
public List<AbstractPreferenceController> createPreferenceControllers(
Context context) {
return buildPreferenceControllers(context, null);
}
@Override
protected boolean isPageSearchEnabled(Context context) {
return FeatureFlagUtils

View File

@@ -33,10 +33,16 @@ import java.util.Optional;
/** Controller of the On-device recognition preference. */
public class OnDeviceRecognitionPreferenceController extends BasePreferenceController {
private static final String KEY_ON_DEVICE_RECOGNITION = "on_device_recognition_settings";
private static final String TAG = "OnDeviceRecognitionPreferenceController";
private Optional<Intent> mIntent;
public OnDeviceRecognitionPreferenceController(Context context) {
this(context, KEY_ON_DEVICE_RECOGNITION);
}
public OnDeviceRecognitionPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
}
@@ -51,6 +57,10 @@ public class OnDeviceRecognitionPreferenceController extends BasePreferenceContr
: CONDITIONALLY_UNAVAILABLE;
}
public String getPreferenceKey() {
return KEY_ON_DEVICE_RECOGNITION;
}
@Override
public void updateState(Preference preference) {
super.updateState(preference);

View File

@@ -26,9 +26,15 @@ import com.android.settings.core.BasePreferenceController;
public class TtsPreferenceController extends BasePreferenceController {
private static final String KEY_TEXT_TO_SPEECH = "tts_settings_summary";
@VisibleForTesting
TtsEngines mTtsEngines;
public TtsPreferenceController(Context context) {
this(context, KEY_TEXT_TO_SPEECH);
}
public TtsPreferenceController(Context context, String key) {
super(context, key);
mTtsEngines = new TtsEngines(context);
@@ -40,4 +46,8 @@ public class TtsPreferenceController extends BasePreferenceController {
mContext.getResources().getBoolean(R.bool.config_show_tts_settings_summary)
? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
public String getPreferenceKey() {
return KEY_TEXT_TO_SPEECH;
}
}

View File

@@ -102,7 +102,6 @@ public class WifiHotspotRepository {
protected Boolean mIs6gBandSupported;
protected Boolean mIs6gAvailable;
protected MutableLiveData<Boolean> m6gAvailable;
protected String mCurrentCountryCode;
protected ActiveCountryCodeChangedCallback mActiveCountryCodeChangedCallback;
@VisibleForTesting
@@ -568,17 +567,12 @@ public class WifiHotspotRepository {
@Override
public void onActiveCountryCodeChanged(String country) {
log("onActiveCountryCodeChanged(), country:" + country);
mCurrentCountryCode = country;
purgeRefreshData();
refresh();
}
@Override
public void onCountryCodeInactive() {
log("onCountryCodeInactive()");
mCurrentCountryCode = null;
purgeRefreshData();
refresh();
}
}

View File

@@ -78,7 +78,6 @@ import java.util.List;
public class WifiHotspotRepositoryTest {
static final String WIFI_SSID = "wifi_ssid";
static final String WIFI_PASSWORD = "wifi_password";
static final String WIFI_CURRENT_COUNTRY_CODE = "US";
static final int WIFI_5GHZ_BAND_PREFERRED = BAND_2GHZ_5GHZ;
static final int WIFI_6GHZ_BAND_PREFERRED = BAND_2GHZ_5GHZ_6GHZ;
@@ -112,7 +111,6 @@ public class WifiHotspotRepositoryTest {
mRepository = new WifiHotspotRepository(mContext, mWifiManager, mTetheringManager);
mRepository.mSecurityType = mSecurityType;
mRepository.mSpeedType = mSpeedType;
mRepository.mCurrentCountryCode = WIFI_CURRENT_COUNTRY_CODE;
mRepository.mIsDualBand = true;
mRepository.mIs5gAvailable = true;
mRepository.mIs6gAvailable = true;