blob: 169892ba0217c829349862310f3b73cd067d9812 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
package jp.example.tethering;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
/**
* Enables USB tethering after boot when the user has not turned auto mode off.
* The root relay (/kcroot.sh) may still be starting, so wait a little.
*/
public class BootReceiver extends BroadcastReceiver {
@Override
public void onReceive(final Context context, Intent intent) {
SharedPreferences prefs = context.getSharedPreferences("tethering", Context.MODE_PRIVATE);
if (!prefs.getBoolean("auto_usb", true)) {
return;
}
if (prefs.getBoolean("manual_off", false)) {
return;
}
final PendingResult pending = goAsync();
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(20000);
String apk = context.getPackageCodePath();
RootRelay.run(RootRelay.acceptMobileData()
+ "pm disable-user --user 0 jp.softbank.mb.tetherAuthNfp >/dev/null 2>&1\n"
+ "am force-stop jp.softbank.mb.tetherAuthNfp\n"
+ "CLASSPATH=" + apk + " /system/bin/app_process /system/bin "
+ "jp.example.tethering.TetherCli usb true\n");
} catch (InterruptedException ignored) {
} finally {
pending.finish();
}
}
}).start();
}
}
|