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

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16998230

Change-Id: I5fe977d55fba294000ff768d9ae8318bc2c5908f
This commit is contained in:
TreeHugger Robot
2022-02-28 17:13:32 +00:00
committed by Automerger Merge Worker
2 changed files with 44 additions and 5 deletions

View File

@@ -0,0 +1,20 @@
/*
* 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;

View File

@@ -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