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

Commit 959d41c6 authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Move launched activity info getter to ActivityClientController"

parents 77fc882f f90b2d46
Loading
Loading
Loading
Loading
+2 −13
Original line number Diff line number Diff line
@@ -16,16 +16,12 @@
package android.accounts;

import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityTaskManager;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.Process;
import android.os.UserHandle;
import android.util.Log;
@@ -71,15 +67,8 @@ public class ChooseAccountActivity extends Activity {
            return;
        }

        try {
            IBinder activityToken = getActivityToken();
            mCallingUid = ActivityTaskManager.getService().getLaunchedFromUid(activityToken);
            mCallingPackage = ActivityTaskManager.getService().getLaunchedFromPackage(
                    activityToken);
        } catch (RemoteException re) {
            // Couldn't figure out caller details
            Log.w(getClass().getSimpleName(), "Unable to get caller identity \n" + re);
        }
        mCallingUid = getLaunchedFromUid();
        mCallingPackage = getLaunchedFromPackage();

        if (UserHandle.isSameApp(mCallingUid, Process.SYSTEM_UID) &&
            getIntent().getStringExtra(AccountManager.KEY_ANDROID_PACKAGE_NAME) != null) {
+7 −20
Original line number Diff line number Diff line
@@ -15,16 +15,12 @@
 */
package android.accounts;

import android.app.ActivityTaskManager;
import com.google.android.collect.Sets;

import android.app.Activity;
import android.app.ActivityManager;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;
import android.text.TextUtils;
@@ -144,23 +140,14 @@ public class ChooseTypeAndAccountActivity extends Activity
                    + savedInstanceState + ")");
        }

        String message = null;

        try {
            IBinder activityToken = getActivityToken();
            mCallingUid = ActivityTaskManager.getService().getLaunchedFromUid(activityToken);
            mCallingPackage = ActivityTaskManager.getService().getLaunchedFromPackage(
                    activityToken);
        mCallingUid = getLaunchedFromUid();
        mCallingPackage = getLaunchedFromPackage();
        if (mCallingUid != 0 && mCallingPackage != null) {
            Bundle restrictions = UserManager.get(this)
                    .getUserRestrictions(new UserHandle(UserHandle.getUserId(mCallingUid)));
            mDisallowAddAccounts =
                    restrictions.getBoolean(UserManager.DISALLOW_MODIFY_ACCOUNTS, false);
        }
        } catch (RemoteException re) {
            // Couldn't figure out caller details
            Log.w(getClass().getSimpleName(), "Unable to get caller identity \n" + re);
        }

        // save some items we use frequently
        final Intent intent = getIntent();
+1 −11
Original line number Diff line number Diff line
@@ -16,18 +16,14 @@
package android.accounts;

import android.app.Activity;
import android.app.ActivityTaskManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Process;
import android.os.RemoteException;
import android.os.UserHandle;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
@@ -85,13 +81,7 @@ public class GrantCredentialsPermissionActivity extends Activity implements View
            return;
        }

        try {
            IBinder activityToken = getActivityToken();
            mCallingUid = ActivityTaskManager.getService().getLaunchedFromUid(activityToken);
        } catch (RemoteException re) {
            // Couldn't figure out caller details
            Log.w(getClass().getSimpleName(), "Unable to get caller identity \n" + re);
        }
        mCallingUid = getLaunchedFromUid();

        if (!UserHandle.isSameApp(mCallingUid, Process.SYSTEM_UID) && mCallingUid != mUid) {
            setResult(Activity.RESULT_CANCELED);
+17 −0
Original line number Diff line number Diff line
@@ -6229,6 +6229,23 @@ public class Activity extends ContextThemeWrapper
        return ActivityClient.getInstance().getCallingActivity(mToken);
    }

    /**
     * Returns the uid who started this activity.
     * @hide
     */
    public int getLaunchedFromUid() {
        return ActivityClient.getInstance().getLaunchedFromUid(getActivityToken());
    }

    /**
     * Returns the package who started this activity.
     * @hide
     */
    @Nullable
    public String getLaunchedFromPackage() {
        return ActivityClient.getInstance().getLaunchedFromPackage(getActivityToken());
    }

    /**
     * Control whether this activity's main window is visible.  This is intended
     * only for the special case of an activity that is not going to show a
+16 −0
Original line number Diff line number Diff line
@@ -221,6 +221,22 @@ public class ActivityClient {
        }
    }

    public int getLaunchedFromUid(IBinder token) {
        try {
            return getActivityClientController().getLaunchedFromUid(token);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    public String getLaunchedFromPackage(IBinder token) {
        try {
            return getActivityClientController().getLaunchedFromPackage(token);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    Bundle getActivityOptions(IBinder token) {
        try {
            return getActivityClientController().getActivityOptions(token);
Loading