Snap for 7953399 from cd429e74db to tm-release

Change-Id: I3889667c798adb3ac597b19a1879be8e1eb9815d
This commit is contained in:
Android Build Coastguard Worker
2021-11-30 02:09:35 +00:00
14 changed files with 86 additions and 70 deletions

View File

@@ -1900,6 +1900,7 @@
<activity
android:name=".accessibility.AccessibilityScreenSizeForSetupWizardActivity"
android:theme="@android:style/Theme.DeviceDefault.Settings"
android:exported="false"/>
<activity

View File

@@ -77,8 +77,8 @@ public class ActivityEmbeddingRulesController {
ComponentName primaryComponent,
ComponentName secondaryComponent,
String secondaryIntentAction,
boolean finishPrimaryWithSecondary,
boolean finishSecondaryWithPrimary,
int finishPrimaryWithSecondary,
int finishSecondaryWithPrimary,
boolean clearTop) {
if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(context)) {
return;
@@ -88,8 +88,8 @@ public class ActivityEmbeddingRulesController {
secondaryIntentAction));
SplitController.getInstance().registerRule(new SplitPairRule(filters,
finishPrimaryWithSecondary ? SplitRule.FINISH_ADJACENT : SplitRule.FINISH_NEVER,
finishSecondaryWithPrimary ? SplitRule.FINISH_ADJACENT : SplitRule.FINISH_NEVER,
finishPrimaryWithSecondary,
finishSecondaryWithPrimary,
clearTop,
ActivityEmbeddingUtils.getMinCurrentScreenSplitWidthPx(context),
ActivityEmbeddingUtils.getMinSmallestScreenSplitWidthPx(context),
@@ -117,17 +117,8 @@ public class ActivityEmbeddingRulesController {
getComponentName(context, Settings.class),
secondaryComponent,
secondaryIntentAction,
finishPrimaryWithSecondary,
finishSecondaryWithPrimary,
clearTop);
registerTwoPanePairRule(
context,
new ComponentName(context, DeepLinkHomepageActivity.class),
secondaryComponent,
secondaryIntentAction,
finishPrimaryWithSecondary,
finishSecondaryWithPrimary,
finishPrimaryWithSecondary ? SplitRule.FINISH_ADJACENT : SplitRule.FINISH_NEVER,
finishSecondaryWithPrimary ? SplitRule.FINISH_ADJACENT : SplitRule.FINISH_NEVER,
clearTop);
registerTwoPanePairRule(
@@ -135,8 +126,19 @@ public class ActivityEmbeddingRulesController {
getComponentName(context, SettingsHomepageActivity.class),
secondaryComponent,
secondaryIntentAction,
finishPrimaryWithSecondary,
finishSecondaryWithPrimary,
finishPrimaryWithSecondary ? SplitRule.FINISH_ADJACENT : SplitRule.FINISH_NEVER,
finishSecondaryWithPrimary ? SplitRule.FINISH_ADJACENT : SplitRule.FINISH_NEVER,
clearTop);
// We should finish HomePageActivity altogether even if it shows in single pane for all deep
// link cases.
registerTwoPanePairRule(
context,
new ComponentName(context, DeepLinkHomepageActivity.class),
secondaryComponent,
secondaryIntentAction,
finishPrimaryWithSecondary ? SplitRule.FINISH_ALWAYS : SplitRule.FINISH_NEVER,
finishSecondaryWithPrimary ? SplitRule.FINISH_ALWAYS : SplitRule.FINISH_NEVER,
clearTop);
registerTwoPanePairRule(
@@ -144,8 +146,8 @@ public class ActivityEmbeddingRulesController {
getComponentName(context, SliceDeepLinkHomepageActivity.class),
secondaryComponent,
secondaryIntentAction,
finishPrimaryWithSecondary,
finishSecondaryWithPrimary,
finishPrimaryWithSecondary ? SplitRule.FINISH_ALWAYS : SplitRule.FINISH_NEVER,
finishSecondaryWithPrimary ? SplitRule.FINISH_ALWAYS : SplitRule.FINISH_NEVER,
clearTop);
}

View File

@@ -52,12 +52,12 @@ public class BluetoothDetailsMacAddressController extends BluetoothDetailsContro
@Override
protected void refresh() {
if (mCachedDevice.getGroupId() != BluetoothCsipSetCoordinator.GROUP_ID_INVALID) {
StringBuilder mTitle = new StringBuilder(mContext.getString(
StringBuilder title = new StringBuilder(mContext.getString(
R.string.bluetooth_multuple_devices_mac_address, mCachedDevice.getAddress()));
for (CachedBluetoothDevice member: mCachedDevice.getMemberDevice()) {
mTitle.append("\n").append(member.getAddress());
title.append("\n").append(member.getAddress());
}
mFooterPreference.setTitle(mTitle);
mFooterPreference.setTitle(title);
} else {
mFooterPreference.setTitle(mContext.getString(
R.string.bluetooth_device_mac_address, mCachedDevice.getAddress()));

View File

@@ -31,6 +31,8 @@ import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settingslib.bluetooth.BluetoothDiscoverableTimeoutReceiver;
import java.time.Duration;
/**
* BluetoothDiscoverableEnabler is a helper to manage the "Discoverable"
* checkbox. It sets/unsets discoverability and keeps track of how much time
@@ -136,9 +138,8 @@ final class BluetoothDiscoverableEnabler implements Preference.OnPreferenceClick
int timeout = getDiscoverableTimeout();
long endTimestamp = System.currentTimeMillis() + timeout * 1000L;
LocalBluetoothPreferences.persistDiscoverableEndTimestamp(mContext, endTimestamp);
mBluetoothAdapter
.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE, timeout);
mBluetoothAdapter.setDiscoverableTimeout(Duration.ofSeconds(timeout));
mBluetoothAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE);
updateCountdownSummary();
Log.d(TAG, "setEnabled(): enabled = " + enable + "timeout = " + timeout);

View File

@@ -94,7 +94,7 @@ public class BluetoothPairingController implements OnCheckedChangeListener,
mPasskeyFormatted = formatKey(mPasskey);
final CachedBluetoothDevice cachedDevice =
mBluetoothManager.getCachedDeviceManager().findDevice(mDevice);
mIsCoordinatedSetMember = (cachedDevice != null)
mIsCoordinatedSetMember = cachedDevice != null
? cachedDevice.isCoordinatedSetMemberDevice() : false;
}

View File

@@ -16,10 +16,13 @@
package com.android.settings.bluetooth;
import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
import android.annotation.NonNull;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothStatusCodes;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
@@ -39,7 +42,7 @@ import androidx.appcompat.app.AlertDialog;
import com.android.settings.R;
import com.android.settingslib.bluetooth.BluetoothDiscoverableTimeoutReceiver;
import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
import java.time.Duration;
/**
* RequestPermissionActivity asks the user whether to enable discovery. This is
@@ -261,22 +264,26 @@ public class RequestPermissionActivity extends Activity implements
if (mRequest == REQUEST_ENABLE || mRequest == REQUEST_DISABLE) {
// BT toggled. Done
returnCode = RESULT_OK;
} else if (mBluetoothAdapter.setScanMode(
BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE, mTimeout)) {
// If already in discoverable mode, this will extend the timeout.
long endTime = System.currentTimeMillis() + (long) mTimeout * 1000;
LocalBluetoothPreferences.persistDiscoverableEndTimestamp(
this, endTime);
if (0 < mTimeout) {
BluetoothDiscoverableTimeoutReceiver.setDiscoverableAlarm(this, endTime);
}
returnCode = mTimeout;
// Activity.RESULT_FIRST_USER should be 1
if (returnCode < RESULT_FIRST_USER) {
returnCode = RESULT_FIRST_USER;
}
} else {
returnCode = RESULT_CANCELED;
mBluetoothAdapter.setDiscoverableTimeout(Duration.ofSeconds(mTimeout));
if (mBluetoothAdapter.setScanMode(
BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE)
== BluetoothStatusCodes.SUCCESS) {
// If already in discoverable mode, this will extend the timeout.
long endTime = System.currentTimeMillis() + (long) mTimeout * 1000;
LocalBluetoothPreferences.persistDiscoverableEndTimestamp(
this, endTime);
if (0 < mTimeout) {
BluetoothDiscoverableTimeoutReceiver.setDiscoverableAlarm(this, endTime);
}
returnCode = mTimeout;
// Activity.RESULT_FIRST_USER should be 1
if (returnCode < RESULT_FIRST_USER) {
returnCode = RESULT_FIRST_USER;
}
} else {
returnCode = RESULT_CANCELED;
}
}
if (mDialog != null) {

View File

@@ -109,10 +109,6 @@ public class PreviewPagerAdapter extends PagerAdapter {
return (view == object);
}
FrameLayout[] getPreviewFrames() {
return mPreviewFrames;
}
boolean isAnimating() {
return mAnimationCounter > 0;
}

View File

@@ -264,12 +264,6 @@ public abstract class PreviewSeekBarPreferenceFragment extends SettingsPreferenc
@Override
public void onPageSelected(int position) {
mPreviewPager.sendAccessibilityEvent(AccessibilityEvent.TYPE_ANNOUNCEMENT);
// To avoid displaying previous page on the left side in SUW landscape mode for
// large size.
if (position > 0) {
mPreviewPagerAdapter.getPreviewFrames()[position - 1].setVisibility(View.INVISIBLE);
}
mPreviewPagerAdapter.getPreviewFrames()[position].setVisibility(View.VISIBLE);
}
};

View File

@@ -40,6 +40,7 @@ import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.window.embedding.SplitRule;
import com.android.settings.R;
import com.android.settings.Settings;
@@ -338,15 +339,15 @@ public class SettingsHomepageActivity extends FragmentActivity implements
new ComponentName(getApplicationContext(), getClass()),
targetComponentName,
targetIntent.getAction(),
true /* finishPrimaryWithSecondary */,
true /* finishSecondaryWithPrimary */,
SplitRule.FINISH_ALWAYS,
SplitRule.FINISH_ALWAYS,
true /* clearTop*/);
ActivityEmbeddingRulesController.registerTwoPanePairRule(this,
new ComponentName(Settings.class.getPackageName(), Settings.class.getName()),
targetComponentName,
targetIntent.getAction(),
true /* finishPrimaryWithSecondary */,
true /* finishSecondaryWithPrimary */,
SplitRule.FINISH_ALWAYS,
SplitRule.FINISH_ALWAYS,
true /* clearTop*/);
startActivity(targetIntent);
}

View File

@@ -58,7 +58,9 @@ public class UserCapabilities {
DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(
Context.DEVICE_POLICY_SERVICE);
// No restricted profiles for tablets with a device owner, or phones.
if (dpm.isDeviceManaged() || Utils.isVoiceCapable(context)) {
if (dpm.isDeviceManaged()
|| Utils.isVoiceCapable(context)
|| !userManager.isUserTypeEnabled(UserManager.USER_TYPE_FULL_RESTRICTED)) {
caps.mCanAddRestrictedProfile = false;
}
caps.updateAddUserCapabilities(context);
@@ -76,15 +78,19 @@ public class UserCapabilities {
mDisallowAddUser = (mEnforcedAdmin != null || hasBaseUserRestriction);
mUserSwitcherEnabled = userManager.isUserSwitcherEnabled();
mCanAddUser = true;
if (!mIsAdmin || UserManager.getMaxSupportedUsers() < 2
if (!mIsAdmin
|| UserManager.getMaxSupportedUsers() < 2
|| !UserManager.supportsMultipleUsers()
|| mDisallowAddUser) {
|| mDisallowAddUser
|| (!userManager.isUserTypeEnabled(UserManager.USER_TYPE_FULL_SECONDARY)
&& !mCanAddRestrictedProfile)) {
mCanAddUser = false;
}
final boolean canAddUsersWhenLocked = mIsAdmin || Settings.Global.getInt(
context.getContentResolver(), Settings.Global.ADD_USERS_WHEN_LOCKED, 0) == 1;
mCanAddGuest = !mIsGuest && !mDisallowAddUser && canAddUsersWhenLocked;
mCanAddGuest = !mIsGuest && !mDisallowAddUser && canAddUsersWhenLocked
&& userManager.isUserTypeEnabled(UserManager.USER_TYPE_FULL_GUEST);
mDisallowSwitchUser = userManager.hasUserRestriction(UserManager.DISALLOW_USER_SWITCH);
}

View File

@@ -1080,6 +1080,7 @@ public class UserSettings extends SettingsPreferenceFragment
private void updateAddGuest(Context context, boolean isGuestAlreadyCreated) {
if (!isGuestAlreadyCreated && mUserCaps.mCanAddGuest
&& mUserManager.canAddMoreUsers(UserManager.USER_TYPE_FULL_GUEST)
&& WizardManagerHelper.isDeviceProvisioned(context)
&& mUserCaps.mUserSwitcherEnabled) {
mAddGuest.setVisible(true);
@@ -1104,7 +1105,10 @@ public class UserSettings extends SettingsPreferenceFragment
&& mUserCaps.mUserSwitcherEnabled) {
mAddUser.setVisible(true);
mAddUser.setSelectable(true);
final boolean canAddMoreUsers = mUserManager.canAddMoreUsers();
final boolean canAddMoreUsers =
mUserManager.canAddMoreUsers(UserManager.USER_TYPE_FULL_SECONDARY)
|| (mUserCaps.mCanAddRestrictedProfile
&& mUserManager.canAddMoreUsers(UserManager.USER_TYPE_FULL_RESTRICTED));
mAddUser.setEnabled(canAddMoreUsers && !mAddingUser && canSwitchUserNow());
if (!canAddMoreUsers) {
mAddUser.setSummary(

View File

@@ -235,7 +235,7 @@ public class AvailableMediaBluetoothDeviceUpdaterTest {
}
@Test
public void onProfileConnectionStateChanged_leAudioDeviceConnected_notInCall_addPreference() {
public void onProfileConnectionStateChanged_leAudioDeviceConnected_notInCall_addsPreference() {
mAudioManager.setMode(AudioManager.MODE_NORMAL);
when(mBluetoothDeviceUpdater
.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
@@ -248,7 +248,7 @@ public class AvailableMediaBluetoothDeviceUpdaterTest {
}
@Test
public void onProfileConnectionStateChanged_leAudioDeviceConnected_inCall_addPreference() {
public void onProfileConnectionStateChanged_leAudioDeviceConnected_inCall_addsPreference() {
mAudioManager.setMode(AudioManager.MODE_IN_CALL);
when(mBluetoothDeviceUpdater
.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);

View File

@@ -235,7 +235,7 @@ public class ConnectedBluetoothDeviceUpdaterTest {
}
@Test
public void onProfileConnectionStateChanged_leAudioDeviceConnected_inCall_removePreference() {
public void onProfileConnectionStateChanged_leAudioDeviceConnected_inCall_removesPreference() {
mAudioManager.setMode(AudioManager.MODE_IN_CALL);
when(mBluetoothDeviceUpdater
.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
@@ -248,7 +248,7 @@ public class ConnectedBluetoothDeviceUpdaterTest {
}
@Test
public void onProfileConnectionStateChanged_leAudioDeviceConnected_notInCall_removePreference()
public void onProfileConnectionStateChanged_leAudioDeviceConnected_notInCall_removesPreference()
{
mAudioManager.setMode(AudioManager.MODE_NORMAL);
when(mBluetoothDeviceUpdater

View File

@@ -24,6 +24,7 @@ import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.notNull;
import static org.mockito.Mockito.doReturn;
@@ -258,7 +259,8 @@ public class UserSettingsTest {
@Test
public void updateUserList_canAddUserAndSwitchUser_shouldShowAddUser() {
mUserCapabilities.mCanAddUser = true;
doReturn(true).when(mUserManager).canAddMoreUsers();
doReturn(true)
.when(mUserManager).canAddMoreUsers(eq(UserManager.USER_TYPE_FULL_SECONDARY));
doReturn(true).when(mAddUserPreference).isEnabled();
doReturn(SWITCHABILITY_STATUS_OK).when(mUserManager).getUserSwitchability();
@@ -274,7 +276,8 @@ public class UserSettingsTest {
@Test
public void updateUserList_canAddGuestAndSwitchUser_shouldShowAddGuest() {
mUserCapabilities.mCanAddGuest = true;
doReturn(true).when(mUserManager).canAddMoreUsers();
doReturn(true)
.when(mUserManager).canAddMoreUsers(eq(UserManager.USER_TYPE_FULL_GUEST));
doReturn(SWITCHABILITY_STATUS_OK).when(mUserManager).getUserSwitchability();
mFragment.updateUserList();
@@ -288,7 +291,7 @@ public class UserSettingsTest {
@Test
public void updateUserList_cannotSwitchUser_shouldDisableAddUser() {
mUserCapabilities.mCanAddUser = true;
doReturn(true).when(mUserManager).canAddMoreUsers();
doReturn(true).when(mUserManager).canAddMoreUsers(anyString());
doReturn(true).when(mAddUserPreference).isEnabled();
doReturn(SWITCHABILITY_STATUS_USER_SWITCH_DISALLOWED)
.when(mUserManager).getUserSwitchability();
@@ -304,7 +307,7 @@ public class UserSettingsTest {
@Test
public void updateUserList_canNotAddMoreUsers_shouldDisableAddUserWithSummary() {
mUserCapabilities.mCanAddUser = true;
doReturn(false).when(mUserManager).canAddMoreUsers();
doReturn(false).when(mUserManager).canAddMoreUsers(anyString());
doReturn(false).when(mAddUserPreference).isEnabled();
doReturn(SWITCHABILITY_STATUS_OK).when(mUserManager).getUserSwitchability();
doReturn(4).when(mFragment).getRealUsersCount();
@@ -320,7 +323,8 @@ public class UserSettingsTest {
@Test
public void updateUserList_cannotSwitchUser_shouldDisableAddGuest() {
mUserCapabilities.mCanAddGuest = true;
doReturn(true).when(mUserManager).canAddMoreUsers();
doReturn(true)
.when(mUserManager).canAddMoreUsers(eq(UserManager.USER_TYPE_FULL_GUEST));
doReturn(SWITCHABILITY_STATUS_USER_IN_CALL).when(mUserManager).getUserSwitchability();
mFragment.updateUserList();