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

Commit ec5f7d16 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Support more createPackageContextAsUser() users.

We created this API to make it easy to pass a given UserHandle into
all Managers obtained from a given Context, which works great for
"normal" users, but we should also support special users like ALL
and CURRENT.

Also add an AutoCloseable marker to make try-with-resources easier.

Bug: 112153259
Test: atest android.content.cts.ContextTest
Change-Id: I261dfcc5cfdfc76bda5d70181785e11c2715a558
parent f0ed7769
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -12652,7 +12652,7 @@ package android.database.sqlite {
    ctor public SQLiteMisuseException(java.lang.String);
  }
  public abstract class SQLiteOpenHelper {
  public abstract class SQLiteOpenHelper implements java.lang.AutoCloseable {
    ctor public SQLiteOpenHelper(android.content.Context, java.lang.String, android.database.sqlite.SQLiteDatabase.CursorFactory, int);
    ctor public SQLiteOpenHelper(android.content.Context, java.lang.String, android.database.sqlite.SQLiteDatabase.CursorFactory, int, android.database.DatabaseErrorHandler);
    ctor public SQLiteOpenHelper(android.content.Context, java.lang.String, int, android.database.sqlite.SQLiteDatabase.OpenParams);
+3 −0
Original line number Diff line number Diff line
@@ -4107,6 +4107,9 @@ package android.os {
    method public boolean isSystem();
    method public static int myUserId();
    method public static android.os.UserHandle of(int);
    field public static final android.os.UserHandle ALL;
    field public static final android.os.UserHandle CURRENT;
    field public static final android.os.UserHandle SYSTEM;
    field public static final int USER_NULL = -10000; // 0xffffd8f0
  }

+3 −0
Original line number Diff line number Diff line
@@ -259,6 +259,7 @@ package android.content {
  }

  public abstract class Context {
    method public android.content.Context createPackageContextAsUser(java.lang.String, int, android.os.UserHandle) throws android.content.pm.PackageManager.NameNotFoundException;
    method public abstract java.lang.String getOpPackageName();
    method public android.os.UserHandle getUser();
    method public int getUserId();
@@ -765,6 +766,8 @@ package android.os {
    method public static int getAppId(int);
    method public int getIdentifier();
    method public static boolean isApp(int);
    field public static final android.os.UserHandle ALL;
    field public static final android.os.UserHandle CURRENT;
    field public static final android.os.UserHandle SYSTEM;
  }

+0 −2
Original line number Diff line number Diff line
@@ -1001,8 +1001,6 @@ Landroid/os/UserHandle;->AID_APP_START:I
Landroid/os/UserHandle;->AID_CACHE_GID_START:I
Landroid/os/UserHandle;->AID_ROOT:I
Landroid/os/UserHandle;->AID_SHARED_GID_START:I
Landroid/os/UserHandle;->ALL:Landroid/os/UserHandle;
Landroid/os/UserHandle;->CURRENT:Landroid/os/UserHandle;
Landroid/os/UserHandle;->CURRENT_OR_SELF:Landroid/os/UserHandle;
Landroid/os/UserHandle;->ERR_GID:I
Landroid/os/UserHandle;->formatUid(Ljava/io/PrintWriter;I)V
+1 −1
Original line number Diff line number Diff line
@@ -2131,7 +2131,7 @@ public final class ActivityThread extends ClientTransactionHandler {
            ai = getPackageManager().getApplicationInfo(packageName,
                    PackageManager.GET_SHARED_LIBRARY_FILES
                            | PackageManager.MATCH_DEBUG_TRIAGED_MISSING,
                    userId);
                    (userId < 0) ? UserHandle.myUserId() : userId);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
Loading