Call Recorder v6.34.2版本的 MD5 值为:298659ce317c966b10d9947b76831521

以下内容为反编译后的 AuthActivity.java 源代码,内容仅作参考


package com.dropbox.core.android;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import com.google.android.gms.ads.RequestConfiguration;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import m2.a0;
import m2.h;
import m2.j;
import m2.k;
import m2.l;
import m2.m;
import m2.n;
import m2.r;
public class AuthActivity extends Activity {
    private static String[] A = null;
    private static String B = null;
    private static a0 C = null;
    private static m D = null;
    private static k E = null;
    private static String F = null;
    private static r G = null;
    private static final String f6126t = "com.dropbox.core.android.AuthActivity";
    private static d f6127u = new a();
    private static final Object f6128v = new Object();
    public static Intent f6129w = null;
    private static String f6130x;
    private static String f6131y;
    private static String f6132z;
    private String f6133a;
    private String f6134b;
    private String f6135c;
    private String[] f6136d;
    private String f6137e;
    private a0 f6138h;
    private l f6139k;
    private m f6140m;
    private k f6141n;
    private String f6142p;
    private r f6143q;
    private String f6144r = null;
    private boolean f6145s = false;

    static class a implements d {
        a() {
        }

        @Override
        public SecureRandom a() {
            return n2.a.a();
        }
    }

    static class b implements DialogInterface.OnClickListener {
        b() {
        }

        @Override
        public void onClick(DialogInterface dialogInterface, int i9) {
            dialogInterface.dismiss();
        }
    }

    class c implements Runnable {
        final Intent f6146a;
        final String f6147b;

        c(Intent intent, String str) {
            this.f6146a = intent;
            this.f6147b = str;
        }

        @Override
        public void run() {
            Log.d(AuthActivity.f6126t, "running startActivity in handler");
            try {
                if (com.dropbox.core.android.b.a(AuthActivity.this, this.f6146a) != null) {
                    AuthActivity.this.startActivity(this.f6146a);
                } else {
                    AuthActivity.this.t(this.f6147b);
                }
                AuthActivity.this.f6144r = this.f6147b;
                AuthActivity.q(null, null, null);
            } catch (ActivityNotFoundException e9) {
                Log.e(AuthActivity.f6126t, "Could not launch intent. User may have restricted profile", e9);
                AuthActivity.this.finish();
            }
        }
    }

    public interface d {
        SecureRandom a();
    }

    private class e extends AsyncTask<Void, Void, h> {
        private final String f6149a;

        e(AuthActivity authActivity, String str, a aVar) {
            this(str);
        }

        @Override
        public h doInBackground(Void... voidArr) {
            try {
                return AuthActivity.this.f6139k.e(AuthActivity.this.f6140m, this.f6149a, AuthActivity.this.f6133a, null, AuthActivity.this.f6141n);
            } catch (j e9) {
                String str = AuthActivity.f6126t;
                Log.e(str, "Token Request Failed: " + e9.getMessage());
                return null;
            }
        }

        private e(String str) {
            this.f6149a = str;
        }
    }

    private enum f {
        OAUTH2("oauth2:"),
        OAUTH2CODE("oauth2code:");
        
        private String f6154a;

        f(String str) {
            this.f6154a = str;
        }

        @Override
        public String toString() {
            return this.f6154a;
        }
    }

    private void h(Intent intent) {
        f6129w = intent;
        this.f6144r = null;
        q(null, null, null);
        finish();
    }

    public static boolean i(Context context, String str, boolean z8) {
        Intent intent = new Intent("android.intent.action.VIEW");
        String str2 = "db-" + str;
        intent.setData(Uri.parse(str2 + "://1/connect"));
        List<ResolveInfo> queryIntentActivities = context.getPackageManager().queryIntentActivities(intent, 0);
        if (queryIntentActivities != null && queryIntentActivities.size() != 0) {
            if (queryIntentActivities.size() <= 1) {
                ResolveInfo resolveInfo = queryIntentActivities.get(0);
                if (resolveInfo == null || resolveInfo.activityInfo == null || !context.getPackageName().equals(resolveInfo.activityInfo.packageName)) {
                    throw new IllegalStateException("There must be a " + AuthActivity.class.getName() + " within your app's package registered for your URI scheme (" + str2 + "). However, it appears that an activity in a different package is registered for that scheme instead. If you have multiple apps that all want to use the same accesstoken pair, designate one of them to do authentication and have the other apps launch it and then retrieve the token pair from it.");
                }
                return true;
            }
            if (z8) {
                AlertDialog.Builder builder = new AlertDialog.Builder(context);
                builder.setTitle("Security alert");
                builder.setMessage("Another app on your phone may be trying to pose as the app you are currently using. The malicious app can't access your account, but linking to Dropbox has been disabled as a precaution. Please contact support@dropbox.com.");
                builder.setPositiveButton("OK", new b());
                builder.show();
            } else {
                Log.w(f6126t, "There are multiple apps registered for the AuthActivity URI scheme (" + str2 + ").  Another app may be trying to  impersonate this app, so authentication will be disabled.");
            }
            return false;
        }
        throw new IllegalStateException("URI scheme in your app's manifest is not set up correctly. You should have a " + AuthActivity.class.getName() + " with the scheme: " + str2);
    }

    private String j() {
        Locale locale;
        if (this.f6138h != null) {
            String format = String.format(Locale.US, "%s=%s&%s=%s&%s=%s&%s=%s", "code_challenge", this.f6139k.c(), "code_challenge_method", "S256", "token_access_type", this.f6138h.toString(), "response_type", "code");
            if (this.f6142p != null) {
                format = format + String.format(locale, "&%s=%s", "scope", this.f6142p);
            }
            if (this.f6143q != null) {
                return format + String.format(locale, "&%s=%s", "include_granted_scopes", this.f6143q.toString());
            }
            return format;
        }
        throw new IllegalStateException("Extra Query Param should only be used in short live token flow.");
    }

    private String k() {
        String format = String.format(Locale.US, "oauth2code:%s:%s:%s", this.f6139k.c(), "S256", this.f6138h.toString());
        if (this.f6142p != null) {
            format = format + ":" + this.f6142p;
        }
        if (this.f6143q != null) {
            return format + ":" + this.f6143q.toString();
        }
        return format;
    }

    private String l() {
        byte[] bArr = new byte[16];
        n().nextBytes(bArr);
        StringBuilder sb = new StringBuilder();
        sb.append("oauth2:");
        for (int i9 = 0; i9 < 16; i9++) {
            sb.append(String.format("%02x", Integer.valueOf(bArr[i9] & 255)));
        }
        return sb.toString();
    }

    static Intent m() {
        Intent intent = new Intent("com.dropbox.android.AUTHENTICATE_V2");
        intent.setPackage("com.dropbox.android");
        return intent;
    }

    private static SecureRandom n() {
        d o9 = o();
        if (o9 != null) {
            return o9.a();
        }
        return new SecureRandom();
    }

    private static d o() {
        d dVar;
        synchronized (f6128v) {
            dVar = f6127u;
        }
        return dVar;
    }

    public static Intent p(Context context, String str, String str2, String[] strArr, String str3, String str4, String str5, a0 a0Var, m mVar, k kVar, String str6, r rVar) {
        if (str != null) {
            s(str, str2, strArr, str3, str4, str5, a0Var, mVar, kVar, str6, rVar);
            return new Intent(context, AuthActivity.class);
        }
        throw new IllegalArgumentException("'appKey' can't be null");
    }

    static void q(String str, String str2, String[] strArr) {
        r(str, str2, strArr, null);
    }

    static void r(String str, String str2, String[] strArr, String str3) {
        s(str, str2, strArr, str3, null, null, null, null, null, null, null);
    }

    static void s(String str, String str2, String[] strArr, String str3, String str4, String str5, a0 a0Var, m mVar, k kVar, String str6, r rVar) {
        f6130x = str;
        f6132z = str2;
        if (strArr == null) {
            strArr = new String[0];
        }
        A = strArr;
        B = str3;
        f6131y = str5;
        C = a0Var;
        D = mVar;
        if (kVar != null) {
            E = kVar;
        } else if (str4 != null) {
            k kVar2 = k.f24683e;
            E = new k(kVar2.h(), kVar2.i(), str4, kVar2.j());
        } else {
            E = k.f24683e;
        }
        F = str6;
        G = rVar;
    }

    public void t(String str) {
        Locale locale = Locale.getDefault();
        Locale locale2 = new Locale(locale.getLanguage(), locale.getCountry());
        String[] strArr = this.f6136d;
        ArrayList arrayList = new ArrayList(Arrays.asList("k", this.f6133a, "n", strArr.length > 0 ? strArr[0] : "0", "api", this.f6134b, "state", str));
        if (this.f6138h != null) {
            arrayList.add("extra_query_params");
            arrayList.add(j());
        }
        startActivity(new Intent("android.intent.action.VIEW", Uri.parse(n.g(locale2.toString(), this.f6141n.k(), "1/connect", (String[]) arrayList.toArray(new String[0])))));
    }

    @Override
    protected void onCreate(Bundle bundle) {
        this.f6133a = f6130x;
        this.f6134b = f6131y;
        this.f6135c = f6132z;
        this.f6136d = A;
        this.f6137e = B;
        this.f6138h = C;
        this.f6140m = D;
        this.f6141n = E;
        this.f6142p = F;
        this.f6143q = G;
        if (bundle == null) {
            f6129w = null;
            this.f6144r = null;
            this.f6139k = new l();
        } else {
            this.f6144r = bundle.getString("SIS_KEY_AUTH_STATE_NONCE");
            this.f6139k = new l(bundle.getString("SIS_KEY_PKCE_CODE_VERIFIER"));
        }
        setTheme(16973840);
        super.onCreate(bundle);
    }

    @Override
    protected void onNewIntent(Intent intent) {
        String str;
        String str2;
        String str3;
        String str4;
        Intent intent2 = null;
        if (this.f6144r == null) {
            h(null);
            return;
        }
        if (intent.hasExtra("ACCESS_TOKEN")) {
            str2 = intent.getStringExtra("ACCESS_TOKEN");
            str3 = intent.getStringExtra("ACCESS_SECRET");
            str4 = intent.getStringExtra("UID");
            str = intent.getStringExtra("AUTH_STATE");
        } else {
            Uri data = intent.getData();
            if (data == null || !"/connect".equals(data.getPath())) {
                str = null;
                str2 = null;
                str3 = null;
                str4 = null;
            } else {
                try {
                    str2 = data.getQueryParameter("oauth_token");
                    try {
                        str3 = data.getQueryParameter("oauth_token_secret");
                        try {
                            str4 = data.getQueryParameter("uid");
                        } catch (UnsupportedOperationException unused) {
                            str4 = null;
                        }
                    } catch (UnsupportedOperationException unused2) {
                        str3 = null;
                        str4 = str3;
                        str = null;
                        if (str2 != null) {
                            if (this.f6144r.equals(str)) {
                            }
                        }
                        h(intent2);
                    }
                } catch (UnsupportedOperationException unused3) {
                    str2 = null;
                    str3 = null;
                }
                try {
                    str = data.getQueryParameter("state");
                } catch (UnsupportedOperationException unused4) {
                    str = null;
                    if (str2 != null) {
                    }
                    h(intent2);
                }
            }
        }
        if (str2 != null && !str2.equals(RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED) && str3 != null && !str3.equals(RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED) && str4 != null && !str4.equals(RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED) && str != null && !str.equals(RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED)) {
            if (this.f6144r.equals(str)) {
                h(null);
                return;
            } else if (str2.equals(f.OAUTH2.toString())) {
                intent2 = new Intent();
                intent2.putExtra("ACCESS_TOKEN", str2);
                intent2.putExtra("ACCESS_SECRET", str3);
                intent2.putExtra("UID", str4);
            } else if (str2.equals(f.OAUTH2CODE.toString())) {
                try {
                    h hVar = new e(this, str3, null).execute(new Void[0]).get();
                    if (hVar != null) {
                        Intent intent3 = new Intent();
                        intent3.putExtra("ACCESS_TOKEN", hVar.a());
                        intent3.putExtra("ACCESS_SECRET", hVar.a());
                        intent3.putExtra("REFRESH_TOKEN", hVar.c());
                        intent3.putExtra("EXPIRES_AT", hVar.b());
                        intent3.putExtra("UID", hVar.e());
                        intent3.putExtra("CONSUMER_KEY", this.f6133a);
                        intent3.putExtra("SCOPE", hVar.d());
                        intent2 = intent3;
                    }
                } catch (Exception unused5) {
                }
            }
        }
        h(intent2);
    }

    @Override
    protected void onResume() {
        String l9;
        super.onResume();
        if (isFinishing()) {
            return;
        }
        if (this.f6144r != null || this.f6133a == null) {
            h(null);
            return;
        }
        f6129w = null;
        if (this.f6145s) {
            Log.w(f6126t, "onResume called again before Handler run");
            return;
        }
        Intent m9 = m();
        if (this.f6138h != null) {
            l9 = k();
            m9.putExtra("AUTH_QUERY_PARAMS", j());
        } else {
            l9 = l();
        }
        m9.putExtra("CONSUMER_KEY", this.f6133a);
        m9.putExtra("CONSUMER_SIG", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED);
        m9.putExtra("CALLING_PACKAGE", getPackageName());
        m9.putExtra("CALLING_CLASS", getClass().getName());
        m9.putExtra("AUTH_STATE", l9);
        m9.putExtra("DESIRED_UID", this.f6135c);
        m9.putExtra("ALREADY_AUTHED_UIDS", this.f6136d);
        m9.putExtra("SESSION_ID", this.f6137e);
        new Handler(Looper.getMainLooper()).post(new c(m9, l9));
        this.f6145s = true;
    }

    @Override
    protected void onSaveInstanceState(Bundle bundle) {
        super.onSaveInstanceState(bundle);
        bundle.putString("SIS_KEY_AUTH_STATE_NONCE", this.f6144r);
        bundle.putString("SIS_KEY_PKCE_CODE_VERIFIER", this.f6139k.d());
    }
}