mirror of
https://gitee.com/farsunset/cim.git
synced 2025-06-17 07:35:25 +08:00
修改android版sdk Not allowed to delete channel with a foreground service 的问题
This commit is contained in:
parent
538f80cee1
commit
560da9bebe
@ -6,12 +6,12 @@
|
||||
|
||||
<groupId>com.farsunset</groupId>
|
||||
<artifactId>cim-android-sdk</artifactId>
|
||||
<version>4.2.6</version>
|
||||
<version>4.2.7</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>${project.groupId}:${project.artifactId}</name>
|
||||
<description>Netty based instant messaging android sdk</description>
|
||||
<url>https://github.com/farsunset/cim</url>
|
||||
<url>http://farsunset.com</url>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
|
@ -167,7 +167,7 @@ class CIMConnectorManager {
|
||||
return socketChannel != null && socketChannel.isConnected();
|
||||
}
|
||||
|
||||
public void sendHeartbeat() {
|
||||
public void pong() {
|
||||
send(Pong.getInstance());
|
||||
}
|
||||
|
||||
@ -270,7 +270,7 @@ class CIMConnectorManager {
|
||||
private final Handler idleHandler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(android.os.Message m) {
|
||||
workerExecutor.execute(() -> onSessionIdle());
|
||||
workerExecutor.execute(CIMConnectorManager.this::onSessionIdle);
|
||||
}
|
||||
};
|
||||
|
||||
@ -283,7 +283,7 @@ class CIMConnectorManager {
|
||||
/*
|
||||
* 随机3-10秒后重连
|
||||
*/
|
||||
long interval = 3000 + random.nextInt(7001) ;
|
||||
long interval = 3000L + random.nextInt(7001) ;
|
||||
|
||||
LOGGER.connectFailure(interval);
|
||||
|
||||
|
@ -333,8 +333,7 @@ public class CIMPushManager {
|
||||
try {
|
||||
PackageInfo mPackageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
|
||||
return mPackageInfo.versionName;
|
||||
} catch (NameNotFoundException ignore) {
|
||||
}
|
||||
} catch (NameNotFoundException ignore) {}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,6 @@ public class CIMPushService extends Service {
|
||||
private NotificationManager notificationManager;
|
||||
private final AtomicBoolean persistHolder = new AtomicBoolean(false);
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
|
||||
@ -177,7 +176,6 @@ public class CIMPushService extends Service {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
connectHandler.removeMessages(0);
|
||||
|
||||
connectHandler.sendEmptyMessageDelayed(0, delayMillis);
|
||||
@ -206,7 +204,7 @@ public class CIMPushService extends Service {
|
||||
CIMLogger.getLogger().connectState(true, CIMPushManager.isStopped(this), CIMPushManager.isDestroyed(this));
|
||||
|
||||
if (connectorManager.isConnected()) {
|
||||
connectorManager.sendHeartbeat();
|
||||
connectorManager.pong();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -239,6 +237,11 @@ public class CIMPushService extends Service {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
connectivityManager.unregisterNetworkCallback(networkCallback);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && notificationManager.getNotificationChannel(PERSIST_NTC_CHANNEL_ID) != null) {
|
||||
notificationManager.deleteNotificationChannel(TRANSIENT_NTC_CHANNEL_ID);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void createTransientNotification() {
|
||||
@ -282,10 +285,8 @@ public class CIMPushService extends Service {
|
||||
channel.enableVibration(false);
|
||||
channel.setSound(null, null);
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
notificationManager.deleteNotificationChannel(TRANSIENT_NTC_CHANNEL_ID);
|
||||
}
|
||||
|
||||
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
|
||||
intent.setPackage(getPackageName());
|
||||
|
@ -34,7 +34,7 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "com.farsunset:cim-android-sdk:4.2.5"
|
||||
implementation "com.farsunset:cim-android-sdk:4.2.7"
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||
implementation 'com.google.android.material:material:1.2.1'
|
||||
implementation 'androidx.annotation:annotation:1.1.0'
|
||||
|
Loading…
x
Reference in New Issue
Block a user