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

Commit f143a2eb authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Ignore GrantCredentials call with unexpected calling uid." into pi-dev...

Merge "Ignore GrantCredentials call with unexpected calling uid." into pi-dev am: 54090718 am: 9bca2e2c am: 36fabac3 am: 4b9ee685 am: 50f534a8

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12933114

Change-Id: I83bc7b71b6aa99c5fef803fd55075f56df23ec1b
parents 655789af 50f534a8
Loading
Loading
Loading
Loading
+28 −6
Original line number Diff line number Diff line
@@ -16,16 +16,23 @@
package android.accounts;

import android.app.Activity;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.LinearLayout;
import android.view.View;
import android.view.LayoutInflater;
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;
import android.widget.TextView;

import com.android.internal.R;

import java.io.IOException;
@@ -42,6 +49,7 @@ public class GrantCredentialsPermissionActivity extends Activity implements View
    private Account mAccount;
    private String mAuthTokenType;
    private int mUid;
    private int mCallingUid;
    private Bundle mResultBundle = null;
    protected LayoutInflater mInflater;

@@ -74,6 +82,20 @@ 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);
        }

        if (!UserHandle.isSameApp(mCallingUid, Process.SYSTEM_UID) && mCallingUid != mUid) {
            setResult(Activity.RESULT_CANCELED);
            finish();
            return;
        }

        String accountTypeLabel;
        try {
            accountTypeLabel = getAccountLabel(mAccount);