导航菜单

页面标题

页面副标题

Life Church v15.20.21 - RaygunPostService.java 源代码

正在查看: Life Church v15.20.21 应用的 RaygunPostService.java JAVA 源代码文件

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


package main.java.com.mindscapehq.android.raygun4android;

import android.app.Service;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.os.IBinder;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;

public class RaygunPostService extends Service {
    private Intent intent;
    private int tCount = 0;

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    static int access$110(RaygunPostService raygunPostService) {
        int i = raygunPostService.tCount;
        raygunPostService.tCount = i - 1;
        return i;
    }

    @Override
    public int onStartCommand(Intent intent, int i, int i2) {
        this.intent = intent;
        final Bundle extras = intent.getExtras();
        if (extras == null) {
            return 2;
        }
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                String str = (String) extras.get("msg");
                String str2 = (String) extras.get("apikey");
                if (!"True".equals((String) extras.get("isPulse"))) {
                    if (RaygunPostService.this.hasInternetConnection()) {
                        RaygunClient.post(str2, str);
                    } else {
                        synchronized (this) {
                            ArrayList arrayList = new ArrayList(Arrays.asList(RaygunPostService.this.getCacheDir().listFiles()));
                            Iterator it = arrayList.iterator();
                            int i3 = 0;
                            while (it.hasNext()) {
                                File file = (File) it.next();
                                String str3 = Integer.toString(i3) + ".raygun";
                                if (RaygunClient.getExtension(file.getName()).equals("raygun") && !file.getName().equals(str3)) {
                                    break;
                                } else if (i3 < 64) {
                                    i3++;
                                } else {
                                    ((File) arrayList.get(0)).delete();
                                }
                            }
                            File file2 = new File(RaygunPostService.this.getCacheDir(), Integer.toString(i3) + ".raygun");
                            try {
                                MessageApiKey messageApiKey = new MessageApiKey(str2, str);
                                ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream(file2));
                                objectOutputStream.writeObject(messageApiKey);
                                objectOutputStream.close();
                            } catch (FileNotFoundException e) {
                                RaygunLogger.e("Error creating file when caching message to filesystem - " + e.getMessage());
                            } catch (IOException e2) {
                                RaygunLogger.e("Error writing message to filesystem - " + e2.getMessage());
                            }
                        }
                    }
                } else {
                    RaygunClient.postPulseMessage(str2, str);
                }
                RaygunPostService.access$110(RaygunPostService.this);
                if (RaygunPostService.this.tCount == 0) {
                    RaygunPostService.this.stopSelf();
                }
            }
        });
        thread.setDaemon(true);
        this.tCount++;
        thread.start();
        return 2;
    }

    public boolean hasInternetConnection() {
        ConnectivityManager connectivityManager = (ConnectivityManager) getApplicationContext().getSystemService("connectivity");
        return connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isConnectedOrConnecting();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        stopService(this.intent);
    }
}