Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bba71b8a authored by Po-Chien Hsueh's avatar Po-Chien Hsueh Committed by android-build-merger
Browse files

Check if DSU is in use before feature flag

am: 7687aaac

Change-Id: Ia62234d7f1ab96803ad90fed51ae0e6b168af50c
parents 38c5f1fd 7687aaac
Loading
Loading
Loading
Loading
+15 −10
Original line number Diff line number Diff line
@@ -22,8 +22,8 @@ import android.content.Intent;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.image.DynamicSystemClient;
import android.os.image.DynamicSystemManager;
import android.util.FeatureFlagUtils;
import android.util.Log;


/**
@@ -37,22 +37,27 @@ public class BootCompletedReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        if (!featureFlagEnabled()) {
        String action = intent.getAction();

        if (!Intent.ACTION_BOOT_COMPLETED.equals(action)) {
            return;
        }

        String action = intent.getAction();
        DynamicSystemManager dynSystem =
                (DynamicSystemManager) context.getSystemService(Context.DYNAMIC_SYSTEM_SERVICE);

        Log.d(TAG, "Broadcast received: " + action);
        boolean isInUse = (dynSystem != null) && dynSystem.isInUse();

        if (!isInUse && !featureFlagEnabled()) {
            return;
        }

        if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
        Intent startServiceIntent = new Intent(
                context, DynamicSystemInstallationService.class);

        startServiceIntent.setAction(DynamicSystemClient.ACTION_NOTIFY_IF_IN_USE);
        context.startServiceAsUser(startServiceIntent, UserHandle.SYSTEM);
    }
    }

    private boolean featureFlagEnabled() {
        return SystemProperties.getBoolean(
+12 −1
Original line number Diff line number Diff line
@@ -152,7 +152,18 @@ public class DynamicSystemService extends IDynamicSystemService.Stub implements

    @Override
    public boolean isInUse() throws RemoteException {
        return getGsiService().isGsiRunning();
        boolean gsidWasRunning = "running".equals(SystemProperties.get("init.svc.gsid"));
        boolean isInUse = false;

        try {
            isInUse = getGsiService().isGsiRunning();
        } finally {
            if (!gsidWasRunning && !isInUse) {
                SystemProperties.set("ctl.stop", "gsid");
            }
        }

        return isInUse;
    }

    @Override