Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
e
os
GmsCore
Commits
aee45c22
Verified
Commit
aee45c22
authored
Apr 28, 2021
by
Marvin W.
🐿
Browse files
EN: Add implementation for getStatus()
parent
ad12bd5d
Changes
1
Show whitespace changes
Inline
Side-by-side
play-services-nearby-core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ExposureNotificationServiceImpl.kt
View file @
aee45c22
...
...
@@ -9,8 +9,10 @@ import android.app.Activity
import
android.app.PendingIntent
import
android.bluetooth.BluetoothAdapter
import
android.content.*
import
android.location.LocationManager
import
android.os.*
import
android.util.Log
import
androidx.core.location.LocationManagerCompat
import
androidx.lifecycle.Lifecycle
import
androidx.lifecycle.LifecycleCoroutineScope
import
androidx.lifecycle.LifecycleOwner
...
...
@@ -622,11 +624,33 @@ class ExposureNotificationServiceImpl(private val context: Context, private val
override
fun
getStatus
(
params
:
GetStatusParams
)
{
Log
.
w
(
TAG
,
"Not yet implemented: getStatus"
)
lifecycleScope
.
launchSafely
{
ExposureDatabase
.
with
(
context
)
{
database
->
val
isAuthorized
=
ExposureDatabase
.
with
(
context
)
{
database
->
database
.
noteAppAction
(
packageName
,
"getStatus"
)
database
.
isAppAuthorized
(
packageName
)
}
val
flags
=
hashSetOf
<
ExposureNotificationStatus
>()
val
adapter
=
BluetoothAdapter
.
getDefaultAdapter
()
if
(
adapter
==
null
||
!
adapter
.
isEnabled
)
{
flags
.
add
(
ExposureNotificationStatus
.
BLUETOOTH_DISABLED
)
flags
.
add
(
ExposureNotificationStatus
.
BLUETOOTH_SUPPORT_UNKNOWN
)
}
else
if
(
Build
.
VERSION
.
SDK_INT
<
21
)
{
flags
.
add
(
ExposureNotificationStatus
.
EN_NOT_SUPPORT
)
}
else
if
(
adapter
.
bluetoothLeScanner
==
null
){
flags
.
add
(
ExposureNotificationStatus
.
HW_NOT_SUPPORT
)
}
if
(!
LocationManagerCompat
.
isLocationEnabled
(
context
.
getSystemService
(
Context
.
LOCATION_SERVICE
)
as
LocationManager
))
{
flags
.
add
(
ExposureNotificationStatus
.
LOCATION_DISABLED
)
}
if
(!
isAuthorized
)
{
flags
.
add
(
ExposureNotificationStatus
.
NO_CONSENT
)
}
if
(
isAuthorized
&&
ExposurePreferences
(
context
).
enabled
)
{
flags
.
add
(
ExposureNotificationStatus
.
ACTIVATED
)
}
else
{
flags
.
add
(
ExposureNotificationStatus
.
INACTIVATED
)
}
try
{
params
.
callback
.
onResult
(
Status
.
SUCCESS
,
ExposureNotificationStatus
.
setToFlags
(
setOf
(
ExposureNotificationStatus
.
UNKNOWN
)
))
params
.
callback
.
onResult
(
Status
.
SUCCESS
,
ExposureNotificationStatus
.
setToFlags
(
flags
))
}
catch
(
e
:
Exception
)
{
Log
.
w
(
TAG
,
"Callback failed"
,
e
)
}
...
...
Write
Preview
Supports
Markdown
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