-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
198 additions
and
540 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
app/src/main/java/com/sevtinge/hyperceiler/crash/service/CrashRecord.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package com.sevtinge.hyperceiler.crash.service; | ||
|
||
import static com.sevtinge.hyperceiler.utils.log.XposedLogUtils.logE; | ||
|
||
import com.sevtinge.hyperceiler.callback.ITAG; | ||
|
||
import org.json.JSONArray; | ||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
|
||
import java.util.ArrayList; | ||
|
||
/** | ||
* 崩溃记录数据库 | ||
*/ | ||
public class CrashRecord { | ||
public static final String TAG = ITAG.TAG + ": CrashRecord"; | ||
// public String label; | ||
public String pkg; | ||
public long time; | ||
public int count; | ||
|
||
public CrashRecord(String p, long t, int c) { | ||
// label = l; | ||
pkg = p; | ||
time = t; | ||
count = c; | ||
} | ||
|
||
public JSONObject toJSON() { | ||
JSONObject jsonObject = new JSONObject(); | ||
try { | ||
// jsonObject.put("l", label); | ||
jsonObject.put("p", pkg); | ||
jsonObject.put("t", time); | ||
jsonObject.put("c", count); | ||
return jsonObject; | ||
} catch (JSONException e) { | ||
logE(TAG, "Failed to convert JSON!" + e); | ||
} | ||
return jsonObject; | ||
} | ||
|
||
public JSONObject toJSONSmall() { | ||
JSONObject jsonObject = new JSONObject(); | ||
try { | ||
jsonObject.put("p", pkg); | ||
jsonObject.put("c", count); | ||
return jsonObject; | ||
} catch (JSONException e) { | ||
logE(TAG, "Failed to convert JSON!" + e); | ||
} | ||
return jsonObject; | ||
} | ||
|
||
/*public static String getLabel(JSONObject jsonObject) { | ||
try { | ||
return jsonObject.getString("l"); | ||
} catch (JSONException e) { | ||
logE(TAG, "Failed to get name!" + e); | ||
} | ||
return "null"; | ||
}*/ | ||
|
||
public static String getPkg(JSONObject jsonObject) { | ||
try { | ||
return jsonObject.getString("p"); | ||
} catch (JSONException e) { | ||
logE(TAG, "Failed to get package name!" + e); | ||
} | ||
return "null"; | ||
} | ||
|
||
public static long getTime(JSONObject jsonObject) { | ||
try { | ||
return jsonObject.getLong("t"); | ||
} catch (JSONException e) { | ||
logE(TAG, "Failed to get timestamp!" + e); | ||
} | ||
return -1L; | ||
} | ||
|
||
public static int getCount(JSONObject jsonObject) { | ||
try { | ||
return jsonObject.getInt("c"); | ||
} catch (JSONException e) { | ||
logE(TAG, "Failed to get the number of times!" + e); | ||
} | ||
return -1; | ||
} | ||
|
||
public static JSONObject putParam(JSONObject jsonObject, long time, int count) { | ||
try { | ||
jsonObject.put("c", count); | ||
jsonObject.put("t", time); | ||
return jsonObject; | ||
} catch (JSONException e) { | ||
logE(TAG, "Failed to update data!" + e); | ||
} | ||
return null; | ||
} | ||
|
||
public static ArrayList<JSONObject> toArray(String json) { | ||
try { | ||
ArrayList<JSONObject> list = new ArrayList<>(); | ||
JSONArray jsonArray = new JSONArray(json); | ||
for (int i = 0; i < jsonArray.length(); i++) { | ||
JSONObject obj = jsonArray.getJSONObject(i); | ||
list.add(obj); | ||
} | ||
return list; | ||
} catch (Exception e) { | ||
logE(TAG, "Failed to convert Array!" + e); | ||
} | ||
return new ArrayList<>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.