<commit_before>/*
 garlic-player: SMIL Player for Digital Signage
 Copyright (C) 2016 <NAME> <<EMAIL>>
 This file is part of the garlic-player source code

 This program is free software: you can redistribute it and/or  modify
 it under the terms of the GNU Affero General Public License, version 3,
 as published by the Free Software Foundation.

 This program 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 Affero General Public License for more details.

 You should have received a copy of the GNU Affero General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

package com.sagiadinos.garlic.player.java;

import android.content.Context;
import android.os.Environment;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.PowerManager;
import java.util.concurrent.ExecutionException;

public class GarlicActivity extends org.qtproject.qt5.android.bindings.QtActivity
{
    private static  GarlicActivity m_instance;
    private AsyncTask<Void, Void, String> runningTaskSmilIndex;
    private AsyncTask<Void, Void, String> runningTaskUUID;
    private AsyncTask<Void, Void, String> runningTaskLauncherVersion;
    private String content_url      = null;
    private String uuid             = null;
    private String launcher_version = null;

    public GarlicActivity()
    {
        m_instance = this;
    }

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        if (isLauncherInstalled())
        {
            retrieveSmilIndex();
            retrieveUUID();
            retrieveLauncherVersion();
        }
    }

    public void registerBroadcastReceiver()
    {

        IntentFilter filter = new IntentFilter("com.sagiadinos.garlic.player.java.ConfigReceiver");
        ConfigReceiver MyConfigReceiver = new ConfigReceiver();
        registerReceiver(MyConfigReceiver, filter);

        // needed when USB Stick enters with local SMIL File
        IntentFilter filter2 = new IntentFilter("com.sagiadinos.garlic.player.java.SmilIndexReceiver");
        SmilIndexReceiver MySmilIndexReceiver = new SmilIndexReceiver();
        registerReceiver(MySmilIndexReceiver, filter2);
    }

    public boolean isLauncherInstalled()
    {
        PackageManager pm = getPackageManager();
        try
        {
            pm.getPackageInfo("com.sagiadinos.garlic.launcher", PackageManager.GET_META_DATA);
        }
        catch (PackageManager.NameNotFoundException e)
        {
            return false;
        }
        return true;
    }

    public String getContentUrlFromLauncher()
    {
        return content_url;
    }

    public String getUUIDFromLauncher()
    {
        return uuid;
    }

    public String getLauncherVersion()
    {
        return launcher_version;
    }

    public static boolean isPackageInstalled(Context c, String targetPackage)
    {
        PackageManager pm = m_instance.getPackageManager();
        try
        {
            pm.getPackageInfo(targetPackage, PackageManager.GET_META_DATA);
        }
        catch (PackageManager.NameNotFoundException e)
        {
            return false;
        }
        return true;
    }

    public static void setScreenOff()
    {
        Intent intent = new Intent("com.sagiadinos.garlic.launcher.receiver.CommandReceiver");
        intent.putExtra("command", "screen_off");
        m_instance.sendBroadcast(intent);
    }

    public static void setScreenOn()
    {
        Intent intent = new Intent("com.sagiadinos.garlic.launcher.receiver.CommandReceiver");
        intent.putExtra("command", "screen_on");
        m_instance.sendBroadcast(intent);
    }

    public static void rebootOS(String task_id)
    {
        Intent intent = new Intent("com.sagiadinos.garlic.launcher.receiver.RebootReceiver");
        intent.putExtra("task_id", task_id);
        m_instance.sendBroadcast(intent);

/*        Intent intent = new Intent("com.sagiadinos.garlic.launcher.receiver.CommandReceiver");
        intent.putExtra("command", "reboot");
        intent.putExtra("task_id", task_id);
        m_instance.sendBroadcast(intent);
*/    }

    public static void applyConfig(String config_path)
    {
        Intent intent = new Intent("com.sagiadinos.garlic.launcher.receiver.ConfigXMLReceiver");
        intent.putExtra("config_path", config_path);
        m_instance.sendBroadcast(intent);
    }

    public static void installSoftware(String apk_path)
    {
        Intent intent = new Intent("com.sagiadinos.garlic.launcher.receiver.InstallAppReceiver");
        intent.putExtra("apk_path", apk_path);
        m_instance.sendBroadcast(intent);<commit_msg>reboot sends now intends to new commandreceiver<commit_after>/*
 garlic-player: SMIL Player for Digital Signage
 Copyright (C) 2016 <NAME> <<EMAIL>>
 This file is part of the garlic-player source code

 This program is free software: you can redistribute it and/or  modify
 it under the terms of the GNU Affero General Public License, version 3,
 as published by the Free Software Foundation.

 This program 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 Affero General Public License for more details.

 You should have received a copy of the GNU Affero General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

package com.sagiadinos.garlic.player.java;

import android.content.Context;
import android.os.Environment;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.PowerManager;
import java.util.concurrent.ExecutionException;

public class GarlicActivity extends org.qtproject.qt5.android.bindings.QtActivity
{
    private static  GarlicActivity m_instance;
    private AsyncTask<Void, Void, String> runningTaskSmilIndex;
    private AsyncTask<Void, Void, String> runningTaskUUID;
    private AsyncTask<Void, Void, String> runningTaskLauncherVersion;
    private String content_url      = null;
    private String uuid             = null;
    private String launcher_version = null;

    public GarlicActivity()
    {
        m_instance = this;
    }

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        if (isLauncherInstalled())
        {
            retrieveSmilIndex();
            retrieveUUID();
            retrieveLauncherVersion();
        }
    }

    public void registerBroadcastReceiver()
    {

        IntentFilter filter = new IntentFilter("com.sagiadinos.garlic.player.java.ConfigReceiver");
        ConfigReceiver MyConfigReceiver = new ConfigReceiver();
        registerReceiver(MyConfigReceiver, filter);

        // needed when USB Stick enters with local SMIL File
        IntentFilter filter2 = new IntentFilter("com.sagiadinos.garlic.player.java.SmilIndexReceiver");
        SmilIndexReceiver MySmilIndexReceiver = new SmilIndexReceiver();
        registerReceiver(MySmilIndexReceiver, filter2);
    }

    public boolean isLauncherInstalled()
    {
        PackageManager pm = getPackageManager();
        try
        {
            pm.getPackageInfo("com.sagiadinos.garlic.launcher", PackageManager.GET_META_DATA);
        }
        catch (PackageManager.NameNotFoundException e)
        {
            return false;
        }
        return true;
    }

    public String getContentUrlFromLauncher()
    {
        return content_url;
    }

    public String getUUIDFromLauncher()
    {
        return uuid;
    }

    public String getLauncherVersion()
    {
        return launcher_version;
    }

    public static boolean isPackageInstalled(Context c, String targetPackage)
    {
        PackageManager pm = m_instance.getPackageManager();
        try
        {
            pm.getPackageInfo(targetPackage, PackageManager.GET_META_DATA);
        }
        catch (PackageManager.NameNotFoundException e)
        {
            return false;
        }
        return true;
    }

    public static void setScreenOff()
    {
        Intent intent = new Intent("com.sagiadinos.garlic.launcher.receiver.CommandReceiver");
        intent.putExtra("command", "screen_off");
        m_instance.sendBroadcast(intent);
    }

    public static void setScreenOn()
    {
        Intent intent = new Intent("com.sagiadinos.garlic.launcher.receiver.CommandReceiver");
        intent.putExtra("command", "screen_on");
        m_instance.sendBroadcast(intent);
    }

    public static void rebootOS(String task_id)
    {
        Intent intent = new Intent("com.sagiadinos.garlic.launcher.receiver.CommandReceiver");
        intent.putExtra("command", "reboot");
        intent.putExtra("task_id", task_id);
        m_instance.sendBroadcast(intent);
    }

    public static void applyConfig(String config_path)
    {
        Intent intent = new Intent("com.sagiadinos.garlic.launcher.receiver.ConfigXMLReceiver");
        intent.putExtra("config_path", config_path);
        m_instance.sendBroadcast(intent);
    }

    public static void installSoftware(String apk_path)
    {
        Intent intent = new Intent("com.sagiadinos.garlic.launcher.receiver.InstallAppReceiver");
        intent.putExtra("apk_path", apk_path);
        m_instance.sendBroadcast(intent);
{'fraction_non_alphanumeric': 0.08268424206111444, 'fraction_numerical': 0.001597763131615738, 'mean_word_length': 3.0860873113015095, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3876492', 'n_tokens_mistral': 2732, 'n_tokens_neox': 2673, 'n_words': 684}