This commit is contained in:
ZhanGSKen 2025-03-07 11:15:22 +08:00
parent bca31f9079
commit bc252041d3
13 changed files with 132 additions and 140 deletions

View File

@ -44,7 +44,7 @@ android {
} }
dependencies { dependencies {
api project(':libappbase') implementation project(':libappbase')
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
// //

View File

@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle #Created by .winboll/winboll_app_build.gradle
#Thu Feb 27 02:34:13 GMT 2025 #Fri Mar 07 03:14:48 GMT 2025
stageCount=3 stageCount=3
libraryProject=libappbase libraryProject=libappbase
baseVersion=2.0 baseVersion=2.0
publishVersion=2.0.2 publishVersion=2.0.2
buildCount=4 buildCount=5
baseBetaVersion=2.0.3 baseBetaVersion=2.0.3

View File

@ -6,22 +6,23 @@ package cc.winboll.studio.appbase;
* @Describe APPbase 应用类 * @Describe APPbase 应用类
*/ */
import cc.winboll.studio.libappbase.GlobalApplication; import cc.winboll.studio.libappbase.GlobalApplication;
import cc.winboll.studio.libappbase.SOSCSBroadcastReceiver;
import android.content.IntentFilter; import android.content.IntentFilter;
import cc.winboll.studio.libappbase.sos.SOSCenterServiceReceiver;
import cc.winboll.studio.libappbase.sos.SOS;
public class App extends GlobalApplication { public class App extends GlobalApplication {
public static final String TAG = "App"; public static final String TAG = "App";
SOSCSBroadcastReceiver mSOSCSBroadcastReceiver; SOSCenterServiceReceiver mSOSCenterServiceReceiver;
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
GlobalApplication.setIsDebuging(this, BuildConfig.DEBUG); GlobalApplication.setIsDebuging(this, BuildConfig.DEBUG);
mSOSCSBroadcastReceiver = new SOSCSBroadcastReceiver(); mSOSCenterServiceReceiver = new SOSCenterServiceReceiver();
IntentFilter intentFilter = new IntentFilter(); IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(SOSCSBroadcastReceiver.ACTION_SOS); intentFilter.addAction(SOS.ACTION_SOS);
registerReceiver(mSOSCSBroadcastReceiver, intentFilter); registerReceiver(mSOSCenterServiceReceiver, intentFilter);
} }
} }

View File

@ -12,12 +12,10 @@ import cc.winboll.studio.appbase.services.MainService;
import cc.winboll.studio.libappbase.GlobalApplication; import cc.winboll.studio.libappbase.GlobalApplication;
import cc.winboll.studio.libappbase.LogUtils; import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.LogView; import cc.winboll.studio.libappbase.LogView;
import cc.winboll.studio.libappbase.WinBoll;
import cc.winboll.studio.libappbase.SimpleOperateSignalCenterService;
import cc.winboll.studio.libappbase.bean.APPNewsBean;
import cc.winboll.studio.libappbase.services.TestService; import cc.winboll.studio.libappbase.services.TestService;
import cc.winboll.studio.libappbase.widgets.StatusWidget; import cc.winboll.studio.libappbase.widgets.StatusWidget;
import com.hjq.toast.ToastUtils; import com.hjq.toast.ToastUtils;
import cc.winboll.studio.libappbase.sos.SOS;
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
@ -69,44 +67,44 @@ public class MainActivity extends AppCompatActivity {
} }
public void onTestStopWithoutSettingEnable(View view) { public void onTestStopWithoutSettingEnable(View view) {
LogUtils.d(TAG, "onTestStopWithoutSettingEnable"); // LogUtils.d(TAG, "onTestStopWithoutSettingEnable");
stopService(new Intent(this, SimpleOperateSignalCenterService.class)); // stopService(new Intent(this, SimpleOperateSignalCenterService.class));
} }
public void onTestStartWithString(View view) { public void onTestStartWithString(View view) {
LogUtils.d(TAG, "onTestStartWithString"); LogUtils.d(TAG, "onTestStartWithString");
// 目标服务的包名和类名 // 目标服务的包名和类名
String packageName = this.getPackageName(); // String packageName = this.getPackageName();
String serviceClassName = SimpleOperateSignalCenterService.class.getName(); // String serviceClassName = SimpleOperateSignalCenterService.class.getName();
//
// 构建Intent // // 构建Intent
Intent intentService = new Intent(); // Intent intentService = new Intent();
intentService.setComponent(new ComponentName(packageName, serviceClassName)); // intentService.setComponent(new ComponentName(packageName, serviceClassName));
//
startService(intentService); // startService(intentService);
} }
public void onSOS(View view) { public void onSOS(View view) {
Intent intent = new Intent(this, TestService.class); // Intent intent = new Intent(this, TestService.class);
stopService(intent); // stopService(intent);
WinBoll.sosService(this, new APPNewsBean(getPackageName(), TestService.class.getName())); // SOS.se(this, new APPNewsBean(getPackageName(), TestService.class.getName()));
} }
public void onStartTestService(View view) { public void onStartTestService(View view) {
Intent intent = new Intent(this, TestService.class); // Intent intent = new Intent(this, TestService.class);
intent.setAction(WinBoll.ACTION_SERVICE_ENABLE); // intent.setAction(WinBoll.ACTION_SERVICE_ENABLE);
startService(intent); // startService(intent);
} }
public void onStopTestService(View view) { public void onStopTestService(View view) {
Intent intent = new Intent(this, TestService.class); // Intent intent = new Intent(this, TestService.class);
intent.setAction(WinBoll.ACTION_SERVICE_DISABLE); // intent.setAction(WinBoll.ACTION_SERVICE_DISABLE);
startService(intent); // startService(intent);
//
Intent intentStop = new Intent(this, TestService.class); // Intent intentStop = new Intent(this, TestService.class);
stopService(intentStop); // stopService(intentStop);
} }
public void onStopTestServiceNoSettings(View view) { public void onStopTestServiceNoSettings(View view) {

View File

@ -16,13 +16,15 @@ import cc.winboll.studio.appbase.services.MainService;
import cc.winboll.studio.appbase.widgets.WinBollNewsWidget; import cc.winboll.studio.appbase.widgets.WinBollNewsWidget;
import cc.winboll.studio.libappbase.AppUtils; import cc.winboll.studio.libappbase.AppUtils;
import cc.winboll.studio.libappbase.LogUtils; import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.WinBoll;
import cc.winboll.studio.libappbase.bean.APPNewsBean;
import com.hjq.toast.ToastUtils; import com.hjq.toast.ToastUtils;
import java.io.IOException; import java.io.IOException;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import cc.winboll.studio.libappbase.sos.WinBoll;
import cc.winboll.studio.libappbase.sos.APPModel;
import cc.winboll.studio.libappbase.sos.SOS;
import cc.winboll.studio.libappbase.sos.SOSObject;
public class MainReceiver extends BroadcastReceiver { public class MainReceiver extends BroadcastReceiver {
@ -52,12 +54,12 @@ public class MainReceiver extends BroadcastReceiver {
LogUtils.d(TAG, String.format("szAPPSOSBean %s", szAPPSOSBean)); LogUtils.d(TAG, String.format("szAPPSOSBean %s", szAPPSOSBean));
if (szAPPSOSBean != null && !szAPPSOSBean.equals("")) { if (szAPPSOSBean != null && !szAPPSOSBean.equals("")) {
try { try {
APPNewsBean bean = APPNewsBean.parseStringToBean(szAPPSOSBean, APPNewsBean.class); APPModel bean = APPModel.parseStringToBean(szAPPSOSBean, APPModel.class);
if (bean != null) { if (bean != null) {
String szNewsPackageName = bean.getNewsPackageName(); String szAppPackageName = bean.getAppPackageName();
LogUtils.d(TAG, String.format("szNewsPackageName %s", szNewsPackageName)); LogUtils.d(TAG, String.format("szAppPackageName %s", szAppPackageName));
String szNewsClassName = bean.getNewsClassName(); String szAppMainServiveName = bean.getAppMainServiveName();
LogUtils.d(TAG, String.format("szNewsClassName %s", szNewsClassName)); LogUtils.d(TAG, String.format("szNewsClassName %s", szAppMainServiveName));
mwrService.get().bindSOSConnection(bean); mwrService.get().bindSOSConnection(bean);
} }
} catch (IOException e) { } catch (IOException e) {
@ -65,50 +67,42 @@ public class MainReceiver extends BroadcastReceiver {
} }
} }
} }
} else if (intent.getAction().equals(WinBoll.ACTION_SOS)) { } else if (intent.getAction().equals(SOS.ACTION_SOS)) {
LogUtils.d(TAG, "ACTION_SOS"); LogUtils.d(TAG, "ACTION_SOS");
LogUtils.d(TAG, String.format("context.getPackageName() %s", context.getPackageName())); String sos = intent.getStringExtra(SOS.EXTRA_OBJECT);
LogUtils.d(TAG, String.format("intent.getAction() %s", intent.getAction())); LogUtils.d(TAG, String.format("SOS %s", sos));
String SOS = intent.getStringExtra("SOS"); if (sos != null && sos.equals("")) {
LogUtils.d(TAG, String.format("SOS %s", SOS)); SOSObject bean = SOS.parseSOSObject(sos);
if (SOS != null && SOS.equals("Service")) { if (bean != null) {
String szAPPNewsBean = intent.getStringExtra("APPSOSBean"); String szObjectPackageName = bean.getObjectPackageName();
LogUtils.d(TAG, String.format("szAPPNewsBean %s", szAPPNewsBean)); LogUtils.d(TAG, String.format("szObjectPackageName %s", szObjectPackageName));
if (szAPPNewsBean != null && !szAPPNewsBean.equals("")) { String szObjectServiveName = bean.getObjectServiveName();
try { LogUtils.d(TAG, String.format("szObjectServiveName %s", szObjectServiveName));
APPNewsBean bean = APPNewsBean.parseStringToBean(szAPPNewsBean, APPNewsBean.class);
if (bean != null) {
String szNewsPackageName = bean.getNewsPackageName();
LogUtils.d(TAG, String.format("szNewsPackageName %s", szNewsPackageName));
String szNewsClassName = bean.getNewsClassName();
LogUtils.d(TAG, String.format("szNewsClassName %s", szNewsClassName));
Intent intentService = new Intent(); Intent intentService = new Intent();
intentService.setComponent(new ComponentName(szNewsPackageName, szNewsClassName)); intentService.setComponent(new ComponentName(szObjectPackageName, szObjectServiveName));
context.startService(intentService); context.startService(intentService);
String appName = AppUtils.getAppNameByPackageName(context, szNewsPackageName); String appName = AppUtils.getAppNameByPackageName(context, szObjectPackageName);
LogUtils.d(TAG, String.format("appName %s", appName)); LogUtils.d(TAG, String.format("appName %s", appName));
WinBollNewsBean appWinBollNewsBean = new WinBollNewsBean(appName); WinBollNewsBean appWinBollNewsBean = new WinBollNewsBean(appName);
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
String currentTime = sdf.format(new Date()); String currentTime = sdf.format(new Date());
StringBuilder sbLine = new StringBuilder(); StringBuilder sbLine = new StringBuilder();
sbLine.append("["); sbLine.append("[");
sbLine.append(currentTime); sbLine.append(currentTime);
sbLine.append("] Power to "); sbLine.append("] Power to ");
sbLine.append(appName); sbLine.append(appName);
appWinBollNewsBean.setMessage(sbLine.toString()); appWinBollNewsBean.setMessage(sbLine.toString());
WinBollNewsWidget.addWinBollNewsBean(context, appWinBollNewsBean); WinBollNewsWidget.addWinBollNewsBean(context, appWinBollNewsBean);
Intent intentWidget = new Intent(context, WinBollNewsWidget.class); Intent intentWidget = new Intent(context, WinBollNewsWidget.class);
intentWidget.setAction(WinBollNewsWidget.ACTION_RELOAD_REPORT); intentWidget.setAction(WinBollNewsWidget.ACTION_RELOAD_REPORT);
context.sendBroadcast(intentWidget); context.sendBroadcast(intentWidget);
}
} catch (IOException e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
} }
} }
} else { } else {
ToastUtils.show(szAction); ToastUtils.show(szAction);
@ -120,10 +114,8 @@ public class MainReceiver extends BroadcastReceiver {
public void registerAction(MainService service) { public void registerAction(MainService service) {
IntentFilter filter=new IntentFilter(); IntentFilter filter=new IntentFilter();
filter.addAction(ACTION_BOOT_COMPLETED); filter.addAction(ACTION_BOOT_COMPLETED);
filter.addAction(WinBoll.ACTION_SOS); filter.addAction(SOS.ACTION_SOS);
filter.addAction(WinBoll.ACTION_BIND); filter.addAction(WinBoll.ACTION_BIND);
filter.addAction(WinBoll.ACTION_SERVICE_ENABLE);
filter.addAction(WinBoll.ACTION_SERVICE_DISABLE);
//filter.addAction(Intent.ACTION_BATTERY_CHANGED); //filter.addAction(Intent.ACTION_BATTERY_CHANGED);
service.registerReceiver(this, filter); service.registerReceiver(this, filter);
} }

View File

@ -25,8 +25,8 @@ import cc.winboll.studio.appbase.services.AssistantService;
import cc.winboll.studio.appbase.threads.MainServiceThread; import cc.winboll.studio.appbase.threads.MainServiceThread;
import cc.winboll.studio.appbase.widgets.WinBollNewsWidget; import cc.winboll.studio.appbase.widgets.WinBollNewsWidget;
import cc.winboll.studio.libappbase.LogUtils; import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.bean.APPNewsBean;
import java.util.ArrayList; import java.util.ArrayList;
import cc.winboll.studio.libappbase.sos.APPModel;
public class MainService extends Service { public class MainService extends Service {
@ -192,7 +192,7 @@ public class MainService extends Service {
} }
} }
public void bindSOSConnection(APPNewsBean bean) { public void bindSOSConnection(APPModel bean) {
LogUtils.d(TAG, "bindSOSConnection(...)"); LogUtils.d(TAG, "bindSOSConnection(...)");
// 清理旧的绑定链接 // 清理旧的绑定链接
for (int i = mSOSConnectionList.size() - 1; i > -1; i--) { for (int i = mSOSConnectionList.size() - 1; i > -1; i--) {
@ -207,13 +207,13 @@ public class MainService extends Service {
// 绑定服务 // 绑定服务
SOSConnection sosConnection = new SOSConnection(); SOSConnection sosConnection = new SOSConnection();
Intent intentService = new Intent(); Intent intentService = new Intent();
intentService.setComponent(new ComponentName(bean.getNewsPackageName(), bean.getNewsClassName())); intentService.setComponent(new ComponentName(bean.getAppPackageName(), bean.getAppMainServiveName()));
bindService(intentService, sosConnection, Context.BIND_IMPORTANT); bindService(intentService, sosConnection, Context.BIND_IMPORTANT);
mSOSConnectionList.add(sosConnection); mSOSConnectionList.add(sosConnection);
Intent intentWidget = new Intent(this, WinBollNewsWidget.class); Intent intentWidget = new Intent(this, WinBollNewsWidget.class);
intentWidget.setAction(WinBollNewsWidget.ACTION_WAKEUP_SERVICE); intentWidget.setAction(WinBollNewsWidget.ACTION_WAKEUP_SERVICE);
APPNewsBean appSOSBean = new APPNewsBean(bean.getNewsPackageName(), bean.getNewsClassName()); APPModel appSOSBean = new APPModel(bean.getAppPackageName(), bean.getAppMainServiveName());
intentWidget.putExtra("APPSOSBean", appSOSBean.toString()); intentWidget.putExtra("APPSOSBean", appSOSBean.toString());
sendBroadcast(intentWidget); sendBroadcast(intentWidget);
} }
@ -222,10 +222,10 @@ public class MainService extends Service {
ComponentName mComponentName; ComponentName mComponentName;
boolean isBindToAPPSOSBean(APPNewsBean bean) { boolean isBindToAPPSOSBean(APPModel bean) {
return mComponentName != null return mComponentName != null
&& mComponentName.getClassName().equals(bean.getNewsClassName()) && mComponentName.getClassName().equals(bean.getAppMainServiveName())
&& mComponentName.getPackageName().equals(bean.getNewsPackageName()); && mComponentName.getPackageName().equals(bean.getAppPackageName());
} }
@Override @Override

View File

@ -15,11 +15,11 @@ import cc.winboll.studio.appbase.R;
import cc.winboll.studio.appbase.beans.WinBollNewsBean; import cc.winboll.studio.appbase.beans.WinBollNewsBean;
import cc.winboll.studio.libappbase.AppUtils; import cc.winboll.studio.libappbase.AppUtils;
import cc.winboll.studio.libappbase.LogUtils; import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.bean.APPNewsBean;
import java.io.IOException; import java.io.IOException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import cc.winboll.studio.libappbase.sos.APPModel;
public class WinBollNewsWidget extends AppWidgetProvider { public class WinBollNewsWidget extends AppWidgetProvider {
@ -59,11 +59,11 @@ public class WinBollNewsWidget extends AppWidgetProvider {
LogUtils.d(TAG, String.format("szWinBollNewsBean %s", szWinBollNewsBean)); LogUtils.d(TAG, String.format("szWinBollNewsBean %s", szWinBollNewsBean));
if (szWinBollNewsBean != null && !szWinBollNewsBean.equals("")) { if (szWinBollNewsBean != null && !szWinBollNewsBean.equals("")) {
try { try {
APPNewsBean bean = APPNewsBean.parseStringToBean(szWinBollNewsBean, APPNewsBean.class); APPModel bean = APPModel.parseStringToBean(szWinBollNewsBean, APPModel.class);
if (bean != null) { if (bean != null) {
String szNewsPackageName = bean.getNewsPackageName(); String szNewsPackageName = bean.getAppPackageName();
LogUtils.d(TAG, String.format("szNewsPackageName %s", szNewsPackageName)); LogUtils.d(TAG, String.format("szNewsPackageName %s", szNewsPackageName));
String szNewsClassName = bean.getNewsClassName(); String szNewsClassName = bean.getAppMainServiveName();
LogUtils.d(TAG, String.format("szNewsClassName %s", szNewsClassName)); LogUtils.d(TAG, String.format("szNewsClassName %s", szNewsClassName));

View File

@ -1,6 +1,12 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
repositories { repositories {
// Nexus Maven
// "WinBoll Release"
maven { url "https://nexus.winboll.cc/repository/maven-public/" }
// "WinBoll Snapshot"
maven { url "https://nexus.winboll.cc/repository/maven-snapshots/" }
maven { url 'https://maven.aliyun.com/repository/public/' } maven { url 'https://maven.aliyun.com/repository/public/' }
maven { url 'https://maven.aliyun.com/repository/google/' } maven { url 'https://maven.aliyun.com/repository/google/' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' } maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' }
@ -10,12 +16,6 @@ buildscript {
mavenCentral() mavenCentral()
google() google()
mavenLocal() mavenLocal()
// Nexus Maven
// "WinBoll Release"
maven { url "https://nexus.winboll.cc/repository/maven-public/" }
// "WinBoll Snapshot"
maven { url "https://nexus.winboll.cc/repository/maven-snapshots/" }
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:7.2.1' classpath 'com.android.tools.build:gradle:7.2.1'
@ -26,6 +26,12 @@ buildscript {
allprojects { allprojects {
repositories { repositories {
// Nexus Maven
// "WinBoll Release"
maven { url "https://nexus.winboll.cc/repository/maven-public/" }
// "WinBoll Snapshot"
maven { url "https://nexus.winboll.cc/repository/maven-snapshots/" }
maven { maven {
url "https://mirrors.tencent.com/repository/maven/tencent_public/" url "https://mirrors.tencent.com/repository/maven/tencent_public/"
} }
@ -42,12 +48,6 @@ allprojects {
mavenCentral() mavenCentral()
google() google()
mavenLocal() mavenLocal()
// Nexus Maven
// "WinBoll Release"
maven { url "https://nexus.winboll.cc/repository/maven-public/" }
// "WinBoll Snapshot"
maven { url "https://nexus.winboll.cc/repository/maven-snapshots/" }
} }
ext { ext {
// //

View File

@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle #Created by .winboll/winboll_app_build.gradle
#Thu Feb 27 02:21:32 GMT 2025 #Fri Mar 07 03:14:48 GMT 2025
stageCount=3 stageCount=3
libraryProject=libappbase libraryProject=libappbase
baseVersion=2.0 baseVersion=2.0
publishVersion=2.0.2 publishVersion=2.0.2
buildCount=4 buildCount=5
baseBetaVersion=2.0.3 baseBetaVersion=2.0.3

View File

@ -13,6 +13,7 @@ import android.os.IBinder;
import cc.winboll.studio.libappbase.LogUtils; import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.bean.TestServiceBean; import cc.winboll.studio.libappbase.bean.TestServiceBean;
import cc.winboll.studio.libappbase.sos.WinBoll; import cc.winboll.studio.libappbase.sos.WinBoll;
import cc.winboll.studio.libappbase.sos.APPModel;
public class TestService extends Service { public class TestService extends Service {
@ -129,7 +130,7 @@ public class TestService extends Service {
isStarted = true; isStarted = true;
super.run(); super.run();
LogUtils.d(TAG, "run() start"); LogUtils.d(TAG, "run() start");
WinBoll.bindToAPPBase(mContext, new APPNewsBean(mContext.getPackageName(), TestService.class.getName())); WinBoll.bindToAPPBase(mContext, TestService.class.getName());
while (!isExit()) { while (!isExit()) {
LogUtils.d(TAG, "run()"); LogUtils.d(TAG, "run()");

View File

@ -34,13 +34,13 @@ public class SOS {
static void sos(Context context, String szToPackage, String sosService) { static void sos(Context context, String szToPackage, String sosService) {
LogUtils.d(TAG, "sos(...)"); LogUtils.d(TAG, "sos(...)");
Intent intent = new Intent(ACTION_SOS); Intent intent = new Intent(ACTION_SOS);
intent.putExtra(EXTRA_OBJECT, genSOSObjectString(context.getPackageName(), sosService)); intent.putExtra(EXTRA_OBJECT, genSOSObject(context.getPackageName(), sosService));
intent.setPackage(szToPackage); intent.setPackage(szToPackage);
LogUtils.d(TAG, String.format("ACTION_SOS :\nTo Package : %sSOS Service : %s\n", szToPackage, sosService)); LogUtils.d(TAG, String.format("ACTION_SOS :\nTo Package : %sSOS Service : %s\n", szToPackage, sosService));
context.sendBroadcast(intent); context.sendBroadcast(intent);
} }
static SOSObject stringToSOSObject(String szSOSObject) { public static SOSObject parseSOSObject(String szSOSObject) {
try { try {
return SOSObject.parseStringToBean(szSOSObject, SOSObject.class); return SOSObject.parseStringToBean(szSOSObject, SOSObject.class);
} catch (IOException e) { } catch (IOException e) {
@ -49,11 +49,11 @@ public class SOS {
return null; return null;
} }
static String sosObjectToString(SOSObject object) { public static String sosObjectToString(SOSObject object) {
return object.toString(); return object.toString();
} }
static String genSOSObjectString(String objectPackageName, String objectServiveName) { public static String genSOSObject(String objectPackageName, String objectServiveName) {
return (new SOSObject(objectPackageName, objectServiveName)).toString(); return (new SOSObject(objectPackageName, objectServiveName)).toString();
} }
} }

View File

@ -1,9 +1,5 @@
package cc.winboll.studio.libappbase.sos; package cc.winboll.studio.libappbase.sos;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
/** /**
* @Author ZhanGSKen@AliYun.Com * @Author ZhanGSKen@AliYun.Com
* @Date 2025/02/27 14:00:21 * @Date 2025/02/27 14:00:21
@ -17,8 +13,11 @@ import android.os.IBinder;
import android.os.IInterface; import android.os.IInterface;
import android.os.Parcel; import android.os.Parcel;
import android.os.RemoteException; import android.os.RemoteException;
import cc.winboll.studio.libappbase.bean.SimpleOperateSignalCenterServiceBean;
import java.io.FileDescriptor; import java.io.FileDescriptor;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import cc.winboll.studio.libappbase.LogUtils;
public class SOSCenterService extends Service { public class SOSCenterService extends Service {
@ -26,7 +25,7 @@ public class SOSCenterService extends Service {
private final IBinder binder =(IBinder)new SOSBinder(); private final IBinder binder =(IBinder)new SOSBinder();
SimpleOperateSignalCenterServiceBean mSimpleOperateSignalCenterServiceBean; SOSCenterServiceModel mSOSCenterServiceModel;
static MainThread _MainThread; static MainThread _MainThread;
public static synchronized MainThread getMainThreadInstance() { public static synchronized MainThread getMainThreadInstance() {
if (_MainThread == null) { if (_MainThread == null) {
@ -85,8 +84,8 @@ public class SOSCenterService extends Service {
} }
public static final String TAG = "SOSBinder"; public static final String TAG = "SOSBinder";
SimpleOperateSignalCenterService getService() { SOSCenterService getService() {
return SimpleOperateSignalCenterService.this; return SOSCenterService.this;
} }
} }
@ -94,10 +93,10 @@ public class SOSCenterService extends Service {
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
LogUtils.d(TAG, "onCreate"); LogUtils.d(TAG, "onCreate");
mSimpleOperateSignalCenterServiceBean = SimpleOperateSignalCenterServiceBean.loadBean(this, SimpleOperateSignalCenterServiceBean.class); mSOSCenterServiceModel = SOSCenterServiceModel.loadBean(this, SOSCenterServiceModel.class);
if(mSimpleOperateSignalCenterServiceBean == null) { if(mSOSCenterServiceModel == null) {
mSimpleOperateSignalCenterServiceBean = new SimpleOperateSignalCenterServiceBean(); mSOSCenterServiceModel = new SOSCenterServiceModel();
SimpleOperateSignalCenterServiceBean.saveBean(this, mSimpleOperateSignalCenterServiceBean); SOSCenterServiceModel.saveBean(this, mSOSCenterServiceModel);
} }
runMainThread(); runMainThread();
} }
@ -108,12 +107,12 @@ public class SOSCenterService extends Service {
runMainThread(); runMainThread();
return mSimpleOperateSignalCenterServiceBean.isEnable() ? Service.START_STICKY: super.onStartCommand(intent, flags, startId); return mSOSCenterServiceModel.isEnable() ? Service.START_STICKY: super.onStartCommand(intent, flags, startId);
} }
void runMainThread() { void runMainThread() {
mSimpleOperateSignalCenterServiceBean = SimpleOperateSignalCenterServiceBean.loadBean(this, SimpleOperateSignalCenterServiceBean.class); mSOSCenterServiceModel = mSOSCenterServiceModel.loadBean(this, SOSCenterServiceModel.class);
if (mSimpleOperateSignalCenterServiceBean.isEnable() if (mSOSCenterServiceModel.isEnable()
&& _MainThread == null) { && _MainThread == null) {
getMainThreadInstance().start(); getMainThreadInstance().start();
} }
@ -123,9 +122,9 @@ public class SOSCenterService extends Service {
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();
LogUtils.d(TAG, "onDestroy"); LogUtils.d(TAG, "onDestroy");
mSimpleOperateSignalCenterServiceBean = SimpleOperateSignalCenterServiceBean.loadBean(this, SimpleOperateSignalCenterServiceBean.class); mSOSCenterServiceModel = SOSCenterServiceModel.loadBean(this, SOSCenterServiceModel.class);
if (mSimpleOperateSignalCenterServiceBean.isEnable()) { if (mSOSCenterServiceModel.isEnable()) {
LogUtils.d(TAG, "mSimpleOperateSignalCenterServiceBean.isEnable()"); LogUtils.d(TAG, "mSOSCenterServiceModel.isEnable()");
// ISOSAPP iSOSAPP = (ISOSAPP)getApplication(); // ISOSAPP iSOSAPP = (ISOSAPP)getApplication();
// iSOSAPP.helpISOSService(getISOSServiceIntentWhichAskForHelp()); // iSOSAPP.helpISOSService(getISOSServiceIntentWhichAskForHelp());
} }
@ -137,22 +136,22 @@ public class SOSCenterService extends Service {
public static void stopISOSService(Context context) { public static void stopISOSService(Context context) {
LogUtils.d(TAG, "stopISOSService"); LogUtils.d(TAG, "stopISOSService");
SimpleOperateSignalCenterServiceBean bean = new SimpleOperateSignalCenterServiceBean(); SOSCenterServiceModel bean = new SOSCenterServiceModel();
bean.setIsEnable(false); bean.setIsEnable(false);
SimpleOperateSignalCenterServiceBean.saveBean(context, bean); SOSCenterServiceModel.saveBean(context, bean);
context.stopService(new Intent(context, SimpleOperateSignalCenterService.class)); context.stopService(new Intent(context, SOSCenterServiceModel.class));
} }
public static void startISOSService(Context context) { public static void startISOSService(Context context) {
LogUtils.d(TAG, "startISOSService"); LogUtils.d(TAG, "startISOSService");
SimpleOperateSignalCenterServiceBean bean = new SimpleOperateSignalCenterServiceBean(); SOSCenterServiceModel bean = new SOSCenterServiceModel();
bean.setIsEnable(true); bean.setIsEnable(true);
SimpleOperateSignalCenterServiceBean.saveBean(context, bean); SOSCenterServiceModel.saveBean(context, bean);
context.startService(new Intent(context, SimpleOperateSignalCenterService.class)); context.startService(new Intent(context, SOSCenterServiceModel.class));
} }
public String getMessage() { public String getMessage() {
return "Hello from SimpleOperateSignalCenterService"; return "Hello from SOSCenterServiceModel";
} }
static class MainThread extends Thread { static class MainThread extends Thread {

View File

@ -1,24 +1,25 @@
package cc.winboll.studio.libappbase.sos; package cc.winboll.studio.libappbase.sos;
/** /**
* @Author ZhanGSKen@AliYun.Com * @Author ZhanGSKen@AliYun.Com
* @Date 2025/02/27 14:04:35 * @Date 2025/02/27 14:04:35
* @Describe SOSCenterServiceReceiver * @Describe SOSCenterServiceReceiver
*/ */
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import cc.winboll.studio.libappbase.LogUtils;
public class SOSCenterServiceReceiver extends BroadcastReceiver { public class SOSCenterServiceReceiver extends BroadcastReceiver {
public static final String TAG = "SOSCenterServiceReceiver"; public static final String TAG = "SOSCenterServiceReceiver";
public static final String ACTION_SOS = SOSCenterServiceReceiver.class.getName() + ".ACTION_SOS"; public static final String ACTION_SOS = SOSCenterServiceReceiver.class.getName() + ".ACTION_SOS";
public static final String
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
String action = intent.getAction(); String action = intent.getAction();
if (action.equals(ACTION_SOS)) { if (action.equals(ACTION_SOS)) {
// 处理接收到的广播消息 // 处理接收到的广播消息
LogUtils.d(TAG, String.format("Action %s \n%s\n%s", action)); LogUtils.d(TAG, String.format("Action %s \n%s\n%s", action));
} else { } else {