package com.foxx.androidcast;

/*********************************************************************
 * AndroidCastApplication.java
 * Created at: Sun 17 May 2026 18:17:14 +0200
 * Updated at: Wed 20 May 2026 15:17:13 +0200 by Anton Afanasyeu <a.afanasieff@gmail.com>
 * Commit: 5d8e82d2e60a21fff3138d2a394ee4e8b4c6dcb8
 * class AndroidCastApplication
 * Contributors:
 *    - Anton Afanasyeu <a.afanasieff@gmail.com> (6 commits, 34 lines)
 *    - Cursor Agent (project assistant)
 * Digest: SHA256	c6ffb05899adbbdc35c27a4048643990b8f2d162583777745b968b7e62189070
**********************************************************************/
import android.app.Application;
import android.content.Context;

import com.foxx.androidcast.commercial.CommercialFeatures;
import com.foxx.androidcast.crash.CrashReporter;
import com.foxx.androidcast.dev.DevAdbWifiKeeper;
import com.foxx.androidcast.display.WiredDisplayMonitor;
import com.foxx.androidcast.media.CodecPriorityCatalog;
import com.foxx.androidcast.network.CastTransportFactory;
import com.foxx.androidcast.receiver.av.ReceiverAvRuntime;
import com.foxx.androidcast.remoteaccess.RemoteAccessCoordinator;

/** Applies saved theme and locale at process start. */
public class AndroidCastApplication extends Application {
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
    }

    @Override
    public void onCreate() {
        super.onCreate();
        CrashReporter.install(this);
        if (!CrashReporter.isMainProcess(this, CrashReporter.currentProcessName())) {
            return;
        }
        CodecPriorityCatalog.init(this);
        CastLocaleHelper.applyStoredLocale(this);
        CastThemeHelper.applyNightMode(this);
        ReceiverAvRuntime.reload(this);
        CastTransportFactory.init(this);
        WiredDisplayMonitor.getInstance(this).ensureRegistered();
        CommercialFeatures.refreshFromPreferences(this);
        RemoteAccessCoordinator.onBootIfNeeded(this);
        DevAdbWifiKeeper.ensureStarted(this);
    }
}
