Skip to content

Allows a 3rd party to start/stop ARO #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

.DS_Store
bin
6 changes: 6 additions & 0 deletions ARODataCollector/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@
android:name=".activities.AROCollectorLegalTermsActivity"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="portrait" />
<receiver android:name=".activities.StartStopReceiver">
<intent-filter>
<action android:name="com.att.android.arodatacollector.STARTARO"/>
<action android:name="com.att.android.arodatacollector.STOPARO"/>
</intent-filter>
</receiver>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -114,24 +114,24 @@ 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
// user
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() ) {
videotrace.setText(getResources().getText(R.string.aro_yestext));
} else {
videotrace.setText(getResources().getText(R.string.aro_notext));
}
mApp.setTcpDumpTraceFolderName(null);
//ARODataCollector.setTcpDumpTraceFolderName(getApplicationContext(), null);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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();
Expand All @@ -257,6 +263,8 @@ public void onClick(View v) {
}
});
handleARODataCollectorErrors(getIntent().getExtras().getInt(ARODataCollector.ERRODIALOGID));

ARODataCollector.setTcpDumpTraceFolderName(getApplicationContext(),null);
}

/**
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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));
}
Expand All @@ -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();
Expand All @@ -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
Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}

}
Loading