diff --git a/.gitignore b/.gitignore
index 9bea4330..0a07b96b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
.DS_Store
+bin
diff --git a/ARODataCollector/AndroidManifest.xml b/ARODataCollector/AndroidManifest.xml
index 18b1b926..06ce4b6a 100644
--- a/ARODataCollector/AndroidManifest.xml
+++ b/ARODataCollector/AndroidManifest.xml
@@ -77,6 +77,12 @@
android:name=".activities.AROCollectorLegalTermsActivity"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="portrait" />
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ARODataCollector/src/com/att/android/arodatacollector/activities/AROCollectorCompletedActivity.java b/ARODataCollector/src/com/att/android/arodatacollector/activities/AROCollectorCompletedActivity.java
index 168bb2fe..2f749e27 100644
--- a/ARODataCollector/src/com/att/android/arodatacollector/activities/AROCollectorCompletedActivity.java
+++ b/ARODataCollector/src/com/att/android/arodatacollector/activities/AROCollectorCompletedActivity.java
@@ -114,7 +114,7 @@ private void initTraceSummaryControls() {
final TextView videotrace = (TextView) findViewById(R.id.tracevideo);
try {
- mApp.readPcapStartEndTime();
+ mApp.readPcapStartEndTime(getApplicationContext());
setApplicationUpTime();
} catch (IOException e) {
// TODO: Setting default value for application up time and notify
@@ -122,8 +122,8 @@ private void initTraceSummaryControls() {
AROLogger.e(TAG, "exception in readPcapStartEndTime. Could not read trace start time", e);
}
traceSummaryOKButton = (Button) findViewById(R.id.datasummaryok);
- tracePath.setText(ARODataCollector.ARO_TRACE_ROOTDIR + mApp.getDumpTraceFolderName());
- if ((mApp.getCollectVideoOption() && !mApp.isVideoFileExisting() && !mApp.isUSBVideoCaptureON())
+ tracePath.setText(ARODataCollector.ARO_TRACE_ROOTDIR + ARODataCollector.getDumpTraceFolderName(getApplicationContext()));
+ if ((mApp.getCollectVideoOption() && !ARODataCollector.isVideoFileExisting(getApplicationContext()) && !mApp.isUSBVideoCaptureON())
|| mApp.getVideoCaptureFailed()) {
videotrace.setText(getResources().getText(R.string.aro_failedvideo));
} else if (mApp.getCollectVideoOption() || mApp.isUSBVideoCaptureON() ) {
@@ -131,7 +131,7 @@ private void initTraceSummaryControls() {
} else {
videotrace.setText(getResources().getText(R.string.aro_notext));
}
- mApp.setTcpDumpTraceFolderName(null);
+ //ARODataCollector.setTcpDumpTraceFolderName(getApplicationContext(), null);
}
/**
diff --git a/ARODataCollector/src/com/att/android/arodatacollector/activities/AROCollectorHomeActivity.java b/ARODataCollector/src/com/att/android/arodatacollector/activities/AROCollectorHomeActivity.java
index 924989e7..cb99c827 100644
--- a/ARODataCollector/src/com/att/android/arodatacollector/activities/AROCollectorHomeActivity.java
+++ b/ARODataCollector/src/com/att/android/arodatacollector/activities/AROCollectorHomeActivity.java
@@ -207,11 +207,13 @@ public void onClick(View v) {
* Stops the data collector trace by stopping Video Trace and tcpdump from
* shell
*/
- private void stopARODataCollector() {
+ private void stopARODataCollector()
+ {
AROLogger.d(TAG, "Inside stopARODataCollector....");
stopDataCollector.setEnabled(false);
hideDataCollector.setEnabled(false);
- mApp.setARODataCollectorStopFlag(true);
+ ARODataCollector.setARODataCollectorStopFlag(getApplicationContext(), true);
+
if (mApp != null) {
AROLogger.d(TAG, "calling unregisterUsbBroadcastReceiver inside stopARODataCollector");
unregisterUsbBroadcastReceiver();
diff --git a/ARODataCollector/src/com/att/android/arodatacollector/activities/AROCollectorMainActivity.java b/ARODataCollector/src/com/att/android/arodatacollector/activities/AROCollectorMainActivity.java
index 453438d4..c742ef32 100644
--- a/ARODataCollector/src/com/att/android/arodatacollector/activities/AROCollectorMainActivity.java
+++ b/ARODataCollector/src/com/att/android/arodatacollector/activities/AROCollectorMainActivity.java
@@ -54,8 +54,11 @@
* Collector trace, and opening the Task Killer.
*/
-public class AROCollectorMainActivity extends Activity {
+public class AROCollectorMainActivity extends Activity
+{
+
+
/** Log TAG string for ARO-Data Collector main landing Screen */
private static final String TAG = "ARO.MainActivity";
@@ -162,7 +165,8 @@ private void registerAnalyzerLaunchReceiver() {
* and it receives all the error dialogs ID for the respective error
* messages to be shown during application life cycle.
*/
- private void initializeMainScreenControls() {
+ private void initializeMainScreenControls()
+ {
// The Connectivity manager object to get current connect network, this
// is used to check if we have active network before DC kicks off
@@ -177,7 +181,9 @@ private void initializeMainScreenControls() {
mAroUtils = new AROCollectorUtils();
mAROConnectiviyMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
mApp.setDataCollectorStopEnable(true);
- if (mApp.getDumpTraceFolderName()!=null) {
+
+ if (ARODataCollector.getDumpTraceFolderName(getApplicationContext()) !=null)
+ {
mApp.setUSBVideoCaptureON(true);
startDataCollector.setText(R.string.continuecollector);
}else {
@@ -245,7 +251,7 @@ public void onClick(View v) {
AROLogger.e(TAG, "exception in getting root permission", e);
}
mAROrootShell = null;
- if(mApp.getDumpTraceFolderName()!=null) {
+ if(ARODataCollector.getDumpTraceFolderName(getApplicationContext()) !=null) {
mApp.setCollectorLaunchfromAnalyzer(true);
mApp.setDataCollectorStopEnable(false);
startARODataCollector();
@@ -257,6 +263,8 @@ public void onClick(View v) {
}
});
handleARODataCollectorErrors(getIntent().getExtras().getInt(ARODataCollector.ERRODIALOGID));
+
+ ARODataCollector.setTcpDumpTraceFolderName(getApplicationContext(),null);
}
/**
@@ -281,7 +289,8 @@ private void validateAROAnalyzerConnectedLaunch(){
* from SD card.
*
*/
- private void startARODataCollector() {
+ private void startARODataCollector()
+ {
// Timer object which start as soon user press the Start Data Collector
// to checks the tcpdump execution in the shell
@@ -293,28 +302,23 @@ private void startARODataCollector() {
// process
final AROCollectorTaskManagerProcessInfo mAROTaskManagerProcessInfo = new AROCollectorTaskManagerProcessInfo();
- mApp.setARODataCollectorStopFlag(false);
- mApp.setDataCollectorInProgressFlag(true);
- mApp.setRequestDataCollectorStop(false);
- mApp.setVideoCaptureFailed(false);
- startDataCollector.setEnabled(false);
- createAROTraceDirectory();
+
+
+ startDataCollector.setEnabled(false);
- if (mApp.getDumpTraceFolderName() != null) {
+ if (ARODataCollector.getDumpTraceFolderName(getApplicationContext()) != null)
+ {
- //Takes a snap shoot of the time the system booted to be used for the timer on the home page.
- mApp.setElapsedTimeStartTime(System.currentTimeMillis());
+ //send START broadcast
+ sendBroadcast( new Intent(StartStopReceiver.ACTION_START_ARO) );
- // Starting the ARO Data collector service before tcpdump to record
- // >=t(0)
- startService(new Intent(getApplicationContext(), AROCollectorTraceService.class));
- // Starting the tcpdump service and starts the video capture
- startService(new Intent(getApplicationContext(), AROCollectorService.class));
collectScreenVideo.setEnabled(false);
- if (collectScreenVideo.isChecked()) {
- mApp.setCollectVideoOption(true);
- } else {
- mApp.setCollectVideoOption(false);
+ if (collectScreenVideo.isChecked())
+ {
+ ARODataCollector.setCollectVideoOption(getApplicationContext(),true);
+ } else
+ {
+ ARODataCollector.setCollectVideoOption(getApplicationContext(),false);
}
mApp.showProgressDialog(this);
// ARO Watch timer for failed start message of data collector after 15
@@ -324,12 +328,14 @@ private void startARODataCollector() {
public void run() {
if (!mApp.getTcpDumpStartFlag()) {
AROLogger.w(TAG, "Failed to start ARODataCollector in 15 sec");
- stopService(new Intent(getApplicationContext(), AROCollectorTraceService.class));
- stopService(new Intent(getApplicationContext(), AROCollectorService.class));
+
+ //send STOP broadcast
+ sendBroadcast( new Intent(StartStopReceiver.ACTION_STOP_ARO) );
+
// As we collect peripherals trace i.e wifi,GPs
// service before tcpdump trace so we making sure we delete
// all of the traces if we don't have tcpdump running
- mAroUtils.deleteTraceFolder(new File(mApp.getTcpDumpTraceFolderName()));
+ mAroUtils.deleteTraceFolder(new File(ARODataCollector.getTcpDumpTraceFolderName(getApplicationContext())));
mAROFailStartHandler.sendMessage(Message.obtain(mAROFailStartHandler,
NAVIGATE_HOME_SCREEN));
}
@@ -345,7 +351,7 @@ public void run() {
mApp.setTcpDumpStartFlag(mAROTaskManagerProcessInfo.pstcpdump());
if (mApp.getTcpDumpStartFlag()) {
mApp.hideProgressDialog();
- mApp.setDataCollectorInProgressFlag(false);
+ ARODataCollector.setDataCollectorInProgressFlag(getApplicationContext(),false);
mApp.triggerAROAlertNotification();
mAROHomeScreenHandler.sendMessage(Message.obtain(mAROHomeScreenHandler, 0));
aroDCStartWatchTimer.cancel();
@@ -361,23 +367,23 @@ public void run() {
* directory of ARO (\SDCARD\ARO)
*
*/
- private void createAROTraceDirectory() {
-
- final String mAroTraceDatapath = mApp.getTcpDumpTraceFolderName();
- final File traceFolder = new File(mAroTraceDatapath);
- final File traceRootFolder = new File(ARODataCollector.ARO_TRACE_ROOTDIR);
-
- AROLogger.d(TAG, "mAroTraceDatapath=" + mAroTraceDatapath);
-
- // Creates the trace root directory
- if (!traceRootFolder.exists()) {
- traceRootFolder.mkdir();
- }
- // Creates the trace directory inside /SDCARD/ARO
- if (!traceFolder.exists()) {
- traceFolder.mkdir();
- }
- }
+// private void createAROTraceDirectory() {
+//
+// final String mAroTraceDatapath = ARODataCollector.getTcpDumpTraceFolderName(getApplicationContext());
+// final File traceFolder = new File(mAroTraceDatapath);
+// final File traceRootFolder = new File(ARODataCollector.ARO_TRACE_ROOTDIR);
+//
+// AROLogger.d(TAG, "mAroTraceDatapath=" + mAroTraceDatapath);
+//
+// // Creates the trace root directory
+// if (!traceRootFolder.exists()) {
+// traceRootFolder.mkdir();
+// }
+// // Creates the trace directory inside /SDCARD/ARO
+// if (!traceFolder.exists()) {
+// traceFolder.mkdir();
+// }
+// }
/**
* Displays the ARO error message dialog during the application lifetime
@@ -542,7 +548,7 @@ public void handleMessage(Message msg) {
}
showARODataCollectorErrorDialog(Dialog_Type.DC_FAILED_START);
AROLogger.d(TAG, "Setting Data Collector stop flag");
- mApp.setARODataCollectorStopFlag(true);
+ ARODataCollector.setARODataCollectorStopFlag(getApplicationContext(), true);
collectScreenVideo.setEnabled(true);
startDataCollector.setEnabled(true);
AROLogger.d(TAG, "Setting Data Collector stop flag");
diff --git a/ARODataCollector/src/com/att/android/arodatacollector/activities/AROCollectorSplashActivity.java b/ARODataCollector/src/com/att/android/arodatacollector/activities/AROCollectorSplashActivity.java
index 8d17229e..996955a1 100644
--- a/ARODataCollector/src/com/att/android/arodatacollector/activities/AROCollectorSplashActivity.java
+++ b/ARODataCollector/src/com/att/android/arodatacollector/activities/AROCollectorSplashActivity.java
@@ -366,11 +366,13 @@ private void startMainActivity() {
final Bundle apkCommandLineParameters = getIntent().getExtras();
if (apkCommandLineParameters != null) {
//sendAnalyzerLaunchBroadcast();
- mAROTraceFolderNamefromAnalyzer = apkCommandLineParameters.getString("TraceFolderName");
- mApp.setTcpDumpTraceFolderName(mAROTraceFolderNamefromAnalyzer);
- }else{
- mApp.setTcpDumpTraceFolderName(null);
+ mAROTraceFolderNamefromAnalyzer = apkCommandLineParameters.getString("TraceFolderName");
+ ARODataCollector.setTcpDumpTraceFolderName(getApplicationContext(), mAROTraceFolderNamefromAnalyzer);
}
+// else
+// {
+// ARODataCollector.setTcpDumpTraceFolderName(getApplicationContext(), null);
+// }
final Intent splashScreenIntent = new Intent(getBaseContext(),
AROCollectorMainActivity.class);
diff --git a/ARODataCollector/src/com/att/android/arodatacollector/activities/StartStopReceiver.java b/ARODataCollector/src/com/att/android/arodatacollector/activities/StartStopReceiver.java
new file mode 100644
index 00000000..2de41907
--- /dev/null
+++ b/ARODataCollector/src/com/att/android/arodatacollector/activities/StartStopReceiver.java
@@ -0,0 +1,80 @@
+package com.att.android.arodatacollector.activities;
+
+import java.io.File;
+
+import com.att.android.arodatacollector.main.AROCollectorService;
+import com.att.android.arodatacollector.main.AROCollectorTraceService;
+import com.att.android.arodatacollector.main.ARODataCollector;
+import com.att.android.arodatacollector.utils.AROLogger;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+
+public class StartStopReceiver extends BroadcastReceiver
+{
+ private static String TAG = "ARO.StartStopReceiver";
+
+ public static final String ACTION_START_ARO ="com.att.android.arodatacollector.STARTARO";
+ public static final String ACTION_STOP_ARO ="com.att.android.arodatacollector.STOPARO";
+
+ @Override
+ public void onReceive(Context context, Intent intent)
+ {
+ AROLogger.d(TAG, "Received \"" + intent.getAction() + "\"");
+ if (intent.getAction().equals(ACTION_START_ARO))
+ {
+ ARODataCollector.setARODataCollectorStopFlag(context, false);
+ ARODataCollector.setDataCollectorInProgressFlag(context,true);
+ ARODataCollector.setRequestDataCollectorStop(false);
+ ARODataCollector.setVideoCaptureFailed(context, false);
+
+ createAROTraceDirectory(context);
+
+ //Takes a snap shoot of the time the system booted to be used for the timer on the home page.
+ ARODataCollector.setElapsedTimeStartTime(context, System.currentTimeMillis());
+
+ // Starting the ARO Data collector service before tcpdump to record
+ // >=t(0)
+ context.startService(new Intent(context, AROCollectorTraceService.class));
+ // Starting the tcpdump service and starts the video capture
+ context.startService(new Intent(context, AROCollectorService.class));
+
+ }
+ else if (intent.getAction().equals(ACTION_STOP_ARO))
+ {
+ context.stopService(new Intent(context, AROCollectorTraceService.class));
+ context.stopService(new Intent(context, AROCollectorService.class));
+
+ ARODataCollector.setTcpDumpTraceFolderName(context,null);
+ }
+ else
+ {
+ AROLogger.e(TAG, intent.getAction() + " is an unexpected action, doing nothing");
+ }
+ }
+
+ /**
+ * Creates the given trace directory on the device SD card under root
+ * directory of ARO (\SDCARD\ARO)
+ *
+ */
+ private void createAROTraceDirectory(Context ctx)
+ {
+ String mAroTraceDatapath = ARODataCollector.getTcpDumpTraceFolderName(ctx);
+ File traceFolder = new File(mAroTraceDatapath);
+ File traceRootFolder = new File(ARODataCollector.ARO_TRACE_ROOTDIR);
+
+ AROLogger.d(TAG, "mAroTraceDatapath=" + mAroTraceDatapath);
+
+ // Creates the trace root directory
+ if (!traceRootFolder.exists()) {
+ traceRootFolder.mkdir();
+ }
+ // Creates the trace directory inside /SDCARD/ARO
+ if (!traceFolder.exists()) {
+ traceFolder.mkdir();
+ }
+ }
+
+}
diff --git a/ARODataCollector/src/com/att/android/arodatacollector/main/AROCollectorCustomDialog.java b/ARODataCollector/src/com/att/android/arodatacollector/main/AROCollectorCustomDialog.java
index ff467c2f..46da6f89 100644
--- a/ARODataCollector/src/com/att/android/arodatacollector/main/AROCollectorCustomDialog.java
+++ b/ARODataCollector/src/com/att/android/arodatacollector/main/AROCollectorCustomDialog.java
@@ -353,11 +353,11 @@ private void createAROGetTraceFolderDialog() {
buttonCancel.setOnClickListener(new CancelListener());
// Setting the current timestamp as the default name of trace folder
final EditText mTraceFolderName = (EditText) findViewById(R.id.dialog_tracefoldername);
- if (mApp.getErrorTraceFoldername() != null) {
- mTraceFolderName.setText(mApp.getErrorTraceFoldername());
- mApp.setErrorTraceFoldername(null);
+ if (ARODataCollector.getErrorTraceFoldername() != null) {
+ mTraceFolderName.setText(ARODataCollector.getErrorTraceFoldername());
+ ARODataCollector.setErrorTraceFoldername(null);
} else {
- mTraceFolderName.setText(mAROUtils.getDefaultTraceFolderName());
+ mTraceFolderName.setText(AROCollectorUtils.getDefaultTraceFolderName());
}
}
@@ -536,22 +536,29 @@ public void onClick(View v) {
case TRACE_FOLDERNAME: {
final EditText givenTraceFolderName = (EditText) findViewById(R.id.dialog_tracefoldername);
mTraceFolderName = givenTraceFolderName.getText().toString();
- mApp.setTcpDumpTraceFolderName(mTraceFolderName);
- traceFolderPath = new File(mApp.getTcpDumpTraceFolderName());
- if (mAROUtils.isContainsSpecialCharacterorSpace(mTraceFolderName)) {
+
+ ARODataCollector.setTcpDumpTraceFolderName(v.getContext(), mTraceFolderName);
+ traceFolderPath = new File(ARODataCollector.getTcpDumpTraceFolderName(getContext()));
+
+ if (mAROUtils.isContainsSpecialCharacterorSpace(mTraceFolderName))
+ {
errrocode = Dialog_CallBack_Error.CALLBACK_SPECIALCHARERROR;
AROCollectorCustomDialog.this.dismiss();
- mApp.setErrorTraceFoldername(mTraceFolderName);
+ ARODataCollector.setErrorTraceFoldername(mTraceFolderName);
readyListener.ready(errrocode, false);
break;
- } else if (mTraceFolderName != null && !traceFolderPath.isDirectory()) {
+ }
+ else if (mTraceFolderName != null && !traceFolderPath.isDirectory())
+ {
// Setting the trace folder name at application context
- mApp.setTcpDumpTraceFolderName(givenTraceFolderName.getText().toString());
+ ARODataCollector.setTcpDumpTraceFolderName(v.getContext(), givenTraceFolderName.getText().toString());
AROCollectorCustomDialog.this.dismiss();
readyListener.ready(Dialog_CallBack_Error.CALLBACK_DEFAULT, true);
- } else {
- mApp.setTcpDumpTraceFolderName(givenTraceFolderName.getText().toString());
+ }
+ else
+ {
+ ARODataCollector.setTcpDumpTraceFolderName(v.getContext(), givenTraceFolderName.getText().toString());
if (mTraceFolderName.equalsIgnoreCase("") || mTraceFolderName == null) {
errrocode = Dialog_CallBack_Error.CALLBACK_TRACEFOLDERERROR; // "Please enter valid trace folder name";
AROCollectorCustomDialog.this.dismiss();
@@ -565,12 +572,12 @@ public void onClick(View v) {
break;
case TRACE_FOLDERNAME_EXISTS:
- if (mApp.getTcpDumpTraceFolderName() != null) {
- mAROUtils.deleteDirectory(new File(mApp.getTcpDumpTraceFolderName()));
+ if (ARODataCollector.getTcpDumpTraceFolderName(getContext()) != null) {
+ mAROUtils.deleteDirectory(new File(ARODataCollector.getTcpDumpTraceFolderName(getContext())));
if (AROLogger.logDebug) {
AROLogger.d(TAG,
"TRACE_FOLDERNAME_EXISTS deleting directory"
- + mApp.getTcpDumpTraceFolderName());
+ + ARODataCollector.getTcpDumpTraceFolderName(getContext()));
}
}
readyListener.ready(Dialog_CallBack_Error.CALLBACK_DEFAULT, true);
diff --git a/ARODataCollector/src/com/att/android/arodatacollector/main/AROCollectorService.java b/ARODataCollector/src/com/att/android/arodatacollector/main/AROCollectorService.java
index d490f345..9c450096 100644
--- a/ARODataCollector/src/com/att/android/arodatacollector/main/AROCollectorService.java
+++ b/ARODataCollector/src/com/att/android/arodatacollector/main/AROCollectorService.java
@@ -34,6 +34,7 @@
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
@@ -106,10 +107,10 @@ public class AROCollectorService extends Service {
private AROCollectorUtils mAroUtils;
/** ARO Data Collector full trace folder path */
- private String TRACE_FOLDERNAME;
+ private static String TRACE_FOLDERNAME;
/** To holds value ARO Data Collector video recording trace ON/OFF */
- private boolean mVideoRecording;
+ private static boolean mVideoRecording;
/** Intent to launch ARO Data Collector Completed screen */
private Intent tcpdumpStoppedIntent;
@@ -179,9 +180,9 @@ public void onCreate() {
AROLogger.d(TAG, "flurry-TelephonyManager deviceId: " + mAROtelManager.getDeviceId());
}
disableScreenTimeout();
- TRACE_FOLDERNAME = mApp.getDumpTraceFolderName();
+ TRACE_FOLDERNAME = ARODataCollector.getDumpTraceFolderName(getApplicationContext());
mVideoRecording = mApp.getCollectVideoOption();
- startDataCollectorVideoCapture();
+ startDataCollectorVideoCapture(getApplicationContext());
statDataCollectortcpdumpCapture();
}
@@ -240,8 +241,8 @@ private void disableScreenTimeout() {
* @return device manufacturer and model in lower case
*/
private String getDeviceName() {
- String manufacturer = Build.MANUFACTURER.toLowerCase();
- String model = Build.MODEL.toLowerCase();
+ String manufacturer = Build.MANUFACTURER.toLowerCase(Locale.getDefault());
+ String model = Build.MODEL.toLowerCase(Locale.getDefault());
if (model.startsWith(manufacturer)) {
return model;
} else {
@@ -306,7 +307,8 @@ public void run() {
* Initializes the video capture flag and starts the video capture on
* separate thread
*/
- private void startDataCollectorVideoCapture() {
+ private static void startDataCollectorVideoCapture(final Context ctx)
+ {
// Wait for the tcpdump to start
if (mVideoRecording) {
new Thread(new Runnable() {
@@ -314,8 +316,8 @@ private void startDataCollectorVideoCapture() {
public void run() {
mApp.setAROVideoCaptureRunningFlag(true);
try {
- mApp.initVideoTraceTime();
- startScreenVideoCapture();
+ ARODataCollector.initVideoTraceTime(ctx);
+ startScreenVideoCapture(ctx);
} catch (FileNotFoundException e) {
AROLogger.e(TAG, "exception in initVideoTraceTime. Failed to start Video", e);
}
@@ -387,7 +389,7 @@ private void startTcpDump() throws IOException, InterruptedException {
//We will continue and block the thread untill we see valid instance of tcpdump running in shell
//waitFor() does not seems to be working on ICS firmware
- while (mAROTaskManagerProcessInfo.pstcpdump()) {
+ while (mAROTaskManagerProcessInfo.pstcpdump() == false) {
continue;
}
if (AROLogger.logInfo) {
@@ -499,7 +501,7 @@ private void logFlurryEvents() {
AROCollectorTraceService.backgroundAppsFlurryEvent.getMapToWrite());
}
//trace video y/n
- if ((mApp.getCollectVideoOption() && !mApp.isVideoFileExisting())
+ if ((mApp.getCollectVideoOption() && !ARODataCollector.isVideoFileExisting(getApplicationContext()))
|| mApp.getVideoCaptureFailed()) {
mApp.writeToFlurryAndLogEvent(mApp.flurryVideoTaken, getResources().getText(R.string.flurry_param_traceVideoTaken).toString(),
getResources().getText(R.string.aro_failedvideo).toString(),
@@ -696,7 +698,7 @@ private int getScreenTimeOut() throws SettingNotFoundException {
* Starts the video capture of the device desktop by reading frame buffer
* using ffmpeg command
*/
- private void startScreenVideoCapture() {
+ private static void startScreenVideoCapture(Context ctx) {
Process sh = null;
DataOutputStream os = null;
try {
@@ -731,13 +733,14 @@ private void startScreenVideoCapture() {
}
try {
// Recording start time of video
- mApp.writeVideoTraceTime(Double.toString(mApp.getAROVideoCaptureStartTime()));
- mApp.closeVideoTraceTimeFile();
+ ARODataCollector.writeVideoTraceTime(Double.toString(mApp.getAROVideoCaptureStartTime()));
+ ARODataCollector.closeVideoTraceTimeFile();
} catch (IOException e) {
AROLogger.e(TAG, "IOException in writing video start time", e);
}
- if (mApp.getTcpDumpStartFlag() && !mApp.getARODataCollectorStopFlag()) {
- mApp.setVideoCaptureFailed(true);
+ if (mApp.getTcpDumpStartFlag() && !mApp.getARODataCollectorStopFlag())
+ {
+ ARODataCollector.setVideoCaptureFailed(ctx, false);
}
try {
mApp.setAROVideoCaptureRunningFlag(false);
@@ -895,9 +898,9 @@ private void writAppVersions() throws IOException {
BufferedReader appNamesFileReader = null;
BufferedWriter appNmesFileWriter = null;
try {
- final String strTraceFolderName = mApp.getTcpDumpTraceFolderName();
+ final String strTraceFolderName = ARODataCollector.getTcpDumpTraceFolderName(getApplicationContext());
AROLogger.i(TAG, "Trace folder name is: " + strTraceFolderName);
- final File appNameFile = new File(mApp.getTcpDumpTraceFolderName() + APP_NAME_FILE);
+ final File appNameFile = new File(ARODataCollector.getTcpDumpTraceFolderName(getApplicationContext()) + APP_NAME_FILE);
appNamesFileReader = new BufferedReader(new InputStreamReader(new FileInputStream(
appNameFile)));
String processName = null;
@@ -963,7 +966,7 @@ public void run() {
if (AROCollectorTraceService.getServiceObj() != null) {
AROLogger.d(TAG, "Inside Ping Connection....hideProgressDialog");
AROLogger.d(TAG, "Setting Data Collector stop flag");
- mApp.setARODataCollectorStopFlag(true);
+ ARODataCollector.setARODataCollectorStopFlag(getApplicationContext(), true);
try {
// Going to ping google to break out of tcpdump
// while loop to come out of native shell and stop
diff --git a/ARODataCollector/src/com/att/android/arodatacollector/main/AROCollectorTraceService.java b/ARODataCollector/src/com/att/android/arodatacollector/main/AROCollectorTraceService.java
index c4a85a9f..c7bfeb8f 100644
--- a/ARODataCollector/src/com/att/android/arodatacollector/main/AROCollectorTraceService.java
+++ b/ARODataCollector/src/com/att/android/arodatacollector/main/AROCollectorTraceService.java
@@ -32,6 +32,7 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Locale;
import java.util.Timer;
import java.util.TimerTask;
import java.util.regex.Matcher;
@@ -447,7 +448,7 @@ public void setCpuScriptPid(String pid) {
* @return full path of the cpu dir
*/
private String getCpuDirFullPath(){
- return mApp.getTcpDumpTraceFolderName() + CPU_DIR;
+ return ARODataCollector.getTcpDumpTraceFolderName(getApplicationContext()) + CPU_DIR;
}
@@ -941,7 +942,7 @@ private int getDeviceNetworkType(NetworkInfo mCurrentNetworkType) {
*/
private void initAROTraceFile() throws FileNotFoundException {
- final String mAroTraceDatapath = mApp.getTcpDumpTraceFolderName();
+ final String mAroTraceDatapath = ARODataCollector.getTcpDumpTraceFolderName(getApplicationContext());
if (AROLogger.logDebug) {
AROLogger.d(TAG, "mAroTraceDatapath=" + mAroTraceDatapath);
}
@@ -2044,9 +2045,9 @@ private boolean checkCurrentProcessStateForGround(String processname) {
.hasNext();) {
final RunningAppProcessInfo runningAppProcessInfo = (RunningAppProcessInfo) iterator
.next();
- final String pSname = runningAppProcessInfo.processName.toLowerCase();
+ final String pSname = runningAppProcessInfo.processName.toLowerCase(Locale.getDefault());
final int pImportance = runningAppProcessInfo.importance;
- if (pSname.contains(processname.toLowerCase())) {
+ if (pSname.contains(processname.toLowerCase(Locale.getDefault()))) {
switch (pImportance) {
case RunningAppProcessInfo.IMPORTANCE_FOREGROUND:
return true;
diff --git a/ARODataCollector/src/com/att/android/arodatacollector/main/ARODataCollector.java b/ARODataCollector/src/com/att/android/arodatacollector/main/ARODataCollector.java
index 2e76157b..ef031da9 100644
--- a/ARODataCollector/src/com/att/android/arodatacollector/main/ARODataCollector.java
+++ b/ARODataCollector/src/com/att/android/arodatacollector/main/ARODataCollector.java
@@ -157,7 +157,7 @@ public class ARODataCollector extends Application {
public Map flurryError = new HashMap();
/** The ARO Data Collector trace folder name */
- private String mTraceFolderName;
+ private static String mTraceFolderName = AROCollectorUtils.getDefaultTraceFolderName();
/**
* The notification manager class to display ARO-Data Collector alert menu
@@ -169,7 +169,7 @@ public class ARODataCollector extends Application {
* String to keep trace folder name to be edited which has spaces and
* special characters in it
*/
- private String traceFolderNamehasError;
+ private static String traceFolderNamehasError = AROCollectorUtils.getDefaultTraceFolderName();
/** Notification to be used for alert menu */
public Notification mAROnotification;
@@ -181,10 +181,10 @@ public class ARODataCollector extends Application {
private boolean mDCLaunchfromAnalyzer;
/** OutputStaream for video_time file */
- private OutputStream mTraceVideoTimeStampFile;
+ private static OutputStream mTraceVideoTimeStampFile;
/** BufferedWriter for video_time file */
- private BufferedWriter mTraceVideoTimeStampWriter;
+ private static BufferedWriter mTraceVideoTimeStampWriter;
/** tcpdump start time which is read from TIME file */
private Double pcapStartTime;
@@ -213,7 +213,7 @@ public class ARODataCollector extends Application {
private Dialog aroProgressDialog;
/** ARO Data Collector is wifi lost flag */
- private boolean requestDataCollectorStop = false;
+ private static boolean requestDataCollectorStop = false;
/** Stores the value to find if launch of collector from Analyzer */
private boolean mDataCollectorStopDisable = false;
@@ -464,8 +464,8 @@ private void PushDataCollectorFFmpegToNative() throws IOException {
*
* @throws IOException
*/
- public void writeTimetoFile(BufferedWriter outputfilewriter, String timestamp)
- throws IOException {
+ public static void writeTimetoFile(BufferedWriter outputfilewriter, String timestamp) throws IOException
+ {
final String eol = System.getProperty("line.separator");
outputfilewriter.write(timestamp + eol);
}
@@ -477,8 +477,9 @@ public void writeTimetoFile(BufferedWriter outputfilewriter, String timestamp)
* @throws IOException
*/
- public void readPcapStartEndTime() throws IOException {
- final File file = new File(getTcpDumpTraceFolderName(), TIME_FILE);
+ public void readPcapStartEndTime(Context ctx) throws IOException
+ {
+ final File file = new File(getTcpDumpTraceFolderName(ctx), TIME_FILE);
final BufferedReader br = new BufferedReader(new FileReader(file));
try {
String line;
@@ -511,7 +512,7 @@ public void readPcapStartEndTime() throws IOException {
* @throws IOException
*/
- public void writeVideoTraceTime(String timestamp) throws IOException {
+ public static void writeVideoTraceTime(String timestamp) throws IOException {
writeTimetoFile(mTraceVideoTimeStampWriter, timestamp);
}
@@ -520,7 +521,7 @@ public void writeVideoTraceTime(String timestamp) throws IOException {
*
* @throws IOException
*/
- public void closeVideoTraceTimeFile() throws IOException {
+ public static void closeVideoTraceTimeFile() throws IOException {
mTraceVideoTimeStampWriter.close();
mTraceVideoTimeStampFile.close();
}
@@ -533,8 +534,9 @@ public void closeVideoTraceTimeFile() throws IOException {
* @throws FileNotFoundException
*/
- public void initVideoTraceTime() throws FileNotFoundException {
- mTraceVideoTimeStampFile = new FileOutputStream(getTcpDumpTraceFolderName()
+ public static void initVideoTraceTime(Context ctx) throws FileNotFoundException
+ {
+ mTraceVideoTimeStampFile = new FileOutputStream(getTcpDumpTraceFolderName(ctx)
+ outVideoTimeFileName);
mTraceVideoTimeStampWriter = new BufferedWriter(new OutputStreamWriter(
mTraceVideoTimeStampFile));
@@ -644,10 +646,14 @@ public double getAROVideoCaptureStartTime() {
/**
* Gets the path name of the ARO Data Collector tcpdump trace folder.
*
+ * @param ctx
+ * A handle to the Context , this will be used to store the flag
+ *
* @return A string that is the trace folder path name.
*/
- public String getTcpDumpTraceFolderName() {
- return (ARO_TRACE_ROOTDIR + getDumpTraceFolderName() + "/");
+ public static String getTcpDumpTraceFolderName(Context ctx)
+ {
+ return (ARO_TRACE_ROOTDIR + getDumpTraceFolderName(ctx) + "/");
}
/**
@@ -655,9 +661,11 @@ public String getTcpDumpTraceFolderName() {
* string.
*
* @param traceFolderName A string value that is the trace folder name.
+ * @param ctx A handle to the Context , this will be used to store the flag
*/
- public void setTcpDumpTraceFolderName(String traceFolderName) {
- final SharedPreferences prefs = getSharedPreferences(PREFS, 0);
+ public static void setTcpDumpTraceFolderName(Context ctx, String traceFolderName)
+ {
+ final SharedPreferences prefs = ctx.getSharedPreferences(PREFS, 0);
SharedPreferences.Editor editor = prefs.edit();
editor.putString("TraceFolderName", traceFolderName);
editor.commit();
@@ -666,11 +674,22 @@ public void setTcpDumpTraceFolderName(String traceFolderName) {
/**
* Gets the ARO Data Collector trace folder name.
*
- * @return A string that is the ARO Data Collector trace folder name.
+ * @param ctx
+ * A handle to the Context , this will be used to store the flag
+ *
+ * @return A string that is the ARO Data Collector trace folder name.
*/
- public String getDumpTraceFolderName() {
- final SharedPreferences prefs = getSharedPreferences(PREFS, 0);
+ public static String getDumpTraceFolderName(Context ctx)
+ {
+ final SharedPreferences prefs = ctx.getSharedPreferences(PREFS, 0);
mTraceFolderName = prefs.getString("TraceFolderName", null);
+
+ if (mTraceFolderName == null)
+ {
+ mTraceFolderName = AROCollectorUtils.getDefaultTraceFolderName();
+ }
+ setTcpDumpTraceFolderName(ctx, mTraceFolderName);
+
return (mTraceFolderName);
}
@@ -678,12 +697,16 @@ public String getDumpTraceFolderName() {
* Sets a value that enables the Video Recording collection option for an
* ARO Data Collector trace.
*
+ * @param ctx
+ * A handle to the Context , this will be used to store the flag
+ *
* @param videoRecording
* A boolean value that is "true" to enable video recording for a
* trace, and "false" otherwise.
*/
- public void setCollectVideoOption(boolean videoRecording) {
- final SharedPreferences prefs = getSharedPreferences(PREFS, 0);
+ public static void setCollectVideoOption(Context ctx, boolean videoRecording)
+ {
+ final SharedPreferences prefs = ctx.getSharedPreferences(PREFS, 0);
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("VideoRecordFlag", videoRecording);
editor.commit();
@@ -739,7 +762,8 @@ public long getAppUpTimeinSeconds() {
* @param tracefoldername
* A string that is the error trace folder name.
*/
- public void setErrorTraceFoldername(String tracefoldername) {
+ public static void setErrorTraceFoldername(String tracefoldername)
+ {
traceFolderNamehasError = tracefoldername;
}
@@ -748,7 +772,8 @@ public void setErrorTraceFoldername(String tracefoldername) {
*
* @return A string that is the trace folder name that contains errors.
*/
- public String getErrorTraceFoldername() {
+ public static String getErrorTraceFoldername()
+ {
return traceFolderNamehasError;
}
@@ -772,9 +797,11 @@ public void setTcpDumpStartFlag(boolean flag) {
* @param flag
* A boolean value that is true if the ARO Data Collector is in
* progress, and false if it is not.
+ * @param ctx
+ * A handle to the Context , this will be used to store the flag
*/
- public void setDataCollectorInProgressFlag(boolean flag) {
- final SharedPreferences prefs = getSharedPreferences(PREFS, 0);
+ public static void setDataCollectorInProgressFlag(Context ctx, boolean flag) {
+ final SharedPreferences prefs = ctx.getSharedPreferences(PREFS, 0);
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("isDataCollectorStartInProgress", flag);
editor.commit();
@@ -873,9 +900,11 @@ public boolean getTcpDumpStartFlag() {
* @param flag
* A boolean value that is "true" if video capture is running
* during the trace, and "false" if it is not.
+ * @param ctx
+ * A handle to the Context , this will be used to store the flag
*/
- public void setARODataCollectorStopFlag(boolean flag) {
- final SharedPreferences prefs = getSharedPreferences(PREFS, 0);
+ public static void setARODataCollectorStopFlag(Context ctx, boolean flag) {
+ final SharedPreferences prefs = ctx.getSharedPreferences(PREFS, 0);
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("isARODataCollectorStopped", flag);
editor.commit();
@@ -898,7 +927,8 @@ public boolean getARODataCollectorStopFlag() {
*
* @return A long integer that represents when the trace started for the home page timer.
*/
- public long getElapsedTimeStartTime() {
+ public long getElapsedTimeStartTime()
+ {
final SharedPreferences prefs = getSharedPreferences(PREFS, 0);
final long elapsedTimeStartTime = prefs.getLong("elapsedTimeStartTime", 0);
return elapsedTimeStartTime;
@@ -910,8 +940,9 @@ public long getElapsedTimeStartTime() {
* @param paramElapsedTimeStartTime
* A long integer that represents when the trace started for the home page timer.
*/
- public void setElapsedTimeStartTime(long paramElapsedTimeStartTime) {
- final SharedPreferences prefs = getSharedPreferences(PREFS, 0);
+ public static void setElapsedTimeStartTime(Context ctx, long paramElapsedTimeStartTime)
+ {
+ final SharedPreferences prefs = ctx.getSharedPreferences(PREFS, 0);
SharedPreferences.Editor editor = prefs.edit();
editor.putLong("elapsedTimeStartTime", paramElapsedTimeStartTime);
editor.commit();
@@ -1021,9 +1052,12 @@ public boolean getVideoCaptureFailed() {
* @param flag
* boolean value that is "true" if the video capture has failed,
* and "false" if it has not.
+ * @param ctx
+ * A handle to the Context , this will be used to store the flag
*/
- public void setVideoCaptureFailed(boolean flag) {
- final SharedPreferences prefs = getSharedPreferences(PREFS, 0);
+ public static void setVideoCaptureFailed(Context ctx, boolean flag)
+ {
+ final SharedPreferences prefs = ctx.getSharedPreferences(PREFS, 0);
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("isVideoCaptureFailed", flag);
editor.commit();
@@ -1132,9 +1166,9 @@ public boolean getTaskKillerAllTasksSelected() {
* @return A boolean value that is true if the video.mp4 file exists in the
* current trace folder and is larger than 0 bytes. Otherwise, the value is false.
*/
- public boolean isVideoFileExisting() {
+ public static boolean isVideoFileExisting(Context ctx) {
final String videoAbsolutePath = ARODataCollector.ARO_TRACE_ROOTDIR
- + this.getDumpTraceFolderName() + "/" + videoMp4;
+ + ARODataCollector.getTcpDumpTraceFolderName(ctx) + "/" + videoMp4;
if (AROLogger.logDebug) {
AROLogger.d(TAG, "isVideoFileExisting()--videoPath: " + videoAbsolutePath);
@@ -1162,8 +1196,9 @@ public boolean isVideoFileExisting() {
* A boolean value that is true if a request
* to stop data collection has been made, and is false otherwise.
*/
- public void setRequestDataCollectorStop(boolean requestDataCollectorStop) {
- this.requestDataCollectorStop = requestDataCollectorStop;
+ public static void setRequestDataCollectorStop(boolean flag)
+ {
+ ARODataCollector.requestDataCollectorStop = flag;
}
/**
@@ -1172,7 +1207,8 @@ public void setRequestDataCollectorStop(boolean requestDataCollectorStop) {
* @return A boolean value that is true if a request to stop data collection
* has been made, and is false otherwise.
*/
- public boolean isRequestDataCollectorStop() {
+ public static boolean isRequestDataCollectorStop()
+ {
return requestDataCollectorStop;
}
diff --git a/ARODataCollector/src/com/att/android/arodatacollector/utils/AROCollectorUtils.java b/ARODataCollector/src/com/att/android/arodatacollector/utils/AROCollectorUtils.java
index 0eb7896e..5629039e 100644
--- a/ARODataCollector/src/com/att/android/arodatacollector/utils/AROCollectorUtils.java
+++ b/ARODataCollector/src/com/att/android/arodatacollector/utils/AROCollectorUtils.java
@@ -444,13 +444,15 @@ public int getProcessID(String processName) throws IOException, InterruptedExcep
*
* @return The default ARO trace folder name.
*/
- public String getDefaultTraceFolderName() {
+ public static String getDefaultTraceFolderName()
+ {
final Date systemDate = new Date();
final Calendar now = Calendar.getInstance();
final int currenthours = systemDate.getHours();
final int currentminutes = systemDate.getMinutes();
final int currentseconds = systemDate.getSeconds();
final int currentdate = now.get(Calendar.DATE); // java calendar
+
int currentmonth = now.get(Calendar.MONTH); // As Jan is defined as 0 in
currentmonth = currentmonth + 1;
if (currentmonth >= 13) // As Jan is defined as 0 in java calendar
@@ -690,11 +692,14 @@ public void OpenHttpConnection() throws ClientProtocolException, IOException {
}
}
- public boolean isTcpDumpRunning(){
+ public boolean isTcpDumpRunning()
+ {
boolean isRunning = false;
- try {
+ try
+ {
isRunning = getProcessID(TCPDUMP_PROCESS_NAME) != 0;
- } catch (Exception e) {
+ } catch (Exception e)
+ {
AROLogger.e(TAG, "ignoring exception in isTcpDumpRunning()", e);
}