导航菜单

页面标题

页面副标题

SpeedCash v6.5.1482 - BBDonwloadPdfService.java 源代码

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

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


package com.bm.sc.bebasbayar.service;

import android.app.IntentService;
import android.content.Context;
import android.content.Intent;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.bm.sc.bebasbayar.message.qr.DataMessage;
import com.bm.sc.bebasbayar.setting.ApiConfig;
import com.bm.sc.bebasbayar.setting.session.ConfigSession;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.concurrent.TimeUnit;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Response;
import okhttp3.ResponseBody;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Call;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.http.GET;
import retrofit2.http.Query;

public class BBDonwloadPdfService extends IntentService {
    public static final String ACTION_COMPLETE = "BBDonwloadPdfService.ACTION_COMPLETE";
    public static final String EXTRA_RESULT = "result";
    public final String a;

    public enum BBDonwloadPdfServicePathType {
        PRINT_STNK_PATH,
        OTHER_PATH;

        public String getPathValue() {
            int i = b.a[ordinal()];
            if (i == 1) {
                return "samsatjatim/print-stnk";
            }
            if (i == 2) {
                return "";
            }
            throw new IllegalArgumentException("Unexpected value: " + this);
        }
    }

    public interface BBDownloadPdfApiService {
        @GET("samsatjatim/print-stnk")
        Call<ResponseBody> getTbpkp(@Query("user_id") String str, @Query("id_transaksi") String str2);
    }

    public class a implements Interceptor {
        public final String a;

        public a(String str) {
            this.a = str;
        }

        @NonNull
        public Response intercept(Interceptor.Chain chain) throws IOException {
            return chain.proceed(chain.request().newBuilder().addHeader("Authorization", " Bearer " + this.a).addHeader("Cache-Control", "no-cache, no-store, must-revalidate").build());
        }
    }

    public static class b {
        public static final int[] a;

        static {
            int[] iArr = new int[BBDonwloadPdfServicePathType.values().length];
            a = iArr;
            try {
                iArr[BBDonwloadPdfServicePathType.PRINT_STNK_PATH.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                a[BBDonwloadPdfServicePathType.OTHER_PATH.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
        }
    }

    public BBDonwloadPdfService() {
        super("BBDonwloadPdfService");
        this.a = "BBDonwloadPdfService";
    }

    public final void a(Intent intent, BBDownloadPdfApiService bBDownloadPdfApiService) {
        try {
            String stringExtra = intent.getStringExtra("user_id");
            String stringExtra2 = intent.getStringExtra(DataMessage.ID_TRANSAKSI);
            String stringExtra3 = intent.getStringExtra("no_pol");
            retrofit2.Response execute = bBDownloadPdfApiService.getTbpkp(stringExtra, stringExtra2).execute();
            if (!execute.isSuccessful() || execute.body() == null) {
                StringBuilder sb = new StringBuilder();
                sb.append("error getPrintStnk: ");
                sb.append(execute.message());
                c();
            } else {
                b((ResponseBody) execute.body(), stringExtra3);
            }
        } catch (Exception e) {
            StringBuilder sb2 = new StringBuilder();
            sb2.append("error getPrintStnk: ");
            sb2.append(e.getMessage());
            c();
        }
    }

    public final void b(ResponseBody responseBody, String str) {
        FileOutputStream fileOutputStream;
        try {
            byte[] bytes = responseBody.bytes();
            Calendar calendar = Calendar.getInstance();
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yy-MM-dd");
            File file = new File(getCacheDir(), "eTBPKP-" + str + "-" + simpleDateFormat.format(calendar.getTime()) + ".pdf");
            try {
                fileOutputStream = new FileOutputStream(file);
            } catch (IOException unused) {
                c();
            }
            try {
                fileOutputStream.write(bytes);
                fileOutputStream.close();
                StringBuilder sb = new StringBuilder();
                sb.append("handlePrintStnk:: ");
                sb.append(file.getAbsolutePath());
                Intent intent = new Intent(ACTION_COMPLETE);
                intent.putExtra(EXTRA_RESULT, file.getAbsolutePath());
                sendBroadcast(intent);
            } catch (Throwable th) {
                try {
                    fileOutputStream.close();
                } catch (Throwable th2) {
                    th.addSuppressed(th2);
                }
                throw th;
            }
        } catch (Exception e) {
            c();
            StringBuilder sb2 = new StringBuilder();
            sb2.append("error handlePrintStnk:: ");
            sb2.append(e.getMessage());
        }
    }

    public final void c() {
        Intent intent = new Intent(ACTION_COMPLETE);
        intent.putExtra(EXTRA_RESULT, "");
        sendBroadcast(intent);
    }

    @Override
    public void onHandleIntent(@Nullable Intent intent) {
        if (intent == null) {
            return;
        }
        String stringExtra = intent.getStringExtra("host");
        String stringExtra2 = intent.getStringExtra(ConfigSession.KEY_WIKI_PATH);
        String retrieve = new ConfigSession(getApplicationContext()).retrieve(ConfigSession.PROPERTY_APP_CENTRAL_API_2);
        try {
            OkHttpClient.Builder addInterceptor = new OkHttpClient.Builder().addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.NONE)).addInterceptor(new a(retrieve));
            TimeUnit timeUnit = TimeUnit.SECONDS;
            BBDownloadPdfApiService bBDownloadPdfApiService = (BBDownloadPdfApiService) new Retrofit.Builder().baseUrl(ApiConfig.getBaseUrl()[0] + stringExtra).addConverterFactory(GsonConverterFactory.create()).client(addInterceptor.readTimeout(10L, timeUnit).connectTimeout(10L, timeUnit).writeTimeout(10L, timeUnit).retryOnConnectionFailure(true).build()).build().create(BBDownloadPdfApiService.class);
            if (stringExtra2.equals(BBDonwloadPdfServicePathType.PRINT_STNK_PATH.getPathValue())) {
                a(intent, bBDownloadPdfApiService);
            } else if (stringExtra2.equals(BBDonwloadPdfServicePathType.OTHER_PATH.getPathValue())) {
                c();
            }
        } catch (Exception e) {
            StringBuilder sb = new StringBuilder();
            sb.append("error onHandleIntent: ");
            sb.append(e.getMessage());
            c();
        }
    }

    public void startGetTbpkpService(Context context, String str, BBDonwloadPdfServicePathType bBDonwloadPdfServicePathType, String str2, String str3, String str4) {
        Intent intent = new Intent(context, (Class<?>) BBDonwloadPdfService.class);
        intent.putExtra("host", str);
        intent.putExtra(ConfigSession.KEY_WIKI_PATH, bBDonwloadPdfServicePathType.getPathValue());
        intent.putExtra("user_id", str2);
        intent.putExtra(DataMessage.ID_TRANSAKSI, str3);
        intent.putExtra("no_pol", str4);
        context.startService(intent);
    }
}