2013-03-20 124 views
0

所以我有一個LG P920我要修改的TI FMrX應用命令通過tinymix這裏添加音頻路由是shell命令在Android應用程序運行終端命令可將音頻路由

# tinymix 6 120 
# tinymix 66 7 
# tinymix 67 7 
# tinymix 73 2 
# tinymix 74 2 

二進制位於/system/bin/tinymix

所以我試圖impliment它在Java林不知道它的正確的,但在這裏它是

public static void RouteAudioOn() 
    { 
    String MIX = "tinymix"; 
    int DL1 = 6; 
    int DL1Value = 120; 
    int FMvol = 66; 
    int Headsetvol = 67' 
    int RightCh = 73; 
    int LeftCh = 74; 
    int SoundValue = 7; 
    int HeadsetValue = 8; 
    int LineIn = 2 

    Process process = Runtime.getRuntime().exec("su"); 
    DataOutputStream os = new DataOutputStream(process.getOutputStream()); 

    os.writeBytes(MIX+" "+DL1+" "+DL1Value"\n"); 
    os.writeBytes(MIX+" "+FMvol+" "+SoundValue"\n"); 
    os.writeBytes(MIX+" "+Headsetvol+" "+HeadsetValue"\n"); 
    os.writeBytes(MIX+" "+RightCh+" "+LineIn"\n"); 
    os.writeBytes(MIX+" "+LeftCh+" "+LineIn"\n"); 

    os.writeBytes("exit\n"); 
    os.flush(); 
    os.close(); 

    process.waitFor(); 
    } 

public static void RouteAudioOff() 
    { 
    String MIX = "tinymix"; 
    int DL1 = 6; 
    int DL1Value = 0; 
    int FMvol = 66; 
    int Headsetvol = 67' 
    int RightCh = 73; 
    int LeftCh = 74; 
    int SoundValue = 0; 
    int HeadsetValue = 0; 
    int LineIn = 0 

    Process process = Runtime.getRuntime().exec("su"); 
    DataOutputStream os = new DataOutputStream(process.getOutputStream()); 

    os.writeBytes(MIX+" "+DL1+" "+DL1Value"\n"); 
    os.writeBytes(MIX+" "+FMvol+" "+SoundValue"\n"); 
    os.writeBytes(MIX+" "+Headsetvol+" "+HeadsetValue"\n"); 
    os.writeBytes(MIX+" "+RightCh+" "+LineIn"\n"); 
    os.writeBytes(MIX+" "+LeftCh+" "+LineIn"\n"); 

    os.writeBytes("exit\n"); 
    os.flush(); 
    os.close(); 

    process.waitFor(); 
    } 

回答

0

我做到了這樣,並處於正常

布爾兒子= false爲耳機和真正的免提

public void RunAsRoot(boolean son) { 
    Process p = null; 
    ArrayList tmpCmd = new ArrayList(); 
    tmpCmd.add("chmod 777 /dev/radio0"); 
    tmpCmd.add("tinymix 6 120"); 
    tmpCmd.add("tinymix 66 4"); 
if(son){tmpCmd.add("tinymix 67 1");tmpCmd.add("tinymix 73 1"); 
tmpCmd.add("tinymix 74 0");tmpCmd.add("tinymix 68 28");tmpCmd.add("tinymix 75 2");tmpCmd.add("tinymix 76 2");} 
else {tmpCmd.add("tinymix 75 0");tmpCmd.add("tinymix 76 0");tmpCmd.add("tinymix 68 0");tmpCmd.add("tinymix 67 4"); 
tmpCmd.add("tinymix 73 2"); 
tmpCmd.add("tinymix 74 2");} 

    try { 
     p = Runtime.getRuntime().exec("su"); 
    } catch (IOException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 
    DataOutputStream os = new DataOutputStream(p.getOutputStream());    
    for (int i=0;i<tmpCmd.size();i++) { 
     try { 
     os.writeBytes(tmpCmd.get(i)+"\n"); 
    } catch (IOException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 
    }   
    try { 
     os.writeBytes("exit\n"); 
    } catch (IOException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 
    try { 
     os.flush(); 
    } catch (IOException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 
}