adb - Script to add PIN but not secure start-up - android

I'm trying to write a shellscript to create android emulators programatically (OS version >= 7.1.1), and I want those emulators to have a PIN but not "secure start-up".
Note that "secure start-up" is not the "lock screen" and also not the screen to unlock an encrypted device.
The secure start prevents android from booting without first inserting the PIN; lock screen is what appears after the boot up has finished.
Here's the description that shows up on Android 8.1 when you set the PIN manually on the emulator:
And what shows up when the emulator starts with the secure start-up activated:
I only managed to insert the PIN using the command:
adb -s <emulator_name> shell locksettings set-pin 1111
but this also activates the secure-start and I didn't find a way to deactivate it.
Do you know a command to deactivate only the secure-start and not the PIN? Thanks!

Related

How to set On/Off Timers on Android 9 using ADB?

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?

Android SMS limit on Android 4.0.4

I am working with phone with Android 4.0.4 (I know, the old one)
Now I need to override limit of 100 sms send per hour (Below android 4.1 there should be limit 100 sms per hour. Since android 4.1 there is limit 30 sms per 30 minutes).
Since Android 4.2 it is possible via adb shell settings put global sms_outgoing_check_max_count.
But I have no idea how to do it on Android 4.0.4 without rooting because there is no "adb shell settings" command. Any idea?
P.S. I am not creating app. I need to override this limit ideally in android settings via adb or by using another app for this (if it exists)
You could do it by creating the application and overriding the SmsUsageMonitor:
com.android.internal.telephony.SmsUsageMonitor
It should basically work on any phone, without rooting it first.
Could you try to follow theses steps via ADB :
1.Open Command Terminal
2.Type in adb shell hit enter
3.Type in su hit enter
4.Type in sqlite3 /data/data/com.android.providers.settings/databases/settings.db hit enter
5.Type in INSERT INTO secure (name, value) VALUES('sms_outgoing_check_max_count’, 9999); hit enter
6.Type in INSERT INTO system (name, value) VALUES('sms_outgoing_check_max_count’, 9999); hit enter
7.Type in .exit hit enter (you should now see a hash tag again instead of sqlite>. If not conitune typing in .exit and hitting enter until you are)
8.Type in sqlite3 /data/data/com.google.android.gsf/databases/gservices.db
9.Type in INSERT INTO main (name, value) VALUES('sms_outgoing_check_max_count’, 9999); hit enter
10.Again exit back to where the command line has a hashtag
11.Type in reboot and hit enter.
I don't have a phone with Android 4.0.4, so i can't confirm that it will work
Happy testing !
you have to use abd command to open that restrictions here is the link for tutorial change sms limit
1.Go to the android platform tool directory
`(C:\Users\username\AppData\Local\Android\Sdk\platform-tools)``enter code here`
open command shell by using Shift+mouserightclick and enter this command
adb shell settings put global sms_outgoing_check_max_count 5
settings put global sms_outgoing_check_interval_ms 9000000
I am actually reducing the number so Android warns me if I have sent more than 5 SMS messages within 30(9000000) minutes. Change “5” to whatever number you want
What exactly do you want to acheive with over 100 SMS per hour?
I am sure there is a way more efficient way of sending your data for example through
a wireless network or mobile data. You would hardly manage to reach the data limits of
those networks.
Just saying ... try only to do it over SMS if there really is NO other way of sending it.
Good luck!

Appium : How to launch app from Android For Work work profile

I need to launch an app which is in different work profile (Android For Work). If install the app in personal profile then I am able to launch the app from the personal profile on the same device.
However, When I install the app only in the work profile then I am not able to launch the app through adb command.
As per my understanding, google keeps two different containers for personal and work profile. I think the work profile has different space and adb does not have any access to that app and workspace of work profile.
I need to launch the app through appium
If anyone has the answer to the above problem, please answer. Thanks in Advance !
Do you mean launching application on different user account ? check this link please : https://stackoverflow.com/a/24093533/5093606
You can get try to get list of accounts using
adb shell pm list users
and if you working account is there, try
adb shell am start --user WORKING_ACCOUNT com.example.MainActivity
Yes, there is way to launch the apps by using Appium/Adb commands. Instead of appium use adb commands to launch the apps.
The app which you have used for AndroidForWork enrollment, it should be in android:debuggable mode. Set debuggable mode to true and build the apk.
Once the device is enrolled/Configured Androidfor work then get the list of users.
adb shell pm list users UserInfo{0:Drew:13} running UserInfo{10:Work profile:30} running
Get the workprofile user id. In this case 10 is the id. Use the user id to launch the apps.
adb shell am start --user 10 -n "com.android.vending/com.google.android.finsky.activities.MainActivity"
Note: If the provision app is not enabled in Debug mode then you don't have the access to the work profile user.
Turns out I was able to accomplish this with Appium Desktop by adding another parameter to the inspector:
optionalIntentArguments text --user 12
Where '12' is the work profile id you'd see from typing this:
adb -d shell pm list users
Users:
UserInfo{0:Ken Corey:13} running
UserInfo{12:Workspace:50100030} running

Cannot record screen on Android 4.4.2

I am trying to record my device screen using the shell command as outlined here:
http://developer.android.com/tools/help/adb.html#screenrecord
Using the verbose flag, I am getting a Permission Denial that I think is connected to the fact there is an Owner profile on the device, as it references User 0 and User 1 in the error message.
Does anyone know how I can remove the Owner profile (can't see any options to do so) or how I can set the Owner to user 0?
EDIT - clarification, the error states "broadcast asks to run as user -1 but is calling from user 0"
I got the recording to work.
It seems that for whatever reason, you need to do this via adb shell.
Whilst adb shell is running shell commands on the connected device, running the screenrecord commands directly on the device just doesn't want to work.

Wake and unlock Android phone screen when compile and run project?

When build and run iOS app using Xcode, the phone becomes awake and app runs. Is there a way to wake and unlock Android phone (or tablet) screen then run installed Android app (Eclipse, Android Studio)?
One solution: set the following flags in your activity class(es):
if (BuildConfig.DEBUG) {
// These flags cause the device screen to turn on (and bypass screen guard if possible) when launching.
// This makes it easy for developers to test the app launch without needing to turn on the device
// each time and without needing to enable the "Stay awake" option.
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
}
These flags will:
Turn on the screen
Bypass the lock-screen
Allow showing the activity even if the device is locked
By setting those flags in your base activity, you'll be able to continue using your application even if the device was off and/or locked at the time of running. If you try to leave your application's process (i.e., hitting the home button, or switching to another app), the lock screen will appear, and you'll have to manually unlock to continue using the device.
Warning: this should only be used while developing/debugging your application, so I recommend keeping the if (BuildConfig.DEBUG) check, as it is in this example
Better and easiest solution is use the option (in development section) that the screen never goes off I thing the name is "Stay awake". This option prevent your phone to get locked when the usb cable is connected.
Another way is to write a script which runs before the app deploys and unlocks the device. This requires no app code change and will not change screen timeout which can have security implications.
You can find the full setup here
#!/bin/bash
# When a device is attached there will be atleast 3 lines -> heading, device details, an empty new line
if adb devices | wc -l | grep "3"; then
# Check if device locked, this may differ on some OEMs
if adb shell dumpsys window | grep "mInputRestricted=true"; then
echo "Device is Locked"
adb shell input keyevent KEYCODE_WAKEUP # wakeup device
adb shell input touchscreen swipe 530 1420 530 1120 # swipe up gesture
adb shell input text "000000" # <- Change to the your device PIN/Password
#adb shell input keyevent 66 # simulate press enter, if your keyguard requires it
else
echo "Device already unLocked"
fi
# 2 = Stay awake on USB, 0 = reset
adb shell settings put global stay_on_while_plugged_in 2
#adb shell settings put system screen_brightness 700
adb shell input keyevent KEYCODE_WAKEUP
adb shell input touchscreen tap 0 0 # this will wake up the screen and won't have any unwanted touches
else
echo "There should be only one device connected at a time"
fi
return 0
You cant unlock and wake the phone as that would not be very secure, however you can enable "Stay awake" in developer options.

Categories

Resources