Loading services/core/java/com/android/server/security/advancedprotection/AdvancedProtectionService.java +6 −3 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ import com.android.server.security.advancedprotection.features.DisallowCellular2 import com.android.server.security.advancedprotection.features.DisallowInstallUnknownSourcesAdvancedProtectionHook; import com.android.server.security.advancedprotection.features.MemoryTaggingExtensionHook; import com.android.server.security.advancedprotection.features.UsbDataAdvancedProtectionHook; import com.android.server.security.advancedprotection.features.DisallowWepAdvancedProtectionProvider; import java.io.File; import java.io.FileDescriptor; Loading Loading @@ -132,6 +133,8 @@ public class AdvancedProtectionService extends IAdvancedProtectionService.Stub Slog.e(TAG, "Failed to initialize UsbDataAdvancedProtection", e); } } mProviders.add(new DisallowWepAdvancedProtectionProvider()); } // Only for tests Loading Loading @@ -303,7 +306,7 @@ public class AdvancedProtectionService extends IAdvancedProtectionService.Stub getAdvancedProtectionFeatures_enforcePermission(); List<AdvancedProtectionFeature> features = new ArrayList<>(); for (int i = 0; i < mProviders.size(); i++) { features.addAll(mProviders.get(i).getFeatures()); features.addAll(mProviders.get(i).getFeatures(mContext)); } for (int i = 0; i < mHooks.size(); i++) { Loading Loading @@ -341,7 +344,7 @@ public class AdvancedProtectionService extends IAdvancedProtectionService.Stub writer.println(" Providers: "); mProviders.stream().forEach(provider -> { writer.println(" " + provider.getClass().getSimpleName()); provider.getFeatures().stream().forEach(feature -> { provider.getFeatures(mContext).stream().forEach(feature -> { writer.println(" " + feature.getClass().getSimpleName()); }); }); Loading services/core/java/com/android/server/security/advancedprotection/features/AdvancedProtectionProvider.java +3 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.server.security.advancedprotection.features; import android.annotation.NonNull; import android.content.Context; import android.security.advancedprotection.AdvancedProtectionFeature; import java.util.List; Loading @@ -23,5 +25,5 @@ import java.util.List; /** @hide */ public abstract class AdvancedProtectionProvider { /** The list of features provided */ public abstract List<AdvancedProtectionFeature> getFeatures(); public abstract List<AdvancedProtectionFeature> getFeatures(@NonNull Context context); } services/core/java/com/android/server/security/advancedprotection/features/DisallowWepAdvancedProtectionProvider.java 0 → 100644 +31 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 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 com.android.server.security.advancedprotection.features; import android.annotation.NonNull; import android.content.Context; import android.net.wifi.WifiManager; import android.security.advancedprotection.AdvancedProtectionFeature; import java.util.List; public class DisallowWepAdvancedProtectionProvider extends AdvancedProtectionProvider { public List<AdvancedProtectionFeature> getFeatures(@NonNull Context context) { WifiManager wifiManager = context.getSystemService(WifiManager.class); return wifiManager.getAvailableAdvancedProtectionFeatures(); } } services/tests/servicestests/src/com/android/server/security/advancedprotection/AdvancedProtectionServiceTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -259,7 +259,7 @@ public class AdvancedProtectionServiceTest { AdvancedProtectionProvider provider = new AdvancedProtectionProvider() { @Override public List<AdvancedProtectionFeature> getFeatures() { public List<AdvancedProtectionFeature> getFeatures(Context context) { return List.of(feature2); } }; Loading Loading @@ -291,7 +291,7 @@ public class AdvancedProtectionServiceTest { AdvancedProtectionProvider provider = new AdvancedProtectionProvider() { @Override public List<AdvancedProtectionFeature> getFeatures() { public List<AdvancedProtectionFeature> getFeatures(Context context) { return List.of(feature2); } }; Loading Loading
services/core/java/com/android/server/security/advancedprotection/AdvancedProtectionService.java +6 −3 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ import com.android.server.security.advancedprotection.features.DisallowCellular2 import com.android.server.security.advancedprotection.features.DisallowInstallUnknownSourcesAdvancedProtectionHook; import com.android.server.security.advancedprotection.features.MemoryTaggingExtensionHook; import com.android.server.security.advancedprotection.features.UsbDataAdvancedProtectionHook; import com.android.server.security.advancedprotection.features.DisallowWepAdvancedProtectionProvider; import java.io.File; import java.io.FileDescriptor; Loading Loading @@ -132,6 +133,8 @@ public class AdvancedProtectionService extends IAdvancedProtectionService.Stub Slog.e(TAG, "Failed to initialize UsbDataAdvancedProtection", e); } } mProviders.add(new DisallowWepAdvancedProtectionProvider()); } // Only for tests Loading Loading @@ -303,7 +306,7 @@ public class AdvancedProtectionService extends IAdvancedProtectionService.Stub getAdvancedProtectionFeatures_enforcePermission(); List<AdvancedProtectionFeature> features = new ArrayList<>(); for (int i = 0; i < mProviders.size(); i++) { features.addAll(mProviders.get(i).getFeatures()); features.addAll(mProviders.get(i).getFeatures(mContext)); } for (int i = 0; i < mHooks.size(); i++) { Loading Loading @@ -341,7 +344,7 @@ public class AdvancedProtectionService extends IAdvancedProtectionService.Stub writer.println(" Providers: "); mProviders.stream().forEach(provider -> { writer.println(" " + provider.getClass().getSimpleName()); provider.getFeatures().stream().forEach(feature -> { provider.getFeatures(mContext).stream().forEach(feature -> { writer.println(" " + feature.getClass().getSimpleName()); }); }); Loading
services/core/java/com/android/server/security/advancedprotection/features/AdvancedProtectionProvider.java +3 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.server.security.advancedprotection.features; import android.annotation.NonNull; import android.content.Context; import android.security.advancedprotection.AdvancedProtectionFeature; import java.util.List; Loading @@ -23,5 +25,5 @@ import java.util.List; /** @hide */ public abstract class AdvancedProtectionProvider { /** The list of features provided */ public abstract List<AdvancedProtectionFeature> getFeatures(); public abstract List<AdvancedProtectionFeature> getFeatures(@NonNull Context context); }
services/core/java/com/android/server/security/advancedprotection/features/DisallowWepAdvancedProtectionProvider.java 0 → 100644 +31 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 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 com.android.server.security.advancedprotection.features; import android.annotation.NonNull; import android.content.Context; import android.net.wifi.WifiManager; import android.security.advancedprotection.AdvancedProtectionFeature; import java.util.List; public class DisallowWepAdvancedProtectionProvider extends AdvancedProtectionProvider { public List<AdvancedProtectionFeature> getFeatures(@NonNull Context context) { WifiManager wifiManager = context.getSystemService(WifiManager.class); return wifiManager.getAvailableAdvancedProtectionFeatures(); } }
services/tests/servicestests/src/com/android/server/security/advancedprotection/AdvancedProtectionServiceTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -259,7 +259,7 @@ public class AdvancedProtectionServiceTest { AdvancedProtectionProvider provider = new AdvancedProtectionProvider() { @Override public List<AdvancedProtectionFeature> getFeatures() { public List<AdvancedProtectionFeature> getFeatures(Context context) { return List.of(feature2); } }; Loading Loading @@ -291,7 +291,7 @@ public class AdvancedProtectionServiceTest { AdvancedProtectionProvider provider = new AdvancedProtectionProvider() { @Override public List<AdvancedProtectionFeature> getFeatures() { public List<AdvancedProtectionFeature> getFeatures(Context context) { return List.of(feature2); } }; Loading