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

Commit 28f1c8ab authored by Aditya's avatar Aditya
Browse files

Add @RequiresApi annotation for sdk version S for UserManagerState.

The interface is not used for sdk version R because call to
ActivityManager.getCurrentUser() is not supported. Explicit checks for
minimum sdk version had to be added to all the places that were using
either UserManagerState or TestUserManagerState instances. This had to
be done to satisfy presbumit lint checks.

Bug: 329508093
Test: atest DocumentsUIUnitTests
Change-Id: I32317805d1aae3b0a0fb89a486a41c3b24889bc4
parent 862c9f9e
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ import com.android.documentsui.roots.ProvidersCache;
import com.android.documentsui.sidebar.RootsFragment;
import com.android.documentsui.sorting.SortController;
import com.android.documentsui.sorting.SortModel;
import com.android.modules.utils.build.SdkLevel;

import com.google.android.material.appbar.AppBarLayout;

@@ -307,7 +308,7 @@ public abstract class BaseActivity
        // If private space feature flag is enabled, we should store the intent that launched docsUi
        // so that we can use this intent to get CrossProfileResolveInfo when ever we want to,
        // for example when ACTION_PROFILE_AVAILABLE intent is received
        if (mUserManagerState != null) {
        if (mUserManagerState != null && SdkLevel.isAtLeastS()) {
            mUserManagerState.setCurrentStateIntent(intent);
        }
        mSearchManager = new SearchViewManager(searchListener, queryInterceptor,
+2 −1
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import com.android.documentsui.base.State;
import com.android.documentsui.base.UserId;
import com.android.documentsui.roots.RootCursorWrapper;
import com.android.documentsui.sorting.SortModel;
import com.android.modules.utils.build.SdkLevel;

import java.util.ArrayList;
import java.util.List;
@@ -331,7 +332,7 @@ public class DirectoryLoader extends AsyncTaskLoader<DirectoryResult> {
    }

    private List<UserId> getUserIds() {
        if (mState.configStore.isPrivateSpaceInDocsUIEnabled()) {
        if (mState.configStore.isPrivateSpaceInDocsUIEnabled() && SdkLevel.isAtLeastS()) {
            return DocumentsApplication.getUserManagerState(getContext()).getUserIds();
        }
        return DocumentsApplication.getUserIdManager(getContext()).getUserIds();
+3 −2
Original line number Diff line number Diff line
@@ -127,7 +127,8 @@ public class DocumentsApplication extends Application {
    public static UserManagerState getUserManagerState(Context context) {
        UserManagerState userManagerState =
                ((DocumentsApplication) context.getApplicationContext()).mUserManagerState;
        if (userManagerState == null && getConfigStore().isPrivateSpaceInDocsUIEnabled()) {
        if (userManagerState == null && getConfigStore().isPrivateSpaceInDocsUIEnabled()
                && SdkLevel.isAtLeastS()) {
            userManagerState = UserManagerState.create(context);
            ((DocumentsApplication) context.getApplicationContext()).mUserManagerState =
                    userManagerState;
@@ -264,7 +265,7 @@ public class DocumentsApplication extends Application {
            } else if (PROFILE_FILTER_ACTIONS.contains(action)) {
                // Make the changes to UserManagerState object before calling providers updateAsync
                // so that providers for all the users are loaded
                if (getConfigStore().isPrivateSpaceInDocsUIEnabled()) {
                if (getConfigStore().isPrivateSpaceInDocsUIEnabled() && SdkLevel.isAtLeastS()) {
                    UserHandle userHandle = intent.getParcelableExtra(Intent.EXTRA_USER);
                    UserId userId = UserId.of(userHandle);
                    getUserManagerState(context).onProfileActionStatusChange(action, userId);
+3 −2
Original line number Diff line number Diff line
@@ -180,7 +180,7 @@ public class ProfileTabs implements ProfileTabsAddons {
            mUserIds.addAll(userIds);
            mTabs.removeAllTabs();
            if (mUserIds.size() > 1) {
                if (mConfigStore.isPrivateSpaceInDocsUIEnabled()) {
                if (mConfigStore.isPrivateSpaceInDocsUIEnabled() && SdkLevel.isAtLeastS()) {
                    addTabsPrivateSpaceEnabled();
                } else {
                    addTabsPrivateSpaceDisabled();
@@ -190,7 +190,7 @@ public class ProfileTabs implements ProfileTabsAddons {
    }

    private List<UserId> getUserIds() {
        if (mConfigStore.isPrivateSpaceInDocsUIEnabled()) {
        if (mConfigStore.isPrivateSpaceInDocsUIEnabled() && SdkLevel.isAtLeastS()) {
            assert mUserManagerState != null;
            return mUserManagerState.getUserIds();
        }
@@ -198,6 +198,7 @@ public class ProfileTabs implements ProfileTabsAddons {
        return mUserIdManager.getUserIds();
    }

    @RequiresApi(Build.VERSION_CODES.S)
    private void addTabsPrivateSpaceEnabled() {
        // set setSelected to false otherwise it will trigger callback.
        assert mUserManagerState != null;
+1 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RequiresApi(Build.VERSION_CODES.S)
public interface UserManagerState {

    /**
Loading