Android 4.4.2以下のAndroidバージョンで動作するコードがありますが、ロリポップでは動作しません。
lollipop が登場したとき、ROOT 権限を必要とする多くのアプリが機能しなくなることは知っていましたが、それらがどのように問題を解決したのかはわかりません。
これはコードです:
System.out.println("Running tool");
Process p = Runtime.getRuntime().exec("su");
os = p.getOutputStream();
os.write((context.getFilesDir().getAbsolutePath() + "/tool " + context.getFilesDir().getAbsolutePath() + "\n").getBytes());
os.write("exit\n".getBytes());
p.waitFor();
テストされたすべての電話は ROOT です。
行で:
os.write((context.getFilesDir().getAbsolutePath() + "/tool " + context.getFilesDir().getAbsolutePath() + "\n").getBytes());
例外をスローします:
02-15 23:02:23.917 10130-10130/com.test I/System.out? Running tool
02-15 23:02:24.680 10130-10130/com.test W/System.err? java.io.IOException: write failed: EPIPE (Broken pipe)
02-15 23:02:24.681 10130-10130/com.test W/System.err? at libcore.io.IoBridge.write(IoBridge.java:502)
02-15 23:02:24.681 10130-10130/com.test W/System.err? at java.io.FileOutputStream.write(FileOutputStream.java:186)
02-15 23:02:24.681 10130-10130/com.test W/System.err? at java.io.OutputStream.write(OutputStream.java:82)
02-15 23:02:24.681 10130-10130/com.test W/System.err? at com.secondary_test.MainActivity.onClick(MainActivity.java:86)
02-15 23:02:24.681 10130-10130/com.test W/System.err? at com.secondary_test.Principal.getPass(Principal.java:25)
02-15 23:02:24.681 10130-10130/com.test W/System.err? at com.test.Main.onCreate(Main.java:36)
02-15 23:02:24.681 10130-10130/com.test W/System.err? at android.app.Activity.performCreate(Activity.java:5933)
02-15 23:02:24.681 10130-10130/com.test W/System.err? at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
02-15 23:02:24.681 10130-10130/com.test W/System.err? at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2282)
02-15 23:02:24.681 10130-10130/com.test W/System.err? at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2391)
02-15 23:02:24.681 10130-10130/com.test W/System.err? at android.app.ActivityThread.access$900(ActivityThread.java:147)
02-15 23:02:24.681 10130-10130/com.test W/System.err? at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1296)
02-15 23:02:24.682 10130-10130/com.test W/System.err? at android.os.Handler.dispatchMessage(Handler.java:102)
02-15 23:02:24.682 10130-10130/com.test W/System.err? at android.os.Looper.loop(Looper.java:135)
02-15 23:02:24.682 10130-10130/com.test W/System.err? at android.app.ActivityThread.main(ActivityThread.java:5256)
02-15 23:02:24.682 10130-10130/com.test W/System.err? at java.lang.reflect.Method.invoke(Native Method)
02-15 23:02:24.682 10130-10130/com.test W/System.err? at java.lang.reflect.Method.invoke(Method.java:372)
02-15 23:02:24.682 10130-10130/com.test W/System.err? at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
02-15 23:02:24.682 10130-10130/com.test W/System.err? at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
02-15 23:02:24.682 10130-10130/com.test W/System.err? Caused by: android.system.ErrnoException: write failed: EPIPE (Broken pipe)
02-15 23:02:24.690 10130-10130/com.test W/System.err? at libcore.io.Posix.writeBytes(Native Method)
02-15 23:02:24.691 10130-10130/com.test W/System.err? at libcore.io.Posix.write(Posix.java:223)
02-15 23:02:24.691 10130-10130/com.test W/System.err? at libcore.io.BlockGuardOs.write(BlockGuardOs.java:313)
02-15 23:02:24.691 10130-10130/com.test W/System.err? at libcore.io.IoBridge.write(IoBridge.java:497)
誰もがこの問題に遭遇したか、それを解決する方法を知っていますか?
みんなありがとう。