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

Commit ad357d18 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Jeff Sharkey
Browse files

Pass in the user defined by Context.

The majority of Manager-style classes already use Context.getUserId()
when making calls into the OS, so clean up the remaining callers to
unify behind this strategy.

This gives @SystemApi developers a nice clean interface to interact
across user boundaries, instead of manually adding "AsUser" or
"ForUser" method variants, which would quickly become unsustainable.

Test: builds, boots
Bug: 72863821
Exempt-From-Owner-Approval: trivial changes
Change-Id: Ib772ec4438e57a2ad4950821b9432f9842998451
parent 4a740846
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -11616,15 +11616,15 @@ package android.content.res {
  public final class AssetManager implements java.lang.AutoCloseable {
    method public void close();
    method public final java.lang.String[] getLocales();
    method public final java.lang.String[] list(java.lang.String) throws java.io.IOException;
    method public final java.io.InputStream open(java.lang.String) throws java.io.IOException;
    method public final java.io.InputStream open(java.lang.String, int) throws java.io.IOException;
    method public final android.content.res.AssetFileDescriptor openFd(java.lang.String) throws java.io.IOException;
    method public final android.content.res.AssetFileDescriptor openNonAssetFd(java.lang.String) throws java.io.IOException;
    method public final android.content.res.AssetFileDescriptor openNonAssetFd(int, java.lang.String) throws java.io.IOException;
    method public final android.content.res.XmlResourceParser openXmlResourceParser(java.lang.String) throws java.io.IOException;
    method public final android.content.res.XmlResourceParser openXmlResourceParser(int, java.lang.String) throws java.io.IOException;
    method public java.lang.String[] getLocales();
    method public java.lang.String[] list(java.lang.String) throws java.io.IOException;
    method public java.io.InputStream open(java.lang.String) throws java.io.IOException;
    method public java.io.InputStream open(java.lang.String, int) throws java.io.IOException;
    method public android.content.res.AssetFileDescriptor openFd(java.lang.String) throws java.io.IOException;
    method public android.content.res.AssetFileDescriptor openNonAssetFd(java.lang.String) throws java.io.IOException;
    method public android.content.res.AssetFileDescriptor openNonAssetFd(int, java.lang.String) throws java.io.IOException;
    method public android.content.res.XmlResourceParser openXmlResourceParser(java.lang.String) throws java.io.IOException;
    method public android.content.res.XmlResourceParser openXmlResourceParser(int, java.lang.String) throws java.io.IOException;
    field public static final int ACCESS_BUFFER = 3; // 0x3
    field public static final int ACCESS_RANDOM = 1; // 0x1
    field public static final int ACCESS_STREAMING = 2; // 0x2
+1 −4
Original line number Diff line number Diff line
@@ -183,10 +183,7 @@ package android.content {
  }

  public abstract class Context {
    method public abstract int getUserId();
  }

  public class ContextWrapper extends android.content.Context {
    method public android.os.UserHandle getUser();
    method public int getUserId();
  }

+3 −3
Original line number Diff line number Diff line
@@ -680,7 +680,7 @@ public class AccountManager {
     */
    @NonNull
    public Account[] getAccountsByType(String type) {
        return getAccountsByTypeAsUser(type, Process.myUserHandle());
        return getAccountsByTypeAsUser(type, mContext.getUser());
    }

    /** @hide Same as {@link #getAccountsByType(String)} but for a specific user. */
@@ -2006,7 +2006,7 @@ public class AccountManager {
            final AccountManagerCallback<Bundle> callback,
            final Handler handler) {
        return confirmCredentialsAsUser(account, options, activity, callback, handler,
                Process.myUserHandle());
                mContext.getUser());
    }

    /**
@@ -3208,7 +3208,7 @@ public class AccountManager {
        return finishSessionAsUser(
                sessionBundle,
                activity,
                Process.myUserHandle(),
                mContext.getUser(),
                callback,
                handler);
    }
+1 −1
Original line number Diff line number Diff line
@@ -5832,7 +5832,7 @@ public class Activity extends ContextThemeWrapper
                        ActivityManager.INTENT_SENDER_ACTIVITY_RESULT, packageName,
                        mParent == null ? mToken : mParent.mToken,
                        mEmbeddedID, requestCode, new Intent[] { data }, null, flags, null,
                        UserHandle.myUserId());
                        getUserId());
            return target != null ? new PendingIntent(target) : null;
        } catch (RemoteException e) {
            // Empty
+6 −6
Original line number Diff line number Diff line
@@ -1691,7 +1691,7 @@ public class ActivityManager {
            if (maxNum < 0) {
                throw new IllegalArgumentException("The requested number of tasks should be >= 0");
            }
            return getService().getRecentTasks(maxNum, flags, UserHandle.myUserId()).getList();
            return getService().getRecentTasks(maxNum, flags, mContext.getUserId()).getList();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -2685,7 +2685,7 @@ public class ActivityManager {
    public boolean clearApplicationUserData(String packageName, IPackageDataObserver observer) {
        try {
            return getService().clearApplicationUserData(packageName, false,
                    observer, UserHandle.myUserId());
                    observer, mContext.getUserId());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -2724,7 +2724,7 @@ public class ActivityManager {
        try {
            @SuppressWarnings("unchecked")
            final ParceledListSlice<GrantedUriPermission> castedList = getService()
                    .getGrantedUriPermissions(packageName, UserHandle.myUserId());
                    .getGrantedUriPermissions(packageName, mContext.getUserId());
            return castedList;
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
@@ -2743,7 +2743,7 @@ public class ActivityManager {
    public void clearGrantedUriPermissions(String packageName) {
        try {
            getService().clearGrantedUriPermissions(packageName,
                    UserHandle.myUserId());
                    mContext.getUserId());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -3528,7 +3528,7 @@ public class ActivityManager {
    public void killBackgroundProcesses(String packageName) {
        try {
            getService().killBackgroundProcesses(packageName,
                    UserHandle.myUserId());
                    mContext.getUserId());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -3586,7 +3586,7 @@ public class ActivityManager {
    @SystemApi
    @RequiresPermission(Manifest.permission.FORCE_STOP_PACKAGES)
    public void forceStopPackage(String packageName) {
        forceStopPackageAsUser(packageName, UserHandle.myUserId());
        forceStopPackageAsUser(packageName, mContext.getUserId());
    }

    /**
Loading