Disable always-on VPN options if an app has opted out.

The user can turn on / off always-on for individual VPN apps in
Settings > Network > VPN. Now that we're providing an opt-out of the
always-on feature for VPN apps, we should disabled the toggles if the
VPN app has an explicit opt-out.

Related unit tests are also removed as the check is now performed in the
frameworks, not in Settings.

Bug: 36650087
Test: CTS Verifier

Change-Id: I486fec14a1f8b86e7120dbdbfed3885801ab4dd7
This commit is contained in:
Charles He
2017-06-08 17:15:32 +01:00
parent 446f2d2896
commit fc1ce57b13
2 changed files with 13 additions and 44 deletions

View File

@@ -16,26 +16,26 @@
package com.android.settings.vpn2;
import static com.android.settings.vpn2.AppManagementFragment.isAlwaysOnSupportedByApp;
import static com.android.settings.vpn2.AppManagementFragment.appHasVpnPermission;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.when;
import android.app.AppOpsManager;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.os.Build;
import android.os.Process;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import android.content.Context;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
public class AppSettingsTest extends AndroidTestCase {
private static final String TAG = AppSettingsTest.class.getSimpleName();
@@ -48,23 +48,6 @@ public class AppSettingsTest extends AndroidTestCase {
when(mContext.getSystemService(eq(Context.APP_OPS_SERVICE))).thenReturn(mAppOps);
}
@SmallTest
public void testAlwaysOnVersionRestriction() {
ApplicationInfo mockApp = createMockApp();
// API 23 (MNC) = not supported
mockApp.targetSdkVersion = Build.VERSION_CODES.M;
assertFalse(isAlwaysOnSupportedByApp(mockApp));
// API 24 (NYC) = supported
mockApp.targetSdkVersion = Build.VERSION_CODES.N;
assertTrue(isAlwaysOnSupportedByApp(mockApp));
// API 25 (NYC MR1) = supported
mockApp.targetSdkVersion = Build.VERSION_CODES.N_MR1;
assertTrue(isAlwaysOnSupportedByApp(mockApp));
}
@SmallTest
public void testAppOpsRequiredToOpenFragment() {
ApplicationInfo mockApp = createMockApp();