<commit_before>package sk.henrichg.phoneprofiles;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.provider.Settings;

public class ScreenOnOffBroadcastReceiver extends BroadcastReceiver {

    public void onReceive(Context context, Intent intent) {
        //Thread.setDefaultUncaughtExceptionHandler(new TopExceptionHandler());

        PPApplication.logE("ScreenOnOffBroadcastReceiver.onReceive","xxx");

        if (!PPApplication.getApplicationStarted(context, true))
            // application is not started
            return;

        PPApplication.logE("ScreenOnOffBroadcastReceiver.onReceive","application started");

        boolean lockDeviceEnabled = false;
        if (PPApplication.lockDeviceActivity != null) {
            lockDeviceEnabled = true;
            PPApplication.lockDeviceActivity.finish();
            PPApplication.lockDeviceActivity.overridePendingTransition(0, 0);
        }

        //PPApplication.loadPreferences(context);

        if (intent.getAction().equals(Intent.ACTION_SCREEN_ON))
            PPApplication.logE("@@@ ScreenOnOffBroadcastReceiver.onReceive", "screen on");
        else if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
            PPApplication.logE("@@@ ScreenOnOffBroadcastReceiver.onReceive", "screen off");
            ActivateProfileHelper.setScreenUnlocked(context, false);

            if (ApplicationPreferences.notificationShowInStatusBar(context) &&
                    ApplicationPreferences.notificationHideInLockscreen(context)) {
                DataWrapper dataWrapper = new DataWrapper(context, true, false, 0);
                dataWrapper.getActivateProfileHelper().initialize(dataWrapper, context);
                //dataWrapper.getActivateProfileHelper().removeNotification();
                //dataWrapper.getActivateProfileHelper().setAlarmForRecreateNotification();
                Profile activatedProfile = dataWrapper.getActivatedProfile();
                dataWrapper.getActivateProfileHelper().showNotification(activatedProfile);
                dataWrapper.invalidateDataWrapper();
            }
        }
        if (intent.getAction().equals(Intent.ACTION_USER_PRESENT))
        {
            PPApplication.logE("@@@ ScreenOnOffBroadcastReceiver.onReceive", "screen unlock");
            ActivateProfileHelper.setScreenUnlocked(context, true);

            DataWrapper dataWrapper = new DataWrapper(context, true, false, 0);
            dataWrapper.getActivateProfileHelper().initialize(dataWrapper, context);

            if (ApplicationPreferences.notificationShowInStatusBar(context) &&
                    ApplicationPreferences.notificationHideInLockscreen(context)) {
                //dataWrapper.getActivateProfileHelper().removeNotification();
                //dataWrapper.getActivateProfileHelper().setAlarmForRecreateNotification();
                Profile activatedProfile = dataWrapper.getActivatedProfile();
                dataWrapper.getActivateProfileHelper().showNotification(activatedProfile);
                dataWrapper.invalidateDataWrapper();
            }

            // change screen timeout
            if (lockDeviceEnabled && Permissions.checkLockDevice(context))
                Settings.System.putInt(context.getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, PPApplication.screenTimeoutBeforeDeviceLock);
            int screenTimeout = ActivateProfileHelper.getActivatedProfileScreenTimeout(context);
            if (screenTimeout > 0)
                dataWrapper.getActivateProfileHelper().setScreenTimeout(screenTimeout);

            dataWrapper.invalidateDataWrapper();

            // enable/disable keyguard
            Intent keyguardService = new Intent(context.getApplicationContext(), KeyguardService.class);
            context.startService(keyguardService);
        }

        if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
            PPApplication.logE("@@@ ScreenOnOffBroadcastReceiver.onReceive", "screen on");
            if (ApplicationPreferences.notificationShowInStatusBar(context) &&
                    ApplicationPreferences.notificationHideInLockscreen(context)) {
                DataWrapper dataWrapper = new DataWrapper(context, true, false, 0);
                dataWrapper.getActivateProfileHelper().initialize(dataWrapper, context);
                //dataWrapper.getActivateProfileHelper().removeNotification();
                //dataWrapper.getActivateProfileHelper().setAlarmForRecreateNotification();
                Profile activatedProfile = dataWrapper.getActivatedProfile();
                dataWrapper.getActivateProfileHelper().showNotification(activatedProfile);
                dataWrapper.invalidateDataWrapper();
            }
        }

    }

}
<commit_msg>Fixed FC: Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.ContentResolver android.content.Context.getContentResolver()' on a null object reference                  at sk.henrichg.phoneprofiles.ActivateProfileHelper.setScreenTimeout(ActivateProfileHelper.java:1541)<commit_after>package sk.henrichg.phoneprofiles;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.provider.Settings;

public class ScreenOnOffBroadcastReceiver extends BroadcastReceiver {

    public void onReceive(Context context, Intent intent) {
        //Thread.setDefaultUncaughtExceptionHandler(new TopExceptionHandler());

        PPApplication.logE("ScreenOnOffBroadcastReceiver.onReceive","xxx");

        Context appContext = context.getApplicationContext();
        if (!PPApplication.getApplicationStarted(appContext, true))
            // application is not started
            return;

        PPApplication.logE("ScreenOnOffBroadcastReceiver.onReceive","application started");

        boolean lockDeviceEnabled = false;
        if (PPApplication.lockDeviceActivity != null) {
            lockDeviceEnabled = true;
            PPApplication.lockDeviceActivity.finish();
            PPApplication.lockDeviceActivity.overridePendingTransition(0, 0);
        }

        //PPApplication.loadPreferences(context);

        if (intent.getAction().equals(Intent.ACTION_SCREEN_ON))
            PPApplication.logE("@@@ ScreenOnOffBroadcastReceiver.onReceive", "screen on");
        else if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
            PPApplication.logE("@@@ ScreenOnOffBroadcastReceiver.onReceive", "screen off");
            ActivateProfileHelper.setScreenUnlocked(appContext, false);

            if (ApplicationPreferences.notificationShowInStatusBar(appContext) &&
                    ApplicationPreferences.notificationHideInLockscreen(appContext)) {
                DataWrapper dataWrapper = new DataWrapper(appContext, true, false, 0);
                dataWrapper.getActivateProfileHelper().initialize(dataWrapper, appContext);
                //dataWrapper.getActivateProfileHelper().removeNotification();
                //dataWrapper.getActivateProfileHelper().setAlarmForRecreateNotification();
                Profile activatedProfile = dataWrapper.getActivatedProfile();
                dataWrapper.getActivateProfileHelper().showNotification(activatedProfile);
                dataWrapper.invalidateDataWrapper();
            }
        }
        if (intent.getAction().equals(Intent.ACTION_USER_PRESENT))
        {
            PPApplication.logE("@@@ ScreenOnOffBroadcastReceiver.onReceive", "screen unlock");
            ActivateProfileHelper.setScreenUnlocked(appContext, true);

            DataWrapper dataWrapper = new DataWrapper(appContext, true, false, 0);
            dataWrapper.getActivateProfileHelper().initialize(dataWrapper, appContext);

            if (ApplicationPreferences.notificationShowInStatusBar(appContext) &&
                    ApplicationPreferences.notificationHideInLockscreen(appContext)) {
                //dataWrapper.getActivateProfileHelper().removeNotification();
                //dataWrapper.getActivateProfileHelper().setAlarmForRecreateNotification();
                Profile activatedProfile = dataWrapper.getActivatedProfile();
                dataWrapper.getActivateProfileHelper().showNotification(activatedProfile);
                dataWrapper.invalidateDataWrapper();
            }

            // change screen timeout
            if (lockDeviceEnabled && Permissions.checkLockDevice(appContext))
                Settings.System.putInt(appContext.getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, PPApplication.screenTimeoutBeforeDeviceLock);
            int screenTimeout = ActivateProfileHelper.getActivatedProfileScreenTimeout(appContext);
            if (screenTimeout > 0)
                dataWrapper.getActivateProfileHelper().setScreenTimeout(screenTimeout);

            dataWrapper.invalidateDataWrapper();

            // enable/disable keyguard
            Intent keyguardService = new Intent(appContext, KeyguardService.class);
            appContext.startService(keyguardService);
        }

        if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
            PPApplication.logE("@@@ ScreenOnOffBroadcastReceiver.onReceive", "screen on");
            if (ApplicationPreferences.notificationShowInStatusBar(appContext) &&
                    ApplicationPreferences.notificationHideInLockscreen(appContext)) {
                DataWrapper dataWrapper = new DataWrapper(appContext, true, false, 0);
                dataWrapper.getActivateProfileHelper().initialize(dataWrapper, appContext);
                //dataWrapper.getActivateProfileHelper().removeNotification();
                //dataWrapper.getActivateProfileHelper().setAlarmForRecreateNotification();
                Profile activatedProfile = dataWrapper.getActivatedProfile();
                dataWrapper.getActivateProfileHelper().showNotification(activatedProfile);
                dataWrapper.invalidateDataWrapper();
            }
        }

    }

}

{'fraction_non_alphanumeric': 0.08891765408742408, 'fraction_numerical': 0.001593149457333466, 'mean_word_length': 3.1333333333333333, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2409284', 'n_tokens_mistral': 2348, 'n_tokens_neox': 2249, 'n_words': 335}