Dirk Vogt | 47ac2d4 | 2017-08-29 23:15:57 +0200 | [diff] [blame] | 1 | package com.fairphone.cameraswapinfo; |
| 2 | |
| 3 | import android.content.BroadcastReceiver; |
| 4 | import android.content.ComponentName; |
| 5 | import android.content.Context; |
| 6 | import android.content.Intent; |
| 7 | import android.content.pm.PackageManager; |
| 8 | |
| 9 | public class BootUpReceiver extends BroadcastReceiver { |
| 10 | @Override |
| 11 | public void onReceive(Context context, Intent intent) { |
| 12 | if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) { |
Borjan Tchakaloff | 973196b | 2017-09-04 14:31:20 +0200 | [diff] [blame^] | 13 | CameraSwapNotificationService.startActionCameraChanged(context); |
Dirk Vogt | 47ac2d4 | 2017-08-29 23:15:57 +0200 | [diff] [blame] | 14 | } |
| 15 | } |
| 16 | |
| 17 | public static void disable(Context context) { |
| 18 | PackageManager pm = context.getPackageManager(); |
| 19 | ComponentName componentName = new ComponentName(context, BootUpReceiver.class); |
| 20 | pm.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, |
| 21 | PackageManager.DONT_KILL_APP); |
| 22 | } |
| 23 | |
| 24 | public static void enable(Context context) { |
| 25 | PackageManager pm = context.getPackageManager(); |
| 26 | ComponentName componentName = new ComponentName(context, BootUpReceiver.class); |
| 27 | pm.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_ENABLED, |
| 28 | PackageManager.DONT_KILL_APP); |
| 29 | } |
| 30 | } |