package co.tgbot.peekfun; /* * Shadowsocks - A co.tgbot.peekfun client for Android * Copyright (C) 2014 <[email protected]> * * This program 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. * * 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * * ___====-_ _-====___ * _--^^^#####// \\#####^^^--_ * _-^##########// ( ) \\##########^-_ * -############// |\^^/| \\############- * _/############// (@::@) \\############\_ * /#############(( \\// ))#############\ * -###############\\ (oo) //###############- * -#################\\ / VV \ //#################- * -###################\\/ \//###################- * _#/|##########/\######( /\ )######/\##########|\#_ * |/ |#/\#/\#/\/ \#/\##\ | | /##/\#/ \/\#/\#/\#| \| * ` |/ V V ` V \#\| | | |/#/ V ' V V \| ' * ` ` ` ` / | | | | \ ' ' ' ' * ( | | | | ) * __\ | | | | /__ * (vvv(VVV)(VVV)vvv) * * HERE BE DRAGONS * */ import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import co.tgbot.peekfun.utils.Utils; public class BootReceiver extends BroadcastReceiver { public static boolean getEnabled(Context context) { PackageManager pm = context.getPackageManager(); ComponentName cn = new ComponentName(context, BootReceiver.class); return PackageManager.COMPONENT_ENABLED_STATE_ENABLED == pm.getComponentEnabledSetting(cn); } public static void setEnabled(Context context, boolean enabled) { PackageManager pm = context.getPackageManager(); ComponentName cn = new ComponentName(context, BootReceiver.class); int state = enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED; pm.setComponentEnabledSetting(cn, state, PackageManager.DONT_KILL_APP); } @Override public void onReceive(Context context, Intent intent) { Utils.startSsService(context); } }