How would you programmatically get the application to install itself in /system/app so that it is treated as a System application and not a user app?
I don't believe it's possible to programmatically install your app in /system/app folder. You can however, ask for root permissions and execute any commands requiring root privileges using this guide:
http://muzikant-android.blogspot.in/2011/02/how-to-get-root-access-and-execute.html
Related
For a setup box powered by Android(Q) we want the ability for an app which resides in /priv-app/ section to uninstall packages silently without user interaction.
I have root access to the device.
The app has android.permission.INSTALL_PACKAGES and android.permission.DELETE_PACKAGES permissions declared in the manifest.
When the same code is run on Android phones/ emulators with root access it is able to uninstall the app from the device (when the app is made as device owner).
But in case of Android-TV, there is no provision/section for enabling device admin apps, and if I try to enable it using command adb shell dpm set-device-owner com.tvdevice.deviceadminapp/.DevAdminReceiver
line it throws error
java.lang.RuntimeException: Can't set package ComponentInfo{com.tvdevice.deviceadminapp/com.tvdevice.deviceadminapp.DevAdminReceiver} as device owner.
at com.android.commands.dpm.Dpm.runSetDeviceOwner(Dpm.java:177)
at com.android.commands.dpm.Dpm.onRun(Dpm.java:106)
at com.android.internal.os.BaseCommand.run(BaseCommand.java:54)
at com.android.commands.dpm.Dpm.main(Dpm.java:41)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:340)
So as a workaround I directly edited the xml files device_owner_2.xml and device_policies.xml at /data/system/ to include my app as device owner, but still it is not able to uninstall the app installed from some other package (ex: com.android.vending, installer of package for apps installed from play).
Note: The app is able to uninstall the packages which are installed by it (to which the current app is installer of package), but it fails for apps installed from other sources.
Is there any way to make if work?, please help.
While developing in Android Studio on Windows, every now and then I have to check the database on my testing device. To pull it I use Android Device Manager. Through adb I granted access permissions to /data/data/xx.xxx.xxx/ folders, but read and write permissions to /data/data/xx.xxx.xxx/databases folder and its files I have to grant every few minutes.
I'm giving grants with chmod 777 command while running adb.
Is there a way to set things up that I can have constant read and write grants to the databases folder and its files?
You can root the phone or use an emulator. Emulator files (including sqlite db) are easily accessible via DDMS without any permission. It also has a neat little download button which you can use to download db on your computer .
I made a filemanager that I want go be able to navegate/modify some system folders (say, /data/). I copied my apk to /system/app, gave 644 permission to the apk file, and rebooted. Yet, my app is still run without root privileges (deny simple access to /data). I'm using Cyanogenmod 11.
Any clue?
Thanks!
L.
To clarify, the app being in the /system/app folder does not run it as root. Android is linux based, so having root access means that your app is able to run shell commands as the root user.
Generally speaking an app being in the /system/app folder makes all declared permissions available to it, (for example, declaring WRITE_SECURE_SETTINGS only does anything for system apps), and then the code that was only available to system apps is now available to yours as well.
For reliability, you should use shell commands where possible for anything that's normally unavailable. Do not use java.io.File to access files that are normally restricted.
I would recommend using RootTools as it makes running shell commands as root much easier. The first 3 pages on this linux command cheat sheet will probably cover everything you need.
I am developing app which will come pre-installed with certain devices, however im testing the app on my own device and will need to demo it on my own device. At the moment its fine as im testing it as a user app, but now i need to use permissions which only the system apps get to use. Is their a way in the project settings to say its a system app so I can test and demo it?
short answer - i would root your phone. However, unlocking the bootloader is possible without root. So, IMO, you could install CWM as your recovery, then boot to CWM, then use the CWM option to MOUNT system, then use adb to copy your .apk to /cache, then use linux util 'cat' to get the apk from /cache to /system/app, then unmount /system using CWM, then reboot.
long answer - if you are developing system apps, learn the security environment of android. Learn the issues around permissions in the /system folder, and learn the recovery type tools that allow a developer to have access to the /system folder where adb activities like install , uninstall are restricted.
This is an older discussion 'froyo' on how-to install system app, illustrating some of the permissions issues in the /system folder. I would not simply follow these instructions without reading up on how its done in honeycomb and in ICS.
We are creating an Android application which requires super user privileges. The SuperUser.apk and su are installed. However there seems to be a difference between installing our application in /data/app vs. /system/app. If we install in /data/app, everything seems to work fine. If we install in /system/app, SuperUser.apk does not popup to grant privileges.
Are there certain types of programs that must be installed in one location vs. another?
TIA
APK files in the /system/app folder already have system-level permissions so they don't require SuperUser, which I assume is why it doesn't pop up.
You should confirm that your application already has the permission you have requested. For instance, AlarmManager.setTime requires the signatureOrSystem permission android.permission.SET_TIME and will throw an exception if it doesn't have it. You can also check explicitly with PackageManager.checkPermission.
If this doesn't work, check the attributes of the APK file. If they don't match the other APKs in the system folder Android may ignore them. You can fix it like this:
chmod 644 <filename>