Merge "Rename CrossProfileApps API as per API council feedback"
This commit is contained in:
committed by
Android (Google) Code Review
commit
940ba0c8fe
@@ -117,7 +117,7 @@ java_library {
|
||||
"core/java/android/content/ISyncServiceAdapter.aidl",
|
||||
"core/java/android/content/ISyncStatusObserver.aidl",
|
||||
"core/java/android/content/om/IOverlayManager.aidl",
|
||||
"core/java/android/content/pm/crossprofile/ICrossProfileApps.aidl",
|
||||
"core/java/android/content/pm/ICrossProfileApps.aidl",
|
||||
"core/java/android/content/pm/IDexModuleRegisterCallback.aidl",
|
||||
"core/java/android/content/pm/ILauncherApps.aidl",
|
||||
"core/java/android/content/pm/IOnAppsChangedListener.aidl",
|
||||
|
||||
@@ -10687,6 +10687,13 @@ package android.content.pm {
|
||||
field public int reqTouchScreen;
|
||||
}
|
||||
|
||||
public class CrossProfileApps {
|
||||
method public android.graphics.drawable.Drawable getProfileSwitchingIconDrawable(android.os.UserHandle);
|
||||
method public java.lang.CharSequence getProfileSwitchingLabel(android.os.UserHandle);
|
||||
method public java.util.List<android.os.UserHandle> getTargetUserProfiles();
|
||||
method public void startMainActivity(android.content.ComponentName, android.os.UserHandle);
|
||||
}
|
||||
|
||||
public final class FeatureGroupInfo implements android.os.Parcelable {
|
||||
ctor public FeatureGroupInfo();
|
||||
ctor public FeatureGroupInfo(android.content.pm.FeatureGroupInfo);
|
||||
@@ -11481,17 +11488,6 @@ package android.content.pm {
|
||||
|
||||
}
|
||||
|
||||
package android.content.pm.crossprofile {
|
||||
|
||||
public class CrossProfileApps {
|
||||
method public android.graphics.drawable.Drawable getProfileSwitchingIcon(android.os.UserHandle);
|
||||
method public java.lang.CharSequence getProfileSwitchingLabel(android.os.UserHandle);
|
||||
method public java.util.List<android.os.UserHandle> getTargetUserProfiles();
|
||||
method public void startMainActivity(android.content.ComponentName, android.os.UserHandle);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package android.content.res {
|
||||
|
||||
public class AssetFileDescriptor implements java.io.Closeable android.os.Parcelable {
|
||||
|
||||
@@ -38,12 +38,12 @@ import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.IRestrictionsManager;
|
||||
import android.content.RestrictionsManager;
|
||||
import android.content.pm.CrossProfileApps;
|
||||
import android.content.pm.ICrossProfileApps;
|
||||
import android.content.pm.IShortcutService;
|
||||
import android.content.pm.LauncherApps;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ShortcutManager;
|
||||
import android.content.pm.crossprofile.CrossProfileApps;
|
||||
import android.content.pm.crossprofile.ICrossProfileApps;
|
||||
import android.content.res.Resources;
|
||||
import android.hardware.ConsumerIrManager;
|
||||
import android.hardware.ISerialManager;
|
||||
|
||||
@@ -4146,7 +4146,7 @@ public abstract class Context {
|
||||
|
||||
/**
|
||||
* Use with {@link #getSystemService(String)} to retrieve a
|
||||
* {@link android.content.pm.crossprofile.CrossProfileApps} for cross profile operations.
|
||||
* {@link android.content.pm.CrossProfileApps} for cross profile operations.
|
||||
*
|
||||
* @see #getSystemService(String)
|
||||
*/
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package android.content.pm.crossprofile;
|
||||
package android.content.pm;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.content.ComponentName;
|
||||
@@ -57,13 +57,14 @@ public class CrossProfileApps {
|
||||
* action {@link android.content.Intent#ACTION_MAIN}, category
|
||||
* {@link android.content.Intent#CATEGORY_LAUNCHER}. Otherwise, SecurityException will
|
||||
* be thrown.
|
||||
* @param user The UserHandle of the profile, must be one of the users returned by
|
||||
* @param targetUser The UserHandle of the profile, must be one of the users returned by
|
||||
* {@link #getTargetUserProfiles()}, otherwise a {@link SecurityException} will
|
||||
* be thrown.
|
||||
*/
|
||||
public void startMainActivity(@NonNull ComponentName component, @NonNull UserHandle user) {
|
||||
public void startMainActivity(@NonNull ComponentName component,
|
||||
@NonNull UserHandle targetUser) {
|
||||
try {
|
||||
mService.startActivityAsUser(mContext.getPackageName(), component, user);
|
||||
mService.startActivityAsUser(mContext.getPackageName(), component, targetUser);
|
||||
} catch (RemoteException ex) {
|
||||
throw ex.rethrowFromSystemServer();
|
||||
}
|
||||
@@ -114,7 +115,7 @@ public class CrossProfileApps {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an icon that calling app can show to user for the semantic of profile switching --
|
||||
* Return a drawable that calling app can show to user for the semantic of profile switching --
|
||||
* launching its own activity in specified user profile. For example, it may return a briefcase
|
||||
* icon if the given user handle is the managed profile one.
|
||||
*
|
||||
@@ -124,9 +125,9 @@ public class CrossProfileApps {
|
||||
* @return an icon that calling app can show user for the semantic of launching its own
|
||||
* activity in specified user profile.
|
||||
*
|
||||
* @see #startMainActivity(ComponentName, UserHandle, Rect, Bundle)
|
||||
* @see #startMainActivity(ComponentName, UserHandle)
|
||||
*/
|
||||
public @NonNull Drawable getProfileSwitchingIcon(@NonNull UserHandle userHandle) {
|
||||
public @NonNull Drawable getProfileSwitchingIconDrawable(@NonNull UserHandle userHandle) {
|
||||
verifyCanAccessUser(userHandle);
|
||||
|
||||
final boolean isManagedProfile =
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.content.pm.crossprofile;
|
||||
package android.content.pm;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.content.pm.crossprofile;
|
||||
package android.content.pm;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.nullable;
|
||||
@@ -42,7 +42,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* Build/Install/Run:
|
||||
* bit FrameworksCoreTests:android.content.pm.crossprofile.CrossProfileAppsTest
|
||||
* atest frameworks/base/core/tests/coretests/src/android/content/pm/CrossProfileAppsTest.java
|
||||
*/
|
||||
@Presubmit
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@@ -118,7 +118,7 @@ public class CrossProfileAppsTest {
|
||||
public void getProfileSwitchingIcon_managedProfile() {
|
||||
setValidTargetProfile(MANAGED_PROFILE);
|
||||
|
||||
mCrossProfileApps.getProfileSwitchingIcon(MANAGED_PROFILE);
|
||||
mCrossProfileApps.getProfileSwitchingIconDrawable(MANAGED_PROFILE);
|
||||
verify(mResources).getDrawable(R.drawable.ic_corp_badge, null);
|
||||
}
|
||||
|
||||
@@ -126,13 +126,13 @@ public class CrossProfileAppsTest {
|
||||
public void getProfileSwitchingIcon_personalProfile() {
|
||||
setValidTargetProfile(PERSONAL_PROFILE);
|
||||
|
||||
mCrossProfileApps.getProfileSwitchingIcon(PERSONAL_PROFILE);
|
||||
mCrossProfileApps.getProfileSwitchingIconDrawable(PERSONAL_PROFILE);
|
||||
verify(mResources).getDrawable(R.drawable.ic_account_circle, null);
|
||||
}
|
||||
|
||||
@Test(expected = SecurityException.class)
|
||||
public void getProfileSwitchingIcon_securityException() {
|
||||
mCrossProfileApps.getProfileSwitchingIcon(PERSONAL_PROFILE);
|
||||
mCrossProfileApps.getProfileSwitchingIconDrawable(PERSONAL_PROFILE);
|
||||
}
|
||||
|
||||
private void setValidTargetProfile(UserHandle userHandle) {
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.server.pm.crossprofile;
|
||||
package com.android.server.pm;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.server.pm.crossprofile;
|
||||
package com.android.server.pm;
|
||||
|
||||
import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_AWARE;
|
||||
import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_UNAWARE;
|
||||
@@ -25,14 +25,12 @@ import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ICrossProfileApps;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManagerInternal;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.pm.crossprofile.ICrossProfileApps;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Binder;
|
||||
import android.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
@@ -46,10 +46,10 @@ import android.os.SystemProperties;
|
||||
import android.os.Trace;
|
||||
import android.os.UserHandle;
|
||||
import android.os.storage.IStorageManager;
|
||||
import android.util.TimingsTraceLog;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.EventLog;
|
||||
import android.util.Slog;
|
||||
import android.util.TimingsTraceLog;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.android.internal.R;
|
||||
@@ -57,20 +57,21 @@ import com.android.internal.app.ColorDisplayController;
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.notification.SystemNotificationChannels;
|
||||
import com.android.internal.os.BinderInternal;
|
||||
import com.android.internal.util.EmergencyAffordanceManager;
|
||||
import com.android.internal.util.ConcurrentUtils;
|
||||
import com.android.internal.util.EmergencyAffordanceManager;
|
||||
import com.android.internal.widget.ILockSettings;
|
||||
import com.android.server.accessibility.AccessibilityManagerService;
|
||||
import com.android.server.am.ActivityManagerService;
|
||||
import com.android.server.audio.AudioService;
|
||||
import com.android.server.broadcastradio.BroadcastRadioService;
|
||||
import com.android.server.camera.CameraServiceProxy;
|
||||
import com.android.server.car.CarServiceHelperService;
|
||||
import com.android.server.clipboard.ClipboardService;
|
||||
import com.android.server.connectivity.IpConnectivityMetrics;
|
||||
import com.android.server.coverage.CoverageService;
|
||||
import com.android.server.devicepolicy.DevicePolicyManagerService;
|
||||
import com.android.server.display.DisplayManagerService;
|
||||
import com.android.server.display.ColorDisplayService;
|
||||
import com.android.server.display.DisplayManagerService;
|
||||
import com.android.server.dreams.DreamManagerService;
|
||||
import com.android.server.emergency.EmergencyAffordanceService;
|
||||
import com.android.server.fingerprint.FingerprintService;
|
||||
@@ -92,17 +93,16 @@ import com.android.server.om.OverlayManagerService;
|
||||
import com.android.server.os.DeviceIdentifiersPolicyService;
|
||||
import com.android.server.os.SchedulingPolicyService;
|
||||
import com.android.server.pm.BackgroundDexOptService;
|
||||
import com.android.server.pm.CrossProfileAppsService;
|
||||
import com.android.server.pm.Installer;
|
||||
import com.android.server.pm.LauncherAppsService;
|
||||
import com.android.server.pm.OtaDexoptService;
|
||||
import com.android.server.pm.PackageManagerService;
|
||||
import com.android.server.pm.ShortcutService;
|
||||
import com.android.server.pm.UserManagerService;
|
||||
import com.android.server.pm.crossprofile.CrossProfileAppsService;
|
||||
import com.android.server.policy.PhoneWindowManager;
|
||||
import com.android.server.power.PowerManagerService;
|
||||
import com.android.server.power.ShutdownThread;
|
||||
import com.android.server.broadcastradio.BroadcastRadioService;
|
||||
import com.android.server.restrictions.RestrictionsManagerService;
|
||||
import com.android.server.security.KeyAttestationApplicationIdProviderService;
|
||||
import com.android.server.security.KeyChainSystemService;
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.android.server.pm.crossprofile;
|
||||
package com.android.server.pm;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
@@ -34,7 +32,6 @@ import android.util.SparseArray;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
@@ -44,7 +41,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* Build/Install/Run:
|
||||
* bit FrameworksServicesTests:com.android.server.pm.crossprofile.CrossProfileAppsServiceImplTest
|
||||
* atest FrameworksServicesTests:com.android.server.pm.CrossProfileAppsServiceImplTest
|
||||
*/
|
||||
@Presubmit
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
Reference in New Issue
Block a user