Commit 7fb708ab by onuma

#47941 HW連携 アルコールチェッカーから値を取得する処理を追加中5

parent 26838b37
......@@ -1527,11 +1527,12 @@
<string name="msg_pairing_device_no_info">登録されたアルコールチェッカー情報がありません。\n設定画面のアルコールチェッカーHW設定から登録できます。</string>
<string name="msg_power_on">登録された機器の電源をオンにしてください。</string>
<string name="msg_press_button">アルコール濃度を測定するため、機器のボタン押してください</string>
<string name="msg_breath_error">正しく呼気が吹き込まれませんでした。ボタンを押して再計測してください。</string>
<string name="msg_break_down_device">機器が故障している可能性があります。購入元へご連絡ください。</string>
<string name="msg_low_battery">バッテリー不足です。機器の電池を交換してください。</string>
<string name="msg_over_used">使用回数が上限を超えました。他の機器を使用してください。</string>
<string name="msg_power_off">機器の電源がOFFになりました。電源を入れて再接続してください。</string>
<string name="msg_disconnected_device">アルコールチェッカーと切断されました。</string>
<!--
<string name="pairing_search_scan">スキャン</string>
<string name="pairing_search_scaning">スキャン中..</string>
......
......@@ -1531,7 +1531,8 @@
<string name="wait_breathe">입김을 불어주십시오. </string>
<string name="msg_pairing_device_no_info">등록된 기기 정보가 없습니다. 설정화면의 알코올체커설정을 확인해주십시오.</string>
<string name="msg_power_on">등록된 기기의 전원을 켜 주십시오.</string>
<string name="msg_press_button">올바르게 입김을 불어 넣어주시지 않으셨습니다. 버튼을 눌러 재측정을 하십시오</string>
<string name="msg_press_button">알코올 농도를 측정하기 위해 기기의 버튼 누르십시오.</string>
<string name="msg_breath_error">올바르게 입김을 불어 넣어주시지 않으셨습니다. 버튼을 눌러 재측정을 하십시오</string>
<string name="msg_break_down_device">기기가 고장났을 가능성이 있습니다.구입처로 연락해 주십시오</string>
<string name="msg_low_battery">배터리 부족입니다.기기의 베터리를 교환해 주십시오.</string>
<string name="msg_over_used">사용 횟수가 상한을 넘었습니다.다른 기기를 사용해 주십시오.</string>
......
......@@ -1529,11 +1529,15 @@
<string name="msg_pairing_device_no_info">There is no registered device information. Check the alcohol checker settings on the settings screen.</string>
<string name="msg_power_on">Please turn on the power of the registered device.</string>
<string name="msg_press_button">Press the button on the device to measure the alcohol concentration.</string>
<string name="msg_breath_error">The breath was not blown correctly. Press the button to remeasure.</string>
<string name="msg_break_down_device">The device may be out of order. Please contact the place of purchase.</string>
<string name="msg_low_battery">The battery is low. Replace the battery of the device.</string>
<string name="msg_over_used">The number of uses has exceeded the upper limit. Please use other device.</string>
<string name="msg_power_off">The power of the device has been turned off. Turn on the power and reconnect.</string>
<!--
<string name="msg_connection_timeout">デバイスと接続できませんでした</string>
<string name="msg_disconnected_device">デバイスと切断されました。</string>
<!--
<string name="center_thermometer">中心温度計</string>
<string name="pairing_search_scan">Scan</string>
<string name="pairing_search_scaning">Scaning...</string>
......
......@@ -76,7 +76,7 @@
<PreferenceCategory android:title="@string/set_title_pairing" android:key="set_pairing" android:layout="@layout/custom_preference_category">
<PreferenceScreen
android:key="setAlcPairing"
android:title="@string/alc_checker_setting"
android:title="@string/set_title_pairing"
android:layout="@layout/custom_preference_screen">
</PreferenceScreen>
</PreferenceCategory>
......
package jp.agentec.abook.abv.cl.util;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattDescriptor;
import java.util.TimerTask;
import java.util.UUID;
import jp.agentec.abook.abv.bl.common.log.Logger;
......
package jp.agentec.abook.abv.cl.util;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattDescriptor;
......@@ -8,15 +7,12 @@ import android.bluetooth.BluetoothGattService;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Timer;
import java.util.UUID;
import jp.agentec.abook.abv.bl.common.constant.ABookKeys;
import jp.agentec.abook.abv.bl.common.log.Logger;
public class AlcoholCheckerUtil {
......@@ -76,6 +72,11 @@ public class AlcoholCheckerUtil {
public static final String F_BLE_COM_FC_COMMAND = "01464301F37E04"; // 測定開始
public static final String F_BLE_COM_FC_COMMAND_F1 = "01464301F17E04"; // BLE接続解除
public static final String F_BLE_COM_FC_COMMAND_F2 = "01464301F27E04"; // 測定中断
public static final String F_BLE_COM_FC_COMMAND_F22 = "01464301F27D04"; // 中断コマンド(rdyに戻す
// RPコマンド 01525000A304
// RDコマンド 015244009704
// FC(中断)コマンド 01464301F27D04
// @BLE Rx
private final int F_RX_BUFSIZE = 32;
......@@ -134,14 +135,9 @@ public class AlcoholCheckerUtil {
this.listener = listener;
}
// public void initAlcoholChecker() {
// stopAlcTimer();
// disconnect(true);
// }
public void finish() {
stopAlcTimer();
//disconnect(true);
disconnect(true);
//listener = null;
}
......@@ -153,23 +149,18 @@ public class AlcoholCheckerUtil {
@Override
public void onGetDeviceInfoFailed(int status) {
Logger.i(TAG,"------------------------------------");
Logger.i(TAG,"onGetDeviceInfoFailed = %s", status);
Logger.i(TAG,"------------------------------------");
listener.onGetDeviceInfoFailed(status);
}
@Override
public void onConnectionState(int status) {
Logger.i(TAG,"------------------------------------");
Logger.i(TAG,"onConnectionState = %s" + status);
Logger.i(TAG,"------------------------------------");
if (status == BluetoothProfile.STATE_CONNECTED) {
Log.i(TAG, "Connected to GATT server.");
listener.onFugoAction(ACTION_GATT_CONNECTED, null, null, null, null);
// @@@@@
// ペリフェラルとの接続に成功した時点でサービスを検索する
if (bleManagerUtil.mBluetoothGatt.discoverServices()) {
Logger.i(TAG, "Started discovering services");
} else {
......@@ -182,8 +173,7 @@ public class AlcoholCheckerUtil {
return;
} else {
Logger.i(TAG, "Disconnected from GATT server.");
listener.onFugoAction(ACTION_GATT_DISCONNECTED, null, null, null, null);
bleManagerUtil.disconnect(true);
listener.onConnectionError(19);
}
} else {
......@@ -192,29 +182,24 @@ public class AlcoholCheckerUtil {
@Override
public void onDisConnectionState() {
Logger.i(TAG,"------------------------------------");
//Logger.i(TAG,"------------------------------------");
Logger.i(TAG,"onDisConnectionState");
Logger.i(TAG,"------------------------------------");
//Logger.i(TAG,"------------------------------------");
isConnected = false;
listener.onConnectionError(0);
}
@Override
public void onConnectionError(int status) {
Logger.i(TAG,"------------------------------------");
Logger.i(TAG,"onConnectionError = %s", status);
Logger.i(TAG,"------------------------------------");
isConnected = false;
listener.onConnectionError(status);
}
@Override
public void onServicesDiscovered(int status) {
Logger.i(TAG,"------------------------------------");
Logger.i(TAG,"onServicesDiscovered = %s", status);
Logger.i(TAG,"------------------------------------");
if (status == BluetoothGatt.GATT_SUCCESS) {
Logger.i(TAG,"------------------------------------------------------ BluetoothGatt.GATT_SUCCESS");
Logger.i(TAG,"BluetoothGatt.GATT_SUCCESS");
TaiyoYudenService = bleManagerUtil.mBluetoothGatt.getService(TY_SERVICE_UUID);
......@@ -226,7 +211,7 @@ public class AlcoholCheckerUtil {
TxChar = TaiyoYudenService.getCharacteristic(TX_CHARACTERISTIC_UUID);
if (RxChar == null || TxChar == null) {
Logger.e(TAG,"No Tx/Rx");
Logger.e(TAG, "No Tx/Rx");
} else {
gi_status = F_BLE_COM_INIT;
......@@ -252,17 +237,11 @@ public class AlcoholCheckerUtil {
gi_status = F_BLE_COM_RP_START;
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
startAlcTimer();
}
});
thread.start();
}
}
listener.onServicesDiscovered(status);
}
}
} else {
Logger.d(TAG,"");
}
......@@ -281,6 +260,32 @@ public class AlcoholCheckerUtil {
}
sub_rx_chk(rx);
}
@Override
public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
Logger.i(TAG,"onDescriptorWrite");
if (bleManagerUtil.mBluetoothGatt.getService(TY_SERVICE_UUID).getCharacteristic(INDICATION_CHARACTERISTIC_UUID) == null){
Logger.d(TAG, "Old version");
// This version doesn't support latest characteristics
return;
}
UUID characteristic_uuid = descriptor.getCharacteristic().getUuid();
if(characteristic_uuid.equals(NOTIFICATION_CHARACTERISTIC_UUID)){
bleManagerUtil.mBluetoothGatt.setCharacteristicNotification(IndicationChar, true);
BluetoothGattDescriptor indication_descriptor = IndicationChar.getDescriptor(CCCD);
indication_descriptor.setValue(BluetoothGattDescriptor.ENABLE_INDICATION_VALUE);
bleManagerUtil.mBluetoothGatt.writeDescriptor(indication_descriptor);
} else if(characteristic_uuid.equals(INDICATION_CHARACTERISTIC_UUID)){
// Enable notification on receiving data
bleManagerUtil.mBluetoothGatt.setCharacteristicNotification(batteryLevelChar, true);
BluetoothGattDescriptor notification_descriptor = batteryLevelChar.getDescriptor(CCCD);
notification_descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
bleManagerUtil.mBluetoothGatt.writeDescriptor(notification_descriptor);
} else if(characteristic_uuid.equals(BATTERY_LEVEL_UUID)){
Logger.i(TAG, "Wrote descriptor: " + BATTERY_LEVEL_UUID);
}
}
});
......@@ -294,7 +299,7 @@ public class AlcoholCheckerUtil {
/**
* アルコールチェッカーを監視するタイマーを開始する
*/
private void startAlcTimer() {
public void startAlcTimer() {
if (alcoholCheckerTimerTask != null) {
alcoholCheckerTimerTask.cancel();
alcoholCheckerTimerTask = null;
......@@ -315,17 +320,6 @@ public class AlcoholCheckerUtil {
}
private void init() {
//rxMessage = "";
bleManagerUtil.mBluetoothGatt.setCharacteristicNotification(NotificationChar, true);
BluetoothGattDescriptor notification_descriptor = NotificationChar.getDescriptor(CCCD);
notification_descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
bleManagerUtil.mBluetoothGatt.writeDescriptor(notification_descriptor);
gi_status = F_BLE_COM_RP_START;
}
public void connect(int connectTargetDeviceType, String deviceAddress) {
bleManagerUtil.connect(connectTargetDeviceType, deviceAddress);
}
......@@ -427,12 +421,12 @@ public class AlcoholCheckerUtil {
}
//Intent intent;
if (!error_msg.equals("")) {
listener.onFugoAction(ACTION_TX_ERROR, null, null, error_msg, null);
} else {
listener.onFugoAction(ACTION_TX_FINISHED, null, null, message, null);
}
// if (!error_msg.equals("")) {
// listener.onFugoAction(ACTION_TX_ERROR, null, null, error_msg, null);
// } else {
//
// listener.onFugoAction(ACTION_TX_FINISHED, null, null, message, null);
// }
}
}
Thread thread = new Thread(new MessageSender(message));
......
package jp.agentec.abook.abv.cl.util;
import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCharacteristic;
import java.util.UUID;
public interface AlcoholCheckerUtilListener {
void onFugoAction(String action, UUID CHAR, byte[] data, String MESSAGE, String Type);
void onGetDeviceInfoFailed(int status);
void onConnectionError(int status); // ディバイス接続エラー
......
......@@ -15,20 +15,16 @@ import android.content.Context;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.widget.Toast;
import java.lang.reflect.Method;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.List;
import java.util.UUID;
import jp.agentec.abook.abv.bl.common.Constant;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.adf.util.StringUtil;
import oz.lottie.animation.content.Content;
import static android.bluetooth.BluetoothDevice.TRANSPORT_LE;
import static org.chromium.base.ThreadUtils.runOnUiThread;
......@@ -78,7 +74,8 @@ public class BleManagerUtil {
@Override
public void run() {
mListener.onConnectionError(status);
disconnect(true);
//disconnect(true);
Logger.e(TAG,"onConnectionStateChange status = " + status);
}
});
return;
......@@ -120,19 +117,19 @@ public class BleManagerUtil {
return;
}
Logger.d(TAG, "--gattSize : " + gatt.getServices().size());
if (gatt.getServices().size() == 0) {
// サービスがない場合は、再接続
bleGattReconnect();
return;
}
// Logger.d(TAG, "--gattSize : " + gatt.getServices().size());
// if (gatt.getServices().size() == 0) {
// // サービスがない場合は、再接続
// bleGattReconnect();
// return;
// }
mBluetoothGatt.requestConnectionPriority(BluetoothGatt.CONNECTION_PRIORITY_HIGH);
// アルコールチェッカー
if (mBleConnectDeviceType == Constant.DeviceType.alcoholChecker) {
//if (mBleConnectDeviceType == Constant.DeviceType.alcoholChecker) {
mListener.onServicesDiscovered(status);
return;
}
//return;
//}
// 発見されたサービスのループ
// for(BluetoothGattService service : gatt.getServices()) {
......@@ -168,10 +165,11 @@ public class BleManagerUtil {
// キャラクタリスティックが読み込まれたときの処理
@Override
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status ) {
Logger.i(TAG,"onCharacteristicChanged");
if( BluetoothGatt.GATT_SUCCESS != status ) {
Logger.i(TAG, "onCharacteristicRead");
if (BluetoothGatt.GATT_SUCCESS != status) {
return;
}
}
// if( UUID_CHARACTERISTIC_PRIVATE.equals(characteristic.getUuid())) {
// final String strTemperature = byteToString(characteristic.getValue());
// runOnUiThread( new Runnable() {
......@@ -186,16 +184,16 @@ public class BleManagerUtil {
// setCharacteristicNotification(UUID_SERVICE_PRIVATE, UUID_CHARACTERISTIC_PRIVATE, true);
// return;
// }
}
// }
// キャラクタリスティック変更が通知されたときの処理
@Override
public void onCharacteristicChanged( BluetoothGatt gatt, BluetoothGattCharacteristic characteristic ) {
Logger.i(TAG,"onCharacteristicChanged");
if (mBleConnectDeviceType == Constant.DeviceType.alcoholChecker) {
//if (mBleConnectDeviceType == Constant.DeviceType.alcoholChecker) {
mListener.onCharacteristicChanged(gatt, characteristic);
return;
}
//return;
//}
// if( UUID_CHARACTERISTIC_PRIVATE.equals( characteristic.getUuid() ) ) {
// final String strTemperature = byteToString(characteristic.getValue());
//
......@@ -213,6 +211,11 @@ public class BleManagerUtil {
// return;
// }
}
@Override
public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status){
Logger.i(TAG,"onDescriptorWrite");
mListener.onDescriptorWrite(gatt, descriptor, status);
}
};
/**
......
......@@ -2,13 +2,14 @@ package jp.agentec.abook.abv.cl.util;
import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattDescriptor;
public interface BleManagerUtilListener {
// void onGetDeviceInfo(String strTemperature); // ディバイスから渡す情報
void onGetDeviceInfoFailed(int status); // ディバイスと接続失敗時の情報渡す。
void onConnectionState(int status); // ディバイスと接続された時情報渡す。
void onDisConnectionState(); // ディバイスと切断時
void onConnectionError(int status); // ディバイス接続エラー
void onServicesDiscovered(int status);
void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic);
void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status);
}
package jp.agentec.abook.abv.ui.common.activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothGattDescriptor;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
......@@ -41,7 +40,6 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import jp.agentec.abook.abv.bl.acms.type.OperationType;
......@@ -140,7 +138,6 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
protected ImageButton operationHomeButton;
protected ImageButton taskListButton;
protected ImageButton quickReportPrintButton;
// protected ImageButton helpButton;
protected boolean isPageFinished;
protected Double latitude;
......@@ -174,8 +171,6 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
// アルコールチェッカー
private AlcoholCheckerUtil alcoholCheckerUtil;
// Bluetoothの接続状態
//private boolean mIsConnection;
//待ち状態の時画面に表示するダイアログ
protected ABookAlertDialog mWaitingDialog = null;
// 計測用ダイアログ
......@@ -242,96 +237,39 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
alcoholCheckerUtil = new AlcoholCheckerUtil(this, new AlcoholCheckerUtilListener() {
@Override
public void onFugoAction(String action, UUID CHAR, byte[] data, String MESSAGE, String Type) {
Logger.i(TAG,"------------------------------------");
Logger.i(TAG,"onFugoAction = %s", action);
Logger.i(TAG,"------------------------------------");
if (action.equals(AlcoholCheckerUtil.ACTION_GATT_CONNECTED)) {
Logger.i(TAG,"ACTION_GATT_CONNECTED");
} else if (action.equals(AlcoholCheckerUtil.ACTION_GATT_DISCONNECTED)) {
Logger.i(TAG,"ACTION_GATT_DISCONNECTED");
errorAfterAbookCheckApi("");
} else if (action.equals(AlcoholCheckerUtil.ACTION_DATA_RECEIVED)) {
Logger.i(TAG,"ACTION_DATA_RECEIVED");
byte[] rx = data;
String rxStr = " ";
if (rx != null && rx.length > 0) {
for ( byte rx1 : rx) {
rxStr += rx1 + " ,";
}
}
alcoholCheckerUtil.sub_rx_chk(rx);
// } else if (action.equals(AlcoholCheckerUtil.ACTION_TX_FINISHED)) {
// Logger.i(TAG,"------------------------------------");
// Logger.i(TAG,"ACTION_TX_FINISHED = %s", action);
// Logger.i(TAG,"------------------------------------");
// } else if (action.equals(AlcoholCheckerUtil.ACTION_TX_ERROR)) {
// Logger.i(TAG,"------------------------------------");
// Logger.i(TAG,"ACTION_TX_ERROR", action);
// Logger.i(TAG,"------------------------------------");
} else if (action.equals(AlcoholCheckerUtil.ACTION_DESCRIPTOR_WROTE)) {
Logger.i(TAG, "------------------------------------");
Logger.i(TAG, "ACTION_DESCRIPTOR_WROTE", action);
Logger.i(TAG, "------------------------------------");
if (alcoholCheckerUtil.bleManagerUtil.mBluetoothGatt.getService(AlcoholCheckerUtil.TY_SERVICE_UUID).getCharacteristic(AlcoholCheckerUtil.INDICATION_CHARACTERISTIC_UUID) == null) {
Logger.i(TAG, "Old Version.");
return;
}
if (Type.equals("Notification")) {
// Enable indication on receiving data
alcoholCheckerUtil.bleManagerUtil.mBluetoothGatt.setCharacteristicNotification(alcoholCheckerUtil.IndicationChar, true);
BluetoothGattDescriptor indication_descriptor = alcoholCheckerUtil.IndicationChar.getDescriptor(AlcoholCheckerUtil.CCCD);
indication_descriptor.setValue(BluetoothGattDescriptor.ENABLE_INDICATION_VALUE);
alcoholCheckerUtil.bleManagerUtil.mBluetoothGatt.writeDescriptor(indication_descriptor);
} else if (Type.equals("Indication")) {
// Enable notification on receiving data
alcoholCheckerUtil.bleManagerUtil.mBluetoothGatt.setCharacteristicNotification(alcoholCheckerUtil.batteryLevelChar, true);
BluetoothGattDescriptor notification_descriptor = alcoholCheckerUtil.batteryLevelChar.getDescriptor(AlcoholCheckerUtil.CCCD);
notification_descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
alcoholCheckerUtil.bleManagerUtil.mBluetoothGatt.writeDescriptor(notification_descriptor);
}
}
}
@Override
public void onUpdateTBVCalc(String text) {
Logger.i(TAG,"------------------------------------");
//Logger.i(TAG,"------------------------------------");
Logger.i(TAG,"onUpdateTBVCalc = %s", text);
Logger.i(TAG,"------------------------------------");
//Logger.i(TAG,"------------------------------------");
}
@Override
public void onUpdateStatus(String text) {
Logger.i(TAG,"------------------------------------");
//Logger.i(TAG,"------------------------------------");
Logger.i(TAG,"onUpdateStatus = %s", text);
Logger.i(TAG,"------------------------------------");
//Logger.i(TAG,"------------------------------------");
}
@Override
public void onUpdateSendMessage(String text) {
Logger.i(TAG,"------------------------------------");
//Logger.i(TAG,"------------------------------------");
Logger.i(TAG,"onFugoActonUpdateSendMessageion = %s", text);
Logger.i(TAG,"------------------------------------");
//Logger.i(TAG,"------------------------------------");
}
@Override
public void onUpdateReceivedData(String text) {
Logger.i(TAG,"------------------------------------");
//Logger.i(TAG,"------------------------------------");
Logger.i(TAG,"onUpdateReceivedData = %s", text);
Logger.i(TAG,"------------------------------------");
//Logger.i(TAG,"------------------------------------");
}
@Override
public void onServicesDiscovered(int status){
Logger.i(TAG,"------------------------------------");
Logger.i(TAG,"onServicesDiscovered = %s", status);
Logger.i(TAG,"------------------------------------");
alcoholCheckerUtil.isConnected = true;
if (mWaitMeasureDialog != null) {
return;
}
runOnUiThread(new Runnable() {
@Override
public void run() {
......@@ -349,7 +287,6 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
public void onGetDeviceInfo(String alcohol) {
// 測定完了
successAfterAbookCheckApi(alcohol);
//alcoholCheckerUtil.finish();
}
@Override
......@@ -371,8 +308,13 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
@Override
public void onConnectionError(int status) {
errorAfterAbookCheckApi("");
//alcoholCheckerUtil.finish();
String message = "";
if (status == 133 || status == 8) {
message = getString(R.string.msg_connection_timeout);
} else if (status == 19){
message = getString(R.string.msg_disconnected_device);
}
errorAfterAbookCheckApi(message);
}
@Override
......@@ -381,7 +323,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
runOnUiThread(new Runnable() {
@Override
public void run() {
mMeasureDialog.setMessage("正しく呼気が吹き込まれませんでした。機器のボタンを押して再計測してください。");
mMeasureDialog.setMessage(getString(R.string.msg_breath_error));
}
});
}
......@@ -389,49 +331,40 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
@Override
public void onGetDeviceInfoFailed(int status) {
errorAfterAbookCheckApi("");
//alcoholCheckerUtil.finish();
errorAfterAbookCheckApi("いいいいいいいいいいいいいいいいいいいいいいいいいいいいいい");
}
@Override
public void onBreakDownError(String text) {
errorAfterAbookCheckApi("機器が故障している可能性があります。購入元へご連絡ください。");
//alcoholCheckerUtil.finish();
errorAfterAbookCheckApi(getString(R.string.msg_break_down_device));
}
@Override
public void onLowBatteryError(String text) {
errorAfterAbookCheckApi("バッテリー不足です。機器の電池を交換してください。");
//alcoholCheckerUtil.finish();
errorAfterAbookCheckApi(getString(R.string.msg_low_battery));
}
@Override
public void onOverUsedError(String text) {
errorAfterAbookCheckApi("使用回数が上限を超えました。他の機器を使用してください。");
//alcoholCheckerUtil.finish();
errorAfterAbookCheckApi(getString(R.string.msg_over_used));
}
@Override
public void onPowerOff(String text) {
errorAfterAbookCheckApi("機器の電源がOFFになりました。電源を入れて再接続してください。");
//alcoholCheckerUtil.finish();
errorAfterAbookCheckApi(getString(R.string.msg_power_off));
}
@Override
public void onError(String txt) {
alcoholCheckerUtil.finish();
errorAfterAbookCheckApi("不明なエラーです");
errorAfterAbookCheckApi("あああああああああああああああああああ");
}
});
if (!alcoholCheckerUtil.startGetDeviceInfo()) {
// 端末がBluetoothをサポートしていないなどの理由で、アルコールチェッカーが使えない
Logger.e(TAG,"bluetooth damedame.");
}
// 遠隔連動
meetingManager = MeetingManager.getInstance();
isCollaboration = meetingManager.isCollaboration();
......@@ -1075,79 +1008,6 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
*/
protected void onActionOperationPdfWebView(Map<String, String> checkParam, OperationTaskDto operationTaskDto) {}
// public void onClickShowHelpView(View v) {
// int helpViewType = 0;
// switch (mStatusCode) {
// case Constant.XWalkWebViewDisplayStatus.InitView:
// if (mXWalkOpenType == Constant.XWalkOpenType.PANO_EDIT) {
// helpViewType = Constant.HelpViewType.PanoContentEdit;
// } else {
// switch (mOperationType) {
// case OperationType.LIST:
// switch (mXWalkOpenType) {
// case Constant.XWalkOpenType.TASK_DERECTION:
// helpViewType = Constant.HelpViewType.ListOperationDirector;
// break;
// case Constant.XWalkOpenType.TASK_REPORT:
// if (operationDto.reportType == Constant.ReportType.RoutineTask) {
// helpViewType = Constant.HelpViewType.RoutineTaskOperation;
// } else {
// helpViewType = Constant.HelpViewType.ListOperationReporter;
// }
// break;
// }
// break;
// case OperationType.DRAWING:
// case OperationType.PDF:
// switch (mXWalkOpenType) {
// case Constant.XWalkOpenType.TASK_DERECTION:
// helpViewType = Constant.HelpViewType.DrawingOperationDirector;
// break;
// case Constant.XWalkOpenType.TASK_REPORT:
// helpViewType = Constant.HelpViewType.DrawingOperationReporter;
// break;
// }
// break;
// case OperationType.PANO:
// switch (mXWalkOpenType) {
// case Constant.XWalkOpenType.TASK_DERECTION:
// helpViewType = Constant.HelpViewType.PanoOperationDirector;
// break;
// case Constant.XWalkOpenType.TASK_REPORT:
// helpViewType = Constant.HelpViewType.PanoOperationReporter;
// break;
// }
//
// break;
// }
// }
// break;
// case Constant.XWalkWebViewDisplayStatus.TaskView:
// if (mXWalkOpenType == Constant.XWalkOpenType.TASK_DERECTION) {
// helpViewType = Constant.HelpViewType.DirectorTask;
// } else if (mXWalkOpenType == Constant.XWalkOpenType.TASK_REPORT) {
// if (operationDto.reportType == Constant.ReportType.RoutineTask) {
// helpViewType = Constant.HelpViewType.RoutineTaskOperationReport;
// } else {
// helpViewType = Constant.HelpViewType.ReportTask;
// }
// }
// break;
// case Constant.XWalkWebViewDisplayStatus.ReportPreView:
// helpViewType = Constant.HelpViewType.ReportPreview;
// break;
// case Constant.XWalkWebViewDisplayStatus.TaskListView:
// if (mXWalkOpenType == Constant.XWalkOpenType.TASK_DERECTION) {
// helpViewType = Constant.HelpViewType.DirectorTaskList;
// } else if (mXWalkOpenType == Constant.XWalkOpenType.TASK_REPORT) {
// helpViewType = Constant.HelpViewType.ReportTaskList;
// }
// break;
// }
//
// showHelpViewDialog(helpViewType);
// }
private void closeAllDialog() {
runOnUiThread(new Runnable() {
@Override
......@@ -1172,27 +1032,35 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
* 各デバイスから値を正常に取得された場合、HTML側にコールする
* @param value 各種デバイスから取得した値
*/
private void successAfterAbookCheckApi(String value) {
private void successAfterAbookCheckApi(final String value) {
runOnUiThread(new Runnable() {
@Override
public void run() {
closeAllDialog();
alcoholCheckerUtil.finish();
JSONObject responseJson = new JSONObject();
responseJson.put(ABookKeys.TASK_QUESTION_ID, mQid);
responseJson.put("value", value);
afterABookCheckApi(mCmd, "", 0, "", responseJson.toString());
Logger.i(TAG, "successAfterAbookCheckAip JSON [%s]", responseJson.toString());
isAlcLock = false;
}
});
}
/**
* 各デバイスからエラー(接続不能など)発生した場合、HTML側にコールする
* @param errorMessage 各種デバイスから取得した値
*/
private void errorAfterAbookCheckApi(String errorMessage) {
private void errorAfterAbookCheckApi(final String errorMessage) {
runOnUiThread(new Runnable() {
@Override
public void run() {
closeAllDialog();
alcoholCheckerUtil.finish();
afterABookCheckApi(mCmd, "", 1, errorMessage, null);
isAlcLock = false;
Logger.e(TAG,errorMessage);
}
});
}
/**
......@@ -1201,18 +1069,15 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
* @param message 内容
*/
private void showWaitingDialog(String title, String message) {
Logger.i(TAG,"-------------------------------------------------");
// Logger.i(TAG,"-------------------------------------------------");
Logger.i(TAG,"showWaitingDialog");
Logger.i(TAG,"-------------------------------------------------");
// Logger.i(TAG,"-------------------------------------------------");
mWaitingDialog = AlertDialogUtil.createAlertDialog(this, title);
mWaitingDialog.setMessage(message);
mWaitingDialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.pairing_search_stop), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Logger.i(TAG, "waiting Dialog stop click : " + mDeviceType);
//mWaitingDialog.dismiss();
mWaitingDialog = null;
//alcoholCheckerUtil.disconnect(true);
Logger.i(TAG, "waiting Dialog stop click");
successAfterAbookCheckApi("");
}
});
......@@ -1220,31 +1085,26 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
}
/**
* 接続待ち
* 行き吹きかけボタン押し待ち
* @param title タイトル
* @param message 内容
*/
private void showWaitMeasureDialog(String title, String message) {
Logger.i(TAG,"-------------------------------------------------");
Logger.i(TAG,"showWaitMeasureDialog");
Logger.i(TAG,"-------------------------------------------------");
mWaitMeasureDialog = AlertDialogUtil.createAlertDialog(this, title);
mWaitMeasureDialog.setMessage(getString(R.string.connection_completed));
mWaitMeasureDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Logger.i(TAG, "waiting mWaitMeasureDialog stop click : " + mDeviceType);
//mWaitMeasureDialog.dismiss();
mWaitMeasureDialog = null;
//alcoholCheckerUtil.disconnect(true);
errorAfterAbookCheckApi("");
Logger.i(TAG, "waiting mWaitMeasureDialog stop clickf");
successAfterAbookCheckApi("");
}
});
mWaitMeasureDialog.show();
}
/**
* 接続待ち
* 吹きかけてください
* @param title タイトル
* @param message 内容
*/
......@@ -1255,16 +1115,22 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
mMeasureDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Logger.i(TAG, "waiting Dialog stop click : " + mDeviceType);
//alcoholCheckerUtil.disconnect(true);
//mMeasureDialog.dismiss();
mMeasureDialog = null;
errorAfterAbookCheckApi("");
Logger.i(TAG, "wait mMeasureDialog stop click");
returnWaitMeasureDialog();
}
});
mMeasureDialog.show();
}
private void returnWaitMeasureDialog() {
runOnUiThread(new Runnable() {
@Override
public void run() {
closeAllDialog();
showWaitMeasureDialog(getString(R.string.alcohl_checker), getString(R.string.connection_completed));
}
});
}
/**
* アルコールチェッカー処理
......@@ -1278,16 +1144,10 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
mDeviceType = Integer.parseInt(abookCheckParam.get(ABookKeys.TASK_DEVICE_TYPE));
mQid = abookCheckParam.get(ABookKeys.TASK_QUESTION_ID);
if (isAlcLock) {
return;
}
isAlcLock = true;
// アルコールチェッカー接続
connectToAlcholChecker();
}
private boolean isAlcLock = false;
/**
* BLEディバイスのアルコールチェッカーの情報取得
*/
......@@ -1303,16 +1163,17 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
BluetoothPairingDeviceInfoDto dto = getABVUIDataCache().getPairingBluetoothDeviceInfo(Constant.DeviceType.alcoholChecker);
if (alcoholCheckerUtil.isConnected) {
Logger.i(TAG,"-------------------------------------------------");
Logger.i(TAG, "isConnection = true");
Logger.i(TAG,"-------------------------------------------------");
String message = String.format(getString(R.string.msg_ble_connect_success), dto.deviceName);
showWaitingDialog(getString(R.string.alcohl_checker),message);
} else {
Logger.i(TAG,"-------------------------------------------------");
Logger.i(TAG, "isConnection = false");
Logger.i(TAG,"-------------------------------------------------");
// if (alcoholCheckerUtil.isConnected) {
// Logger.i(TAG,"-------------------------------------------------");
// Logger.i(TAG, "isConnection = true");
// Logger.i(TAG,"-------------------------------------------------");
// String message = String.format(getString(R.string.msg_ble_connect_success), dto.deviceName);
// showWaitingDialog(getString(R.string.alcohl_checker),message);
// } else
{
// Logger.i(TAG,"-------------------------------------------------");
// Logger.i(TAG, "isConnection = false");
// Logger.i(TAG,"-------------------------------------------------");
// 登録されているアルコールチェッカーがある
String message = String.format(getString(R.string.ble_connecting), dto.deviceName);
showWaitingDialog(getString(R.string.alcohl_checker), message);
......
......@@ -111,7 +111,7 @@ public class BlePairingSettingActivity extends ABVUIActivity {
setContentView(R.layout.pairing_setting);
TextView deviceTitle = (TextView) findViewById(R.id.device_toolbar_title);
deviceTitle.setText(getString(R.string.alc_checker_setting));
deviceTitle.setText(getString(R.string.set_title_pairing));
// 戻り値の初期化
setResult( Activity.RESULT_CANCELED );
......@@ -211,7 +211,7 @@ public class BlePairingSettingActivity extends ABVUIActivity {
switch (requestCode) {
case REQUEST_ENABLEBLUETOOTH: // Bluetooth有効化要求
if( Activity.RESULT_CANCELED == resultCode ) { // 有効にされなかった
ABVToastUtil.showMakeText(getApplicationContext(), String.format(getString(R.string.msg_scan_bluetooth_no_allow), getString(R.string.chino_machine)), Toast.LENGTH_SHORT);
//ABVToastUtil.showMakeText(getApplicationContext(), String.format(getString(R.string.msg_scan_bluetooth_no_allow), getString(R.string.chino_machine)), Toast.LENGTH_SHORT);
return;
}
break;
......@@ -237,7 +237,7 @@ public class BlePairingSettingActivity extends ABVUIActivity {
//端末側の位置情報許可チェック
if (!(gpsEnabled || secureLocationGpsEnabled)) {
showSimpleAlertDialog(R.string.chino_machine, R.string.msg_location_device_no_allow);
//showSimpleAlertDialog(R.string.chino_machine, R.string.msg_location_device_no_allow);
return;
}
......@@ -356,21 +356,16 @@ public class BlePairingSettingActivity extends ABVUIActivity {
if (CollectionUtil.isNotEmpty(bluetoothPairingInfoDtoList)) {
for (BluetoothPairingDeviceInfoDto bluetoothPairingDeviceInfoDto : bluetoothPairingInfoDtoList) {
// ペアリング情報が既に保存されてる場合はヘッダー情報を各機器毎に追加する
// if (bluetoothPairingDeviceInfoDto.deviceType.equals(DeviceType.centerThermomete)) {
// sectionList.add(new SectionHeaderData(String.format(getString(R.string.pairing_save_machine), getString(R.string.center_thermometer))));
// } else if (bluetoothPairingDeviceInfoDto.deviceType.equals(DeviceType.radiationThermomete)) {
// sectionList.add(new SectionHeaderData(String.format(getString(R.string.pairing_save_machine), getString(R.string.radiation_thermometer))));
// } else
if (bluetoothPairingDeviceInfoDto.deviceType.equals(DeviceType.alcoholChecker)) {
sectionList.add(new SectionHeaderData(String.format(getString(R.string.pairing_save_machine), getString(R.string.alcohl_checker))));
sectionList.add(new SectionHeaderData(String.format(getString(R.string.pairing_save_machine))));
}
}
}
// その他のヘッダー情報追加
if (mScanning) {
sectionList.add(new SectionHeaderData(String.format(getString(R.string.pairing_other_machine_searching), getString(R.string.alcohl_checker))));
sectionList.add(new SectionHeaderData(String.format(getString(R.string.pairing_other_machine_searching))));
} else {
sectionList.add(new SectionHeaderData(String.format(getString(R.string.alc_checker_setting))));
sectionList.add(new SectionHeaderData(String.format(getString(R.string.set_title_pairing))));
}
return sectionList;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment