android - How do I give superuser access to my app on a device I own and control? -


background

  • we build , control hardware devices on app run.
  • (edit)we build custom version of android os well.
  • we're building app expect "always-on."
  • we want app able self-update, independent of market. hence, hosting service client app periodically poll updates, download apk, , install it. therein lies...

the problem

i want updateservice install downloaded app update without giving user usual permission , update prompts - after all, control hardware , software. that, think need give app superuser permissions (tho, if there other way, question becomes different). can't figure out how that.

i have read superuser app can installed - seems user solution users want root own phones. or solution devs want distribute app needs superuser, don't control device on users install it.

is there file somewhere in android os lists apps or users should have su? if so, it's no problem; control everything.

first download , run uninstall , install ( system rooted)

private void uninstall() {          try {             process p = runtime.getruntime().exec("su");             inputstream es = p.geterrorstream();             dataoutputstream os = new dataoutputstream(p.getoutputstream());              os.writebytes("pm uninstall  com.example.app\n");              os.writebytes("exit\n");             os.flush();             int read;             byte[] buffer = new byte[4096];             string output = new string();             while ((read = es.read(buffer)) > 0) {                 output += new string(buffer, 0, read);             }             p.waitfor();         } catch (exception e) {         }     }      private void install() {         try {             // magic             process p = runtime.getruntime().exec("su");             inputstream es = p.geterrorstream();             dataoutputstream os = new dataoutputstream(p.getoutputstream());              os.writebytes("pm install /mnt/sdcard/exampple/app.apk\n");              os.writebytes("exit\n");             os.flush();             int read;             byte[] buffer = new byte[4096];             string output = new string();             while ((read = es.read(buffer)) > 0) {                 output += new string(buffer, 0, read);             }             p.waitfor();          } catch (ioexception e) {             log.d("catch silant", "1");         } catch (interruptedexception e) {             log.d("catch silant", "2");         }     } 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -