Stop Android Service from another package - android

Before someone tells me this cannot be done, I have done plenty of research on why on process cannot interfere with one another and under what conditions this is possible. Our problem is that the Bluetooth support between devices is inconsistent and the solution on some devices is to stop the existing Bluetooth service and run a separate app (BlueFTP) which is then able to listen on the freed port and manage OPP communication.
android.permission.RESTART_PACKAGES permission plus ActivityManager.restartPackage() doesn't work as it simply restarts the offending package.
Process.killProcess does not work for the obvious reasons (read the API)
android.permission.KILL_BACKGROUND_PROCESSES permission plus ActivityManager.killBackgroundProcesses() is ignored because (I believe as per the API) the Bluetooth app is not considered a background app and therefore not eligible to be killed.
Currently if a client is having an issue with a specific phone, we get them to go to the running apps and force stop the offending OPP Service before refreshing BlueFTP so that the port listener starts. The offending service has more than one possible name depending on the phone and Android version.
So. The process is currently manual but I was hoping there would be a way to achieve this via code mirroring the force stop option in settings. A lighter option could be to assist in opening the settings for that service rather than needing to explain to clients how to get there, but I'd prefer a complete solution if one is available.
Note that while our the dev phones have root access, the client phones will not.

You can use implicit intents for your services in other apps to close them. It wouldn't need extra permissions as well, unless your service enforces a permission for it's access.
Oh, I overlooked the fact that it's a third party app. In that case, you can't really do much. Sorry.

Related

Android Oreo: Is there any way to auto - start the application on mobile reboot?

I am developing an application for a business entity. That application should run in the background in every employees' mobile phone. Employees are mostly salesman. The application basically detects location changes and suggest the salesman where they might visit. A kind of reminder application. It also lets other salesmen see where are their teammates.
Right now I am using a foreground activity and it works fine till the system forcefully doesn't kill the service or the phone doesn't reboot due to manual activity or battery discharge.
Ones the application is closed, as of now, the managers in the firm needs to call salespeople to turn on the application once, as on application start it automatically turn on its foreground service. But this is really an extra burden on the management team which can be automated.
I am ok to have any settings based or code based solution. One solution is to root the phones of salespeople and install some extra utility app or write the code based on root APIs, but this will be too much for this simple task.
THe permission RECEIVE_BOOT_COMPLETED was not added properly in the manifest. After adding the permission it worked calmly. In on receive method of the broadcast receiver, I am starting the foreground service.
At the moment, the best way is to use WorkManager https://developer.android.com/topic/libraries/architecture/workmanager/ Yes, it still alpha, but works very good.
From other side, you could work on automating the task "managers in the firm needs to call salespeople to turn on the application once". I mean, an app/backend could automatically call the salesman (with some pre-recorded message) or send SMS to them.

Android User tracking application which prevent it self from being killed by users

I am working on an Android enterprise application that targets limited mobile devices which help owner to track the user/device status (like GPS, Calls logs) remotely. I managed to implement these basics features to my application. Challenge that I'm facing now is the end users who traveling away with the device can force stop the application or can revoke some permissions(above Marshmallow) to prevent them self from being tracked remotely by the owner.
First of all is it possible to make such an application?
If yes, what are APIs given for such applications development?
Note - All the targeted devices are rooted anything I can get advantage of that.
Is there are any special APIs available for developments of those applications which work only on Rooted devices?
According to your requirement i will suggest you to look deep into the android Service.
As You might also have a look on the persistent service,
You can only make your service persistent if you are developing system apps. This service is basically unkillable.
Here is some write up for persistent service
Hopefully this might help you.
But for non-system applications, startForeground is your best option.

How to lock (other) apps with password?

I've seen some "app locking" solutions in the Google Play store and I was wondering how those apps work. I'd like to build something similar.
I realize that this might require some special permission or maybe request the app to be added as device administrator.
Is there some broadcast that is triggered just before an app is launched that I can intercept and do some action (e.g. launch an activity that will request the user to fill a password)? I've read some lengthy discussions how this is not a good idea and the only idea is to have a background service that will continuously poll the running processes and check for changes, but I think retrieving this list every second and checking it for chances is not good for the battery and I think other app locking apps out there must be using a different approch.
If possible, without the need for a rooted phone.

Disable intents registered by other apps

I want to disable/unregister intents registered by other apps so that they would not get broadcast messages sent by the system?
Something like this:
Gemini app
(3rd screenshot)
Is there any similar app with the open source code?
Also, it is possible to remove permissions registered by another app?
I want to disable/unregister intents registered by other apps so that they would not get broadcast messages sent by the system?
Fortunately, that is not possible, except on rooted devices.
Something like this: Gemini app (3rd screenshot)
As the app notes, this requires root.
Also, it is possible to remove permissions registered by another app?
As JonTraex notes in his linked-to answer, this is not possible even with root.
I answered a similar question here:
https://stackoverflow.com/a/9106832/529691
If you had bothered to look at their permissions you could see how they are doing it.
SYSTEM TOOLS
KILL BACKGROUND PROCESSES Allows an application to kill background
processes of other applications, even if memory isn't low.
KILL BACKGROUND PROCESSES Allows an application to kill background
processes of other applications, even if memory isn't low.
FORCE STOP OTHER APPLICATIONS Allows an application to forcibly stop
other applications.
MEASURE APPLICATION STORAGE SPACE Allows an application to retrieve
its code, data, and cache sizes

How to Lock(Block) an android application from starting / How to stop an android application (service) from starting at boot

I would like to know if there is a way to lock (prevent) an application from starting.
And i also would like to know if there is a way to prevent a service(application) from starting at boot of the device
...i would like to know because i would like to create an anti-malware app.
I know this question is old, but for others stumbling over it:
Autostarts is an application that can disable apps from starting at boot time. It's the best I've found to do that (it isn't resident and doesn't kill processes like a task manager, it actually parses apk packages and reads registered actions and blocks the actions you tell it to). BUT it needs root and hasn't been updated for a while (december 2011). It works on Android 2.3 on which I tested it. Because it was discontinued, I don't know if it works on newer OS versions.
It's commercial now, but that's not the point, you need a peek at the source code.
If you search a bit, you'll be able to find the source code for an older version and see how it implements the blocking system.
I would be very interested in an application that could block certain services. NOT kill, but prevent them from starting in the first place. And the list is quite big: Facebook (OrcaService, MqttPushService, MediaUploadService, BackgroundDetectionService), Twitter, Maps (NetworkInitiatedService), Yahoo Mail Sync, etc. I don't use the features that the services provide, I even disabled some of them in the app interface where possible, but they still pop up and remain resident after exiting the application.
I would like to know if there is a way to lock (prevent) an application from starting.
Not in any supported fashion. Anything that does this is malware, and the techniques for doing it are security holes.
And i also would like to know if there is a way to prevent a service(application) from
starting at boot of the device
The user can boot their phone in safe mode (I forget the exact process, but it's something like holding down the HOME key while turning the phone on).

Categories

Resources