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

Commit 2b7e1dcc authored by Jonathan Scott's avatar Jonathan Scott Committed by Android (Google) Code Review
Browse files

Merge changes from topics "docheckfix4", "docheckfix5", "hasFeatureCrossUser", "testuser"

* changes:
  Fix incorrect check for Sysuser.
  Update DO and role holder requirements to block if there are accounts on any user.
  Allow use of #hasFeatures across users.
  Update Device Owner and Role Holder requirements to allow FOR_TESTING users.
  Add FOR_TESTING  UserInfo Flag.
parents c1de6541 6369ffad
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -528,6 +528,7 @@ package android.app.admin {
    method @NonNull public static String operationSafetyReasonToString(int);
    method @NonNull public static String operationToString(int);
    method @RequiresPermission(android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS) public void resetDefaultCrossProfileIntentFilters(int);
    method @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS) public void resetShouldAllowBypassingDevicePolicyManagementRoleQualificationState();
    method @RequiresPermission(allOf={android.Manifest.permission.MANAGE_DEVICE_ADMINS, android.Manifest.permission.INTERACT_ACROSS_USERS_FULL}) public void setActiveAdmin(@NonNull android.content.ComponentName, boolean, int);
    method @RequiresPermission(android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS) public boolean setDeviceOwner(@NonNull android.content.ComponentName, int);
    method @RequiresPermission(android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS) public boolean setDeviceOwnerOnly(@NonNull android.content.ComponentName, int);
@@ -897,6 +898,7 @@ package android.content.pm {
    method public boolean isDemo();
    method public boolean isEnabled();
    method public boolean isEphemeral();
    method public boolean isForTesting();
    method public boolean isFull();
    method public boolean isGuest();
    method public boolean isInitialized();
+13 −2
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.accounts;

import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;

import android.annotation.BroadcastBehavior;
import android.annotation.IntDef;
import android.annotation.NonNull;
@@ -891,15 +893,24 @@ public class AccountManager {
     * @return An {@link AccountManagerFuture} which resolves to a Boolean, true if the account
     *         exists and has all of the specified features.
     */
    @UserHandleAware(enabledSinceTargetSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE,
            requiresPermissionIfNotCaller = INTERACT_ACROSS_USERS_FULL)
    public AccountManagerFuture<Boolean> hasFeatures(final Account account,
            final String[] features,
            AccountManagerCallback<Boolean> callback, Handler handler) {
        return hasFeaturesAsUser(account, features, callback, handler, mContext.getUserId());
    }

    private AccountManagerFuture<Boolean> hasFeaturesAsUser(
            final Account account, final String[] features,
            AccountManagerCallback<Boolean> callback, Handler handler, int userId) {
        if (account == null) throw new IllegalArgumentException("account is null");
        if (features == null) throw new IllegalArgumentException("features is null");
        return new Future2Task<Boolean>(handler, callback) {
            @Override
            public void doWork() throws RemoteException {
                mService.hasFeatures(mResponse, account, features, mContext.getOpPackageName());
                mService.hasFeatures(
                        mResponse, account, features, userId, mContext.getOpPackageName());
            }
            @Override
            public Boolean bundleToResult(Bundle bundle) throws AuthenticatorException {
@@ -3319,7 +3330,7 @@ public class AccountManager {
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
    @RequiresPermission(INTERACT_ACROSS_USERS_FULL)
    public AccountManagerFuture<Bundle> finishSessionAsUser(
            final Bundle sessionBundle,
            final Activity activity,
+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ interface IAccountManager {
    Account[] getAccountsByTypeForPackage(String type, String packageName, String opPackageName);
    Account[] getAccountsAsUser(String accountType, int userId, String opPackageName);
    void hasFeatures(in IAccountManagerResponse response, in Account account, in String[] features,
        String opPackageName);
        int userId, String opPackageName);
    void getAccountByTypeAndFeatures(in IAccountManagerResponse response, String accountType,
        in String[] features, String opPackageName);
    void getAccountsByFeatures(in IAccountManagerResponse response, String accountType,
+24 −6
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.app.admin;
import static android.Manifest.permission.QUERY_ADMIN_POLICY;
import static android.Manifest.permission.SET_TIME;
import static android.Manifest.permission.SET_TIME_ZONE;
import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
import static android.content.Intent.LOCAL_FLAG_FROM_SYSTEM;
import static android.net.NetworkCapabilities.NET_ENTERPRISE_ID_1;
@@ -4186,7 +4187,7 @@ public class DevicePolicyManager {
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
    @RequiresPermission(INTERACT_ACROSS_USERS_FULL)
    public boolean packageHasActiveAdmins(String packageName) {
        return packageHasActiveAdmins(packageName, myUserId());
    }
@@ -8743,7 +8744,7 @@ public class DevicePolicyManager {
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    @RequiresPermission(allOf = {
            android.Manifest.permission.MANAGE_DEVICE_ADMINS,
            android.Manifest.permission.INTERACT_ACROSS_USERS_FULL
            INTERACT_ACROSS_USERS_FULL
    })
    public void setActiveAdmin(@NonNull ComponentName policyReceiver, boolean refreshing,
            int userHandle) {
@@ -10654,7 +10655,7 @@ public class DevicePolicyManager {
     */
    @UserHandleAware
    @RequiresPermission(allOf = {
            android.Manifest.permission.INTERACT_ACROSS_USERS_FULL,
            INTERACT_ACROSS_USERS_FULL,
            android.Manifest.permission.MANAGE_USERS
            }, conditional = true)
    public @Nullable List<String> getPermittedInputMethods() {
@@ -14845,7 +14846,7 @@ public class DevicePolicyManager {
     * @hide
     */
    @RequiresPermission(anyOf = {
            permission.INTERACT_ACROSS_USERS_FULL,
            INTERACT_ACROSS_USERS_FULL,
            permission.INTERACT_ACROSS_USERS
    }, conditional = true)
    public boolean isPackageAllowedToAccessCalendar(@NonNull  String packageName) {
@@ -14877,7 +14878,7 @@ public class DevicePolicyManager {
     * @hide
     */
    @RequiresPermission(anyOf = {
            permission.INTERACT_ACROSS_USERS_FULL,
            INTERACT_ACROSS_USERS_FULL,
            permission.INTERACT_ACROSS_USERS
    })
    public @Nullable Set<String> getCrossProfileCalendarPackages() {
@@ -14970,7 +14971,7 @@ public class DevicePolicyManager {
     * @hide
     */
    @RequiresPermission(anyOf = {
            permission.INTERACT_ACROSS_USERS_FULL,
            INTERACT_ACROSS_USERS_FULL,
            permission.INTERACT_ACROSS_USERS,
            permission.INTERACT_ACROSS_PROFILES
    })
@@ -16153,6 +16154,23 @@ public class DevicePolicyManager {
        return deviceManagerConfig;
    }
    /**
     * Reset cache for {@link #shouldAllowBypassingDevicePolicyManagementRoleQualification}.
     *
     * @hide
     */
    @TestApi
    @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS)
    public void resetShouldAllowBypassingDevicePolicyManagementRoleQualificationState() {
        if (mService != null) {
            try {
                mService.resetShouldAllowBypassingDevicePolicyManagementRoleQualificationState();
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
    }
    /**
     * @return {@code true} if bypassing the device policy management role qualification is allowed
     * with the current state of the device.
+1 −0
Original line number Diff line number Diff line
@@ -575,6 +575,7 @@ interface IDevicePolicyManager {
    void resetStrings(in List<String> stringIds);
    ParcelableResource getString(String stringId);

    void resetShouldAllowBypassingDevicePolicyManagementRoleQualificationState();
    boolean shouldAllowBypassingDevicePolicyManagementRoleQualification();

    List<UserHandle> getPolicyManagedProfiles(in UserHandle userHandle);
Loading