导航菜单

页面标题

页面副标题

爱心e站 v1.0.0 - d.java 源代码

正在查看: 爱心e站 v1.0.0 应用的 d.java JAVA 源代码文件

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


package com.iflytek.sunflower;

import android.content.Context;
import android.content.SharedPreferences;
import com.iflytek.sunflower.c.g;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringWriter;
import org.json.JSONException;
import org.json.JSONObject;

public class d {

    private static long f875a = 2097152;

    public static long a(Context context, String str) {
        File file = new File(context.getFilesDir(), str);
        if (file.exists()) {
            return file.length();
        }
        return 0L;
    }

    public static SharedPreferences a(Context context) {
        return context.getSharedPreferences("iflytek_state_" + context.getPackageName(), 0);
    }

    public static void a(Context context, String str, Long l) {
        SharedPreferences.Editor edit = a(context).edit();
        edit.putLong(str, l.longValue());
        edit.commit();
    }

    public static synchronized void a(Context context, String str, String str2, int i) {
        synchronized (d.class) {
            if (str != null) {
                if (!str.equals("")) {
                    try {
                        String c = c(context);
                        if (str2 == null) {
                            str2 = c;
                        }
                        if (0 == i) {
                            i = 0;
                        }
                        FileOutputStream openFileOutput = context.openFileOutput(str2, i);
                        openFileOutput.write(str.getBytes());
                        openFileOutput.flush();
                        openFileOutput.close();
                        g.a("Collector", "write to file success");
                    } catch (IOException e) {
                        g.d("Collector", "write to file error.");
                    }
                }
            }
        }
    }

    private static boolean a(File file) {
        long length = file.length();
        g.a("Collector", "file length:" + length);
        return file.exists() && length > f875a;
    }

    public static SharedPreferences b(Context context) {
        return context.getSharedPreferences("iflytek_online_" + context.getPackageName(), 0);
    }

    public static String c(Context context) {
        return "iflytek_cached_" + context.getPackageName();
    }

    public static String d(Context context) {
        return "iflytek_log_" + context.getPackageName();
    }

    public static synchronized JSONObject e(Context context) {
        JSONObject jSONObject = null;
        synchronized (d.class) {
            String c = c(context);
            try {
                File file = new File(context.getFilesDir(), c);
                if (a(file)) {
                    file.delete();
                    g.c("Collector", "delete local file which beyond 2MB");
                } else {
                    FileInputStream openFileInput = context.openFileInput(c);
                    try {
                        try {
                            InputStreamReader inputStreamReader = new InputStreamReader(openFileInput);
                            char[] cArr = new char[1024];
                            StringWriter stringWriter = new StringWriter();
                            while (true) {
                                int read = inputStreamReader.read(cArr);
                                if (-1 == read) {
                                    break;
                                }
                                stringWriter.write(cArr, 0, read);
                            }
                            String stringWriter2 = stringWriter.toString();
                            openFileInput.close();
                            JSONObject jSONObject2 = new JSONObject(stringWriter2);
                            if (jSONObject2.length() != 0) {
                                jSONObject = jSONObject2;
                            }
                        } catch (Exception e) {
                            g.d("Collector", "read from local file error. ", e);
                            openFileInput.close();
                        }
                    } catch (Throwable th) {
                        openFileInput.close();
                        throw th;
                    }
                }
            } catch (FileNotFoundException e2) {
            } catch (IOException e3) {
                g.d("Collector", e3.toString());
            } catch (JSONException e4) {
                g(context);
                g.d("Collector", "local JSONObject error.", e4);
            } catch (Throwable th2) {
            }
        }
        return jSONObject;
    }

    public static synchronized String f(Context context) {
        String str = null;
        synchronized (d.class) {
            String d = d(context);
            try {
                File file = new File(context.getFilesDir(), d);
                if (a(file)) {
                    file.delete();
                    g.c("Collector", "delete local file which beyond 2MB");
                } else {
                    FileInputStream openFileInput = context.openFileInput(d);
                    try {
                        try {
                            InputStreamReader inputStreamReader = new InputStreamReader(openFileInput);
                            char[] cArr = new char[1024];
                            StringWriter stringWriter = new StringWriter();
                            while (true) {
                                int read = inputStreamReader.read(cArr);
                                if (-1 == read) {
                                    break;
                                }
                                stringWriter.write(cArr, 0, read);
                            }
                            String stringWriter2 = stringWriter.toString();
                            openFileInput.close();
                            str = stringWriter2;
                        } catch (Exception e) {
                            g.d("Collector", "read from local file error. ", e);
                            openFileInput.close();
                        }
                    } catch (Throwable th) {
                        openFileInput.close();
                        throw th;
                    }
                }
            } catch (FileNotFoundException e2) {
            } catch (IOException e3) {
                g.d("Collector", e3.toString());
            } catch (Exception e4) {
            }
        }
        return str;
    }

    public static void g(Context context) {
        context.deleteFile(c(context));
    }
}