Create Service in Kernel Which is Monitoring Multiple Packages on Android - android

I want to write one script(.sh file) in the kernel which is continuously checking my System app.
if my system app is crashed or for any other reason it stopped. my script(.sh file) will start the application.
Anyone have this script example or any other method to do this?
in which location I have to add this script in the Android part?
Thanks.
Let me know if you give more details.

In Android, you should handle this on the framework level.
Specifically ActivityManagerService is the system service which deals with this. You should debug and find the specific logic that is triggered when app crashes, so that you can there trigger a re-open.
Having searched a bit on the AOSP code, this seems to be the relevant file:
https://android.googlesource.com/platform/frameworks/base/+/master/services/core/java/com/android/server/am/AppErrors.java

Related

How to make own OTA app in AOSP - fslota?

we have build Android from sources and it looks good on our device. Currently we need to make own OTA process, but we dont know how.
We try to implement FSLOTa (https://github.com/embest-tech/android_packages_apps_fsl_imx_demo/tree/master/FSLOta) against our http server, but documentation is very poor - so we simply add source to our source and compile it.
Problem is, that we see app in our box, but it doesnt nothing.
Or there is way to modify built in OTA app, when we change server to our server, we get http request at least. But we dont know, how tells http server to box about new version - any manifest file? XML, JSON or? Is there any example?
Or is there another simple way for implements OTA update to AOSP?
Thank you very much
D
I dont know about FSLOTa nor do I know about the device you are working on. But If you want to implement your own OTA process you could try the following (Just a short draft since your question is very broad):
Create a system app that checks from time to time your server for new packages.
if it detects a new package it downloads it to your device.
it copies the downloaded update.zip to /cache/
Then the app creates the following file /cache/recovery/command and writes --update_package=path_to_your_file in it. (For more commands see /bootable/recovery.cpp)
Then it forces a reboot into recovery
recovery installs your ota package.
Update:
I quickly checked the app you linked. I would check these things:
Do you get till the point where RecoverySystem.installPackage() is called ? (https://github.com/embest-tech/android_packages_apps_fsl_imx_demo/blob/master/FSLOta/src/com/fsl/android/ota/OTAServerManager.java#L282)
Do you see a message in logcat from the RecoverySystem that it is going to reboot? (maybe you have a permission problem and your app is not allowed to force "reboot recovery")
Is the path to your update.zip correct? (it should be in /cache/)
i have been developing an OTA updater android application, you should know application send request to backend server and receive a JSON file about the available update. everything iiiiiiiiiiiiiiiiiiiiii anwserd was ok on non/AB devices, but for A/B devices, the android application downloads the OTA package under /data
and installation will not happen in recovery or anything, the changes will apply to the unused slot before REBOOT.

com.android.server.PackageManagerServices and Android

I am trying to debug native code in my Android App development and I need to have com.android.server.PackageManagerServices in the device. I search the info for PackageManagerServices and can't find good info in the web.
My queries are
(1)Where to get com.android.server.PackageManagerServices?
(2)How to create this service available on the device?
Thanks
PackageManagerService is located at /frameworks/base/services/java/com/android/server/pm/
PackageManagerService is a system service which gets started by SystemServer.java at boot time and always keeps running. one need not to create another instance of it.
You can refer aosp source code at http://androidxref.com

Permission check event (or log) for Android

I understand that when you install an android app you need to accept the permissions requested by the app. When you run the app, when it comes to the point that app really about to use that permission and perform a task, the android system has to check again "whether this app is allowed to perform this task?". I need to perform some task (log the event) at this moment. How can I do this?
There is a catch. I want to identify these instances (moments) for other running apps (not for my app)
(Ex: I want to know when DropBox app is about to access the internet.)
I need to perform some task (log the event) at this moment. How can I do this?
You can download the Android source code, modify it to incorporate your desired security flaw, compile the results into a ROM mod, and install that ROM mod on your own device.
This is not possible via the Android SDK.
There is a catch. I want to identify these instances (moments) for other running apps (not for my app) (Ex: I want to know when DropBox app is about to access the internet.)
You are welcome to install and use a firewall package on your rooted Android device and perhaps hook something up that way, for this specific scenario. In general, what you seek is not possible, for blindingly obvious privacy and security reasons.

What is android.permission.SET_PROCESS_LIMIT used for in an android application?

I have been trying to figure this out on the web with no information whatsoever as to what this actually does. The Google Manifest information says:
Allows an application to set the maximum number of (not needed) application processes that can be running.
I am thinking this is not a third party app permission but I need to be sure, its for our embedded device.
My guess is that this limits the number of processes that one application can have open when calling android:process=".RemoteActivity" in the manifest.
Anyone? Thank you.
It's a development/debug intended permisson. And just do what it says. Remember that when you run an app, android creates a process for all it's activities. This is, if you start opening the different activities of your application, you use the same process. However, Android let's you choose if an activity uses the main process or another new one. That's why this permission exists.
Sources:
http://developer.android.com/guide/topics/fundamentals/processes-and-threads.html
http://developer.android.com/reference/android/Manifest.permission.html#SET_PROCESS_LIMIT

Android: Sharing a common folder between linux application and Android application

Hi I'm a newbie for Android... Please throw some light on the following issue..
I have a file created by a linux application (written in C) with S_IRWXU|S_IRWXG permission and the file belongs to root user and root group.
Now I'd like to read/write to this file as an Android application as a different user (say app_41). It is not possible for the android application because it has no permission for the file.
What is the best way to implement this (without allowing "others" permission to the file/folder)?
The reason is that I have a daemon written in C that creates and manages named pipes for other process use. I'm trying to write to the named pipe from Android application (using native code) and I don't have the right permission to do it.
I won't be surprised, if someone says... "Hey it is very simple.. do this..."
Thanks for your help!!
I figured out a solution and it works... Please let me know if anyone has any better solution..
For an android application to share a file owened by a root process, we need to do the following
Make the Android application to belong to "system" user using
android:sharedUserId="android.uid.system"
Let the other platform process (owning the file) remain as root, but add it to the group "system".
Now the question is how do I add a process to the group "system".. One quick thing that comes to our mind is to add the process to init.rc and use the "group" keyword and start it. But Android doesn't allow it to happen.
To add the process to group "system" the process has to request the groupid from inside the process. That is, use the setgid(1000) system call from inside the process to add it to the group "system"..
And it works great!

Categories

Resources