package com.geenk.hardware.scanner.gk;
import com.geenk.hardware.scanner.yto.APNVO;
import android.content.Context;
import android.content.Intent;
public class GKDeviceControler {
/**
* 设置APN
* @param context
* @param vo
*/
public void setAPN(Context context, APNVO vo) {
Intent intent = new Intent("com.geenk.action.SET_APN");
intent.putExtra("apn_data", APNVO2Json(vo));
context.sendBroadcast(intent);
}
private String APNVO2Json(APNVO vo) {
String json = "{\"apn\":\"" + vo.getApn() + "\",\"authtype\":\""
+ vo.getAuthtype() + "\",\"current\":\"" + vo.getCurrent()
+ "\",\"mcc\":\"" + vo.getMcc() + "\",\"mmsc\":\""
+ vo.getMmsc() + "\",\"mmsport\":\"" + vo.getMmsport()
+ "\",\"mmsproxy\":\"" + vo.getMmsproxy() + "\",\"mnc\":\""
+ vo.getMnc() + "\",\"name\":\"" + vo.getName()
+ "\",\"numeric\":\"" + vo.getNumeric() + "\",\"password\":\""
+ vo.getPassword() + "\",\"port\":\"" + vo.getPort()
+ "\",\"proxy\":\"" + vo.getProxy()+ "\",\"server\":\""
+ vo.getServer()+ "\",\"type\":\"" + vo.getType()
+ "\",\"user\":\"" + vo.getUser()+ "\"} ";
return json;
}
/**
* extra为0时,关闭扫描头,extra为1时开启扫描头
*
* @param context
*/
public void openOrCloseScanner(Context context, int extra) {
Intent intent = new Intent();
intent.setAction("com.geenk.action.SCAN_SWITCH");
intent.putExtra("extra", extra);
context.sendBroadcast(intent);
}
/**
* 开启扫描头
*
* @param context
*/
public void openScanner(Context context) {
Intent intent = new Intent();
intent.setAction("com.geenk.action.SCAN_SWITCH");
intent.putExtra("extra", 1);
context.sendBroadcast(intent);
}
/**
* 关闭扫描头
*
* @param context
*/
public void closeScanner(Context context) {
Intent intent = new Intent();
intent.setAction("com.geenk.action.SCAN_SWITCH");
intent.putExtra("extra", 0);
context.sendBroadcast(intent);
}
/**
* 开始扫描
*
* @param context
*/
public void scan(Context context) {
Intent intent = new Intent();
intent.setAction("com.geenk.action.START_SCAN");
context.sendBroadcast(intent);
}
/**
* 停止扫描
*
* @param context
*/
public void stop(Context context) {
Intent intent = new Intent();
intent.setAction("com.geenk.action.STOP_SCAN");
context.sendBroadcast(intent);
}
public final int LIAN_SAO_OPEN = 1;
public final int LIAN_SAO_CLOSE = 0;
/**
* extra为0时,关闭扫描头连扫,extra为1时开启扫描头连扫功能
*
* @param context
*/
public void continuousScan(Context context, int extra) {
Intent intent = new Intent();
intent.setAction("com.geenk.action.CONTINUE_SCAN");
intent.putExtra("extra", extra);
context.sendBroadcast(intent);
}
/**
* 设置Home键是否可用
*
* @param context
* @param enable
* enable为true时,开启此功能,enable为false时关闭此功能
*/
public void setHomeKeyEnable(Context context, boolean enable) {
Intent intent = new Intent("com.geenk.action.HOMEKEY_SWITCH_STATE");
intent.putExtra("enable", enable);
context.sendBroadcast(intent);
}
/**
* 是否需要获取图片
*
* @param context
* @param enable
* enable为true时,需要,enable为false不需要
*/
public static void setNeedPicture(Context context, boolean enable) {
Intent intent = new Intent("com.geenk.action.GET_PICTURE");
intent.putExtra("enable", enable);
context.sendBroadcast(intent);
}
/**
* 设置下拉栏是否可用
*
* @param context
* @param enable
*/
public void setStatusbarEnable(Context context, boolean enable) {
Intent intent = new Intent("com.geenk.action.STATUSBAR_SWITCH_STATE");
intent.putExtra("enable", enable);
context.sendBroadcast(intent);
}
/**
* 设置系统时间
*
* @param context
* @param timeInMillis
*/
public void setTime(Context context, long timeInMillis) {
Intent intent = new Intent("com.geenk.action.SET_DATETIME");
intent.putExtra("datetime", timeInMillis);
context.sendBroadcast(intent);
}
public final String NET_TYPE_WIFI = "wifi";
public final String NET_TYPE_MOBILE = "mobile";
/**
* type为String类型,取值范围为"wifi"和"mobile",type为"mobile"设置为移动数据网络的状态,type为"wifi"
* 时设置wifi的状态 enable为Boolean类型,enable为true时,开启,enable为false时,关闭
*
* @param context
* @param netType
* @param enable
*/
public void setNet(Context context, String netType, boolean enable) {
Intent intent = new Intent("com.geenk.action.CHANGE_NETWORK_STATE");
intent.putExtra("type", netType);
intent.putExtra("enable", enable);
context.sendBroadcast(intent);
}
/**
* 开启和关闭应用程序安装功能的API接口
*
* @param context
* @param enable
*/
public void setInstallApkEnable(Context context, boolean enable) {
Intent intent = new Intent("com.geenk.action.APP_INSTALL_ENABLE");
intent.putExtra("enable", enable);
context.sendBroadcast(intent);
}
/**
* 开启和关闭adb pull和adb push的API接口
*
* @param context
* @param enable
*/
public void setAdbPushEnable(Context context, boolean enable) {
Intent intent = new Intent("com.geenk.action.SET_ADB");
intent.putExtra("enable", enable);
context.sendBroadcast(intent);
}
// /**
// * 设置扫描头2维
// */
// public void setScanner(){
// ScanManager mScanManager = new ScanManager();
// mScanManager.setOutputParameter(7, 4);
// }
}