mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-21 12:03:02 +00:00
Fix root mouse capture on Nougat
This commit is contained in:
parent
8aba4888e1
commit
1b5330323c
@ -1,6 +1,7 @@
|
|||||||
package com.limelight.binding.input.evdev;
|
package com.limelight.binding.input.evdev;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.os.Build;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.limelight.LimeLog;
|
import com.limelight.LimeLog;
|
||||||
@ -47,26 +48,42 @@ public class EvdevCaptureProvider extends InputCaptureProvider {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Launch a su shell
|
final String evdevReaderCmd = libraryPath+File.separatorChar+"libevdev_reader.so "+servSock.getLocalPort();
|
||||||
ProcessBuilder builder = new ProcessBuilder("su");
|
|
||||||
builder.redirectErrorStream(true);
|
|
||||||
|
|
||||||
try {
|
// On Nougat and later, we'll need to pass the command directly to SU.
|
||||||
su = builder.start();
|
// Writing to SU's input stream after it has started doesn't seem to work anymore.
|
||||||
} catch (IOException e) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
reportDeviceNotRooted();
|
// Launch evdev_reader directly via SU
|
||||||
e.printStackTrace();
|
try {
|
||||||
return;
|
su = Runtime.getRuntime().exec("su -c "+evdevReaderCmd);
|
||||||
|
} catch (IOException e) {
|
||||||
|
reportDeviceNotRooted();
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// Launch a SU shell on Marshmallow and earlier
|
||||||
|
ProcessBuilder builder = new ProcessBuilder("su");
|
||||||
|
builder.redirectErrorStream(true);
|
||||||
|
|
||||||
// Start evdevreader
|
try {
|
||||||
DataOutputStream suOut = new DataOutputStream(su.getOutputStream());
|
su = builder.start();
|
||||||
try {
|
} catch (IOException e) {
|
||||||
suOut.writeChars(libraryPath+File.separatorChar+"libevdev_reader.so "+servSock.getLocalPort()+"\n");
|
reportDeviceNotRooted();
|
||||||
} catch (IOException e) {
|
e.printStackTrace();
|
||||||
reportDeviceNotRooted();
|
return;
|
||||||
e.printStackTrace();
|
}
|
||||||
return;
|
|
||||||
|
// Start evdevreader
|
||||||
|
DataOutputStream suOut = new DataOutputStream(su.getOutputStream());
|
||||||
|
try {
|
||||||
|
suOut.writeChars(evdevReaderCmd+"\n");
|
||||||
|
} catch (IOException e) {
|
||||||
|
reportDeviceNotRooted();
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for evdevreader's connection
|
// Wait for evdevreader's connection
|
||||||
|
Loading…
x
Reference in New Issue
Block a user