XPadSystem.java
4.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
package com.sunvote.xpadcomm;
import android.content.Context;
import android.content.Intent;
import com.sunvote.sdk.HuaWeiSDK;
import com.sunvote.util.LogUtil;
import com.sunvote.xpadapp.MainActivity;
import com.sunvote.xpadapp.R;
public class XPadSystem {
private static String TAG="XPadSystem";
public static void setStatusBarSingal(Context context,int rssi) {
String actionName = null;
// LogUtil.d(TAG, "setStatusBarSingal:"+level);
int level =0;
if (rssi < 95)
level = 1;
if (rssi < 85)
level = 2;
if (rssi < 75)
level = 3;
if (rssi < 65)
level = 4;
if (rssi < 55)
level = 5;
if (rssi == 0)
level = 0;
switch (level) {
case 0:
actionName = "com.along.intent.ZERO";
break;
case 1:
actionName = "com.along.intent.ONE";
break;
case 2:
actionName = "com.along.intent.TWO";
break;
case 3:
actionName = "com.along.intent.THREE";
break;
case 4:
actionName = "com.along.intent.FOUR";
break;
case 5:
actionName = "com.along.intent.FIVE";
break;
default:
break;
}
Intent intent = new Intent();
intent.setAction(actionName);
context.sendBroadcast(intent);
//setStatusBarDataIcon(context,3);
}
public static void setStatusBarDataIcon(Context context,int flag) {
String actionName = null;
switch (flag) {
case 0:
actionName = "com.along.intent.BACK";
break;
case 1:
actionName = "com.along.intent.UP";
break;
case 2:
actionName = "com.along.intent.DOWN";
break;
case 3:
actionName = "com.along.intent.LIGHT";
break;
default:
break;
}
Intent intent = new Intent();
intent.setAction(actionName);
context.sendBroadcast(intent);
}
public static void setStatusBarDataIcon(Context context,int tx,int rx) {
String actionName = null;
int flag = 0;
if (tx == 0 && rx == 0) {
flag=0;
} else if ( tx == 1 && rx == 0) {
flag=1;
} else if (tx == 0 && rx == 1) {
flag=2;
} else if (tx == 1 && rx == 1) {
flag=3;
}
switch (flag) {
case 0:
actionName = "com.along.intent.BACK";
break;
case 1:
actionName = "com.along.intent.UP";
break;
case 2:
actionName = "com.along.intent.DOWN";
break;
case 3:
actionName = "com.along.intent.LIGHT";
break;
default:
break;
}
Intent intent = new Intent();
intent.setAction(actionName);
context.sendBroadcast(intent);
}
public static void setStatusBarBaseId(Context context,String info) {
// LogUtil.d(TAG, "set statusbar: "+info);
Intent intent = new Intent();
intent.putExtra("company_name_Intent", info);
intent.setAction("com.along.intent.COMPANY_NAME");
context.sendBroadcast(intent);
}
public static void setStatusBarChannel(Context context,int ch) {
Intent intent = new Intent();
intent.putExtra("table_channel_Intent", String.valueOf(ch));
intent.setAction("com.along.intent.CHANGE_CHANNEL");
context.sendBroadcast(intent);
}
public static void setStatusBarPadID(Context context,int padid) {
Intent intent = new Intent();
intent.putExtra("table_id_Intent", context.getString(R.string.terminal_id) + padid);
intent.setAction("com.along.intent.CHANGE_TABLE_ID");
context.sendBroadcast(intent);
}
public static void powerOffXPad(Context context) {
Intent intent = context.getPackageManager().getLaunchIntentForPackage("com.example.powerdown");
if (intent != null) {
context.startActivity(intent);
}
HuaWeiSDK.getInstance((MainActivity)context).powerOffXPad();
}
public static void rebootXPad(Context context) {
Intent intent = context.getPackageManager().getLaunchIntentForPackage("com.example.powerreboot");
if (intent != null) {
context.startActivity(intent);
}
HuaWeiSDK.getInstance((MainActivity)context).rebootXPad();
}
public static void setNavgationVisible(Context context){
LogUtil.d(TAG, "setNavgationVisible");
Intent intent = new Intent();
intent.setAction("com.along.intent.Navigation_VISIBLE");
context.sendBroadcast(intent);
HuaWeiSDK.getInstance((MainActivity)context).setHomeButtonDisabled(false);
HuaWeiSDK.getInstance((MainActivity)context).setStatusBarExpandPanelDisabled(false);
HuaWeiSDK.getInstance((MainActivity)context).setTaskButtonDisabled(false);
}
public static void setNavgationGone(Context context){
LogUtil.d(TAG, "setNavgationGone");
Intent intent = new Intent();
intent.setAction("com.along.intent.Navigation_GONE");
context.sendBroadcast(intent);
HuaWeiSDK.getInstance((MainActivity)context).setHomeButtonDisabled(true);
HuaWeiSDK.getInstance((MainActivity)context).setStatusBarExpandPanelDisabled(true);
HuaWeiSDK.getInstance((MainActivity)context).setTaskButtonDisabled(true);
}
public static void goToSleep(Context context){
LogUtil.d(TAG, "goToSleep");
Intent intent = new Intent();
intent.setAction("android.intent.action.SCREEN_OFF");
context.sendBroadcast(intent);
}
}