[core] Close fd (#1161)
This commit is contained in:
parent
1588d6160c
commit
fb9ab9d9bd
|
|
@ -68,7 +68,7 @@ public class ActivityController extends IActivityController.Stub {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean replaceShellCommand(IBinder am, Parcel data) {
|
static boolean replaceShellCommand(IBinder am, Parcel data, Parcel reply) {
|
||||||
if (!inited) return false;
|
if (!inited) return false;
|
||||||
try {
|
try {
|
||||||
data.setDataPosition(fdSize * 3);
|
data.setDataPosition(fdSize * 3);
|
||||||
|
|
@ -76,9 +76,9 @@ public class ActivityController extends IActivityController.Stub {
|
||||||
|
|
||||||
if (args.length > 0 && "monitor".equals(args[0])) {
|
if (args.length > 0 && "monitor".equals(args[0])) {
|
||||||
data.setDataPosition(0);
|
data.setDataPosition(0);
|
||||||
var in = data.readFileDescriptor();
|
try (var in = data.readFileDescriptor();
|
||||||
var out = data.readFileDescriptor();
|
var out = data.readFileDescriptor();
|
||||||
var err = data.readFileDescriptor();
|
var err = data.readFileDescriptor()) {
|
||||||
data.createStringArray();
|
data.createStringArray();
|
||||||
ShellCallback shellCallback = ShellCallback.CREATOR.createFromParcel(data);
|
ShellCallback shellCallback = ShellCallback.CREATOR.createFromParcel(data);
|
||||||
ResultReceiver resultReceiver = ResultReceiver.CREATOR.createFromParcel(data);
|
ResultReceiver resultReceiver = ResultReceiver.CREATOR.createFromParcel(data);
|
||||||
|
|
@ -108,10 +108,13 @@ public class ActivityController extends IActivityController.Stub {
|
||||||
|
|
||||||
}
|
}
|
||||||
}.exec((Binder) am, in.getFileDescriptor(), out.getFileDescriptor(), err.getFileDescriptor(), args, shellCallback, resultReceiver);
|
}.exec((Binder) am, in.getFileDescriptor(), out.getFileDescriptor(), err.getFileDescriptor(), args, shellCallback, resultReceiver);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Log.e(TAG, "replace shell command", e);
|
Log.e(TAG, "replace shell command", e);
|
||||||
|
} finally {
|
||||||
|
if (reply != null) reply.writeNoException();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
data.setDataPosition(0);
|
data.setDataPosition(0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -297,7 +297,7 @@ public class BridgeService {
|
||||||
!descriptor.equals("com.sonymobile.hookservice.HookActivityService"))) {
|
!descriptor.equals("com.sonymobile.hookservice.HookActivityService"))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return ActivityController.replaceShellCommand(obj, data);
|
return ActivityController.replaceShellCommand(obj, data, reply);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Log.e(TAG, "replace shell command", e);
|
Log.e(TAG, "replace shell command", e);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue