Loading src/com/android/documentsui/UserIdManager.java +2 −3 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageManager; import android.os.Build; import android.os.UserHandle; import android.os.UserManager; import android.util.Log; Loading @@ -37,6 +36,7 @@ import androidx.annotation.VisibleForTesting; import com.android.documentsui.base.Features; import com.android.documentsui.base.UserId; import com.android.documentsui.util.VersionUtils; import java.util.ArrayList; import java.util.List; Loading Loading @@ -213,8 +213,7 @@ public interface UserIdManager { private static boolean isDeviceSupported(Context context) { // The feature requires Android R DocumentsContract APIs and INTERACT_ACROSS_USERS // permission. return (Build.VERSION.CODENAME.equals("R") || (Build.VERSION.CODENAME.equals("REL") && Build.VERSION.SDK_INT >= 30)) return VersionUtils.isAtLeastR() && context.checkSelfPermission(Manifest.permission.INTERACT_ACROSS_USERS) == PackageManager.PERMISSION_GRANTED; } Loading src/com/android/documentsui/picker/PickActivity.java +2 −2 Original line number Diff line number Diff line Loading @@ -65,6 +65,7 @@ import com.android.documentsui.services.FileOperationService; import com.android.documentsui.sidebar.RootsFragment; import com.android.documentsui.ui.DialogController; import com.android.documentsui.ui.MessageBuilder; import com.android.documentsui.util.CrossProfileUtils; import java.util.Collection; import java.util.Collections; Loading Loading @@ -215,8 +216,7 @@ public class PickActivity extends BaseActivity implements ActionHandler.Addons { moreApps.setPackage(null); for (ResolveInfo info : getPackageManager().queryIntentActivities(moreApps, PackageManager.MATCH_DEFAULT_ONLY)) { if (RootsFragment.PROFILE_TARGET_ACTIVITY.equals( info.activityInfo.targetActivity)) { if (CrossProfileUtils.isCrossProfileIntentForwarderActivity(info)) { mState.canShareAcrossProfile = true; break; } Loading src/com/android/documentsui/sidebar/RootsFragment.java +2 −3 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ import com.android.documentsui.base.UserId; import com.android.documentsui.roots.ProvidersAccess; import com.android.documentsui.roots.ProvidersCache; import com.android.documentsui.roots.RootsLoader; import com.android.documentsui.util.CrossProfileUtils; import java.util.ArrayList; import java.util.Collection; Loading @@ -92,8 +93,6 @@ public class RootsFragment extends Fragment { private static final String TAG = "RootsFragment"; private static final String EXTRA_INCLUDE_APPS = "includeApps"; public static final String PROFILE_TARGET_ACTIVITY = "com.android.internal.app.IntentForwarderActivity"; private static final int CONTEXT_MENU_ITEM_TIMEOUT = 500; private final OnItemClickListener mItemListener = new OnItemClickListener() { Loading Loading @@ -399,7 +398,7 @@ public class RootsFragment extends Fragment { appsMapping.put(userPackage, info); // for change personal profile root. if (PROFILE_TARGET_ACTIVITY.equals(info.activityInfo.targetActivity)) { if (CrossProfileUtils.isCrossProfileIntentForwarderActivity(info)) { if (UserId.CURRENT_USER.equals(userId)) { profileItem = new ProfileItem(info, info.loadLabel(pm).toString(), mActionHandler); Loading src/com/android/documentsui/util/CrossProfileUtils.java 0 → 100644 +43 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 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.documentsui.util; import android.content.pm.ResolveInfo; /** * A utility class for cross-profile usage. */ public class CrossProfileUtils { private static final String PROFILE_TARGET_ACTIVITY = "com.android.internal.app.IntentForwarderActivity"; private CrossProfileUtils() { } /** * Returns whether this resolution represents the intent forwarder activity. */ public static boolean isCrossProfileIntentForwarderActivity(ResolveInfo info) { if (VersionUtils.isAtLeastR()) { return info.isCrossProfileIntentForwarderActivity(); } if (info.activityInfo != null) { return PROFILE_TARGET_ACTIVITY.equals(info.activityInfo.targetActivity); } return false; } } src/com/android/documentsui/util/VersionUtils.java 0 → 100644 +36 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 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.documentsui.util; import android.os.Build; /** * A utility class for checking Android version. */ public class VersionUtils { private VersionUtils() { } /** * Returns whether the device is running on the Android R or newer. */ public static boolean isAtLeastR() { return Build.VERSION.CODENAME.equals("R") || (Build.VERSION.CODENAME.equals("REL") && Build.VERSION.SDK_INT >= 30); } } Loading
src/com/android/documentsui/UserIdManager.java +2 −3 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageManager; import android.os.Build; import android.os.UserHandle; import android.os.UserManager; import android.util.Log; Loading @@ -37,6 +36,7 @@ import androidx.annotation.VisibleForTesting; import com.android.documentsui.base.Features; import com.android.documentsui.base.UserId; import com.android.documentsui.util.VersionUtils; import java.util.ArrayList; import java.util.List; Loading Loading @@ -213,8 +213,7 @@ public interface UserIdManager { private static boolean isDeviceSupported(Context context) { // The feature requires Android R DocumentsContract APIs and INTERACT_ACROSS_USERS // permission. return (Build.VERSION.CODENAME.equals("R") || (Build.VERSION.CODENAME.equals("REL") && Build.VERSION.SDK_INT >= 30)) return VersionUtils.isAtLeastR() && context.checkSelfPermission(Manifest.permission.INTERACT_ACROSS_USERS) == PackageManager.PERMISSION_GRANTED; } Loading
src/com/android/documentsui/picker/PickActivity.java +2 −2 Original line number Diff line number Diff line Loading @@ -65,6 +65,7 @@ import com.android.documentsui.services.FileOperationService; import com.android.documentsui.sidebar.RootsFragment; import com.android.documentsui.ui.DialogController; import com.android.documentsui.ui.MessageBuilder; import com.android.documentsui.util.CrossProfileUtils; import java.util.Collection; import java.util.Collections; Loading Loading @@ -215,8 +216,7 @@ public class PickActivity extends BaseActivity implements ActionHandler.Addons { moreApps.setPackage(null); for (ResolveInfo info : getPackageManager().queryIntentActivities(moreApps, PackageManager.MATCH_DEFAULT_ONLY)) { if (RootsFragment.PROFILE_TARGET_ACTIVITY.equals( info.activityInfo.targetActivity)) { if (CrossProfileUtils.isCrossProfileIntentForwarderActivity(info)) { mState.canShareAcrossProfile = true; break; } Loading
src/com/android/documentsui/sidebar/RootsFragment.java +2 −3 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ import com.android.documentsui.base.UserId; import com.android.documentsui.roots.ProvidersAccess; import com.android.documentsui.roots.ProvidersCache; import com.android.documentsui.roots.RootsLoader; import com.android.documentsui.util.CrossProfileUtils; import java.util.ArrayList; import java.util.Collection; Loading @@ -92,8 +93,6 @@ public class RootsFragment extends Fragment { private static final String TAG = "RootsFragment"; private static final String EXTRA_INCLUDE_APPS = "includeApps"; public static final String PROFILE_TARGET_ACTIVITY = "com.android.internal.app.IntentForwarderActivity"; private static final int CONTEXT_MENU_ITEM_TIMEOUT = 500; private final OnItemClickListener mItemListener = new OnItemClickListener() { Loading Loading @@ -399,7 +398,7 @@ public class RootsFragment extends Fragment { appsMapping.put(userPackage, info); // for change personal profile root. if (PROFILE_TARGET_ACTIVITY.equals(info.activityInfo.targetActivity)) { if (CrossProfileUtils.isCrossProfileIntentForwarderActivity(info)) { if (UserId.CURRENT_USER.equals(userId)) { profileItem = new ProfileItem(info, info.loadLabel(pm).toString(), mActionHandler); Loading
src/com/android/documentsui/util/CrossProfileUtils.java 0 → 100644 +43 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 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.documentsui.util; import android.content.pm.ResolveInfo; /** * A utility class for cross-profile usage. */ public class CrossProfileUtils { private static final String PROFILE_TARGET_ACTIVITY = "com.android.internal.app.IntentForwarderActivity"; private CrossProfileUtils() { } /** * Returns whether this resolution represents the intent forwarder activity. */ public static boolean isCrossProfileIntentForwarderActivity(ResolveInfo info) { if (VersionUtils.isAtLeastR()) { return info.isCrossProfileIntentForwarderActivity(); } if (info.activityInfo != null) { return PROFILE_TARGET_ACTIVITY.equals(info.activityInfo.targetActivity); } return false; } }
src/com/android/documentsui/util/VersionUtils.java 0 → 100644 +36 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 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.documentsui.util; import android.os.Build; /** * A utility class for checking Android version. */ public class VersionUtils { private VersionUtils() { } /** * Returns whether the device is running on the Android R or newer. */ public static boolean isAtLeastR() { return Build.VERSION.CODENAME.equals("R") || (Build.VERSION.CODENAME.equals("REL") && Build.VERSION.SDK_INT >= 30); } }