At work, we have an Android-based infotainment system that we're constantly deploying new versions to, on a half-dozen different test benches. The deployment script does the moral equivalent of:
for apk in ${apk_files}; do
adb install -r ${apk]
done
After this, we need to manually execute the following steps:
Set the home app to be one of our just-installed applications (Always, not Just Once)
Become a developer, and enable the Stay Awake option
Select the Google TTS engine for text-to-speech functionality rather than Pico
Executing these steps after each deploy is a giant PITA. People often forget one or more steps, and leave the test bench in a non-working state. This results in a bunch of 'bogus' bug reports that waste everbody's time.
Is there some way (using adb, perhaps) that we can automate these steps?
You can disable other home apps with adb shell pm disable .... I don't think there's a command line option to set apps as default. I remember looking into this before and there was a "preferred application" XML file where this was stored. If you want to look into it, the magic happens in PackageManagerService.addPreferredActivityInternal(). Looks like it writes the data to a file on disk: package-restrictions.xml. I suppose it's possible you could figure out the format thereof and write the file (you'd need root).
This is controlled by a system settings, "stay_on_while_plugged_in". You can set it using adb shell settings system put ....
The TTS engine is stored in a secure setting, "tts_default_synth". You can see the value like,
$ adb shell settings get secure tts_default_synth com.svox.pico
com.svox.pico
And you can set it with adb shell settings put secure "tts_default_synth" <the value>.
I noticed that if the value was not been previously set, when you get the value using the settings command you get null and it's not listed in settings list, even though there is a default value. As of Android 6 (I think), settings are no longer in a DB but rather are stored in XML files in /data/system/users/0/settings_*.xml. You can see the values therein.
Related
I am trying to set an automatic on/off timer for a device that is running Android 9 (For examples sake let's say I want it to turn on at 9 AM and turn off at 5PM) This must happen daily.
I want this to be done using adb commands so that it can be automated down the line.
If I go into settings I can navigate as so: Settings > Accessibility > Scheduled Power on and off
once in here I can set the Power off time, Power on time and the 2 relative Repeats
Any changes I make (physically or via adb) are then required to be confirmed by pressing the Save Settings button at the bottom of the screen.
Pressing the Save Settings button triggers the introduction of multiple variables:
close_machine_time_hour
close_machine_time_mins
open_machine_time_hour
open_machine_time_mins
power_off_cycle_mode
power_on_cycle_mode
power_off_date
power_on_date
power_way
machine_time_secs
Of which the 2 I am most concerned about are the last 2 as these seem like odd variables to only introduce when activating a niche setting (I feel as though they should either be there always)
Question 1: would be is this a standard Android feature? Or is this something that has been done for custom ROM?
I have tried setting all the settings as they appear in settings grabbed using command adb shell settings list system
They are set individually using the commands below:
adb shell settings put system timer_power_switch_settings 1
adb shell settings put system close_machine_time_hour 09
adb shell settings put system close_machine_time_mins 00
adb shell settings put system open_machine_time_hour 17
adb shell settings put system open_machine_time_mins 00
adb shell settings put system power_off_time 9:00:16
adb shell settings put system power_on_time 17:00:16
adb shell settings put system power_off_cycle_mode 0-1-2-3-4-5-6-
adb shell settings put system power_on_cycle_mode 0-1-2-3-4-5-6-
You'll note that in essence I am setting the time twice, which is quite odd.
The key thing is that none of this works unless I physically press the save button (despite showing visual feedback on the device screen that values change as I alter them via adb). Which is fine for 1 device but will become quite laborious if it needs to be done for 30+ devices at a time.
Question 2: Is there to simulate this Save Settings button click without simulating a tap on screen? Or to bypass this setting entirely?
Question 2.A: Is there a way to continuously monitor activity using an adb command? so I can run it, then click the button, and it will show me what's going on in the background?
I have 285 different networks between the different campus apartments for which I am trying to add network profile information to a series of Lenovo Tab4 10 TB-X304F so they may connect without having our Apartment Managers carry around a list of wifi passwords.
So far, I have created a custom wpa_supplicant.conf file with all of the network blocks for each of the networks across the campus. I have rooted the device. I have pushed this custom file to /sdcard/TWRP. I then copied the file from /sdcard/TWRP to /data/misc/wifi.
Now we run into my issue, it appears that this file is stored in at least 3 locations which I have currently found, /etc/wifi, /system/etc/wifi and /data/misc/wifi. The other part of the problem is that these files appear to be rewritten/overwritten on boot.
Which of these file locations should I be updating with my custom wpa_supplicant.conf file? How do I stop the file from being rebuilt on boot? Or, how do I make the process, which builds the file on boot, build it with the networks I want added?
Am I missing any other steps?
I have also tried running " wpa_supplicant -iwlan0 -c/sdcard/TWRP/wpa_supplicant.conf -B " as a command in the adb shell with super user permissions and didn't receive any output or confirmation. What am I misunderstanding about the wpa_supplicant command?
Just in case here are the settings currently in /data/misc/wifi/wpa_supplicant.conf which I have copied into my custom file:
ctrl_interface=/data/misc/wifi/sockets
disable_scan_offload=1
driver_param=use_p2p_group_interface=1
update_config=1
device_name=LenovoTB-X304F
manufacturer=LENOVO
model_name=Lenovo TB-X304F
model_number=Lenovo TB-X304F
serial_number=<SerialNumber>
device_type=10-0050F204-5
config_methods=physical_display virtual_push_button
p2p_disabled=1
pmf=1
external_sim=1
tdls_external_control=1
I do not really know much, but I can successfully edit/replace
/data/misc/wifi/wpa_supplicant.conf
provided that (1) I have the device in Aeroplane Mode and (2) I make sure that the file belongs to user "system" and group "wifi", and has permissions 660. If I forget (1) or (2), somehow the file reverts later to the one before editing/replacing or is reinitialized to virtually empty (I am not sure when either happened exactly, but I noticed both cases). I believe your use of TWRP is effectively equivalent to my use of Aeroplane Mode--but I am not aware that you can "chown" a file in TWRP. I never had to touch any of the other locations where the file can apparently be found.
For reference, the commands to get the right ownership and permissions should be
chmod 660 /data/misc/wifi/wpa_supplicant.conf
chown system:wifi /data/misc/wifi/wpa_supplicant.conf
Of course, all this needs one to be root.
I am trying to set the Settings.Global.PACKAGE_VERIFIER_ENABLE value in Android by using
Settings.Global.putInt(mContext.getContentResolver(),key,value);
However, what ever value I set , I was not getting the value when do following adb command.
adb shell settings get global package_verifier_enable
Thanks InAdvance
in the official android documentation is described that
Applications can read these but are not allowed to write; like the "Secure" settings, these are for preferences that the user must explicitly modify through the system UI or specialized APIs for those values.
This means that unless your app is running as system you're not allowed to write to those settings.
If you have the right signing certificate for the android operating system that you're using, you can sign your app to run with system privileges. As long as you're just running as a "normal" app there is no way to modify these settings.
You can however (which is bad practice) use su to set this setting via
su -c 'settings set global package_verifier_enable 0'
There are command line flags (or "switches") that Chromium (and Chrome) accept in order to enable particular features or modify otherwise default functionality.
Chromium Command Line Switches
Run Chromium with flags
Tried Chrome 41.0.xx and Chromium 43.0.xxx shell with:
# echo "chrome <flags>" > /data/local/tmp/android-webview-command-line
# echo "chrome <flags>" > /data/local/tmp/content-shell-command-line
Any idea how to run chrome with flags on Android or directly add these into default profile.
Want to add --sync-url flag to use my sync server instead of google sync servers. chrome://flags only enable/disable flags but wont let you add new flag.
New method added in Chrome 661 that works for a production build on unrooted devices.
Using adb, write the flags to /data/local/tmp/chrome-command-line.
For example:
~$ adb shell 'echo --unsafely-treat-insecure-origin-as-secure=http://a.test > /data/local/tmp/chrome-command-line'
In chrome://flags, turn on enable-command-line-on-non-rooted-devices.
Force stop Chrome (the relaunch now button will not trigger the reading of the flags file, even though the danger snackbar will disagree).
Verify in chrome://version that this worked.
https://www.chromium.org/developers/how-tos/run-chromium-with-flags#TOC-Android
What you're doing is correct, but seems like you're writing the switches to the wrong file for Chrome (and note that the file that you write the switches to may vary based on the OS version [or maybe phone?] ).
I tried this on two different phones, and had to write to two different files! Hopefully one of them will work for you:
Phone 1: Nexus 6 with Android 6.0.1
Simply do the following in adb shell:
echo "chrome --sync-url" > /data/local/tmp/chrome-command-line'
Phone 2: MotoG with Android 4.4.4
This is a bit trickier. It turned out that Chrome actually reads the switches from /data/local/chrome-command-line (not in the tmp subdirectory!). Now the issue is that on an unrooted phone you won't have permission to write to this file! So I had to root my phone* and use su to write to the file:
adb shell
su
echo "chrome --sync-url" > /data/local/chrome-command-line
*Rooting an Android phone is actually very easy and takes only a few minutes. There are a number of one click apps for rooting your phone (e.g. KingoRoot). For the case of MotoG, I had to do a few more steps to root, following this)
I needed insecure origin flag for testing of service workers on mobile device. However, for some reason these flags did not work on mobile chrome. Behaviour similar to insecure origin flag can be achieved by port forwarding.
You can find further info in my original answer here: https://stackoverflow.com/a/56146180/5048121
This does not apply exclusively on service workers, if you need https behavior on mobile device, you can combine it for example with allow-insecure-localhost flag or use self-signed certificate for localhost on server and get rid of cert errors on mobile chrome.
You need chromium debug build in order to use these switches.
I've created a sample project using BackupRestore. I went to register for a key at Android Backup Service. I got the following:
Your key is:
AEdPqrEAAAAIW4p30C1GTNjzBOqWrb0clI7_OCWxm3ddIgkKhw
This key is good for the app with the package name:
com.example.android.backuprestore
Provide this key in your AndroidManifest.xml file with the following element,
placed inside the <application> element:
<meta-data android:name="com.google.android.backup.api_key"
android:value="AEdPqrEAAAAIW4p30C1GTNjzBOqWrb0clI7_OCWxm3ddIgkKhw" />
When I launch the app and choose "Bacon" + "Tomato", I can see pending backups using dumpsys backup. So I force run it (bgmr run => pendings disappear) and uninstall the app.
When I restore it, logcat tells me "No restore data available" and of course, the settings aren't displayed with the correct info.
Any ideas what I could be doing wrong ?
When you uninstall the app the backup data got removed. Lookup logs for
BackupManagerService: Removing backed-up knowledge of <app package>
Seems that backup/restore process can vary from manufacturer and device. Testing Backup and Restore document can simple work by uninstalling and installing using a nexus device, but I would not expect the same behavior and consistency on every device.
See also this answer https://stackoverflow.com/a/13648673/1598308
Had the same error, only years later. It's probably because you are using Google Transport instead of LocalTransport. Google imposes a rate limit of 24 hours for every backup, so it's trying to create a backup, but it doesn't, and the restore fails.
Run adb shell bmgr list transports to see the transports.
Run adb shell bmgr transport android/com.android.internal.backup.LocalTransport to change the transport to Local.