Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
b9b5f70c
Commit
b9b5f70c
authored
Aug 17, 2022
by
刘鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 解决锁屏后无声音问题
parent
8670a576
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
97 additions
and
4 deletions
+97
-4
build.gradle
build.gradle
+1
-1
AudioHomeActivity.kt
m-audioim/src/main/java/com/ydl/audioim/AudioHomeActivity.kt
+13
-2
FloatService.kt
m-audioim/src/main/java/com/ydl/audioim/notification/FloatService.kt
+73
-0
ConsultantAudioHomeActivity.kt
m-audioim/src/main/java/com/ydl/consultantim/ConsultantAudioHomeActivity.kt
+10
-1
No files found.
build.gradle
View file @
b9b5f70c
...
@@ -14,7 +14,7 @@ buildscript {
...
@@ -14,7 +14,7 @@ buildscript {
ydlrouter_version
=
'1.2.3'
ydlrouter_version
=
'1.2.3'
constrait_support_version
=
'1.0.2'
constrait_support_version
=
'1.0.2'
componentVersion
=
"0.3.0.3
8
"
componentVersion
=
"0.3.0.3
9-SNAPSHOT
"
}
}
repositories
{
repositories
{
mavenCentral
()
mavenCentral
()
...
...
m-audioim/src/main/java/com/ydl/audioim/AudioHomeActivity.kt
View file @
b9b5f70c
...
@@ -33,6 +33,7 @@ import com.ydl.audioim.http.command.ConnectExceptionCommand
...
@@ -33,6 +33,7 @@ import com.ydl.audioim.http.command.ConnectExceptionCommand
import
com.ydl.audioim.http.command.NoticePushCommand
import
com.ydl.audioim.http.command.NoticePushCommand
import
com.ydl.audioim.http.command.PayLoad
import
com.ydl.audioim.http.command.PayLoad
import
com.ydl.audioim.listener.IntentConstants
import
com.ydl.audioim.listener.IntentConstants
import
com.ydl.audioim.notification.FloatService
import
com.ydl.audioim.player.AudioPlayer
import
com.ydl.audioim.player.AudioPlayer
import
com.ydl.audioim.presenter.AudioHomePresenterImpl
import
com.ydl.audioim.presenter.AudioHomePresenterImpl
import
com.ydl.audioim.router.AudioImIn
import
com.ydl.audioim.router.AudioImIn
...
@@ -233,7 +234,7 @@ class AudioHomeActivity :
...
@@ -233,7 +234,7 @@ class AudioHomeActivity :
private
var
canChangeRoute
:
Boolean
=
false
private
var
canChangeRoute
:
Boolean
=
false
private
var
hasHandleRefused
=
false
private
var
hasHandleRefused
=
false
private
var
mServiceIntent
:
Intent
?
=
null
private
val
notificationCallback
=
object
:
IMRegisterObserverCustomNotificationCallBack
{
private
val
notificationCallback
=
object
:
IMRegisterObserverCustomNotificationCallBack
{
override
fun
onObserverCustomNotification
(
fromUid
:
String
,
toUid
:
String
,
content
:
String
)
{
override
fun
onObserverCustomNotification
(
fromUid
:
String
,
toUid
:
String
,
content
:
String
)
{
if
(
fromUid
==
listenerUid
)
{
if
(
fromUid
==
listenerUid
)
{
...
@@ -521,6 +522,12 @@ class AudioHomeActivity :
...
@@ -521,6 +522,12 @@ class AudioHomeActivity :
override
fun
initDataAndEvent
()
{
override
fun
initDataAndEvent
()
{
//状态栏颜色
//状态栏颜色
setWindowStatusBarColor
()
setWindowStatusBarColor
()
mServiceIntent
=
Intent
(
this
@AudioHomeActivity
,
FloatService
::
class
.
java
)
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
startForegroundService
(
mServiceIntent
)
}
else
{
startService
(
mServiceIntent
)
}
//初始化传感器
//初始化传感器
initSensorManager
()
initSensorManager
()
//页面传递数据初始化
//页面传递数据初始化
...
@@ -529,7 +536,10 @@ class AudioHomeActivity :
...
@@ -529,7 +536,10 @@ class AudioHomeActivity :
writeAgoraLog
(
"通话页面打开的时候,RTM登录状态码:${YDLavManager.sdkStatus}"
)
writeAgoraLog
(
"通话页面打开的时候,RTM登录状态码:${YDLavManager.sdkStatus}"
)
AliYunRichLogsHelper
.
getInstance
()
AliYunRichLogsHelper
.
getInstance
()
.
sendRichLog
(
AliYunLogConfig
.
RTM
,
"通话页面打开的时候,RTM登录状态码:${YDLavManager.sdkStatus} channelId:${channelId}"
)
.
sendRichLog
(
AliYunLogConfig
.
RTM
,
"通话页面打开的时候,RTM登录状态码:${YDLavManager.sdkStatus} channelId:${channelId}"
)
if
(
YDLavManager
.
sdkStatus
!=
Constants
.
CONNECTION_STATE_CONNECTED
)
{
if
(
YDLavManager
.
sdkStatus
!=
Constants
.
CONNECTION_STATE_CONNECTED
)
{
//再次登录声网,确保声网登录状态
//再次登录声网,确保声网登录状态
reLoginRTM
()
reLoginRTM
()
...
@@ -1597,6 +1607,7 @@ class AudioHomeActivity :
...
@@ -1597,6 +1607,7 @@ class AudioHomeActivity :
override
fun
onDestroy
()
{
override
fun
onDestroy
()
{
super
.
onDestroy
()
super
.
onDestroy
()
stopService
(
mServiceIntent
)
findRouteService
(
IImService
::
class
.
java
).
unregisterObserveCustomNotification
(
notificationCallback
)
findRouteService
(
IImService
::
class
.
java
).
unregisterObserveCustomNotification
(
notificationCallback
)
uploadLog
()
uploadLog
()
phoneHandler
?.
removeCallbacksAndMessages
(
null
)
phoneHandler
?.
removeCallbacksAndMessages
(
null
)
...
...
m-audioim/src/main/java/com/ydl/audioim/notification/FloatService.kt
0 → 100644
View file @
b9b5f70c
package
com.ydl.audioim.notification
import
android.app.*
import
android.content.Context
import
android.content.Intent
import
android.os.Build
import
android.os.IBinder
import
com.ydl.audioim.R
class
FloatService
:
Service
()
{
var
notificationManager
:
NotificationManager
?
=
null
;
var
notificationId
=
"audio_av"
;
var
notificationName
=
"正在通话中"
;
override
fun
onBind
(
intent
:
Intent
?):
IBinder
?
{
return
null
}
override
fun
onCreate
()
{
super
.
onCreate
()
notificationManager
=
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
//创建NotificationChannel
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
var
channel
=
NotificationChannel
(
notificationId
,
notificationName
,
NotificationManager
.
IMPORTANCE_HIGH
);
//不震动
channel
.
enableVibration
(
false
);
//静音
channel
.
setSound
(
null
,
null
);
notificationManager
?.
createNotificationChannel
(
channel
);
}
//创建服务后,五秒内调用该方法
startForeground
(
1
,
getNotification
());
}
/**
* 获取通知(Android8.0后需要)
* @return
*/
fun
getNotification
():
Notification
{
var
builder
=
Notification
.
Builder
(
this
)
.
setSmallIcon
(
R
.
drawable
.
dialog_list_bg
)
.
setContentTitle
(
"壹点灵"
)
.
setContentIntent
(
getIntent
())
.
setContentText
(
"正在通话中"
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
builder
.
setChannelId
(
notificationId
);
}
return
builder
.
build
();
}
/**
* 点击后,直接打开app(之前的页面),不跳转特定activity
* @return
*/
fun
getIntent
():
PendingIntent
{
var
msgIntent
=
applicationContext
.
packageManager
.
getLaunchIntentForPackage
(
packageName
);
//获取启动Activity
var
pendingIntent
=
PendingIntent
.
getActivity
(
applicationContext
,
1
,
msgIntent
,
PendingIntent
.
FLAG_UPDATE_CURRENT
);
return
pendingIntent
;
}
}
\ No newline at end of file
m-audioim/src/main/java/com/ydl/consultantim/ConsultantAudioHomeActivity.kt
View file @
b9b5f70c
...
@@ -11,6 +11,7 @@ import android.hardware.SensorEvent
...
@@ -11,6 +11,7 @@ import android.hardware.SensorEvent
import
android.hardware.SensorEventListener
import
android.hardware.SensorEventListener
import
android.hardware.SensorManager
import
android.hardware.SensorManager
import
android.net.Uri
import
android.net.Uri
import
android.os.Build
import
android.os.PowerManager
import
android.os.PowerManager
import
android.provider.Settings
import
android.provider.Settings
import
android.text.TextUtils
import
android.text.TextUtils
...
@@ -26,6 +27,7 @@ import com.ydl.audioim.R
...
@@ -26,6 +27,7 @@ import com.ydl.audioim.R
import
com.ydl.audioim.YDLavManager
import
com.ydl.audioim.YDLavManager
import
com.ydl.audioim.http.command.ConnectExceptionCommand
import
com.ydl.audioim.http.command.ConnectExceptionCommand
import
com.ydl.audioim.http.command.PayLoad
import
com.ydl.audioim.http.command.PayLoad
import
com.ydl.audioim.notification.FloatService
import
com.ydl.audioim.player.AudioPlayer
import
com.ydl.audioim.player.AudioPlayer
import
com.ydl.audioim.utils.AudioLogUtils
import
com.ydl.audioim.utils.AudioLogUtils
import
com.ydl.audioim.utils.DateUtils
import
com.ydl.audioim.utils.DateUtils
...
@@ -118,6 +120,7 @@ class ConsultantAudioHomeActivity :
...
@@ -118,6 +120,7 @@ class ConsultantAudioHomeActivity :
* 是否连接成功
* 是否连接成功
*/
*/
private
var
isConnectSuccess
:
Boolean
=
false
private
var
isConnectSuccess
:
Boolean
=
false
private
var
mServiceIntent
:
Intent
?
=
null
companion
object
{
companion
object
{
const
val
PARAM
:
String
=
"param"
const
val
PARAM
:
String
=
"param"
...
@@ -498,7 +501,12 @@ class ConsultantAudioHomeActivity :
...
@@ -498,7 +501,12 @@ class ConsultantAudioHomeActivity :
override
fun
initDataAndEvent
()
{
override
fun
initDataAndEvent
()
{
EventBus
.
getDefault
().
register
(
this
)
EventBus
.
getDefault
().
register
(
this
)
callEventSave
(
"30"
,
"进入接听界面"
)
callEventSave
(
"30"
,
"进入接听界面"
)
mServiceIntent
=
Intent
(
this
@ConsultantAudioHomeActivity
,
FloatService
::
class
.
java
)
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
startForegroundService
(
mServiceIntent
)
}
else
{
startService
(
mServiceIntent
)
}
//状态栏颜色
//状态栏颜色
setWindowStatusBarColor
()
setWindowStatusBarColor
()
//点亮屏幕 并解锁
//点亮屏幕 并解锁
...
@@ -1115,6 +1123,7 @@ class ConsultantAudioHomeActivity :
...
@@ -1115,6 +1123,7 @@ class ConsultantAudioHomeActivity :
}
}
override
fun
onDestroy
()
{
override
fun
onDestroy
()
{
stopService
(
mServiceIntent
)
LogUtil
.
e
(
"http-------------onDestory"
)
LogUtil
.
e
(
"http-------------onDestory"
)
AliYunRichLogsHelper
.
getInstance
().
sendRichLog
(
AliYunLogConfig
.
AGORA
,
"咨询用户端:onDestroy channelId:${mAudioMessageBean?.channelId}"
)
AliYunRichLogsHelper
.
getInstance
().
sendRichLog
(
AliYunLogConfig
.
AGORA
,
"咨询用户端:onDestroy channelId:${mAudioMessageBean?.channelId}"
)
...
...
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