Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 4faba0b7 authored by Kevin F. Haggerty's avatar Kevin F. Haggerty
Browse files

Merge tag 'android-security-13.0.0_r16' into staging/lineage-20.0_android-security-13.0.0_r16

Android Security 13.0.0 Release 16 (11422632)

* tag 'android-security-13.0.0_r16':
  [RESTRICT AUTOMERGE] Restrict WifiDialogActivity

Conflicts:
	src/com/android/settings/wifi/WifiDialogActivity.java
	tests/robotests/src/com/android/settings/wifi/WifiDialogActivityTest.java

Change-Id: I1a09fbdc1c92ec0112df350a5053c70984d05f15
parents fe01b2f5 76f5427d
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.settings.wifi;

import static android.Manifest.permission.ACCESS_FINE_LOCATION;
import static android.os.UserManager.DISALLOW_ADD_WIFI_CONFIG;
import static android.os.UserManager.DISALLOW_CONFIG_WIFI;

import android.app.KeyguardManager;
@@ -122,7 +123,7 @@ public class WifiDialogActivity extends ObservableActivity implements WifiDialog
        }

        super.onCreate(savedInstanceState);
        if (!isConfigWifiAllowed()) {
        if (!isConfigWifiAllowed() || !isAddWifiConfigAllowed()) {
            finish();
            return;
        }
@@ -393,6 +394,16 @@ public class WifiDialogActivity extends ObservableActivity implements WifiDialog
        return isConfigWifiAllowed;
    }

    @VisibleForTesting
    boolean isAddWifiConfigAllowed() {
        UserManager userManager = getSystemService(UserManager.class);
        if (userManager != null && userManager.hasUserRestriction(DISALLOW_ADD_WIFI_CONFIG)) {
            Log.e(TAG, "The user is not allowed to add Wi-Fi configuration.");
            return false;
        }
        return true;
    }

    private boolean hasWifiManager() {
        if (mWifiManager != null) return true;
        mWifiManager = getSystemService(WifiManager.class);
+15 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.settings.wifi;

import static android.Manifest.permission.ACCESS_COARSE_LOCATION;
import static android.Manifest.permission.ACCESS_FINE_LOCATION;
import static android.os.UserManager.DISALLOW_ADD_WIFI_CONFIG;
import static android.os.UserManager.DISALLOW_CONFIG_WIFI;

import static com.android.settings.wifi.WifiDialogActivity.REQUEST_CODE_WIFI_DPP_ENROLLEE_QR_CODE_SCANNER;
@@ -234,6 +235,20 @@ public class WifiDialogActivityTest {
        assertThat(mActivity.isConfigWifiAllowed()).isFalse();
    }

    @Test
    public void isAddWifiConfigAllowed_hasNoUserRestriction_returnTrue() {
        when(mUserManager.hasUserRestriction(DISALLOW_ADD_WIFI_CONFIG)).thenReturn(false);

        assertThat(mActivity.isAddWifiConfigAllowed()).isTrue();
    }

    @Test
    public void isAddWifiConfigAllowed_hasUserRestriction_returnFalse() {
        when(mUserManager.hasUserRestriction(DISALLOW_ADD_WIFI_CONFIG)).thenReturn(true);

        assertThat(mActivity.isAddWifiConfigAllowed()).isFalse();
    }

    @Test
    public void hasPermissionForResult_noCallingPackage_returnFalse() {
        when(mActivity.getCallingPackage()).thenReturn(null);