All ADB devices offline when starting adb at boot - android

I'm testing an application which records user travels for later review. One part of testing involves testing application behavior when under user specified battery level.
It must stop recording to save battery. I have built a system with a raspberry pi that when you flip a switch, adb commands are sent to all connected devices to mock battery status.
My issue is when I tried to have adb as startup or as a service it, adb list all device offline thus the device doesn't work. My script will work as long you start manually the adb server.
More info:
It is the cold season here so we use a car to record travels. We can't have a screen on the device to comply with local regulations that is why, I require the adb to start at boot or during account automatic login.
Can anyone help me on this issue?

Related

Get instant current il milliampere from Android using adb

I need to calculate the power consumption of an Android smartphone using adb.
I know that there is Google Battery Historian, and I also know the command:
adb shell dumpsys batterystats
But I need something different: I want to launch an app (youtube for example) using adb for 10 minutes and, using adb (wireless) I want to collect the power consumption in milliamperes every second.
I know that there is a way to get the mA, but I cannot understand how.

How to exit recovery mode loop on an android phone used for development?

so i was messing with second screen app for changing resolution while mirroring
and i installed adb and added:
adb shell pm grant com.farmerbb.secondscreen.free android.permission.WRITE_SECURE_SETTINGS
and as soon as i started second screen my phone went into recovery mode and stuck in a loop where i have three options:
1-connect with mi assistant (which the software doesn't recognize my phone)
2-wipe Data but considering the fact that i haven't backup phone and i have some important data it's just impossible for me
3-is the reboot option which gets interesting cause when my phone is in this mode my device is shown in adb devices
List of devices attached
68100cf8 device
and seems like i have full access (i'm not sure)
so My Question is: is it possible to recover my data with adb or is there any other way?
in recovery mode, the adb also can be used, you can pull data from data partition if it mounted.

Update user location to server when application is in background

Mobile Technology: React native
Live Tracking using: Socket.io
I have taxi services application, in which I'm updating driver's location continuously to server. It is working fine when application is foreground. Now I want to update location of driver to server using socket on any other way when the application is in background. I need solution that works for both ios/android.
Please share your suggestions
im not sure about using socket but you can try saving your data on an sqlite database then using react-native-background-task for when your app is in the background
https://github.com/jamesisaac/react-native-background-task
use it like so:
BackgroundTask.define(() => {
//API CALL
BackgroundTask.finish()
})
componentDidMount() {
BackgroundTask.schedule();
}
please note that it takes ATLEAST 15 minutes for it to be called on iOS
OK, here goes not such an answer more an explanation of the situation you are in.
I've been in the same situation before and there are some things you can do to test your React Native app in the same scenario as being in 'Doze Mode'. Android introduced this as a way to limit CPU and battery usage whilst the phone is in Doze Mode. Doze mode itself is reached if the phone is stationary and/or hasn't had any interaction with the user for a set amount of time.
Firstly, with your current solution - you want to test your app in Standby/Doze Mode. You can achieve this by doing the below:
Testing your app with Doze
You can test Doze mode by following these steps:
https://developer.android.com/training/monitoring-device-state/doze-standby#testing_doze
Configure a hardware device or virtual device with an Android 6.0 (API level 23) or higher system image.
Connect the device to your development machine and install your app.
Run your app and leave it active.
Force the system into idle mode by running the following command:
$ adb shell dumpsys deviceidle force-idle
When ready, exit idle mode by running the following command:
$ adb shell dumpsys deviceidle unforce
Reactivate the device by performing the following command:
$ adb shell dumpsys battery reset
Observe the behavior of your app after you reactivate the device. Make sure the app recovers gracefully when the device exits Doze.
This will give you your testing scenario in order to test on Android.
The problem:
Android gives the apps less and less control of phones connectivity whilst in the background. It will stop networking all together and only opens in a 'Maintenance Window'. Android state:
The Doze restriction on network access is also likely to affect your app, especially if the app relies on real-time messages such as tickles or notifications. If your app requires a persistent connection to the network to receive messages, you should use Firebase Cloud Messaging (FCM) if possible.
The issue:
The problem is not running your app in the background, your problem will be using network in the background. For example, headless JS will run - runnable tasks will run BUT it may not be able to make any requests for network.
Possible solutions:
Using Alarms
If you need to set alarms that fire while in Doze, use setAndAllowWhileIdle() or setExactAndAllowWhileIdle().
Alarms set with setAlarmClock()continue to fire normally — the system exits Doze shortly before those alarms fire.
Putting your App into a whitelist (visit the link above for acceptable use cases).
iOS:
For React Native, I used this:
https://github.com/mauron85/react-native-background-geolocation
This also works for Android, however the Doze mode (in my case) wouldn't send off network requests.

How long does an App need to be idle for App Standby to kick in (Android Marshmallow)

I've looked all over the internet to find specifics about App Standby mode in Android Marshmallow, but I've not found any specific data for when it happens, other than some listed conditions that might cause it to happen. I also see a nebulous "If the device is idle for long periods of time, the system allows idle apps network access around once a day" without any specifics about how long this window would be.
Doze mode seems pretty well researched (This gist was particularly helpful and consistent with my findings), but I haven't been able to see App Standby in action. I created a test app that sends data to a server every 5 minutes via an Alarm and ran it for a week, and it continued to hit the server every 5 minutes unless the phone went into Doze mode and only hit the server in maintenance periods, then go back to every 5 minutes when the phone was awoken, so it did not appear that Android ever put it in "App Standby" state even though I didn't directly interact with the app.
Is there any specific data on how App Standby works?
You can force the device to enter this mode using the code below:
adb shell dumpsys deviceidle enable
adb shell dumpsys battery unplug
adb shell dumpsys deviceidle step
adb shell dumpsys deviceidle force-idle

Capture RRC state log in android

I am trying to capture RRC state logs which change time to time in mobile devices based on network usage .As of now the only way possible is to run special codes E.g "*#0011#" from dialer which is an inbuilt feature of device and cannot be run as a service in background.
Assuming i know the code to turn RCC state capture on, how can i log this in background in a file ?
Also is there anyway to capture and store logs that come up in adb logcat even when device is not connected to a computer ? assuming device keeps generating similar logs even when not connected to android adb shell.

Categories

Resources