3
donuts
5y

Are native Android apps easier to write now than like back in KitKat days?

I need a app that gets root permissions and reads a db file of another app (Yes my phone is rooted).

Anyone can give a gist, I forget do I need to create a Service background worker to do the DB reads... Or just need to send the op to a bg thread with a UI callback sorta like Node...

I did try writing a ReactNative app maybe last year just to try it out but can't seem to easily get root access... And the SQLite package is buggy, couldn't npm install on Win10...

Comments
  • 2
    Native is harder than back then.
  • 1
    @kescherRant how about getting root permissions..I remember need to run a su command and set a manifest flag?
  • 1
    @billgates No manifest flag necessary. That's outdated and unused. But yes, you have to run su and wait for a shell (and handle the case where the command is unsuccessful (user pressed cancel or no su rights at all)
  • 4
    It is pretty much the same as back then.
    depending on exactly how you want to access the sqlite db,. you need to:
    1. request root permissions via su command.
    2. make sure the other app does not hold the sqlite file open for write purpose.
    3. access the sqlite file, while using root uid. This is not a simple trick - most use a Background process spawed from the su command. Other options avilable.
    4. publish the results to your UI. My prefered method was to use an eventbus.
  • 0
  • 2
    Guess time to set up my PC for mobile dev again, give it another shot....

    Seems I always arrive to the party really late. But probably because I only really write apps for myself so if I have no reason to use it (aka not pissed off enough), I don't feel like building it.

    The app just reads another db to get stats from it (# of books read, on reading list). Feature I've asked them to add for years but they haven't bothered...

    I have a C# app to do it on PC but it's annoying to have to copy the file out of root and send it over, etc....
  • 0
    @billgates why not add it to the original app, or copy the db over to your app, and open from there?
  • 0
    @magicMirror the app I want the feature in is Blinkist... I don't own it but I know their db file is unencrypted since I have root so can access /data, and query the data I want out of it.

    The DB gets updated by the actual app so manual copy is a pain and not needed. That's what i do if I want to read it on PC but and sorta overkill just so I can get some "real time" reading stats.
  • 1
    @billgates
    Hmmm. The easy solution is to just get root, and copy the sqlite fileset (db, shm, wal) over to your app private data, change the file owner, and end the root session. Then you can open as your own file. Avoids the double open issue, and more stable. Copy the file over, only when file timestamp changes.

    The more complicated solution is to decomplie the original app, graft your new feature into it, then recompile it.
  • 0
    @magicMirror I guess I'll try not copying first, the DB is like 60mb+. Also I think the chances that both apps are accessing the DB at the same time should be low though I guess now Android does keeps apps alive/cached in the bg...

    I actually did have an app that did this before but there L or O update broke it.
  • 1
    @magicMirror looks like I gotta start from scratch.... Apparently the original source code I thought I backed up 4 years ago, wasnt the complete project...

    What API should I target? My own phone is Oreo.
  • 2
    @billgates Oreo it is then.
    No point to play with it, if you don't plan to release to play store.
    It should reduce build times.
  • 1
    @magicMirror seems ur rite it maybe easier to just root as needed... Though that's usually not how rooted apps work.

    I just figured out how to run su cp -c ... but can't find the docs for persistent root.... Like in Titanium of those explorers...

    I remember there should be a way to run the entire app/Activity as root but Google it helping...
  • 1
    @billgates In theory - it is possible.
    Here is a possible way:
    Spawn a background process under root, that has a contentProvider + Service, and establish communications from the normal wrapper app via binder RPC.

    Most persistent apps go this way, as it makes things easier to maintain.
Add Comment