package com.unibuy.smartdevice.worker;

import android.util.Log;

import java.io.DataOutputStream;

public class EthernetTetherHelper {
    public static void enableEthernetTethering() {
        try {
            Process su = Runtime.getRuntime().exec("su");
            DataOutputStream os = new DataOutputStream(su.getOutputStream());

            os.writeBytes("ndc tether interface add eth0\n");
            os.writeBytes("ndc tether start\n");
            os.writeBytes("exit\n");
            os.flush();

            su.waitFor();
            Log.i("EthernetTetherHelper", "Ethernet tethering enabled.");
        } catch (Exception e) {
            Log.e("EthernetTetherHelper", "啟用失敗：" + e.getMessage());
            e.printStackTrace();
        }
    }
}
