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

Commit 862eda0d authored by Pete Varvarezis's avatar Pete Varvarezis Committed by Android (Google) Code Review
Browse files

Merge "Add package-level control to CallerId and Contacts"

parents 02489189 21a6daa5
Loading
Loading
Loading
Loading
+21 −4
Original line number Diff line number Diff line
@@ -7500,8 +7500,8 @@ package android.app.admin {
    method public boolean getCameraDisabled(@Nullable android.content.ComponentName);
    method @Deprecated @Nullable public String getCertInstallerPackage(@NonNull android.content.ComponentName) throws java.lang.SecurityException;
    method @Deprecated @Nullable public java.util.Set<java.lang.String> getCrossProfileCalendarPackages(@NonNull android.content.ComponentName);
    method public boolean getCrossProfileCallerIdDisabled(@NonNull android.content.ComponentName);
    method public boolean getCrossProfileContactsSearchDisabled(@NonNull android.content.ComponentName);
    method @Deprecated public boolean getCrossProfileCallerIdDisabled(@NonNull android.content.ComponentName);
    method @Deprecated public boolean getCrossProfileContactsSearchDisabled(@NonNull android.content.ComponentName);
    method @NonNull public java.util.Set<java.lang.String> getCrossProfilePackages(@NonNull android.content.ComponentName);
    method @NonNull public java.util.List<java.lang.String> getCrossProfileWidgetProviders(@NonNull android.content.ComponentName);
    method public int getCurrentFailedPasswordAttempts();
@@ -7521,6 +7521,8 @@ package android.app.admin {
    method public int getLockTaskFeatures(@NonNull android.content.ComponentName);
    method @NonNull public String[] getLockTaskPackages(@NonNull android.content.ComponentName);
    method @Nullable public CharSequence getLongSupportMessage(@NonNull android.content.ComponentName);
    method @Nullable public android.app.admin.PackagePolicy getManagedProfileCallerIdAccessPolicy();
    method @Nullable public android.app.admin.PackagePolicy getManagedProfileContactsAccessPolicy();
    method public long getManagedProfileMaximumTimeOff(@NonNull android.content.ComponentName);
    method public int getMaximumFailedPasswordsForWipe(@Nullable android.content.ComponentName);
    method public long getMaximumTimeToLock(@Nullable android.content.ComponentName);
@@ -7649,8 +7651,8 @@ package android.app.admin {
    method public void setCommonCriteriaModeEnabled(@NonNull android.content.ComponentName, boolean);
    method public void setConfiguredNetworksLockdownState(@NonNull android.content.ComponentName, boolean);
    method @Deprecated public void setCrossProfileCalendarPackages(@NonNull android.content.ComponentName, @Nullable java.util.Set<java.lang.String>);
    method public void setCrossProfileCallerIdDisabled(@NonNull android.content.ComponentName, boolean);
    method public void setCrossProfileContactsSearchDisabled(@NonNull android.content.ComponentName, boolean);
    method @Deprecated public void setCrossProfileCallerIdDisabled(@NonNull android.content.ComponentName, boolean);
    method @Deprecated public void setCrossProfileContactsSearchDisabled(@NonNull android.content.ComponentName, boolean);
    method public void setCrossProfilePackages(@NonNull android.content.ComponentName, @NonNull java.util.Set<java.lang.String>);
    method public void setDefaultSmsApplication(@NonNull android.content.ComponentName, @NonNull String);
    method public void setDelegatedScopes(@NonNull android.content.ComponentName, @NonNull String, @NonNull java.util.List<java.lang.String>);
@@ -7669,6 +7671,8 @@ package android.app.admin {
    method public void setLockTaskPackages(@NonNull android.content.ComponentName, @NonNull String[]) throws java.lang.SecurityException;
    method public void setLogoutEnabled(@NonNull android.content.ComponentName, boolean);
    method public void setLongSupportMessage(@NonNull android.content.ComponentName, @Nullable CharSequence);
    method public void setManagedProfileCallerIdAccessPolicy(@Nullable android.app.admin.PackagePolicy);
    method public void setManagedProfileContactsAccessPolicy(@Nullable android.app.admin.PackagePolicy);
    method public void setManagedProfileMaximumTimeOff(@NonNull android.content.ComponentName, long);
    method public void setMasterVolumeMuted(@NonNull android.content.ComponentName, boolean);
    method public void setMaximumFailedPasswordsForWipe(@NonNull android.content.ComponentName, int);
@@ -7980,6 +7984,19 @@ package android.app.admin {
    field @NonNull public static final android.os.Parcelable.Creator<android.app.admin.NetworkEvent> CREATOR;
  }
  public final class PackagePolicy implements android.os.Parcelable {
    ctor public PackagePolicy(int);
    ctor public PackagePolicy(int, @NonNull java.util.Set<java.lang.String>);
    method public int describeContents();
    method @NonNull public java.util.Set<java.lang.String> getPackageNames();
    method public int getPolicyType();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.app.admin.PackagePolicy> CREATOR;
    field public static final int PACKAGE_POLICY_ALLOWLIST = 3; // 0x3
    field public static final int PACKAGE_POLICY_ALLOWLIST_AND_SYSTEM = 2; // 0x2
    field public static final int PACKAGE_POLICY_BLOCKLIST = 1; // 0x1
  }
  public final class PreferentialNetworkServiceConfig implements android.os.Parcelable {
    method public int describeContents();
    method @NonNull public int[] getExcludedUids();
+2 −0
Original line number Diff line number Diff line
@@ -63,6 +63,8 @@ package android.app.admin {
  public class DevicePolicyManager {
    method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.INTERACT_ACROSS_USERS}) public void acknowledgeNewUserDisclaimer();
    method @Nullable @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.INTERACT_ACROSS_USERS}) public android.os.UserHandle getLogoutUser();
    method public boolean hasManagedProfileCallerIdAccess(@NonNull android.os.UserHandle, @NonNull String);
    method public boolean hasManagedProfileContactsAccess(@NonNull android.os.UserHandle, @NonNull String);
    method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.INTERACT_ACROSS_USERS}) public int logoutUser();
    field public static final String ACTION_SHOW_NEW_USER_DISCLAIMER = "android.app.action.SHOW_NEW_USER_DISCLAIMER";
  }
+204 −3
Original line number Diff line number Diff line
@@ -9878,11 +9878,20 @@ public class DevicePolicyManager {
     * <p>
     * The calling device admin must be a profile owner. If it is not, a security exception will be
     * thrown.
     * <p>
     * Starting with {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, calling this function
     * is similar to calling {@link #setManagedProfileCallerIdAccessPolicy(PackagePolicy)}
     * with a {@link PackagePolicy#PACKAGE_POLICY_BLOCKLIST} policy type when {@code disabled} is
     * false or a {@link PackagePolicy#PACKAGE_POLICY_ALLOWLIST} policy type when
     * {@code disabled} is true.
     *
     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
     * @param disabled If true caller-Id information in the managed profile is not displayed.
     * @throws SecurityException if {@code admin} is not a profile owner.
     * @deprecated starting with {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, use
     * {@link #setManagedProfileCallerIdAccessPolicy(PackagePolicy)} instead
     */
    @Deprecated
    public void setCrossProfileCallerIdDisabled(@NonNull ComponentName admin, boolean disabled) {
        throwIfParentInstance("setCrossProfileCallerIdDisabled");
        if (mService != null) {
@@ -9900,10 +9909,19 @@ public class DevicePolicyManager {
     * <p>
     * The calling device admin must be a profile owner. If it is not, a security exception will be
     * thrown.
     * <p>
     * Starting with {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE},
     * this will return true when
     * {@link #setManagedProfileCallerIdAccessPolicy(PackagePolicy)}
     * has been set with a non-null policy whose policy type is NOT
     * {@link PackagePolicy#PACKAGE_POLICY_BLOCKLIST}
     *
     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
     * @throws SecurityException if {@code admin} is not a profile owner.
     * @deprecated starting with {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, use
     * {@link #getManagedProfileCallerIdAccessPolicy()} instead
     */
    @Deprecated
    public boolean getCrossProfileCallerIdDisabled(@NonNull ComponentName admin) {
        throwIfParentInstance("getCrossProfileCallerIdDisabled");
        if (mService != null) {
@@ -9917,11 +9935,20 @@ public class DevicePolicyManager {
    }
    /**
     * Determine whether or not caller-Id information has been disabled.
     * Called by the system to determine whether or not caller-Id information has been disabled.
     * <p>
     * Starting with {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE},
     * this will return true when
     * {@link #setManagedProfileCallerIdAccessPolicy(PackagePolicy)}
     * has been set with a non-null policy whose policy type is NOT
     * {@link PackagePolicy#PACKAGE_POLICY_BLOCKLIST}
     *
     * @param userHandle The user for whom to check the caller-id permission
     * @deprecated use {@link #hasManagedProfileCallerIdAccess(UserHandle, String)} and provide the
     * package name requesting access
     * @hide
     */
    @Deprecated
    public boolean getCrossProfileCallerIdDisabled(UserHandle userHandle) {
        if (mService != null) {
            try {
@@ -9933,6 +9960,154 @@ public class DevicePolicyManager {
        return false;
    }
    /**
     * Called by a profile owner of a managed profile to set the packages that are allowed to
     * lookup contacts in the managed profile based on caller id information.
     * <p>
     * For example, the policy determines if a dialer app in the parent profile resolving
     * an incoming call can search the caller id data, such as phone number,
     * of managed contacts and return managed contacts that match.
     * <p>
     * The calling device admin must be a profile owner of a managed profile.
     * If it is not, a {@link SecurityException} will be thrown.
     * <p>
     * A {@link PackagePolicy#PACKAGE_POLICY_ALLOWLIST_AND_SYSTEM} policy type
     * allows access from the OEM default packages for the Sms, Dialer and Contact roles,
     * in addition to the packages specified in {@link PackagePolicy#getPackageNames()}
     *
     * @param policy the policy to set, setting this value to {@code null} will allow
     *               all packages
     * @throws SecurityException if caller is not a profile owner of a managed profile
     */
    public void setManagedProfileCallerIdAccessPolicy(@Nullable PackagePolicy policy) {
        throwIfParentInstance("setManagedProfileCallerIdAccessPolicy");
        if (mService != null) {
            try {
                mService.setManagedProfileCallerIdAccessPolicy(policy);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
    }
    /**
     * Called by a profile owner of a managed profile to retrieve the caller id policy.
     * <p>
     * The calling device admin must be a profile owner of a managed profile.
     * If it is not, a {@link SecurityException} will be thrown.
     *
     * @throws SecurityException if caller is not a profile owner of a managed profile.
     * @return the current caller id policy
     */
    public @Nullable PackagePolicy getManagedProfileCallerIdAccessPolicy() {
        throwIfParentInstance("getManagedProfileCallerIdAccessPolicy");
        if (mService != null) {
            try {
                return mService.getManagedProfileCallerIdAccessPolicy();
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
        return null;
    }
    /**
     * Determine whether the given package is allowed to query the requested user to
     * populate caller id information
     *
     * @param userHandle The user for whom to check the contacts search permission
     * @param packageName the name of the package requesting access
     * @return true if package should be granted access, false otherwise
     * @hide
     */
    @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
    public boolean hasManagedProfileCallerIdAccess(@NonNull UserHandle userHandle,
            @NonNull String packageName) {
        if (mService == null) {
            return true;
        }
        try {
            return mService.hasManagedProfileCallerIdAccess(userHandle.getIdentifier(),
                    packageName);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
    /**
     * Called by a profile owner of a managed profile to set the packages that are allowed
     * access to the managed profile contacts from the parent user.
     * <p>
     * For example, the system will enforce the provided policy and determine
     * if contacts in the managed profile are shown when queried by an application
     * in the parent user.
     * <p>
     * The calling device admin must be a profile owner of a managed profile.
     * If it is not, a {@link SecurityException} will be thrown.
     * <p>
     * A {@link PackagePolicy#PACKAGE_POLICY_ALLOWLIST_AND_SYSTEM} policy type
     * allows access from the OEM default packages for the Sms, Dialer and Contact roles,
     * in addition to the packages specified in {@link PackagePolicy#getPackageNames()}
     *
     * @param policy the policy to set, setting this value to {@code null} will allow
     *               all packages
     * @throws SecurityException if caller is not a profile owner of a managed profile
     */
    public void setManagedProfileContactsAccessPolicy(@Nullable PackagePolicy policy) {
        throwIfParentInstance("setManagedProfileContactsAccessPolicy");
        if (mService != null) {
            try {
                mService.setManagedProfileContactsAccessPolicy(policy);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
    }
    /**
     * Called by a profile owner of a managed profile to determine the current policy applied
     * to managed profile contacts.
     * <p>
     * The calling device admin must be a profile owner of a managed profile.
     * If it is not, a {@link SecurityException} will be thrown.
     *
     * @throws SecurityException if caller is not a profile owner of a managed profile.
     * @return the current contacts search policy
     */
    public @Nullable PackagePolicy getManagedProfileContactsAccessPolicy() {
        throwIfParentInstance("getManagedProfileContactsAccessPolicy");
        if (mService == null) {
            return null;
        }
        try {
            return mService.getManagedProfileContactsAccessPolicy();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
    /**
     * Determine whether requesting package has ability to access contacts of the requested user
     *
     * @param userHandle The user for whom to check the contacts search permission
     * @param packageName packageName requesting access to contact search
     * @return true when package is allowed access, false otherwise
     * @hide
     */
    @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
    public boolean hasManagedProfileContactsAccess(@NonNull UserHandle userHandle,
            @NonNull String packageName) {
        if (mService != null) {
            try {
                return mService.hasManagedProfileContactsAccess(userHandle.getIdentifier(),
                        packageName);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
        return false;
    }
    /**
     * Called by a profile owner of a managed profile to set whether contacts search from the
     * managed profile will be shown in the parent profile, for incoming calls.
@@ -9940,10 +10115,20 @@ public class DevicePolicyManager {
     * The calling device admin must be a profile owner. If it is not, a security exception will be
     * thrown.
     *
     * Starting with {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, calling this function
     * is similar to calling {@link #setManagedProfileContactsAccessPolicy(PackagePolicy)} with a
     * {@link PackagePolicy#PACKAGE_POLICY_BLOCKLIST} policy type when {@code disabled} is false
     * or a {@link PackagePolicy#PACKAGE_POLICY_ALLOWLIST} policy type when {@code disabled}
     * is true.
     *
     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
     * @param disabled If true contacts search in the managed profile is not displayed.
     * @throws SecurityException if {@code admin} is not a profile owner.
     *
     * @deprecated From {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE} use
     * {@link #setManagedProfileContactsAccessPolicy(PackagePolicy)}
     */
    @Deprecated
    public void setCrossProfileContactsSearchDisabled(@NonNull ComponentName admin,
            boolean disabled) {
        throwIfParentInstance("setCrossProfileContactsSearchDisabled");
@@ -9962,10 +10147,19 @@ public class DevicePolicyManager {
     * <p>
     * The calling device admin must be a profile owner. If it is not, a security exception will be
     * thrown.
     * <p>
     * Starting with {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE},
     * this will return true when
     * {@link #setManagedProfileContactsAccessPolicy(PackagePolicy)}
     * has been set with a non-null policy whose policy type is NOT
     * {@link PackagePolicy#PACKAGE_POLICY_BLOCKLIST}
     *
     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
     * @throws SecurityException if {@code admin} is not a profile owner.
     * @deprecated From {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE} use
     * {@link #getManagedProfileContactsAccessPolicy()}
     */
    @Deprecated
    public boolean getCrossProfileContactsSearchDisabled(@NonNull ComponentName admin) {
        throwIfParentInstance("getCrossProfileContactsSearchDisabled");
        if (mService != null) {
@@ -9978,13 +10172,20 @@ public class DevicePolicyManager {
        return false;
    }
    /**
     * Determine whether or not contacts search has been disabled.
     *
     * <p>
     * Starting with {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE},
     * this will return true when
     * {@link #setManagedProfileContactsAccessPolicy(PackagePolicy)}
     * has been set with a non-null policy whose policy type is NOT
     * {@link PackagePolicy#PACKAGE_POLICY_BLOCKLIST}
     * @param userHandle The user for whom to check the contacts search permission
     * @deprecated use {@link #hasManagedProfileContactsAccess(UserHandle, String)} and provide the
     * package name requesting access
     * @hide
     */
    @Deprecated
    public boolean getCrossProfileContactsSearchDisabled(@NonNull UserHandle userHandle) {
        if (mService != null) {
            try {
+9 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.app.admin.PreferentialNetworkServiceConfig;
import android.app.admin.StartInstallingUpdateCallback;
import android.app.admin.SystemUpdateInfo;
import android.app.admin.SystemUpdatePolicy;
import android.app.admin.PackagePolicy;
import android.app.admin.PasswordMetrics;
import android.app.admin.FactoryResetProtectionPolicy;
import android.app.admin.ManagedProfileProvisioningParams;
@@ -330,6 +331,14 @@ interface IDevicePolicyManager {
    boolean getCrossProfileContactsSearchDisabledForUser(int userId);
    void startManagedQuickContact(String lookupKey, long contactId, boolean isContactIdIgnored, long directoryId, in Intent originalIntent);

    void setManagedProfileCallerIdAccessPolicy(in PackagePolicy policy);
    PackagePolicy getManagedProfileCallerIdAccessPolicy();
    boolean hasManagedProfileCallerIdAccess(int userId, String packageName);

    void setManagedProfileContactsAccessPolicy(in PackagePolicy policy);
    PackagePolicy getManagedProfileContactsAccessPolicy();
    boolean hasManagedProfileContactsAccess(int userId, String packageName);

    void setBluetoothContactSharingDisabled(in ComponentName who, boolean disabled);
    boolean getBluetoothContactSharingDisabled(in ComponentName who);
    boolean getBluetoothContactSharingDisabledForUser(int userId);
+20 −0
Original line number Diff line number Diff line
/*
 * 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 PackagePolicy;
 No newline at end of file
Loading