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

Commit 29e461a6 authored by Hani Kazmi's avatar Hani Kazmi Committed by Android (Google) Code Review
Browse files

Merge "[AAPM] Add Feature class" into main

parents fcebec5a ee6b8f7b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -39834,7 +39834,7 @@ package android.security {
package android.security.advancedprotection {
  @FlaggedApi("android.security.aapm_api") public class AdvancedProtectionManager {
  @FlaggedApi("android.security.aapm_api") public final class AdvancedProtectionManager {
    method @RequiresPermission(android.Manifest.permission.QUERY_ADVANCED_PROTECTION_MODE) public boolean isAdvancedProtectionEnabled();
    method @RequiresPermission(android.Manifest.permission.QUERY_ADVANCED_PROTECTION_MODE) public void registerAdvancedProtectionCallback(@NonNull java.util.concurrent.Executor, @NonNull android.security.advancedprotection.AdvancedProtectionManager.Callback);
    method @RequiresPermission(android.Manifest.permission.QUERY_ADVANCED_PROTECTION_MODE) public void unregisterAdvancedProtectionCallback(@NonNull android.security.advancedprotection.AdvancedProtectionManager.Callback);
+10 −1
Original line number Diff line number Diff line
@@ -12467,7 +12467,16 @@ package android.security {
package android.security.advancedprotection {
  @FlaggedApi("android.security.aapm_api") public class AdvancedProtectionManager {
  @FlaggedApi("android.security.aapm_api") public final class AdvancedProtectionFeature implements android.os.Parcelable {
    ctor public AdvancedProtectionFeature(@NonNull String);
    method public int describeContents();
    method @NonNull public String getId();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.security.advancedprotection.AdvancedProtectionFeature> CREATOR;
  }
  @FlaggedApi("android.security.aapm_api") public final class AdvancedProtectionManager {
    method @NonNull @RequiresPermission(android.Manifest.permission.SET_ADVANCED_PROTECTION_MODE) public java.util.List<android.security.advancedprotection.AdvancedProtectionFeature> getAdvancedProtectionFeatures();
    method @RequiresPermission(android.Manifest.permission.SET_ADVANCED_PROTECTION_MODE) public void setAdvancedProtectionEnabled(boolean);
  }
+23 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.security.advancedprotection;

/**
 * Represents an advanced protection feature providing protections
 * @hide
 */
parcelable AdvancedProtectionFeature;
 No newline at end of file
+77 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.security.advancedprotection;

import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
import android.security.Flags;

/**
 * An advanced protection feature providing protections.
 * @hide
 */
@FlaggedApi(Flags.FLAG_AAPM_API)
@SystemApi
public final class AdvancedProtectionFeature implements Parcelable {
    private final String mId;

    /**
     * Create an object identifying an Advanced Protection feature for AdvancedProtectionManager
     * @param id A unique ID to identify this feature. It is used by Settings screens to display
     *           information about this feature.
     */
    public AdvancedProtectionFeature(@NonNull String id) {
        mId = id;
    }

    private AdvancedProtectionFeature(Parcel in) {
        mId = in.readString8();
    }

    /**
     * @return the unique ID representing this feature
     */
    @NonNull
    public String getId() {
        return mId;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeString8(mId);
    }

    @NonNull
    public static final Parcelable.Creator<AdvancedProtectionFeature> CREATOR =
            new Parcelable.Creator<>() {
                public AdvancedProtectionFeature createFromParcel(Parcel in) {
                    return new AdvancedProtectionFeature(in);
                }

                public AdvancedProtectionFeature[] newArray(int size) {
                    return new AdvancedProtectionFeature[size];
                }
            };
}
+18 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.os.RemoteException;
import android.security.Flags;
import android.util.Log;

import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;

@@ -41,7 +42,7 @@ import java.util.concurrent.Executor;
 */
@FlaggedApi(Flags.FLAG_AAPM_API)
@SystemService(Context.ADVANCED_PROTECTION_SERVICE)
public class AdvancedProtectionManager {
public final class AdvancedProtectionManager {
    private static final String TAG = "AdvancedProtectionMgr";

    private final ConcurrentHashMap<Callback, IAdvancedProtectionCallback>
@@ -146,6 +147,22 @@ public class AdvancedProtectionManager {
        }
    }

    /**
     * Returns the list of advanced protection features which are available on this device.
     *
     * @hide
     */
    @SystemApi
    @NonNull
    @RequiresPermission(Manifest.permission.SET_ADVANCED_PROTECTION_MODE)
    public List<AdvancedProtectionFeature> getAdvancedProtectionFeatures() {
        try {
            return mService.getAdvancedProtectionFeatures();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * A callback class for monitoring changes to Advanced Protection state
     *
Loading