Snap for 10612918 from 804104ce36 to udc-qpr1-release
Change-Id: I6037fdce276fd4399453617036db91dc5731e30a
This commit is contained in:
@@ -324,11 +324,16 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
|
||||
return;
|
||||
}
|
||||
|
||||
LocalBluetoothProfile asha = mProfileManager.getHearingAidProfile();
|
||||
|
||||
for (CachedBluetoothDevice leAudioDevice : mProfileDeviceMap.get(profile.toString())) {
|
||||
Log.d(TAG,
|
||||
"device:" + leAudioDevice.getDevice().getAnonymizedAddress()
|
||||
+ "disable LE profile");
|
||||
profile.setEnabled(leAudioDevice.getDevice(), false);
|
||||
if (asha != null) {
|
||||
asha.setEnabled(leAudioDevice.getDevice(), true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!SystemProperties.getBoolean(ENABLE_DUAL_MODE_AUDIO, false)) {
|
||||
@@ -354,12 +359,16 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
|
||||
disableProfileBeforeUserEnablesLeAudio(mProfileManager.getA2dpProfile());
|
||||
disableProfileBeforeUserEnablesLeAudio(mProfileManager.getHeadsetProfile());
|
||||
}
|
||||
LocalBluetoothProfile asha = mProfileManager.getHearingAidProfile();
|
||||
|
||||
for (CachedBluetoothDevice leAudioDevice : mProfileDeviceMap.get(profile.toString())) {
|
||||
Log.d(TAG,
|
||||
"device:" + leAudioDevice.getDevice().getAnonymizedAddress()
|
||||
+ "enable LE profile");
|
||||
profile.setEnabled(leAudioDevice.getDevice(), true);
|
||||
if (asha != null) {
|
||||
asha.setEnabled(leAudioDevice.getDevice(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -376,6 +385,12 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
|
||||
+ profile.toString() + " profile is disabled. Do nothing.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (profile == null) {
|
||||
Log.w(TAG, "profile is null");
|
||||
} else {
|
||||
Log.w(TAG, profile.toString() + " is not in " + mProfileDeviceMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,6 +407,12 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
|
||||
+ profile.toString() + " profile is enabled. Do nothing.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (profile == null) {
|
||||
Log.w(TAG, "profile is null");
|
||||
} else {
|
||||
Log.w(TAG, profile.toString() + " is not in " + mProfileDeviceMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.core.view.MotionEventCompat;
|
||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
@@ -178,17 +179,33 @@ class LocaleDragAndDropAdapter
|
||||
// clear listener before setChecked() in case another item already bind to
|
||||
// current ViewHolder and checked event is triggered on stale listener mistakenly.
|
||||
checkbox.setOnCheckedChangeListener(null);
|
||||
checkbox.setChecked(mRemoveMode ? feedItem.getChecked() : false);
|
||||
boolean isChecked = mRemoveMode ? feedItem.getChecked() : false;
|
||||
checkbox.setChecked(isChecked);
|
||||
setCheckBoxDescription(dragCell, checkbox, isChecked);
|
||||
|
||||
checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
LocaleStore.LocaleInfo feedItem =
|
||||
(LocaleStore.LocaleInfo) dragCell.getTag();
|
||||
feedItem.setChecked(isChecked);
|
||||
setCheckBoxDescription(dragCell, checkbox, isChecked);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
protected void setCheckBoxDescription(LocaleDragCell dragCell, CheckBox checkbox,
|
||||
boolean isChecked) {
|
||||
CharSequence checkedStatus = mContext.getText(
|
||||
isChecked ? com.android.internal.R.string.checked
|
||||
: com.android.internal.R.string.not_checked);
|
||||
// Talkback
|
||||
dragCell.setStateDescription(checkedStatus);
|
||||
// Select to Speak
|
||||
checkbox.setContentDescription(checkedStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
int itemCount = (null != mFeedItemList ? mFeedItemList.size() : 0);
|
||||
|
||||
@@ -50,6 +50,7 @@ public class ForgotPasswordActivity extends Activity {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
ThemeHelper.trySetDynamicColor(this);
|
||||
setContentView(R.layout.forgot_password_activity);
|
||||
|
||||
DevicePolicyManager devicePolicyManager = getSystemService(DevicePolicyManager.class);
|
||||
|
||||
@@ -61,7 +61,7 @@ import com.android.internal.net.LegacyVpnInfo;
|
||||
import com.android.internal.net.VpnConfig;
|
||||
import com.android.internal.net.VpnProfile;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.RestrictedSettingsFragment;
|
||||
import com.android.settings.dashboard.RestrictedDashboardFragment;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.widget.GearPreference;
|
||||
import com.android.settings.widget.GearPreference.OnGearClickListener;
|
||||
@@ -80,7 +80,7 @@ import java.util.Set;
|
||||
* Settings screen listing VPNs. Configured VPNs and networks managed by apps
|
||||
* are shown in the same list.
|
||||
*/
|
||||
public class VpnSettings extends RestrictedSettingsFragment implements
|
||||
public class VpnSettings extends RestrictedDashboardFragment implements
|
||||
Handler.Callback, Preference.OnPreferenceClickListener {
|
||||
private static final String LOG_TAG = "VpnSettings";
|
||||
private static final boolean DEBUG = Log.isLoggable(LOG_TAG, Log.DEBUG);
|
||||
@@ -135,7 +135,6 @@ public class VpnSettings extends RestrictedSettingsFragment implements
|
||||
mUnavailable = isUiRestricted();
|
||||
setHasOptionsMenu(!mUnavailable);
|
||||
|
||||
addPreferencesFromResource(R.xml.vpn_settings2);
|
||||
mPreferenceScreen = getPreferenceScreen();
|
||||
}
|
||||
|
||||
@@ -211,6 +210,16 @@ public class VpnSettings extends RestrictedSettingsFragment implements
|
||||
mUpdater.sendEmptyMessage(RESCAN_MESSAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.vpn_settings2;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return LOG_TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
if (mUnavailable) {
|
||||
|
||||
@@ -22,6 +22,7 @@ import androidx.annotation.VisibleForTesting;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.wifitrackerlib.WifiEntry;
|
||||
|
||||
/**
|
||||
@@ -34,7 +35,7 @@ public class LongPressWifiEntryPreference extends WifiEntryPreference {
|
||||
public LongPressWifiEntryPreference(Context context, WifiEntry wifiEntry, Fragment fragment) {
|
||||
super(context, wifiEntry);
|
||||
mFragment = fragment;
|
||||
checkRestrictionAndSetDisabled(UserManager.DISALLOW_ADD_WIFI_CONFIG);
|
||||
checkRestrictionAndSetDisabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,4 +66,22 @@ public class LongPressWifiEntryPreference extends WifiEntryPreference {
|
||||
}
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void checkRestrictionAndSetDisabled() {
|
||||
if (!getWifiEntry().hasAdminRestrictions()) {
|
||||
return;
|
||||
}
|
||||
RestrictedLockUtils.EnforcedAdmin admin = null;
|
||||
Context context = getContext();
|
||||
if (context != null) {
|
||||
admin = RestrictedLockUtils.getProfileOrDeviceOwner(context, context.getUser());
|
||||
}
|
||||
if (admin == null) {
|
||||
// Use UserManager.DISALLOW_ADD_WIFI_CONFIG as default Wi-Fi network restriction.
|
||||
admin = RestrictedLockUtils.EnforcedAdmin.createDefaultEnforcedAdminWithRestriction(
|
||||
UserManager.DISALLOW_ADD_WIFI_CONFIG);
|
||||
}
|
||||
setDisabledByAdmin(admin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.anyBoolean;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -34,6 +35,10 @@ import android.os.Bundle;
|
||||
import android.os.LocaleList;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
@@ -46,6 +51,7 @@ import com.android.settings.R;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.shadow.ShadowActivityManager;
|
||||
import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@@ -58,7 +64,6 @@ import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -75,11 +80,12 @@ public class LocaleListEditorTest {
|
||||
private static final int REQUEST_CONFIRM_SYSTEM_DEFAULT = 1;
|
||||
|
||||
private LocaleListEditor mLocaleListEditor;
|
||||
|
||||
private Context mContext;
|
||||
private FragmentActivity mActivity;
|
||||
private List mLocaleList;
|
||||
private List<LocaleStore.LocaleInfo> mLocaleList;
|
||||
private Intent mIntent = new Intent();
|
||||
private LocaleDragCell mLocaleDragCell;
|
||||
private LocaleDragAndDropAdapter.CustomViewHolder mCustomViewHolder;
|
||||
|
||||
@Mock
|
||||
private LocaleDragAndDropAdapter mAdapter;
|
||||
@@ -95,11 +101,23 @@ public class LocaleListEditorTest {
|
||||
private IActivityManager mActivityService;
|
||||
@Mock
|
||||
private MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
@Mock
|
||||
private TextView mLabel;
|
||||
@Mock
|
||||
private CheckBox mCheckbox;
|
||||
@Mock
|
||||
private TextView mMiniLabel;
|
||||
@Mock
|
||||
private TextView mLocalized;
|
||||
@Mock
|
||||
private TextView mCurrentDefault;
|
||||
@Mock
|
||||
private ImageView mDragHandle;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
mLocaleListEditor = spy(new LocaleListEditor());
|
||||
when(mLocaleListEditor.getContext()).thenReturn(mContext);
|
||||
mActivity = Robolectric.buildActivity(FragmentActivity.class).get();
|
||||
@@ -300,6 +318,35 @@ public class LocaleListEditorTest {
|
||||
verify(mAdapter).doTheUpdate();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onBindViewHolder_shouldSetCheckedBoxText() {
|
||||
ReflectionHelpers.setField(mLocaleListEditor, "mRemoveMode", true);
|
||||
mLocaleList = new ArrayList<>();
|
||||
mLocaleList.add(mLocaleInfo);
|
||||
when(mLocaleInfo.getFullNameNative()).thenReturn("English");
|
||||
when(mLocaleInfo.getLocale()).thenReturn(LocaleList.forLanguageTags("en-US").get(0));
|
||||
|
||||
mAdapter = spy(new LocaleDragAndDropAdapter(mLocaleListEditor, mLocaleList));
|
||||
ReflectionHelpers.setField(mAdapter, "mFeedItemList", mLocaleList);
|
||||
ReflectionHelpers.setField(mAdapter, "mParent", mLocaleListEditor);
|
||||
ReflectionHelpers.setField(mAdapter, "mCacheItemList", new ArrayList<>(mLocaleList));
|
||||
ReflectionHelpers.setField(mAdapter, "mContext", mContext);
|
||||
ViewGroup view = new FrameLayout(mContext);
|
||||
mCustomViewHolder = mAdapter.onCreateViewHolder(view, 0);
|
||||
mLocaleDragCell = new LocaleDragCell(mContext, null);
|
||||
ReflectionHelpers.setField(mCustomViewHolder, "mLocaleDragCell", mLocaleDragCell);
|
||||
ReflectionHelpers.setField(mLocaleDragCell, "mLabel", mLabel);
|
||||
ReflectionHelpers.setField(mLocaleDragCell, "mLocalized", mLocalized);
|
||||
ReflectionHelpers.setField(mLocaleDragCell, "mCurrentDefault", mCurrentDefault);
|
||||
ReflectionHelpers.setField(mLocaleDragCell, "mMiniLabel", mMiniLabel);
|
||||
ReflectionHelpers.setField(mLocaleDragCell, "mDragHandle", mDragHandle);
|
||||
ReflectionHelpers.setField(mLocaleDragCell, "mCheckbox", mCheckbox);
|
||||
|
||||
mAdapter.onBindViewHolder(mCustomViewHolder, 0);
|
||||
|
||||
verify(mAdapter).setCheckBoxDescription(any(LocaleDragCell.class), any(), anyBoolean());
|
||||
}
|
||||
|
||||
private void setUpLocaleConditions() {
|
||||
ShadowActivityManager.setService(mActivityService);
|
||||
mLocaleList = new ArrayList<>();
|
||||
|
||||
@@ -18,6 +18,10 @@ package com.android.settings.wifi;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -60,7 +64,7 @@ public class LongPressWifiEntryPreferenceTest {
|
||||
when(mWifiEntry.canDisconnect()).thenReturn(false);
|
||||
when(mWifiEntry.isSaved()).thenReturn(false);
|
||||
|
||||
mPreference = new LongPressWifiEntryPreference(mContext, mWifiEntry, mFragment);
|
||||
mPreference = spy(new LongPressWifiEntryPreference(mContext, mWifiEntry, mFragment));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -106,4 +110,23 @@ public class LongPressWifiEntryPreferenceTest {
|
||||
|
||||
assertThat(mPreference.shouldEnabled()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkRestrictionAndSetDisabled_hasAdminRestrictions_doSetDisabledByAdmin() {
|
||||
when(mContext.getUser()).thenReturn(null);
|
||||
when(mWifiEntry.hasAdminRestrictions()).thenReturn(true);
|
||||
|
||||
mPreference.checkRestrictionAndSetDisabled();
|
||||
|
||||
verify(mPreference).setDisabledByAdmin(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkRestrictionAndSetDisabled_noAdminRestrictions_doNotSetDisabledByAdmin() {
|
||||
when(mWifiEntry.hasAdminRestrictions()).thenReturn(false);
|
||||
|
||||
mPreference.checkRestrictionAndSetDisabled();
|
||||
|
||||
verify(mPreference, never()).setDisabledByAdmin(any());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user