java - How to give superuser permission to android 2.3.5 device programmatically? -
i'm installing apk files programmatically.it working. have 2 rooted android devices , version of devices 2.3.5 , 4.4.2. problem that; when install apk file on 2.3.5 device, cannot see app icon. restart device icon showing. however, 4.4.2 device not have problem. result; want install apk file 2.3.5 device way of installation 4.4.2.
here codes:
private boolean installappforand235(string sourcefile, string filename, boolean issystemapp) { boolean result = false; try { string destinationpath = ((issystemapp) ? path_system_app : path_user_app) + filename; result = setexecpermision(destinationpath, true); result = androidutils.runshellcommand(string.format("mv %s %s", sourcefile, destinationpath), false); return result; } catch (exception e) { e.printstacktrace(); } return result; } private boolean installappforand442(string sourcefile, string filename, boolean issystemapp) { boolean result = false; try { setexecpermision(sourcefile, true); return androidutils.runshellcommand("pm install -r " + sourcefile, true); } catch (exception e) { e.printstacktrace(); } return result; } public static boolean runshellcommand(string command, boolean runassuperuser) { boolean result = false; try { process process = null; dataoutputstream dataoutputstream = null; try { if (runassuperuser) { process = runtime.getruntime().exec("su"); dataoutputstream = new dataoutputstream(process.getoutputstream()); dataoutputstream.writebytes(command + "\n"); dataoutputstream.writebytes("exit\n"); dataoutputstream.flush(); } else { process = runtime.getruntime().exec(command); } process.waitfor(); bufferedreader r = new bufferedreader(new inputstreamreader(process.geterrorstream())); stringbuilder total = new stringbuilder(); string line; while ((line = r.readline()) != null) { total.append(line).append('\n'); } log.d("run process error ", total.tostring()); log.d("run process exitvalue", string.valueof(process.exitvalue())); if (process.exitvalue() == 0) result = true; else result = false; } catch (exception e) { e.printstacktrace(); } { try { if (dataoutputstream != null) { dataoutputstream.close(); } process.destroy(); } catch (exception e) { } } } catch (exception e) { e.printstacktrace(); } return result; }
what have to?
Comments
Post a Comment