diff options
author | Po-Chien Hsueh <pchsueh@google.com> | 2019-05-14 16:57:18 +0800 |
---|---|---|
committer | PO HUNG CHEN <howardsoc@google.com> | 2019-05-21 01:16:33 +0000 |
commit | 7687aaac1d60de95c55a2bc62f3e23a56e2f16bd (patch) | |
tree | 5579300f9fae4aa0b34aa562284f30fd434a0479 | |
parent | 7ad66d5e14e4f1985c2caf6bf8c35d809036914a (diff) | |
download | frameworks_base-7687aaac1d60de95c55a2bc62f3e23a56e2f16bd.tar.gz frameworks_base-7687aaac1d60de95c55a2bc62f3e23a56e2f16bd.tar.bz2 frameworks_base-7687aaac1d60de95c55a2bc62f3e23a56e2f16bd.zip |
Check if DSU is in use before feature flag
We are using a feature flag to protect DSU and the device. But when
a Dynamic System is in use, feature flag is set as false by default.
This CL makes DSU bypass feature flag and start GSI service on boot
completed, check if the device is currently running a Dynamic System,
then, stop GSI service if the device isn't.
Bug: 132575851
Test: restart into DSU, check if the "In Use" notification is shown.
Change-Id: I9dabf9bc1716ef18d513278415c6544a5467d510
-rw-r--r-- | packages/DynamicSystemInstallationService/src/com/android/dynsystem/BootCompletedReceiver.java | 25 | ||||
-rw-r--r-- | services/core/java/com/android/server/DynamicSystemService.java | 13 |
2 files changed, 27 insertions, 11 deletions
diff --git a/packages/DynamicSystemInstallationService/src/com/android/dynsystem/BootCompletedReceiver.java b/packages/DynamicSystemInstallationService/src/com/android/dynsystem/BootCompletedReceiver.java index ea7b378eb60..06c52942e67 100644 --- a/packages/DynamicSystemInstallationService/src/com/android/dynsystem/BootCompletedReceiver.java +++ b/packages/DynamicSystemInstallationService/src/com/android/dynsystem/BootCompletedReceiver.java @@ -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,21 +37,26 @@ 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(); - - Log.d(TAG, "Broadcast received: " + action); + DynamicSystemManager dynSystem = + (DynamicSystemManager) context.getSystemService(Context.DYNAMIC_SYSTEM_SERVICE); - if (Intent.ACTION_BOOT_COMPLETED.equals(action)) { - Intent startServiceIntent = new Intent( - context, DynamicSystemInstallationService.class); + boolean isInUse = (dynSystem != null) && dynSystem.isInUse(); - startServiceIntent.setAction(DynamicSystemClient.ACTION_NOTIFY_IF_IN_USE); - context.startServiceAsUser(startServiceIntent, UserHandle.SYSTEM); + if (!isInUse && !featureFlagEnabled()) { + return; } + + Intent startServiceIntent = new Intent( + context, DynamicSystemInstallationService.class); + + startServiceIntent.setAction(DynamicSystemClient.ACTION_NOTIFY_IF_IN_USE); + context.startServiceAsUser(startServiceIntent, UserHandle.SYSTEM); } private boolean featureFlagEnabled() { diff --git a/services/core/java/com/android/server/DynamicSystemService.java b/services/core/java/com/android/server/DynamicSystemService.java index 9d979a6701c..f92d0e0ff6f 100644 --- a/services/core/java/com/android/server/DynamicSystemService.java +++ b/services/core/java/com/android/server/DynamicSystemService.java @@ -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 |