Hi, If I use the code below, I get java.io.FileNotFoundException :
/system/bin/rsync (Read-Only File system). I have one more question
following this for the Samsung Tablet. The emulator has a
/dev/block/mtdblock0 file. But the samsung tablet does not. It instead
has a mmcblk0. I need to know how I identify which is the right
/dev/block/<file to be used> for remounting ? May be forgetting my
basics here. Please guide me.
public class DeployRSync extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
runCommand("mount -o remount,rw /dev/block/mtdblock0 /system",
false);
try {
copy(getAssets().open("rsync"), new
File("/system/bin/rsync"));
} catch (IOException e) {
e.printStackTrace();
}
runCommand("chmod 755 /system/bin/rsync", false);
runCommand("mount -o remount, ro /dev/block/mtdblock0 /system",
false);
}
void copy(InputStream in, File dst) throws IOException {
OutputStream out = new FileOutputStream(dst);
// Transfer bytes from in to out
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
}
private String runCommand(String command, boolean check) {
try {
String env[] = new String[1] ;
env[0] =
Environment.getRootDirectory().getAbsolutePath() ;
Process process ;
if (check)
process = Runtime.getRuntime().exec(command, env, new
File("/system/bin"));
else
process = Runtime.getRuntime().exec(command);
BufferedReader reader = new BufferedReader(
new
InputStreamReader(process.getInputStream()),4096);
process.getOutputStream();
int read;
char[] buffer = new char[4096];
StringBuffer output = new StringBuffer();
while ((read = reader.read(buffer)) > 0) {
output.append(buffer, 0, read);
}
reader.close();
// Waits for the command to finish.
process.waitFor();
return output.toString();
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
} catch (InterruptedException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
}
Regards
Siddharth
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en