private final String UDiskFileName = "/2969_logo/bootfile.image";
private final String LocalFile = "/tmp/factory/bootfile.image";
private boolean setBootLogo()
{
String tmp = getExternalStorageDirectory();
String USBPath = tmp.split("\n")[0];
if(USBPath.length() <= 0)
{
Toast.makeText(TSBPanelMode.this, "没有检测到U盘",
Toast.LENGTH_LONG).show();
return false;
}
String UDiskFile = USBPath + UDiskFileName;
Log.d("XYP_DEBUG", UDiskFile);
if (!fileIsExists(UDiskFile))
{
Toast.makeText(TSBPanelMode.this, "U盘中没有文件" + UDiskFileName,
Toast.LENGTH_LONG).show();
return false;
}
try
{
String tmpcmd = "mount -o remount,rw /system ;\n"+
"rm " + LocalFile + "; \n" +
"cp " + UDiskFile + " " + LocalFile +";\n" +
"ls;\n";
String[] cmd = new String[] { "/bin/sh","-c", tmpcmd};
Runtime runtime = Runtime.getRuntime();
Process proc = runtime.exec(cmd);
InputStream is = proc.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
String line;
BufferedReader br = new BufferedReader(isr);
while ((line = br.readLine()) != null)
{
Log.d(TAG, line);
}
mTvManager.saveFactoryData();
Log.d("XYP_DEBUG", "==== have done ====");
}catch(Exception e)
{
e.printStackTrace();
return false;
}
if (!fileIsExists(LocalFile))
{
Toast.makeText(TSBPanelMode.this, "U盘中文件没有复制到本地存储空间",
Toast.LENGTH_LONG).show();
return false;
}
return true;
}
private boolean fileIsExists(String strFile)
{
try
{
File f=new File(strFile);
if(!f.exists())
{
return false;
}
}
catch (Exception e)
{
e.printStackTrace();
return false;
}
return true;
}
public static String getExternalStorageDirectory(){
String dir = new String();
try {
Runtime runtime = Runtime.getRuntime();
Process proc = runtime.exec("mount");
InputStream is = proc.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
String line;
BufferedReader br = new BufferedReader(isr);
while ((line = br.readLine()) != null) {
if (line.contains("fuse")) {
String columns[] = line.split(" ");
if (columns != null && columns.length > 1) {
if(columns[1].contains("emulated"))
continue;
dir = dir.concat(columns[1] + "\n");
}
}
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return dir;
}
golang os/exec 执行外部命令
exec包执行外部命令,它将os.StartProcess进行包装使得它更容易映射到stdin和stdout,并且利用pipe连接i/o. func LookPath(file string) (st ...
PHP在linux上执行外部命令
PHP在linux上执行外部命令 一.PHP中调用外部命令介绍二.关于安全问题三.关于超时问题四.关于PHP运行linux环境中命令出现的问题 一.PHP中调用外部命令介绍在PHP中调用外部命令,可以 ...
Android执行shell命令
一.方法 /** * 执行一个shell命令,并返回字符串值 * * @param cmd * 命令名称&参数组成的数组(例如:{"/system/bin/cat", &q ...
Powershell 执行外部命令
Powershell 执行外部命令 724 11月, 2011 在 Powershell tagged Powershell教程 / 程序 by Mooser Lee本文索引[隐藏]1通过nets ...
php -- PHP在linux上执行外部命令,system(),exec(),shell_exec()
目录:一.PHP中调用外部命令介绍二.关于安全问题三.关于超时问题四.关于PHP运行linux环境中命令出现的问题 一.PHP中调用外部命令介绍 在PHP中调用外部命令,有三种方法: 1. 调用专门函 ...
php执行外部命令
php执行外部命令的不少,例如:exec.shell_exec.system.popen等.我特意的讲一下popen,它跟其他函数不太一样,其他函数执行一个命令后,会等待其返回后,再向下执行,而pop ...
Android执行shell命令 top ps
Android执行shell命令 一.方法 /** * 执行一个shell命令,并返回字符串值 * * @param cmd * 命令名称&参数组成的数组(例如:{"/system/ ...
php在linux中执行外部命令
目录:一.PHP中调用外部命令介绍二.关于安全问题三.关于超时问题四.关于PHP运行linux环境中命令出现的问题 一.PHP中调用外部命令介绍在PHP中调用外部命令,可以用,1>调用专门函数. ...
PHP执行外部命令【转】
PHP是完全支持外部命令的,但是出于安全考虑,一般很少使用. PHP提供共了3种方法调用外部命令: (1)调用执行外部命令函数(system(),exec(),passthru(),shell_exe ...
随机推荐
用PHP链接mysql数据库
PHP提供了两套数据库可用于访问mysql数据库 1)MySQL扩展函数数据库 2)MySQLI扩展数据库(improved) 使用MySQLI函数访问MySQL数据库步骤 1)链接数据库管理系统 m ...
安装Postman