<commit_before>package core.task.restart;

import core.command.CommandExecutor;
import core.message.DeployMessage;
import core.message.RestartAppMessage;
import core.task.Task;
import core.task.TaskPurpose;
import core.telemetry.Telemetry;

public class RestartAppTask implements Task<DeployMessage, RestartAppMessage> {

    private final String androidSdkPath;
    private final String appPackage;
    private final String mainActivity;

    public RestartAppTask(String androidSdkPath, String appPackage, String mainActivity) {
        this.androidSdkPath = androidSdkPath;
        this.appPackage = appPackage;
        this.mainActivity = mainActivity;
    }

    @Override
    public TaskPurpose getPurpose() {
        return TaskPurpose.RESTART_APPLICATION;
    }

    @Override
    public RestartAppMessage exec(Telemetry telemetry, DeployMessage message) {
        telemetry.message("Application package: %s", appPackage);
        telemetry.message("Application launcher activity: %s", mainActivity);
        telemetry.message("Restarting...");

        String cmdForceStop = String.format("adb shell am force-stop %s", appPackage);
        String cmdStart = String.format("adb shell am start -n \"%s/%s\" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER", appPackage, mainActivity);
        CommandExecutor.exec(cmdForceStop);
        CommandExecutor.exec(cmdStart);
        return null;
    }
}
<commit_msg>Fix for running adb tool.<commit_after>package core.task.restart;

import core.command.CommandExecutor;
import core.message.DeployMessage;
import core.message.RestartAppMessage;
import core.task.Task;
import core.task.TaskPurpose;
import core.telemetry.Telemetry;

public class RestartAppTask implements Task<DeployMessage, RestartAppMessage> {

    private final String androidSdkPath;
    private final String appPackage;
    private final String mainActivity;

    public RestartAppTask(String androidSdkPath, String appPackage, String mainActivity) {
        this.androidSdkPath = androidSdkPath;
        this.appPackage = appPackage;
        this.mainActivity = mainActivity;
    }

    @Override
    public TaskPurpose getPurpose() {
        return TaskPurpose.RESTART_APPLICATION;
    }

    @Override
    public RestartAppMessage exec(Telemetry telemetry, DeployMessage message) {
        telemetry.message("Application package: %s", appPackage);
        telemetry.message("Application launcher activity: %s", mainActivity);
        telemetry.message("Restarting...");

        String adbFilePath = androidSdkPath + "/platform-tools/adb";
        String action = "android.intent.action.MAIN";
        String category = "android.intent.category.LAUNCHER";
        String cmdForceStop = String.format("%s shell am force-stop %s", adbFilePath, appPackage);
        String cmdStart = String.format("%s shell am start -n \"%s/%s\" -a %s -c %s", adbFilePath, appPackage, mainActivity, action, category);
        CommandExecutor.exec(cmdForceStop);
        CommandExecutor.exec(cmdStart);
        return null;
    }
}

{'fraction_non_alphanumeric': 0.09400589584015723, 'fraction_numerical': 0.0, 'mean_word_length': 3.764430577223089, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4732894', 'n_tokens_mistral': 854, 'n_tokens_neox': 833, 'n_words': 206}