Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
105.61k stars 10.25k forks source link

scrcpy --stay-awake #4778

Open ihuanx opened 3 months ago

ihuanx commented 3 months ago

Environment

Describe the bug A clear and concise description of what the bug is.

On errors, please provide the output of the console (and adb logcat if relevant).

Please paste terminal output in a code block.
[server] ERROR: Could not change "stay_on_while_plugged_in"
com.genymobile.scrcpy.SettingsException: Could not access settings: put global stay_on_while_plugged_in 7
        at com.genymobile.scrcpy.Settings.execSettingsPut(Settings.java:24)
        at com.genymobile.scrcpy.Settings.putValue(Settings.java:59)
        at com.genymobile.scrcpy.Settings.getAndPutValue(Settings.java:78)
        at com.genymobile.scrcpy.Server.initAndCleanUp(Server.java:75)
        at com.genymobile.scrcpy.Server.lambda$startInitThread$2(Server.java:206)
        at com.genymobile.scrcpy.Server$$ExternalSyntheticLambda0.run(Unknown Source:4)
        at java.lang.Thread.run(Thread.java:1012)
Caused by: java.io.IOException: Command [settings, put, global, stay_on_while_plugged_in, 7] returned with value 255
        at com.genymobile.scrcpy.Command.exec(Command.java:16)
        at com.genymobile.scrcpy.Settings.execSettingsPut(Settings.java:22)
        ... 6 more

Please do not post screenshots of your terminal, just post the content as text instead.

rom1v commented 3 months ago

What happens if you execute:

adb shell settings get global stay_on_while_plugged_in
adb shell settings put global stay_on_while_plugged_in 7
adb shell settings get global stay_on_while_plugged_in
adb shell settings put global stay_on_while_plugged_in 0
adb shell settings get global stay_on_while_plugged_in

and

adb shell settings list global

?

ihuanx commented 3 months ago

C:\Users\Administrator>adb shell settings get global stay_on_while_plugged_in
0

C:\Users\Administrator>adb shell settings put global stay_on_while_plugged_in 7

Exception occurred while executing 'put':
java.lang.SecurityException: Permission denial: writing to settings requires:android.permission.WRITE_SECURE_SETTINGS
        at com.android.providers.settings.SettingsProvider.enforceWritePermission(SettingsProvider.java:2562)
        at com.android.providers.settings.SettingsProvider.mutateGlobalSetting(SettingsProvider.java:1562)
        at com.android.providers.settings.SettingsProvider.insertGlobalSetting(SettingsProvider.java:1516)
        at com.android.providers.settings.SettingsProvider.call(SettingsProvider.java:495)
        at android.content.ContentProvider.call(ContentProvider.java:2548)
        at android.content.ContentProvider$Transport.call(ContentProvider.java:538)
        at com.android.providers.settings.SettingsService$MyShellCommand.putForUser(SettingsService.java:384)
        at com.android.providers.settings.SettingsService$MyShellCommand.onCommand(SettingsService.java:280)
        at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
        at android.os.ShellCommand.exec(ShellCommand.java:38)
        at com.android.providers.settings.SettingsService.onShellCommand(SettingsService.java:51)
        at android.os.Binder.shellCommand(Binder.java:1073)
        at android.os.Binder.onTransact(Binder.java:901)
        at android.os.Binder.execTransactInternal(Binder.java:1331)
        at android.os.Binder.execTransact(Binder.java:1268)

C:\Users\Administrator>adb shell settings get global stay_on_while_plugged_in
0

C:\Users\Administrator>adb shell settings put global stay_on_while_plugged_in 0

Exception occurred while executing 'put':
java.lang.SecurityException: Permission denial: writing to settings requires:android.permission.WRITE_SECURE_SETTINGS
        at com.android.providers.settings.SettingsProvider.enforceWritePermission(SettingsProvider.java:2562)
        at com.android.providers.settings.SettingsProvider.mutateGlobalSetting(SettingsProvider.java:1562)
        at com.android.providers.settings.SettingsProvider.insertGlobalSetting(SettingsProvider.java:1516)
        at com.android.providers.settings.SettingsProvider.call(SettingsProvider.java:495)
        at android.content.ContentProvider.call(ContentProvider.java:2548)
        at android.content.ContentProvider$Transport.call(ContentProvider.java:538)
        at com.android.providers.settings.SettingsService$MyShellCommand.putForUser(SettingsService.java:384)
        at com.android.providers.settings.SettingsService$MyShellCommand.onCommand(SettingsService.java:280)
        at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
        at android.os.ShellCommand.exec(ShellCommand.java:38)
        at com.android.providers.settings.SettingsService.onShellCommand(SettingsService.java:51)
        at android.os.Binder.shellCommand(Binder.java:1073)
        at android.os.Binder.onTransact(Binder.java:901)
        at android.os.Binder.execTransactInternal(Binder.java:1331)
        at android.os.Binder.execTransact(Binder.java:1268)

C:\Users\Administrator>adb shell settings get global stay_on_while_plugged_in
0

C:\Users\Administrator>adb shell settings list global
DarkMode_BackgroundMaxL=0.0
DarkMode_DialogBgMaxL=27.0
DarkMode_ForegroundMinL=100.0
FIVEG_VISIBLE_FROM_RUS46000=0
FIVEG_VISIBLE_FROM_RUS46001=0
FIVEG_VISIBLE_FROM_RUS46002=0
FIVEG_VISIBLE_FROM_RUS46003=0
FIVEG_VISIBLE_FROM_RUS46004=0
FIVEG_VISIBLE_FROM_RUS46007=0
FIVEG_VISIBLE_FROM_RUS46008=0
FIVEG_VISIBLE_FROM_RUS46009=0
FIVEG_VISIBLE_FROM_RUS46011=0
FIVEG_VISIBLE_FROM_RUS46015=0
LAST_CELL_TRAFFIC_TIME=1690825534735
LAST_CELL_TRAFFIC_USAGE=1930861979
Phenotype_boot_count=574
Phenotype_flags=activity_starts_logging_enabled:alarm_manager_constants:alarm_manager_dummy_flags:always_on_display_constants:anomaly_config:anomaly_config_version:anomaly_detection_constants:app_idle_constants:app_standby_enabled:backup_agent_timeout_parameters:battery_stats_constants:battery_tip_constants:binder_calls_stats:ble_scan_low_power_interval_ms:ble_scan_low_power_window_ms:blocking_helper_dismiss_to_view_ratio:blocking_helper_streak_limit:emergency_call_codes_data:gnss_satellite_blacklist:hybrid_sysui_battery_warning_flags:job_scheduler_constants:job_scheduler_quota_controller_constants:job_scheduler_time_controller_constants:location_background_throttle_interval_ms:location_ignore_settings_package_whitelist:network_watchlist_enabled:night_display_forced_auto_mode_available:notification_snooze_options:phenotype_test_setting:settings_use_external_provider_api:settings_use_psd_api:smart_replies_in_notifications_flags:sqlite_compatibility_wal_flags:sys_uidcpupower:text_classifier_constants:zram_enabled
RiskNrPaCfgPara=ver_num=1;cmcc_valid=0;cu_valid=0;ct_valid=0;nr_block=0;scg_add_speed=1024000;scg_fail_speed=1024000;dis_endc_timer=10
SaControlCfgPara=ver_num=5;nr_prio_ctrl=1;lte_pref_prohibit_t=900;sa_pref_prohibit_t0=120;sa_pref_prohibit_stage_num=5
_boot_Phenotype_flags=
a2dp_gamemode_value=0
activity_starts_logging_enabled=1
adb_enabled=1
adb_ocar=no
adb_wifi_enabled=1
add_users_when_locked=0
airplane_mode_on=0
airplane_mode_radios=cell,wifi,nfc,wimax
airplane_mode_toggleable_radios=bluetooth,wifi,nfc
alarm_manager_constants=
alarm_manager_dummy_flags=null
alt_bypass_wifi_requirement_time_millis=0
always_finish_activities=0
always_on_display_constants=null
ambient_enabled=1
ambient_force_when_docked=0
ambient_low_bit_enabled=0
ambient_low_bit_enabled_dev=0
ambient_plugged_timeout_min=-1
ambient_tilt_to_bright=0
ambient_tilt_to_wake=1
ambient_touch_to_wake=1
android_wear_system_edition=1
android_wear_version=2
animator_duration_scale=1.0
anomaly_config=
anomaly_config_version=11
anomaly_detection_constants=null
apn_version=489
app_idle_constants=
app_standby_enabled=1
apply_ramping_ringer=0
art_verifier_verify_debuggable=1
assisted_gps_enabled=1
audio_safe_volume_state=3
auto_add_number_prefix=1
auto_download_network_type=3
auto_time=1
auto_time_gps=0
auto_time_zone=1
auto_wifi=1
autofill_compat_mode_allowed_packages=com.android.chrome[url_bar]:com.brave.browser[url_bar]:com.brave.browser_beta[url_bar]:com.brave.browser_nightly[url_bar]:com.chrome.beta[url_bar]:com.chrome.dev[url_bar]:com.chrome.canary[url_bar]:com.microsoft.emmx[url_bar]:com.microsoft.emmx.beta[url_bar]:com.microsoft.emmx.canary[url_bar]:com.microsoft.emmx.dev[url_bar]:com.opera.browser[url_field]:com.opera.browser.beta[url_bar]:com.opera.mini.native[url_bar]:com.opera.mini.native.beta[url_bar]:com.sec.android.app.sbrowser[location_bar_edit_text]:com.sec.android.app.sbrowser.beta[location_bar_edit_text]:org.mozilla.fennec_aurora[url_bar]:org.mozilla.firefox[url_bar]:org.mozilla.firefox_beta[url_bar]
autofill_logging_level=0
average_time_to_discharge=-1
backup_agent_timeout_parameters=
battery_estimates_last_update_time=1710996355116
battery_health_enter_times_daily=0
battery_saver_constants=soundtrigger_disabled=false,aod_disabled=false
battery_stats_constants=track_cpu_times_by_proc_state=false
battery_tip_constants=app_restriction_enabled=true
binder_calls_stats=
ble_scan_low_power_interval_ms=10240
ble_scan_low_power_window_ms=512
blocking_helper_dismiss_to_view_ratio=null
blocking_helper_streak_limit=null
bluetooth_disabled_profiles=0
bluetooth_on=0
bluetooth_sanitized_exposure_notification_supported=1
boot_count=574
bug_report=0
bugreport_in_power_menu=0
burn_in_protection=0
button_set=0
cached_apps_freezer=device_default
call_auto_retry=0
can_update_at_night=0
captive_portal_mode=1
car_dock_sound=/product/media/audio/ui/Dock.ogg
car_undock_sound=/product/media/audio/ui/Undock.ogg
carrier_app_names=com.google.android.apps.tycho:Google Fi
carrier_app_whitelist=4C36AF4A5BDAD97C1F3D8B283416D244496C2AC5EAFE8226079EF6F676FD1859:com.google.android.apps.tycho
cdma_cell_broadcast_sms=1
cell_on=1
cert_pin_content_url=https://www.gstatic.com/android/config_update/08202014-pins.txt
cert_pin_metadata_url=https://www.gstatic.com/android/config_update/08202014-metadata.txt
charging_started_sound=/product/media/audio/ui/ChargingStarted.ogg
chinese_number_heads=13,15,17,18,16,19
clockwork_24hr_time=0
clockwork_auto_time=0
clockwork_auto_time_zone=0
clockwork_sysui_main_activity=
clockwork_sysui_package=
comm_phone_rus_status=0
content_capture_service_explicitly_enabled=default
corner_roundness=0
current_watchface_decomposable=0
customize_blacklistapp_intercept_criminal=1
customize_contacts_criminal_number=
customize_contacts_hide_card_recognize=0
customize_contacts_need_block=0
customize_mms_service_number_update_time=1589193600136
customize_soshelper_emergency_mode=0
customize_soshelper_longtime_unused_supported=1
daily_alert_new_method_updated=1
daily_alert_use_new_method=1
daily_alert_version=69905
data_network_notify_dialog_time_global=1643232614151
data_roaming1=1
data_space_monitor_curve_switch=1
database_creation_buildid=RP1A.200720.011
debug.force_rtl=0
debug_app=null
debug_gamemode_savegame=
debug_gamemode_value=0
debug_view_attributes=0
default_install_location=0
default_restrict_background_data=0
desk_dock_sound=/product/media/audio/ui/Dock.ogg
desk_undock_sound=/product/media/audio/ui/Undock.ogg
development_settings_enabled=1
device_case_enabled=1
device_name=OPPO A55 5G
device_provisioned=1
disable_gms_apps_settings=com.google.android.gms
disturb_for_game_space_mode=1
disturb_for_game_space_mode_flag=0
dock_audio_media_enabled=1
dock_sounds_enabled=0
dock_sounds_enabled_when_accessbility=0
emergency_call_codes_data=null
emergency_tone=0
enable_cellular_on_boot=1
enable_freeform_support=0
enable_gnss_raw_meas_full_tracking=0
enable_gpu_debug_layers=0
enable_non_resizable_multi_window=0
enable_sizecompat_freeform=0
enhanced_mac_randomization_force_enabled=0
filter_notification_track=1
first_time_clean_data=1
first_time_clean_data_on_T=1
force_allow_on_external=0
force_desktop_mode_on_external_displays=0
force_resizable_activities=0
game_dock_panel_state=0
getReadInterceptState=1
get_default_ring=/system_ext/media/audio/ringtones/ringtone_001.ogg
global.wifi.heytap.support=1
gms_checkin_timeout_min=6
gnss_satellite_blocklist=
gps_debug_switch=0
guardelf_battery_clear_usage_time=cleared
guardelf_battery_time=0=0=0=0=1693370186120
has_pay_tokens=0
heads_up_notifications_enabled=1
hide_carrier_network_settings=0
hide_game_icon_mode_flag=0
hotword_detection_enabled=0
hybrid_sysui_battery_warning_flags=
ims_switch=1
install_non_market_apps=0
isolated_storage_remote=null
job_scheduler_constants=
job_scheduler_quota_controller_constants=max_job_count_per_rate_limiting_window=10,rate_limiting_window_ms=60000,max_job_count_active=75,max_session_count_active=75
job_scheduler_time_controller_constants=
key_display_show_dialog_local_apps=
last_call_forward_action=-1
last_charge_duration_time=79676259
last_charge_scr_on_duration_time=13628758
last_charge_time=1711178700015
last_scr_on_time=1711178678257
lid_behavior=0
location_background_throttle_interval_ms=600000
location_background_throttle_package_whitelist=com.oplus.location
location_ignore_settings_package_whitelist=com.google.android.gms,com.google.android.dialer
lock_sound=/product/media/audio/ui/Lock.ogg
low_battery_sound=/product/media/audio/ui/LowBattery.ogg
low_battery_sound_timeout=0
low_power=1
low_power_sticky=1
max_sound_trigger_detection_service_ops_per_day=1000
mobile_data0=1
mobile_data1=0
mobile_data2=1
mobile_data=0
mobile_data_always_on=1
mobile_signal_detector=1
mode_ringer=0
msim_mode_setting=3
multi_cb=0
multi_sim_data_call=-1
multi_sim_defaut_data_call=1
multi_sim_sms=-1
multi_sim_sms_prompt=1
multi_sim_voice_call=-1
multi_sim_voice_prompt=0
netstats_enabled=1
network_recommendations_enabled=0
network_recommendations_package=com.google.android.gms
network_scoring_ui_enabled=1
network_watchlist_enabled=
network_watchlist_last_report_time=1711123200000
nfc_boot_complete=0
night_display_forced_auto_mode_available=0
notification_bool_flag=1
notification_snooze_options=null
ntp_server_2=persist.vendor.ntp.svr_2
obtain_mute_when_off_body=1
obtain_paired_device_location=0
oplus.diff_time=1693373713699
oplus_comm_incallui_side_notification_incomming_type=3
oplus_comm_soshelper_license=0
oplus_comm_telecom_count_for_mark_info_call_log=20210729:1
oplus_comm_telecom_count_for_stranger_call_log=20210924:2
oplus_comm_trafficmonitor_gms_network_control=1
oplus_comm_wifi_auto_change_network_level=0
oplus_customize_apk_prescan_switch=0
oplus_customize_comm_incallui_side_notification_incomming_type=3
oplus_customize_comm_phone_intercept_notify=0
oplus_customize_comm_phone_show_ussd_dialog=0
oplus_customize_harass_intercept_mark_number_advertising=0
oplus_customize_harass_intercept_mark_number_enbale=3
oplus_customize_harass_intercept_mark_number_fraud=3
oplus_customize_harass_intercept_mark_number_harassment=0
oplus_customize_harass_intercept_mark_number_intermediary=0
oplus_customize_multi_sim_auto_call_back=0
oplus_customize_multi_sim_network_primary_slot=0
oplus_customize_system_stable_plan_switch=0
oplus_customize_user_preferred_network_mode1=-1
oplus_customize_volte_change=1
oplus_customize_wifi_smart_connect=1
oppo.comm.network.monitor.available=1
oppo.comm.network.monitor.portal=0
oppo.diff_time=1693368227471
oppo.oroaming.nettime=1693368348227;120755
oppo_comm_phone_intercept_settings_opti_version=3
oppo_comm_phone_show_ussd_dialog=0
oppo_commcenter_wifi_detect_result=
oppo_multi_sim_user_config_subid=1,0
ota_disable_automatic_update=1
ota_storage_bad_block_count=0
ota_upgraded_once=1
overlay_display_devices=null
paired_device_os_type=0
phenotype_test_setting=V15AboveDefault
phone_play_store_availability=0
power_save_disable_five_g_state=1
power_save_five_g_request=2
power_sounds_enabled=1
preferred_network_mode1=20
preferred_network_mode=33
private_dns_default_mode=off
reboot_for_cos=0
recommend_update_config_day=0
record_volte_call_status1=-1
require_password_to_decrypt=0
retail_mode=0
safe_readapps_list=com.coloros.phonemanager,com.android.settings,com.heytap.market,com.quark.browser,com.shizhuang.duapp,cn.mama.pregnant,com.guotai.dazhihui,com.wisedu.cpdaily,com.yoosee,com.app.shanghai.metro,com.ishowedu.peiyin,com.rockets.chang,com.duitang.main,com.xingluo.molitt,com.ss.android.tuchong,co.runner.app,com.happyelements.AndroidClover.nearme.gamecenter,com.tencent.start,com.xingluo.mlpp,com.secoo,com.kys.mobimarketsim,com.flyingeffects.com,com.yibasan.lizhifm,com.lechuan.mdwz,com.kmxs.reader,com.youxiang.soyoungapp,com.vvvdj.player,com.toolsplatform.videoeditplatform,com.duowan.kiwi
send_action_app_error=1
set_install_location=0
settings_use_external_provider_api=1
settings_use_psd_api=1
setup_skipped=0
show_gamespace_edge_panel=1
show_notification_channel_warnings=0
side_button=1
simsettings_manual_select_1=
simsettings_manual_select_2=
sla_app_com.tencent.tmgp.pubgmhd=0
sla_app_com.tencent.tmgp.sgame=0
sla_game_0=0,0,0,0,0,0,0
sla_game_1=1,0,0,0,0,0,0
sla_game_2=2,0,0,0,0,0,0
smart_illuminate_enabled=1
smart_replies_enabled=0
smart_replies_in_notifications_flags=enabled=true,max_squeeze_remeasure_attempts=3,requires_targeting_p=true
sms_short_codes_content_url=https://www.gstatic.com/android/config_update/03082024-sms-denylist.txt
sms_short_codes_metadata_url=https://www.gstatic.com/android/config_update/03082024-sms-denylist-metadata.txt
soft_ap_timeout_enabled=1
soft_ap_wifi6_support=false
sos_low_battery_notification_level=15
sound_trigger_detection_service_op_timeout=15000
sqlite_compatibility_wal_flags=
stay_on_while_plugged_in=0
subscription_mode=0
switch_key_network=1
sync_mms_lower_bound=1624789056000
sys_uidcpupower=
system_capabilities=99
systemui_debug=0
sysui_demo_allowed=null
telephony_misc_feature_config=3
tether_offload_disabled=1
theater_mode_on=0
time_remaining_estimate_based_on_usage=0
time_remaining_estimate_millis=-1
transition_animation_scale=1.0
trusted_sound=/product/media/audio/ui/Trusted.ogg
tzupdate_whitelist=0
ucar_casting_state=0
unlock_sound=/product/media/audio/ui/Unlock.ogg
updatable_driver_production_allowlist=
updatable_driver_production_denylist=
upload_period_test_count=621
usb_mass_storage_enabled=1
user_click_wlan_assistant_switch=0
user_disabled_hdr_formats=
user_hfp_client_setting=0
user_switcher_enabled=0
vab_update_user_type=0
verifier_timeout=17000
verifier_verify_adb_installs=0
volte_call_status1=1
volte_subscription0=1
volte_vt_enabled1=1
volte_vt_enabled=-1
wait_for_debugger=0
wear_companion_os_version=-1
wear_os_version_string=
wear_platform_mr_number=0
webview_fallback_logic_enabled=0
wifi_ap_state=0
wifi_auto_change_access_point=0
wifi_auto_change_network=0
wifi_country_code=CN
wifi_display_certification_on=0
wifi_display_max_resolution=0
wifi_display_on=0
wifi_display_portrait_resolution=0
wifi_display_power_saving_delay=10
wifi_display_power_saving_option=1
wifi_max_dhcp_retry_count=9
wifi_migration_completed=1
wifi_networks_available_notification_on=0
wifi_on=1
wifi_passpoint_enabled_state=0
wifi_power_save=120
wifi_reset_password=1
wifi_scan_always_enabled=0
wifi_scan_interval_p2p_connected_ms=180000
wifi_sleep_policy=2
window_animation_scale=1.0
wireless.secondary.portal.app.launched=0
wireless.wifi.monitor.setting=0
wireless.wifi.portal.app.launched=0
wireless_charging_started_sound=/product/media/audio/ui/WirelessChargingStarted.ogg
wlan_band_label_switch_on=1
zen_mode=0
zen_mode_config_etag=1669448546
zen_mode_ringer_level=0
zram_enabled=1
rom1v commented 3 months ago

See https://github.com/Genymobile/gnirehtet/issues/5#issuecomment-1280404975

benny856694 commented 4 weeks ago

See Genymobile/gnirehtet#5 (comment)

I just want to add this: after you changed the setting, you need to reboot your phone so that the setting can eventually take effect.