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: Ie61c516f097f76fd2fa39ac5248c1e2dbc18b1b9
This commit is contained in:
20
core/java/android/app/admin/WifiSsidPolicy.aidl
Normal file
20
core/java/android/app/admin/WifiSsidPolicy.aidl
Normal 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;
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user