导航菜单

页面标题

页面副标题

SpeedCash v6.5.1482 - BBCekBalanceService.java 源代码

正在查看: SpeedCash v6.5.1482 应用的 BBCekBalanceService.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.bm.sc.bebasbayar.service;

import android.app.IntentService;
import android.content.Intent;
import com.bm.sc.bebasbayar.handler.MessageComposer;
import com.bm.sc.bebasbayar.iface.BBCallback;
import com.bm.sc.bebasbayar.message.BusMessage;
import com.bm.sc.bebasbayar.service.BBCekBalanceService;
import com.bm.sc.bebasbayar.setting.ApiConfig;
import com.bm.sc.bebasbayar.setting.session.AppSession;
import com.bm.sc.bebasbayar.setting.session.ConfigSession;
import com.google.firebase.perf.network.FirebasePerfUrlConnection;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;
import java.util.Objects;
import java.util.Timer;
import java.util.TimerTask;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.EventBusException;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.json.JSONObject;

public class BBCekBalanceService extends IntentService {
    public static final String IGNORE_CACHE = "ign:cache";
    public static long j = 60000;
    public final String a;
    public BusMessage b;
    public StringBuilder c;
    public String d;
    public Timer e;
    public ConfigSession f;
    public AppSession g;
    public HttpURLConnection h;
    public boolean i;

    public class a extends TimerTask {
        public final URL a;
        public final HashMap b;

        public a(URL url, HashMap hashMap) {
            this.a = url;
            this.b = hashMap;
        }

        @Override
        public void run() {
            BBCekBalanceService.this.h = null;
            if (BBCekBalanceService.this.i) {
                BBCekBalanceService bBCekBalanceService = BBCekBalanceService.this;
                if (!bBCekBalanceService.d.equals(bBCekBalanceService.g.retrieve(AppSession.PROPERTY_MERCHANT_ID))) {
                    String unused = BBCekBalanceService.this.a;
                    if (BBCekBalanceService.this.e != null) {
                        BBCekBalanceService.this.e.cancel();
                        BBCekBalanceService.this.e = null;
                        BBCekBalanceService.this.l();
                    }
                }
                if (!BBCekBalanceService.this.g.isLogin()) {
                    String unused2 = BBCekBalanceService.this.a;
                    BBCekBalanceService.this.stopSelf();
                    if (BBCekBalanceService.this.e != null) {
                        BBCekBalanceService.this.e.cancel();
                        BBCekBalanceService.this.e = null;
                        return;
                    }
                    return;
                }
                if (!Boolean.parseBoolean(BBCekBalanceService.this.f.retrieve(ConfigSession.ALLOW_HIT_BALANCE_SCHEDULER))) {
                    String unused3 = BBCekBalanceService.this.a;
                    BBCekBalanceService.this.stopSelf();
                    if (BBCekBalanceService.this.e != null) {
                        BBCekBalanceService.this.e.cancel();
                        BBCekBalanceService.this.e = null;
                        return;
                    }
                    return;
                }
                String unused4 = BBCekBalanceService.this.a;
                try {
                    BBCekBalanceService.this.h = (HttpURLConnection) ((URLConnection) FirebasePerfUrlConnection.instrument(this.a.openConnection()));
                    BBCekBalanceService.this.h.setRequestMethod(MessageComposer.GET);
                    BBCekBalanceService.this.h.setReadTimeout(60000);
                    BBCekBalanceService.this.h.setConnectTimeout(60000);
                    for (String str : this.b.keySet()) {
                        BBCekBalanceService.this.h.setRequestProperty(str, (String) this.b.get(str));
                    }
                    if (BBCekBalanceService.this.h.getResponseCode() == 200) {
                        JSONObject jSONObject = new JSONObject(new BufferedReader(new InputStreamReader(BBCekBalanceService.this.h.getInputStream())).readLine());
                        if (jSONObject.getString("rc").equals("00")) {
                            BBCekBalanceService.this.o(Double.valueOf(jSONObject.getJSONObject("data").getDouble("balance")));
                        }
                    }
                } catch (Exception e) {
                    String unused5 = BBCekBalanceService.this.a;
                    Objects.requireNonNull(e.getMessage());
                }
            }
        }
    }

    public BBCekBalanceService() {
        super("BBCekBalanceService");
        this.a = BBCekBalanceService.class.getSimpleName();
        this.h = null;
    }

    public void m(Double d, int i, Boolean bool) {
        try {
            BusMessage busMessage = new BusMessage(1);
            this.b = busMessage;
            busMessage.setBalance(d.doubleValue());
        } catch (Exception unused) {
            this.b = null;
        }
        if (this.b != null) {
            EventBus.getDefault().post(this.b);
        }
    }

    public final void l() {
        StringBuilder sb = new StringBuilder();
        this.c = sb;
        sb.append(ApiConfig.getBaseUrl()[0]);
        sb.append("sc-api/user_balance?");
        sb.append("id_outlet=");
        sb.append(this.g.retrieve(AppSession.PROPERTY_MERCHANT_ID));
        this.d = this.g.retrieve(AppSession.PROPERTY_MERCHANT_ID);
        try {
            n(new URL(this.c.toString()));
        } catch (Exception e) {
            Objects.requireNonNull(e.getMessage());
        }
    }

    public final void n(URL url) {
        String str = "Bearer " + this.f.retrieve(ConfigSession.PROPERTY_APP_CENTRAL_API_2);
        HashMap hashMap = new HashMap();
        hashMap.put("Authorization", str);
        hashMap.put("Cache-Control", "no-cache, no-store, must-revalidate");
        Long.parseLong(this.f.retrieve(ConfigSession.HIT_BALANCE_INTERVAL));
        j = 60000L;
        Timer timer = new Timer();
        this.e = timer;
        timer.schedule(new a(url, hashMap), 1000L, j);
    }

    public final void o(final Double d) {
        this.g.storeSync(AppSession.PROPERTY_BALANCE, String.valueOf(d), new BBCallback() {
            @Override
            public final void do_callback(int i, Object obj) {
                BBCekBalanceService.this.m(d, i, (Boolean) obj);
            }
        });
    }

    @Override
    public void onHandleIntent(Intent intent) {
        this.g = new AppSession(getApplicationContext());
        this.f = new ConfigSession(getApplicationContext());
        this.i = true;
        try {
            if (!EventBus.getDefault().isRegistered(this)) {
                EventBus.getDefault().register(this);
            }
        } catch (EventBusException e) {
            Objects.requireNonNull(e.getMessage());
        }
        l();
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessageEvent(BusMessage busMessage) {
        if (busMessage.getEventType() != 3) {
            if (busMessage.getEventType() == 4) {
                this.i = true;
                l();
                return;
            }
            return;
        }
        HttpURLConnection httpURLConnection = this.h;
        if (httpURLConnection != null) {
            httpURLConnection.disconnect();
        }
        this.i = false;
        Timer timer = this.e;
        if (timer != null) {
            timer.cancel();
            this.e.purge();
        }
        this.e = null;
    }
}