/** Shows the Legal terms page to user */ private void acceptLegalTerms() { startActivityForResult( new Intent(AROCollectorSplashActivity.this, AROCollectorLegalTermsActivity.class), TERMS_ACTIVITY); // TODO:Adding code to launch Data Collector from Analyzer final Bundle apkCommandLineParameters = getIntent().getExtras(); if (apkCommandLineParameters != null) { // sendAnalyzerLaunchBroadcast(); final String mAROTraceFolderNamefromAnalyzer = apkCommandLineParameters.getString("TraceFolderName"); String mAROTraceStopDuration = apkCommandLineParameters.getString("TraceStopDuration"); if (mAROTraceStopDuration == null) { mAROTraceStopDuration = "0"; } mApp.setTcpDumpTraceFolderName(mAROTraceFolderNamefromAnalyzer); mApp.setTraceStopDuration(Integer.parseInt(mAROTraceStopDuration)); } else { mApp.setTcpDumpTraceFolderName(null); mApp.setTraceStopDuration(0); } if (mApp.getTraceStopDuration() > 0 && mApp.getTcpDumpTraceFolderName() != null) { mApp.setRQMCollectorLaunchfromAnalyzer(true); aroDCStartWatchTimer = new Timer(); aroDCStartWatchTimer.schedule( new TimerTask() { @Override public void run() { startMainActivity(); // Cancel the timers aroDCStartWatchTimer.cancel(); } }, ARO_LEGAL_AUTO_ACCEPT_TIME); } else { mApp.setRQMCollectorLaunchfromAnalyzer(false); } }
/** * Handles the result of an activity performed on the UI of the Splash screen when calling * activity from the current instance has finished and released memory. Overrides the * android.app.Activity# onActivityResult method. * * @param requestCode A code representing a request to the UI of the Splash screen. * @param resultCode A code representing the result of an activity performed on the UI of the * Splash screen. * @param data An Intent object that contains data associated with the result of the activity. */ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == TERMS_ACTIVITY) { AROLogger.d(TAG, "inside onActivityResult, resultCode=" + resultCode); if (resultCode == AROCollectorLegalTermsActivity.TERMS_ACCEPTED) { AROLogger.d(TAG, "inside onActivityResult, starting main activity"); startMainActivity(); } else { AROLogger.d(TAG, "inside onActivityResult, term not accepted, closing activity"); /*if (resultCode == AROCollectorLegalTermsActivity.TERMS_REJECTED){ resetAnalyzerLaunchWaitingIndicator(); }*/ finish(); } if (aroDCStartWatchTimer != null && mApp.isRQMCollectorLaunchfromAnalyzer()) { aroDCStartWatchTimer.cancel(); } } super.onActivityResult(requestCode, resultCode, data); }
/** * Initializes data members with a saved instance of an AROCollectorMainActivity object. Overrides * the android.app.Activity#onCreate method. * * @param savedInstanceState A saved instance of an AROCollectorSplashActivity object. * @see android.app.Activity#onCreate(android.os.Bundle) */ @Override protected void onCreate(Bundle savedInstanceState) { // The Display object to fetch the current device display properties // like height,width Display mScreenDisplay; super.onCreate(savedInstanceState); if (AROCollectorService.getServiceObj() != null) { AROLogger.d(TAG, "collector already running, going to home screen"); startAROHomeActivity(); return; } requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow() .setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); mApp = (ARODataCollector) getApplication(); mScreenDisplay = getWindowManager().getDefaultDisplay(); mApp.setDeviceScreenHeight(mScreenDisplay.getHeight()); mApp.setDeviceScreenWidth(mScreenDisplay.getWidth()); setContentView(R.layout.splash); final TextView version = (TextView) findViewById(R.id.version); version.setText("Version " + mApp.getVersion()); if (mScreenDisplay.getHeight() < SCREEN_HEIGHT_TOADJUST) { final TextView SplashMessage = (TextView) findViewById(R.id.splash_message); final String splashmessagestring = SplashMessage.getText().toString(); if ((splashmessagestring.startsWith("Do"))) { final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT); layoutParams.setMargins(15, 160, 0, 0); SplashMessage.setLayoutParams(layoutParams); } } // add check after screen setup to avoid black screen if (ARODataCollector.isAnalyzerLaunchInProgress()) { // already launched via analyzer showAnalyzerLaunchInProgress(); return; } // new launch, clean up old screen sendAnalyzerLaunchBroadcast(); if (isAnalyzerLaunch()) { AROLogger.d(TAG, "analyzer launch, setAnalyzerLaunchInProgress(true)"); ARODataCollector.setAnalyzerLaunchInProgress(true); } // we'll need a timer thread to make sure the screen is // displayed for at least SPLASH_DISPLAY_TIME seconds final Thread timerThread = new Thread( new Runnable() { public void run() { if (AROLogger.logDebug) { AROLogger.d( TAG, "timerThread started at timestamp:" + System.currentTimeMillis()); } long timeRemaining = SPLASH_DISPLAY_TIME; long stopTime = System.currentTimeMillis() + timeRemaining; synchronized (mMutex) { do { try { if (timeRemaining == 0) { // we already ran out of time so we must be // waiting for initialization to complete mMutex.wait(); } else { mMutex.wait(timeRemaining); } } catch (InterruptedException e) { AROLogger.e(TAG, "Splash Screen InterruptedException", e); } if (timeRemaining > 0) { // recalculate time remaining long currentTime = System.currentTimeMillis(); if (currentTime < stopTime) { timeRemaining = stopTime - currentTime; } else { timeRemaining = 0; } } } while (!mActivityFinished && (!mInitialized || (!mAbortSplash && timeRemaining > 0))); } if (!mActivityFinished) { mHandler.post( new Runnable() { public void run() { if (AROLogger.logDebug) { AROLogger.d( TAG, "checking for root access at timestamp:" + System.currentTimeMillis()); } if (mApp != null) { if (mApp.hasRootAccess()) { acceptLegalTerms(); // TODO : EULA Method Call } else { showNoRootAccessDialog(); } } else { AROLogger.e(TAG, "mApp is null"); } } }); } } }); // and another thread to do whatever initialization is needed final Thread initializeThread = new Thread( new Runnable() { public void run() { if (AROLogger.logDebug) { AROLogger.d( TAG, "start initializeThread at timestamp:" + System.currentTimeMillis()); } try { if (mApp != null) { mApp.initARODataCollector(); } } finally { if (AROLogger.logDebug) { AROLogger.d( TAG, "initialization complete at timestamp:" + System.currentTimeMillis()); } synchronized (mMutex) { mInitialized = true; mMutex.notify(); } } } }); timerThread.start(); initializeThread.start(); }