How to deactivate wifi and bluetooth in sleep mode?

Well, it’s not feasible to use this crude method. We have to use other methods. Where do you need to go into deep sleep? If it is a screen saver, do you need to enter deep sleep?

The deepsleep needs when I short press Power button only or XPWR Pads (like on VIMs).
After short press EDGE ignores an active Bluetooth connection, playing music, and a network connection, it go to deepsleep fast (1-2seconds) and power off USB ports.
This mechanism is realize on VIMs boards with this change. Need to realize it on EDGE too.

I have some comment about VIMs board. I use this change on all VIMs boards. And USB port is short enable (0.1sec) and disable again periodically. But it works fine.

Remove all the previous changes, and Make the following changes:

hlm@Server:/users/hlm/10_Edge_backup/kernel$ git diff
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 6bcb47d3..415dd7a1
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -594,11 +594,16 @@ static suspend_state_t decode_state(const char *buf, size_t n)
        return PM_SUSPEND_ON;
 }
 
+extern void release_whole_wake_lock(void);
 static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr,
                           const char *buf, size_t n)
 {
        suspend_state_t state;
        int error;
+       if(strncmp(buf, "all_wake_unlock", 15) == 0){
+               release_whole_wake_lock();
+               return 1;
+       }
 
        error = pm_autosleep_lock();
        if (error)
diff --git a/kernel/power/wakelock.c b/kernel/power/wakelock.c
index 105df4d..7b16763
--- a/kernel/power/wakelock.c
+++ b/kernel/power/wakelock.c
@@ -286,3 +286,18 @@ int pm_wake_unlock(const char *buf)
        mutex_unlock(&wakelocks_lock);
        return ret;
 }
+
+void release_whole_wake_lock(void)
+{
+       struct rb_node *node;
+       struct wakelock *wl;
+       
+       for (node = rb_first(&wakelocks_tree); node; node = rb_next(node)) {
+               wl = rb_entry(node, struct wakelock, node);
+               if (wl->ws->active == true){
+                       //printk("hlm wake lock =%s \n", wl->name);
+                       pm_wake_unlock(wl->name);
+               }
+       }
+
+}

hlm@Server:/users/hlm/10_Edge_backup/frameworks/base$ git diff
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java
index 6e71f912..c6164b6
--- a/core/java/android/os/PowerManager.java
+++ b/core/java/android/os/PowerManager.java
@@ -37,6 +37,13 @@ import com.android.internal.util.Preconditions;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.util.concurrent.Executor;
+import java.io.IOException;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.FileWriter;
 
 /**
  * This class gives you control of the power state of the device.
@@ -1070,6 +1077,14 @@ public final class PowerManager {
      */
     @UnsupportedAppUsage
     public void goToSleep(long time, int reason, int flags) {
+       try{
+                       FileWriter fw = new FileWriter("/sys/power/state");
+                       fw.write("all_wake_unlock");
+                       fw.close();
+               } catch (IOException e){
+                       Log.e(TAG, e.toString());
+               }
+               
         try {
             mService.goToSleep(time, reason, flags);
1 Like

I apply this changes and rebuilt kernel and android “make -jN”.
Sometime EDGE go to deepsleep fast (3-5 sec) and disable USB power, but sometime EDGE go to deepsleep not fast (20 sec) and does not disable USB power. When EDGE does not disable USB, I can touch USB mouse and it wakes up EDGE board without press power button and after that I try to press power button, but EDGE can not go to deepsleep.

No way. Did you plug in a USB connection to the computer for verification?

No, I plug in a AC-DC power supply.

Then you post the corresponding log。。。。。。。。

This is kernel log:

The first enter - fast enter to deepsleep with USB disable:
[   36.455696] OOM killer disabled.
[   36.455758] Freezing remaining freezable tasks ... (elapsed 0.002 seconds) done.
[   36.458636] Suspending console(s) (use no_console_suspend to debug)
INFO:    sleep mode config[0xde]:
INFO:           AP_PWROFF
INFO:           SLP_ARMPD
INFO:           SLP_PLLPD
INFO:           DDR_RET
INFO:           SLP_CENTER_PD
INFO:    wakeup source config[0x804]:
INFO:           GPIO interrupt can wakeup system
INFO:           PWM interrupt can wakeup system
INFO:    PWM CONFIG[0x4]:
INFO:           PWM: PWM2D_REGULATOR_EN
INFO:    APIOS info[0x0]:
INFO:           not config
INFO:    GPIO POWER INFO:
INFO:           GPIO0_B5
INFO:           GPIO1_B5
INFO:    PMU_MODE_CONG: 0x1466bf51
The second enter - not fast (5-7sec) with usb disable
[   88.419214] init: Received control message 'interface_start' for 'android.hardware.radio@1.1::IRadio/slot1' from pid: 153 (/system/bin/hwservicemanager)
[   88.419305] init: Could not find 'android.hardware.radio@1.1::IRadio/slot1' for ctl.interface_start
[   88.420692] init: Received control message 'interface_start' for 'android.hardware.radio@1.1::IRadio/slot1' from pid: 153 (/system/bin/hwservicemanager)
[   88.420774] init: Could not find 'android.hardware.radio@1.1::IRadio/slot1' for ctl.interface_start
[   88.588226] type=1400 audit(1597931063.090:123): avc: denied { ioctl } for comm="allocator@2.0-s" path="/dev/binder" dev="tmpfs" ino=19647 ioctlcmd=0x6201 scontext=u:r:hal_graphics_allocator_default:s0 tcontext=u:object_r:binder_device:s0 tclass=chr_file permissive=1
[   88.588300] type=1400 audit(1597931063.603:124): avc: denied { getattr } for comm="ndroid.settings" path="/sys/devices/platform/pwm-fan/hwmon/hwmon1/enable" dev="sysfs" ino=22266 scontext=u:r:system_app:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=1
[   88.967264] PM: suspend entry (deep)
[   88.967302] PM: Syncing filesystems ... done.
[   88.986320] Freezing user space processes ...
[   89.509914] cec-dw_hdmi: message 88 timed out
[   91.167208] Freezing of tasks aborted after 2.180 seconds
[   91.167363] OOM killer enabled.
[   91.167463] Restarting tasks ... done.
[   91.173790] PM: suspend exit
[   91.176108] init: Received control message 'interface_start' for 'android.hardware.radio@1.1::IRadio/slot1' from pid: 153 (/system/bin/hwservicemanager)
[   91.176236] init: Could not find 'android.hardware.radio@1.1::IRadio/slot1' for ctl.interface_start
[   91.621672] cec-dw_hdmi: message bb timed out
[   92.176673] init: Received control message 'interface_start' for 'android.hardware.radio@1.1::IRadio/slot1' from pid: 153 (/system/bin/hwservicemanager)
[   92.176807] init: Could not find 'android.hardware.radio@1.1::IRadio/slot1' for ctl.interface_start
[   93.178637] init: Received control message 'interface_start' for 'android.hardware.radio@1.1::IRadio/slot1' from pid: 153 (/system/bin/hwservicemanager)
[   93.178764] init: Could not find 'android.hardware.radio@1.1::IRadio/slot1' for ctl.interface_start
[   93.733676] cec-dw_hdmi: message bb timed out
[   93.822238] PM: suspend entry (deep)
[   93.822256] PM: Syncing filesystems ... done.
[   93.827235] Freezing user space processes ... (elapsed 0.003 seconds) done.
[   93.830724] OOM killer disabled.
[   93.830729] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done.
[   93.832464] Suspending console(s) (use no_console_suspend to debug)
INFO:    sleep mode config[0xde]:
INFO:           AP_PWROFF
INFO:           SLP_ARMPD
INFO:           SLP_PLLPD
INFO:           DDR_RET
INFO:           SLP_CENTER_PD
INFO:    wakeup source config[0x804]:
INFO:           GPIO interrupt can wakeup system
INFO:           PWM interrupt can wakeup system
INFO:    PWM CONFIG[0x4]:
INFO:           PWM: PWM2D_REGULATOR_EN
INFO:    APIOS info[0x0]:
INFO:           not config
INFO:    GPIO POWER INFO:
INFO:           GPIO0_B5
INFO:           GPIO1_B5
INFO:    PMU_MODE_CONG: 0x1466bf51
The third - press mouse button after press power button - not enter to deepsleep
[  102.873574] PM: Syncing filesystems ... done.
[  102.926216] Freezing user space processes ...
[  102.927087] Freezing of tasks aborted after 0.000 seconds
[  102.927095] OOM killer enabled.
[  102.927100] Restarting tasks ... done.
[  102.957154] PM: suspend exit
[  103.271654] init: Received control message 'interface_start' for 'android.hardware.radio@1.1::IRadio/slot1' from pid: 153 (/system/bin/hwservicemanager)
[  103.271890] init: Could not find 'android.hardware.radio@1.1::IRadio/slot1' for ctl.interface_start
[  103.827789] sensors 7-0068: set sensor poll time to 66ms
[  103.903511] sensors 7-0068: sensor on: starting poll sensor data 62ms
[  103.922887] rockchip-vop ff8f0000.vop: [drm:vop_crtc_atomic_enable] Update mode to 1088x1920p47, type: 16
[  103.923064] rockchip-vop ff900000.vop: [drm:vop_crtc_atomic_enable] Update mode to 1920x1080p60, type: 11
[  103.952598] dw-mipi-dsi ff960000.dsi: [drm:dw_mipi_dsi_encoder_enable] final DSI-Link bandwidth: 996 x 4 Mbps
[  104.268710] init: Received control message 'interface_start' for 'android.hardware.radio@1.1::IRadio/slot1' from pid: 153 (/system/bin/hwservicemanager)
[  104.268761] init: Could not find 'android.hardware.radio@1.1::IRadio/slot1' for ctl.interface_start
[  104.293394] cec-dw_hdmi: message 88 timed out
[  104.740489] rockchip-vop ff8f0000.vop: [drm:vop_crtc_atomic_enable] Update mode to 1088x1920p47, type: 16
[  104.740810] dw-mipi-dsi ff960000.dsi: [drm:dw_mipi_dsi_encoder_enable] final DSI-Link bandwidth: 996 x 4 Mbps
[  105.269871] init: Received control message 'interface_start' for 'android.hardware.radio@1.1::IRadio/slot1' from pid: 153 (/system/bin/hwservicemanager)
[  105.269960] init: Could not find 'android.hardware.radio@1.1::IRadio/slot1' for ctl.interface_start
[  106.272632] init: Received control message 'interface_start' for 'android.hardware.radio@1.1::IRadio/slot1' from pid: 153 (/system/bin/hwservicemanager)
[  106.272812] init: Could not find 'android.hardware.radio@1.1::IRadio/slot1' for ctl.interface_start
[  106.405619] cec-dw_hdmi: message 88 timed out
[  107.273555] init: Received control message 'interface_start' for 'android.hardware.radio@1.1::IRadio/slot1' from pid: 153 (/system/bin/hwservicemanager)
[  107.273648] init: Could not find 'android.hardware.radio@1.1::IRadio/slot1' for ctl.interface_start
[  108.275826] init: Received control message 'interface_start' for 'android.hardware.radio@1.1::IRadio/slot1' from pid: 153 (/system/bin/hwservicemanager)
[  108.276002] init: Could not find 'android.hardware.radio@1.1::IRadio/slot1' for ctl.interface_start
[  108.517704] cec-dw_hdmi: message bb timed out
[  109.277023] init: Received control message 'interface_start' for 'android.hardware.radio@1.1::IRadio/slot1' from pid: 153 (/system/bin/hwservicemanager)
[  109.277120] init: Could not find 'android.hardware.radio@1.1::IRadio/slot1' for ctl.interface_start
The fourth - fast enter to deepsleep with USB disable:
[  216.596050] PM: Syncing filesystems ... done.
[  216.598420] Freezing user space processes ... (elapsed 0.005 seconds) done.
[  216.603556] OOM killer disabled.
[  216.603576] Freezing remaining freezable tasks ... (elapsed 0.003 seconds) done.
[  216.607164] Suspending console(s) (use no_console_suspend to debug)
INFO:    sleep mode config[0xde]:
INFO:           AP_PWROFF
INFO:           SLP_ARMPD
INFO:           SLP_PLLPD
INFO:           DDR_RET
INFO:           SLP_CENTER_PD
INFO:    wakeup source config[0x804]:
INFO:           GPIO interrupt can wakeup system
INFO:           PWM interrupt can wakeup system
INFO:    PWM CONFIG[0x4]:
INFO:           PWM: PWM2D_REGULATOR_EN
INFO:    APIOS info[0x0]:
INFO:           not config
INFO:    GPIO POWER INFO:
INFO:           GPIO0_B5
INFO:           GPIO1_B5
INFO:    PMU_MODE_CONG: 0x1466bf51
No sleep 20-30 sec
[  235.907613] init: Could not find 'android.hardware.radio@1.1::IRadio/slot1' for ctl.interface_start
[  236.522746] PM: suspend entry (deep)
[  236.522820] PM: Syncing filesystems ... done.
[  236.529240] Freezing user space processes ...
[  236.837857] cec-dw_hdmi: message 44 timed out
[  238.949602] cec-dw_hdmi: message 44 timed out
[  241.061600] cec-dw_hdmi: message 88 timed out
[  241.637543] Freezing of tasks aborted after 5.108 seconds
[  241.637700] OOM killer enabled.
[  241.637767] Restarting tasks ...
[  241.648020] init: Received control message 'interface_start' for 'android.hardware.radio@1.1::IRadio/slot1' from pid: 153 (/system/bin/hwservicemanager)
[  241.648323] init: Could not find 'android.hardware.radio@1.1::IRadio/slot1' for ctl.interface_start
[  241.653240] done.
[  241.653523] PM: suspend exit
[  241.855029] PM: suspend entry (deep)
[  241.855115] PM: Syncing filesystems ... done.
[  241.858286] Freezing user space processes ...
[  243.173325] cec-dw_hdmi: message 88 timed out
[  245.022015] Freezing of tasks aborted after 3.163 seconds
[  245.022099] OOM killer enabled.
[  245.022115] Restarting tasks ... done.
[  245.025870] PM: suspend exit
[  245.032312] init: Received control message 'interface_start' for 'android.hardware.radio@1.1::IRadio/slot1' from pid: 153 (/system/bin/hwservicemanager)
[  245.032497] init: Could not find 'android.hardware.radio@1.1::IRadio/slot1' for ctl.interface_start
[  245.285590] cec-dw_hdmi: message bb timed out
[  246.032765] init: Received control message 'interface_start' for 'android.hardware.radio@1.1::IRadio/slot1' from pid: 153 (/system/bin/hwservicemanager)
[  246.032951] init: Could not find 'android.hardware.radio@1.1::IRadio/slot1' for ctl.interface_start
[  247.035345] init: Received control message 'interface_start' for 'android.hardware.radio@1.1::IRadio/slot1' from pid: 153 (/system/bin/hwservicemanager)
[  247.035527] init: Could not find 'android.hardware.radio@1.1::IRadio/slot1' for ctl.interface_start
[  247.397578] cec-dw_hdmi: message bb timed out
[  248.037407] init: Received control message 'interface_start' for 'android.hardware.radio@1.1::IRadio/slot1' from pid: 153 (/system/bin/hwservicemanager)
[  248.037593] init: Could not find 'android.hardware.radio@1.1::IRadio/slot1' for ctl.interface_start
[  249.039753] init: Received control message 'interface_start' for 'a

EDGE turn on usb power and off again periodically.

Full log here

Please post the corresponding log。。。。。。。。

LOG....

image

What log do you need?
And what is your picture mean?

post your log on the forum like this…

1 Like

Ok. I tried to find button for log, but menu does not have it.
And message has limit 32000.

Do you have any ideas, why it (not fast enter to deepsleep) happens?

image

I posted parts of log like you want.
Full log has 130000 symbols, but this forum has limit 32000, so I shared full log this 4 days ago.

Why do you do so many logs? You just need the corresponding log,There should be few logs corresponding to problems. Complete log is not required. Only the log with the problem is needed

I give the timestamps for this log. I don’t know what is the issue, but after 230 sec issue is happened.

I can’t download the link you gave me. So I always ask you to paste the corresponding log according to my requirements, but you have not posted it. You say too much, but you can post it several times.

I posted many logs as you want.
Find it on this post - How to deactivate wifi and bluetooth in sleep mode? - #39 by davemf
just open their

The first enter - fast enter to deepsleep with USB disable:
The second enter - not fast (5-7sec) with usb disable
The third - press mouse button after press power button - not enter to deepsleep
The fourth - fast enter to deepsleep with USB disable:
No sleep 20-30 sec

I said that the link you gave can’t be downloaded at all.