[Bugfix] Fix after performing adb shell am hang and kill this process, the phone can not resume from hang state

After performing adb shell am hang and kill this process, the phone can not resume from hang state. The reason is that the IBinder object in runHang(PrintWriter pw) of ActivityManagerShellCommand.java is not the IBinder object of client.

Bug: 180949375
Fixes: 180949375

Test: Run adb shell am hang, and open some APPs, then the phone will hang. Then perform ctrl + c, the phone can resume from hang state.

Signed-off-by: yuxi1 <yuxi1@xiaomi.com>
Change-Id: Ie1153df2e21fc267fd131994422b7c263a17372a
This commit is contained in:
yuxi1
2021-02-23 17:55:54 +08:00
committed by yuxi
parent 9c92c37f56
commit 409fcc7207
2 changed files with 12 additions and 1 deletions

View File

@@ -102,6 +102,10 @@ public class ShellCallback implements Parcelable {
}
}
public IBinder getShellCallbackBinder() {
return mShellCallback.asBinder();
}
ShellCallback(Parcel in) {
mLocal = false;
mShellCallback = IShellCallback.Stub.asInterface(in.readStrongBinder());

View File

@@ -1690,7 +1690,14 @@ final class ActivityManagerShellCommand extends ShellCommand {
pw.println("Hanging the system...");
pw.flush();
mInterface.hang(new Binder(), allowRestart);
try {
mInterface.hang(getShellCallback().getShellCallbackBinder(), allowRestart);
} catch (NullPointerException e) {
pw.println("Hanging failed, since caller " + Binder.getCallingPid() +
" did not provide a ShellCallback!");
pw.flush();
return 1;
}
return 0;
}