1115
This commit is contained in:
@@ -44,7 +44,7 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api project(':libappbase')
|
||||
implementation project(':libappbase')
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
// 二维码类库
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#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
|
||||
libraryProject=libappbase
|
||||
baseVersion=2.0
|
||||
publishVersion=2.0.2
|
||||
buildCount=4
|
||||
buildCount=5
|
||||
baseBetaVersion=2.0.3
|
||||
|
@@ -6,22 +6,23 @@ package cc.winboll.studio.appbase;
|
||||
* @Describe APPbase 应用类
|
||||
*/
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import cc.winboll.studio.libappbase.SOSCSBroadcastReceiver;
|
||||
import android.content.IntentFilter;
|
||||
import cc.winboll.studio.libappbase.sos.SOSCenterServiceReceiver;
|
||||
import cc.winboll.studio.libappbase.sos.SOS;
|
||||
|
||||
public class App extends GlobalApplication {
|
||||
|
||||
public static final String TAG = "App";
|
||||
|
||||
SOSCSBroadcastReceiver mSOSCSBroadcastReceiver;
|
||||
SOSCenterServiceReceiver mSOSCenterServiceReceiver;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
GlobalApplication.setIsDebuging(this, BuildConfig.DEBUG);
|
||||
mSOSCSBroadcastReceiver = new SOSCSBroadcastReceiver();
|
||||
mSOSCenterServiceReceiver = new SOSCenterServiceReceiver();
|
||||
IntentFilter intentFilter = new IntentFilter();
|
||||
intentFilter.addAction(SOSCSBroadcastReceiver.ACTION_SOS);
|
||||
registerReceiver(mSOSCSBroadcastReceiver, intentFilter);
|
||||
intentFilter.addAction(SOS.ACTION_SOS);
|
||||
registerReceiver(mSOSCenterServiceReceiver, intentFilter);
|
||||
}
|
||||
}
|
||||
|
@@ -12,12 +12,10 @@ import cc.winboll.studio.appbase.services.MainService;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
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.widgets.StatusWidget;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import cc.winboll.studio.libappbase.sos.SOS;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@@ -69,44 +67,44 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
public void onTestStopWithoutSettingEnable(View view) {
|
||||
LogUtils.d(TAG, "onTestStopWithoutSettingEnable");
|
||||
stopService(new Intent(this, SimpleOperateSignalCenterService.class));
|
||||
// LogUtils.d(TAG, "onTestStopWithoutSettingEnable");
|
||||
// stopService(new Intent(this, SimpleOperateSignalCenterService.class));
|
||||
}
|
||||
|
||||
public void onTestStartWithString(View view) {
|
||||
LogUtils.d(TAG, "onTestStartWithString");
|
||||
|
||||
// 目标服务的包名和类名
|
||||
String packageName = this.getPackageName();
|
||||
String serviceClassName = SimpleOperateSignalCenterService.class.getName();
|
||||
|
||||
// 构建Intent
|
||||
Intent intentService = new Intent();
|
||||
intentService.setComponent(new ComponentName(packageName, serviceClassName));
|
||||
|
||||
startService(intentService);
|
||||
// String packageName = this.getPackageName();
|
||||
// String serviceClassName = SimpleOperateSignalCenterService.class.getName();
|
||||
//
|
||||
// // 构建Intent
|
||||
// Intent intentService = new Intent();
|
||||
// intentService.setComponent(new ComponentName(packageName, serviceClassName));
|
||||
//
|
||||
// startService(intentService);
|
||||
}
|
||||
|
||||
public void onSOS(View view) {
|
||||
Intent intent = new Intent(this, TestService.class);
|
||||
stopService(intent);
|
||||
WinBoll.sosService(this, new APPNewsBean(getPackageName(), TestService.class.getName()));
|
||||
// Intent intent = new Intent(this, TestService.class);
|
||||
// stopService(intent);
|
||||
// SOS.se(this, new APPNewsBean(getPackageName(), TestService.class.getName()));
|
||||
}
|
||||
|
||||
public void onStartTestService(View view) {
|
||||
Intent intent = new Intent(this, TestService.class);
|
||||
intent.setAction(WinBoll.ACTION_SERVICE_ENABLE);
|
||||
startService(intent);
|
||||
// Intent intent = new Intent(this, TestService.class);
|
||||
// intent.setAction(WinBoll.ACTION_SERVICE_ENABLE);
|
||||
// startService(intent);
|
||||
|
||||
}
|
||||
|
||||
public void onStopTestService(View view) {
|
||||
Intent intent = new Intent(this, TestService.class);
|
||||
intent.setAction(WinBoll.ACTION_SERVICE_DISABLE);
|
||||
startService(intent);
|
||||
|
||||
Intent intentStop = new Intent(this, TestService.class);
|
||||
stopService(intentStop);
|
||||
// Intent intent = new Intent(this, TestService.class);
|
||||
// intent.setAction(WinBoll.ACTION_SERVICE_DISABLE);
|
||||
// startService(intent);
|
||||
//
|
||||
// Intent intentStop = new Intent(this, TestService.class);
|
||||
// stopService(intentStop);
|
||||
}
|
||||
|
||||
public void onStopTestServiceNoSettings(View view) {
|
||||
|
@@ -16,13 +16,15 @@ import cc.winboll.studio.appbase.services.MainService;
|
||||
import cc.winboll.studio.appbase.widgets.WinBollNewsWidget;
|
||||
import cc.winboll.studio.libappbase.AppUtils;
|
||||
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 java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.text.SimpleDateFormat;
|
||||
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 {
|
||||
|
||||
@@ -52,12 +54,12 @@ public class MainReceiver extends BroadcastReceiver {
|
||||
LogUtils.d(TAG, String.format("szAPPSOSBean %s", szAPPSOSBean));
|
||||
if (szAPPSOSBean != null && !szAPPSOSBean.equals("")) {
|
||||
try {
|
||||
APPNewsBean bean = APPNewsBean.parseStringToBean(szAPPSOSBean, APPNewsBean.class);
|
||||
APPModel bean = APPModel.parseStringToBean(szAPPSOSBean, APPModel.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));
|
||||
String szAppPackageName = bean.getAppPackageName();
|
||||
LogUtils.d(TAG, String.format("szAppPackageName %s", szAppPackageName));
|
||||
String szAppMainServiveName = bean.getAppMainServiveName();
|
||||
LogUtils.d(TAG, String.format("szNewsClassName %s", szAppMainServiveName));
|
||||
mwrService.get().bindSOSConnection(bean);
|
||||
}
|
||||
} 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, String.format("context.getPackageName() %s", context.getPackageName()));
|
||||
LogUtils.d(TAG, String.format("intent.getAction() %s", intent.getAction()));
|
||||
String SOS = intent.getStringExtra("SOS");
|
||||
LogUtils.d(TAG, String.format("SOS %s", SOS));
|
||||
if (SOS != null && SOS.equals("Service")) {
|
||||
String szAPPNewsBean = intent.getStringExtra("APPSOSBean");
|
||||
LogUtils.d(TAG, String.format("szAPPNewsBean %s", szAPPNewsBean));
|
||||
if (szAPPNewsBean != null && !szAPPNewsBean.equals("")) {
|
||||
try {
|
||||
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));
|
||||
String sos = intent.getStringExtra(SOS.EXTRA_OBJECT);
|
||||
LogUtils.d(TAG, String.format("SOS %s", sos));
|
||||
if (sos != null && sos.equals("")) {
|
||||
SOSObject bean = SOS.parseSOSObject(sos);
|
||||
if (bean != null) {
|
||||
String szObjectPackageName = bean.getObjectPackageName();
|
||||
LogUtils.d(TAG, String.format("szObjectPackageName %s", szObjectPackageName));
|
||||
String szObjectServiveName = bean.getObjectServiveName();
|
||||
LogUtils.d(TAG, String.format("szObjectServiveName %s", szObjectServiveName));
|
||||
|
||||
Intent intentService = new Intent();
|
||||
intentService.setComponent(new ComponentName(szNewsPackageName, szNewsClassName));
|
||||
context.startService(intentService);
|
||||
Intent intentService = new Intent();
|
||||
intentService.setComponent(new ComponentName(szObjectPackageName, szObjectServiveName));
|
||||
context.startService(intentService);
|
||||
|
||||
String appName = AppUtils.getAppNameByPackageName(context, szNewsPackageName);
|
||||
LogUtils.d(TAG, String.format("appName %s", appName));
|
||||
WinBollNewsBean appWinBollNewsBean = new WinBollNewsBean(appName);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
|
||||
String currentTime = sdf.format(new Date());
|
||||
StringBuilder sbLine = new StringBuilder();
|
||||
sbLine.append("[");
|
||||
sbLine.append(currentTime);
|
||||
sbLine.append("] Power to ");
|
||||
sbLine.append(appName);
|
||||
appWinBollNewsBean.setMessage(sbLine.toString());
|
||||
String appName = AppUtils.getAppNameByPackageName(context, szObjectPackageName);
|
||||
LogUtils.d(TAG, String.format("appName %s", appName));
|
||||
WinBollNewsBean appWinBollNewsBean = new WinBollNewsBean(appName);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
|
||||
String currentTime = sdf.format(new Date());
|
||||
StringBuilder sbLine = new StringBuilder();
|
||||
sbLine.append("[");
|
||||
sbLine.append(currentTime);
|
||||
sbLine.append("] Power to ");
|
||||
sbLine.append(appName);
|
||||
appWinBollNewsBean.setMessage(sbLine.toString());
|
||||
|
||||
WinBollNewsWidget.addWinBollNewsBean(context, appWinBollNewsBean);
|
||||
WinBollNewsWidget.addWinBollNewsBean(context, appWinBollNewsBean);
|
||||
|
||||
Intent intentWidget = new Intent(context, WinBollNewsWidget.class);
|
||||
intentWidget.setAction(WinBollNewsWidget.ACTION_RELOAD_REPORT);
|
||||
context.sendBroadcast(intentWidget);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
Intent intentWidget = new Intent(context, WinBollNewsWidget.class);
|
||||
intentWidget.setAction(WinBollNewsWidget.ACTION_RELOAD_REPORT);
|
||||
context.sendBroadcast(intentWidget);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
ToastUtils.show(szAction);
|
||||
@@ -120,10 +114,8 @@ public class MainReceiver extends BroadcastReceiver {
|
||||
public void registerAction(MainService service) {
|
||||
IntentFilter filter=new IntentFilter();
|
||||
filter.addAction(ACTION_BOOT_COMPLETED);
|
||||
filter.addAction(WinBoll.ACTION_SOS);
|
||||
filter.addAction(SOS.ACTION_SOS);
|
||||
filter.addAction(WinBoll.ACTION_BIND);
|
||||
filter.addAction(WinBoll.ACTION_SERVICE_ENABLE);
|
||||
filter.addAction(WinBoll.ACTION_SERVICE_DISABLE);
|
||||
//filter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
||||
service.registerReceiver(this, filter);
|
||||
}
|
||||
|
@@ -25,8 +25,8 @@ import cc.winboll.studio.appbase.services.AssistantService;
|
||||
import cc.winboll.studio.appbase.threads.MainServiceThread;
|
||||
import cc.winboll.studio.appbase.widgets.WinBollNewsWidget;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.bean.APPNewsBean;
|
||||
import java.util.ArrayList;
|
||||
import cc.winboll.studio.libappbase.sos.APPModel;
|
||||
|
||||
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(...)");
|
||||
// 清理旧的绑定链接
|
||||
for (int i = mSOSConnectionList.size() - 1; i > -1; i--) {
|
||||
@@ -207,13 +207,13 @@ public class MainService extends Service {
|
||||
// 绑定服务
|
||||
SOSConnection sosConnection = new SOSConnection();
|
||||
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);
|
||||
mSOSConnectionList.add(sosConnection);
|
||||
|
||||
Intent intentWidget = new Intent(this, WinBollNewsWidget.class);
|
||||
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());
|
||||
sendBroadcast(intentWidget);
|
||||
}
|
||||
@@ -222,10 +222,10 @@ public class MainService extends Service {
|
||||
|
||||
ComponentName mComponentName;
|
||||
|
||||
boolean isBindToAPPSOSBean(APPNewsBean bean) {
|
||||
boolean isBindToAPPSOSBean(APPModel bean) {
|
||||
return mComponentName != null
|
||||
&& mComponentName.getClassName().equals(bean.getNewsClassName())
|
||||
&& mComponentName.getPackageName().equals(bean.getNewsPackageName());
|
||||
&& mComponentName.getClassName().equals(bean.getAppMainServiveName())
|
||||
&& mComponentName.getPackageName().equals(bean.getAppPackageName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -15,11 +15,11 @@ import cc.winboll.studio.appbase.R;
|
||||
import cc.winboll.studio.appbase.beans.WinBollNewsBean;
|
||||
import cc.winboll.studio.libappbase.AppUtils;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.bean.APPNewsBean;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import cc.winboll.studio.libappbase.sos.APPModel;
|
||||
|
||||
public class WinBollNewsWidget extends AppWidgetProvider {
|
||||
|
||||
@@ -59,11 +59,11 @@ public class WinBollNewsWidget extends AppWidgetProvider {
|
||||
LogUtils.d(TAG, String.format("szWinBollNewsBean %s", szWinBollNewsBean));
|
||||
if (szWinBollNewsBean != null && !szWinBollNewsBean.equals("")) {
|
||||
try {
|
||||
APPNewsBean bean = APPNewsBean.parseStringToBean(szWinBollNewsBean, APPNewsBean.class);
|
||||
APPModel bean = APPModel.parseStringToBean(szWinBollNewsBean, APPModel.class);
|
||||
if (bean != null) {
|
||||
String szNewsPackageName = bean.getNewsPackageName();
|
||||
String szNewsPackageName = bean.getAppPackageName();
|
||||
LogUtils.d(TAG, String.format("szNewsPackageName %s", szNewsPackageName));
|
||||
String szNewsClassName = bean.getNewsClassName();
|
||||
String szNewsClassName = bean.getAppMainServiveName();
|
||||
LogUtils.d(TAG, String.format("szNewsClassName %s", szNewsClassName));
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user