Blame view

C5/app/src/main/java/com/sunvote/xpadcomm/XPadSystem.java 4.78 KB
fac86401   孙向锦   初始化C5 Vote
1
2
3
4
5
6
  package com.sunvote.xpadcomm;
  
  
  import android.content.Context;
  import android.content.Intent;
  
18faef8d   孙向锦   下载修改
7
  import com.sunvote.sdk.HuaWeiSDK;
fac86401   孙向锦   初始化C5 Vote
8
  import com.sunvote.util.LogUtil;
18faef8d   孙向锦   下载修改
9
  import com.sunvote.xpadapp.MainActivity;
fac86401   孙向锦   初始化C5 Vote
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
  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);
  		}
18faef8d   孙向锦   下载修改
149
  		HuaWeiSDK.getInstance((MainActivity)context).powerOffXPad();
fac86401   孙向锦   初始化C5 Vote
150
151
152
153
154
155
156
157
  	}
  
  	public static void rebootXPad(Context context) {
  		Intent intent = context.getPackageManager().getLaunchIntentForPackage("com.example.powerreboot");
  
  		if (intent != null) {
  			context.startActivity(intent);
  		}
18faef8d   孙向锦   下载修改
158
  		HuaWeiSDK.getInstance((MainActivity)context).rebootXPad();
fac86401   孙向锦   初始化C5 Vote
159
160
161
162
163
164
165
166
  
  	}
  	
  	public static void setNavgationVisible(Context context){
  		LogUtil.d(TAG, "setNavgationVisible");
  		Intent intent = new Intent();
  		intent.setAction("com.along.intent.Navigation_VISIBLE");
  		context.sendBroadcast(intent);
18faef8d   孙向锦   下载修改
167
168
169
  		HuaWeiSDK.getInstance((MainActivity)context).setHomeButtonDisabled(false);
  		HuaWeiSDK.getInstance((MainActivity)context).setStatusBarExpandPanelDisabled(false);
  		HuaWeiSDK.getInstance((MainActivity)context).setTaskButtonDisabled(false);
fac86401   孙向锦   初始化C5 Vote
170
171
172
173
174
175
176
  	}
  	
  	public static void setNavgationGone(Context context){
  		LogUtil.d(TAG, "setNavgationGone");
  		Intent intent = new Intent();
  		intent.setAction("com.along.intent.Navigation_GONE");
  		context.sendBroadcast(intent);
18faef8d   孙向锦   下载修改
177
178
179
  		HuaWeiSDK.getInstance((MainActivity)context).setHomeButtonDisabled(true);
  		HuaWeiSDK.getInstance((MainActivity)context).setStatusBarExpandPanelDisabled(true);
  		HuaWeiSDK.getInstance((MainActivity)context).setTaskButtonDisabled(true);
fac86401   孙向锦   初始化C5 Vote
180
181
182
183
184
185
186
187
188
189
  	}
  	
  	public static void goToSleep(Context context){
  		LogUtil.d(TAG, "goToSleep");
  		Intent intent = new Intent();
  		intent.setAction("android.intent.action.SCREEN_OFF");
  		context.sendBroadcast(intent);
  	}
  	
  }