Note:
Following solution:
- is tested on Android 4.2.1, COS12 (Android 5.0.2) and CM12.1 (Android 5.1.1) - all of them running Play Store v6.0.51
- requires a rooted Android
- here is a short demo of the solution
While browsing the manifest of Play Store, I took an educated guess that only the following service is likely the initiator of auto-update of apps over Wi-Fi.
com.google.android.finsky.autoupdate.ReschedulerUsingAlarmManager$CheckWifiAndAutoUpdate
I played with that service under few conditions on different devices and found it useful for the goal in question. It goes without saying that the auto-update setting of apps should be set to "Auto-update apps over Wi-Fi only" in Play Store.
Here is what you can do: Install an automation app which can execute series of actions when power source and Wi-Fi are connected and later on, disconnected. I used Tasker (trial version; userguide) as the automation app.
We would be needing two tasks: an entry task and an exit task. See my answer here for related help.
What does those tasks do?
When the conditions for both the contexts are met, the enter task is run. The commands in that task does these things in sequential order:
- enable the aforesaid Play Store's service
- force-stop Play Store
- start the said Play Store's service
And that's all for the auto-update to begin.
After remaining activated, whenever the profile deactivates (simply because a condition for a context doesn't meet anymore) the exit task would run. That exit task executes following steps in sequential order:
- store the state (enabled/disabled) of mobile data in a variable Mdata
the job of those commands is to:
- disable mobile data
- disable Wi-Fi
- force-stop Play Store
- force-stop Download Manager
I noticed that if an update (download in progress) for an app is interrupted due to unavailability of Wi-Fi, the progress bar (notification) is dismissed, the status of the progress gets stored in a row in the table downloads of database downloads.db. (That database is located under the data directory of Download Manager.) That row also contains the location of the partially downloaded file.
In order to make sure that auto-update doesn't occur on the next successful connection to Wi-Fi and making sure that it never does so when the profile is not running the enter task, following is what rest of the commands do:
- extract the location of the partially downloaded file from the value in the column
_data
corresponding to a row identified by com.android.vending as notificationpackage. We aim to delete that file. This is a small sacrifice to make.
- if there is indeed a file path under _data, then use it to delete the file pointed by it.
- delete that row, otherwise, it will be read by Download Manager when network connectivity changes (reconnected to a Wi-Fi) and auto-update would begin again.
- disable the aforesaid Play Store service so that auto-update never begins on it own
- enable Wi-Fi
- enable mobile data, if it were enabled prior to running this task.
1At the time of creating the first revision of this answer the current Play Store version is definitely not 6.0.5 but above. However, none of my devices have received any further Play Store update so far.