Snap for 5053735 from 6607361db7 to qt-release

Change-Id: I53b27594949e36358a17fffa6b2fdcf40c4108b1
This commit is contained in:
android-build-team Robot
2018-10-07 03:06:16 +00:00
10 changed files with 99 additions and 49 deletions

View File

@@ -33,7 +33,7 @@ public abstract class BiometricStatusPreferenceController extends BasePreference
protected final UserManager mUm;
protected final LockPatternUtils mLockPatternUtils;
protected final int mUserId = UserHandle.myUserId();
private final int mUserId = UserHandle.myUserId();
protected final int mProfileChallengeUserId;
/**

View File

@@ -46,7 +46,7 @@ public class FaceStatusPreferenceController extends BiometricStatusPreferenceCon
@Override
protected boolean hasEnrolledBiometrics() {
return mFaceManager.hasEnrolledTemplates(mUserId);
return mFaceManager.hasEnrolledTemplates(getUserId());
}
@Override

View File

@@ -45,12 +45,12 @@ public class FingerprintStatusPreferenceController extends BiometricStatusPrefer
@Override
protected boolean hasEnrolledBiometrics() {
return mFingerprintManager.hasEnrolledFingerprints(mUserId);
return mFingerprintManager.hasEnrolledFingerprints(getUserId());
}
@Override
protected String getSummaryTextEnrolled() {
final int numEnrolled = mFingerprintManager.getEnrolledFingerprints(mUserId).size();
final int numEnrolled = mFingerprintManager.getEnrolledFingerprints(getUserId()).size();
return mContext.getResources().getQuantityString(
R.plurals.security_settings_fingerprint_preference_summary,
numEnrolled, numEnrolled);

View File

@@ -18,6 +18,8 @@ import static android.net.ConnectivityManager.TYPE_MOBILE;
import static android.net.ConnectivityManager.TYPE_WIFI;
import static android.telephony.TelephonyManager.SIM_STATE_READY;
import android.app.usage.NetworkStats.Bucket;
import android.app.usage.NetworkStatsManager;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.INetworkStatsService;
@@ -33,8 +35,11 @@ import android.telephony.TelephonyManager;
import android.text.BidiFormatter;
import android.text.format.Formatter;
import android.text.format.Formatter.BytesResult;
import android.util.FeatureFlagUtils;
import android.util.Log;
import com.android.settings.core.FeatureFlags;
import java.util.List;
/**
@@ -69,28 +74,48 @@ public final class DataUsageUtils {
}
final ConnectivityManager conn = ConnectivityManager.from(context);
final boolean hasEthernet = conn.isNetworkSupported(ConnectivityManager.TYPE_ETHERNET);
final long ethernetBytes;
try {
INetworkStatsService statsService = INetworkStatsService.Stub.asInterface(
ServiceManager.getService(Context.NETWORK_STATS_SERVICE));
INetworkStatsSession statsSession = statsService.openSession();
if (statsSession != null) {
ethernetBytes = statsSession.getSummaryForNetwork(
NetworkTemplate.buildTemplateEthernet(), Long.MIN_VALUE, Long.MAX_VALUE)
.getTotalBytes();
TrafficStats.closeQuietly(statsSession);
} else {
ethernetBytes = 0;
}
} catch (RemoteException e) {
throw new RuntimeException(e);
if (!conn.isNetworkSupported(ConnectivityManager.TYPE_ETHERNET)) {
return false;
}
// only show ethernet when both hardware present and traffic has occurred
return hasEthernet && ethernetBytes > 0;
if (FeatureFlagUtils.isEnabled(context, FeatureFlags.DATA_USAGE_V2)) {
final TelephonyManager telephonyManager = TelephonyManager.from(context);;
final NetworkStatsManager networkStatsManager =
context.getSystemService(NetworkStatsManager.class);
boolean hasEthernetUsage = false;
try {
final Bucket bucket = networkStatsManager.querySummaryForUser(
ConnectivityManager.TYPE_ETHERNET, telephonyManager.getSubscriberId(),
0L /* startTime */, System.currentTimeMillis() /* endTime */);
if (bucket != null) {
hasEthernetUsage = bucket.getRxBytes() > 0 || bucket.getTxBytes() > 0;
}
} catch (RemoteException e) {
Log.e(TAG, "Exception querying network detail.", e);
}
return hasEthernetUsage;
} else {
final long ethernetBytes;
try {
INetworkStatsService statsService = INetworkStatsService.Stub.asInterface(
ServiceManager.getService(Context.NETWORK_STATS_SERVICE));
INetworkStatsSession statsSession = statsService.openSession();
if (statsSession != null) {
ethernetBytes = statsSession.getSummaryForNetwork(
NetworkTemplate.buildTemplateEthernet(), Long.MIN_VALUE, Long.MAX_VALUE)
.getTotalBytes();
TrafficStats.closeQuietly(statsSession);
} else {
ethernetBytes = 0;
}
} catch (RemoteException e) {
throw new RuntimeException(e);
}
// only show ethernet when both hardware present and traffic has occurred
return ethernetBytes > 0;
}
}
/**

View File

@@ -66,20 +66,6 @@ public class BluetoothA2dpHwOffloadPreferenceController extends DeveloperOptions
}
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
final boolean offloadSupported =
SystemProperties.getBoolean(A2DP_OFFLOAD_SUPPORTED_PROPERTY, false);
if (offloadSupported) {
((SwitchPreference) mPreference).setChecked(false);
SystemProperties.set(A2DP_OFFLOAD_DISABLED_PROPERTY, "false");
} else {
((SwitchPreference) mPreference).setChecked(true);
SystemProperties.set(A2DP_OFFLOAD_DISABLED_PROPERTY, "true");
}
}
public void onA2dpHwDialogConfirmed() {
final boolean offloadDisabled =
SystemProperties.getBoolean(A2DP_OFFLOAD_DISABLED_PROPERTY, false);

View File

@@ -54,12 +54,12 @@ public class CbrsDataSwitchPreferenceController extends DeveloperOptionsPreferen
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean state = (Boolean)newValue;
return mTelephonyManager.setAlternativeNetworkAccessState(state);
return mTelephonyManager.setAlternativeNetworkState(state);
}
@Override
public void updateState(Preference preference) {
boolean state = mTelephonyManager.isAlternativeNetworkAccessEnabled();
boolean state = mTelephonyManager.isAlternativeNetworkEnabled();
((SwitchPreference) mPreference).setChecked(state);
}

View File

@@ -123,7 +123,8 @@ public class WifiConfigController implements TextWatcher,
private final ArrayAdapter<String> mPhase2FullAdapter;
// e.g. AccessPoint.SECURITY_NONE
private int mAccessPointSecurity;
@VisibleForTesting
int mAccessPointSecurity;
private TextView mPasswordView;
private String mUnspecifiedCertString;
@@ -465,7 +466,8 @@ public class WifiConfigController implements TextWatcher,
} else {
enabled = ipAndProxyFieldsAreValid();
}
if (mAccessPointSecurity == AccessPoint.SECURITY_EAP) {
if (mAccessPointSecurity == AccessPoint.SECURITY_EAP && mEapCaCertSpinner != null
&& mView.findViewById(R.id.l_ca_cert).getVisibility() != View.GONE) {
String caCertSelection = (String) mEapCaCertSpinner.getSelectedItem();
if (caCertSelection.equals(mUnspecifiedCertString)) {
// Disallow submit if the user has not selected a CA certificate for an EAP network
@@ -481,7 +483,8 @@ public class WifiConfigController implements TextWatcher,
enabled = false;
}
}
if (mAccessPointSecurity == AccessPoint.SECURITY_EAP
if (mAccessPointSecurity == AccessPoint.SECURITY_EAP && mEapUserCertSpinner != null
&& mView.findViewById(R.id.l_user_cert).getVisibility() != View.GONE
&& mEapUserCertSpinner.getSelectedItem().equals(mUnspecifiedCertString)) {
// Disallow submit if the user has not selected a user certificate for an EAP network
// configuration.

View File

@@ -19,13 +19,19 @@ package com.android.settings.datausage;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.usage.NetworkStatsManager;
import android.content.Context;
import android.net.ConnectivityManager;
import android.telephony.TelephonyManager;
import android.util.DataUnit;
import android.util.FeatureFlagUtils;
import com.android.settings.core.FeatureFlags;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
@@ -42,6 +48,9 @@ public final class DataUsageUtilsTest {
private ConnectivityManager mManager;
@Mock
private TelephonyManager mTelephonyManager;
@Mock
private NetworkStatsManager mNetworkStatsManager;
private Context mContext;
@Before
@@ -51,6 +60,7 @@ public final class DataUsageUtilsTest {
mContext = shadowContext.getApplicationContext();
shadowContext.setSystemService(Context.CONNECTIVITY_SERVICE, mManager);
shadowContext.setSystemService(Context.TELEPHONY_SERVICE, mTelephonyManager);
shadowContext.setSystemService(Context.NETWORK_STATS_SERVICE, mNetworkStatsManager);
}
@Test
@@ -88,4 +98,17 @@ public final class DataUsageUtilsTest {
assertThat(formattedDataUsage).isEqualTo("1.00 GB");
}
@Test
public void hasEthernet_shouldQueryEthernetSummaryForUser() throws Exception {
FeatureFlagUtils.setEnabled(mContext, FeatureFlags.DATA_USAGE_V2, true);
when(mManager.isNetworkSupported(anyInt())).thenReturn(true);
final String subscriber = "TestSub";
when(mTelephonyManager.getSubscriberId()).thenReturn(subscriber);
DataUsageUtils.hasEthernet(mContext);
verify(mNetworkStatsManager).querySummaryForUser(eq(ConnectivityManager.TYPE_ETHERNET),
eq(subscriber), anyLong() /* startTime */, anyLong() /* endTime */);
}
}

View File

@@ -62,19 +62,19 @@ public final class CbrsDataSwitchPreferenceControllerTest {
public void onPreferenceChanged_settingEnabled_shouldEnableANAS() {
mController.onPreferenceChange(mPreference, true);
assertThat(mTelephonyManager.isAlternativeNetworkAccessEnabled()).isTrue();
assertThat(mTelephonyManager.isAlternativeNetworkEnabled()).isTrue();
}
@Test
public void onPreferenceChanged_settingDisabled_shouldDisableANAS() {
mController.onPreferenceChange(mPreference, false);
assertThat(mTelephonyManager.isAlternativeNetworkAccessEnabled()).isFalse();
assertThat(mTelephonyManager.isAlternativeNetworkEnabled()).isFalse();
}
@Test
public void updateState_settingEnabled_shouldEnablePreference() {
mTelephonyManager.setAlternativeNetworkAccessState(true);
mTelephonyManager.setAlternativeNetworkState(true);
mController.updateState(mPreference);
assertThat(mPreference.isChecked()).isTrue();
@@ -82,7 +82,7 @@ public final class CbrsDataSwitchPreferenceControllerTest {
@Test
public void updateState_settingDisabled_shouldDisablePreference() {
mTelephonyManager.setAlternativeNetworkAccessState(false);
mTelephonyManager.setAlternativeNetworkState(false);
mController.updateState(mPreference);
assertThat(mPreference.isChecked()).isFalse();

View File

@@ -57,11 +57,10 @@ public class WifiConfigControllerTest {
@Mock
private Context mContext;
@Mock
private View mView;
@Mock
private AccessPoint mAccessPoint;
@Mock
private KeyStore mKeyStore;
private View mView;
private Spinner mHiddenSettingsSpinner;
public WifiConfigController mController;
@@ -74,6 +73,7 @@ public class WifiConfigControllerTest {
private static final String SHORT_PSK = "abcdefg";
// Valid PSK pass phrase
private static final String GOOD_PSK = "abcdefghijklmnopqrstuvwxyz";
private static final String GOOD_SSID = "abc";
private static final int DHCP = 0;
@Before
@@ -185,6 +185,9 @@ public class WifiConfigControllerTest {
@Test
public void isSubmittable_EapToPskWithValidPassword_shouldReturnTrue() {
mController = new TestWifiConfigController(mConfigUiBase, mView, null,
WifiConfigUiBase.MODE_CONNECT);
final TextView ssid = mView.findViewById(R.id.ssid);
final TextView password = mView.findViewById(R.id.password);
final Spinner securitySpinner = mView.findViewById(R.id.security);
assertThat(password).isNotNull();
@@ -195,6 +198,16 @@ public class WifiConfigControllerTest {
mController.onItemSelected(securitySpinner, null, AccessPoint.SECURITY_EAP, 0);
mController.onItemSelected(securitySpinner, null, AccessPoint.SECURITY_PSK, 0);
password.setText(GOOD_PSK);
ssid.setText(GOOD_SSID);
assertThat(mController.isSubmittable()).isTrue();
}
@Test
public void isSubmittable_EapWithAkaMethod_shouldReturnTrue() {
when(mAccessPoint.isSaved()).thenReturn(true);
mController.mAccessPointSecurity = AccessPoint.SECURITY_EAP;
mView.findViewById(R.id.l_ca_cert).setVisibility(View.GONE);
assertThat(mController.isSubmittable()).isTrue();
}