package com.parentalmonitor.child.receivers;

import android.content.*;
import android.os.Build;
import com.parentalmonitor.child.services.*;

public class BootReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context ctx, Intent intent) {
        if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
            Intent syncIntent = new Intent(ctx, SyncService.class);
            Intent appIntent = new Intent(ctx, AppMonitorService.class);
            Intent screenIntent = new Intent(ctx, ScreenTimeService.class);
            Intent locIntent = new Intent(ctx, LocationService.class);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                ctx.startForegroundService(syncIntent);
            } else {
                ctx.startService(syncIntent);
            }
            ctx.startService(appIntent);
            ctx.startService(screenIntent);
            ctx.startService(locIntent);
        }
    }
}
