Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abook_check
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abook_android
abook_check
Commits
6d3a69d6
Commit
6d3a69d6
authored
Jun 24, 2022
by
onuma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
アプリがバックグラウンドになった時にタイマーを止める、Bluetoothを切る。
parent
3d1f0f8f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
72 deletions
+77
-72
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerTimerTask.java
+4
-3
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerUtil.java
+28
-13
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerUtilListener.java
+6
-9
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVContentViewActivity.java
+39
-47
No files found.
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerTimerTask.java
View file @
6d3a69d6
...
...
@@ -34,16 +34,17 @@ public class AlcoholCheckerTimerTask extends TimerTask {
break
;
case
F_BLE_COM_RP_START:
// RP Command Send
listener
.
onUpdateSendMessage
(
"TIMER F_BLE_COM_RP_COMMAND
"
);
Logger
.
d
(
TAG
,
"F_BLE_COM_RP_START
"
);
alcoholCheckerUtil
.
sendMessage
(
F_BLE_COM_RP_COMMAND
);
break
;
case
AlcoholCheckerUtil
.
F_BLE_COM_RD_START
:
// RD Command Send
listener
.
onUpdateSendMessage
(
"TIMER F_BLE_COM_RD_COMMAND
"
);
Logger
.
d
(
TAG
,
"F_BLE_COM_RD_START
"
);
alcoholCheckerUtil
.
sendMessage
(
F_BLE_COM_RD_COMMAND
);
break
;
case
AlcoholCheckerUtil
.
F_BLE_COM_FC_START
:
listener
.
onUpdateSendMessage
(
"TIMER F_BLE_COM_FC_COMMAND"
);
// Fc Command Send
Logger
.
d
(
TAG
,
"F_BLE_COM_FC_START"
);
alcoholCheckerUtil
.
sendMessage
(
AlcoholCheckerUtil
.
F_BLE_COM_FC_COMMAND_F11
);
break
;
// case F_BLE_COM_RECONNECT1:
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerUtil.java
View file @
6d3a69d6
...
...
@@ -14,6 +14,7 @@ import java.util.Timer;
import
java.util.UUID
;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
import
jp.agentec.adf.util.StringUtil
;
public
class
AlcoholCheckerUtil
{
public
static
final
String
TAG
=
"AlcoholCheckerUtil"
;
...
...
@@ -134,6 +135,14 @@ public class AlcoholCheckerUtil {
private
AlcoholCheckerTimerTask
alcoholCheckerTimerTask
=
null
;
public
boolean
isConnected
=
false
;
// ステータス
public
static
final
int
fugo_wait_connect
=
0
;
public
static
final
int
fugo_conntected
=
1
;
public
static
final
int
fugo_wait_go
=
2
;
public
static
final
int
fugo_fu_error
=
3
;
public
static
final
int
fugo_restart
=
4
;
public
int
alcStatus
=
0
;
public
AlcoholCheckerUtil
(
Context
context
,
AlcoholCheckerUtilListener
listener
)
{
this
.
context
=
context
;
isConnected
=
false
;
...
...
@@ -146,11 +155,6 @@ public class AlcoholCheckerUtil {
disconnect
(
true
);
}
// public void dispose() {
// bleManagerUtil = null;
// listener = null;
// }
// Bluetoothアダプタの取得処理
public
boolean
startGetDeviceInfo
()
{
...
...
@@ -265,6 +269,10 @@ public class AlcoholCheckerUtil {
}
}
sub_rx_chk
(
rx
);
if
(
gi_status
==
F_BLE_COM_FC_WAIT
)
{
Logger
.
d
(
TAG
,
"FC_WAIT"
);
}
}
@Override
...
...
@@ -406,16 +414,19 @@ public class AlcoholCheckerUtil {
// @Mode Change
switch
(
gi_status
)
{
case
F_BLE_COM_RP_START:
listener
.
onUpdateStatus
(
"sendMessage = F_BLE_COM_RP_WAIT"
);
//
listener.onUpdateStatus("sendMessage = F_BLE_COM_RP_WAIT");
gi_status
=
F_BLE_COM_RP_WAIT
;
Logger
.
d
(
TAG
,
"F_BLE_COM_RP_WAIT:"
+
gi_status
);
break
;
case
F_BLE_COM_RD_START:
listener
.
onUpdateStatus
(
"sendMessage = F_BLE_COM_RD_WAIT"
);
//
listener.onUpdateStatus("sendMessage = F_BLE_COM_RD_WAIT");
gi_status
=
F_BLE_COM_RD_WAIT
;
Logger
.
d
(
TAG
,
"F_BLE_COM_RD_WAIT:"
+
gi_status
);
break
;
case
F_BLE_COM_FC_START:
listener
.
onUpdateStatus
(
"sendMessage = F_BLE_COM_FC_WAIT"
);
//
listener.onUpdateStatus("sendMessage = F_BLE_COM_FC_WAIT");
gi_status
=
F_BLE_COM_FC_WAIT
;
Logger
.
d
(
TAG
,
"F_BLE_COM_FC_WAIT:"
+
gi_status
);
break
;
default
:
// None
...
...
@@ -517,7 +528,7 @@ public class AlcoholCheckerUtil {
sub_rx_data_gen
(
rxdata
);
// Mode
Logger
.
i
(
TAG
,
"gi_status = "
+
gi_status
);
Logger
.
i
(
TAG
,
"
sub_rx_chk
gi_status = "
+
gi_status
);
switch
(
gi_status
)
{
case
F_BLE_COM_INIT:
// BLE Init
...
...
@@ -713,9 +724,10 @@ public class AlcoholCheckerUtil {
byte
[]
res
=
hex2string
(
rxdata
);
for
(
byte
b:
rxdata
)
{
str_msg
+=
Byte
.
toString
(
b
);
//str_msg += Byte.toString(b);
Logger
.
d
(
TAG
,
"%s, "
+
Byte
.
toString
(
b
));
}
Logger
.
i
(
TAG
,
"fn_rx_fc_chk = "
+
str_msg
);
//
Logger.i(TAG, "fn_rx_fc_chk = " + str_msg);
// 01 72 70 02 rp 上位
// 01 114 112 02
...
...
@@ -743,9 +755,12 @@ public class AlcoholCheckerUtil {
}
//Logger.i(TAG, "fc=" + fcWaitMode);
listener
.
onGetDeviceInfo
(
alcol
);
if
(
StringUtil
.
isNullOrEmpty
(
alcol
))
{
si_ret
=
F_BLE_COM_FC_START
;
}
else
{
si_ret
=
F_BLE_COM_RP_START
;
}
fcWaitMode
=
0
;
si_ret
=
F_BLE_COM_RP_START
;
}
}
return
si_ret
;
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerUtilListener.java
View file @
6d3a69d6
...
...
@@ -2,16 +2,13 @@ package jp.agentec.abook.abv.cl.util;
public
interface
AlcoholCheckerUtilListener
{
void
onConnectionError
(
int
status
);
// ディバイス接続エラー
void
onMeasurementError
(
String
txt
);
// 吹付エラー
void
onBreakDownError
(
String
txt
);
// 機器の故障
void
onLowBatteryError
(
String
txt
);
// バッテリー不足
void
onOverUsedError
(
String
txt
);
// 使用回数超過
void
onPowerOff
(
String
txt
);
// 機器の電源がOFF
void
onStartMeasurement
();
void
onMeasurementError
(
String
txt
);
// 吹付エラー
void
onBreakDownError
(
String
txt
);
// 機器の故障
void
onLowBatteryError
(
String
txt
);
// バッテリー不足
void
onOverUsedError
(
String
txt
);
// 使用回数超過
void
onPowerOff
(
String
txt
);
// 機器の電源がOFF
void
onStartMeasurement
();
// 吹付開始
void
onUpdateTBVCalc
(
String
text
);
void
onUpdateStatus
(
String
text
);
void
onUpdateSendMessage
(
String
text
);
void
onUpdateReceivedData
(
String
text
);
void
onServicesDiscovered
(
int
status
);
void
onGetDeviceInfo
(
String
alcohol
);
}
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVContentViewActivity.java
View file @
6d3a69d6
...
...
@@ -188,14 +188,6 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
// 二重起動防止フラグ(アルコールチェッカー)
private
boolean
isAlcBlock
=
false
;
// ステータス
private
static
final
int
fugo_wait_connect
=
0
;
private
static
final
int
fugo_conntected
=
1
;
private
static
final
int
fugo_wait_go
=
2
;
private
static
final
int
fugo_fu_error
=
3
;
private
static
final
int
fugo_restart
=
4
;
private
int
alcStatus
=
0
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
...
...
@@ -277,29 +269,14 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
@Override
public
void
onUpdateTBVCalc
(
String
text
)
{
Logger
.
i
(
TAG
,
"onUpdateTBVCalc = %s"
,
text
);
}
@Override
public
void
onUpdateStatus
(
String
text
)
{
Logger
.
d
(
TAG
,
"onUpdateStatus = %s"
,
text
);
}
@Override
public
void
onUpdateSendMessage
(
String
text
)
{
Logger
.
d
(
TAG
,
"onUpdateSendMessage = %s"
,
text
);
}
@Override
public
void
onUpdateReceivedData
(
String
text
)
{
Logger
.
d
(
TAG
,
"onUpdateReceivedData = %s"
,
text
);
Logger
.
d
(
TAG
,
"onUpdateTBVCalc = %s"
,
text
);
}
@Override
public
void
onServicesDiscovered
(
int
status
)
{
Logger
.
d
(
TAG
,
"onServicesDiscovered = %s"
,
status
);
if
(
alc
Status
==
fugo_wait_connect
)
{
alc
Status
=
fugo_conntected
;
if
(
alc
oholCheckerUtil
.
alcStatus
==
AlcoholCheckerUtil
.
fugo_wait_connect
)
{
alc
oholCheckerUtil
.
alcStatus
=
AlcoholCheckerUtil
.
fugo_conntected
;
}
else
{
return
;
}
...
...
@@ -320,14 +297,18 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
@Override
public
void
onGetDeviceInfo
(
String
alcohol
)
{
Logger
.
d
(
TAG
,
"測定完了 = "
+
alcohol
);
successAfterAbookCheckApi
(
alcohol
,
false
);
if
(!
alcohol
.
equals
(
""
))
{
successAfterAbookCheckApi
(
alcohol
,
false
);
}
else
{
}
}
@Override
public
void
onStartMeasurement
()
{
Logger
.
d
(
TAG
,
"onStartMeasurement"
);
if
(
alc
Status
==
fugo_conntected
)
{
alc
Status
=
fugo_wait_go
;
if
(
alc
oholCheckerUtil
.
alcStatus
==
AlcoholCheckerUtil
.
fugo_conntected
)
{
alc
oholCheckerUtil
.
alcStatus
=
AlcoholCheckerUtil
.
fugo_wait_go
;
}
else
{
return
;
}
...
...
@@ -360,7 +341,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
public
void
onMeasurementError
(
String
text
)
{
Logger
.
d
(
TAG
,
"onMeasurementError = "
+
text
);
if
(
mMeasureDialog
!=
null
)
{
alc
Status
=
fugo_fu_error
;
alc
oholCheckerUtil
.
alcStatus
=
AlcoholCheckerUtil
.
fugo_fu_error
;
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
...
...
@@ -392,8 +373,8 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
});
}
private
void
closeAllDialog
()
{
private
void
dismissAllDialog
()
{
Logger
.
d
(
TAG
,
"dismissAllDialog"
);
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
...
...
@@ -422,8 +403,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
closeAllDialog
();
dismissAllDialog
();
JSONObject
responseJson
=
new
JSONObject
();
responseJson
.
put
(
ABookKeys
.
TASK_QUESTION_ID
,
mQid
);
responseJson
.
put
(
"value"
,
value
);
...
...
@@ -442,7 +422,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
close
AllDialog
();
dismiss
AllDialog
();
alcoholCheckerUtil
.
sendMessage
(
AlcoholCheckerUtil
.
F_BLE_COM_FC_COMMAND_F11
);
afterABookCheckApi
(
mCmd
,
""
,
1
,
errorMessage
,
null
);
Logger
.
e
(
TAG
,
errorMessage
);
...
...
@@ -556,10 +536,10 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
return
;
}
BluetoothPairingDeviceInfoDto
dto
=
getABVUIDataCache
().
getPairingBluetoothDeviceInfo
(
Constant
.
DeviceType
.
alcoholChecker
);
alc
Status
=
fugo_wait_connect
;
alc
oholCheckerUtil
.
alcStatus
=
AlcoholCheckerUtil
.
fugo_wait_connect
;
if
(
alcoholCheckerUtil
.
isConnected
)
{
Logger
.
d
(
TAG
,
"isConnection = true"
);
alc
Status
=
fugo_conntected
;
alc
oholCheckerUtil
.
alcStatus
=
AlcoholCheckerUtil
.
fugo_conntected
;
showWaitMeasureDialog
(
getString
(
R
.
string
.
alcohol_checker
),
getString
(
R
.
string
.
connection_completed
));
}
else
{
Logger
.
d
(
TAG
,
"isConnection = false"
);
...
...
@@ -633,17 +613,38 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
@Override
protected
void
onStop
()
{
Logger
.
d
(
TAG
,
"-------------------------------------------------"
);
Logger
.
d
(
TAG
,
"onStop"
);
Logger
.
d
(
TAG
,
"-------------------------------------------------"
);
super
.
onStop
();
if
(!
DeviceInfo
.
isForegrdound
(
getApplicationContext
())
&&
readingLogFlg
)
{
ContentReadingLogLogic
logic
=
AbstractLogic
.
getLogic
(
ContentReadingLogLogic
.
class
);
logic
.
pauseContentReadLog
(
contentId
);
}
// ダイアログ閉じる
dismissAllDialog
();
// タイマーにFCコマンド
if
(
alcoholCheckerUtil
!=
null
)
{
isAlcBlock
=
false
;
// false にしないと2回目押せない
alcoholCheckerUtil
.
gi_status
=
AlcoholCheckerUtil
.
F_BLE_COM_FC_START
;
handler
.
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
// チェッカーも終了
alcoholCheckerUtil
.
finish
();
}
},
1000
);
}
}
@Override
protected
void
onDestroy
()
{
Logger
.
d
(
TAG
,
"onDestroy"
);
Logger
.
d
(
TAG
,
"-------------------------------------------------"
);
Logger
.
d
(
TAG
,
"onDestroy"
);
Logger
.
d
(
TAG
,
"-------------------------------------------------"
);
//Logger.d(TAG, "onDestroy");
if
(
readingLogFlg
)
{
ContentReadingLogLogic
logic
=
AbstractLogic
.
getLogic
(
ContentReadingLogLogic
.
class
);
logic
.
endContentReadLog
(
contentId
);
...
...
@@ -1940,12 +1941,4 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
this
.
mPhotoEditDialog
.
show
();
}
}
// public void disconnectBluetoothDevice() {
// Logger.d(TAG, "disconnectBluetoothDevice");
//
// if (alcoholCheckerUtil != null) {
// alcoholCheckerUtil.sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND_F11);
// alcoholCheckerUtil.finish();
// }
// }
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment