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

Commit 056b8f00 authored by Makoto Onuki's avatar Makoto Onuki Committed by android-build-merger
Browse files

Merge "Add Context.createContextAsUser()"

am: 63d5e4a0

Change-Id: I022daba2bc9234ffe7b7fa760942a58852e406b3
parents fa968e96 63d5e4a0
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1366,8 +1366,9 @@ package android.content {
  public abstract class Context {
    method @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) public boolean bindServiceAsUser(@RequiresPermission android.content.Intent, android.content.ServiceConnection, int, android.os.UserHandle);
    method @NonNull public android.content.Context createContextAsUser(@NonNull android.os.UserHandle);
    method public abstract android.content.Context createCredentialProtectedStorageContext();
    method public android.content.Context createPackageContextAsUser(String, int, android.os.UserHandle) throws android.content.pm.PackageManager.NameNotFoundException;
    method @NonNull public android.content.Context createPackageContextAsUser(@NonNull String, int, @NonNull android.os.UserHandle) throws android.content.pm.PackageManager.NameNotFoundException;
    method @Nullable public abstract java.io.File getPreloadsFileCache();
    method public abstract boolean isCredentialProtectedStorage();
    method public abstract void sendBroadcast(android.content.Intent, @Nullable String, @Nullable android.os.Bundle);
+2 −1
Original line number Diff line number Diff line
@@ -640,7 +640,8 @@ package android.content {
  }

  public abstract class Context {
    method public android.content.Context createPackageContextAsUser(String, int, android.os.UserHandle) throws android.content.pm.PackageManager.NameNotFoundException;
    method @NonNull public android.content.Context createContextAsUser(@NonNull android.os.UserHandle);
    method @NonNull public android.content.Context createPackageContextAsUser(@NonNull String, int, @NonNull android.os.UserHandle) throws android.content.pm.PackageManager.NameNotFoundException;
    method public abstract android.view.Display getDisplay();
    method public abstract int getDisplayId();
    method public android.os.UserHandle getUser();
+9 −0
Original line number Diff line number Diff line
@@ -2223,6 +2223,15 @@ class ContextImpl extends Context {
                "Application package " + packageName + " not found");
    }

    @Override
    public Context createContextAsUser(UserHandle user) {
        try {
            return createPackageContextAsUser(getPackageName(), mFlags, user);
        } catch (NameNotFoundException e) {
            throw new IllegalStateException("Own package not found: package=" + getPackageName());
        }
    }

    @Override
    public Context createContextForSplit(String splitName) throws NameNotFoundException {
        if (!mPackageInfo.getApplicationInfo().requestsIsolatedSplitLoading()) {
+19 −1
Original line number Diff line number Diff line
@@ -5264,8 +5264,9 @@ public abstract class Context {
     */
    @SystemApi
    @TestApi
    @NonNull
    public Context createPackageContextAsUser(
            String packageName, @CreatePackageOptions int flags, UserHandle user)
            @NonNull String packageName, @CreatePackageOptions int flags, @NonNull UserHandle user)
            throws PackageManager.NameNotFoundException {
        if (Build.IS_ENG) {
            throw new IllegalStateException("createPackageContextAsUser not overridden!");
@@ -5273,6 +5274,23 @@ public abstract class Context {
        return this;
    }

    /**
     * Similar to {@link #createPackageContext(String, int)}, but for the own package with a
     * different {@link UserHandle}. For example, {@link #getContentResolver()}
     * will open any {@link Uri} as the given user.
     *
     * @hide
     */
    @SystemApi
    @TestApi
    @NonNull
    public Context createContextAsUser(@NonNull UserHandle user) {
        if (Build.IS_ENG) {
            throw new IllegalStateException("createContextAsUser not overridden!");
        }
        return this;
    }

    /**
     * Creates a context given an {@link android.content.pm.ApplicationInfo}.
     *
+6 −0
Original line number Diff line number Diff line
@@ -896,6 +896,12 @@ public class ContextWrapper extends Context {
        return mBase.createPackageContextAsUser(packageName, flags, user);
    }

    /** @hide */
    @Override
    public Context createContextAsUser(UserHandle user) {
        return mBase.createContextAsUser(user);
    }

    /** @hide */
    @Override
    @UnsupportedAppUsage
Loading