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

Commit deb79e30 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Split DPM API to check current Wi-Fi network" into tm-dev

parents 09076f0a 9287b577
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project

 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.app.admin;

parcelable WifiSsidPolicy;
 No newline at end of file
+24 −5
Original line number Diff line number Diff line
@@ -214,6 +214,7 @@ import android.app.admin.StartInstallingUpdateCallback;
import android.app.admin.SystemUpdateInfo;
import android.app.admin.SystemUpdatePolicy;
import android.app.admin.UnsafeStateException;
import android.app.admin.WifiSsidPolicy;
import android.app.backup.IBackupManager;
import android.app.compat.CompatChanges;
import android.app.role.RoleManager;
@@ -269,6 +270,7 @@ import android.net.Uri;
import android.net.VpnManager;
import android.net.metrics.IpConnectivityLog;
import android.net.wifi.WifiManager;
import android.net.wifi.WifiSsid;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
@@ -389,6 +391,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.Constructor;
import java.nio.charset.StandardCharsets;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
@@ -18514,9 +18517,21 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        );
    }
    private void validateCurrentWifiMeetsAdminRequirements() {
    private void notifyMinimumRequiredWifiSecurityLevelChanged(int level) {
        mInjector.binderWithCleanCallingIdentity(
                () -> mInjector.getWifiManager().validateCurrentWifiMeetsAdminRequirements());
                () -> mInjector.getWifiManager()
                        .notifyMinimumRequiredWifiSecurityLevelChanged(level));
    }
    private void notifyWifiSsidPolicyChanged(int policyType, List<String> ssids) {
        List<WifiSsid> wifiSsidList = new ArrayList<>();
        for (String ssid : ssids) {
            wifiSsidList.add(
                    WifiSsid.fromBytes(ssid.getBytes(StandardCharsets.UTF_8)));
        }
        WifiSsidPolicy policy = new WifiSsidPolicy(policyType, new ArraySet<>(wifiSsidList));
        mInjector.binderWithCleanCallingIdentity(
                () -> mInjector.getWifiManager().notifyWifiSsidPolicyChanged(policy));
    }
    @Override
@@ -18536,7 +18551,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                valueChanged = true;
            }
        }
        if (valueChanged) validateCurrentWifiMeetsAdminRequirements();
        if (valueChanged) notifyMinimumRequiredWifiSecurityLevelChanged(level);
    }
    @Override
@@ -18568,7 +18583,9 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
            }
            if (changed) saveSettingsLocked(caller.getUserId());
        }
        if (changed) validateCurrentWifiMeetsAdminRequirements();
        if (changed && !ssids.isEmpty()) {
            notifyWifiSsidPolicyChanged(WifiSsidPolicy.WIFI_SSID_POLICY_TYPE_ALLOWLIST, ssids);
        }
    }
    @Override
@@ -18607,7 +18624,9 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
            }
            if (changed) saveSettingsLocked(caller.getUserId());
        }
        if (changed) validateCurrentWifiMeetsAdminRequirements();
        if (changed) {
            notifyWifiSsidPolicyChanged(WifiSsidPolicy.WIFI_SSID_POLICY_TYPE_DENYLIST, ssids);
        }
    }
    @Override