<commit_before>/*
 * Copyright (C) 2015-2016 <NAME> <<EMAIL>>
 *
 * This file is part of Kernel Adiutor.
 *
 * Kernel Adiutor is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Kernel Adiutor is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Kernel Adiutor.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
package com.grarak.kerneladiutor.services.profile;

import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;

import com.grarak.kerneladiutor.R;
import com.grarak.kerneladiutor.database.tools.profiles.Profiles;
import com.grarak.kerneladiutor.services.boot.Service;
import com.grarak.kerneladiutor.utils.Prefs;
import com.grarak.kerneladiutor.utils.Utils;
import com.grarak.kerneladiutor.utils.kernel.cpu.CPUFreq;
import com.grarak.kerneladiutor.utils.root.RootUtils;

import java.util.ArrayList;
import java.util.List;

import cyanogenmod.app.CMStatusBarManager;
import cyanogenmod.app.CustomTile;

/**
 * Created by willi on 21.07.16.
 */
public class Tile extends BroadcastReceiver {

    private static final String TAG = Tile.class.getSimpleName();

    private static final String NAME = "name";
    private static final String COMMANDS = "commands";
    private static final String ACTION_TOGGLE_STATE = "com.grarak.kerneladiutor.action.ACTION_TOGGLE_STATE";

    @Override
    public void onReceive(Context context, Intent intent) {
        if (ACTION_TOGGLE_STATE.equals(intent.getAction())) {
            Log.i(TAG, intent.getStringExtra(NAME));
            String[] commands = intent.getStringArrayExtra(COMMANDS);
            if (commands != null) {
                List<String> adjustedCommands = new ArrayList<>();
                RootUtils.SU su = new RootUtils.SU(true, TAG);
                for (String command : commands) {
                    synchronized (this) {
                        CPUFreq.ApplyCpu applyCpu;
                        if (command.startsWith("#") && command.contains("%d")
                                && (applyCpu = new CPUFreq.ApplyCpu(command.substring(1))).toString() != null) {
                            adjustedCommands.addAll(Service.getApplyCpu(applyCpu, su));
                        } else {
                            adjustedCommands.add(command);<commit_msg>Tile: Fix logging<commit_after>/*
 * Copyright (C) 2015-2016 <NAME> <<EMAIL>>
 *
 * This file is part of Kernel Adiutor.
 *
 * Kernel Adiutor is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Kernel Adiutor is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Kernel Adiutor.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
package com.grarak.kerneladiutor.services.profile;

import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;

import com.grarak.kerneladiutor.R;
import com.grarak.kerneladiutor.database.tools.profiles.Profiles;
import com.grarak.kerneladiutor.services.boot.Service;
import com.grarak.kerneladiutor.utils.Prefs;
import com.grarak.kerneladiutor.utils.Utils;
import com.grarak.kerneladiutor.utils.kernel.cpu.CPUFreq;
import com.grarak.kerneladiutor.utils.root.RootUtils;

import java.util.ArrayList;
import java.util.List;

import cyanogenmod.app.CMStatusBarManager;
import cyanogenmod.app.CustomTile;

/**
 * Created by willi on 21.07.16.
 */
public class Tile extends BroadcastReceiver {

    private static final String TAG = Tile.class.getSimpleName();

    private static final String NAME = "name";
    private static final String COMMANDS = "commands";
    private static final String ACTION_TOGGLE_STATE = "com.grarak.kerneladiutor.action.ACTION_TOGGLE_STATE";

    @Override
    public void onReceive(Context context, Intent intent) {
        if (ACTION_TOGGLE_STATE.equals(intent.getAction())) {
            String name = intent.getStringExtra(NAME);
            if (name != null) Log.i(TAG, name);
            String[] commands = intent.getStringArrayExtra(COMMANDS);
            if (commands != null) {
                List<String> adjustedCommands = new ArrayList<>();
                RootUtils.SU su = new RootUtils.SU(true, TAG);
                for (String command : commands) {
                    synchronized (this) {
                        CPUFreq.ApplyCpu applyCpu;
                        if (command.startsWith("#") && command.contains("%d")
                                && (applyCpu = new CPUFreq.ApplyCpu(command.substring(1))).toString() != null) {
                            adjustedCommands.addAll(Service.getApplyCpu(applyCpu, su));
                        } else {
                            adjustedCommands.add(command);
{'fraction_non_alphanumeric': 0.09571478749560941, 'fraction_numerical': 0.005619950825430277, 'mean_word_length': 3.0304317055909413, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5034759', 'n_tokens_mistral': 1645, 'n_tokens_neox': 1550, 'n_words': 461}