Persistent App on Android Lollipop - android

In my Android manifest, I have flagged my application as "persistent", so that it automatically restarts if it crashes, is less likely to be killed by the system, etc. I know that normal applications cannot use this setting, but I am working on a custom ROM, and I load my application into the priv-app folder, and so I am able to use it.
This works perfectly well on pre-Lollipop phones. However, when I load my APK onto an Android 5 phone, the "persistent" setting is no longer honoured. I can use 'dumpsys activity' to verify that my app is persistent on Android 4.4.4, but not on Android 5.0.
Is there some additional requirement for persistence in Android 5? I see that some system-supplied apps are still persistent, so it's not as if it's completely impossible. Thanks.

Turns out I misunderstood the nature of the problem. The real problem was that I hadn't given the apk the selinux context permissions. I used chcon to copy the context from another file in priv-app and that sorted it out.

Related

Android - remove all app, except settings and custom app

I am working on a project where I am developing mobile app (android) using react native. The development of the app is fine. However, I need to remove all other apps from the existing device (I am using Nexus 7) but except settings and my app (the one that I am developing).
This special requirements is a must have as the device will be giving to the customer for one purpose only. So I need to have only one app installed and disable any option to installed any other apps from the app store.
But I have no idea, how I might be able to do so. So I really need your help. If you could guide me on this, would mean the world to me.
AFAIK you can't remove the standard applications because they are stored in flash memory (OS image) and this memory is readonly. What you can do is to download entire android, build own image stripping all the unnecessary services, applications, etc. And then flash this new image to the device. The process is not sample and straight.

Non-system applications install automatically on Factory Reset

I want to create an application that preserves its APK file with the ROM and is available (fresh installs) after factory reset.
Logic:
I bought a new phone from an e-commerce website and the phone had the e-commerce's application pre-installed on my phone.
I uninstalled the application but the application re-installed after I did a factory reset.
Uninstalling the application showed that it was a non-system application.
Automatically being re-installed shows it is included with the ROM.
How do I achieve this?
Factory reset basically wipes the internal storage and replaces it with a copy. On some models, you can replace that restore image- but you need the device's boot loader to be unlocked to do that. Its not a programming thing, its a matter of replacing the restore image with an image including your apk.
If you want your app to always be included in Device even after factory reset. For that you need to embed your app into that particular ROM, Like all google application comes already embedded in Android ROM.
Also If can develop new ROM from stock one then you can embed your apps too. Like, most of the Chinese and Samsung's TouchWiz ROM comes pre-bundled with their own APPs, instead of that stock one e.g Contacts(System), Messaging(System) and Flipkart(Non-system).

how to check if another app is minimized or open in android?

I have seen many solutions to check if our own app is minimized,running or background.but is there a way to check if another app package is running or minimized so that based on that we can run a code.like an app-locker.Here we need to turn off network for a certain apps according to the user selection on installed apps in device, so when that selected apps are on foreground, network should be disabled when the selected apps are closed or minimized.then enable the network.
Will it be compliant with Google play if we make such an app? because somewhere i read they don't allow apps that interfere with other apps.so confused.
TL;DR: Google doesn't want you to do this, and you shouldn't try.
The old hack that relied on ActivityManager#getRecentTasks() to find out which app is in the foreground was disabled starting in Android 5.0.
App lockers that work on Lollipop are using a new hack involving ActivityManager#getRunningAppProcesses(). How it works is described in this answer. This hack is reportedly broken on Android M.
There's a new UsageStats API from which you might be able to glean a bit of info, but it requires a permission that can only be granted by a system activity. It's documented that this system activity may not be present on all devices. Samsung and LG are among the manufacturers that have reportedly removed this activity from their Lollipop devices, so only system apps will ever be able to use UsageStats.
The bottom line is that Google has shown their commitment to preventing what you're trying to do. Even if you find a temporary solution, you can bet that it will stop working in a future Android version. Eventually, Google will close all the loopholes and your app will be permanently broken. So it's probably a waste of time to write a new app that depends on this capability.

How to modify android system application

I made a little modification to the default Phone application of Android 4.2.2 from AOSP. I want to replace the stock app with the one i modified. When I try to remove the stock app and place the modified app (and then reboot), the phone app fails. I'm guessing it has got something to do with apk signing. Is there any way to solve this?
My device is rooted and i also have the factory image.

Replacing phone.apk with a customized app

I need to know what are the steps in modifying the phone.apk app on android, which allows to call and receive calls (and what is shown upon talking on the phone).
What do I need to do (of course I have a rooted device)? is it possible to do the tests on the emulator first?
my guess is that I first need to fetch get its source somehow, use some kind of system signing, do the changes and put it forcefully into the device, maybe also restarting it.
However, I've never done such a thing and I couldn't find much help in xda forums and here, maybe because it's pretty hardcore thing to do , plus it might not work well on some devices.
I've noticed that the only thing that shows this is possible is the calls-recorder patch, which is incredibly cool by itself.
First thing is you need source code. Phone app heavily depends on the radio interface layer and radio interface layer is proprietory to what kind of communications processor they use.
I believe you cannot test on emulator unless you are working on nexus family of devices. Also phone app runs on a particular shareduserid which can break other apps running with same shared user Id . So you will need platform certificate for signing which is next to impossible for release version of phone software.
One thing you could do is download cyanogenmod code for your phone , do changes , build and download the whole of software on the phone rather than just phone apk.

Categories

Resources