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

Commit c8cf19d4 authored by Hani Kazmi's avatar Hani Kazmi
Browse files

[AAPM] Add WEP FeatureId for getFeatures

Bug: 398828398
Test: atest DisallowWepTest
Flag: android.security.aapm_api
Change-Id: If72bfa986216ce02ec27b76c1340f3ba9aadf154
parent 7472a4ca
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -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;
@@ -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
@@ -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++) {
@@ -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());
            });
        });
+3 −1
Original line number Diff line number Diff line
@@ -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;
@@ -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);
}
+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();
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -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);
            }
        };
@@ -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);
            }
        };