Merge "Create a new string to alert unsupported vpn start." into main
diff --git a/Android.bp b/Android.bp
index 4d07913..9680b8b 100644
--- a/Android.bp
+++ b/Android.bp
@@ -61,6 +61,7 @@
"res-product",
],
static_libs: [
+ "android.nfc.flags-aconfig-java",
"androidx-constraintlayout_constraintlayout",
"androidx.slice_slice-builders",
"androidx.slice_slice-core",
diff --git a/res/layout/vpn_dialog.xml b/res/layout/vpn_dialog.xml
index 892a176..062772e 100644
--- a/res/layout/vpn_dialog.xml
+++ b/res/layout/vpn_dialog.xml
@@ -66,25 +66,6 @@
<EditText style="@style/vpn_value"
android:id="@+id/server"/>
- <CheckBox style="@style/vpn_value"
- android:id="@+id/mppe"
- android:text="@string/vpn_mppe"
- android:visibility="gone"/>
-
- <LinearLayout android:id="@+id/l2tp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:visibility="gone">
- <TextView style="@style/vpn_label"
- android:text="@string/vpn_l2tp_secret"
- android:labelFor="@+id/l2tp_secret"/>
- <EditText style="@style/vpn_value"
- android:id="@+id/l2tp_secret"
- android:password="true"
- android:hint="@string/vpn_not_used"/>
- </LinearLayout>
-
<LinearLayout android:id="@+id/options_ipsec_identity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -154,31 +135,6 @@
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
- <LinearLayout android:id="@+id/network_options"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical">
- <TextView style="@style/vpn_label"
- android:text="@string/vpn_search_domains"
- android:labelFor="@+id/search_domains"/>
- <EditText style="@style/vpn_value"
- android:id="@+id/search_domains"
- android:hint="@string/vpn_not_used"/>
-
- <TextView style="@style/vpn_label"
- android:text="@string/vpn_dns_servers"
- android:labelFor="@+id/dns_servers"/>
- <EditText style="@style/vpn_value"
- android:id="@+id/dns_servers"
- android:hint="@string/vpn_not_used"/>
-
- <TextView style="@style/vpn_label"
- android:text="@string/vpn_routes"
- android:labelFor="@+id/routes"/>
- <EditText style="@style/vpn_value"
- android:id="@+id/routes"
- android:hint="@string/vpn_not_used"/>
- </LinearLayout>
<TextView android:id="@+id/vpn_proxy_settings_title"
style="@style/vpn_label"
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 787163e..7427a0a 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -872,15 +872,9 @@
<item>1</item>
</string-array>
- <!-- Match this with the constants in VpnProfile. --> <skip />
+ <!-- Match this with the array VPN_TYPES in ConfigDialog. --> <skip />
<!-- Short names for each VPN type, not really translatable. [CHAR LIMIT=20] -->
<string-array name="vpn_types" translatable="false">
- <item>PPTP</item>
- <item>L2TP/IPSec PSK</item>
- <item>L2TP/IPSec RSA</item>
- <item>IPSec Xauth PSK</item>
- <item>IPSec Xauth RSA</item>
- <item>IPSec Hybrid RSA</item>
<item>IKEv2/IPSec MSCHAPv2</item>
<item>IKEv2/IPSec PSK</item>
<item>IKEv2/IPSec RSA</item>
diff --git a/res/values/config.xml b/res/values/config.xml
index 2c683ea..b4087df 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -726,6 +726,9 @@
<item></item>
</string-array>
+ <!-- Whether to display the "Enable wireless display" menu -->
+ <bool name="config_show_wifi_display_enable_menu">true</bool>
+
<!-- List of packages that should be hidden for MVNO. Do not translate -->
<string-array name="datausage_hiding_carrier_service_package_names" translatable="false"/>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index c812ed4..1dbeb75 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -6087,10 +6087,6 @@
<string name="vpn_type">Type</string>
<!-- Input label for the server address of a VPN profile. [CHAR LIMIT=40] -->
<string name="vpn_server">Server address</string>
- <!-- Checkbox label to enable PPP encryption for a VPN profile. [CHAR LIMIT=40] -->
- <string name="vpn_mppe">PPP encryption (MPPE)</string>
- <!-- Input label for the L2TP secret of a VPN profile. [CHAR LIMIT=40] -->
- <string name="vpn_l2tp_secret">L2TP secret</string>
<!-- Input label for the IPSec identifier of a VPN profile. [CHAR LIMIT=40] -->
<string name="vpn_ipsec_identifier">IPSec identifier</string>
<!-- Input label for the IPSec pre-shared key of a VPN profile. [CHAR LIMIT=40] -->
@@ -6103,12 +6099,6 @@
<string name="vpn_ipsec_server_cert">IPSec server certificate</string>
<!-- Checkbox label to show advanced options of a VPN profile. [CHAR LIMIT=40] -->
<string name="vpn_show_options">Show advanced options</string>
- <!-- Input label for the DNS search domains of a VPN profile. [CHAR LIMIT=40] -->
- <string name="vpn_search_domains">DNS search domains</string>
- <!-- Input label for the DNS servers of a VPN profile. [CHAR LIMIT=40] -->
- <string name="vpn_dns_servers">DNS servers (e.g. 8.8.8.8)</string>
- <!-- Input label for the forwarding routes of a VPN profile. [CHAR LIMIT=40] -->
- <string name="vpn_routes">Forwarding routes (e.g. 10.0.0.0/8)</string>
<!-- Input label for the username of a VPN profile. [CHAR LIMIT=40] -->
<string name="vpn_username">Username</string>
<!-- Input label for the password of a VPN profile. [CHAR LIMIT=40] -->
@@ -6122,22 +6112,6 @@
<!-- Option to use the server certificate received from the VPN server. [CHAR LIMIT=40] -->
<string name="vpn_no_server_cert">(received from server)</string>
<!-- Error message displayed below the always-on VPN checkbox when the checkbox is disabled:
- the selected VPN type doesn't support always-on. [CHAR LIMIT=120] -->
- <string name="vpn_always_on_invalid_reason_type">This VPN type can\'t stay connected at all
- times</string>
- <!-- Error message displayed below the always-on VPN checkbox when the checkbox is disabled:
- the server address is not in numeric form (e.g. 8.8.8.8). [CHAR LIMIT=120] -->
- <string name="vpn_always_on_invalid_reason_server">Always-on VPN only supports numeric server
- addresses</string>
- <!-- Error message displayed below the always-on VPN checkbox when the checkbox is disabled:
- no DNS is found. [CHAR LIMIT=120] -->
- <string name="vpn_always_on_invalid_reason_no_dns">A DNS server must be specified for always-on
- VPN</string>
- <!-- Error message displayed below the always-on VPN checkbox when the checkbox is disabled:
- DNS server addresses are not in numeric form (e.g. 8.8.8.8). [CHAR LIMIT=120] -->
- <string name="vpn_always_on_invalid_reason_dns">DNS server addresses must be numeric for
- always-on VPN</string>
- <!-- Error message displayed below the always-on VPN checkbox when the checkbox is disabled:
generic error. [CHAR LIMIT=120] -->
<string name="vpn_always_on_invalid_reason_other">The information entered doesn\'t support
always-on VPN</string>
diff --git a/src/com/android/settings/MainClear.java b/src/com/android/settings/MainClear.java
index f706c78..07888c6 100644
--- a/src/com/android/settings/MainClear.java
+++ b/src/com/android/settings/MainClear.java
@@ -26,11 +26,13 @@
import android.accounts.AuthenticatorDescription;
import android.app.ActionBar;
import android.app.Activity;
+import android.app.AlertDialog;
import android.app.admin.DevicePolicyManager;
import android.app.settings.SettingsEnums;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
@@ -43,6 +45,7 @@
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
+import android.os.image.DynamicSystemManager;
import android.provider.Settings;
import android.telephony.euicc.EuiccManager;
import android.text.TextUtils;
@@ -266,6 +269,19 @@
return;
}
+ final DynamicSystemManager dsuManager = (DynamicSystemManager)
+ getActivity().getSystemService(Context.DYNAMIC_SYSTEM_SERVICE);
+ if (dsuManager.isInUse()) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
+ builder.setTitle(R.string.dsu_is_running);
+ builder.setPositiveButton(R.string.okay, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {}
+ });
+ AlertDialog dsuAlertdialog = builder.create();
+ dsuAlertdialog.show();
+ return;
+ }
+
if (runKeyguardConfirmation(KEYGUARD_REQUEST)) {
return;
}
diff --git a/src/com/android/settings/applications/specialaccess/PaymentSettingsEnabler.java b/src/com/android/settings/applications/specialaccess/PaymentSettingsEnabler.java
index 597705c..e378eb3 100644
--- a/src/com/android/settings/applications/specialaccess/PaymentSettingsEnabler.java
+++ b/src/com/android/settings/applications/specialaccess/PaymentSettingsEnabler.java
@@ -17,8 +17,10 @@
package com.android.settings.applications.specialaccess;
import android.content.Context;
+import android.nfc.Flags;
import android.nfc.NfcAdapter;
import android.nfc.cardemulation.CardEmulation;
+import android.os.UserHandle;
import androidx.preference.Preference;
@@ -64,12 +66,21 @@
}
}
+ private boolean hasAnyServices() {
+ if (Flags.enableNfcMainline()) {
+ return mCardEmuManager.getServices(
+ CardEmulation.CATEGORY_PAYMENT, UserHandle.myUserId()).isEmpty();
+ } else {
+ return mCardEmuManager.getServices(CardEmulation.CATEGORY_PAYMENT).isEmpty();
+ }
+ }
+
@Override
public void resume() {
if (!isNfcAvailable()) {
return;
}
- if (mCardEmuManager.getServices(CardEmulation.CATEGORY_PAYMENT).isEmpty()) {
+ if (hasAnyServices()) {
mIsPaymentAvailable = false;
} else {
mIsPaymentAvailable = true;
diff --git a/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverController.java b/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverController.java
index 992136c..42c7de1 100644
--- a/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverController.java
+++ b/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverController.java
@@ -52,9 +52,6 @@
private boolean mShouldToggleSwitchBackOnRebootDialogDismiss;
@VisibleForTesting
- static final String PROPERTY_RO_GFX_ANGLE_SUPPORTED = "ro.gfx.angle.supported";
-
- @VisibleForTesting
static final String PROPERTY_PERSISTENT_GRAPHICS_EGL = "persist.graphics.egl";
@VisibleForTesting
@@ -97,11 +94,6 @@
return mSystemProperties.getBoolean(PROPERTY_DEBUG_ANGLE_DEVELOPER_OPTION, false);
}
- private boolean isAngleSupported() {
- return TextUtils.equals(
- mSystemProperties.get(PROPERTY_RO_GFX_ANGLE_SUPPORTED, ""), "true");
- }
-
@VisibleForTesting
GraphicsDriverEnableAngleAsSystemDriverController(
Context context, DevelopmentSettingsDashboardFragment fragment, Injector injector) {
@@ -145,10 +137,6 @@
/** Return the default value of "persist.graphics.egl" */
public boolean isDefaultValue() {
- if (!isAngleSupported()) {
- return true;
- }
-
final String currentGlesDriver =
mSystemProperties.get(PROPERTY_PERSISTENT_GRAPHICS_EGL, "");
// default value of "persist.graphics.egl" is ""
@@ -158,17 +146,11 @@
@Override
public void updateState(Preference preference) {
super.updateState(preference);
- if (isAngleSupported()) {
- // set switch on if "persist.graphics.egl" is "angle" and angle is built in /vendor
- // set switch off otherwise.
- final String currentGlesDriver =
- mSystemProperties.get(PROPERTY_PERSISTENT_GRAPHICS_EGL, "");
- final boolean isAngle = TextUtils.equals(ANGLE_DRIVER_SUFFIX, currentGlesDriver);
- ((SwitchPreference) mPreference).setChecked(isAngle);
- } else {
- mPreference.setEnabled(false);
- ((SwitchPreference) mPreference).setChecked(false);
- }
+ // set switch on if "persist.graphics.egl" is "angle".
+ final String currentGlesDriver =
+ mSystemProperties.get(PROPERTY_PERSISTENT_GRAPHICS_EGL, "");
+ final boolean isAngle = TextUtils.equals(ANGLE_DRIVER_SUFFIX, currentGlesDriver);
+ ((SwitchPreference) mPreference).setChecked(isAngle);
// Disable the developer option toggle UI if ANGLE is disabled, this means next time the
// debug property needs to be set to true again to enable ANGLE. If ANGLE is enabled, don't
@@ -182,12 +164,10 @@
protected void onDeveloperOptionsSwitchDisabled() {
// 1) disable the switch
super.onDeveloperOptionsSwitchDisabled();
- if (isAngleSupported()) {
- // 2) set the persist.graphics.egl empty string
- GraphicsEnvironment.getInstance().toggleAngleAsSystemDriver(false);
- // 3) reset the switch
- ((SwitchPreference) mPreference).setChecked(false);
- }
+ // 2) set the persist.graphics.egl empty string
+ GraphicsEnvironment.getInstance().toggleAngleAsSystemDriver(false);
+ // 3) reset the switch
+ ((SwitchPreference) mPreference).setChecked(false);
}
void toggleSwitchBack() {
diff --git a/src/com/android/settings/inputmethod/SpellCheckerPreference.java b/src/com/android/settings/inputmethod/SpellCheckerPreference.java
index 116f1c7..8c8942a 100644
--- a/src/com/android/settings/inputmethod/SpellCheckerPreference.java
+++ b/src/com/android/settings/inputmethod/SpellCheckerPreference.java
@@ -47,6 +47,9 @@
super(context, null);
mScis = scis;
setWidgetLayoutResource(R.layout.preference_widget_gear);
+ if (scis == null) {
+ return;
+ }
CharSequence[] labels = new CharSequence[scis.length];
CharSequence[] values = new CharSequence[scis.length];
for (int i = 0 ; i < scis.length; i++) {
diff --git a/src/com/android/settings/inputmethod/SpellCheckersSettings.java b/src/com/android/settings/inputmethod/SpellCheckersSettings.java
index 99f7a4e..fcba473 100644
--- a/src/com/android/settings/inputmethod/SpellCheckersSettings.java
+++ b/src/com/android/settings/inputmethod/SpellCheckersSettings.java
@@ -133,6 +133,7 @@
if (preference instanceof SpellCheckerPreference) {
final SpellCheckerPreference pref = (SpellCheckerPreference) preference;
pref.setSelected(mCurrentSci);
+ pref.setEnabled(mEnabledScis != null);
}
}
mSpellCheckerLanaguagePref.setEnabled(isSpellCheckerEnabled && mCurrentSci != null);
diff --git a/src/com/android/settings/network/MobileNetworkRepository.java b/src/com/android/settings/network/MobileNetworkRepository.java
index 7d88821..1e6e782 100644
--- a/src/com/android/settings/network/MobileNetworkRepository.java
+++ b/src/com/android/settings/network/MobileNetworkRepository.java
@@ -225,6 +225,9 @@
createTelephonyManagerBySubId(subId);
mDataRoamingObserver.register(mContext, subId);
}
+ // When one client registers callback first time, convey the cached results to the client
+ // so that the client is aware of the content therein.
+ sendAvailableSubInfoCache(mobileNetworkCallback);
}
public void addRegisterBySubId(int subId) {
@@ -415,7 +418,15 @@
private void onAvailableSubInfoChanged(
List<SubscriptionInfoEntity> availableSubInfoEntityList) {
- mAvailableSubInfoEntityList = new ArrayList<>(availableSubInfoEntityList);
+ synchronized (this) {
+ if (mAvailableSubInfoEntityList != null
+ && mAvailableSubInfoEntityList.size() == availableSubInfoEntityList.size()
+ && mAvailableSubInfoEntityList.containsAll(availableSubInfoEntityList)) {
+ Log.d(TAG, "onAvailableSubInfoChanged, duplicates = " + availableSubInfoEntityList);
+ return;
+ }
+ mAvailableSubInfoEntityList = new ArrayList<>(availableSubInfoEntityList);
+ }
if (DEBUG) {
Log.d(TAG, "onAvailableSubInfoChanged, availableSubInfoEntityList = "
+ availableSubInfoEntityList);
@@ -425,23 +436,48 @@
}
mMetricsFeatureProvider.action(mContext,
SettingsEnums.ACTION_MOBILE_NETWORK_DB_NOTIFY_SUB_INFO_IS_CHANGED, 0);
- onActiveSubInfoListChanged(mAvailableSubInfoEntityList);
+ onActiveSubInfoListChanged(availableSubInfoEntityList);
}
private void onActiveSubInfoListChanged(
List<SubscriptionInfoEntity> availableSubInfoEntityList) {
- mActiveSubInfoEntityList = availableSubInfoEntityList.stream()
+ List<SubscriptionInfoEntity> activeSubInfoEntityList =
+ availableSubInfoEntityList.stream()
.filter(SubscriptionInfoEntity::isActiveSubscription)
.filter(SubscriptionInfoEntity::isSubscriptionVisible)
.collect(Collectors.toList());
if (DEBUG) {
Log.d(TAG, "onActiveSubInfoChanged, activeSubInfoEntityList = "
- + mActiveSubInfoEntityList);
+ + activeSubInfoEntityList);
}
- List<SubscriptionInfoEntity> activeSubInfoEntityList = new ArrayList<>(
- mActiveSubInfoEntityList);
+ List<SubscriptionInfoEntity> tempActiveSubInfoEntityList = new ArrayList<>(
+ activeSubInfoEntityList);
+ synchronized (this) {
+ mActiveSubInfoEntityList = activeSubInfoEntityList;
+ }
for (MobileNetworkCallback callback : sCallbacks) {
- callback.onActiveSubInfoChanged(activeSubInfoEntityList);
+ callback.onActiveSubInfoChanged(tempActiveSubInfoEntityList);
+ }
+ }
+
+ private void sendAvailableSubInfoCache(MobileNetworkCallback callback) {
+ if (callback != null) {
+ List<SubscriptionInfoEntity> availableSubInfoEntityList = null;
+ List<SubscriptionInfoEntity> activeSubInfoEntityList = null;
+ synchronized (this) {
+ if (mAvailableSubInfoEntityList != null) {
+ availableSubInfoEntityList = new ArrayList<>(mAvailableSubInfoEntityList);
+ }
+ if (mActiveSubInfoEntityList != null) {
+ activeSubInfoEntityList = new ArrayList<>(mActiveSubInfoEntityList);
+ }
+ }
+ if (availableSubInfoEntityList != null) {
+ callback.onAvailableSubInfoChanged(availableSubInfoEntityList);
+ }
+ if (activeSubInfoEntityList != null) {
+ callback.onActiveSubInfoChanged(activeSubInfoEntityList);
+ }
}
}
@@ -497,8 +533,6 @@
mMobileNetworkDatabase.deleteSubInfoBySubId(subId);
mMobileNetworkDatabase.deleteUiccInfoBySubId(subId);
mMobileNetworkDatabase.deleteMobileNetworkInfoBySubId(subId);
- mAvailableSubInfoEntityList.removeIf(info -> info.subId.equals(subId));
- mActiveSubInfoEntityList.removeIf(info -> info.subId.equals(subId));
mUiccInfoEntityList.removeIf(info -> info.subId.equals(subId));
mMobileNetworkInfoEntityList.removeIf(info -> info.subId.equals(subId));
int id = Integer.parseInt(subId);
@@ -655,10 +689,15 @@
private void insertAvailableSubInfoToEntity(List<SubscriptionInfo> inputAvailableInfoList) {
sExecutor.execute(() -> {
- SubscriptionInfoEntity[] availableInfoArray = mAvailableSubInfoEntityList.toArray(
+ SubscriptionInfoEntity[] availableInfoArray = null;
+ int availableEntitySize = 0;
+ synchronized (this) {
+ availableInfoArray = mAvailableSubInfoEntityList.toArray(
new SubscriptionInfoEntity[0]);
+ availableEntitySize = mAvailableSubInfoEntityList.size();
+ }
if ((inputAvailableInfoList == null || inputAvailableInfoList.size() == 0)
- && mAvailableSubInfoEntityList.size() != 0) {
+ && availableEntitySize != 0) {
if (DEBUG) {
Log.d(TAG, "availableSudInfoList from framework is empty, remove all subs");
}
@@ -671,7 +710,7 @@
SubscriptionInfo[] inputAvailableInfoArray = inputAvailableInfoList.toArray(
new SubscriptionInfo[0]);
// Remove the redundant subInfo
- if (inputAvailableInfoList.size() <= mAvailableSubInfoEntityList.size()) {
+ if (inputAvailableInfoList.size() <= availableEntitySize) {
for (SubscriptionInfo subInfo : inputAvailableInfoArray) {
int subId = subInfo.getSubscriptionId();
if (mSubscriptionInfoMap.containsKey(subId)) {
@@ -685,7 +724,7 @@
deleteAllInfoBySubId(String.valueOf(key));
}
}
- } else if (inputAvailableInfoList.size() < mAvailableSubInfoEntityList.size()) {
+ } else if (inputAvailableInfoList.size() < availableEntitySize) {
// Check the subInfo between the new list from framework and old list in
// the database, if the subInfo is not existed in the new list, delete it
// from the database.
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index 28e02ec..7d31632 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -1719,6 +1719,9 @@
public List<SearchIndexableRaw> getRawDataToIndex(Context context,
boolean enabled) {
final List<SearchIndexableRaw> rawData = new ArrayList<>();
+ if (!UserManager.supportsMultipleUsers()) {
+ return rawData;
+ }
SearchIndexableRaw allowMultipleUsersResult = new SearchIndexableRaw(context);
diff --git a/src/com/android/settings/vpn2/ConfigDialog.java b/src/com/android/settings/vpn2/ConfigDialog.java
index 036487d..1c001cb 100644
--- a/src/com/android/settings/vpn2/ConfigDialog.java
+++ b/src/com/android/settings/vpn2/ConfigDialog.java
@@ -16,8 +16,6 @@
package com.android.settings.vpn2;
-import static com.android.internal.net.VpnProfile.isLegacyType;
-
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
@@ -43,9 +41,6 @@
import com.android.settings.R;
import com.android.settings.utils.AndroidKeystoreAliasLoader;
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.List;
@@ -60,13 +55,18 @@
View.OnClickListener, AdapterView.OnItemSelectedListener,
CompoundButton.OnCheckedChangeListener {
private static final String TAG = "ConfigDialog";
+ // Vpn profile constants to match with R.array.vpn_types.
+ private static final List<Integer> VPN_TYPES = List.of(
+ VpnProfile.TYPE_IKEV2_IPSEC_USER_PASS,
+ VpnProfile.TYPE_IKEV2_IPSEC_PSK,
+ VpnProfile.TYPE_IKEV2_IPSEC_RSA
+ );
+
private final DialogInterface.OnClickListener mListener;
private final VpnProfile mProfile;
private boolean mEditing;
private boolean mExists;
- private List<String> mTotalTypes;
- private List<String> mAllowedTypes;
private View mView;
@@ -75,14 +75,9 @@
private TextView mServer;
private TextView mUsername;
private TextView mPassword;
- private TextView mSearchDomains;
- private TextView mDnsServers;
- private TextView mRoutes;
private Spinner mProxySettings;
private TextView mProxyHost;
private TextView mProxyPort;
- private CheckBox mMppe;
- private TextView mL2tpSecret;
private TextView mIpsecIdentifier;
private TextView mIpsecSecret;
private Spinner mIpsecUserCert;
@@ -116,14 +111,9 @@
mServer = (TextView) mView.findViewById(R.id.server);
mUsername = (TextView) mView.findViewById(R.id.username);
mPassword = (TextView) mView.findViewById(R.id.password);
- mSearchDomains = (TextView) mView.findViewById(R.id.search_domains);
- mDnsServers = (TextView) mView.findViewById(R.id.dns_servers);
- mRoutes = (TextView) mView.findViewById(R.id.routes);
mProxySettings = (Spinner) mView.findViewById(R.id.vpn_proxy_settings);
mProxyHost = (TextView) mView.findViewById(R.id.vpn_proxy_host);
mProxyPort = (TextView) mView.findViewById(R.id.vpn_proxy_port);
- mMppe = (CheckBox) mView.findViewById(R.id.mppe);
- mL2tpSecret = (TextView) mView.findViewById(R.id.l2tp_secret);
mIpsecIdentifier = (TextView) mView.findViewById(R.id.ipsec_identifier);
mIpsecSecret = (TextView) mView.findViewById(R.id.ipsec_secret);
mIpsecUserCert = (Spinner) mView.findViewById(R.id.ipsec_user_cert);
@@ -137,29 +127,17 @@
// Second, copy values from the profile.
mName.setText(mProfile.name);
setTypesByFeature(mType);
- // Not all types will be available to the user. Find the index corresponding to the
- // string of the profile's type.
- if (mAllowedTypes != null && mTotalTypes != null) {
- mType.setSelection(mAllowedTypes.indexOf(mTotalTypes.get(mProfile.type)));
- } else {
- Log.w(TAG, "Allowed or Total vpn types not initialized when setting initial selection");
- }
+ mType.setSelection(convertVpnProfileConstantToTypeIndex(mProfile.type));
mServer.setText(mProfile.server);
if (mProfile.saveLogin) {
mUsername.setText(mProfile.username);
mPassword.setText(mProfile.password);
}
- mSearchDomains.setText(mProfile.searchDomains);
- mDnsServers.setText(mProfile.dnsServers);
- mRoutes.setText(mProfile.routes);
if (mProfile.proxy != null) {
mProxyHost.setText(mProfile.proxy.getHost());
int port = mProfile.proxy.getPort();
mProxyPort.setText(port == 0 ? "" : Integer.toString(port));
}
- mMppe.setChecked(mProfile.mppe);
- mL2tpSecret.setText(mProfile.l2tpSecret);
- mL2tpSecret.setTextAppearance(android.R.style.TextAppearance_DeviceDefault_Medium);
mIpsecIdentifier.setText(mProfile.ipsecIdentifier);
mIpsecSecret.setText(mProfile.ipsecSecret);
final AndroidKeystoreAliasLoader androidKeystoreAliasLoader =
@@ -185,8 +163,6 @@
mServer.addTextChangedListener(this);
mUsername.addTextChangedListener(this);
mPassword.addTextChangedListener(this);
- mDnsServers.addTextChangedListener(this);
- mRoutes.addTextChangedListener(this);
mProxySettings.setOnItemSelectedListener(this);
mProxyHost.addTextChangedListener(this);
mProxyPort.addTextChangedListener(this);
@@ -217,12 +193,6 @@
// Create a button to forget the profile if it has already been saved..
setButton(DialogInterface.BUTTON_NEUTRAL,
context.getString(R.string.vpn_forget), mListener);
-
- // Display warning subtitle if the existing VPN is an insecure type...
- if (VpnProfile.isLegacyType(mProfile.type)) {
- TextView subtitle = mView.findViewById(R.id.dialog_alert_subtitle);
- subtitle.setVisibility(View.VISIBLE);
- }
}
// Create a button to save the profile.
@@ -285,10 +255,7 @@
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (parent == mType) {
- // Because the spinner may not display all available types,
- // convert the selected position into the actual vpn profile type integer.
- final int profileType = convertAllowedIndexToProfileType(position);
- changeType(profileType);
+ changeType(VPN_TYPES.get(position));
} else if (parent == mProxySettings) {
updateProxyFieldsVisibility(position);
}
@@ -330,17 +297,7 @@
} else {
mAlwaysOnVpn.setChecked(false);
mAlwaysOnVpn.setEnabled(false);
- if (!profile.isTypeValidForLockdown()) {
- mAlwaysOnInvalidReason.setText(R.string.vpn_always_on_invalid_reason_type);
- } else if (isLegacyType(profile.type) && !profile.isServerAddressNumeric()) {
- mAlwaysOnInvalidReason.setText(R.string.vpn_always_on_invalid_reason_server);
- } else if (isLegacyType(profile.type) && !profile.hasDns()) {
- mAlwaysOnInvalidReason.setText(R.string.vpn_always_on_invalid_reason_no_dns);
- } else if (isLegacyType(profile.type) && !profile.areDnsAddressesNumeric()) {
- mAlwaysOnInvalidReason.setText(R.string.vpn_always_on_invalid_reason_dns);
- } else {
- mAlwaysOnInvalidReason.setText(R.string.vpn_always_on_invalid_reason_other);
- }
+ mAlwaysOnInvalidReason.setText(R.string.vpn_always_on_invalid_reason_other);
mAlwaysOnInvalidReason.setVisibility(View.VISIBLE);
}
@@ -370,21 +327,14 @@
}
private boolean isAdvancedOptionsEnabled() {
- return mSearchDomains.getText().length() > 0 || mDnsServers.getText().length() > 0 ||
- mRoutes.getText().length() > 0 || mProxyHost.getText().length() > 0
- || mProxyPort.getText().length() > 0;
+ return mProxyHost.getText().length() > 0 || mProxyPort.getText().length() > 0;
}
private void configureAdvancedOptionsVisibility() {
if (mShowOptions.isChecked() || isAdvancedOptionsEnabled()) {
mView.findViewById(R.id.options).setVisibility(View.VISIBLE);
mShowOptions.setVisibility(View.GONE);
-
- // Configure networking option visibility
// TODO(b/149070123): Add ability for platform VPNs to support DNS & routes
- final int visibility =
- isLegacyType(getSelectedVpnType()) ? View.VISIBLE : View.GONE;
- mView.findViewById(R.id.network_options).setVisibility(visibility);
} else {
mView.findViewById(R.id.options).setVisibility(View.GONE);
mShowOptions.setVisibility(View.VISIBLE);
@@ -393,8 +343,6 @@
private void changeType(int type) {
// First, hide everything.
- mMppe.setVisibility(View.GONE);
- mView.findViewById(R.id.l2tp).setVisibility(View.GONE);
mView.findViewById(R.id.ipsec_psk).setVisibility(View.GONE);
mView.findViewById(R.id.ipsec_user).setVisibility(View.GONE);
mView.findViewById(R.id.ipsec_peer).setVisibility(View.GONE);
@@ -403,34 +351,18 @@
setUsernamePasswordVisibility(type);
// Always enable identity for IKEv2/IPsec profiles.
- if (!isLegacyType(type)) {
- mView.findViewById(R.id.options_ipsec_identity).setVisibility(View.VISIBLE);
- }
+ mView.findViewById(R.id.options_ipsec_identity).setVisibility(View.VISIBLE);
// Then, unhide type-specific fields.
switch (type) {
- case VpnProfile.TYPE_PPTP:
- mMppe.setVisibility(View.VISIBLE);
- break;
-
- case VpnProfile.TYPE_L2TP_IPSEC_PSK:
- mView.findViewById(R.id.l2tp).setVisibility(View.VISIBLE);
- // fall through
- case VpnProfile.TYPE_IKEV2_IPSEC_PSK: // fall through
- case VpnProfile.TYPE_IPSEC_XAUTH_PSK:
+ case VpnProfile.TYPE_IKEV2_IPSEC_PSK:
mView.findViewById(R.id.ipsec_psk).setVisibility(View.VISIBLE);
mView.findViewById(R.id.options_ipsec_identity).setVisibility(View.VISIBLE);
break;
-
- case VpnProfile.TYPE_L2TP_IPSEC_RSA:
- mView.findViewById(R.id.l2tp).setVisibility(View.VISIBLE);
- // fall through
- case VpnProfile.TYPE_IKEV2_IPSEC_RSA: // fall through
- case VpnProfile.TYPE_IPSEC_XAUTH_RSA:
+ case VpnProfile.TYPE_IKEV2_IPSEC_RSA:
mView.findViewById(R.id.ipsec_user).setVisibility(View.VISIBLE);
// fall through
- case VpnProfile.TYPE_IKEV2_IPSEC_USER_PASS: // fall through
- case VpnProfile.TYPE_IPSEC_HYBRID_RSA:
+ case VpnProfile.TYPE_IKEV2_IPSEC_USER_PASS:
mView.findViewById(R.id.ipsec_peer).setVisibility(View.VISIBLE);
break;
}
@@ -443,7 +375,8 @@
return false;
}
- final int type = getSelectedVpnType();
+ final int position = mType.getSelectedItemPosition();
+ final int type = VPN_TYPES.get(position);
if (!editing && requiresUsernamePassword(type)) {
return mUsername.getText().length() != 0 && mPassword.getText().length() != 0;
}
@@ -451,15 +384,8 @@
return false;
}
- // TODO(b/149070123): Add ability for platform VPNs to support DNS & routes
- if (isLegacyType(mProfile.type)
- && (!validateAddresses(mDnsServers.getText().toString(), false)
- || !validateAddresses(mRoutes.getText().toString(), true))) {
- return false;
- }
-
// All IKEv2 methods require an identifier
- if (!isLegacyType(mProfile.type) && mIpsecIdentifier.getText().length() == 0) {
+ if (mIpsecIdentifier.getText().length() == 0) {
return false;
}
@@ -468,56 +394,23 @@
}
switch (type) {
- case VpnProfile.TYPE_PPTP: // fall through
- case VpnProfile.TYPE_IPSEC_HYBRID_RSA: // fall through
case VpnProfile.TYPE_IKEV2_IPSEC_USER_PASS:
return true;
- case VpnProfile.TYPE_IKEV2_IPSEC_PSK: // fall through
- case VpnProfile.TYPE_L2TP_IPSEC_PSK: // fall through
- case VpnProfile.TYPE_IPSEC_XAUTH_PSK:
+ case VpnProfile.TYPE_IKEV2_IPSEC_PSK:
return mIpsecSecret.getText().length() != 0;
- case VpnProfile.TYPE_IKEV2_IPSEC_RSA: // fall through
- case VpnProfile.TYPE_L2TP_IPSEC_RSA: // fall through
- case VpnProfile.TYPE_IPSEC_XAUTH_RSA:
+ case VpnProfile.TYPE_IKEV2_IPSEC_RSA:
return mIpsecUserCert.getSelectedItemPosition() != 0;
}
return false;
}
- private boolean validateAddresses(String addresses, boolean cidr) {
- try {
- for (String address : addresses.split(" ")) {
- if (address.isEmpty()) {
- continue;
- }
- // Legacy VPN currently only supports IPv4.
- int prefixLength = 32;
- if (cidr) {
- String[] parts = address.split("/", 2);
- address = parts[0];
- prefixLength = Integer.parseInt(parts[1]);
- }
- byte[] bytes = InetAddress.parseNumericAddress(address).getAddress();
- int integer = (bytes[3] & 0xFF) | (bytes[2] & 0xFF) << 8 |
- (bytes[1] & 0xFF) << 16 | (bytes[0] & 0xFF) << 24;
- if (bytes.length != 4 || prefixLength < 0 || prefixLength > 32 ||
- (prefixLength < 32 && (integer << prefixLength) != 0)) {
- return false;
- }
- }
- } catch (Exception e) {
- return false;
- }
- return true;
- }
-
private void setTypesByFeature(Spinner typeSpinner) {
String[] types = getContext().getResources().getStringArray(R.array.vpn_types);
- mTotalTypes = new ArrayList<>(Arrays.asList(types));
- mAllowedTypes = new ArrayList<>(Arrays.asList(types));
-
+ if (types.length != VPN_TYPES.size()) {
+ Log.wtf(TAG, "VPN_TYPES array length does not match string array");
+ }
// Although FEATURE_IPSEC_TUNNELS should always be present in android S and beyond,
// keep this check here just to be safe.
if (!getContext().getPackageManager().hasSystemFeature(
@@ -532,17 +425,6 @@
mProfile.type = VpnProfile.TYPE_IKEV2_IPSEC_USER_PASS;
}
- // Remove all types which are legacy types from the typesList
- if (!VpnProfile.isLegacyType(mProfile.type)) {
- for (int i = mAllowedTypes.size() - 1; i >= 0; i--) {
- // This must be removed from back to front in order to ensure index consistency
- if (VpnProfile.isLegacyType(i)) {
- mAllowedTypes.remove(i);
- }
- }
-
- types = mAllowedTypes.toArray(new String[0]);
- }
final ArrayAdapter<String> adapter = new ArrayAdapter<String>(
getContext(), android.R.layout.simple_spinner_item, types);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
@@ -606,20 +488,14 @@
// First, save common fields.
VpnProfile profile = new VpnProfile(mProfile.key);
profile.name = mName.getText().toString();
- profile.type = getSelectedVpnType();
+ final int position = mType.getSelectedItemPosition();
+ profile.type = VPN_TYPES.get(position);
profile.server = mServer.getText().toString().trim();
profile.username = mUsername.getText().toString();
profile.password = mPassword.getText().toString();
// Save fields based on VPN type.
- if (isLegacyType(profile.type)) {
- // TODO(b/149070123): Add ability for platform VPNs to support DNS & routes
- profile.searchDomains = mSearchDomains.getText().toString().trim();
- profile.dnsServers = mDnsServers.getText().toString().trim();
- profile.routes = mRoutes.getText().toString().trim();
- } else {
- profile.ipsecIdentifier = mIpsecIdentifier.getText().toString();
- }
+ profile.ipsecIdentifier = mIpsecIdentifier.getText().toString();
if (hasProxy()) {
String proxyHost = mProxyHost.getText().toString().trim();
@@ -640,34 +516,17 @@
}
// Then, save type-specific fields.
switch (profile.type) {
- case VpnProfile.TYPE_PPTP:
- profile.mppe = mMppe.isChecked();
- break;
-
- case VpnProfile.TYPE_L2TP_IPSEC_PSK:
- profile.l2tpSecret = mL2tpSecret.getText().toString();
- // fall through
- case VpnProfile.TYPE_IKEV2_IPSEC_PSK: // fall through
- case VpnProfile.TYPE_IPSEC_XAUTH_PSK:
- profile.ipsecIdentifier = mIpsecIdentifier.getText().toString();
+ case VpnProfile.TYPE_IKEV2_IPSEC_PSK:
profile.ipsecSecret = mIpsecSecret.getText().toString();
break;
case VpnProfile.TYPE_IKEV2_IPSEC_RSA:
if (mIpsecUserCert.getSelectedItemPosition() != 0) {
- profile.ipsecSecret = (String) mIpsecUserCert.getSelectedItem();
- }
- // fall through
- case VpnProfile.TYPE_L2TP_IPSEC_RSA:
- profile.l2tpSecret = mL2tpSecret.getText().toString();
- // fall through
- case VpnProfile.TYPE_IPSEC_XAUTH_RSA:
- if (mIpsecUserCert.getSelectedItemPosition() != 0) {
profile.ipsecUserCert = (String) mIpsecUserCert.getSelectedItem();
+ profile.ipsecSecret = profile.ipsecUserCert;
}
// fall through
- case VpnProfile.TYPE_IKEV2_IPSEC_USER_PASS: // fall through
- case VpnProfile.TYPE_IPSEC_HYBRID_RSA:
+ case VpnProfile.TYPE_IKEV2_IPSEC_USER_PASS:
if (mIpsecCaCert.getSelectedItemPosition() != 0) {
profile.ipsecCaCert = (String) mIpsecCaCert.getSelectedItem();
}
@@ -692,19 +551,13 @@
return ProxyUtils.validate(host, port, "") == ProxyUtils.PROXY_VALID;
}
- private int getSelectedVpnType() {
- return convertAllowedIndexToProfileType(mType.getSelectedItemPosition());
- }
-
- private int convertAllowedIndexToProfileType(int allowedSelectedPosition) {
- if (mAllowedTypes != null && mTotalTypes != null) {
- final String typeString = mAllowedTypes.get(allowedSelectedPosition);
- final int profileType = mTotalTypes.indexOf(typeString);
- return profileType;
- } else {
- Log.w(TAG, "Allowed or Total vpn types not initialized when converting protileType");
- return allowedSelectedPosition;
+ private int convertVpnProfileConstantToTypeIndex(int vpnType) {
+ final int typeIndex = VPN_TYPES.indexOf(vpnType);
+ if (typeIndex == -1) {
+ // Existing legacy profile type
+ Log.wtf(TAG, "Invalid existing profile type");
+ return 0;
}
+ return typeIndex;
}
-
}
diff --git a/src/com/android/settings/wfd/WifiDisplaySettings.java b/src/com/android/settings/wfd/WifiDisplaySettings.java
index 8562e5f..cb515e3 100755
--- a/src/com/android/settings/wfd/WifiDisplaySettings.java
+++ b/src/com/android/settings/wfd/WifiDisplaySettings.java
@@ -139,7 +139,6 @@
mWifiP2pChannel = mWifiP2pManager.initialize(context, Looper.getMainLooper(), null);
addPreferencesFromResource(R.xml.wifi_display_settings);
- setHasOptionsMenu(true);
}
@Override
@@ -196,8 +195,9 @@
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- if (mWifiDisplayStatus != null && mWifiDisplayStatus.getFeatureState()
- != WifiDisplayStatus.FEATURE_STATE_UNAVAILABLE) {
+ if (getResources().getBoolean(R.bool.config_show_wifi_display_enable_menu)
+ && mWifiDisplayStatus != null && mWifiDisplayStatus.getFeatureState()
+ != WifiDisplayStatus.FEATURE_STATE_UNAVAILABLE) {
MenuItem item = menu.add(Menu.NONE, MENU_ID_ENABLE_WIFI_DISPLAY, 0,
R.string.wifi_display_enable_menu_item);
item.setCheckable(true);
diff --git a/tests/robotests/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverControllerTest.java b/tests/robotests/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverControllerTest.java
index 249acf5..e069a0b 100644
--- a/tests/robotests/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverControllerTest.java
@@ -19,7 +19,6 @@
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.ANGLE_DRIVER_SUFFIX;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.PROPERTY_DEBUG_ANGLE_DEVELOPER_OPTION;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.PROPERTY_PERSISTENT_GRAPHICS_EGL;
-import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.PROPERTY_RO_GFX_ANGLE_SUPPORTED;
import static com.google.common.truth.Truth.assertThat;
@@ -79,7 +78,6 @@
@Test
public void onPreferenceChange_switchOn_shouldEnableAngleAsSystemDriver() {
- ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, "true");
// since GraphicsEnvironment is mocked in Robolectric test environment,
// we will override the system property persist.graphics.egl as if it is changed by
// mGraphicsEnvironment.toggleAngleAsSystemDriver(true).
@@ -96,7 +94,6 @@
@Test
public void onPreferenceChange_switchOff_shouldDisableAngleAsSystemDriver() {
- ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, "true");
// since GraphicsEnvironment is mocked in Robolectric test environment,
// we will override the system property persist.graphics.egl as if it is changed by
// mGraphicsEnvironment.toggleAngleAsSystemDriver(false).
@@ -112,30 +109,14 @@
}
@Test
- public void updateState_angleNotSupported_preferenceShouldNotBeChecked() {
- ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, "");
- mController.updateState(mPreference);
- verify(mPreference).setChecked(false);
- }
-
- @Test
- public void updateState_angleNotSupported_preferenceShouldNotBeEnabled() {
- ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, "");
- mController.updateState(mPreference);
- verify(mPreference).setEnabled(false);
- }
-
- @Test
- public void updateState_angleSupported_angleUsed_preferenceShouldBeChecked() {
- ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, "true");
+ public void updateState_angleUsed_preferenceShouldBeChecked() {
ShadowSystemProperties.override(PROPERTY_PERSISTENT_GRAPHICS_EGL, ANGLE_DRIVER_SUFFIX);
mController.updateState(mPreference);
verify(mPreference).setChecked(true);
}
@Test
- public void updateState_angleSupported_angleNotUsed_preferenceShouldNotBeChecked() {
- ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, "true");
+ public void updateState_angleNotUsed_preferenceShouldNotBeChecked() {
ShadowSystemProperties.override(PROPERTY_PERSISTENT_GRAPHICS_EGL, "");
mController.updateState(mPreference);
verify(mPreference).setChecked(false);
@@ -143,7 +124,6 @@
@Test
public void onDeveloperOptionSwitchDisabled_shouldDisableAngleAsSystemDriver() {
- ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, "true");
mController.onDeveloperOptionsSwitchDisabled();
final String systemEGLDriver = SystemProperties.get(PROPERTY_PERSISTENT_GRAPHICS_EGL);
assertThat(systemEGLDriver).isEqualTo("");
@@ -151,14 +131,12 @@
@Test
public void onDeveloperOptionSwitchDisabled_preferenceShouldNotBeChecked() {
- ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, "true");
mController.onDeveloperOptionsSwitchDisabled();
verify(mPreference).setChecked(false);
}
@Test
public void onDeveloperOptionsSwitchDisabled_preferenceShouldNotBeEnabled() {
- ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, "true");
mController.onDeveloperOptionsSwitchDisabled();
verify(mPreference).setEnabled(false);
}
diff --git a/tests/unit/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest.java b/tests/unit/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest.java
index a402d91..8304e5d 100644
--- a/tests/unit/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest.java
+++ b/tests/unit/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest.java
@@ -20,7 +20,6 @@
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.Injector;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.PROPERTY_DEBUG_ANGLE_DEVELOPER_OPTION;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.PROPERTY_PERSISTENT_GRAPHICS_EGL;
-import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.PROPERTY_RO_GFX_ANGLE_SUPPORTED;
import static com.google.common.truth.Truth.assertThat;
@@ -181,31 +180,13 @@
}
@Test
- public void updateState_angleNotSupported_PreferenceShouldDisabled() {
- when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any())).thenReturn("");
- mController.updateState(mPreference);
- assertThat(mPreference.isEnabled()).isFalse();
- }
-
- @Test
- public void updateState_angleNotSupported_PreferenceShouldNotBeChecked() {
- when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any())).thenReturn("");
- mController.updateState(mPreference);
- assertThat(mPreference.isChecked()).isFalse();
- }
-
- @Test
- public void updateState_angleSupported_PreferenceShouldEnabled() {
- when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any()))
- .thenReturn("true");
+ public void updateState_PreferenceShouldEnabled() {
mController.updateState(mPreference);
assertThat(mPreference.isEnabled()).isTrue();
}
@Test
- public void updateState_angleSupported_angleIsSystemGLESDriver_PreferenceShouldBeChecked() {
- when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any()))
- .thenReturn("true");
+ public void updateState_angleIsSystemGLESDriver_PreferenceShouldBeChecked() {
when(mSystemPropertiesMock.get(eq(PROPERTY_PERSISTENT_GRAPHICS_EGL), any()))
.thenReturn(ANGLE_DRIVER_SUFFIX);
mController.updateState(mPreference);
@@ -213,10 +194,7 @@
}
@Test
- public void
- updateState_angleSupported_angleIsNotSystemGLESDriver_PreferenceShouldNotBeChecked() {
- when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any()))
- .thenReturn("true");
+ public void updateState_angleIsNotSystemGLESDriver_PreferenceShouldNotBeChecked() {
when(mSystemPropertiesMock.get(eq(PROPERTY_PERSISTENT_GRAPHICS_EGL), any())).thenReturn("");
mController.updateState(mPreference);
assertThat(mPreference.isChecked()).isFalse();
@@ -232,8 +210,6 @@
// Test that onDeveloperOptionSwitchDisabled,
// persist.graphics.egl updates to ""
- when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any()))
- .thenReturn("true");
mController.onDeveloperOptionsSwitchDisabled();
propertyChangeSignal1.wait(100);
final String systemEGLDriver = SystemProperties.get(PROPERTY_PERSISTENT_GRAPHICS_EGL);
@@ -245,16 +221,12 @@
@Test
public void onDeveloperOptionSwitchDisabled_PreferenceShouldNotBeChecked() {
- when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any()))
- .thenReturn("true");
mController.onDeveloperOptionsSwitchDisabled();
assertThat(mPreference.isChecked()).isFalse();
}
@Test
public void onDeveloperOptionSwitchDisabled_PreferenceShouldDisabled() {
- when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any()))
- .thenReturn("true");
mController.onDeveloperOptionsSwitchDisabled();
assertThat(mPreference.isEnabled()).isFalse();
}
@@ -480,8 +452,6 @@
// Test that when debug.graphics.angle.developeroption.enable is false:
when(mSystemPropertiesMock.getBoolean(eq(PROPERTY_DEBUG_ANGLE_DEVELOPER_OPTION),
anyBoolean())).thenReturn(false);
- when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any()))
- .thenReturn("true");
// 1. "Enable ANGLE" switch is on, the switch should be enabled.
when(mSystemPropertiesMock.get(eq(PROPERTY_PERSISTENT_GRAPHICS_EGL), any()))