aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/research
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/research')
-rw-r--r--java/src/com/android/inputmethod/research/LogUnit.java9
-rw-r--r--java/src/com/android/inputmethod/research/LoggingUtils.java38
-rw-r--r--java/src/com/android/inputmethod/research/MainLogBuffer.java59
-rw-r--r--java/src/com/android/inputmethod/research/ResearchLog.java80
-rw-r--r--java/src/com/android/inputmethod/research/ResearchLogger.java167
-rw-r--r--java/src/com/android/inputmethod/research/ResearchSettings.java61
-rw-r--r--java/src/com/android/inputmethod/research/Uploader.java180
-rw-r--r--java/src/com/android/inputmethod/research/UploaderService.java175
8 files changed, 452 insertions, 317 deletions
diff --git a/java/src/com/android/inputmethod/research/LogUnit.java b/java/src/com/android/inputmethod/research/LogUnit.java
index 1a9a720f3..839e2b7ba 100644
--- a/java/src/com/android/inputmethod/research/LogUnit.java
+++ b/java/src/com/android/inputmethod/research/LogUnit.java
@@ -16,7 +16,6 @@
package com.android.inputmethod.research;
-import android.content.SharedPreferences;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.JsonWriter;
@@ -45,7 +44,7 @@ import java.util.List;
* will not violate the user's privacy. Checks for this may include whether other LogUnits have
* been published recently, or whether the LogUnit contains numbers, etc.
*/
-/* package */ class LogUnit {
+public class LogUnit {
private static final String TAG = LogUnit.class.getSimpleName();
private static final boolean DEBUG = false && ProductionFlag.IS_EXPERIMENTAL_DEBUG;
@@ -151,10 +150,10 @@ import java.util.List;
continue;
}
// Only retrieve the jsonWriter if we need to. If we don't get this far, then
- // researchLog.getValidJsonWriterLocked() will not ever be called, and the file
- // will not have been opened for writing.
+ // researchLog.getInitializedJsonWriterLocked() will not ever be called, and the
+ // file will not have been opened for writing.
if (jsonWriter == null) {
- jsonWriter = researchLog.getValidJsonWriterLocked();
+ jsonWriter = researchLog.getInitializedJsonWriterLocked();
outputLogUnitStart(jsonWriter, canIncludePrivateData);
}
logStatement.outputToLocked(jsonWriter, mTimeList.get(i), mValuesList.get(i));
diff --git a/java/src/com/android/inputmethod/research/LoggingUtils.java b/java/src/com/android/inputmethod/research/LoggingUtils.java
new file mode 100644
index 000000000..1261d6780
--- /dev/null
+++ b/java/src/com/android/inputmethod/research/LoggingUtils.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.research;
+
+import android.view.MotionEvent;
+
+/* package */ class LoggingUtils {
+ private LoggingUtils() {
+ // This utility class is not publicly instantiable.
+ }
+
+ /* package */ static String getMotionEventActionTypeString(final int actionType) {
+ switch (actionType) {
+ case MotionEvent.ACTION_CANCEL: return "CANCEL";
+ case MotionEvent.ACTION_UP: return "UP";
+ case MotionEvent.ACTION_DOWN: return "DOWN";
+ case MotionEvent.ACTION_POINTER_UP: return "POINTER_UP";
+ case MotionEvent.ACTION_POINTER_DOWN: return "POINTER_DOWN";
+ case MotionEvent.ACTION_MOVE: return "MOVE";
+ case MotionEvent.ACTION_OUTSIDE: return "OUTSIDE";
+ default: return "ACTION_" + actionType;
+ }
+ }
+}
diff --git a/java/src/com/android/inputmethod/research/MainLogBuffer.java b/java/src/com/android/inputmethod/research/MainLogBuffer.java
index 3a87bf1df..9aa60f859 100644
--- a/java/src/com/android/inputmethod/research/MainLogBuffer.java
+++ b/java/src/com/android/inputmethod/research/MainLogBuffer.java
@@ -18,6 +18,7 @@ package com.android.inputmethod.research;
import android.util.Log;
+import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.latin.Dictionary;
import com.android.inputmethod.latin.Suggest;
import com.android.inputmethod.latin.define.ProductionFlag;
@@ -64,16 +65,11 @@ public abstract class MainLogBuffer extends FixedLogBuffer {
// The size of the n-grams logged. E.g. N_GRAM_SIZE = 2 means to sample bigrams.
public static final int N_GRAM_SIZE = 2;
- // Whether all words should be recorded, leaving unsampled word between bigrams. Useful for
- // testing.
- /* package for test */ static final boolean IS_LOGGING_EVERYTHING = false
- && ProductionFlag.IS_EXPERIMENTAL_DEBUG;
-
- // The number of words between n-grams to omit from the log.
- private static final int DEFAULT_NUMBER_OF_WORDS_BETWEEN_SAMPLES =
- IS_LOGGING_EVERYTHING ? 0 : (DEBUG ? 2 : 18);
-
- private Suggest mSuggest;
+ // TODO: Remove dependence on Suggest, and pass in Dictionary as a parameter to an appropriate
+ // method.
+ private final Suggest mSuggest;
+ @UsedForTesting
+ private Dictionary mDictionaryForTesting;
private boolean mIsStopping = false;
/* package for test */ int mNumWordsBetweenNGrams;
@@ -82,15 +78,25 @@ public abstract class MainLogBuffer extends FixedLogBuffer {
// after a sample is taken.
/* package for test */ int mNumWordsUntilSafeToSample;
- public MainLogBuffer() {
- super(N_GRAM_SIZE + DEFAULT_NUMBER_OF_WORDS_BETWEEN_SAMPLES);
- mNumWordsBetweenNGrams = DEFAULT_NUMBER_OF_WORDS_BETWEEN_SAMPLES;
- final Random random = new Random();
- mNumWordsUntilSafeToSample = DEBUG ? 0 : random.nextInt(mNumWordsBetweenNGrams + 1);
+ public MainLogBuffer(final int wordsBetweenSamples, final int numInitialWordsToIgnore,
+ final Suggest suggest) {
+ super(N_GRAM_SIZE + wordsBetweenSamples);
+ mNumWordsBetweenNGrams = wordsBetweenSamples;
+ mNumWordsUntilSafeToSample = DEBUG ? 0 : numInitialWordsToIgnore;
+ mSuggest = suggest;
}
- public void setSuggest(final Suggest suggest) {
- mSuggest = suggest;
+ @UsedForTesting
+ /* package for test */ void setDictionaryForTesting(final Dictionary dictionary) {
+ mDictionaryForTesting = dictionary;
+ }
+
+ private Dictionary getDictionary() {
+ if (mDictionaryForTesting != null) {
+ return mDictionaryForTesting;
+ }
+ if (mSuggest == null || !mSuggest.hasMainDictionary()) return null;
+ return mSuggest.getMainDictionary();
}
public void resetWordCounter() {
@@ -114,7 +120,7 @@ public abstract class MainLogBuffer extends FixedLogBuffer {
*/
private boolean isSafeNGram(final ArrayList<LogUnit> logUnits, final int minNGramSize) {
// Bypass privacy checks when debugging.
- if (IS_LOGGING_EVERYTHING) {
+ if (ResearchLogger.IS_LOGGING_EVERYTHING) {
if (mIsStopping) {
return true;
}
@@ -137,16 +143,13 @@ public abstract class MainLogBuffer extends FixedLogBuffer {
if (mNumWordsUntilSafeToSample > 0) {
return false;
}
- if (mSuggest == null || !mSuggest.hasMainDictionary()) {
- // Main dictionary is unavailable. Since we cannot check it, we cannot tell if a
- // word is out-of-vocabulary or not. Therefore, we must judge the entire buffer
- // contents to potentially pose a privacy risk.
- return false;
- }
// Reload the dictionary in case it has changed (e.g., because the user has changed
// languages).
- final Dictionary dictionary = mSuggest.getMainDictionary();
+ final Dictionary dictionary = getDictionary();
if (dictionary == null) {
+ // Main dictionary is unavailable. Since we cannot check it, we cannot tell if a
+ // word is out-of-vocabulary or not. Therefore, we must judge the entire buffer
+ // contents to potentially pose a privacy risk.
return false;
}
@@ -220,10 +223,10 @@ public abstract class MainLogBuffer extends FixedLogBuffer {
final boolean canIncludePrivateData);
@Override
- protected void shiftOutWords(int numWords) {
- int oldNumActualWords = getNumActualWords();
+ protected void shiftOutWords(final int numWords) {
+ final int oldNumActualWords = getNumActualWords();
super.shiftOutWords(numWords);
- int numWordsShifted = oldNumActualWords - getNumActualWords();
+ final int numWordsShifted = oldNumActualWords - getNumActualWords();
mNumWordsUntilSafeToSample -= numWordsShifted;
if (DEBUG) {
Log.d(TAG, "wordsUntilSafeToSample now at " + mNumWordsUntilSafeToSample);
diff --git a/java/src/com/android/inputmethod/research/ResearchLog.java b/java/src/com/android/inputmethod/research/ResearchLog.java
index 5114977d8..9016e23b3 100644
--- a/java/src/com/android/inputmethod/research/ResearchLog.java
+++ b/java/src/com/android/inputmethod/research/ResearchLog.java
@@ -38,12 +38,19 @@ import java.util.concurrent.TimeUnit;
/**
* Logs the use of the LatinIME keyboard.
*
- * This class logs operations on the IME keyboard, including what the user has typed.
- * Data is stored locally in a file in app-specific storage.
+ * This class logs operations on the IME keyboard, including what the user has typed. Data is
+ * written to a {@link JsonWriter}, which will write to a local file.
+ *
+ * The JsonWriter is created on-demand by calling {@link #getInitializedJsonWriterLocked}.
+ *
+ * This class uses an executor to perform file-writing operations on a separate thread. It also
+ * tries to avoid creating unnecessary files if there is nothing to write. It also handles
+ * flushing, making sure it happens, but not too frequently.
*
* This functionality is off by default. See {@link ProductionFlag#IS_EXPERIMENTAL}.
*/
public class ResearchLog {
+ // TODO: Automatically initialize the JsonWriter rather than requiring the caller to manage it.
private static final String TAG = ResearchLog.class.getSimpleName();
private static final boolean DEBUG = false && ProductionFlag.IS_EXPERIMENTAL_DEBUG;
private static final long FLUSH_DELAY_IN_MS = 1000 * 5;
@@ -87,6 +94,12 @@ public class ResearchLog {
mContext = context;
}
+ /**
+ * Waits for any publication requests to finish and closes the {@link JsonWriter} used for
+ * output.
+ *
+ * See class comment for details about {@code JsonWriter} construction.
+ */
public synchronized void close(final Runnable onClosed) {
mExecutor.submit(new Callable<Object>() {
@Override
@@ -94,20 +107,15 @@ public class ResearchLog {
try {
if (mHasWrittenData) {
mJsonWriter.endArray();
- mJsonWriter.flush();
- mJsonWriter.close();
- if (DEBUG) {
- Log.d(TAG, "wrote log to " + mFile);
- }
mHasWrittenData = false;
- } else {
- if (DEBUG) {
- Log.d(TAG, "close() called, but no data, not outputting");
- }
+ }
+ mJsonWriter.flush();
+ mJsonWriter.close();
+ if (DEBUG) {
+ Log.d(TAG, "wrote log to " + mFile);
}
} catch (Exception e) {
- Log.d(TAG, "error when closing ResearchLog:");
- e.printStackTrace();
+ Log.d(TAG, "error when closing ResearchLog:", e);
} finally {
if (mFile != null && mFile.exists()) {
mFile.setWritable(false, false);
@@ -125,6 +133,12 @@ public class ResearchLog {
private boolean mIsAbortSuccessful;
+ /**
+ * Waits for publication requests to finish, closes the {@link JsonWriter}, but then deletes the
+ * backing file used for output.
+ *
+ * See class comment for details about {@code JsonWriter} construction.
+ */
public synchronized void abort() {
mExecutor.submit(new Callable<Object>() {
@Override
@@ -184,6 +198,12 @@ public class ResearchLog {
mFlushFuture = mExecutor.schedule(mFlushCallable, FLUSH_DELAY_IN_MS, TimeUnit.MILLISECONDS);
}
+ /**
+ * Queues up {@code logUnit} to be published in the background.
+ *
+ * @param logUnit the {@link LogUnit} to be published
+ * @param canIncludePrivateData whether private data in the LogUnit should be included
+ */
public synchronized void publish(final LogUnit logUnit, final boolean canIncludePrivateData) {
try {
mExecutor.submit(new Callable<Object>() {
@@ -206,29 +226,39 @@ public class ResearchLog {
* Return a JsonWriter for this ResearchLog. It is initialized the first time this method is
* called. The cached value is returned in future calls.
*/
- public JsonWriter getValidJsonWriterLocked() {
+ public JsonWriter getInitializedJsonWriterLocked() {
+ if (mJsonWriter != NULL_JSON_WRITER || mFile == null) return mJsonWriter;
try {
- if (mJsonWriter == NULL_JSON_WRITER && mFile != null) {
- final FileOutputStream fos =
- mContext.openFileOutput(mFile.getName(), Context.MODE_PRIVATE);
- mJsonWriter = new JsonWriter(new BufferedWriter(new OutputStreamWriter(fos)));
- mJsonWriter.beginArray();
+ final JsonWriter jsonWriter = createJsonWriter(mContext, mFile);
+ if (jsonWriter != null) {
+ jsonWriter.beginArray();
+ mJsonWriter = jsonWriter;
mHasWrittenData = true;
}
- } catch (IOException e) {
- e.printStackTrace();
- Log.w(TAG, "Error in JsonWriter; disabling logging");
+ } catch (final IOException e) {
+ Log.w(TAG, "Error in JsonWriter; disabling logging", e);
try {
mJsonWriter.close();
- } catch (IllegalStateException e1) {
+ } catch (final IllegalStateException e1) {
// Assume that this is just the json not being terminated properly.
// Ignore
- } catch (IOException e1) {
- e1.printStackTrace();
+ } catch (final IOException e1) {
+ Log.w(TAG, "Error in closing JsonWriter; disabling logging", e1);
} finally {
mJsonWriter = NULL_JSON_WRITER;
}
}
return mJsonWriter;
}
+
+ /**
+ * Create the JsonWriter to write the ResearchLog to.
+ *
+ * This method may be overriden in testing to redirect the output.
+ */
+ /* package for test */ JsonWriter createJsonWriter(final Context context, final File file)
+ throws IOException {
+ return new JsonWriter(new BufferedWriter(new OutputStreamWriter(
+ context.openFileOutput(file.getName(), Context.MODE_PRIVATE))));
+ }
}
diff --git a/java/src/com/android/inputmethod/research/ResearchLogger.java b/java/src/com/android/inputmethod/research/ResearchLogger.java
index 45212913e..e705ddda1 100644
--- a/java/src/com/android/inputmethod/research/ResearchLogger.java
+++ b/java/src/com/android/inputmethod/research/ResearchLogger.java
@@ -88,6 +88,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
+import java.util.Random;
import java.util.UUID;
/**
@@ -121,31 +122,36 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
// field holds a channel name, the developer does not have to re-enter it when using the
// feedback mechanism to generate multiple tests.
private static final boolean FEEDBACK_DIALOG_SHOULD_PRESERVE_TEXT_FIELD = false;
- public static final boolean DEFAULT_USABILITY_STUDY_MODE = false;
/* package */ static boolean sIsLogging = false;
private static final int OUTPUT_FORMAT_VERSION = 5;
private static final String PREF_USABILITY_STUDY_MODE = "usability_study_mode";
- private static final String PREF_RESEARCH_HAS_SEEN_SPLASH = "pref_research_has_seen_splash";
/* package */ static final String LOG_FILENAME_PREFIX = "researchLog";
private static final String LOG_FILENAME_SUFFIX = ".txt";
/* package */ static final String USER_RECORDING_FILENAME_PREFIX = "recording";
private static final String USER_RECORDING_FILENAME_SUFFIX = ".txt";
private static final SimpleDateFormat TIMESTAMP_DATEFORMAT =
new SimpleDateFormat("yyyyMMddHHmmssS", Locale.US);
+ // Whether all words should be recorded, leaving unsampled word between bigrams. Useful for
+ // testing.
+ /* package for test */ static final boolean IS_LOGGING_EVERYTHING = false
+ && ProductionFlag.IS_EXPERIMENTAL_DEBUG;
+ // The number of words between n-grams to omit from the log.
+ private static final int NUMBER_OF_WORDS_BETWEEN_SAMPLES =
+ IS_LOGGING_EVERYTHING ? 0 : (DEBUG ? 2 : 18);
+
// Whether to show an indicator on the screen that logging is on. Currently a very small red
// dot in the lower right hand corner. Most users should not notice it.
private static final boolean IS_SHOWING_INDICATOR = true;
// Change the default indicator to something very visible. Currently two red vertical bars on
// either side of they keyboard.
private static final boolean IS_SHOWING_INDICATOR_CLEARLY = false ||
- (MainLogBuffer.IS_LOGGING_EVERYTHING && ProductionFlag.IS_EXPERIMENTAL_DEBUG);
+ (IS_LOGGING_EVERYTHING && ProductionFlag.IS_EXPERIMENTAL_DEBUG);
// FEEDBACK_WORD_BUFFER_SIZE should add 1 because it must also hold the feedback LogUnit itself.
public static final int FEEDBACK_WORD_BUFFER_SIZE = (Integer.MAX_VALUE - 1) + 1;
// constants related to specific log points
private static final String WHITESPACE_SEPARATORS = " \t\n\r";
private static final int MAX_INPUTVIEW_LENGTH_TO_CAPTURE = 8192; // must be >=1
- private static final String PREF_RESEARCH_LOGGER_UUID_STRING = "pref_research_logger_uuid";
private static final String PREF_RESEARCH_SAVED_CHANNEL = "pref_research_saved_channel";
private static final ResearchLogger sInstance = new ResearchLogger();
@@ -153,7 +159,6 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
private static String sAllowedAccountDomain = null;
// to write to a different filename, e.g., for testing, set mFile before calling start()
/* package */ File mFilesDir;
- /* package */ String mUUIDString;
/* package */ ResearchLog mMainResearchLog;
// mFeedbackLog records all events for the session, private or not (excepting
// passwords). It is written to permanent storage only if the user explicitly commands
@@ -199,7 +204,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
private Intent mUploadIntent;
private Intent mUploadNowIntent;
- private LogUnit mCurrentLogUnit = new LogUnit();
+ /* package for test */ LogUnit mCurrentLogUnit = new LogUnit();
// Gestured or tapped words may be committed after the gesture of the next word has started.
// To ensure that the gesture data of the next word is not associated with the previous word,
@@ -228,50 +233,44 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
return sInstance;
}
- public void init(final LatinIME latinIME, final KeyboardSwitcher keyboardSwitcher) {
+ public void init(final LatinIME latinIME, final KeyboardSwitcher keyboardSwitcher,
+ final Suggest suggest) {
assert latinIME != null;
- if (latinIME == null) {
- Log.w(TAG, "IMS is null; logging is off");
- } else {
- mFilesDir = latinIME.getFilesDir();
- if (mFilesDir == null || !mFilesDir.exists()) {
- Log.w(TAG, "IME storage directory does not exist.");
- }
- }
- final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(latinIME);
- if (prefs != null) {
- mUUIDString = getUUID(prefs);
- if (!prefs.contains(PREF_USABILITY_STUDY_MODE)) {
- Editor e = prefs.edit();
- e.putBoolean(PREF_USABILITY_STUDY_MODE, DEFAULT_USABILITY_STUDY_MODE);
- e.apply();
- }
- sIsLogging = prefs.getBoolean(PREF_USABILITY_STUDY_MODE, false);
- prefs.registerOnSharedPreferenceChangeListener(this);
-
- final long lastCleanupTime = prefs.getLong(PREF_LAST_CLEANUP_TIME, 0L);
- final long now = System.currentTimeMillis();
- if (lastCleanupTime + DURATION_BETWEEN_DIR_CLEANUP_IN_MS < now) {
- final long timeHorizon = now - MAX_LOGFILE_AGE_IN_MS;
- cleanupLoggingDir(mFilesDir, timeHorizon);
- Editor e = prefs.edit();
- e.putLong(PREF_LAST_CLEANUP_TIME, now);
- e.apply();
- }
+ mLatinIME = latinIME;
+ mFilesDir = latinIME.getFilesDir();
+ if (mFilesDir == null || !mFilesDir.exists()) {
+ Log.w(TAG, "IME storage directory does not exist. Cannot start logging.");
+ return;
}
+ mPrefs = PreferenceManager.getDefaultSharedPreferences(latinIME);
+ mPrefs.registerOnSharedPreferenceChangeListener(this);
+
+ // Initialize fields from preferences
+ sIsLogging = ResearchSettings.readResearchLoggerEnabledFlag(mPrefs);
+
+ // Initialize fields from resources
final Resources res = latinIME.getResources();
sAccountType = res.getString(R.string.research_account_type);
sAllowedAccountDomain = res.getString(R.string.research_allowed_account_domain);
- mLatinIME = latinIME;
- mPrefs = prefs;
+
+ // Cleanup logging directory
+ // TODO: Move this and other file-related components to separate file.
+ final long lastCleanupTime = mPrefs.getLong(PREF_LAST_CLEANUP_TIME, 0L);
+ final long now = System.currentTimeMillis();
+ if (now - lastCleanupTime > DURATION_BETWEEN_DIR_CLEANUP_IN_MS) {
+ final long timeHorizon = now - MAX_LOGFILE_AGE_IN_MS;
+ cleanupLoggingDir(mFilesDir, timeHorizon);
+ mPrefs.edit().putLong(PREF_LAST_CLEANUP_TIME, now).apply();
+ }
+
+ // Initialize external services
mUploadIntent = new Intent(mLatinIME, UploaderService.class);
mUploadNowIntent = new Intent(mLatinIME, UploaderService.class);
mUploadNowIntent.putExtra(UploaderService.EXTRA_UPLOAD_UNCONDITIONALLY, true);
- mReplayer.setKeyboardSwitcher(keyboardSwitcher);
-
if (ProductionFlag.IS_EXPERIMENTAL) {
scheduleUploadingService(mLatinIME);
}
+ mReplayer.setKeyboardSwitcher(keyboardSwitcher);
}
/**
@@ -313,14 +312,16 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
mMainKeyboardView = null;
}
- private boolean hasSeenSplash() {
- return mPrefs.getBoolean(PREF_RESEARCH_HAS_SEEN_SPLASH, false);
+ public void onDestroy() {
+ if (mPrefs != null) {
+ mPrefs.unregisterOnSharedPreferenceChangeListener(this);
+ }
}
private Dialog mSplashDialog = null;
private void maybeShowSplashScreen() {
- if (hasSeenSplash()) {
+ if (ResearchSettings.readHasSeenSplash(mPrefs)) {
return;
}
if (mSplashDialog != null && mSplashDialog.isShowing()) {
@@ -373,32 +374,23 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
}
public void onUserLoggingConsent() {
- setLoggingAllowed(true);
if (mPrefs == null) {
- return;
+ mPrefs = PreferenceManager.getDefaultSharedPreferences(mLatinIME);
+ if (mPrefs == null) return;
}
- final Editor e = mPrefs.edit();
- e.putBoolean(PREF_RESEARCH_HAS_SEEN_SPLASH, true);
- e.apply();
+ sIsLogging = true;
+ ResearchSettings.writeResearchLoggerEnabledFlag(mPrefs, true);
+ ResearchSettings.writeHasSeenSplash(mPrefs, true);
restart();
}
- private void setLoggingAllowed(boolean enableLogging) {
- if (mPrefs == null) {
- return;
- }
- Editor e = mPrefs.edit();
- e.putBoolean(PREF_USABILITY_STUDY_MODE, enableLogging);
- e.apply();
- sIsLogging = enableLogging;
- }
-
private static int sLogFileCounter = 0;
private File createLogFile(final File filesDir) {
final StringBuilder sb = new StringBuilder();
sb.append(LOG_FILENAME_PREFIX).append('-');
- sb.append(mUUIDString).append('-');
+ final String uuid = ResearchSettings.readResearchLoggerUuid(mPrefs);
+ sb.append(uuid).append('-');
sb.append(TIMESTAMP_DATEFORMAT.format(new Date())).append('-');
// Sometimes logFiles are created within milliseconds of each other. Append a counter to
// separate these.
@@ -416,7 +408,8 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
private File createUserRecordingFile(final File filesDir) {
final StringBuilder sb = new StringBuilder();
sb.append(USER_RECORDING_FILENAME_PREFIX).append('-');
- sb.append(mUUIDString).append('-');
+ final String uuid = ResearchSettings.readResearchLoggerUuid(mPrefs);
+ sb.append(uuid).append('-');
sb.append(TIMESTAMP_DATEFORMAT.format(new Date()));
sb.append(USER_RECORDING_FILENAME_SUFFIX);
return new File(filesDir, sb.toString());
@@ -458,17 +451,15 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
// Log.w(TAG, "not in usability mode; not logging");
return;
}
- if (mFilesDir == null || !mFilesDir.exists()) {
- Log.w(TAG, "IME storage directory does not exist. Cannot start logging.");
- return;
- }
if (mMainLogBuffer == null) {
mMainResearchLog = new ResearchLog(createLogFile(mFilesDir), mLatinIME);
- mMainLogBuffer = new MainLogBuffer() {
+ final int numWordsToIgnore = new Random().nextInt(NUMBER_OF_WORDS_BETWEEN_SAMPLES + 1);
+ mMainLogBuffer = new MainLogBuffer(NUMBER_OF_WORDS_BETWEEN_SAMPLES, numWordsToIgnore,
+ mSuggest) {
@Override
protected void publish(final ArrayList<LogUnit> logUnits,
boolean canIncludePrivateData) {
- canIncludePrivateData |= MainLogBuffer.IS_LOGGING_EVERYTHING;
+ canIncludePrivateData |= IS_LOGGING_EVERYTHING;
final int length = logUnits.size();
for (int i = 0; i < length; i++) {
final LogUnit logUnit = logUnits.get(i);
@@ -487,7 +478,6 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
}
}
};
- mMainLogBuffer.setSuggest(mSuggest);
}
if (mFeedbackLogBuffer == null) {
resetFeedbackLogging();
@@ -564,7 +554,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
}
@Override
- public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
+ public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) {
if (key == null || prefs == null) {
return;
}
@@ -586,7 +576,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
presentFeedbackDialog(latinIME);
}
- public void presentFeedbackDialog(LatinIME latinIME) {
+ public void presentFeedbackDialog(final LatinIME latinIME) {
if (isMakingUserRecording()) {
saveRecording();
}
@@ -818,9 +808,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
if (mPrefs == null) {
return;
}
- final Editor e = mPrefs.edit();
- e.putString(PREF_RESEARCH_SAVED_CHANNEL, channelName);
- e.apply();
+ mPrefs.edit().putString(PREF_RESEARCH_SAVED_CHANNEL, channelName).apply();
}
}
@@ -835,10 +823,13 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
mInFeedbackDialog = false;
}
- public void initSuggest(Suggest suggest) {
+ public void initSuggest(final Suggest suggest) {
mSuggest = suggest;
+ // MainLogBuffer has out-of-date Suggest object. Need to close it down and create a new
+ // one.
if (mMainLogBuffer != null) {
- mMainLogBuffer.setSuggest(mSuggest);
+ stop();
+ start();
}
}
@@ -1127,18 +1118,6 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
}
}
- private static String getUUID(final SharedPreferences prefs) {
- String uuidString = prefs.getString(PREF_RESEARCH_LOGGER_UUID_STRING, null);
- if (null == uuidString) {
- UUID uuid = UUID.randomUUID();
- uuidString = uuid.toString();
- Editor editor = prefs.edit();
- editor.putString(PREF_RESEARCH_LOGGER_UUID_STRING, uuidString);
- editor.apply();
- }
- return uuidString;
- }
-
private String scrubWord(String word) {
final Dictionary dictionary = getDictionary();
if (dictionary == null) {
@@ -1185,12 +1164,12 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
0);
final Integer versionCode = packageInfo.versionCode;
final String versionName = packageInfo.versionName;
+ final String uuid = ResearchSettings.readResearchLoggerUuid(researchLogger.mPrefs);
researchLogger.enqueueEvent(LOGSTATEMENT_LATIN_IME_ON_START_INPUT_VIEW_INTERNAL,
- researchLogger.mUUIDString, editorInfo.packageName,
- Integer.toHexString(editorInfo.inputType),
+ uuid, editorInfo.packageName, Integer.toHexString(editorInfo.inputType),
Integer.toHexString(editorInfo.imeOptions), editorInfo.fieldId,
Build.DISPLAY, Build.MODEL, prefs, versionCode, versionName,
- OUTPUT_FORMAT_VERSION, MainLogBuffer.IS_LOGGING_EVERYTHING,
+ OUTPUT_FORMAT_VERSION, IS_LOGGING_EVERYTHING,
ProductionFlag.IS_EXPERIMENTAL_DEBUG);
} catch (NameNotFoundException e) {
e.printStackTrace();
@@ -1226,17 +1205,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
public static void mainKeyboardView_processMotionEvent(final MotionEvent me, final int action,
final long eventTime, final int index, final int id, final int x, final int y) {
if (me != null) {
- final String actionString;
- switch (action) {
- case MotionEvent.ACTION_CANCEL: actionString = "CANCEL"; break;
- case MotionEvent.ACTION_UP: actionString = "UP"; break;
- case MotionEvent.ACTION_DOWN: actionString = "DOWN"; break;
- case MotionEvent.ACTION_POINTER_UP: actionString = "POINTER_UP"; break;
- case MotionEvent.ACTION_POINTER_DOWN: actionString = "POINTER_DOWN"; break;
- case MotionEvent.ACTION_MOVE: actionString = "MOVE"; break;
- case MotionEvent.ACTION_OUTSIDE: actionString = "OUTSIDE"; break;
- default: actionString = "ACTION_" + action; break;
- }
+ final String actionString = LoggingUtils.getMotionEventActionTypeString(action);
final ResearchLogger researchLogger = getInstance();
researchLogger.enqueueEvent(LOGSTATEMENT_MAIN_KEYBOARD_VIEW_PROCESS_MOTION_EVENT,
actionString, false /* IS_LOGGING_RELATED */, MotionEvent.obtain(me));
diff --git a/java/src/com/android/inputmethod/research/ResearchSettings.java b/java/src/com/android/inputmethod/research/ResearchSettings.java
new file mode 100644
index 000000000..11e9ac77a
--- /dev/null
+++ b/java/src/com/android/inputmethod/research/ResearchSettings.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.research;
+
+import android.content.SharedPreferences;
+
+import java.util.UUID;
+
+public final class ResearchSettings {
+ public static final String PREF_RESEARCH_LOGGER_UUID = "pref_research_logger_uuid";
+ public static final String PREF_RESEARCH_LOGGER_ENABLED_FLAG =
+ "pref_research_logger_enabled_flag";
+ public static final String PREF_RESEARCH_LOGGER_HAS_SEEN_SPLASH =
+ "pref_research_logger_has_seen_splash";
+
+ private ResearchSettings() {
+ // Intentional empty constructor for singleton.
+ }
+
+ public static String readResearchLoggerUuid(final SharedPreferences prefs) {
+ if (prefs.contains(PREF_RESEARCH_LOGGER_UUID)) {
+ return prefs.getString(PREF_RESEARCH_LOGGER_UUID, null);
+ }
+ // Generate a random string as uuid if not yet set
+ final String newUuid = UUID.randomUUID().toString();
+ prefs.edit().putString(PREF_RESEARCH_LOGGER_UUID, newUuid).apply();
+ return newUuid;
+ }
+
+ public static boolean readResearchLoggerEnabledFlag(final SharedPreferences prefs) {
+ return prefs.getBoolean(PREF_RESEARCH_LOGGER_ENABLED_FLAG, false);
+ }
+
+ public static void writeResearchLoggerEnabledFlag(final SharedPreferences prefs,
+ final boolean isEnabled) {
+ prefs.edit().putBoolean(PREF_RESEARCH_LOGGER_ENABLED_FLAG, isEnabled).apply();
+ }
+
+ public static boolean readHasSeenSplash(final SharedPreferences prefs) {
+ return prefs.getBoolean(PREF_RESEARCH_LOGGER_HAS_SEEN_SPLASH, false);
+ }
+
+ public static void writeHasSeenSplash(final SharedPreferences prefs,
+ final boolean hasSeenSplash) {
+ prefs.edit().putBoolean(PREF_RESEARCH_LOGGER_HAS_SEEN_SPLASH, hasSeenSplash).apply();
+ }
+}
diff --git a/java/src/com/android/inputmethod/research/Uploader.java b/java/src/com/android/inputmethod/research/Uploader.java
new file mode 100644
index 000000000..df495a88d
--- /dev/null
+++ b/java/src/com/android/inputmethod/research/Uploader.java
@@ -0,0 +1,180 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.research;
+
+import android.Manifest;
+import android.app.AlarmManager;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.pm.PackageManager;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.os.BatteryManager;
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.android.inputmethod.latin.R;
+import com.android.inputmethod.latin.define.ProductionFlag;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ * Manages the uploading of ResearchLog files.
+ */
+public final class Uploader {
+ private static final String TAG = Uploader.class.getSimpleName();
+ private static final boolean DEBUG = false && ProductionFlag.IS_EXPERIMENTAL_DEBUG;
+ // Set IS_INHIBITING_AUTO_UPLOAD to true for local testing
+ private static final boolean IS_INHIBITING_AUTO_UPLOAD = false
+ && ProductionFlag.IS_EXPERIMENTAL_DEBUG; // Force false for non-debug builds
+ private static final int BUF_SIZE = 1024 * 8;
+
+ private final Context mContext;
+ private final File mFilesDir;
+ private final URL mUrl;
+
+ public Uploader(final Context context) {
+ mContext = context;
+ mFilesDir = context.getFilesDir();
+
+ final String urlString = context.getString(R.string.research_logger_upload_url);
+ if (TextUtils.isEmpty(urlString)) {
+ mUrl = null;
+ return;
+ }
+ URL url = null;
+ try {
+ url = new URL(urlString);
+ } catch (final MalformedURLException e) {
+ Log.e(TAG, "Bad URL for uploading", e);
+ }
+ mUrl = url;
+ }
+
+ public boolean isPossibleToUpload() {
+ return hasUploadingPermission() && mUrl != null && !IS_INHIBITING_AUTO_UPLOAD;
+ }
+
+ private boolean hasUploadingPermission() {
+ final PackageManager packageManager = mContext.getPackageManager();
+ return packageManager.checkPermission(Manifest.permission.INTERNET,
+ mContext.getPackageName()) == PackageManager.PERMISSION_GRANTED;
+ }
+
+ public boolean isConvenientToUpload() {
+ return isExternallyPowered() && hasWifiConnection();
+ }
+
+ private boolean isExternallyPowered() {
+ final Intent intent = mContext.registerReceiver(null, new IntentFilter(
+ Intent.ACTION_BATTERY_CHANGED));
+ final int pluggedState = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
+ return pluggedState == BatteryManager.BATTERY_PLUGGED_AC
+ || pluggedState == BatteryManager.BATTERY_PLUGGED_USB;
+ }
+
+ private boolean hasWifiConnection() {
+ final ConnectivityManager manager =
+ (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
+ final NetworkInfo wifiInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
+ return wifiInfo.isConnected();
+ }
+
+ public void doUpload() {
+ if (mFilesDir == null) {
+ return;
+ }
+ final File[] files = mFilesDir.listFiles(new FileFilter() {
+ @Override
+ public boolean accept(final File pathname) {
+ return pathname.getName().startsWith(ResearchLogger.LOG_FILENAME_PREFIX)
+ && !pathname.canWrite();
+ }
+ });
+ for (final File file : files) {
+ uploadFile(file);
+ }
+ }
+
+ private void uploadFile(final File file) {
+ if (DEBUG) {
+ Log.d(TAG, "attempting upload of " + file.getAbsolutePath());
+ }
+ final int contentLength = (int) file.length();
+ HttpURLConnection connection = null;
+ InputStream fileInputStream = null;
+ try {
+ fileInputStream = new FileInputStream(file);
+ connection = (HttpURLConnection) mUrl.openConnection();
+ connection.setRequestMethod("PUT");
+ connection.setDoOutput(true);
+ connection.setFixedLengthStreamingMode(contentLength);
+ final OutputStream outputStream = connection.getOutputStream();
+ uploadContents(fileInputStream, outputStream);
+ if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
+ Log.d(TAG, "upload failed: " + connection.getResponseCode());
+ final InputStream netInputStream = connection.getInputStream();
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(
+ netInputStream));
+ String line;
+ while ((line = reader.readLine()) != null) {
+ Log.d(TAG, "| " + reader.readLine());
+ }
+ reader.close();
+ return;
+ }
+ file.delete();
+ if (DEBUG) {
+ Log.d(TAG, "upload successful");
+ }
+ } catch (final IOException e) {
+ Log.e(TAG, "Exception uploading file", e);
+ } finally {
+ if (fileInputStream != null) {
+ try {
+ fileInputStream.close();
+ } catch (final IOException e) {
+ Log.e(TAG, "Exception closing uploaded file", e);
+ }
+ }
+ if (connection != null) {
+ connection.disconnect();
+ }
+ }
+ }
+
+ private static void uploadContents(final InputStream is, final OutputStream os)
+ throws IOException {
+ // TODO: Switch to NIO.
+ final byte[] buf = new byte[BUF_SIZE];
+ int numBytesRead;
+ while ((numBytesRead = is.read(buf)) != -1) {
+ os.write(buf, 0, numBytesRead);
+ }
+ }
+}
diff --git a/java/src/com/android/inputmethod/research/UploaderService.java b/java/src/com/android/inputmethod/research/UploaderService.java
index 89c67fbb2..26b651056 100644
--- a/java/src/com/android/inputmethod/research/UploaderService.java
+++ b/java/src/com/android/inputmethod/research/UploaderService.java
@@ -16,189 +16,44 @@
package com.android.inputmethod.research;
-import android.Manifest;
import android.app.AlarmManager;
import android.app.IntentService;
-import android.content.Context;
import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.pm.PackageManager;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-import android.os.BatteryManager;
import android.os.Bundle;
-import android.util.Log;
-import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.define.ProductionFlag;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-
+/**
+ * Service to invoke the uploader.
+ *
+ * Can be regularly invoked, invoked on boot, etc.
+ */
public final class UploaderService extends IntentService {
private static final String TAG = UploaderService.class.getSimpleName();
private static final boolean DEBUG = false && ProductionFlag.IS_EXPERIMENTAL_DEBUG;
- // Set IS_INHIBITING_AUTO_UPLOAD to true for local testing
- private static final boolean IS_INHIBITING_AUTO_UPLOAD = false
- && ProductionFlag.IS_EXPERIMENTAL_DEBUG; // Force false in production
public static final long RUN_INTERVAL = AlarmManager.INTERVAL_HOUR;
public static final String EXTRA_UPLOAD_UNCONDITIONALLY = UploaderService.class.getName()
+ ".extra.UPLOAD_UNCONDITIONALLY";
- private static final int BUF_SIZE = 1024 * 8;
protected static final int TIMEOUT_IN_MS = 1000 * 4;
- private boolean mCanUpload;
- private File mFilesDir;
- private URL mUrl;
-
public UploaderService() {
super("Research Uploader Service");
}
@Override
- public void onCreate() {
- super.onCreate();
-
- mCanUpload = false;
- mFilesDir = null;
- mUrl = null;
-
- final PackageManager packageManager = getPackageManager();
- final boolean hasPermission = packageManager.checkPermission(Manifest.permission.INTERNET,
- getPackageName()) == PackageManager.PERMISSION_GRANTED;
- if (!hasPermission) {
- return;
- }
-
- try {
- final String urlString = getString(R.string.research_logger_upload_url);
- if (urlString == null || urlString.equals("")) {
- return;
- }
- mFilesDir = getFilesDir();
- mUrl = new URL(urlString);
- mCanUpload = true;
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- }
-
- @Override
- protected void onHandleIntent(Intent intent) {
- if (!mCanUpload) {
- return;
- }
- boolean isUploadingUnconditionally = false;
- Bundle bundle = intent.getExtras();
- if (bundle != null && bundle.containsKey(EXTRA_UPLOAD_UNCONDITIONALLY)) {
- isUploadingUnconditionally = bundle.getBoolean(EXTRA_UPLOAD_UNCONDITIONALLY);
- }
- doUpload(isUploadingUnconditionally);
- }
-
- private boolean isExternallyPowered() {
- final Intent intent = registerReceiver(null, new IntentFilter(
- Intent.ACTION_BATTERY_CHANGED));
- final int pluggedState = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
- return pluggedState == BatteryManager.BATTERY_PLUGGED_AC
- || pluggedState == BatteryManager.BATTERY_PLUGGED_USB;
- }
-
- private boolean hasWifiConnection() {
- final ConnectivityManager manager =
- (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
- final NetworkInfo wifiInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
- return wifiInfo.isConnected();
- }
-
- private void doUpload(final boolean isUploadingUnconditionally) {
- if (!isUploadingUnconditionally && (!isExternallyPowered() || !hasWifiConnection()
- || IS_INHIBITING_AUTO_UPLOAD)) {
- return;
- }
- if (mFilesDir == null) {
- return;
- }
- final File[] files = mFilesDir.listFiles(new FileFilter() {
- @Override
- public boolean accept(File pathname) {
- return pathname.getName().startsWith(ResearchLogger.LOG_FILENAME_PREFIX)
- && !pathname.canWrite();
- }
- });
- boolean success = true;
- if (files.length == 0) {
- success = false;
- }
- for (final File file : files) {
- if (!uploadFile(file)) {
- success = false;
- }
+ protected void onHandleIntent(final Intent intent) {
+ final Uploader uploader = new Uploader(this);
+ if (!uploader.isPossibleToUpload()) return;
+ if (isUploadingUnconditionally(intent.getExtras()) || uploader.isConvenientToUpload()) {
+ uploader.doUpload();
}
}
- private boolean uploadFile(File file) {
- if (DEBUG) {
- Log.d(TAG, "attempting upload of " + file.getAbsolutePath());
- }
- boolean success = false;
- final int contentLength = (int) file.length();
- HttpURLConnection connection = null;
- InputStream fileInputStream = null;
- try {
- fileInputStream = new FileInputStream(file);
- connection = (HttpURLConnection) mUrl.openConnection();
- connection.setRequestMethod("PUT");
- connection.setDoOutput(true);
- connection.setFixedLengthStreamingMode(contentLength);
- final OutputStream os = connection.getOutputStream();
- final byte[] buf = new byte[BUF_SIZE];
- int numBytesRead;
- while ((numBytesRead = fileInputStream.read(buf)) != -1) {
- os.write(buf, 0, numBytesRead);
- if (DEBUG) {
- Log.d(TAG, new String(buf));
- }
- }
- if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
- Log.d(TAG, "upload failed: " + connection.getResponseCode());
- InputStream netInputStream = connection.getInputStream();
- BufferedReader reader = new BufferedReader(new InputStreamReader(netInputStream));
- String line;
- while ((line = reader.readLine()) != null) {
- Log.d(TAG, "| " + reader.readLine());
- }
- reader.close();
- return success;
- }
- file.delete();
- success = true;
- if (DEBUG) {
- Log.d(TAG, "upload successful");
- }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- if (fileInputStream != null) {
- try {
- fileInputStream.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- if (connection != null) {
- connection.disconnect();
- }
+ private boolean isUploadingUnconditionally(final Bundle bundle) {
+ if (bundle == null) return false;
+ if (bundle.containsKey(EXTRA_UPLOAD_UNCONDITIONALLY)) {
+ return bundle.getBoolean(EXTRA_UPLOAD_UNCONDITIONALLY);
}
- return success;
+ return false;
}
}