<commit_before>package sk.henrichg.phoneprofilesplus;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.provider.Settings;
import android.support.v7.app.AppCompatActivity;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;

public class LockDeviceActivity extends AppCompatActivity {

    private View view = null;

    @SuppressLint("InflateParams")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        overridePendingTransition(0, 0);

        PPApplication.logE("LockDeviceActivity.onCreate", "xxx");

        PPApplication.lockDeviceActivity = this;

        /*
        View decorView = getWindow().getDecorView();
        int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        decorView.setSystemUiVisibility(uiOptions);

        setContentView(R.layout.activity_lock_device);

        WindowManager.LayoutParams lp = getWindow().getAttributes();
        lp.screenBrightness =0.005f;
        getWindow().setAttributes(lp);
        */

        PPApplication.screenTimeoutBeforeDeviceLock = Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, 15000);
        ActivateProfileHelper.screenTimeoutUnlock(getApplicationContext());
        Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, 1000);

        WindowManager.LayoutParams params = new WindowManager.LayoutParams();
        params.flags = 1808;
        //TODO Android O
        //if (android.os.Build.VERSION.SDK_INT < 26)
            params.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
        //else
        //    params.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
        params.gravity = Gravity.TOP;
        params.width = -1;
        params.height = -1;
        params.format = -1;
        params.screenBrightness = 0f;

        LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = layoutInflater.inflate(R.layout.activity_lock_device, null);
        view.setSystemUiVisibility(5894);
        view.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
            @Override
            public void onSystemUiVisibilityChange(int i) {
                view.setSystemUiVisibility(5894);
            }
        });

        WindowManager windowManager = (WindowManager)getSystemService(Context.WINDOW_SERVICE);
        if (windowManager != null)
            windowManager.addView(view, params);

        /*
        WindowManager.LayoutParams aParams = getWindow().getAttributes();
        aParams.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
        aParams.screenBrightness = 0;
        getWindow().setAttributes(aParams);
        */

        LockDeviceActivityFinishBroadcastReceiver.setAlarm(getApplicationContext());
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

        PPApplication.logE("LockDeviceActivity.onDestroy", "xxx");

        if (view != null)
            try {
                WindowManager windowManager = (WindowManager)getSystemService(Context.WINDOW_SERVICE);
                if (windowManager != null)
                    windowManager.removeViewImmediate(view);
            } catch (Exception ignored) {}

        PPApplication.lockDeviceActivity = null;
        if (Permissions.checkLockDevice(getApplicationContext()))
            Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, PPApplication.screenTimeoutBeforeDeviceLock);
    }

    @Override
    public void finish()
    {
        super.finish();
        overridePendingTransition(0, 0);
    }

}<commit_msg>Changed some Handlers to AlarmManager. (2)<commit_after>package sk.henrichg.phoneprofilesplus;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.provider.Settings;
import android.support.v7.app.AppCompatActivity;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;

public class LockDeviceActivity extends AppCompatActivity {

    private View view = null;

    @SuppressLint("InflateParams")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        overridePendingTransition(0, 0);

        PPApplication.logE("LockDeviceActivity.onCreate", "xxx");

        PPApplication.lockDeviceActivity = this;

        /*
        View decorView = getWindow().getDecorView();
        int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        decorView.setSystemUiVisibility(uiOptions);

        setContentView(R.layout.activity_lock_device);

        WindowManager.LayoutParams lp = getWindow().getAttributes();
        lp.screenBrightness =0.005f;
        getWindow().setAttributes(lp);
        */

        PPApplication.screenTimeoutBeforeDeviceLock = Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, 15000);
        ActivateProfileHelper.screenTimeoutUnlock(getApplicationContext());
        Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, 1000);

        WindowManager.LayoutParams params = new WindowManager.LayoutParams();
        params.flags = 1808;
        //TODO Android O
        //if (android.os.Build.VERSION.SDK_INT < 26)
            params.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
        //else
        //    params.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
        params.gravity = Gravity.TOP;
        params.width = -1;
        params.height = -1;
        params.format = -1;
        params.screenBrightness = 0f;

        LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = layoutInflater.inflate(R.layout.activity_lock_device, null);
        view.setSystemUiVisibility(5894);
        view.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
            @Override
            public void onSystemUiVisibilityChange(int i) {
                view.setSystemUiVisibility(5894);
            }
        });

        WindowManager windowManager = (WindowManager)getSystemService(Context.WINDOW_SERVICE);
        if (windowManager != null)
            windowManager.addView(view, params);

        /*
        WindowManager.LayoutParams aParams = getWindow().getAttributes();
        aParams.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
        aParams.screenBrightness = 0;
        getWindow().setAttributes(aParams);
        */

        LockDeviceActivityFinishBroadcastReceiver.setAlarm(getApplicationContext());
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

        PPApplication.logE("LockDeviceActivity.onDestroy", "xxx");

        if (view != null)
            try {
                WindowManager windowManager = (WindowManager)getSystemService(Context.WINDOW_SERVICE);
                if (windowManager != null)
                    windowManager.removeViewImmediate(view);
            } catch (Exception ignored) {}

        LockDeviceActivityFinishBroadcastReceiver.removeAlarm(getApplicationContext());
        PPApplication.lockDeviceActivity = null;
        if (Permissions.checkLockDevice(getApplicationContext()))
            Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, PPApplication.screenTimeoutBeforeDeviceLock);
    }

    @Override
    public void finish()
    {
        super.finish();
        overridePendingTransition(0, 0);
    }

}
{'fraction_non_alphanumeric': 0.09381799564827852, 'fraction_numerical': 0.009599385639319084, 'mean_word_length': 3.1191354770690563, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '2897086', 'n_tokens_mistral': 2133, 'n_tokens_neox': 2033, 'n_words': 328}