From ede335411834de32235fdad8cc0b845e8eb264d9 Mon Sep 17 00:00:00 2001 From: tongtongstudio Date: Thu, 25 Jun 2026 09:20:04 +0800 Subject: [PATCH] =?UTF-8?q?build:=20=E6=B2=A1=E4=BF=AE=E6=94=B9=E4=B9=8B?= =?UTF-8?q?=E5=89=8D=E7=9A=84=E4=BB=A3=E7=A0=81=E5=8D=87=E7=BA=A7agp8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 157 ++++----- app/src/main/AndroidManifest.xml | 32 +- .../com/fuying/sn/base/BaseApplication.java | 36 --- .../java/com/fuying/sn/dialog/InfoDialog.java | 2 +- .../sn/network/NetInterfaceManager.java | 27 +- .../com/fuying/sn/network/UrlAddress.java | 3 - .../com/fuying/sn/push/tpush/Constants.java | 17 - .../fuying/sn/push/tpush/MessageReceiver.java | 297 ------------------ .../sn/push/tpush/common/DBOpenHelper.java | 23 -- .../tpush/common/NotificationService.java | 134 -------- .../sn/push/tpush/po/XGNotification.java | 83 ----- .../com/fuying/sn/service/RemoteService.java | 35 --- .../fuying/sn/service/main/MainService.java | 37 --- app/tpns-configs.json | 14 - build.gradle | 49 ++- gradle/wrapper/gradle-wrapper.properties | 2 +- 16 files changed, 111 insertions(+), 837 deletions(-) delete mode 100644 app/src/main/java/com/fuying/sn/push/tpush/Constants.java delete mode 100644 app/src/main/java/com/fuying/sn/push/tpush/MessageReceiver.java delete mode 100644 app/src/main/java/com/fuying/sn/push/tpush/common/DBOpenHelper.java delete mode 100644 app/src/main/java/com/fuying/sn/push/tpush/common/NotificationService.java delete mode 100644 app/src/main/java/com/fuying/sn/push/tpush/po/XGNotification.java delete mode 100644 app/tpns-configs.json diff --git a/app/build.gradle b/app/build.gradle index b236b8b..4d950c2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,31 +1,18 @@ apply plugin: 'com.android.application' -apply plugin: "com.tencent.android.tpns" static def appName() { return "FLYSN" } static def releaseTime() { - return new Date().format("yyyyMMdd-HHmmss", TimeZone.getDefault()) + return new Date().format("yyyyMMdd_HHmmss", TimeZone.getDefault()) } android { -// gradle.projectsEvaluated { -// tasks.withType(JavaCompile) { -// Set fileSet = options.bootstrapClasspath.getFiles() -// List newFileList = new ArrayList<>(); -// //JAVA语法,可连续调用,输入参数建议为相对路径 -// newFileList.add(new File("libs/framework.jar")) -// //最后将原始参数添加 -// newFileList.addAll(fileSet) -// options.bootstrapClasspath = files( -// newFileList.toArray() -// ) -// } -// } + namespace "com.fuying.sn" compileSdkVersion 29 - buildToolsVersion "29.0.3" + buildToolsVersion "36.0.0" defaultConfig { applicationId "com.fuying.sn" @@ -41,45 +28,54 @@ android { // 还可以添加 'x86', 'x86_64', 'mips', 'mips64' } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - javaCompileOptions { - annotationProcessorOptions { - includeCompileClasspath true - } - } - lintOptions { checkReleaseBuilds false - } - - dataBinding { - enabled true + // Or, if you prefer, you can continue to check for errors in release builds, + // but continue the build even when errors are found: + abortOnError false } manifestPlaceholders = [ XG_ACCESS_ID : "1500031216", XG_ACCESS_KEY: "A1HBG2922B9Z", ] - buildConfigField "String", "SCREEN_URL", '"https://as.fuyingy.com:3018/wm/is_online"' - buildConfigField "String", "WEBSOCKET_URL", '"wss://47.111.23.154:3018"' + + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + buildFeatures { + dataBinding true + buildConfig true + aidl true } //多版本 productFlavors { -// beta { -// flavorDimensions "default" -// versionCode 33 -// versionName "4.2" -// } + beta { + flavorDimensions "default" + versionCode 89 + versionName "4.3" +// applicationId "com.fuying.sn" + applicationId "com.fying.sntest" + + buildConfigField "String", "ROOT_URL", '"https://fxyapi.17hxg.com/android/"' + buildConfigField "String", "SCREEN_URL", '"https://fxyapi.17hxg.com:3018/wm/is_online"' +// buildConfigField "String", "WEBSOCKET_URL", '"wss://47.111.23.154:3018"' + } official { flavorDimensions "default" versionCode 87 versionName "3.4.7" + applicationId "com.fuying.sn" + + buildConfigField "String", "ROOT_URL", '"https://as.fuyingy.com/android/"' + buildConfigField "String", "SCREEN_URL", '"https://as.fuyingy.com:3018/wm/is_online"' +// buildConfigField "String", "WEBSOCKET_URL", '"wss://47.111.23.154:3018"' } } @@ -450,48 +446,28 @@ android { debug { buildConfigField "String", "platform", '"MTK"' versionNameSuffix "-debug" - //Zipalign优化 - zipAlignEnabled true minifyEnabled false signingConfig signingConfigs.mtk - applicationVariants.all { variant -> - variant.outputs.each { output -> - if (outputFile != null) { - def fileName = "${appName()}-${variant.versionCode}-V${variant.versionName}-${releaseTime()}-${buildType.name}.apk" - output.outputFileName = fileName - } - } - } } release { buildConfigField "String", "platform", '"MTK"' - //Zipalign优化 - zipAlignEnabled true - //混淆 minifyEnabled false - //前一部分代表系统默认的android程序的混淆文件,该文件已经包含了基本的混淆声明,后一个文件是自己的定义混淆文件 - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - //签名 + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' signingConfig signingConfigs.mtk -// 将release版本的包名重命名,加上版本及日期 - applicationVariants.all { variant -> - variant.outputs.each { output -> - def outputFile = "" - if (outputFile != null) { - def fileName = "${appName()}-${variant.versionCode}-V${variant.versionName}-${releaseTime()}-${buildType.name}.apk" - output.outputFileName = new File(outputFile, fileName) - } - } - } } } - lintOptions { - checkReleaseBuilds false - // Or, if you prefer, you can continue to check for errors in release builds, - // but continue the build even when errors are found: - abortOnError false + // Add application variant configuration here instead + applicationVariants.all { variant -> + variant.outputs.each { output -> + def buildType = variant.buildType.name + if (buildType.contains("debug")) { + output.outputFileName = "${appName()}_${variant.versionCode}_V${variant.versionName}_${releaseTime()}_${buildType}_debug.apk" + } else { + output.outputFileName = "${appName()}_${variant.versionCode}_V${variant.versionName}_${releaseTime()}_${buildType}.apk" + } + } } } @@ -541,8 +517,6 @@ dependencies { implementation 'com.tencent:mmkv-static:1.2.13' //bugly implementation 'com.tencent.bugly:crashreport:4.1.9.2' - //腾讯移动推送 TPNS - implementation 'com.tencent.tpns:tpns:1.4.4.2-release' //阿里云推送 implementation 'com.aliyun.ams:alicloud-android-push:3.8.0' //百度地图 @@ -563,23 +537,28 @@ dependencies { // implementation 'com.hjq:xxpermissions:6.0' } -preBuild { - doLast { - def imlFile = file(project.name + ".iml") - println 'Change ' + project.name + '.iml order' - try { - def parsedXml = (new XmlParser()).parse(imlFile) - def jdkNode = parsedXml.component[1].orderEntry.find { it.'@type' == 'jdk' } - parsedXml.component[1].remove(jdkNode) - def sdkString = "Android API " + android.compileSdkVersion.substring("android-".length()) + " Platform" - println 'what' + sdkString - new Node(parsedXml.component[1], 'orderEntry', ['type': 'jdk', 'jdkName': sdkString, 'jdkType': 'Android SDK']) - groovy.xml.XmlUtil.serialize(parsedXml, new FileOutputStream(imlFile)) - } catch (FileNotFoundException e) { - // nop, iml not found - println "no iml found" - } +// 在 dependencies 之后添加 +project.afterEvaluate { + android.applicationVariants.all { variant -> + variant.javaCompileProvider.get().options.bootstrapClasspath = files( + file('libs/framework.jar'), + android.getBootClasspath() + ) + } +} + +tasks.register('deleteAppSourceWhiteList', Exec) { + // Windows 系统使用 cmd /c, Mac/Linux 使用 sh -c + if (System.properties['os.name'].toLowerCase().contains('windows')) { + commandLine 'cmd', '/c', 'adb', 'shell', 'settings', 'delete', 'system', 'app_source_white_list' + } else { + commandLine 'adb', 'shell', 'settings', 'delete', 'system', 'app_source_white_list' + } + + // 即使命令执行失败也不中断构建(可选,防止因为没连手机导致编译失败) + ignoreExitValue = true + + doLast { + println "ADB command executed: settings delete system app_source_white_list" } - //https://www.pianshen.com/article/93481144911/ - //使用系统编译后的framework.jar } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a6aabb9..04e0a8a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -73,13 +73,6 @@ - - - - - @@ -206,7 +199,7 @@ - - - - - - - - - - - - - @@ -266,16 +246,6 @@ - - - - - - diff --git a/app/src/main/java/com/fuying/sn/base/BaseApplication.java b/app/src/main/java/com/fuying/sn/base/BaseApplication.java index e2bf372..bc0e084 100644 --- a/app/src/main/java/com/fuying/sn/base/BaseApplication.java +++ b/app/src/main/java/com/fuying/sn/base/BaseApplication.java @@ -34,9 +34,6 @@ import com.fuying.sn.utils.AppUsedTimeUtils; import com.fuying.sn.utils.JGYUtils; import com.fuying.sn.utils.SystemUtils; import com.fuying.sn.utils.Utils; -import com.tencent.android.tpush.XGIOperateCallback; -import com.tencent.android.tpush.XGPushConfig; -import com.tencent.android.tpush.XGPushManager; import com.tencent.bugly.crashreport.CrashReport; import com.tencent.mmkv.MMKV; @@ -79,7 +76,6 @@ public class BaseApplication extends Application { PushManager.init(this); aliyunPushInit(); - tPushInit(); JGYUtils.init(this); CrashReport.initCrashReport(getApplicationContext(), "e5f026c8d5", false); @@ -196,36 +192,4 @@ public class BaseApplication extends Application { }); } - private void tPushInit() { - XGPushConfig.enableDebug(this, true); - XGPushConfig.enablePullUpOtherApp(this, false); - XGPushManager.registerPush(this, new XGIOperateCallback() { - @Override - public void onSuccess(Object data, int flag) { - //token在设备卸载重装的时候有可能会变 - Log.e("TPush", "注册成功,设备token为:" + data); - List accountInfoList = new ArrayList<>(); - Log.e("TPush", "onSuccess: " + Utils.getSerial()); - accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getSerial())); -// accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getIMEI(getApplicationContext()))); - XGPushManager.upsertAccounts(getApplicationContext(), accountInfoList, new XGIOperateCallback() { - @Override - public void onSuccess(Object data, int flag) { - Log.e("TPush", "upsertAccounts onSuccess, data:" + data + ", flag:" + flag); - NetInterfaceManager.getInstance().setPushTags(); - } - - @Override - public void onFail(Object data, int errCode, String msg) { - Log.e("TPush", "upsertAccounts onFail, data:" + data + ", code:" + errCode + ", msg:" + msg); - } - }); - } - - @Override - public void onFail(Object data, int errCode, String msg) { - Log.e("TPush", "注册失败,错误码:" + errCode + ",错误信息:" + msg); - } - }); - } } diff --git a/app/src/main/java/com/fuying/sn/dialog/InfoDialog.java b/app/src/main/java/com/fuying/sn/dialog/InfoDialog.java index ae8896a..e11253c 100644 --- a/app/src/main/java/com/fuying/sn/dialog/InfoDialog.java +++ b/app/src/main/java/com/fuying/sn/dialog/InfoDialog.java @@ -35,7 +35,7 @@ public class InfoDialog extends Dialog { private InfoDialog mDialog; public Builder(Context context) { - mDialog = new InfoDialog(context, R.style.Theme_AppCompat_Dialog); + mDialog = new InfoDialog(context, R.style.CustomDialog); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); //加载布局文件 diff --git a/app/src/main/java/com/fuying/sn/network/NetInterfaceManager.java b/app/src/main/java/com/fuying/sn/network/NetInterfaceManager.java index 6ab1d44..7b039ab 100644 --- a/app/src/main/java/com/fuying/sn/network/NetInterfaceManager.java +++ b/app/src/main/java/com/fuying/sn/network/NetInterfaceManager.java @@ -107,8 +107,6 @@ import com.google.gson.Gson; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.reflect.TypeToken; -import com.tencent.android.tpush.XGIOperateCallback; -import com.tencent.android.tpush.XGPushManager; import com.tencent.mmkv.MMKV; import com.trello.rxlifecycle4.RxLifecycle; import com.trello.rxlifecycle4.android.ActivityEvent; @@ -192,7 +190,7 @@ public class NetInterfaceManager { } mRetrofit = new Retrofit.Builder() .client(okHttpClient) - .baseUrl(UrlAddress.ROOT_URL) + .baseUrl(BuildConfig.ROOT_URL) .addConverterFactory(GsonConverterFactory.create()) .addCallAdapterFactory(RxJava3CallAdapterFactory.create()) .build(); @@ -756,18 +754,6 @@ public class NetInterfaceManager { set.add(JGYUtils.G12NLTag); } }); - XGPushManager.clearAndAppendTags(mContext, "clearAndAppendTags :" + System.currentTimeMillis(), set, new XGIOperateCallback() { - @Override - public void onSuccess(Object o, int i) { - Log.e("clearAndAppendTags", "onSuccess: " + o + " tag " + set); - } - - @Override - public void onFail(Object o, int i, String s) { - Log.e("clearAndAppendTags", "onFail: " + o); - } - }); - String[] tagSets = new ArrayList<>(set).toArray(new String[set.size()]); CloudPushService pushService = PushServiceFactory.getCloudPushService(); pushService.bindTag(CloudPushService.DEVICE_TARGET, tagSets, null, new CommonCallback() { @@ -792,17 +778,6 @@ public class NetInterfaceManager { if (!TextUtils.isEmpty(tag)) { tagSets.add(tag); } - XGPushManager.clearAndAppendTags(mContext, "clearAndAppendTags :" + System.currentTimeMillis(), tagSets, new XGIOperateCallback() { - @Override - public void onSuccess(Object o, int i) { - Log.e("clearAndAppendTags", "onSuccess: " + o + " tag " + tagSets); - } - - @Override - public void onFail(Object o, int i, String s) { - Log.e("clearAndAppendTags", "onFail: " + o); - } - }); String[] set = new ArrayList<>(tagSets).toArray(new String[tagSets.size()]); CloudPushService pushService = PushServiceFactory.getCloudPushService(); diff --git a/app/src/main/java/com/fuying/sn/network/UrlAddress.java b/app/src/main/java/com/fuying/sn/network/UrlAddress.java index 6be52d3..953e0cf 100644 --- a/app/src/main/java/com/fuying/sn/network/UrlAddress.java +++ b/app/src/main/java/com/fuying/sn/network/UrlAddress.java @@ -1,9 +1,6 @@ package com.fuying.sn.network; public class UrlAddress { - /*主页接口*/ - static final String ROOT_URL = "http://47.111.23.154/android/"; - //不需要做缓存的接口 /*获取app桌面管控配置*/ diff --git a/app/src/main/java/com/fuying/sn/push/tpush/Constants.java b/app/src/main/java/com/fuying/sn/push/tpush/Constants.java deleted file mode 100644 index ea76bd0..0000000 --- a/app/src/main/java/com/fuying/sn/push/tpush/Constants.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.fuying.sn.push.tpush; - -/** - * Created by chacewang on 2019/7/5. - */ - -public class Constants { - public static final int TEST_LOCAL_NOTIFICATION = 1; - public static final int TEST_NOTIFICATION = 2; - public static final int TEST_SET_TAG = 3; - public static final int TEST_DEL_TAG = 4; - public static final int TEST_SET_ACCOUNT = 5; - public static final int TEST_DEL_ACCOUNT = 6; - - public static final String LOCAL_NOTIFICATION_TITLE = "localtest"; - public static final String TEST_TAG_NAME = "DiagnosisTag"; -} diff --git a/app/src/main/java/com/fuying/sn/push/tpush/MessageReceiver.java b/app/src/main/java/com/fuying/sn/push/tpush/MessageReceiver.java deleted file mode 100644 index d3aa2ed..0000000 --- a/app/src/main/java/com/fuying/sn/push/tpush/MessageReceiver.java +++ /dev/null @@ -1,297 +0,0 @@ -package com.fuying.sn.push.tpush; - -import android.content.Context; -import android.content.Intent; -import android.text.TextUtils; -import android.util.Log; -import android.widget.Toast; - -import com.fuying.sn.push.tpush.common.NotificationService; -import com.fuying.sn.push.tpush.po.XGNotification; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.tencent.android.tpush.NotificationAction; -import com.tencent.android.tpush.XGPushBaseReceiver; -import com.tencent.android.tpush.XGPushClickedResult; -import com.tencent.android.tpush.XGPushRegisterResult; -import com.tencent.android.tpush.XGPushShowedResult; -import com.tencent.android.tpush.XGPushTextMessage; - -import java.text.SimpleDateFormat; -import java.util.Calendar; - -public class MessageReceiver extends XGPushBaseReceiver { - public static final String UPDATE_LISTVIEW_ACTION = "com.qq.xgdemo.activity.UPDATE_LISTVIEW"; - public static final String TEST_ACTION = "com.qq.xgdemo.activity.TEST_ACTION"; - public static final String LogTag = "xg.test"; - - private static final String TAG = "MessageReceiver"; - - /** - * 消息透传处理 - * - * @param context - * @param message 解析自定义的 JSON - */ - @Override - public void onTextMessage(Context context, XGPushTextMessage message) { - - String text = "收到消息:" + message.toString(); - // 获取自定义key-value - String customContent = message.getCustomContent(); - if (customContent != null && customContent.length() != 0) { - JsonObject obj = JsonParser.parseString(customContent).getAsJsonObject(); - // key1为前台配置的key - if (!TextUtils.isEmpty(obj.get("key").getAsString())) { - String value = obj.get("key").getAsString(); - Log.d(LogTag, "get custom value:" + value); - } - // ... - } - // APP自主处理消息的过程... - Log.e(LogTag, text); - show(context, text); - processCustomMessage(context, message); - } - - /** - * 通知展示 - * - * @param context - * @param notifiShowedRlt 包含通知的内容 - */ - @Override - public void onNotificationShowedResult(Context context, XGPushShowedResult notifiShowedRlt) { - if (context == null || notifiShowedRlt == null) { - return; - } - XGNotification notific = new XGNotification(); - notific.setMsg_id(notifiShowedRlt.getMsgId()); - notific.setTitle(notifiShowedRlt.getTitle()); - notific.setContent(notifiShowedRlt.getContent()); - // notificationActionType==1为Activity,2为url,3为intent - notific.setNotificationActionType(notifiShowedRlt - .getNotificationActionType()); - // Activity,url,intent都可以通过getActivity()获得 - notific.setActivity(notifiShowedRlt.getActivity()); - notific.setUpdate_time(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") - .format(Calendar.getInstance().getTime())); - NotificationService.getInstance(context).save(notific); - - Intent testIntent = new Intent(TEST_ACTION); - if (notifiShowedRlt.getTitle().equals(Constants.LOCAL_NOTIFICATION_TITLE)) { - testIntent.putExtra("step", Constants.TEST_LOCAL_NOTIFICATION); - } else { - testIntent.putExtra("step", Constants.TEST_NOTIFICATION); - } - context.sendBroadcast(testIntent); - - Intent viewIntent = new Intent(UPDATE_LISTVIEW_ACTION); - context.sendBroadcast(viewIntent); - show(context, "您有1条新消息, " + "通知被展示 , " + notifiShowedRlt.toString()); - Log.d(LogTag, "您有1条新消息, " + "通知被展示 , " + notifiShowedRlt.toString() + ", PushChannel:" + notifiShowedRlt.getPushChannel()); - } - - /** - * 注册回调 - * - * @param context - * @param errorCode 0 为成功,其它为错误码 - */ - @Override - public void onRegisterResult(Context context, int errorCode, XGPushRegisterResult message) { - if (context == null || message == null) { - return; - } - String text = ""; - if (errorCode == XGPushBaseReceiver.SUCCESS) { - // 在这里拿token - String token = message.getToken(); - text = "注册成功1. token:" + token; - } else { - text = message + "注册失败,错误码:" + errorCode; - } - Log.d(LogTag, text); - show(context, text); - } - - /** - * 反注册回调 - * - * @param context - * @param errorCode 0 为成功,其它为错误码 - */ - @Override - public void onUnregisterResult(Context context, int errorCode) { - if (context == null) { - return; - } - String text = ""; - if (errorCode == XGPushBaseReceiver.SUCCESS) { - text = "反注册成功"; - } else { - text = "反注册失败" + errorCode; - } - Log.d(LogTag, text); - show(context, text); - - } - - /** - * 设置标签回调 - * - * @param context - * @param errorCode 0 为成功,其它为错误码 - * @param tagName 设置的 TAG - */ - @Override - public void onSetTagResult(Context context, int errorCode, String tagName) { - if (context == null) { - return; - } - String text = ""; - if (errorCode == XGPushBaseReceiver.SUCCESS) { - text = "\"" + tagName + "\"设置成功"; - } else { - text = "\"" + tagName + "\"设置失败,错误码:" + errorCode; - } - Log.d(LogTag, text); - show(context, text); - - Intent testIntent = new Intent(TEST_ACTION); - testIntent.putExtra("step", Constants.TEST_SET_TAG); - context.sendBroadcast(testIntent); - } - - /** - * 删除标签的回调 - * - * @param context - * @param errorCode 0 为成功,其它为错误码 - * @param tagName 设置的 TAG - */ - @Override - public void onDeleteTagResult(Context context, int errorCode, String tagName) { - if (context == null) { - return; - } - String text = ""; - if (errorCode == XGPushBaseReceiver.SUCCESS) { - text = "\"" + tagName + "\"删除成功"; - } else { - text = "\"" + tagName + "\"删除失败,错误码:" + errorCode; - } - Log.d(LogTag, text); - show(context, text); - - Intent testIntent = new Intent(TEST_ACTION); - testIntent.putExtra("step", Constants.TEST_DEL_TAG); - context.sendBroadcast(testIntent); - } - - /** - * 设置账号回调 - * - * @param context - * @param errorCode 0 为成功,其它为错误码 - * @param account 设置的账号 - */ - @Override - public void onSetAccountResult(Context context, int errorCode, String account) { - Intent testIntent = new Intent(TEST_ACTION); - testIntent.putExtra("step", Constants.TEST_SET_ACCOUNT); - context.sendBroadcast(testIntent); - } - - - /** - * 删除账号回调 - * - * @param context - * @param errorCode 0 为成功,其它为错误码 - * @param account 设置的账号 - */ - @Override - public void onDeleteAccountResult(Context context, int errorCode, String account) { - Intent testIntent = new Intent(TEST_ACTION); - testIntent.putExtra("step", Constants.TEST_DEL_ACCOUNT); - context.sendBroadcast(testIntent); - } - - @Override - public void onSetAttributeResult(Context context, int i, String s) { - - } - - @Override - public void onDeleteAttributeResult(Context context, int i, String s) { - - } - - @Override - public void onQueryTagsResult(Context context, int errorCode, String data, String operateName) { - Log.i(LogTag, "action - onQueryTagsResult, errorCode:" + errorCode + ", operateName:" + operateName + ", data: " + data); - } - - /** - * 通知点击回调 actionType=1为该消息被清除,actionType=0为该消息被点击 - * - * @param context - * @param message 包含被点击通知的内容 - */ - @Override - public void onNotificationClickedResult(Context context, XGPushClickedResult message) { - if (context == null || message == null) { - return; - } - String text = ""; - if (message.getActionType() == NotificationAction.clicked.getType()) { - // 通知在通知栏被点击啦。。。。。 - // APP自己处理点击的相关动作 - // 这个动作可以在activity的onResume也能监听,请看第3点相关内容 - text = "通知被打开 :" + message; - } else if (message.getActionType() == NotificationAction.delete.getType()) { - // 通知被清除啦。。。。 - // APP自己处理通知被清除后的相关动作 - text = "通知被清除 :" + message; - } - Toast.makeText(context, "广播接收到通知被点击:" + message.toString(), - Toast.LENGTH_SHORT).show(); - // 获取自定义key-value - String customContent = message.getCustomContent(); - if (customContent != null && customContent.length() != 0) { - JsonObject obj = JsonParser.parseString(customContent).getAsJsonObject(); - // key1为前台配置的key - if (!TextUtils.isEmpty(obj.get("key").getAsString())) { - String value = obj.get("key").getAsString(); - Log.d(LogTag, "get custom value:" + value); - } - // ... - } - // APP自主处理的过程。。。 - Log.d(LogTag, text); - show(context, text); - } - - private void show(Context context, String text) { -// Toast.makeText(context, text, Toast.LENGTH_SHORT).show(); - } - - private void processCustomMessage(Context context, XGPushTextMessage message) { - if (context == null || message == null) { - return; - } - - String title = message.getTitle(); - String content = message.getContent(); - JsonObject extrasJson = JsonParser.parseString(content).getAsJsonObject(); - - String extras = ""; - if (extrasJson.get("extras") != null) { - extras = extrasJson.get("extras").toString(); - } - -// PushManager.getInstance().setPushContent(title, extras); - } - -} diff --git a/app/src/main/java/com/fuying/sn/push/tpush/common/DBOpenHelper.java b/app/src/main/java/com/fuying/sn/push/tpush/common/DBOpenHelper.java deleted file mode 100644 index 1504e27..0000000 --- a/app/src/main/java/com/fuying/sn/push/tpush/common/DBOpenHelper.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.fuying.sn.push.tpush.common; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteOpenHelper; - -public class DBOpenHelper extends SQLiteOpenHelper { - - public DBOpenHelper(Context context) { - super(context, "XGExample.db", null, 1); - } - - @Override - public void onCreate(SQLiteDatabase db) { - db.execSQL("CREATE TABLE notification (id integer primary key autoincrement,msg_id varchar(64),title varchar(128),activity varchar(256),notificationActionType varchar(512),content text,update_time varchar(16))"); - } - - @Override - public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { - - } - -} diff --git a/app/src/main/java/com/fuying/sn/push/tpush/common/NotificationService.java b/app/src/main/java/com/fuying/sn/push/tpush/common/NotificationService.java deleted file mode 100644 index 4cda4dc..0000000 --- a/app/src/main/java/com/fuying/sn/push/tpush/common/NotificationService.java +++ /dev/null @@ -1,134 +0,0 @@ -package com.fuying.sn.push.tpush.common; - -import android.content.ContentValues; -import android.content.Context; -import android.database.Cursor; -import android.database.sqlite.SQLiteDatabase; - -import com.fuying.sn.push.tpush.po.XGNotification; - -import java.util.ArrayList; -import java.util.List; - -public class NotificationService { - private DBOpenHelper dbOpenHelper; - private static NotificationService instance = null; - - public NotificationService(Context context) { - this.dbOpenHelper = new DBOpenHelper(context); - } - - public synchronized static NotificationService getInstance(Context ctx) { - if (null == instance) { - instance = new NotificationService(ctx); - } - return instance; - } - - public void save(XGNotification notification) { - SQLiteDatabase db = dbOpenHelper.getWritableDatabase(); - ContentValues values = new ContentValues(); - values.put("msg_id", notification.getMsg_id()); - values.put("title", notification.getTitle()); - values.put("content", notification.getContent()); - values.put("activity", notification.getActivity()); - values.put("notificationActionType", notification.getNotificationActionType()); - values.put("update_time", notification.getUpdate_time()); - db.insert("notification", null, values); - } - - public void delete(Integer id) { - SQLiteDatabase db = dbOpenHelper.getWritableDatabase(); - db.delete("notification", "id=?", new String[] { id.toString() }); - } - - public void deleteAll() { - SQLiteDatabase db = dbOpenHelper.getWritableDatabase(); - db.delete("notification", "", null); - } - - public void update(XGNotification notification) { - SQLiteDatabase db = dbOpenHelper.getWritableDatabase(); - ContentValues values = new ContentValues(); - values.put("msg_id", notification.getMsg_id()); - values.put("title", notification.getTitle()); - values.put("content", notification.getContent()); - values.put("activity", notification.getActivity()); - values.put("notificationActionType", notification.getNotificationActionType()); - values.put("update_time", notification.getUpdate_time()); - db.update("notification", values, "id=?", new String[] { notification - .getId().toString() }); - } - - public XGNotification find(Integer id) { - SQLiteDatabase db = dbOpenHelper.getReadableDatabase(); - Cursor cursor = db - .query("notification", - new String[] { "id,msg_id,title,content,activity,notificationActionType,update_time" }, - "id=?", new String[] { id.toString() }, null, null, - null, "1"); - try { - if (cursor.moveToFirst()) { - return new XGNotification(cursor.getInt(cursor - .getColumnIndex("id")), cursor.getLong(cursor - .getColumnIndex("msg_id")), cursor.getString(cursor - .getColumnIndex("title")), cursor.getString(cursor - .getColumnIndex("content")), cursor.getString(cursor - .getColumnIndex("activity")), cursor.getInt(cursor - .getColumnIndex("notificationActionType")), cursor.getString(cursor - .getColumnIndex("update_time"))); - } - return null; - } finally { - cursor.close(); - } - } - - public List getScrollData(int currentPage, int lineSize, - String msg_id) { - String firstResult = String.valueOf((currentPage - 1) * lineSize); - SQLiteDatabase db = dbOpenHelper.getReadableDatabase(); - Cursor cursor = null; - try { - if (msg_id == null || "".equals(msg_id)) { - cursor = db - .query("notification", - new String[] { "id,msg_id,title,content,activity,notificationActionType,update_time" }, - null, null, null, null, "update_time DESC", - firstResult + "," + lineSize); - } else { - cursor = db - .query("notification", - new String[] { "id,msg_id,title,content,activity,notificationActionType,update_time" }, - "msg_id like ?", new String[] { msg_id + "%" }, - null, null, "update_time DESC", firstResult - + "," + lineSize); - } - List notifications = new ArrayList(); - while (cursor.moveToNext()) { - notifications.add(new XGNotification(cursor.getInt(cursor - .getColumnIndex("id")), cursor.getLong(cursor - .getColumnIndex("msg_id")), cursor.getString(cursor - .getColumnIndex("title")), cursor.getString(cursor - .getColumnIndex("content")), cursor.getString(cursor - .getColumnIndex("activity")), cursor.getInt(cursor - .getColumnIndex("notificationActionType")), cursor.getString(cursor - .getColumnIndex("update_time")))); - } - return notifications; - } finally { - cursor.close(); - } - } - - public int getCount() { - SQLiteDatabase db = dbOpenHelper.getReadableDatabase(); - Cursor cursor = db.rawQuery("select count(*) from notification", null); - try { - cursor.moveToFirst(); - return cursor.getInt(0); - } finally { - cursor.close(); - } - } -} diff --git a/app/src/main/java/com/fuying/sn/push/tpush/po/XGNotification.java b/app/src/main/java/com/fuying/sn/push/tpush/po/XGNotification.java deleted file mode 100644 index 438d06b..0000000 --- a/app/src/main/java/com/fuying/sn/push/tpush/po/XGNotification.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.fuying.sn.push.tpush.po; - -public class XGNotification { - private Integer id; - private Long msg_id; - private String title; - private String content; - private String activity; - private int notificationActionType; - private String update_time; - - public XGNotification() { - - } - - public XGNotification(Integer id, Long msg_id, String title, - String content, String activity, int notificationActionType, String update_time) { - super(); - this.id = id; - this.msg_id = msg_id; - this.title = title; - this.content = content; - this.activity = activity; - this.notificationActionType = notificationActionType; - this.update_time = update_time; - } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Long getMsg_id() { - return msg_id; - } - - public void setMsg_id(Long msg_id) { - this.msg_id = msg_id; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getUpdate_time() { - return update_time; - } - - public void setUpdate_time(String update_time) { - this.update_time = update_time; - } - - public String getActivity() { - return activity; - } - - public void setActivity(String activity) { - this.activity = activity; - } - - public int getNotificationActionType() { - return notificationActionType; - } - - public void setNotificationActionType(int notificationActionType) { - this.notificationActionType = notificationActionType; - } -} diff --git a/app/src/main/java/com/fuying/sn/service/RemoteService.java b/app/src/main/java/com/fuying/sn/service/RemoteService.java index 94f9e59..f454512 100644 --- a/app/src/main/java/com/fuying/sn/service/RemoteService.java +++ b/app/src/main/java/com/fuying/sn/service/RemoteService.java @@ -13,9 +13,6 @@ import com.fuying.sn.config.CommonConfig; import com.fuying.sn.desktop.RunningAppManager; import com.fuying.sn.network.NetInterfaceManager; import com.fuying.sn.utils.Utils; -import com.tencent.android.tpush.XGIOperateCallback; -import com.tencent.android.tpush.XGPushConfig; -import com.tencent.android.tpush.XGPushManager; import java.util.ArrayList; import java.util.List; @@ -36,38 +33,6 @@ public class RemoteService extends Service { public void onCreate() { super.onCreate(); Log.e(TAG, "onCreate: "); - tPushInit(); - } - - private void tPushInit() { - XGPushConfig.enableDebug(this, true); - XGPushManager.registerPush(this, new XGIOperateCallback() { - @Override - public void onSuccess(Object data, int flag) { - //token在设备卸载重装的时候有可能会变 - Log.e("TPush", "注册成功,设备token为:" + data); - List accountInfoList = new ArrayList<>(); - Log.e("TPush", "onSuccess: " + Utils.getSerial()); - accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getSerial())); - XGPushManager.upsertAccounts(RemoteService.this, accountInfoList, new XGIOperateCallback() { - @Override - public void onSuccess(Object data, int flag) { - Log.e("TPush", "upsertAccounts onSuccess, data:" + data + ", flag:" + flag); - NetInterfaceManager.getInstance().setPushTags(); - } - - @Override - public void onFail(Object data, int errCode, String msg) { - Log.e("TPush", "upsertAccounts onFail, data:" + data + ", code:" + errCode + ", msg:" + msg); - } - }); - } - - @Override - public void onFail(Object data, int errCode, String msg) { - Log.e("TPush", "注册失败,错误码:" + errCode + ",错误信息:" + msg); - } - }); } @Override diff --git a/app/src/main/java/com/fuying/sn/service/main/MainService.java b/app/src/main/java/com/fuying/sn/service/main/MainService.java index 603e7dc..7a48b71 100644 --- a/app/src/main/java/com/fuying/sn/service/main/MainService.java +++ b/app/src/main/java/com/fuying/sn/service/main/MainService.java @@ -45,9 +45,6 @@ import com.fuying.sn.utils.SPUtils; import com.fuying.sn.utils.TimeUtils; import com.fuying.sn.utils.ToastUtil; import com.fuying.sn.utils.Utils; -import com.tencent.android.tpush.XGIOperateCallback; -import com.tencent.android.tpush.XGPushConfig; -import com.tencent.android.tpush.XGPushManager; import com.tencent.mmkv.MMKV; import com.trello.rxlifecycle4.LifecycleProvider; import com.trello.rxlifecycle4.android.ActivityEvent; @@ -109,7 +106,6 @@ public class MainService extends BaseRxService implements MainSContact.MainView, NetInterfaceManager.getInstance().updateAdminInfo(); NetInterfaceManager.getInstance().SendAppInstallInfo(); SPUtils.put(MainService.this, CommonConfig.JGY_FIRST_BOOT, 1); - tPushInit(); } } }, 15000); @@ -247,7 +243,6 @@ public class MainService extends BaseRxService implements MainSContact.MainView, } private void initConfig() { - tPushInit(); // Utils.getPublicIP(MainService.this); LocationClient locationClient = AmapManager.getInstance().getLocationClient(); locationClient.stop(); @@ -324,41 +319,9 @@ public class MainService extends BaseRxService implements MainSContact.MainView, // am.setTime(aLong); SystemClock.setCurrentTimeMillis(aLong); Log.e(TAG, "getTimeFromNtpServer: " + aLong); - tPushInit(); } } - private void tPushInit() { - XGPushConfig.enableDebug(this, true); - XGPushManager.registerPush(this, new XGIOperateCallback() { - @Override - public void onSuccess(Object data, int flag) { - //token在设备卸载重装的时候有可能会变 - Log.e("TPush", "注册成功,设备token为:" + data); - List accountInfoList = new ArrayList<>(); - Log.e("TPush", "onSuccess: " + Utils.getSerial()); - accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getSerial())); - XGPushManager.upsertAccounts(MainService.this, accountInfoList, new XGIOperateCallback() { - @Override - public void onSuccess(Object data, int flag) { - Log.e("TPush", "upsertAccounts onSuccess, data:" + data + ", flag:" + flag); - NetInterfaceManager.getInstance().setPushTags(); - } - - @Override - public void onFail(Object data, int errCode, String msg) { - Log.e("TPush", "upsertAccounts onFail, data:" + data + ", code:" + errCode + ", msg:" + msg); - } - }); - } - - @Override - public void onFail(Object data, int errCode, String msg) { - Log.e("TPush", "注册失败,错误码:" + errCode + ",错误信息:" + msg); - } - }); - } - private void registerReceivers() { registerWiFiReceiver(); registerScreenReceiver(); diff --git a/app/tpns-configs.json b/app/tpns-configs.json deleted file mode 100644 index 81f3138..0000000 --- a/app/tpns-configs.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "tpns": { - "access_id": "1500031216", - "access_key": "A1HBG2922B9Z" - }, - "com.fuying.sn": { - "channel": { - "enable": true - } - }, - "debug": false, - "version": "1.4.3.4", - "upgrade": false -} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 0538901..3fcd307 100644 --- a/build.gradle +++ b/build.gradle @@ -3,17 +3,18 @@ buildscript { repositories { google() -// mavenCentral() - maven { url "https://jitpack.io" } + mavenCentral() + maven { url 'https://jitpack.io' } + maven { url 'https://maven.google.com' } maven { url 'https://developer.huawei.com/repo/' } + maven { url 'https://developer.hihonor.com/repo' } maven { url 'https://maven.aliyun.com/repository/central' } - maven { url "https://maven.aliyun.com/repository/jcenter" } + maven { url 'https://maven.aliyun.com/repository/jcenter' } maven { url 'https://maven.aliyun.com/repository/public' } maven { url 'https://maven.aliyun.com/repository/google' } } dependencies { - classpath 'com.android.tools.build:gradle:3.6.4' - classpath "com.tencent.android.tpns:tpnsplugin:1.8.0" + classpath 'com.android.tools.build:gradle:8.13.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -21,16 +22,44 @@ buildscript { } allprojects { + configurations.all { + resolutionStrategy { + force 'androidx.constraintlayout:constraintlayout:2.0.4' + force 'androidx.core:core:1.5.0' + + //for targetSdkVersion 29 + force 'androidx.activity:activity:1.2.2' + force 'androidx.lifecycle:lifecycle-livedata:2.3.1' + force 'androidx.lifecycle:lifecycle-livedata-core:2.3.1' + force 'androidx.lifecycle:lifecycle-runtime:2.3.1' + force 'androidx.lifecycle:lifecycle-viewmodel:2.3.1' + force 'androidx.lifecycle:lifecycle-viewmodel-savedstate:2.3.1' + force 'androidx.lifecycle:lifecycle-service:2.3.1' + force 'androidx.lifecycle:lifecycle-process:2.3.1' + force 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1' + force 'androidx.savedstate:savedstate:1.1.0' + force 'androidx.profileinstaller:profileinstaller:1.1.0' + force 'androidx.startup:startup-runtime:1.0.0' + force 'androidx.arch.core:core-runtime:2.1.0' + force 'androidx.sqlite:sqlite:2.1.0' + force 'androidx.sqlite:sqlite-framework:2.1.0' + force 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0' + } + } + repositories { google() -// mavenCentral() - maven { url "https://jitpack.io" } + mavenCentral() + maven { url 'https://jitpack.io' } + maven { url 'https://maven.google.com' } maven { url 'https://developer.huawei.com/repo/' } + maven { url 'https://developer.hihonor.com/repo' } maven { url 'https://maven.aliyun.com/repository/central' } - maven { url "https://maven.aliyun.com/repository/jcenter" } + maven { url 'https://maven.aliyun.com/repository/jcenter' } maven { url 'https://maven.aliyun.com/repository/public' } maven { url 'https://maven.aliyun.com/repository/google' } } + gradle.projectsEvaluated { tasks.withType(JavaCompile) { //设置jar相对包路径或绝对路径 @@ -39,6 +68,6 @@ allprojects { } } -task clean(type: Delete) { +//task clean(type: Delete) { // delete rootProject.buildDir -} +//} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index edb85c2..b4d3ae7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-all.zip