智能工厂.apk(点击下载) / ActionHelper.java


package cn.jpush.android.local;

import android.content.Context;
import android.content.Intent;
import cn.jiguang.api.JCoreManager;
import cn.jiguang.internal.JConstants;
import cn.jpush.android.api.CallBackParams;
import cn.jpush.android.api.CustomMessage;
import cn.jpush.android.api.NotificationMessage;
import cn.jpush.android.api.TagAliasCallback;
import cn.jpush.android.helper.JCoreHelper;
import cn.jpush.android.helper.Logger;
import cn.jpush.android.service.JPushMessageReceiver;
import cn.jpush.android.u.e;
import java.util.Set;

public class ActionHelper {
    private static final String TAG = "ActionHelper";
    private static volatile ActionHelper actionHelper;
    private static final Object locker = new Object();
    private JPushAction jPushAction;
    private cn.jpush.android.q.a loadedResource;

    /* access modifiers changed from: package-private */
    public class a extends e {
        private Context b;
        private String c;
        private Object d;

        public a(Context context, String str, Object obj) {
            this.b = context;
            this.c = str;
            this.d = obj;
            this.e = "ActionHelper#Action";
        }

        @Override // cn.jpush.android.u.e
        public void a() {
            try {
                ActionHelper.this.initLoad(this.b);
                ActionHelper.this.jPushAction.handleAction(this.b, this.c, this.d);
            } catch (Throwable th) {
                th.printStackTrace();
            }
        }
    }

    /* access modifiers changed from: package-private */
    public class b extends e {
        private Context b;
        private String c;
        private int d;
        private Set<String> f;
        private CallBackParams g;

        public b(Context context, String str, Set<String> set, int i, CallBackParams callBackParams) {
            this.g = callBackParams;
            this.c = str;
            this.d = i;
            this.b = context;
            this.f = set;
            this.e = "ActionHelper#TagAliasAction";
        }

        @Override // cn.jpush.android.u.e
        public void a() {
            try {
                ActionHelper.this.initLoad(this.b);
                ActionHelper.this.jPushAction.setAliasAndTags(this.b, this.c, this.f, this.g);
            } catch (Throwable th) {
                th.printStackTrace();
            }
        }
    }

    private ActionHelper() {
        JCoreManager.onEvent(null, JPushConstants.SDK_TYPE, 13, TAG, null, new Object[0]);
    }

    public static ActionHelper getInstance() {
        if (actionHelper == null) {
            synchronized (locker) {
                if (actionHelper == null) {
                    actionHelper = new ActionHelper();
                }
            }
        }
        return actionHelper;
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private synchronized void initLoad(Context context) {
        if (this.jPushAction == null) {
            try {
                if (JPushConstants.SUPPORT_DY && JConstants.SDK_VERSION_INT >= 220) {
                    long currentTimeMillis = System.currentTimeMillis();
                    this.loadedResource = cn.jpush.android.q.a.a(context);
                    Logger.d(TAG, "load use time:" + (System.currentTimeMillis() - currentTimeMillis) + ",lr:" + this.loadedResource);
                    if (this.loadedResource != null) {
                        Class b2 = this.loadedResource.b("cn.p.jpush.JPushActionImpl");
                        Logger.d(TAG, "load from cloud");
                        this.jPushAction = (JPushAction) b2.newInstance();
                    }
                }
            } catch (Throwable th) {
                Logger.ww(TAG, "try l p failed:" + th.getMessage());
            }
            if (this.jPushAction == null) {
                this.jPushAction = new cn.jpush.android.k.a();
            }
        }
    }

    public Object beforLogin(Context context, String str, int i, String str2) {
        initLoad(context);
        return this.jPushAction.beforLogin(context, str, i, str2);
    }

    public void doAction(Context context, String str, Object obj) {
        Logger.dd(TAG, "doAction:" + str);
        JCoreHelper.majorExecutor(context, TAG, new a(context, str, obj));
    }

    public void doSingleAction(Context context, String str, Object obj) {
        Logger.dd(TAG, "doSingleAction: " + str);
        JCoreHelper.futureExecutor(context, TAG, new a(context, str, obj));
    }

    public ProxyActivityAction getPopWinActivity(Context context) {
        initLoad(context);
        return this.jPushAction.getPopWinActivity(context);
    }

    public ProxyActivityAction getPushActivity(Context context) {
        initLoad(context);
        return this.jPushAction.getPushActivity(context);
    }

    public int getResourceID(Context context, String str, String str2, String str3) {
        String str4;
        StringBuilder sb;
        String str5;
        int i;
        cn.jpush.android.q.a aVar = this.loadedResource;
        if (aVar != null) {
            i = aVar.a(str2, str);
            str5 = TAG;
            sb = new StringBuilder();
            str4 = "[getResourceID] try load:";
        } else {
            i = context.getResources().getIdentifier(str, str2, str3);
            str5 = TAG;
            sb = new StringBuilder();
            str4 = "[getResourceID]:";
        }
        sb.append(str4);
        sb.append(i);
        Logger.d(str5, sb.toString());
        return i;
    }

    public String getSdkVersion(String str) {
        JPushAction jPushAction2 = this.jPushAction;
        return jPushAction2 != null ? jPushAction2.getSdkVersion(str) : JPushConstants.SDK_VERSION_NAME;
    }

    public void handleNotificationIntent(Context context, Intent intent) {
        initLoad(context);
        this.jPushAction.handleNotificationIntent(context, intent);
    }

    public boolean isSupportedCMD(String str, int i) {
        JPushAction jPushAction2 = this.jPushAction;
        return jPushAction2 != null ? jPushAction2.isSupportedCMD(str, i) : i == 3 || i == 29 || i == 28 || i == 27 || i == 10 || i == 26 || i == 25;
    }

    public void onJPushMessageReceive(Context context, JPushMessageReceiver jPushMessageReceiver, Intent intent) {
        initLoad(context);
        this.jPushAction.onJPushMessageReceive(context, jPushMessageReceiver, intent);
    }

    public void onMessage(Context context, CustomMessage customMessage) {
        initLoad(context);
        this.jPushAction.onMessage(context, customMessage);
    }

    public void onMultiAction(Context context, Intent intent) {
        initLoad(context);
        this.jPushAction.onMultiAction(context, intent);
    }

    public void onNotifyMessageArrived(Context context, NotificationMessage notificationMessage) {
        initLoad(context);
        this.jPushAction.onNotifyMessageArrived(context, notificationMessage);
    }

    public void onNotifyMessageOpened(Context context, NotificationMessage notificationMessage) {
        initLoad(context);
        this.jPushAction.onNotifyMessageOpened(context, notificationMessage);
    }

    public void onTagAliasResponse(Context context, long j, int i, Intent intent) {
        initLoad(context);
        this.jPushAction.onTagAliasResponse(context, j, i, intent);
    }

    public void setAliasAndTagsWithCallBack(Context context, String str, Set<String> set, TagAliasCallback tagAliasCallback, int i, int i2) {
        JCoreHelper.majorExecutor(context, TAG, new b(context, str, set, 0, new CallBackParams(str, set, tagAliasCallback, System.currentTimeMillis(), i, i2)));
    }

    public void setAliasWithCallBack(Context context, int i, String str, int i2, int i3) {
        JCoreHelper.majorExecutor(context, TAG, new b(context, str, null, i, new CallBackParams(i, str, System.currentTimeMillis(), i2, i3)));
    }

    public void setTagsWithCallBack(Context context, int i, Set<String> set, int i2, int i3) {
        JCoreHelper.majorExecutor(context, TAG, new b(context, null, set, i, new CallBackParams(i, set, System.currentTimeMillis(), i2, i3)));
    }
}