Merge "Ignore the reboot to normal intent when DSU is locked"

This commit is contained in:
Treehugger Robot
2023-05-16 02:08:13 +00:00
committed by Gerrit Code Review
4 changed files with 34 additions and 4 deletions

View File

@@ -285,4 +285,16 @@ public class DynamicSystemManager {
throw new RuntimeException(e.toString()); throw new RuntimeException(e.toString());
} }
} }
/**
* Returns the active DSU slot
*/
@RequiresPermission(android.Manifest.permission.MANAGE_DYNAMIC_SYSTEM)
public String getActiveDsuSlot() {
try {
return mService.getActiveDsuSlot();
} catch (RemoteException e) {
throw new RuntimeException(e.toString());
}
}
} }

View File

@@ -145,4 +145,10 @@ interface IDynamicSystemService
*/ */
@EnforcePermission("MANAGE_DYNAMIC_SYSTEM") @EnforcePermission("MANAGE_DYNAMIC_SYSTEM")
long suggestScratchSize(); long suggestScratchSize();
/**
* Get the active DSU slot
*/
@EnforcePermission("MANAGE_DYNAMIC_SYSTEM")
String getActiveDsuSlot();
} }

View File

@@ -423,7 +423,10 @@ public class DynamicSystemInstallationService extends Service
Log.e(TAG, "It's already running in normal system."); Log.e(TAG, "It's already running in normal system.");
return; return;
} }
if (mDynSystem.getActiveDsuSlot().endsWith(".lock")) {
Log.e(TAG, "Ignore the reboot intent for a locked DSU slot");
return;
}
if (!mDynSystem.setEnable(/* enable = */ false, /* oneShot = */ false)) { if (!mDynSystem.setEnable(/* enable = */ false, /* oneShot = */ false)) {
Log.e(TAG, "Failed to disable DynamicSystem."); Log.e(TAG, "Failed to disable DynamicSystem.");

View File

@@ -226,9 +226,7 @@ public class DynamicSystemService extends IDynamicSystemService.Stub {
IGsiService gsiService = getGsiService(); IGsiService gsiService = getGsiService();
if (enable) { if (enable) {
try { try {
if (mDsuSlot == null) { getActiveDsuSlot();
mDsuSlot = gsiService.getActiveDsuSlot();
}
GsiServiceCallback callback = new GsiServiceCallback(); GsiServiceCallback callback = new GsiServiceCallback();
synchronized (callback) { synchronized (callback) {
gsiService.enableGsiAsync(oneShot, mDsuSlot, callback); gsiService.enableGsiAsync(oneShot, mDsuSlot, callback);
@@ -287,4 +285,15 @@ public class DynamicSystemService extends IDynamicSystemService.Stub {
return getGsiService().suggestScratchSize(); return getGsiService().suggestScratchSize();
} }
@Override
@EnforcePermission(android.Manifest.permission.MANAGE_DYNAMIC_SYSTEM)
public String getActiveDsuSlot() throws RemoteException {
super.getActiveDsuSlot_enforcePermission();
if (mDsuSlot == null) {
mDsuSlot = getGsiService().getActiveDsuSlot();
}
return mDsuSlot;
}
} }