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