小红书.apk(点击下载) / a.java


package v8;

import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import d9.f;
import d9.u;
import d9.y;
import d9.z;
import java.util.List;
import u8.d;
import u8.e;
import u8.p;

/* compiled from: CommandBridge */
public final class a {
    public static void a(Context context, Intent intent) throws Exception {
        if (context != null) {
            try {
                context.startService(intent);
            } catch (Exception e14) {
                u.b("CommandBridge", "start service error", e14);
                intent.setComponent(null);
                context.sendBroadcast(intent);
            }
        } else {
            u.n("CommandBridge", "enter startService context is null");
            throw new Exception("context is null");
        }
    }

    public static void b(Context context, String str, p pVar) {
        boolean i10 = pVar.i();
        e b14 = e.b(context, i10 ? "com.vivo.vms.upstageservice" : "com.vivo.vms.aidlservice");
        boolean d14 = b14.d();
        if (TextUtils.isEmpty(pVar.a())) {
            pVar.c(context.getPackageName());
        }
        if (d14 && !"com.vivo.pushservice".equals(context.getPackageName())) {
            d dVar = new d(pVar.a(), str, new Bundle());
            pVar.d(dVar);
            if (!b14.e(dVar.m())) {
                u.h("CommandBridge", "send command error by aidl");
                u.m(context, "send command error by aidl");
            } else {
                return;
            }
        }
        Intent intent = new Intent("com.vivo.pushservice.action.METHOD");
        intent.setPackage(str);
        intent.setClassName(str, i10 ? "com.vivo.push.sdk.service.UpstageService" : "com.vivo.push.sdk.service.PushService");
        pVar.b(intent);
        try {
            a(context, intent);
        } catch (Exception e14) {
            u.b("CommandBridge", "CommandBridge startService exception: ", e14);
        }
    }

    public static void c(Context context, p pVar, String str) {
        try {
            boolean j14 = y.j(context, str);
            String str2 = j14 ? "com.vivo.pushservice.action.RECEIVE" : "com.vivo.pushclient.action.RECEIVE";
            if (TextUtils.isEmpty(str)) {
                u.m(context, "消息接受者包名为空!");
                throw new Exception("消息接受者包名为空!");
            } else if (j14 || d(context, str2, str)) {
                if (TextUtils.isEmpty(pVar.a())) {
                    pVar.c(context.getPackageName());
                }
                Intent intent = new Intent();
                intent.setFlags(1048576);
                if (!TextUtils.isEmpty(str2)) {
                    intent.setAction(str2);
                }
                intent.setPackage(str);
                intent.setClassName(str, j14 ? "com.vivo.push.sdk.service.CommandService" : "com.vivo.push.sdk.service.CommandClientService");
                intent.putExtra("security_avoid_pull", f.a(context).b("com.vivo.pushservice"));
                pVar.f(intent);
                intent.putExtra("command_type", "reflect_receiver");
                if (Build.VERSION.SDK_INT >= 18) {
                    intent.putExtra("security_avoid_pull_rsa", x8.d.b(context).a().a("com.vivo.pushservice"));
                    intent.putExtra("security_avoid_rsa_public_key", z.a(x8.d.b(context).a().a()));
                }
                a(context, intent);
            }
        } catch (Exception e14) {
            u.b("CommandBridge", "CommandBridge sendCommandToClient exception", e14);
        }
    }

    public static boolean d(Context context, String str, String str2) {
        Intent intent = new Intent(str);
        intent.setPackage(str2);
        try {
            List<ResolveInfo> d14 = n02.e.d(context.getPackageManager(), intent, 576);
            if (d14 != null) {
                if (d14.size() > 0) {
                    return true;
                }
            }
            u.h("CommandBridge", "action check error:action>>" + str + ";pkgname>>" + str2);
            return false;
        } catch (Exception unused) {
            u.h("CommandBridge", "queryBroadcastReceivers error");
            return false;
        }
    }
}