Here's an overview of how the entire setup is going to be connected, the phone will be connected to a power bank via USB. The power bank will be charged by connecting it to a hardwire kit that will convert the 12V from the car to the required 5V 2.5A.
The power bank will charge only when the car is running and it will stop charging when the car is turned off. The phone used, is programmed to automatically charge from the power bank when the battery falls below 25% and stop charging when reaches 90%. Thus the phones battery won't be over charged and this entire cycle will be automatic.
To make things more convenient the phone is programmed to send a text message if the battery level falls below 24%, stating that the power bank is not performing as expected or there is some issue with the charging.
The above mentioned steps are the most time consuming one's as it took me a lot of time to find out the perfect file that needs to be edited in the phone to ensure that the phone stops the power completely and does not charge at all even if the power bank supplied power, before the power bank entered hibernation.
Now coming to the tracking part, Google offers a track my phone option which allows you to locate your android phone either from the app "Find my device" or using the website when signed in using your google account, given that mobile data and location are enabled and "Find my device" has been activated in the Device Administrator. We will use this exact same method to track the phone and eventually the car to pin point it's location. We also need a SIM card with data service, preferably the unlimited type plans that cost around 300-400 bucks for a subscription of three months.
Now to ensure that your car lets you know if it's being broken into or being towed or someone has tried to damage it, I have configured the phone's acceleration sensor to measure the deviations in the sensor readings. If there is a 1% deviation in the sensor's readings, it will send a text message stated "Shock detected" to my phone. If this keeps happening I'll get a text message every two seconds every time a shock is felt by the car. Thus I'll be alarmed if someone is trying to mess with the car.
Yes I know, you are thinking what about when I am driving the car.

So to prevent your inbox from getting full, the Shock trigger can be activated and deactivated by sending text messages with specific texts like "Shock on" and "Shock off" from your phone to the programmed phone to enable and disable the shock detection. So you park your car, send a message from your phone to start the shock sensor and when you come back another text message to disable it before you leave.
Activities like, door open and close, boot open and close, hood open and close can be monitored.
Now the entertainment part, who doesn't like to be online on the move. So while we are at it, I decided to add another trigger, also text message based, that will turn the WiFi hotspot ON and OFF on the programmed phone depending on the content of the message.
So without any further ado, let's begin.
Required material:- Rooted Android phone, preferably with 5.X.X (lollipop) operating OS with original battery in good condition.
- Dashcam hardwire kit. (Micro USB)
- Portable power bank preferably 10000mAh.
- and some patience!!
The first step to begin with is a rooted phone, all android phones can be rooted, only the procedure gets a little tricky as the OS goes to a higher number. I have recommended a 5.X.X OS if you wish to use the hotspot feature. If you don't want to use the hotspot any OS above 5.X.X can be used given your phone is rooted. My phone is running on OS 5.1.1.
To root your phone, you can search on XDA developers forum or Google our phone name with root in front of it.
Once you have a rooted phone you have to install the apps I have mentioned below. All of these apps mentioned require root to work. All these apps are available on the Google Play store.
- Automateit PRO. (v4.0.227)
- Automateit Hotpsot Plugin.
- Automateit Shell plugin.
- CPU Awake. (v2.1)
- Memory lock.
- Terminal Emulator.
Once you have successfully installed all the apps. Open Automateit PRO, on the top left corner, click on the hamburger style menu button and click on refresh plugins. This will activate the Hotspot and the Shell plugin. To make sure the plugins are active open both the hotspot and shell plugin app and close them. While in the shell plugin app tap the spanner icon and allow root permissions when the dialog box pops up.
Once inside the app, delete all the default rules and click on the "+" button inside the my rules tab.
Automateit PRO allows you to make rules that trigger under conditions provided by the user and makes changes to your device as required.
Rule I: Disable phone from charging when battery reaches 90%.
After you click the "+" button, you will be shown a list of triggers, out of which you need to select the battery level trigger. After selecting the trigger, enter 90 as value in the text box and select above or equal from the option. This is your trigger set to disable charging. Click OK or next and you will come to the action tab. Scroll to the end of the list and you will find a "Shell Command Action" option, select that.
To make things easier open Terminal Emulator application and type "su" (without quotes) in the window. Grant root permissions when the dialog box appears.
Type in the codes from 1-6 one by one while the phone is connected to the wall charger and is charging. Hit enter key on the keyboard once you are done typing the code and see if the charging stops. If it does, stop, else try with the next code.
Note: The codes given below should work with most of the phones, you can try each of them out. If it doesn't work than either your phone is incompatible or the system doesn't allow you to modify the file. Please enter the text as typed below without the quotes, with proper spacing.
Try the codes below and check which one works fine for you.
Code 1: "echo 0 > /sys/class/hw_power/charger/charge_data/enable_charger"
Code 2: "echo 1 > /sys/module/pm8921_charger/parameters/disabled"
Code 3: "echo 0 > /sys/class/power_supply/bq2589x_charger/enable_charging"
Code 4: "echo 1 > /sys/class/power_supply/battery/input_suspend"
Code 5: "echo 1 > /sys/class/power_supply/battery/store_mode"
Code 6: "echo 0 > /sys/devices/platform/battery/ChargerEnable"
Once you have obtained the code which disables charging, come back to Automateit app and select the shell command trigger, a page will show up with a check box, saying "Check to run commands as root", click in the Check box.
Below this, is a text box where you enter the command that disabled charging. Once done, click next and enter a rule name and hit save on the top right corner.
The disable charging rule is now active.
To enable charging you have to do the similar process as rule I with modified codes. Again try the below mentioned codes in Terminal Emulator app once you have been successful in disabling the charging, while the phone is connected to the wall charger.
If code 1 from rule I worked in disabling the charging then code 1 from rule II will enable the charging.
Code 1: "echo 1 > /sys/class/hw_power/charger/charge_data/enable_charger"
Code 2: "echo 0 > /sys/module/pm8921_charger/parameters/disabled"
Code 3: "echo 1 > /sys/class/power_supply/bq2589x_charger/enable_charging"
Code 4: "echo 0 > /sys/class/power_supply/battery/input_suspend"
Code 5: "echo 0 > /sys/class/power_supply/battery/store_mode"
Code 6: "echo 1 > /sys/devices/platform/battery/ChargerEnable"
Once you have the code, go to Automatieit app and type it in the box using the same battery level trigger, which is now set to activate when battery level falls below 25%.
Now you should have two different rules, with two different tasks.
Here all the hard work ends!!
Once you have successfully enabled the above two rules, you can use your phone as a tracker and not worry about the battery draining as it'll charge and discharge itself as and when required.
Now to make it fool proof we need to first make sure the power bank does it's task. So I made two more rules, with the same battery level trigger but with different actions, one which would send a text message when the battery level falls below 24% and other that would send a text message if the battery went above 91%.
Since we are dealing with lithium-ion batteries, I made another rule which will again send a text message every Saturday at a specified time to check the portable battery condition and the phone.
The app is self explanatory so I'll just add screenshots of the rules.
This is by far the easiest of the lot, as you just need to have data and location services enabled and the GPS set to high accuracy. The phone you wish to use should be logged into your google account. Also make sure to enable "Find my device" in device administrator.
Now just login into Google and type "Find my device" you will have a map displaying the current location of the phone. This also works with the app, given you have logged in with the same account you use on your primary phone. Below is a screenshot taken from my OP3 which shows two devices, since both of them are logged in from the same account.
The accuracy is somewhere between ~100-200m, although that completely depends on how fast the GPS locks and how well is the signal transmitted.
The tracking part ends here.