Changing the UID of a system app - java

I know that we can get the UID of a system app using ApplicationInfo().uid(). But can I set the UID of my app to what that function returns?
I need to do this because I am attempting to copy a shared_pref file belonging to a target system app to a location on the sdcard. Btw, my device is rooted.
More details on my problem at Error in Copying file of a system app into another location.

You can run shell commands as root using the "su" program which is installed when rooting. There is no way to do it directly with the Android SDK.
http://www.stealthcopter.com/blog/2010/01/android-requesting-root-access-in-your-app/

Related

Open an Android app from a directory on sdcard

I have a client that uses android devices with a kiosk mode. They have a kiosk mode manager that only allows apps they add to it to be opened. I was informed the kiosk manager opens apps from the Android/data directory on the device (from one of the com.google.x type directories). I've been attempting to have on of those directories created by this app so they can launch it from their kiosk manager, but haven't had much luck. I can see the directory I'm looking for in the Device File Manager under data/data/com.x and data/app/com.x, but is there a way for me to get those files to be located under sdcard instead of data? The app also doesn't give me an option to manually move it to external storage, so I'm not sure if that's part of the problem. The devices are running Android 8.1.0 and the app just sends user input data to a server on the network.
Essentially, they want to be able to view the app files from the device and also open the app from a directory on the sdcard (sdcard/Android/data/x).
I have tried adding android:installLocation="preferExternal" in hopes of being able to see the app files on the sdcard where they requested it, but it has not made a difference.
Thanks for any help!

How do I build my apk as a system app on Windows?

I have seen many guides online for how to do this, but they are all assuming a linux environment. I am developing using Android Studio on Windows, and am having trouble following these guides. Specifically, I do not know where to find the platform.pk8 and platform.x509​.pem files required for making my keys. The guides all say they are located in build/target/product/security, but I assume this is the corresponding linux directory. Where can I find these files on my windows device?
To have a system app in Android OS you need to sign your APK by the same key which the OS is signed. These key in the Android open source project can find in
build/target/product/security
But each company has got its own key and you cannot access to those key!
You can build your own Android image and load it your own development bard which probably is not easy. Then you have a system key. you can find useful information here
But the main reason if being a system app is to have the privileges of a system app.
What are those privileges? granting all permission and have access to the restricted area and secure setting for example.
So there is another possible way to be a system app.
If you can push(copy) your APK to /system/priv-app/ folder, then Android will grant all system privileges to your app automatically. (to all application in /system/priv-app/ folder not just to your app) .
How you can push your file into /system/priv-app/?
When you have Android Studio probably you can run adb. you can find some information here
You can connect to your android device using adb and through your local network
adb connect deviceip:port
port by default is 5555 and you don't have normal type it.
For connecting to an Android device the device should in developer option. you can find some useful information here
when you connected to your device you check if your device is rooted and the system folder is mountable or not.
/System/ folder is protected by AVB and furthermore, you need to be a root user, so you use the following command
adb root
adb remount
if your device is rooted you can easily push your APK to system folder and have all privileges of a system app.
adb push <yourPackagePath> /system/priv-app/youtPackage/yourPackage.apk
if your device is not rooted you should search for how you can root your device

Store data on device on application install without opening app

Is it possible to save data to a device upon the installation of my application prior to the opening of the application?
If not, I'm looking for a way I can somehow mark a mobile device as "test device" without my application ever being opened on it (only installed).
If you want to distinguish between the shipped devices and every other device, use the build variants. You can add a variable to the BuildConfig class in gradle and specify a value for this sort of "prerelease" you are making and other for the build you are shipping to the store. Then, in the relevant code, check the value of the variable you created in BuildConfig.

How to read database of another application

I am working on a rooted device.
I have connected with the adb shell from my pc and I can verify that the other database exists and I can query its tables.
However in the my java code when I try to open the database I get error
android.database.sqlite.SQLiteException: unable to open database file
I am trying to open the database like this:
SQLiteDatabase.openDatabase(PATH, null, SQLiteDatabase.OPEN_READONLY);
The path is something like /data/data/com.xxx.xxx/databases/xx.db
Am I supposed to read the databases of other applications like this or there is another way?
UPDATE:
I also tried making the system app as adviced in this thread Push my apk to /system/app
I think it works because the app cannot be uninstalled after that from the applications manager like the ordinary apps so I think it is a system app. But still I cannot access the database though I am sure the paths and permissions are ok.
Android OS by default does not allow applications to access each others private folders. To be able to read files that are in another applications folder either:
1) you need to have both applications installed using same user id. Add this to both manifests:
android:sharedUserId="com.xx.xx"
2) If other app is a 3rd party app then your only choice is to install your app as system application. To do that you need a rooted phone and you need to mount the system folder. And then you need to put your application into /system/app/ folder and reboot the phone. It should be installed automatically during the boot.
I would assume that the permissions on the database files are set such that your application has no acess. Even if your device is rooted it doesn't mean that your application is running as root.
This is because the app needs root, and needs to change the permissions of the database you are trying to access so that you can actually access it. What you will need to do is, as root, change the permissions of the database so that everyone can access it, do what you would like on the database, close the database and change the permissions back.
This does circumvent security of android, so proceed at your own risk. You can find a code sample at:
http://rratmansky.wordpress.com/?p=259&preview=true

Which advantages give to developer ROOT access on android ?

I use android platform about 1-2 years, and there are some apps which need to be root access. When i creating android app what give me this ROOT access ? Clearly to say,
if (haveRootAccess) doSomethingSpecial()
what can be doSomethingSpecial() ?
you can access /data/data/ folder of the device which helps to get data of each application installed in device and one can manipulate it.
you can able to run command like su ping ftp etc with command terminal.
Can add additional commandfile /system/bin folder.
Root access is required for apps which needs to execute operations on command-line with Super User rights. Its just like using Terminal on linux system with command sudo.
//for example
Process suPro = Runtime.getRuntime().exec("su");
For more info, read this

Categories

Resources