Commit fceb90af by onuma

単体試験終了まで

parent bd1b9918
......@@ -134,8 +134,8 @@ public class AlcoholCheckerUtil {
public AlcoholCheckerUtil(Context context, AlcoholCheckerUtilListener listener) {
this.context = context;
this.listener = listener;
isConnected = false;
this.listener = listener;
}
public void finish() {
......@@ -144,6 +144,11 @@ public class AlcoholCheckerUtil {
disconnect(true);
}
public void dispose() {
bleManagerUtil = null;
listener = null;
}
// Bluetoothアダプタの取得処理
public boolean startGetDeviceInfo() {
......@@ -263,9 +268,13 @@ public class AlcoholCheckerUtil {
@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
if (bleManagerUtil.mBluetoothGatt != null) {
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;
}
} else {
return;
}
......@@ -766,4 +775,4 @@ public class AlcoholCheckerUtil {
public void NotificationDisable(BluetoothGattCharacteristic uRxChar, UUID ucccd) {
bleManagerUtil.NotificationDisable(uRxChar, ucccd);
}
}
}
\ No newline at end of file
......@@ -67,7 +67,9 @@ public class BleManagerUtil {
runOnUiThread( new Runnable() {
@Override
public void run() {
mListener.onConnectionError(status);
if (mListener != null) {
mListener.onConnectionError(status);
}
Logger.e(TAG,"onConnectionStateChange status = " + status);
}
});
......@@ -104,6 +106,7 @@ public class BleManagerUtil {
}
if( BluetoothProfile.STATE_DISCONNECTED == newState ) { // 切断完了(接続可能範囲から外れて切断された)
Logger.e(TAG,"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
// 切断が発生する場合、Bluetoothと接続を切断する。
disconnect(true);
return;
......@@ -139,7 +142,9 @@ public class BleManagerUtil {
@Override
public void onCharacteristicChanged( BluetoothGatt gatt, BluetoothGattCharacteristic characteristic ) {
Logger.d(TAG,"onCharacteristicChanged");
mListener.onCharacteristicChanged(gatt, characteristic);
if (mListener != null) {
mListener.onCharacteristicChanged(gatt, characteristic);
}
}
@Override
public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status){
......@@ -273,6 +278,7 @@ public class BleManagerUtil {
// 切断時のコールバックでmBluetoothGatt.connect()を呼んでおくと、接続可能範囲に入ったら自動接続する。
mBluetoothGatt.disconnect();
mBluetoothGatt = null;
mListener = null;
}
// キャラクタリスティックの読み込み
......
......@@ -66,6 +66,7 @@ import jp.agentec.abook.abv.cl.helper.ContentMarkingFileHelper;
import jp.agentec.abook.abv.cl.util.AlcoholCheckerUtil;
import jp.agentec.abook.abv.cl.util.AlcoholCheckerUtilListener;
import jp.agentec.abook.abv.cl.util.AndroidStringUtil;
import jp.agentec.abook.abv.cl.util.BleManagerUtil;
import jp.agentec.abook.abv.cl.util.ContentLogUtil;
import jp.agentec.abook.abv.cl.util.LocationManagerUtil;
import jp.agentec.abook.abv.cl.util.PreferenceUtil;
......@@ -244,32 +245,63 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
}
}
// アルコールチェッカースタート
// 遠隔連動
meetingManager = MeetingManager.getInstance();
isCollaboration = meetingManager.isCollaboration();
mContentDir = getIntent().getStringExtra(FILEPATH);
// Activity登録
if (objectId == -1) {
ActivityHandlingHelper.getInstance().setContentViewActivity(this);
ContentDto dto = contentDao.getContent(contentId);
if (dto != null) {
// 閲覧履歴保存
contentDao.updateContentReadingDate(DateTimeUtil.getCurrentTimestamp(), getContentId());
}
} else {
ActivityHandlingHelper.getInstance().setObjectViewActivity(this);
}
contentDownloader.pauseAll();
showUpdateContentAlert(contentId);
}
/**
* アルコールチェッカー、ユーティリティ初期化
*/
private void initAlcoholCheckerUtil() {
// if (alcoholCheckerUtil != null) {
// alcoholCheckerUtil.dispose();
// }
alcoholCheckerUtil = new AlcoholCheckerUtil(this, new AlcoholCheckerUtilListener() {
@Override
public void onUpdateTBVCalc(String text) {
Logger.i(TAG,"onUpdateTBVCalc = %s", text);
Logger.i(TAG, "onUpdateTBVCalc = %s", text);
}
@Override
public void onUpdateStatus(String text) {
Logger.d(TAG,"onUpdateStatus = %s", text);
Logger.d(TAG, "onUpdateStatus = %s", text);
}
@Override
public void onUpdateSendMessage(String text) {
Logger.i(TAG,"onUpdateSendMessage = %s", text);
Logger.i(TAG, "onUpdateSendMessage = %s", text);
}
@Override
public void onUpdateReceivedData(String text) {
Logger.d(TAG,"onUpdateReceivedData = %s", text);
Logger.d(TAG, "onUpdateReceivedData = %s", text);
}
@Override
public void onServicesDiscovered(int status){
Logger.i(TAG,"onServicesDiscovered = %s", status);
public void onServicesDiscovered(int status) {
Logger.i(TAG, "onServicesDiscovered = %s", status);
if (alcStatus == fugo_wait_connect) {
alcStatus = fugo_conntected;
} else {
......@@ -291,7 +323,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
@Override
public void onGetDeviceInfo(String alcohol) {
Logger.d(TAG,"測定完了 = " + alcohol);
Logger.d(TAG, "測定完了 = " + alcohol);
successAfterAbookCheckApi(alcohol, false);
}
......@@ -319,7 +351,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
String message = "";
if (status == 133 || status == 8) {
message = getString(R.string.msg_connection_timeout); // デバイスと接続されていない
} else if (status == 19){
} else if (status == 19) {
message = getString(R.string.msg_disconnected_device);
}
errorAfterAbookCheckApi(message);
......@@ -357,37 +389,10 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
public void onPowerOff(String text) {
errorAfterAbookCheckApi(getString(R.string.msg_power_off));
}
});
if (!alcoholCheckerUtil.startGetDeviceInfo()) {
// 端末がBluetoothをサポートしていないなどの理由で、アルコールチェッカーが使えない
Logger.e(TAG,"bluetooth damedame.");
}
// 遠隔連動
meetingManager = MeetingManager.getInstance();
isCollaboration = meetingManager.isCollaboration();
mContentDir = getIntent().getStringExtra(FILEPATH);
// Activity登録
if (objectId == -1) {
ActivityHandlingHelper.getInstance().setContentViewActivity(this);
ContentDto dto = contentDao.getContent(contentId);
if (dto != null) {
// 閲覧履歴保存
contentDao.updateContentReadingDate(DateTimeUtil.getCurrentTimestamp(), getContentId());
}
} else {
ActivityHandlingHelper.getInstance().setObjectViewActivity(this);
}
contentDownloader.pauseAll();
showUpdateContentAlert(contentId);
}
private void closeAllDialog() {
runOnUiThread(new Runnable() {
@Override
......@@ -456,6 +461,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
alcoholCheckerUtil.finish();
afterABookCheckApi(mCmd, "", 1, errorMessage, null);
Logger.e(TAG,errorMessage);
alcoholCheckerUtil = null;
}
});
}
......@@ -469,7 +475,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
Logger.i(TAG,"showWaitingDialog");
mWaitingDialog = AlertDialogUtil.createAlertDialog(this, title);
mWaitingDialog.setMessage(message);
mWaitingDialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.pairing_search_stop), new DialogInterface.OnClickListener() {
mWaitingDialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Logger.i(TAG, "waiting Dialog stop click");
......@@ -522,16 +528,38 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
* @param abookCheckParam
*/
private void getDeviceInfo(Map<String, String> abookCheckParam) {
Logger.i(TAG,"getDeviceInfo");
Logger.i(TAG,"getDeviceInfo start.");
mDeviceType = Integer.parseInt(abookCheckParam.get(ABookKeys.TASK_DEVICE_TYPE));
mQid = abookCheckParam.get(ABookKeys.TASK_QUESTION_ID);
// アルコールチェッカー初期化
initAlcoholCheckerUtil();
if (!alcoholCheckerUtil.startGetDeviceInfo()) {
// 端末がBluetoothをサポートしていないなどの理由で、アルコールチェッカーが使えない
Logger.e(TAG,"bluetooth not support.");
}
// アルコールチェッカー接続
connectToAlcholChecker();
}
/**
* Android端末のBluetooth機能の有効化要求
* @return true:bluetooth ON, false:bluetooth OFF
*/
private boolean requestBluetoothFeature(int requestCode) {
if(alcoholCheckerUtil.bleManagerUtil.mBluetoothAdapter.isEnabled()) {
return true;
}
// デバイスのBluetooth機能が有効になっていないときは、有効化要求(ダイアログ表示)
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, requestCode);
return false;
}
/**
* BLEディバイスのアルコールチェッカーの情報取得
*/
private void connectToAlcholChecker() {
......@@ -560,20 +588,6 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
}
}
/**
* Android端末のBluetooth機能の有効化要求
* @return true:bluetooth ON, false:bluetooth OFF
*/
private boolean requestBluetoothFeature(int requestCode) {
if(alcoholCheckerUtil.bleManagerUtil.mBluetoothAdapter.isEnabled()) {
return true;
}
// デバイスのBluetooth機能が有効になっていないときは、有効化要求(ダイアログ表示)
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, requestCode);
return false;
}
private void showUpdateContentAlert(long contentId) {
if (meetingManager.isConnected()) {
ContentDto contentDto = contentDao.getContent(contentId);
......
......@@ -484,25 +484,23 @@ public class ABookSettingFragment extends PreferenceFragment {
private void setPairingSetting() {
// アルコールチェッカーHW設定がOFFの場合は、設定のカテゴリを表示しない
PreferenceGroup devicePairing = (PreferenceGroup) findPreference(SET_PAIRING);
if (!ABVDataCache.getInstance().serviceOption.isAlcoholCheckerHw()) {
if (!ABVDataCache.getInstance().serviceOption.isAlcoholCheckerHw()) {
Logger.d(TAG,"アルコールチェッカーHW連携OFF");
PreferenceGroup devicePairing = (PreferenceGroup) findPreference(SET_PAIRING);
Preference alcoholChecker = (Preference) findPreference(SET_ALC_PAIRING);
devicePairing.removePreference(alcoholChecker);
// カテゴリーも消す
PreferenceScreen preferenceScreen = getPreferenceScreen();
Preference pref2 = getPreferenceManager().findPreference(SET_PAIRING);
preferenceScreen.removePreference(pref2);
Preference preference = getPreferenceManager().findPreference(SET_PAIRING);
preferenceScreen.removePreference(preference);
return;
}
PreferenceGroup devicePairing = (PreferenceGroup) findPreference(SET_ALC_PAIRING);
devicePairing.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
try {
Logger.i(TAG,"" + getActivity().getLocalClassName());
// ペアリング設定画面(BLE通信)
Intent intent = new Intent();
intent.setClass(getActivity(), BlePairingSettingActivity.class);
......
......@@ -344,7 +344,7 @@ public class BlePairingSettingActivity extends ABVUIActivity {
if (mScanning) {
sectionList.add(new SectionHeaderData(String.format(getString(R.string.pairing_other_machine_searching))));
} else {
sectionList.add(new SectionHeaderData(String.format(getString(R.string.set_title_pairing))));
sectionList.add(new SectionHeaderData(String.format(getString(R.string.pairing_save_machine))));
}
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