WinBoll 应用体系重构
This commit is contained in:
parent
fb7017a857
commit
bca31f9079
@ -12,7 +12,7 @@ import java.io.IOException;
|
||||
|
||||
public class WinBollNewsBean extends BaseBean {
|
||||
|
||||
public static final String TAG = "APPSOSReportBean";
|
||||
public static final String TAG = "WinBollNewsBean";
|
||||
|
||||
protected String message;
|
||||
|
||||
|
@ -27,12 +27,10 @@ import java.util.Date;
|
||||
public class MainReceiver extends BroadcastReceiver {
|
||||
|
||||
public static final String TAG = "MainReceiver";
|
||||
|
||||
public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
|
||||
|
||||
WeakReference<MainService> mwrService;
|
||||
// 存储电量指示值,
|
||||
// 用于校验电量消息时的电量变化
|
||||
static volatile int _mnTheQuantityOfElectricityOld = -1;
|
||||
static volatile boolean _mIsCharging = false;
|
||||
|
||||
public MainReceiver(MainService service) {
|
||||
mwrService = new WeakReference<MainService>(service);
|
||||
@ -102,7 +100,7 @@ public class MainReceiver extends BroadcastReceiver {
|
||||
appWinBollNewsBean.setMessage(sbLine.toString());
|
||||
|
||||
WinBollNewsWidget.addWinBollNewsBean(context, appWinBollNewsBean);
|
||||
|
||||
|
||||
Intent intentWidget = new Intent(context, WinBollNewsWidget.class);
|
||||
intentWidget.setAction(WinBollNewsWidget.ACTION_RELOAD_REPORT);
|
||||
context.sendBroadcast(intentWidget);
|
||||
|
@ -73,6 +73,18 @@
|
||||
|
||||
</receiver>
|
||||
|
||||
<service android:name="cc.winboll.studio.libappbase.sos.SOSCenter"/>
|
||||
|
||||
<receiver android:name="cc.winboll.studio.libappbase.sos.SOSCenterServiceReceiver">
|
||||
|
||||
<intent-filter>
|
||||
|
||||
<action android:name="cc.winboll.studio.libappbase.sos.SOSCenterServiceReceiver"/>
|
||||
|
||||
</intent-filter>
|
||||
|
||||
</receiver>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
</manifest>
|
@ -1,32 +0,0 @@
|
||||
package cc.winboll.studio.libappbase;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/02/12 23:44:57
|
||||
* @Describe 简单信号通信中心接收器
|
||||
*/
|
||||
public class SOSCSBroadcastReceiver extends BroadcastReceiver {
|
||||
|
||||
public static final String TAG = "SOSCSBroadcastReceiver";
|
||||
public static final String ACTION_SOS = SOSCSBroadcastReceiver.class.getName() + ".ACTION_SOS";
|
||||
|
||||
//ISOSAPP mISOSAPP;
|
||||
|
||||
public SOSCSBroadcastReceiver() {
|
||||
//mISOSAPP = iSOSAPP;
|
||||
}
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (action.equals(ACTION_SOS)) {
|
||||
LogUtils.d(TAG, "ACTION_SOS");
|
||||
//mISOSAPP.helpISOSService(intent);
|
||||
} else {
|
||||
LogUtils.d(TAG, String.format("%s", action));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,59 +1,3 @@
|
||||
package cc.winboll.studio.libappbase;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/02/13 21:09:36
|
||||
* @Describe SOS 组件
|
||||
*/
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
import cc.winboll.studio.libappbase.bean.APPNewsBean;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class WinBoll {
|
||||
|
||||
public static final String TAG = "WinBoll";
|
||||
|
||||
public static final String ACTION_SOS = WinBoll.class.getName() + ".ACTION_SOS";
|
||||
public static final String ACTION_BIND = WinBoll.class.getName() + ".ACTION_BIND";
|
||||
public static final String ACTION_SERVICE_ENABLE = WinBoll.class.getName() + ".ACTION_SERVICE_ENABLE";
|
||||
public static final String ACTION_SERVICE_DISABLE = WinBoll.class.getName() + ".ACTION_SERVICE_DISENABLE";
|
||||
public static final String EXTRA_SOS = "EXTRA_SOS";
|
||||
public static final String EXTRA_APPNEWSBEAN = "EXTRA_APPNEWSBEAN";
|
||||
|
||||
public static void sosService(Context context, APPNewsBean bean) {
|
||||
Intent intent = new Intent(ACTION_SOS);
|
||||
intent.putExtra(EXTRA_SOS, "Service");
|
||||
intent.putExtra(EXTRA_APPNEWSBEAN, bean.toString());
|
||||
String szToPackage = "";
|
||||
if (GlobalApplication.isDebuging()) {
|
||||
szToPackage = "cc.winboll.studio.appbase.beta";
|
||||
} else {
|
||||
szToPackage = "cc.winboll.studio.appbase";
|
||||
}
|
||||
intent.setPackage(szToPackage);
|
||||
context.sendBroadcast(intent);
|
||||
|
||||
LogUtils.d(TAG, String.format("Send ACTION_SOS To WinBoll. (szToPackage : %s)", szToPackage));
|
||||
//ToastUtils.show("SOS Send To WinBoll");
|
||||
}
|
||||
|
||||
public static void bindToAPPBase(Context context, APPNewsBean bean) {
|
||||
Intent intent = new Intent(ACTION_BIND);
|
||||
intent.putExtra(EXTRA_SOS, "Service");
|
||||
intent.putExtra(EXTRA_APPNEWSBEAN, bean.toString());
|
||||
String szToPackage = "";
|
||||
if (GlobalApplication.isDebuging()) {
|
||||
szToPackage = "cc.winboll.studio.appbase.beta";
|
||||
} else {
|
||||
szToPackage = "cc.winboll.studio.appbase";
|
||||
}
|
||||
intent.setPackage(szToPackage);
|
||||
context.sendBroadcast(intent);
|
||||
LogUtils.d(TAG, String.format("Send ACTION_BIND To WinBoll. (szToPackage : %s)", szToPackage));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,87 +0,0 @@
|
||||
package cc.winboll.studio.libappbase.bean;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/02/17 00:29:29
|
||||
* @Describe APPSOSReportBean
|
||||
*/
|
||||
import android.util.JsonReader;
|
||||
import android.util.JsonWriter;
|
||||
import cc.winboll.studio.libappbase.BaseBean;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
|
||||
public class APPNewsBean extends BaseBean {
|
||||
|
||||
public static final String TAG = "APPNewsBean";
|
||||
|
||||
protected String newsPackageName;
|
||||
protected String newsClassName;
|
||||
|
||||
public APPNewsBean() {
|
||||
this.newsPackageName = "";
|
||||
this.newsClassName = "";
|
||||
}
|
||||
|
||||
public APPNewsBean(String newsPackageName, String newsClassName) {
|
||||
this.newsPackageName = newsPackageName;
|
||||
this.newsClassName = newsClassName;
|
||||
}
|
||||
|
||||
public void setNewsPackageName(String newsPackageName) {
|
||||
this.newsPackageName = newsPackageName;
|
||||
}
|
||||
|
||||
public String getNewsPackageName() {
|
||||
return newsPackageName;
|
||||
}
|
||||
|
||||
public void setNewsClassName(String sosClassName) {
|
||||
this.newsClassName = sosClassName;
|
||||
}
|
||||
|
||||
public String getNewsClassName() {
|
||||
return newsClassName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return APPNewsBean.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
||||
super.writeThisToJsonWriter(jsonWriter);
|
||||
jsonWriter.name("newsPackageName").value(getNewsPackageName());
|
||||
jsonWriter.name("newsClassName").value(getNewsClassName());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
|
||||
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
|
||||
if (name.equals("newsPackageName")) {
|
||||
setNewsPackageName(jsonReader.nextString());
|
||||
} else if (name.equals("newsClassName")) {
|
||||
setNewsClassName(jsonReader.nextString());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException {
|
||||
jsonReader.beginObject();
|
||||
while (jsonReader.hasNext()) {
|
||||
String name = jsonReader.nextName();
|
||||
if (!initObjectsFromJsonReader(jsonReader, name)) {
|
||||
jsonReader.skipValue();
|
||||
}
|
||||
}
|
||||
// 结束 JSON 对象
|
||||
jsonReader.endObject();
|
||||
return this;
|
||||
}
|
||||
}
|
@ -11,9 +11,8 @@ import android.content.Intent;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.WinBoll;
|
||||
import cc.winboll.studio.libappbase.bean.APPNewsBean;
|
||||
import cc.winboll.studio.libappbase.bean.TestServiceBean;
|
||||
import cc.winboll.studio.libappbase.sos.WinBoll;
|
||||
|
||||
public class TestService extends Service {
|
||||
|
||||
@ -58,14 +57,14 @@ public class TestService extends Service {
|
||||
if (bean == null) {
|
||||
bean = new TestServiceBean();
|
||||
}
|
||||
if (intent.getAction() != null && intent.getAction().equals(WinBoll.ACTION_SERVICE_ENABLE)) {
|
||||
bean.setIsEnable(true);
|
||||
TestServiceBean.saveBean(this, bean);
|
||||
run();
|
||||
} else if (intent.getAction() != null && intent.getAction().equals(WinBoll.ACTION_SERVICE_DISABLE)) {
|
||||
bean.setIsEnable(false);
|
||||
TestServiceBean.saveBean(this, bean);
|
||||
}
|
||||
// if (intent.getAction() != null && intent.getAction().equals(WinBoll.ACTION_SERVICE_ENABLE)) {
|
||||
// bean.setIsEnable(true);
|
||||
// TestServiceBean.saveBean(this, bean);
|
||||
// run();
|
||||
// } else if (intent.getAction() != null && intent.getAction().equals(WinBoll.ACTION_SERVICE_DISABLE)) {
|
||||
// bean.setIsEnable(false);
|
||||
// TestServiceBean.saveBean(this, bean);
|
||||
// }
|
||||
LogUtils.d(TAG, String.format("TestServiceBean.saveBean setIsEnable %s", bean.isEnable()));
|
||||
return (bean.isEnable()) ? START_STICKY : super.onStartCommand(intent, flags, startId);
|
||||
//return super.onStartCommand(intent, flags, startId);
|
||||
|
@ -0,0 +1,86 @@
|
||||
package cc.winboll.studio.libappbase.sos;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/02 10:28:08
|
||||
* @Describe APPModel
|
||||
*/
|
||||
import android.util.JsonReader;
|
||||
import android.util.JsonWriter;
|
||||
import cc.winboll.studio.libappbase.BaseBean;
|
||||
import java.io.IOException;
|
||||
|
||||
public class APPModel extends BaseBean {
|
||||
|
||||
public static final String TAG = "APPModel";
|
||||
|
||||
String appPackageName;
|
||||
String appMainServiveName;
|
||||
|
||||
public APPModel() {
|
||||
this.appPackageName = "";
|
||||
this.appMainServiveName = "";
|
||||
}
|
||||
|
||||
public APPModel(String appPackageName, String appMainServiveName) {
|
||||
this.appPackageName = appPackageName;
|
||||
this.appMainServiveName = appMainServiveName;
|
||||
}
|
||||
|
||||
public void setAppPackageName(String appPackageName) {
|
||||
this.appPackageName = appPackageName;
|
||||
}
|
||||
|
||||
public String getAppPackageName() {
|
||||
return appPackageName;
|
||||
}
|
||||
|
||||
public void setAppMainServiveName(String appMainServiveName) {
|
||||
this.appMainServiveName = appMainServiveName;
|
||||
}
|
||||
|
||||
public String getAppMainServiveName() {
|
||||
return appMainServiveName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return APPModel.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
||||
super.writeThisToJsonWriter(jsonWriter);
|
||||
jsonWriter.name("appPackageName").value(getAppPackageName());
|
||||
jsonWriter.name("appMainServiveName").value(getAppMainServiveName());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
|
||||
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
|
||||
if (name.equals("appPackageName")) {
|
||||
setAppPackageName(jsonReader.nextString());
|
||||
} else if (name.equals("appMainServiveName")) {
|
||||
setAppMainServiveName(jsonReader.nextString());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException {
|
||||
jsonReader.beginObject();
|
||||
while (jsonReader.hasNext()) {
|
||||
String name = jsonReader.nextName();
|
||||
if (!initObjectsFromJsonReader(jsonReader, name)) {
|
||||
jsonReader.skipValue();
|
||||
}
|
||||
}
|
||||
// 结束 JSON 对象
|
||||
jsonReader.endObject();
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package cc.winboll.studio.libappbase.sos;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/02 09:36:29
|
||||
* @Describe WinBoll 应用 SOS 机理保护类
|
||||
*/
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import java.io.IOException;
|
||||
|
||||
public class SOS {
|
||||
|
||||
public static final String TAG = "SOS";
|
||||
|
||||
public static final String ACTION_SOS = SOS.class.getName() + ".ACTION_SOS";
|
||||
public static final String EXTRA_OBJECT = "EXTRA_OBJECT";
|
||||
|
||||
public static void sosToAppBase(Context context, String sosService) {
|
||||
LogUtils.d(TAG, "sosToAppBase()");
|
||||
String szToPackage = "cc.winboll.studio.appbase";
|
||||
sos(context, szToPackage, sosService);
|
||||
|
||||
}
|
||||
|
||||
public static void sosToAppBaseBeta(Context context, String sosService) {
|
||||
LogUtils.d(TAG, "sosToAppBaseBeta()");
|
||||
String szToPackage = "cc.winboll.studio.appbase.beta";
|
||||
sos(context, szToPackage, sosService);
|
||||
|
||||
}
|
||||
|
||||
static void sos(Context context, String szToPackage, String sosService) {
|
||||
LogUtils.d(TAG, "sos(...)");
|
||||
Intent intent = new Intent(ACTION_SOS);
|
||||
intent.putExtra(EXTRA_OBJECT, genSOSObjectString(context.getPackageName(), sosService));
|
||||
intent.setPackage(szToPackage);
|
||||
LogUtils.d(TAG, String.format("ACTION_SOS :\nTo Package : %sSOS Service : %s\n", szToPackage, sosService));
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
static SOSObject stringToSOSObject(String szSOSObject) {
|
||||
try {
|
||||
return SOSObject.parseStringToBean(szSOSObject, SOSObject.class);
|
||||
} catch (IOException e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static String sosObjectToString(SOSObject object) {
|
||||
return object.toString();
|
||||
}
|
||||
|
||||
static String genSOSObjectString(String objectPackageName, String objectServiveName) {
|
||||
return (new SOSObject(objectPackageName, objectServiveName)).toString();
|
||||
}
|
||||
}
|
@ -1,10 +1,14 @@
|
||||
package cc.winboll.studio.libappbase;
|
||||
package cc.winboll.studio.libappbase.sos;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/02/12 11:12:25
|
||||
* @Describe 简单信号服务中心
|
||||
* @Date 2025/02/27 14:00:21
|
||||
* @Describe Simple Operate Signal Service Center.
|
||||
* 简单操作信号服务中心
|
||||
*/
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
@ -16,14 +20,12 @@ import android.os.RemoteException;
|
||||
import cc.winboll.studio.libappbase.bean.SimpleOperateSignalCenterServiceBean;
|
||||
import java.io.FileDescriptor;
|
||||
|
||||
public class SimpleOperateSignalCenterService extends Service {
|
||||
public class SOSCenterService extends Service {
|
||||
|
||||
public static final String TAG = "SimpleOperateSignalCenterService";
|
||||
public static final String ACTION_ENABLE = SimpleOperateSignalCenterService.class.getName() + ".ACTION_ENABLE";
|
||||
public static final String ACTION_DISABLE = SimpleOperateSignalCenterService.class.getName() + ".ACTION_DISABLE";
|
||||
public static final String TAG = "SOSCenterService";
|
||||
|
||||
private final IBinder binder =(IBinder)new SOSBinder();
|
||||
|
||||
|
||||
SimpleOperateSignalCenterServiceBean mSimpleOperateSignalCenterServiceBean;
|
||||
static MainThread _MainThread;
|
||||
public static synchronized MainThread getMainThreadInstance() {
|
||||
@ -37,7 +39,7 @@ public class SimpleOperateSignalCenterService extends Service {
|
||||
public IBinder onBind(Intent intent) {
|
||||
return binder;
|
||||
}
|
||||
|
||||
|
||||
public class SOSBinder implements IBinder {
|
||||
|
||||
@Override
|
||||
@ -81,13 +83,13 @@ public class SimpleOperateSignalCenterService extends Service {
|
||||
public boolean unlinkToDeath(IBinder.DeathRecipient deathRecipient, int p) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static final String TAG = "SOSBinder";
|
||||
SimpleOperateSignalCenterService getService() {
|
||||
return SimpleOperateSignalCenterService.this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
@ -103,15 +105,9 @@ public class SimpleOperateSignalCenterService extends Service {
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
LogUtils.d(TAG, "onStartCommand");
|
||||
// if (intent.getBooleanExtra(ISOSService.EXTRA_ENABLE, false)) {
|
||||
// LogUtils.d(TAG, "onStartCommand enable service");
|
||||
// mSimpleOperateSignalCenterServiceBean.setIsEnable(true);
|
||||
// SimpleOperateSignalCenterServiceBean.saveBean(this, mSimpleOperateSignalCenterServiceBean);
|
||||
// }
|
||||
|
||||
runMainThread();
|
||||
|
||||
//return super.onStartCommand(intent, flags, startId);
|
||||
return mSimpleOperateSignalCenterServiceBean.isEnable() ? Service.START_STICKY: super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
|
||||
@ -154,7 +150,7 @@ public class SimpleOperateSignalCenterService extends Service {
|
||||
SimpleOperateSignalCenterServiceBean.saveBean(context, bean);
|
||||
context.startService(new Intent(context, SimpleOperateSignalCenterService.class));
|
||||
}
|
||||
|
||||
|
||||
public String getMessage() {
|
||||
return "Hello from SimpleOperateSignalCenterService";
|
||||
}
|
@ -1,20 +1,23 @@
|
||||
package cc.winboll.studio.libappbase.bean;
|
||||
package cc.winboll.studio.libappbase.sos;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/02 09:49:45
|
||||
* @Describe SOSCenterServiceModel
|
||||
* Simple Operate Signal Service Model.
|
||||
*/
|
||||
import android.util.JsonReader;
|
||||
import android.util.JsonWriter;
|
||||
import cc.winboll.studio.libappbase.BaseBean;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/02/13 04:27:42
|
||||
*/
|
||||
public class SimpleOperateSignalCenterServiceBean extends BaseBean {
|
||||
public class SOSCenterServiceModel extends BaseBean {
|
||||
|
||||
public static final String TAG = "SimpleOperateSignalCenterServiceBean";
|
||||
public static final String TAG = "SOSCenterServiceModel";
|
||||
|
||||
boolean isEnable;
|
||||
|
||||
public SimpleOperateSignalCenterServiceBean() {
|
||||
|
||||
public SOSCenterServiceModel() {
|
||||
this.isEnable = false;
|
||||
}
|
||||
|
||||
@ -28,7 +31,7 @@ public class SimpleOperateSignalCenterServiceBean extends BaseBean {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return SimpleOperateSignalCenterServiceBean.class.getName();
|
||||
return SOSCenterServiceModel.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
@ -0,0 +1,28 @@
|
||||
package cc.winboll.studio.libappbase.sos;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/02/27 14:04:35
|
||||
* @Describe SOSCenterServiceReceiver
|
||||
*/
|
||||
public class SOSCenterServiceReceiver extends BroadcastReceiver {
|
||||
|
||||
public static final String TAG = "SOSCenterServiceReceiver";
|
||||
|
||||
public static final String ACTION_SOS = SOSCenterServiceReceiver.class.getName() + ".ACTION_SOS";
|
||||
public static final String
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (action.equals(ACTION_SOS)) {
|
||||
|
||||
// 处理接收到的广播消息
|
||||
LogUtils.d(TAG, String.format("Action %s \n%s\n%s", action));
|
||||
} else {
|
||||
LogUtils.d(TAG, String.format("%s", action));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package cc.winboll.studio.libappbase.sos;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/02/27 14:12:05
|
||||
* @Describe SOSBean
|
||||
*/
|
||||
import android.util.JsonReader;
|
||||
import android.util.JsonWriter;
|
||||
import cc.winboll.studio.libappbase.BaseBean;
|
||||
import java.io.IOException;
|
||||
|
||||
public class SOSObject extends BaseBean {
|
||||
|
||||
public static final String TAG = "SOSObject";
|
||||
|
||||
String objectPackageName;
|
||||
String objectServiveName;
|
||||
|
||||
public SOSObject() {
|
||||
this.objectPackageName = "";
|
||||
this.objectServiveName = "";
|
||||
}
|
||||
|
||||
public SOSObject(String objectPackageName, String objectServiveName) {
|
||||
this.objectPackageName = objectPackageName;
|
||||
this.objectServiveName = objectServiveName;
|
||||
}
|
||||
|
||||
public void setObjectPackageName(String objectPackageName) {
|
||||
this.objectPackageName = objectPackageName;
|
||||
}
|
||||
|
||||
public String getObjectPackageName() {
|
||||
return objectPackageName;
|
||||
}
|
||||
|
||||
public void setObjectServiveName(String objectServiveName) {
|
||||
this.objectServiveName = objectServiveName;
|
||||
}
|
||||
|
||||
public String getObjectServiveName() {
|
||||
return objectServiveName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return SOSObject.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
||||
super.writeThisToJsonWriter(jsonWriter);
|
||||
jsonWriter.name("objectPackageName").value(getObjectPackageName());
|
||||
jsonWriter.name("objectServiveName").value(getObjectServiveName());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
|
||||
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
|
||||
if (name.equals("objectPackageName")) {
|
||||
setObjectPackageName(jsonReader.nextString());
|
||||
} else if (name.equals("objectServiveName")) {
|
||||
setObjectServiveName(jsonReader.nextString());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException {
|
||||
jsonReader.beginObject();
|
||||
while (jsonReader.hasNext()) {
|
||||
String name = jsonReader.nextName();
|
||||
if (!initObjectsFromJsonReader(jsonReader, name)) {
|
||||
jsonReader.skipValue();
|
||||
}
|
||||
}
|
||||
// 结束 JSON 对象
|
||||
jsonReader.endObject();
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package cc.winboll.studio.libappbase.sos;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/02 09:54:28
|
||||
* @Describe WinBoll 系列应用通用管理类
|
||||
*/
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
|
||||
public class WinBoll {
|
||||
|
||||
public static final String TAG = "WinBoll";
|
||||
|
||||
public static final String ACTION_BIND = WinBoll.class.getName() + ".ACTION_BIND";
|
||||
public static final String EXTRA_APPMODEL = "EXTRA_APP";
|
||||
|
||||
public static void bindToAPPBase(Context context, String appMainService) {
|
||||
String toPackage = "cc.winboll.studio.appbase";
|
||||
startBind(context, toPackage, appMainService);
|
||||
}
|
||||
|
||||
public static void bindToAPPBaseBeta(Context context, String appMainService) {
|
||||
String toPackage = "cc.winboll.studio.appbase.beta";
|
||||
startBind(context, toPackage, appMainService);
|
||||
}
|
||||
|
||||
static void startBind(Context context, String toPackage, String appMainService) {
|
||||
Intent intent = new Intent(ACTION_BIND);
|
||||
intent.putExtra(EXTRA_APPMODEL, (new APPModel(toPackage, appMainService)).toString());
|
||||
intent.setPackage(toPackage);
|
||||
LogUtils.d(TAG, String.format("ACTION_BIND :\nTo Package : %s\nAPP Main Service : %s", toPackage, appMainService));
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user