Is it possible to upgrade Android firmware programatically? - android

I need to write Android application which looks for firmware in internet and allows to automatically download selected firmware and perform update on device. Is it possible?
Thanks

It should be possible. I am trying to do the same thing. I posted a question about this as another user. It almost works for me, but my device can't apply the new image on boot time.
Basically you use the RecoverySystem.installPackage(context, packageFile) method to do this. You will also need the following permissions:
<uses-permission android:name="android.permission.REBOOT" />
<uses-permission android:name="android.permission.ACCESS_CACHE_FILESYSTEM" />
<uses-permission android:name="android.permission.DELETE_CACHE_FILES" />
Also, your app must run as a system app. I don't know if you're using the whole Android SDK with Eclipse and the SDK tools, but what I did for that was basically connect my device to my machine and used it for debuggin, then ran the app through the IDE so it gets uploaded and run on the device. And finally use the adb shell command to open up a shell on my device and moved the apk package file from /data/app to /system/app and rebooted.
Check out my post here. It might help you out.
Android development RecoverySystem.installPackage() cannot write to /cache/recovery/command permission denied

You need root, and it won't be automatically applied, but like with cyanogen updater, it reboots to recovery where the user will apply the update by itself

It is possible. Take a look at Clockwork Mod - http://www.clockworkmod.com/rommanager
They have an app which will check for the latest version of the firmware and update it - available on Google Marketplace https://market.android.com/details?id=com.koushikdutta.rommanager&hl=en

Related

Without root, can I use adb to downgrade an app (circumventing the [INSTALL_FAILED_VERSION_DOWNGRADE] error)?

I recently purchased a Moto Z Play Droid Edition which is incapable of being rooted or the bootloader being unlocked. In an attempt to remove bloatware, I have removed several apps. I managed to "uninstall" apps following this XDA tutorial, however without root, that merely disables them from the user.
I have used an old version of Google Calendar for several years, and I wanted to be able to install the same .apk that I have used, however Google Calendar was installed as a system app on Stock Android, so I would need to downgrade it. When I try the simple commands of adb install -r -d -f calendar.apk I get
[INSTALL_FAILED_VERSION_DOWNGRADE]
Because I was unable to fully uninstall the Google Calendar app that came with the stock ROM, there must be some remnant that prevents me from installing an older version.
Is there any way to progress and install this apk? Do I need to change something in the AndroidManifest.xml in order to proceed? Is that even possible with a Google app, which is most likely encrypted?
Any other suggestions?
You would need the source to be able to modify the manifest and rebuild. You would need to change the package name, that's the only way to do it.

My device is rooted but my android app does not have root access (libsuperuser)

I am trying to build an application based on libsuperuser. My device is rooted but I have two problems:
1) After to export my apk, for some reason it is asking for certificate. I need to export signing the app which does not make sense for a rooted device. Why do I need to sign if the device is rooted ?
2) When I run the app, I checked if the app has root privileges calling Shell.SU.available() available in the libsuperuser which returns "false". It means the app is does not root privileges and I cannot run commands like "chmod".
3) If I try to call the shell commands using libsuperuser API adding "su" as prefix in the log message I see that the current app user (which is not root) does not have "su" privileges.
PS: I know Eclipse is deprecated but this project was build on Eclipse and I had some problems importing to Android Studio.. that's why I am using Eclipse at moment.
Any help is very welcome!
Did you add the permission in the AndroidManifest.xml?
<uses-permission android:name="android.permission.ACCESS_SUPERUSER" />

Unknown error code during application install "-505"

I have checked this android 5.0 lollipop app install shows Unknown error code during application install: "-505". But it doesn't seem to address my case as I dont use multiuser env.
I have an app in the playstore which worked fine on my nexus 4(4.4.x) till i upgraded to lollipop and it showed this error every time i tried to install it from playstore(It installs fine if I run it via adb).
Can't understand why I might be facing this issue, neither is there any other reference to this error code.
Any help is appreciated.
This seems stupid on my part, yet finally found the answer which seems to be the fact that I had another dev app(diff package name) which had a common signed permission with the playstore app.
Buried deep in my logcat was this.
11-21 16:20:02.855: E/Finsky(8986): [1] PackageInstallerImpl.handleCommitCallback: Error -505
while installing <package>: INSTALL_FAILED_DUPLICATE_PERMISSION: Package <package> attempting to
redeclare permission <package>.permission.MAPS_RECEIVE already owned by
beginning with lollipop it seems this isn't permitted.
Thanks to everyone.
EDIT
The solution if not apparent yet is to change the permission from
<permission android:name="<old package>.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
to
<permission android:name="<new package>.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
or whichever signed permission that is causing the same.
With an official Lollipop version
and for mac users (i'm sure it's analogue to windows users):
Go to the terminal,
cd into: ADT/sdk/platform-tools
type ./adb uninstall the.app.package
and thats it!
you just uninstalled the app
don't add the -k flag - ('-k' means keep the data and cache
directories)
good luck!
This is caused by a bug with app certificate parsing in Lollipop:
https://code.google.com/p/android/issues/detail?id=79089
If the app you are trying to install has the same certificate as a similar app or related app with the SAME certificate, then Android 5.0 won't allow the installation, believing you are installing a duplicate of the already installed (but different) app. Only solution that worked for me? Uninstall the app with the same certificate, which would be an app made by same developer that made the app you are trying to install. Once you've uninstalled that app, install the problematic app, then go back and reinstall the other app which was already installed. This problem happened to me only once, when trying to install the FB Messenger app. I finally was able to install it after I uninstalled the Facebook app. Then I reinstalled Facebook after Messenger was installed. OK, good luck to all and hope this helps some of you.
Multiple users installing same app on same device may cause this error. Please remove other app from the device and that should work.
I faced similar issue, however in my case it was an old development build sitting on my device and when I was trying to install from play store this error was coming.
I have got similar problem and solved with this solution.
Solution: After you update your Android device to Android 5.0 Lollipop from an older version using Over-the-air update or sideloading factory image, do a factory reset. It has been found out that if you do a factory reset immediately after updating your Android version, the error does not occur, but if you don’t the error persists. Don’t forget to clear the cache too, going to Menu > Settings > Apps > Google Play Store > Clear Cache. Clear the data too, from the very same option.
Source: http://appslova.com/android-fix-unknown-error-code-application-install-505-error-505/
Hope this help!!
Try resetting the play store app. You won't lose your apps following these steps. Nothing important will be lost.
Steps to follow on a motorola xoom
Go to the app drawer (menu)
Tap settings
Tap applications
Tap the "All" tab
Scroll through and look for play store
Tap Play Store (not play store services!)
Tap "clear data"
You will then get a warning, click "ok"
That's it, go through your problem again and see if it fixed. Bear in mind you will have to re-accept the terms and conditions for the play store app, when this comes up, simply click "accept"
try adding applicationId to the defaultConfig section of gradle file like
defaultConfig {
applicationId "com.example.www"
}

Android application works when debugging but won't install

i'm developing an android application using Xamarin.Android.
It's all fine when installing my signed apk on an Android Kitkat phone, but when I try to install it on older android versions, there come the problems...
If I try installing the application on Android 4.1.2, it says "Application not installed", but if I try to debug the app using that phone as target it works brilliantly, no problems at all, every feature is working as expected. I also tried on android 4.2.2 and got the same result, so I think it's not related to minumum API level too low (it's set to 14 right now).
Is there any way I can see why it won't install?
Can anyone help me understanding the problem?
Thanks!
Like Alex.F said, you may need to enable "allow unknown sources" in the settings menu. Other than that you may have added "uses-feature" attributes to your androidmanifest.xml that forbid the app to be installed on certain devices (in release mode).
For instance if you add
<uses-feature android:name="android.hardware.usb.host" />
You shouldn't be able to install/start the app on devices that do not support usb-host mode. To remedy this you can add a required="false" attribute like so:
<uses-feature android:name="android.hardware.usb.host" android:required="false" />
This will make the usb-host feature optional. Hope that helps, otherwise see if you can try to provide a bit more information!
Good luck!

Permission: INJECT_EVENTS for Instrumenation to other apps

I know that this is not the first Thread about this permission, however the other ones aren't finished or don't help me.
What I need is to inflate KeyEvents using Instrumentation. That works great and is insanely faster than the shell ("input keyevent ") method. But if I want to inject to other apps I catch a SecurityException. That didn't surprise me to much so I added <uses-permission android:name="android.permission.INJECT_EVENTS" /> to my manifest. Eclipse stops to debug this telling me that only system apps can use this permission. So I compiled using the signed apk tool and pushed that apk to /system/app. Rebooted, and guess what
W/PackageManager( 3499): Not granting permission android.permission.INJECT_EVENTS to package com.<....> (protectionLevel=2 flags=0x8be45)
The app is targeted for only one special device. So I know all the specs and it is rooted. But su injection-commands take to long and SuperUser is required. I would love to do that with Instrumentation or maybe there is something else I should try?
The firmware is not written by me, so I don't have the platform key.
Thanks for your help!
EDIT: Got the platform keys (The dev used the normal Google ones), signed and aligned, then pushed the apk to /system/app. Also added android:sharedUserId="android.uid.system" to my manifest. On Boot there is no longer the logcat message. However when I want to send the keysync I still catche the SecurityException. Any ideas?
EDIT2: Here is an excerpt from ps. Seems like the package ist not listed as system
u0_a108 5241 2399 492044 48968 ffffffff 40113ab0 S com.mypackage
Update Use the signtool located here, then go ahead and read on in my blog.
Ok, I got the right platform-keys and it works like a charm now! I signed using http://forum.xda-developers.com/showthread.php?t=1125626
and replaced (renamed the sign.... to testkey....) the testkeys inside signare folder with
signapk-key.platform.x509.pem
signapk-key.platform.pk8
(Google for them)
Also make sure to zipalign and then to copy to /system/app. Installing the .apk the normal way is NOT possible as it is flagged as System app.

Categories

Resources