blob: cce76e17a267d705d1ab6aed7a319481342dac56 [file] [log] [blame]
r.xiaoec113d12024-01-12 02:13:28 -08001#include "lynq-qser-autosuspend.h"
2
3#include <stdio.h>
4#include <unistd.h>
5#include <stddef.h>
6#include "mbtk_type.h"
7#include "mbtk_log.h"
8
r.xiaoffbe6ce2024-01-22 19:01:01 -08009/*白名单配置备注
10例如AT*POWERIND=31,就相当于设置NETWORK、SIM、SMS、CS CALL、PS DATA变化时都不主动上报,
11其中PS DATA目前暂时不支持,只是保留了这个标志位(ARS人员回复当前平台结论)
12AP power state: 1~31 means suspend, bitmap: bit0 - NETWORK;bit1 - SIM;bit2 - SMS;bit3 - CS CALL;bit4 - PS DATA
130 means resume all.
14目标文件"/system/etc/powerind"
15该值上电默认值是1,既平台默认是NW不主动上报
16
17白名单的状态由四位数字组成,从左往右判断
18第一位代表是否屏蔽电话唤醒,
19第二位代表是否屏蔽网络注册状态唤醒,
20第三位代表是否屏蔽数据业务唤醒,
21第四位代表是否屏蔽短信唤醒。
22其中 1 代表屏蔽,其他不会屏蔽。
23第一位:1:打开电话唤醒,其他:屏蔽电话唤醒
24第二位:1:打开网络注册状态唤醒,其他:屏蔽网络注册状态唤醒
25第三位:1:打开数据业务唤醒,其他:屏蔽数据业务唤醒
26第四位:1:打开短信唤醒,其他屏蔽短信唤醒
27当四位都不为 1 时(比如默认的状态:0000),则代表白名单为空,
28所有唤醒都不会屏蔽。
29
30*/
r.xiaoec113d12024-01-12 02:13:28 -080031
32static void qser_lpm_handler(qser_lpm_edge_t edge_state)
33{
34 printf("this is qser_lpm_handler, edge_state=%d\n", edge_state);
35}
36
37
38int main(int argc, char *argv[])
39{
40 char operator[10];
41 int opt;
42 int lv_voll = 0;
43 int fd_t;
44
45
46 while(1)
47 {
48 printf("=========sleep main=========\n"
49 "\t0 exit\n"
50 "\t1 autosuspend enable\n"
51 "\t2 wakelock create\n"
52 "\t3 wakelock lock\n"
53 "\t4 wakelock unlock\n"
54 "\t5 wakelock destroy\n"
55 "\t6 whitelist set\n"
56 "\t7 whitelist get\n"
r.xiaocfd7c682024-01-22 03:59:46 -080057 "\t8 lpm init\n"
58 "\t9 lpm destroy\n"
r.xiaoec113d12024-01-12 02:13:28 -080059 "operator: >> \n");
60
61 fgets(operator, sizeof(operator), stdin);
62 fflush(stdin);
63 opt = atoi(operator);
64 switch (opt)
65 {
66 case 0:
67 printf("main exit\n");
68 return 0;
69 case 1:
70 {
71 int en;
72 printf(">>>>>Input 0 or 1<<<<<\n");
73 memset(operator, 0x00, sizeof(operator));
74 fgets(operator, sizeof(operator), stdin);
75 fflush(stdin);
76 en = atoi(operator);
77 if (en == 0 || en == 1)
78 {
79 qser_autosuspend_enable(en);
80 }
81 else
r.xiaocfd7c682024-01-22 03:59:46 -080082 printf(">>>>>re Input 0 or 1 error<<<<<\n");
r.xiaoec113d12024-01-12 02:13:28 -080083 break;
84 }
85 case 2:
86 {
r.xiaocfd7c682024-01-22 03:59:46 -080087 printf(">>>>>Input name<<<<<\n");
r.xiaoec113d12024-01-12 02:13:28 -080088 char *t_name = NULL;
r.xiaoec113d12024-01-12 02:13:28 -080089 int len_name;
r.xiaocfd7c682024-01-22 03:59:46 -080090 memset(operator, 0x00, sizeof(operator));
91 fgets(operator, sizeof(operator), stdin);
r.xiaoec113d12024-01-12 02:13:28 -080092 fflush(stdin);
r.xiaocfd7c682024-01-22 03:59:46 -080093 len_name = strlen(operator);
94 strncpy(t_name, operator, len_name);
r.xiaoec113d12024-01-12 02:13:28 -080095
r.xiaocfd7c682024-01-22 03:59:46 -080096 fd_t = qser_wakelock_create(t_name, len_name);
97 printf(">>>>>Output ID NUM =[%d]<<<<<\n",fd_t);
r.xiaoec113d12024-01-12 02:13:28 -080098 break;
99 }
100 case 3:
r.xiaocfd7c682024-01-22 03:59:46 -0800101 printf(">>>>>Input ID NUM<<<<<\n");
102 fgets(operator, sizeof(operator), stdin);
103 fflush(stdin);
104 fd_t = atoi(operator);
r.xiaoec113d12024-01-12 02:13:28 -0800105 qser_wakelock_lock(fd_t);
106 break;
107 case 4:
r.xiaocfd7c682024-01-22 03:59:46 -0800108 printf(">>>>>Input ID NUM<<<<<\n");
109 memset(operator, 0x00, sizeof(operator));
110 fgets(operator, sizeof(operator), stdin);
111 fflush(stdin);
112 fd_t = atoi(operator);
r.xiaoec113d12024-01-12 02:13:28 -0800113 qser_wakelock_unlock(fd_t);
114 break;
115 case 5:
r.xiaocfd7c682024-01-22 03:59:46 -0800116 printf(">>>>>Input ID NUM<<<<<\n");
117 memset(operator, 0x00, sizeof(operator));
118 fgets(operator, sizeof(operator), stdin);
119 fflush(stdin);
120 fd_t = atoi(operator);
r.xiaoec113d12024-01-12 02:13:28 -0800121 qser_wakelock_destroy(fd_t);
122 break;
123 case 6:
124 {
r.xiaocfd7c682024-01-22 03:59:46 -0800125 printf(">>>>>Input whitelish NUM 4位(eg:1010) <<<<<\n");
126 char* whitelish = "1010";
127
128 printf(">>>server list = [%s]\n", whitelish);
r.xiaoec113d12024-01-12 02:13:28 -0800129 qser_whitelist_set(whitelish);
130 }
131 break;
132 case 7:
133 {
r.xiaocfd7c682024-01-22 03:59:46 -0800134 char whitelish_get[10]={0};
135 printf(">>>>>get\n");
136
137 qser_whitelist_get(whitelish_get);
138 printf(">>>server list = %s\n", whitelish_get);
r.xiaoec113d12024-01-12 02:13:28 -0800139 }
140 break;
141 case 8:
142 {
143 qser_pm_cfg_t *qser_lpm_cfg = NULL;
144 qser_lpm_cfg = (qser_pm_cfg_t *)malloc(sizeof(qser_pm_cfg_t));
145 qser_lpm_cfg->wakeupin.wakeupin_pin = 50;
146 qser_lpm_cfg->wakeupin.wakeupin_edge = E_QL_LPM_FALLING;
147 qser_lpm_init(qser_lpm_handler, qser_lpm_cfg);
r.xiaocfd7c682024-01-22 03:59:46 -0800148 free(qser_lpm_cfg);
r.xiaoec113d12024-01-12 02:13:28 -0800149 }
150 break;
151 case 9:
152 qser_lpm_deinit();
153 break;
154
155 default:
156 break;
157 }
158
159 }
160
161 return 0;
162}
163