Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c8fb818b authored by Maksymilian Osowski's avatar Maksymilian Osowski
Browse files

Changed some parts of the code to prepare it for script support that will come in later commit.

Bug: 2903591

Change-Id: If8fcfad1557c8140c476212d8be9f99987cdaa18
parent 8aff3c05
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -25,8 +25,15 @@ limitations under the License.
            </intent-filter>
        </activity>

        <!-- android:launchMode="singleTask" is there so we only have a one instance
             of this activity. However, it doesn't seem to work exactly like described in the
             documentation, because the behaviour of the application suggest
             there is only a single task for all 3 activities. We don't understand
             how exactly it all works, but at the moment it works just fine.
             It can lead to some weird behaviour in the future. -->
        <activity android:name=".TestsListActivity"
                  android:label="Tests' list activity">
                  android:label="Tests' list activity"
                  android:launchMode="singleTask">
        </activity>

        <activity android:name=".LayoutTestsExecutor"
+7 −1
Original line number Diff line number Diff line
@@ -93,6 +93,11 @@ public class ManagerService extends Service {

                case MSG_ALL_TESTS_FINISHED:
                    mSummarizer.summarize();
                    Intent intent = new Intent(ManagerService.this, TestsListActivity.class);
                    intent.setAction(Intent.ACTION_SHUTDOWN);
                    /** This flag is needed because we send the intent from the service */
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);
                    break;
            }
        }
@@ -166,7 +171,8 @@ public class ManagerService extends Service {

        Intent intent = new Intent(this, TestsListActivity.class);
        intent.setAction(Intent.ACTION_REBOOT);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        /** This flag is needed because we send the intent from the service */
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.putExtra("crashedTestIndex", mCurrentlyRunningTestIndex);
        startActivity(intent);
    }
+14 −6
Original line number Diff line number Diff line
@@ -85,6 +85,15 @@ public class TestsListActivity extends Activity {
        new TestsListPreloaderThread(path, doneMsg).start();
    }

    @Override
    protected void onNewIntent(Intent intent) {
        if (intent.getAction().equals(Intent.ACTION_REBOOT)) {
            onCrashIntent(intent);
        } else if (intent.getAction().equals(Intent.ACTION_SHUTDOWN)) {
            onEverythingFinishedIntent(intent);
        }
    }

    /**
     * This method handles an intent that comes from ManageService when crash is detected.
     * The intent contains an index in mTestsList of the test that crashed. TestsListActivity
@@ -94,18 +103,17 @@ public class TestsListActivity extends Activity {
     * LayoutTestExecutor runs then as usual, sending reports to ManagerService. If it
     * detects the crash it sends a new intent and the flow repeats.
     */
    @Override
    protected void onNewIntent(Intent intent) {
        if (!intent.getAction().equals(Intent.ACTION_REBOOT)) {
            return;
        }

    private void onCrashIntent(Intent intent) {
        int nextTestToRun = intent.getIntExtra("crashedTestIndex", -1) + 1;
        if (nextTestToRun > 0 && nextTestToRun <= mTotalTestCount) {
            restartExecutor(nextTestToRun);
        }
    }

    private void onEverythingFinishedIntent(Intent intent) {
        /** TODO: Show some kind of summary to the user */
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        outState.putStringArrayList("testsList", mTestsList);