package cc.winboll.studio.timestamp.receivers;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.timestamp.MainService;
import cc.winboll.studio.timestamp.models.AppConfigsModel;
import cc.winboll.studio.timestamp.utils.AppConfigsUtil;

/**
 * @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
 * @Date 2025/07/28 11:15
 * @Describe MainReceiver
 */
public class MainReceiver extends BroadcastReceiver {

    public static final String TAG = "MainReceiver";

    static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";

    AppConfigsUtil mAppConfigsUtil;

    @Override
    public void onReceive(Context context, Intent intent) {
        String szAction = intent.getAction();
        if (szAction.equals(ACTION_BOOT_COMPLETED)) {
            AppConfigsModel appConfigs = AppConfigsUtil.getInstance(context).loadAppConfigs();
			boolean isEnable = appConfigs.isEnableService();
			AppConfigsUtil.getInstance(context).saveAppConfigs();

			Intent intentMainService = new Intent(context, MainService.class);
			if (isEnable) {
				context.startService(intentMainService);
			}
			LogUtils.i(TAG, "System Boot And Start ManagerService Completed!");
        }
    }

}
