Skip to content

Commit

Permalink
[AL-101] remove line seperator in json string
Browse files Browse the repository at this point in the history
Change-Id: I2595f298fa81251c50bee28160a562205012005f
Reviewed-on: http://192.168.100.103/gerrit/310
Reviewed-by: hexiaocong <[email protected]>
  • Loading branch information
hexiaocong committed Dec 29, 2014
1 parent 87eb89f commit 0ead69a
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 27 deletions.
4 changes: 2 additions & 2 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions .idea/libraries/support_v4_21_0_3.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified CrashReport.apk
Binary file not shown.
21 changes: 21 additions & 0 deletions CrashReport.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/classes/main" />
<output-test url="file://$MODULE_DIR$/build/classes/test" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

4 changes: 1 addition & 3 deletions app/app.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$USER_HOME$/GitHub/CrashReport" external.system.id="GRADLE" external.system.module.group="CrashReport" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="CrashReport" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
Expand Down Expand Up @@ -100,8 +100,6 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/reports" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@
import android.os.DropBoxManager;
import android.os.SystemClock;

import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.path.android.jobqueue.Job;
import com.path.android.jobqueue.Params;
import com.squareup.okhttp.OkHttpClient;

import org.tecrash.crashreport.api.IDropboxService;
import org.tecrash.crashreport.data.ContentData;
import org.tecrash.crashreport.data.ReportDatas;
import org.tecrash.crashreport.util.Logger;
import org.tecrash.crashreport.util.Util;
Expand Down Expand Up @@ -68,8 +67,8 @@

public class DropboxUploadingJob extends Job {
static final long serialVersionUID = 0x2F3C0888L;
static final int MAX_DIG_LEN = 2 * 1024;
static Logger logger = Logger.getLogger();
private static final int MAX_DIG_LEN = 2 * 1024;
private static Logger logger = Logger.getLogger();
private long timestamp;
private String incremental;

Expand Down Expand Up @@ -158,12 +157,10 @@ public void onRun() throws Throwable {
ReportDatas.Entry data = datas.get(i);
if (result != null && result.dropbox_id != null && result.dropbox_id.length() > 0) {
DropBoxManager.Entry entry = dbm.getNextEntry(tags.get(i), timestamps.get(i));
JsonObject content = new JsonObject();
content.add("content", new JsonPrimitive(convertStreamToString(entry.getInputStream())));
service.updateContent(
Util.getKey(),
result.dropbox_id,
content
new ContentData(convertStreamToString(entry.getInputStream()))
);
}
}
Expand Down Expand Up @@ -246,7 +243,7 @@ private String convertStreamToString(InputStream is)
String line;
while ((line = br.readLine()) != null) {
sb.append(line);
sb.append(System.getProperty("line.separator"));
sb.append("\\n");
}
} catch (IOException e) {
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import com.google.gson.JsonObject;

import org.tecrash.crashreport.data.ContentData;
import org.tecrash.crashreport.data.ReportDatas;

import retrofit.http.Body;
Expand All @@ -49,7 +50,7 @@ ReportDatas.ReportResults report(
JsonObject updateContent(
@Header("Authorization") String nsKey,
@Path("dropbox_id") String dbId,
@Body JsonObject content
@Body ContentData content
);

@Multipart
Expand Down
35 changes: 35 additions & 0 deletions app/src/main/java/org/tecrash/crashreport/data/ContentData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* The MIT License (MIT)
* Copyright (c) 2014 He Xiaocong ([email protected])
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
* OR OTHER DEALINGS IN THE SOFTWARE.
*/

package org.tecrash.crashreport.data;

/**
* Created by xiaocong on 29/12/14.
*/
public class ContentData {
String content;

public ContentData(String content) {
this.content = content;
}
}
4 changes: 2 additions & 2 deletions app/src/main/java/org/tecrash/crashreport/util/Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
* Created by xiaocong on 14-11-21.
*/
public class Logger implements CustomLogger {
static final String TAG = "CrashReport";
private static final String TAG = "CrashReport";
private static Logger logger;

public static final Logger getLogger() {
public static Logger getLogger() {
if (logger == null) {
logger = new Logger();
}
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/java/org/tecrash/crashreport/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@
*/
public class Util {

final static String LOG_REG = "Log:\\s+([\\w\\-\\./:$#\\(\\)]+)";
final static Pattern LOG_PATTERN = Pattern.compile(LOG_REG);
final static String PROCESS_REG = "Process:\\s+([\\w\\-\\./:$#\\(\\)]+)";
final static Pattern PROCESS_PATTERN = Pattern.compile(PROCESS_REG);
final static String TOMBSTONE_REG = "pid:\\s*\\d+,\\s*tid:\\s*\\d+,\\s*name:.+?>>>\\s+([\\w\\-\\./:$#\\(\\)]+)\\s+<<<";
final static Pattern TOMBSTONE_PATTERN = Pattern.compile(TOMBSTONE_REG);
private final static String LOG_REG = "Log:\\s+([\\w\\-\\./:$#\\(\\)]+)";
private final static Pattern LOG_PATTERN = Pattern.compile(LOG_REG);
private final static String PROCESS_REG = "Process:\\s+([\\w\\-\\./:$#\\(\\)]+)";
private final static Pattern PROCESS_PATTERN = Pattern.compile(PROCESS_REG);
private final static String TOMBSTONE_REG = "pid:\\s*\\d+,\\s*tid:\\s*\\d+,\\s*name:.+?>>>\\s+([\\w\\-\\./:$#\\(\\)]+)\\s+<<<";
private final static Pattern TOMBSTONE_PATTERN = Pattern.compile(TOMBSTONE_REG);

static Map<String, IProcess> tags = new HashMap<String, IProcess>();
static int MAX_LINES = 30;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings_activity_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<string-array name="pref_key_url_list_values">
<item></item>
<item>http://cr.ota.xinqitec.com/api/0</item>
<item>http://192.168.1.105:9000/api/0</item>
<item>http://192.168.1.158:9000/api/0</item>
</string-array>

<string name="pref_key_days_to_upload_log">pref_key_days_to_upload_log</string>
Expand Down

0 comments on commit 0ead69a

Please sign in to comment.