Skip to content

Commit 309d873

Browse files
libxzrhungphan2001
authored andcommitted
StrictStandby: Offload force stop onto lock-free context
Fixes potential dead lock when plenty of tasks get removed at the same time. Change-Id: Ib26dc55bfb3b86b29f25e25887406c7859f66e34 Signed-off-by: LibXZR <i@xzr.moe> Signed-off-by: Adithya R <gh0strider.2k18.reborn@gmail.com> Signed-off-by: Dmitrii <bankersenator@gmail.com> Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
1 parent 3cdde55 commit 309d873

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

services/core/java/com/android/server/wm/ActivityTaskSupervisor.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
197197
private static final int REPORT_PIP_MODE_CHANGED_MSG = FIRST_SUPERVISOR_TASK_MSG + 15;
198198
private static final int START_HOME_MSG = FIRST_SUPERVISOR_TASK_MSG + 16;
199199
private static final int TOP_RESUMED_STATE_LOSS_TIMEOUT_MSG = FIRST_SUPERVISOR_TASK_MSG + 17;
200+
private static final int STRICT_STANDBY_KILL_MSG = FIRST_SUPERVISOR_TASK_MSG + 18;
200201

201202
// Used to indicate that windows of activities should be preserved during the resize.
202203
static final boolean PRESERVE_WINDOWS = true;
@@ -1667,15 +1668,7 @@ void cleanUpRemovedTaskLocked(Task task, boolean killProcess, boolean removeFrom
16671668
if (getAppOpsManager().checkOpNoThrow(
16681669
AppOpsManager.OP_RUN_ANY_IN_BACKGROUND,
16691670
task.effectiveUid, pkg) != AppOpsManager.MODE_ALLOWED) {
1670-
try {
1671-
ActivityManager.getService().forceStopPackage(pkg, task.mUserId);
1672-
return;
1673-
} catch (RemoteException e) {
1674-
Slog.e(TAG, "Force stop failed, falling back to old path...");
1675-
} finally {
1676-
mService.mAppStandbyInternal.restrictApp(
1677-
pkg, task.mUserId, REASON_MAIN_FORCED_BY_USER, 0);
1678-
}
1671+
mHandler.sendMessage(mHandler.obtainMessage(STRICT_STANDBY_KILL_MSG, task));
16791672
}
16801673

16811674
ArrayList<Object> procsToKill = new ArrayList<>();
@@ -2442,6 +2435,17 @@ public void handleMessage(Message msg) {
24422435
"restartActivityProcessTimeout");
24432436
}
24442437
} break;
2438+
case STRICT_STANDBY_KILL_MSG: {
2439+
Task task = (Task) msg.obj;
2440+
String pkg = task.getBaseIntent().getComponent().getPackageName();
2441+
try {
2442+
ActivityManager.getService().forceStopPackage(pkg, task.mUserId);
2443+
} catch (RemoteException e) {
2444+
Slog.e(TAG, "Strict standby force stop failed...");
2445+
}
2446+
mService.mAppStandbyInternal.restrictApp(
2447+
pkg, task.mUserId, REASON_MAIN_FORCED_BY_USER, 0);
2448+
} break;
24452449
}
24462450
}
24472451

0 commit comments

Comments
 (0)