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
b3af43b6
Commit
b3af43b6
authored
Oct 13, 2022
by
Takatoshi Miura
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug #50121【府中屋】eXFrameAC1 アルコールチェッカー設定をタップした際にアプリが落ちる
parent
56f4d137
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
20 deletions
+84
-20
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/environment/DeviceInfo.java
+2
-4
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/LocationManagerUtil.java
+80
-4
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/BlePairingSettingActivity.java
+2
-12
No files found.
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/environment/DeviceInfo.java
View file @
b3af43b6
...
@@ -15,7 +15,6 @@ import android.os.Environment;
...
@@ -15,7 +15,6 @@ import android.os.Environment;
import
android.os.StatFs
;
import
android.os.StatFs
;
import
android.provider.Settings
;
import
android.provider.Settings
;
import
android.provider.Settings.Secure
;
import
android.provider.Settings.Secure
;
import
android.text.TextUtils
;
import
android.util.Base64
;
import
android.util.Base64
;
import
android.view.Display
;
import
android.view.Display
;
import
android.view.WindowManager
;
import
android.view.WindowManager
;
...
@@ -31,6 +30,7 @@ import jp.agentec.abook.abv.bl.common.exception.ABVExceptionCode;
...
@@ -31,6 +30,7 @@ import jp.agentec.abook.abv.bl.common.exception.ABVExceptionCode;
import
jp.agentec.abook.abv.bl.common.exception.NetworkDisconnectedException
;
import
jp.agentec.abook.abv.bl.common.exception.NetworkDisconnectedException
;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
import
jp.agentec.abook.abv.bl.common.util.SecurityUtil
;
import
jp.agentec.abook.abv.bl.common.util.SecurityUtil
;
import
jp.agentec.abook.abv.cl.util.LocationManagerUtil
;
import
jp.agentec.abook.abv.cl.util.PreferenceUtil
;
import
jp.agentec.abook.abv.cl.util.PreferenceUtil
;
import
jp.agentec.abook.abv.ui.common.appinfo.AppDefType.UserPrefKey
;
import
jp.agentec.abook.abv.ui.common.appinfo.AppDefType.UserPrefKey
;
import
jp.agentec.adf.util.StringUtil
;
import
jp.agentec.adf.util.StringUtil
;
...
@@ -273,7 +273,6 @@ public class DeviceInfo {
...
@@ -273,7 +273,6 @@ public class DeviceInfo {
*/
*/
public
static
boolean
isDeviceLocationEnabled
(
Context
context
)
{
public
static
boolean
isDeviceLocationEnabled
(
Context
context
)
{
int
locationMode
=
0
;
int
locationMode
=
0
;
String
locationProviders
;
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
KITKAT
){
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
KITKAT
){
try
{
try
{
...
@@ -287,8 +286,7 @@ public class DeviceInfo {
...
@@ -287,8 +286,7 @@ public class DeviceInfo {
return
locationMode
!=
Settings
.
Secure
.
LOCATION_MODE_OFF
;
return
locationMode
!=
Settings
.
Secure
.
LOCATION_MODE_OFF
;
}
else
{
}
else
{
locationProviders
=
Settings
.
Secure
.
getString
(
context
.
getContentResolver
(),
Settings
.
Secure
.
LOCATION_PROVIDERS_ALLOWED
);
return
LocationManagerUtil
.
isLocationGpsEnabled
(
context
);
return
!
TextUtils
.
isEmpty
(
locationProviders
);
}
}
}
}
}
}
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/LocationManagerUtil.java
View file @
b3af43b6
...
@@ -19,6 +19,8 @@ import android.location.LocationListener;
...
@@ -19,6 +19,8 @@ import android.location.LocationListener;
import
android.location.LocationManager
;
import
android.location.LocationManager
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.os.Handler
;
import
android.os.Build
;
import
android.provider.Settings
;
public
class
LocationManagerUtil
{
public
class
LocationManagerUtil
{
private
final
String
TAG
=
"LocationManagerUtil"
;
private
final
String
TAG
=
"LocationManagerUtil"
;
...
@@ -64,8 +66,8 @@ public class LocationManagerUtil {
...
@@ -64,8 +66,8 @@ public class LocationManagerUtil {
return
;
return
;
}
}
final
boolean
gps
=
locationManager
.
isProviderEnabled
(
LocationManager
.
GPS_PROVIDER
);
final
boolean
gps
=
isLocationGpsEnabled
(
);
final
boolean
network
=
locationManager
.
isProviderEnabled
(
LocationManager
.
NETWORK_PROVIDER
);
final
boolean
network
=
isLocationNetWorkEnabled
(
);
if
(!
gps
&&
!
network
)
{
if
(!
gps
&&
!
network
)
{
// この時点で位置情報サービスが有効でない場合は何もしない。
// この時点で位置情報サービスが有効でない場合は何もしない。
...
@@ -232,8 +234,8 @@ public class LocationManagerUtil {
...
@@ -232,8 +234,8 @@ public class LocationManagerUtil {
public
void
showLoactionServiceAlert
()
{
public
void
showLoactionServiceAlert
()
{
locationManager
=
(
LocationManager
)
context
.
getSystemService
(
Context
.
LOCATION_SERVICE
);
locationManager
=
(
LocationManager
)
context
.
getSystemService
(
Context
.
LOCATION_SERVICE
);
if
(
locationManager
!=
null
)
{
if
(
locationManager
!=
null
)
{
final
boolean
gps
=
locationManager
.
isProviderEnabled
(
LocationManager
.
GPS_PROVIDER
);
final
boolean
gps
=
isLocationGpsEnabled
(
);
final
boolean
network
=
locationManager
.
isProviderEnabled
(
LocationManager
.
NETWORK_PROVIDER
);
final
boolean
network
=
isLocationNetWorkEnabled
(
);
if
(!
gps
&&
!
network
)
{
if
(!
gps
&&
!
network
)
{
ABVUIDataCache
appDataCache
=
ABVApplication
.
getABVUIDataCache
(
context
);
ABVUIDataCache
appDataCache
=
ABVApplication
.
getABVUIDataCache
(
context
);
if
(
appDataCache
.
checkLocationServiceFlg
)
{
if
(
appDataCache
.
checkLocationServiceFlg
)
{
...
@@ -294,4 +296,78 @@ public class LocationManagerUtil {
...
@@ -294,4 +296,78 @@ public class LocationManagerUtil {
listener
.
onGetLocationFailed
();
listener
.
onGetLocationFailed
();
}
}
}
}
/**
* GPSが有効かチェックする
* @return 有効の場合true
*/
public
boolean
isLocationGpsEnabled
()
{
locationManager
=
(
LocationManager
)
context
.
getSystemService
(
Context
.
LOCATION_SERVICE
);
if
(
locationManager
==
null
)
{
return
false
;
}
boolean
gps
=
locationManager
.
isProviderEnabled
(
LocationManager
.
GPS_PROVIDER
);
boolean
secureLocationGpsEnabled
;
if
(
Build
.
VERSION
.
SDK_INT
<
31
)
{
// GPSの状態を取得(getSystemtServiceからのGPS ON/OFF取得が取れない場合があるため、secureで取得したgpsも判定するため)
secureLocationGpsEnabled
=
android
.
provider
.
Settings
.
Secure
.
getString
(
context
.
getContentResolver
(),
Settings
.
Secure
.
LOCATION_PROVIDERS_ALLOWED
).
contains
(
"gps"
);
}
else
{
secureLocationGpsEnabled
=
gps
;
}
if
(!
gps
||
!
secureLocationGpsEnabled
)
{
return
false
;
}
return
true
;
}
/**
* GPSが有効かチェックする
* @param context アプリのcontext
* @return 有効の場合はtrue
*/
public
static
boolean
isLocationGpsEnabled
(
Context
context
)
{
LocationManager
locationManager
=
(
LocationManager
)
context
.
getSystemService
(
Context
.
LOCATION_SERVICE
);
if
(
locationManager
==
null
)
{
return
false
;
}
boolean
gpsEnabled
=
locationManager
.
isProviderEnabled
(
LocationManager
.
GPS_PROVIDER
);
boolean
secureLocationGpsEnabled
;
if
(
Build
.
VERSION
.
SDK_INT
<
31
)
{
// GPSの状態を取得(getSystemtServiceからのGPS ON/OFF取得が取れない場合があるため、secureで取得したgpsも判定するため)
secureLocationGpsEnabled
=
android
.
provider
.
Settings
.
Secure
.
getString
(
context
.
getContentResolver
(),
Settings
.
Secure
.
LOCATION_PROVIDERS_ALLOWED
).
contains
(
"gps"
);
}
else
{
secureLocationGpsEnabled
=
gpsEnabled
;
}
if
(!(
gpsEnabled
||
secureLocationGpsEnabled
))
{
return
false
;
}
return
true
;
}
/**
* NetWorkによる位置測定が有効かチェックする
* @return 有効の場合true
*/
public
boolean
isLocationNetWorkEnabled
()
{
locationManager
=
(
LocationManager
)
context
.
getSystemService
(
Context
.
LOCATION_SERVICE
);
if
(
locationManager
==
null
)
{
return
false
;
}
boolean
network
=
locationManager
.
isProviderEnabled
(
LocationManager
.
NETWORK_PROVIDER
);
boolean
secureLocationNetWorkEnabled
;
if
(
Build
.
VERSION
.
SDK_INT
<
31
)
{
// GPSの状態を取得(getSystemtServiceからのGPS ON/OFF取得が取れない場合があるため、secureで取得したgpsも判定するため)
secureLocationNetWorkEnabled
=
android
.
provider
.
Settings
.
Secure
.
getString
(
context
.
getContentResolver
(),
Settings
.
Secure
.
LOCATION_PROVIDERS_ALLOWED
).
contains
(
"network"
);
}
else
{
secureLocationNetWorkEnabled
=
network
;
}
if
(!
network
||
!
secureLocationNetWorkEnabled
)
{
return
false
;
}
return
true
;
}
}
}
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/BlePairingSettingActivity.java
View file @
b3af43b6
...
@@ -29,6 +29,7 @@ import jp.agentec.abook.abv.bl.common.Constant.DeviceType;
...
@@ -29,6 +29,7 @@ import jp.agentec.abook.abv.bl.common.Constant.DeviceType;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
import
jp.agentec.abook.abv.bl.dto.BluetoothPairingDeviceInfoDto
;
import
jp.agentec.abook.abv.bl.dto.BluetoothPairingDeviceInfoDto
;
import
jp.agentec.abook.abv.cl.util.BleManagerUtil
;
import
jp.agentec.abook.abv.cl.util.BleManagerUtil
;
import
jp.agentec.abook.abv.cl.util.LocationManagerUtil
;
import
jp.agentec.abook.abv.launcher.android.R
;
import
jp.agentec.abook.abv.launcher.android.R
;
import
jp.agentec.abook.abv.ui.common.activity.ABVUIActivity
;
import
jp.agentec.abook.abv.ui.common.activity.ABVUIActivity
;
import
jp.agentec.abook.abv.ui.home.adapter.BleListAdapter
;
import
jp.agentec.abook.abv.ui.home.adapter.BleListAdapter
;
...
@@ -217,19 +218,8 @@ public class BlePairingSettingActivity extends ABVUIActivity {
...
@@ -217,19 +218,8 @@ public class BlePairingSettingActivity extends ABVUIActivity {
//BlueTooth許可チェック
//BlueTooth許可チェック
if
(!
requestBluetoothFeature
())
return
;
if
(!
requestBluetoothFeature
())
return
;
LocationManager
lm
=
(
LocationManager
)
this
.
getSystemService
(
this
.
LOCATION_SERVICE
);
boolean
gpsEnabled
=
false
;
if
(
lm
!=
null
)
{
gpsEnabled
=
lm
.
isProviderEnabled
(
LocationManager
.
GPS_PROVIDER
);
}
else
{
Logger
.
w
(
TAG
,
"LocationManager is null"
);
}
// GPSの状態を取得(getSystemtServiceからのGPS ON/OFF取得が取れない場合があるため、secureで取得したgpsも判定するため)
final
boolean
secureLocationGpsEnabled
=
android
.
provider
.
Settings
.
Secure
.
getString
(
getContentResolver
(),
Settings
.
Secure
.
LOCATION_PROVIDERS_ALLOWED
).
contains
(
"gps"
);
//端末側の位置情報許可チェック
//端末側の位置情報許可チェック
if
(!
(
gpsEnabled
||
secureLocationGpsEnabled
))
{
if
(!
LocationManagerUtil
.
isLocationGpsEnabled
(
this
))
{
showSimpleAlertDialog
(
R
.
string
.
alcohol_checker
,
R
.
string
.
msg_location_device_no_allow
);
showSimpleAlertDialog
(
R
.
string
.
alcohol_checker
,
R
.
string
.
msg_location_device_no_allow
);
return
;
return
;
}
}
...
...
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