mirror of
https://gitee.com/farsunset/cim.git
synced 2025-08-01 12:28:00 +08:00
android sdk适配android 15
This commit is contained in:
parent
4a68b47fdb
commit
3634392e7f
@ -65,5 +65,5 @@ CIM采用业内主流开源技术构建,易于扩展和使用,并完美支
|
|||||||
android端sdk引用
|
android端sdk引用
|
||||||
|
|
||||||
```
|
```
|
||||||
implementation "com.farsunset:cim-android-sdk:4.2.13"
|
implementation "com.farsunset:cim-android-sdk:4.2.15"
|
||||||
```
|
```
|
Binary file not shown.
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.farsunset</groupId>
|
<groupId>com.farsunset</groupId>
|
||||||
<artifactId>cim-android-sdk</artifactId>
|
<artifactId>cim-android-sdk</artifactId>
|
||||||
<version>4.2.13</version>
|
<version>4.2.15</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>${project.groupId}:${project.artifactId}</name>
|
<name>${project.groupId}:${project.artifactId}</name>
|
||||||
@ -29,7 +29,7 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<google.protobuf.version>3.22.0</google.protobuf.version>
|
<google.protobuf.version>3.25.4</google.protobuf.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -45,7 +45,7 @@
|
|||||||
<groupId>android</groupId>
|
<groupId>android</groupId>
|
||||||
<artifactId>android</artifactId>
|
<artifactId>android</artifactId>
|
||||||
<scope>system</scope>
|
<scope>system</scope>
|
||||||
<version>10.0.0</version>
|
<version>15.0.0</version>
|
||||||
<systemPath>${project.basedir}/libs/android.jar</systemPath>
|
<systemPath>${project.basedir}/libs/android.jar</systemPath>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -43,13 +43,13 @@ class CIMCacheManager {
|
|||||||
|
|
||||||
public static final String KEY_CIM_CONNECTION_STATE = "KEY_CIM_CONNECTION_STATE";
|
public static final String KEY_CIM_CONNECTION_STATE = "KEY_CIM_CONNECTION_STATE";
|
||||||
|
|
||||||
|
public static final String KEY_NTC_SWITCH = "KEY_NTC_SWITCH";
|
||||||
|
|
||||||
public static final String KEY_NTC_CHANNEL_NAME = "KEY_NTC_CHANNEL_NAME";
|
public static final String KEY_NTC_CHANNEL_NAME = "KEY_NTC_CHANNEL_NAME";
|
||||||
|
|
||||||
public static final String KEY_NTC_CHANNEL_MESSAGE = "KEY_NTC_CHANNEL_MESSAGE";
|
public static final String KEY_NTC_CHANNEL_MESSAGE = "KEY_NTC_CHANNEL_MESSAGE";
|
||||||
|
|
||||||
public static final String KEY_NTC_CHANNEL_ICON = "KEY_NTC_CHANNEL_ICON";
|
public static final String KEY_NTC_CHANNEL_ICON = "KEY_NTC_ICON";
|
||||||
|
|
||||||
|
|
||||||
public static final String CONTENT_URI = "content://%s.cim.provider";
|
public static final String CONTENT_URI = "content://%s.cim.provider";
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ public abstract class CIMEventBroadcastReceiver extends BroadcastReceiver {
|
|||||||
private void connect(long delay) {
|
private void connect(long delay) {
|
||||||
Intent serviceIntent = new Intent(context, CIMPushService.class);
|
Intent serviceIntent = new Intent(context, CIMPushService.class);
|
||||||
serviceIntent.putExtra(BundleKey.KEY_DELAYED_TIME, delay);
|
serviceIntent.putExtra(BundleKey.KEY_DELAYED_TIME, delay);
|
||||||
serviceIntent.setAction(ServiceAction.ACTION_CREATE_CIM_CONNECTION);
|
serviceIntent.setAction(ServiceAction.ACTION_CREATE_CONNECTION);
|
||||||
CIMPushManager.startService(context, serviceIntent);
|
CIMPushManager.startService(context, serviceIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ public class CIMPushManager {
|
|||||||
|
|
||||||
|
|
||||||
Intent serviceIntent = new Intent(context, CIMPushService.class);
|
Intent serviceIntent = new Intent(context, CIMPushService.class);
|
||||||
serviceIntent.setAction(ServiceAction.ACTION_CREATE_CIM_CONNECTION);
|
serviceIntent.setAction(ServiceAction.ACTION_CREATE_CONNECTION);
|
||||||
startService(context, serviceIntent);
|
startService(context, serviceIntent);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -172,7 +172,7 @@ public class CIMPushManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Intent serviceIntent = new Intent(context, CIMPushService.class);
|
Intent serviceIntent = new Intent(context, CIMPushService.class);
|
||||||
serviceIntent.setAction(ServiceAction.ACTION_CIM_CONNECTION_PONG);
|
serviceIntent.setAction(ServiceAction.ACTION_CREATE_CONNECTION);
|
||||||
startService(context, serviceIntent);
|
startService(context, serviceIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ public class CIMPushManager {
|
|||||||
CIMCacheManager.putBoolean(context, CIMCacheManager.KEY_MANUAL_STOP, true);
|
CIMCacheManager.putBoolean(context, CIMCacheManager.KEY_MANUAL_STOP, true);
|
||||||
|
|
||||||
Intent serviceIntent = new Intent(context, CIMPushService.class);
|
Intent serviceIntent = new Intent(context, CIMPushService.class);
|
||||||
serviceIntent.setAction(ServiceAction.ACTION_CLOSE_CIM_CONNECTION);
|
serviceIntent.setAction(ServiceAction.ACTION_CREATE_CONNECTION);
|
||||||
startService(context, serviceIntent);
|
startService(context, serviceIntent);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -253,7 +253,7 @@ public class CIMPushManager {
|
|||||||
CIMCacheManager.remove(context, CIMCacheManager.KEY_UID);
|
CIMCacheManager.remove(context, CIMCacheManager.KEY_UID);
|
||||||
|
|
||||||
Intent serviceIntent = new Intent(context, CIMPushService.class);
|
Intent serviceIntent = new Intent(context, CIMPushService.class);
|
||||||
serviceIntent.setAction(ServiceAction.ACTION_DESTROY_CIM_SERVICE);
|
serviceIntent.setAction(ServiceAction.ACTION_CREATE_CONNECTION);
|
||||||
startService(context, serviceIntent);
|
startService(context, serviceIntent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@ import com.farsunset.cim.sdk.android.model.Pong;
|
|||||||
import com.farsunset.cim.sdk.android.model.SentBody;
|
import com.farsunset.cim.sdk.android.model.SentBody;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 与服务端连接服务
|
* 与服务端连接服务
|
||||||
@ -49,9 +50,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
*/
|
*/
|
||||||
public class CIMPushService extends Service {
|
public class CIMPushService extends Service {
|
||||||
|
|
||||||
private static final String TRANSIENT_NTC_CHANNEL_ID = "CIM_PUSH_TRANSIENT_NTC_ID";
|
private static final String TRANSIENT_NTC_CHANNEL_ID = "PUSH_TRANSIENT_NTC_ID";
|
||||||
private static final String PERSIST_NTC_CHANNEL_ID = "CIM_PUSH_PERSIST_NTC_ID";
|
private static final String PERSIST_NTC_CHANNEL_ID = "PUSH_PERSIST_NTC_ID";
|
||||||
|
|
||||||
private static final int NOTIFICATION_ID = Integer.MAX_VALUE;
|
private static final int NOTIFICATION_ID = Integer.MAX_VALUE;
|
||||||
|
|
||||||
private CIMConnectManager connectManager;
|
private CIMConnectManager connectManager;
|
||||||
@ -59,7 +59,6 @@ public class CIMPushService extends Service {
|
|||||||
private KeepAliveBroadcastReceiver keepAliveReceiver;
|
private KeepAliveBroadcastReceiver keepAliveReceiver;
|
||||||
private ConnectivityManager connectivityManager;
|
private ConnectivityManager connectivityManager;
|
||||||
private NotificationManager notificationManager;
|
private NotificationManager notificationManager;
|
||||||
private final AtomicBoolean persistHolder = new AtomicBoolean(false);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
@ -68,30 +67,26 @@ public class CIMPushService extends Service {
|
|||||||
|
|
||||||
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
keepAliveReceiver = new KeepAliveBroadcastReceiver();
|
||||||
keepAliveReceiver = new KeepAliveBroadcastReceiver();
|
|
||||||
registerReceiver(keepAliveReceiver, keepAliveReceiver.getIntentFilter());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
this.registerReceiver(keepAliveReceiver, keepAliveReceiver.getIntentFilter());
|
||||||
|
|
||||||
connectivityManager = getSystemService(ConnectivityManager.class);
|
connectivityManager = getSystemService(ConnectivityManager.class);
|
||||||
|
|
||||||
connectivityManager.registerDefaultNetworkCallback(networkCallback);
|
connectivityManager.registerDefaultNetworkCallback(networkCallback);
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ConnectivityManager.NetworkCallback networkCallback = new ConnectivityManager.NetworkCallback() {
|
private final ConnectivityManager.NetworkCallback networkCallback = new ConnectivityManager.NetworkCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onAvailable(Network network) {
|
public void onAvailable(Network network) {
|
||||||
sendBroadcast(new Intent(IntentAction.ACTION_NETWORK_CHANGED));
|
sendBroadcast(new Intent(IntentAction.ACTION_NETWORK_CHANGED).setPackage(getPackageName()));
|
||||||
handleKeepAlive();
|
handleKeepAlive();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLost(Network network) {
|
public void onLost(Network network) {
|
||||||
sendBroadcast(new Intent(IntentAction.ACTION_NETWORK_CHANGED));
|
sendBroadcast(new Intent(IntentAction.ACTION_NETWORK_CHANGED).setPackage(getPackageName()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -105,16 +100,15 @@ public class CIMPushService extends Service {
|
|||||||
private final Handler notificationHandler = new Handler() {
|
private final Handler notificationHandler = new Handler() {
|
||||||
@Override
|
@Override
|
||||||
public void handleMessage(android.os.Message message) {
|
public void handleMessage(android.os.Message message) {
|
||||||
if (persistHolder.get()){
|
if (!CIMCacheManager.getBoolean(CIMPushService.this,CIMCacheManager.KEY_NTC_SWITCH)){
|
||||||
return;
|
stopForeground(true);
|
||||||
}
|
}
|
||||||
stopForeground(true);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
|
public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
return super.registerReceiver(keepAliveReceiver, keepAliveReceiver.getIntentFilter(),Context.RECEIVER_EXPORTED);
|
return super.registerReceiver(keepAliveReceiver, keepAliveReceiver.getIntentFilter(),Context.RECEIVER_EXPORTED);
|
||||||
}else {
|
}else {
|
||||||
return super.registerReceiver(keepAliveReceiver, keepAliveReceiver.getIntentFilter());
|
return super.registerReceiver(keepAliveReceiver, keepAliveReceiver.getIntentFilter());
|
||||||
@ -136,9 +130,9 @@ public class CIMPushService extends Service {
|
|||||||
|
|
||||||
String action = newIntent.getAction();
|
String action = newIntent.getAction();
|
||||||
|
|
||||||
createTransientNotification(newIntent);
|
createTransientNotification();
|
||||||
|
|
||||||
if (ServiceAction.ACTION_CREATE_CIM_CONNECTION.equals(action)) {
|
if (ServiceAction.ACTION_CREATE_CONNECTION.equals(action)) {
|
||||||
this.prepareConnect(newIntent.getLongExtra(BundleKey.KEY_DELAYED_TIME, 0));
|
this.prepareConnect(newIntent.getLongExtra(BundleKey.KEY_DELAYED_TIME, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +140,7 @@ public class CIMPushService extends Service {
|
|||||||
connectManager.send((SentBody) newIntent.getSerializableExtra(BundleKey.KEY_SEND_BODY));
|
connectManager.send((SentBody) newIntent.getSerializableExtra(BundleKey.KEY_SEND_BODY));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ServiceAction.ACTION_CLOSE_CIM_CONNECTION.equals(action)) {
|
if (ServiceAction.ACTION_CLOSE_CONNECTION.equals(action)) {
|
||||||
connectManager.close();
|
connectManager.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,12 +148,12 @@ public class CIMPushService extends Service {
|
|||||||
handleKeepAlive();
|
handleKeepAlive();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ServiceAction.ACTION_DESTROY_CIM_SERVICE.equals(action)) {
|
if (ServiceAction.ACTION_DESTROY_SERVICE.equals(action)) {
|
||||||
connectManager.close();
|
connectManager.close();
|
||||||
this.stopSelf();
|
this.stopSelf();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ServiceAction.ACTION_CIM_CONNECTION_PONG.equals(action)) {
|
if (ServiceAction.ACTION_CONNECTION_PONG.equals(action)) {
|
||||||
connectManager.send(Pong.getInstance());
|
connectManager.send(Pong.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,21 +162,20 @@ public class CIMPushService extends Service {
|
|||||||
CIMLogger.getLogger().debugMode(enable);
|
CIMLogger.getLogger().debugMode(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ServiceAction.ACTION_HIDE_PERSIST_NOTIFICATION.equals(action)) {
|
||||||
|
this.stopForeground(true);
|
||||||
|
CIMCacheManager.putBoolean(this, CIMCacheManager.KEY_NTC_SWITCH,false);
|
||||||
|
}
|
||||||
|
|
||||||
if (ServiceAction.ACTION_SHOW_PERSIST_NOTIFICATION.equals(action)) {
|
if (ServiceAction.ACTION_SHOW_PERSIST_NOTIFICATION.equals(action)) {
|
||||||
createPersistNotification(newIntent.getStringExtra(BundleKey.KEY_NOTIFICATION_CHANNEL),
|
createPersistNotification(newIntent.getStringExtra(BundleKey.KEY_NOTIFICATION_CHANNEL),
|
||||||
newIntent.getStringExtra(BundleKey.KEY_NOTIFICATION_MESSAGE),
|
newIntent.getStringExtra(BundleKey.KEY_NOTIFICATION_MESSAGE),
|
||||||
newIntent.getIntExtra(BundleKey.KEY_NOTIFICATION_ICON,0));
|
newIntent.getIntExtra(BundleKey.KEY_NOTIFICATION_ICON,0));
|
||||||
persistHolder.set(true);
|
|
||||||
|
return super.onStartCommand(intent,flags,startId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ServiceAction.ACTION_HIDE_PERSIST_NOTIFICATION.equals(action)) {
|
notificationHandler.sendEmptyMessageDelayed(0, 200);
|
||||||
stopForeground(true);
|
|
||||||
persistHolder.set(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
||||||
notificationHandler.sendEmptyMessageDelayed(0, 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.onStartCommand(intent,flags,startId);
|
return super.onStartCommand(intent,flags,startId);
|
||||||
}
|
}
|
||||||
@ -208,7 +201,7 @@ public class CIMPushService extends Service {
|
|||||||
String host = CIMCacheManager.getString(this, CIMCacheManager.KEY_CIM_SERVER_HOST);
|
String host = CIMCacheManager.getString(this, CIMCacheManager.KEY_CIM_SERVER_HOST);
|
||||||
int port = CIMCacheManager.getInt(this, CIMCacheManager.KEY_CIM_SERVER_PORT);
|
int port = CIMCacheManager.getInt(this, CIMCacheManager.KEY_CIM_SERVER_PORT);
|
||||||
|
|
||||||
if (host == null || host.trim().length() == 0 || port <= 0) {
|
if (host == null || host.trim().isEmpty() || port <= 0) {
|
||||||
Log.e(this.getClass().getSimpleName(), "Invalid hostname or port. host:" + host + " port:" + port);
|
Log.e(this.getClass().getSimpleName(), "Invalid hostname or port. host:" + host + " port:" + port);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -242,39 +235,18 @@ public class CIMPushService extends Service {
|
|||||||
|
|
||||||
stopForeground(true);
|
stopForeground(true);
|
||||||
|
|
||||||
persistHolder.set(false);
|
unregisterReceiver(keepAliveReceiver);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
||||||
unregisterReceiver(keepAliveReceiver);
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
connectivityManager.unregisterNetworkCallback(networkCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createTransientNotification(Intent intent) {
|
private void createTransientNotification() {
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O || persistHolder.get()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (ServiceAction.ACTION_SHOW_PERSIST_NOTIFICATION.equals(intent.getAction())
|
|
||||||
|| ServiceAction.ACTION_HIDE_PERSIST_NOTIFICATION.equals(intent.getAction())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (notificationManager.getNotificationChannel(PERSIST_NTC_CHANNEL_ID) != null) {
|
if (notificationManager.getNotificationChannel(PERSIST_NTC_CHANNEL_ID) != null) {
|
||||||
|
|
||||||
int icon = CIMCacheManager.getInt(this,CIMCacheManager.KEY_NTC_CHANNEL_ICON);
|
int icon = CIMCacheManager.getInt(this, CIMCacheManager.KEY_NTC_CHANNEL_ICON);
|
||||||
String title = CIMCacheManager.getString(this,CIMCacheManager.KEY_NTC_CHANNEL_NAME);
|
String title = CIMCacheManager.getString(this, CIMCacheManager.KEY_NTC_CHANNEL_NAME);
|
||||||
String message = CIMCacheManager.getString(this,CIMCacheManager.KEY_NTC_CHANNEL_MESSAGE);
|
String message = CIMCacheManager.getString(this, CIMCacheManager.KEY_NTC_CHANNEL_MESSAGE);
|
||||||
|
|
||||||
Notification notification = makeNotification(PERSIST_NTC_CHANNEL_ID,icon,title,message);
|
Notification notification = makeNotification(PERSIST_NTC_CHANNEL_ID,icon,title,message);
|
||||||
|
|
||||||
@ -291,7 +263,7 @@ public class CIMPushService extends Service {
|
|||||||
notificationManager.createNotificationChannel(channel);
|
notificationManager.createNotificationChannel(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
Notification notification = makeNotification(TRANSIENT_NTC_CHANNEL_ID,0,CIMPushService.class.getSimpleName(),null);
|
Notification notification = makeNotification(TRANSIENT_NTC_CHANNEL_ID,0, CIMPushService.class.getSimpleName(),null);
|
||||||
|
|
||||||
startForegroundNotification(NOTIFICATION_ID, notification);
|
startForegroundNotification(NOTIFICATION_ID, notification);
|
||||||
|
|
||||||
@ -300,11 +272,12 @@ public class CIMPushService extends Service {
|
|||||||
|
|
||||||
private void createPersistNotification(String channelName ,String message,int icon) {
|
private void createPersistNotification(String channelName ,String message,int icon) {
|
||||||
|
|
||||||
CIMCacheManager.putString(this,CIMCacheManager.KEY_NTC_CHANNEL_NAME,channelName);
|
CIMCacheManager.putString(this, CIMCacheManager.KEY_NTC_CHANNEL_NAME,channelName);
|
||||||
CIMCacheManager.putString(this,CIMCacheManager.KEY_NTC_CHANNEL_MESSAGE,message);
|
CIMCacheManager.putString(this, CIMCacheManager.KEY_NTC_CHANNEL_MESSAGE,message);
|
||||||
CIMCacheManager.putInt(this,CIMCacheManager.KEY_NTC_CHANNEL_ICON,icon);
|
CIMCacheManager.putInt(this, CIMCacheManager.KEY_NTC_CHANNEL_ICON,icon);
|
||||||
|
CIMCacheManager.putBoolean(this, CIMCacheManager.KEY_NTC_SWITCH,true);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && notificationManager.getNotificationChannel(PERSIST_NTC_CHANNEL_ID) == null) {
|
if (notificationManager.getNotificationChannel(PERSIST_NTC_CHANNEL_ID) == null) {
|
||||||
NotificationChannel channel = new NotificationChannel(PERSIST_NTC_CHANNEL_ID,channelName, NotificationManager.IMPORTANCE_DEFAULT);
|
NotificationChannel channel = new NotificationChannel(PERSIST_NTC_CHANNEL_ID,channelName, NotificationManager.IMPORTANCE_DEFAULT);
|
||||||
channel.enableLights(false);
|
channel.enableLights(false);
|
||||||
channel.setShowBadge(false);
|
channel.setShowBadge(false);
|
||||||
@ -322,18 +295,14 @@ public class CIMPushService extends Service {
|
|||||||
private Notification makeNotification(String channel,int icon,String title,String message){
|
private Notification makeNotification(String channel,int icon,String title,String message){
|
||||||
|
|
||||||
Notification.Builder builder;
|
Notification.Builder builder;
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
|
builder = new Notification.Builder(this, channel);
|
||||||
builder = new Notification.Builder(this,channel);
|
|
||||||
}else {
|
|
||||||
builder = new Notification.Builder(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.setAutoCancel(false)
|
builder.setAutoCancel(false)
|
||||||
.setOngoing(false)
|
.setOngoing(false)
|
||||||
.setWhen(System.currentTimeMillis())
|
.setWhen(System.currentTimeMillis())
|
||||||
.setContentIntent(getPendingIntent())
|
.setContentIntent(getPendingIntent())
|
||||||
.setContentTitle(title)
|
.setContentTitle(title)
|
||||||
.setContentText(message);
|
.setContentText(message);
|
||||||
|
|
||||||
if (icon > 0){
|
if (icon > 0){
|
||||||
builder.setSmallIcon(icon);
|
builder.setSmallIcon(icon);
|
||||||
|
@ -23,15 +23,15 @@ package com.farsunset.cim.sdk.android.constant;
|
|||||||
|
|
||||||
public interface ServiceAction {
|
public interface ServiceAction {
|
||||||
|
|
||||||
String ACTION_CREATE_CIM_CONNECTION = "ACTION_CREATE_CIM_CONNECTION";
|
String ACTION_CREATE_CONNECTION = "ACTION_CREATE_CONNECTION";
|
||||||
|
|
||||||
String ACTION_DESTROY_CIM_SERVICE = "ACTION_DESTROY_CIM_SERVICE";
|
String ACTION_DESTROY_SERVICE = "ACTION_DESTROY_SERVICE";
|
||||||
|
|
||||||
String ACTION_ACTIVATE_PUSH_SERVICE = "ACTION_ACTIVATE_PUSH_SERVICE";
|
String ACTION_ACTIVATE_PUSH_SERVICE = "ACTION_ACTIVATE_PUSH_SERVICE";
|
||||||
|
|
||||||
String ACTION_SEND_REQUEST_BODY = "ACTION_SEND_REQUEST_BODY";
|
String ACTION_SEND_REQUEST_BODY = "ACTION_SEND_REQUEST_BODY";
|
||||||
|
|
||||||
String ACTION_CLOSE_CIM_CONNECTION = "ACTION_CLOSE_CIM_CONNECTION";
|
String ACTION_CLOSE_CONNECTION = "ACTION_CLOSE_CONNECTION";
|
||||||
|
|
||||||
String ACTION_SET_LOGGER_EATABLE = "ACTION_SET_LOGGER_EATABLE";
|
String ACTION_SET_LOGGER_EATABLE = "ACTION_SET_LOGGER_EATABLE";
|
||||||
|
|
||||||
@ -39,6 +39,5 @@ public interface ServiceAction {
|
|||||||
|
|
||||||
String ACTION_HIDE_PERSIST_NOTIFICATION = "ACTION_HIDE_PERSIST_NOTIFICATION";
|
String ACTION_HIDE_PERSIST_NOTIFICATION = "ACTION_HIDE_PERSIST_NOTIFICATION";
|
||||||
|
|
||||||
String ACTION_CIM_CONNECTION_PONG = "ACTION_CIM_CONNECTION_PONG";
|
String ACTION_CONNECTION_PONG = "ACTION_CONNECTION_PONG";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,26 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 33
|
namespace 'com.farsunset.cim'
|
||||||
buildToolsVersion '33.0.0'
|
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.farsunset.cim"
|
applicationId "com.farsunset.cim"
|
||||||
minSdkVersion 23
|
minSdkVersion 23
|
||||||
targetSdkVersion 33
|
targetSdkVersion 35
|
||||||
|
compileSdk 35
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
CIM服务器,IP修改为自己的服务器IP
|
CIM服务器,IP修改为自己的服务器IP
|
||||||
*/
|
*/
|
||||||
buildConfigField("String", "CIM_API_URL", '"http://192.168.31.175:8080"')
|
buildConfigField("String", "CIM_API_URL", '"http://114.215.199.17:8080"')
|
||||||
buildConfigField("String", "CIM_SERVER_HOST", '"192.168.31.175"')
|
buildConfigField("String", "CIM_SERVER_HOST", '"114.215.199.17"')
|
||||||
buildConfigField("Integer", "CIM_SERVER_PORT", '23456')
|
buildConfigField("Integer", "CIM_SERVER_PORT", '34567')
|
||||||
|
}
|
||||||
|
|
||||||
|
buildFeatures {
|
||||||
|
buildConfig = true
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
@ -32,12 +36,13 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "com.farsunset:cim-android-sdk:4.2.13"
|
implementation 'androidx.appcompat:appcompat:1.7.1'
|
||||||
implementation 'androidx.appcompat:appcompat:1.6.0'
|
implementation 'com.google.android.material:material:1.12.0'
|
||||||
implementation 'com.google.android.material:material:1.8.0'
|
implementation 'androidx.annotation:annotation:1.9.1'
|
||||||
implementation 'androidx.annotation:annotation:1.3.0'
|
implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
implementation 'com.google.protobuf:protobuf-javalite:3.25.4'
|
||||||
implementation 'com.google.protobuf:protobuf-javalite:3.22.0'
|
implementation 'com.squareup.retrofit2:retrofit:3.0.0'
|
||||||
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
implementation 'com.squareup.retrofit2:converter-gson:3.0.0'
|
||||||
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
|
implementation "com.farsunset:cim-android-sdk:4.2.15"
|
||||||
|
|
||||||
}
|
}
|
@ -2,6 +2,7 @@
|
|||||||
<!-- Base application theme. -->
|
<!-- Base application theme. -->
|
||||||
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
|
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
|
||||||
<!-- Primary brand color. -->
|
<!-- Primary brand color. -->
|
||||||
|
<item name="android:windowOptOutEdgeToEdgeEnforcement" tools:targetApi="35">true</item>
|
||||||
|
|
||||||
<item name="colorPrimary">#FFFFFF</item>
|
<item name="colorPrimary">#FFFFFF</item>
|
||||||
<item name="colorAccent">#0CB069</item>
|
<item name="colorAccent">#0CB069</item>
|
||||||
|
@ -1,27 +1,3 @@
|
|||||||
buildscript {
|
plugins {
|
||||||
repositories {
|
id 'com.android.application' version '8.9.1' apply false
|
||||||
google()
|
|
||||||
jcenter()
|
|
||||||
mavenCentral()
|
|
||||||
maven{ url'https://maven.aliyun.com/repository/central' }
|
|
||||||
maven{ url'https://maven.aliyun.com/repository/google' }
|
|
||||||
maven{ url'https://maven.aliyun.com/repository/public' }
|
|
||||||
maven{ url'https://maven.aliyun.com/repository/gradle-plugin' }
|
|
||||||
maven { url "https://jitpack.io" }
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath 'com.android.tools.build:gradle:7.4.0'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
allprojects {
|
|
||||||
repositories {
|
|
||||||
google()
|
|
||||||
jcenter()
|
|
||||||
mavenCentral()
|
|
||||||
maven { url "https://jitpack.io" }
|
|
||||||
maven{ url'https://maven.aliyun.com/repository/central' }
|
|
||||||
maven{ url'https://maven.aliyun.com/repository/google' }
|
|
||||||
maven{ url'https://maven.aliyun.com/repository/public' }
|
|
||||||
maven{ url'https://maven.aliyun.com/repository/gradle-plugin' }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#Wed Feb 15 10:18:48 CST 2023
|
#Mon Jun 09 11:38:39 CST 2025
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
|
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStorePath=wrapper/dists
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
|
@ -1,2 +1,27 @@
|
|||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
maven { url "https://jitpack.io" }
|
||||||
|
maven{ url'https://maven.aliyun.com/repository/central' }
|
||||||
|
maven{ url'https://maven.aliyun.com/repository/google' }
|
||||||
|
maven{ url'https://maven.aliyun.com/repository/public' }
|
||||||
|
maven{ url'https://maven.aliyun.com/repository/gradle-plugin' }
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dependencyResolutionManagement {
|
||||||
|
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
maven { url "https://jitpack.io" }
|
||||||
|
maven{ url'https://maven.aliyun.com/repository/central' }
|
||||||
|
maven{ url'https://maven.aliyun.com/repository/google' }
|
||||||
|
maven{ url'https://maven.aliyun.com/repository/public' }
|
||||||
|
maven{ url'https://maven.aliyun.com/repository/gradle-plugin' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
include ':app'
|
include ':app'
|
||||||
rootProject.name = "cim-client-android"
|
rootProject.name = "cim-client-android"
|
Loading…
x
Reference in New Issue
Block a user