am 6fbb8ed2: Merge "add logging code" into jb-mr1-dev
* commit '6fbb8ed253049771a6059863d87848c9143cce3d': add logging codemain
commit
73f22e9b3c
|
@ -102,7 +102,14 @@ public class ResearchLog {
|
||||||
mJsonWriter.endArray();
|
mJsonWriter.endArray();
|
||||||
mJsonWriter.flush();
|
mJsonWriter.flush();
|
||||||
mJsonWriter.close();
|
mJsonWriter.close();
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "wrote log to " + mFile);
|
||||||
|
}
|
||||||
mHasWrittenData = false;
|
mHasWrittenData = false;
|
||||||
|
} else {
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "close() called, but no data, not outputting");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.d(TAG, "error when closing ResearchLog:");
|
Log.d(TAG, "error when closing ResearchLog:");
|
||||||
|
|
|
@ -84,6 +84,7 @@ import java.util.UUID;
|
||||||
*/
|
*/
|
||||||
public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChangeListener {
|
public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
private static final String TAG = ResearchLogger.class.getSimpleName();
|
private static final String TAG = ResearchLogger.class.getSimpleName();
|
||||||
|
private static final boolean DEBUG = false;
|
||||||
private static final boolean OUTPUT_ENTIRE_BUFFER = false; // true may disclose private info
|
private static final boolean OUTPUT_ENTIRE_BUFFER = false; // true may disclose private info
|
||||||
public static final boolean DEFAULT_USABILITY_STUDY_MODE = false;
|
public static final boolean DEFAULT_USABILITY_STUDY_MODE = false;
|
||||||
/* package */ static boolean sIsLogging = false;
|
/* package */ static boolean sIsLogging = false;
|
||||||
|
@ -344,6 +345,9 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
}
|
}
|
||||||
|
|
||||||
private void start() {
|
private void start() {
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "start called");
|
||||||
|
}
|
||||||
maybeShowSplashScreen();
|
maybeShowSplashScreen();
|
||||||
updateSuspendedState();
|
updateSuspendedState();
|
||||||
requestIndicatorRedraw();
|
requestIndicatorRedraw();
|
||||||
|
@ -371,6 +375,9 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
}
|
}
|
||||||
|
|
||||||
/* package */ void stop() {
|
/* package */ void stop() {
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "stop called");
|
||||||
|
}
|
||||||
logStatistics();
|
logStatistics();
|
||||||
commitCurrentLogUnit();
|
commitCurrentLogUnit();
|
||||||
|
|
||||||
|
@ -386,6 +393,9 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean abort() {
|
public boolean abort() {
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "abort called");
|
||||||
|
}
|
||||||
boolean didAbortMainLog = false;
|
boolean didAbortMainLog = false;
|
||||||
if (mMainLogBuffer != null) {
|
if (mMainLogBuffer != null) {
|
||||||
mMainLogBuffer.clear();
|
mMainLogBuffer.clear();
|
||||||
|
@ -559,6 +569,9 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
}
|
}
|
||||||
|
|
||||||
public void uploadNow() {
|
public void uploadNow() {
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "calling uploadNow()");
|
||||||
|
}
|
||||||
mInputMethodService.startService(mUploadIntent);
|
mInputMethodService.startService(mUploadIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -578,6 +591,13 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAllowedToLog() {
|
private boolean isAllowedToLog() {
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "iatl: " +
|
||||||
|
"mipw=" + mIsPasswordView +
|
||||||
|
", mils=" + mIsLoggingSuspended +
|
||||||
|
", sil=" + sIsLogging +
|
||||||
|
", mInFeedbackDialog=" + mInFeedbackDialog);
|
||||||
|
}
|
||||||
return !mIsPasswordView && !mIsLoggingSuspended && sIsLogging && !mInFeedbackDialog;
|
return !mIsPasswordView && !mIsLoggingSuspended && sIsLogging && !mInFeedbackDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,6 +686,9 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
}
|
}
|
||||||
|
|
||||||
/* package for test */ void commitCurrentLogUnit() {
|
/* package for test */ void commitCurrentLogUnit() {
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "commitCurrentLogUnit");
|
||||||
|
}
|
||||||
if (!mCurrentLogUnit.isEmpty()) {
|
if (!mCurrentLogUnit.isEmpty()) {
|
||||||
if (mMainLogBuffer != null) {
|
if (mMainLogBuffer != null) {
|
||||||
mMainLogBuffer.shiftIn(mCurrentLogUnit);
|
mMainLogBuffer.shiftIn(mCurrentLogUnit);
|
||||||
|
|
Loading…
Reference in New Issue