Compare commits
19 Commits
contacts-v
...
appbase-v2
Author | SHA1 | Date | |
---|---|---|---|
![]() |
482f289df3 | ||
![]() |
28ab4e2859 | ||
![]() |
fd0cb05812 | ||
![]() |
39b6c0ec89 | ||
![]() |
3b3ddbc8c9 | ||
![]() |
38aee09f87 | ||
![]() |
89c4d00091 | ||
![]() |
4f57678012 | ||
![]() |
b31e55d8ca | ||
![]() |
80129470d7 | ||
![]() |
7b03e8302a | ||
![]() |
4d321dde84 | ||
![]() |
b3a495ff6a | ||
![]() |
a49b6cbfe0 | ||
![]() |
274a7135e7 | ||
![]() |
00d0871809 | ||
![]() |
bc252041d3 | ||
![]() |
bca31f9079 | ||
![]() |
fb7017a857 |
@@ -29,7 +29,7 @@ android {
|
||||
// versionName 更新后需要手动设置
|
||||
// .winboll/winbollBuildProps.properties 文件的 stageCount=0
|
||||
// Gradle编译环境下合起来的 versionName 就是 "${versionName}.0"
|
||||
versionName "2.0"
|
||||
versionName "2.1"
|
||||
if(true) {
|
||||
versionName = genVersionName("${versionName}")
|
||||
}
|
||||
@@ -45,5 +45,26 @@ android {
|
||||
|
||||
dependencies {
|
||||
api project(':libappbase')
|
||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
// SSH
|
||||
implementation 'com.jcraft:jsch:0.1.55'
|
||||
// Html 解析
|
||||
implementation 'org.jsoup:jsoup:1.13.1'
|
||||
// 二维码类库
|
||||
implementation 'com.google.zxing:core:3.4.1'
|
||||
implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
|
||||
// 应用介绍页类库
|
||||
implementation 'io.github.medyo:android-about-page:2.0.0'
|
||||
// 吐司类库
|
||||
implementation 'com.github.getActivity:ToastUtils:10.5'
|
||||
// 网络连接类库
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.4.1'
|
||||
// Android 类库
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation 'androidx.viewpager:viewpager:1.0.0'
|
||||
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
|
||||
implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
|
||||
implementation 'androidx.fragment:fragment:1.1.0'
|
||||
implementation 'com.google.android.material:material:1.4.0'
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Tue Feb 25 16:51:17 HKT 2025
|
||||
stageCount=3
|
||||
#Sat Mar 08 04:46:23 HKT 2025
|
||||
stageCount=5
|
||||
libraryProject=libappbase
|
||||
baseVersion=2.0
|
||||
publishVersion=2.0.2
|
||||
baseVersion=2.1
|
||||
publishVersion=2.1.4
|
||||
buildCount=0
|
||||
baseBetaVersion=2.0.3
|
||||
baseBetaVersion=2.1.5
|
||||
|
@@ -54,19 +54,25 @@
|
||||
<receiver android:name="cc.winboll.studio.appbase.receivers.MainReceiver">
|
||||
|
||||
<intent-filter>
|
||||
|
||||
<action android:name="cc.winboll.studio.appbase.receivers.MainReceiver"/>
|
||||
|
||||
</intent-filter>
|
||||
|
||||
</receiver>
|
||||
|
||||
<receiver
|
||||
android:name=".widgets.SOSWidget"
|
||||
android:name=".widgets.APPNewsWidget"
|
||||
android:exported="true">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="cc.winboll.studio.appbase.widgets.SOSWidget.ACTION_WAKEUP_SERVICE"/>
|
||||
<action android:name="cc.winboll.studio.appbase.widgets.SOSWidget.ACTION_RELOAD_REPORT"/>
|
||||
|
||||
<action android:name="cc.winboll.studio.appbase.widgets.APPNewsWidget.ACTION_WAKEUP_SERVICE"/>
|
||||
|
||||
<action android:name="cc.winboll.studio.appbase.widgets.APPNewsWidget.ACTION_RELOAD_REPORT"/>
|
||||
|
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
|
||||
|
||||
</intent-filter>
|
||||
|
||||
<meta-data
|
||||
@@ -75,13 +81,13 @@
|
||||
|
||||
</receiver>
|
||||
|
||||
<receiver android:name=".widgets.SOSWidgetClickListener">
|
||||
<receiver android:name=".widgets.APPNewsWidgetClickListener">
|
||||
|
||||
<intent-filter>
|
||||
|
||||
<action android:name="cc.winboll.studio.appbase.widgets.SOSWidgetClickListener.ACTION_PRE"/>
|
||||
<action android:name="cc.winboll.studio.appbase.widgets.APPNewsWidgetClickListener.ACTION_PRE"/>
|
||||
|
||||
<action android:name="cc.winboll.studio.appbase.widgets.SOSWidgetClickListener.ACTION_NEXT"/>
|
||||
<action android:name="cc.winboll.studio.appbase.widgets.APPNewsWidgetClickListener.ACTION_NEXT"/>
|
||||
|
||||
</intent-filter>
|
||||
|
||||
@@ -91,6 +97,11 @@
|
||||
android:name="android.max_aspect"
|
||||
android:value="4.0"/>
|
||||
|
||||
<service android:name="cc.winboll.studio.appbase.services.TestDemoBindService"
|
||||
android:exported="true"/>
|
||||
|
||||
<service android:name="cc.winboll.studio.appbase.services.TestDemoService"
|
||||
android:exported="true"/>
|
||||
|
||||
</application>
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package cc.winboll.studio.appbase;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
@@ -9,15 +8,16 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import cc.winboll.studio.appbase.R;
|
||||
import cc.winboll.studio.appbase.services.MainService;
|
||||
import cc.winboll.studio.appbase.services.TestDemoBindService;
|
||||
import cc.winboll.studio.appbase.services.TestDemoService;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.LogView;
|
||||
import cc.winboll.studio.libappbase.SOS;
|
||||
import cc.winboll.studio.libappbase.SimpleOperateSignalCenterService;
|
||||
import cc.winboll.studio.libappbase.bean.APPSOSBean;
|
||||
import cc.winboll.studio.libappbase.services.TestService;
|
||||
import cc.winboll.studio.libappbase.widgets.StatusWidget;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import android.content.ComponentName;
|
||||
import cc.winboll.studio.libappbase.sos.SOS;
|
||||
import cc.winboll.studio.libappbase.sos.SOSObject;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@@ -68,17 +68,17 @@ public class MainActivity extends AppCompatActivity {
|
||||
MainService.stopMainService(this);
|
||||
}
|
||||
|
||||
public void onTestStopWithoutSettingEnable(View view) {
|
||||
LogUtils.d(TAG, "onTestStopWithoutSettingEnable");
|
||||
stopService(new Intent(this, SimpleOperateSignalCenterService.class));
|
||||
public void onTestStopMainServiceWithoutSettingEnable(View view) {
|
||||
LogUtils.d(TAG, "onTestStopMainServiceWithoutSettingEnable");
|
||||
stopService(new Intent(this, MainService.class));
|
||||
}
|
||||
|
||||
public void onTestStartWithString(View view) {
|
||||
LogUtils.d(TAG, "onTestStartWithString");
|
||||
public void onTestUseComponentStartService(View view) {
|
||||
LogUtils.d(TAG, "onTestUseComponentStartService");
|
||||
|
||||
// 目标服务的包名和类名
|
||||
String packageName = this.getPackageName();
|
||||
String serviceClassName = SimpleOperateSignalCenterService.class.getName();
|
||||
String serviceClassName = TestDemoService.class.getName();
|
||||
|
||||
// 构建Intent
|
||||
Intent intentService = new Intent();
|
||||
@@ -87,30 +87,55 @@ public class MainActivity extends AppCompatActivity {
|
||||
startService(intentService);
|
||||
}
|
||||
|
||||
public void onSOS(View view) {
|
||||
Intent intent = new Intent(this, TestService.class);
|
||||
public void onTestSOS(View view) {
|
||||
Intent intent = new Intent(this, TestDemoService.class);
|
||||
stopService(intent);
|
||||
SOS.sosWinBollService(this, new APPSOSBean(getPackageName(), TestService.class.getName()));
|
||||
if(App.isDebuging()) {
|
||||
SOS.sosToAppBaseBeta(this, TestDemoService.class.getName());
|
||||
} else {
|
||||
SOS.sosToAppBase(this, TestDemoService.class.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public void onStartTestService(View view) {
|
||||
Intent intent = new Intent(this, TestService.class);
|
||||
intent.setAction(SOS.ACTION_SERVICE_ENABLE);
|
||||
public void onSartTestDemoService(View view) {
|
||||
Intent intent = new Intent(this, TestDemoService.class);
|
||||
intent.setAction(TestDemoService.ACTION_ENABLE);
|
||||
startService(intent);
|
||||
|
||||
}
|
||||
|
||||
public void onStopTestService(View view) {
|
||||
Intent intent = new Intent(this, TestService.class);
|
||||
intent.setAction(SOS.ACTION_SERVICE_DISABLE);
|
||||
public void onStopTestDemoService(View view) {
|
||||
Intent intent = new Intent(this, TestDemoService.class);
|
||||
intent.setAction(TestDemoService.ACTION_DISABLE);
|
||||
startService(intent);
|
||||
|
||||
Intent intentStop = new Intent(this, TestService.class);
|
||||
Intent intentStop = new Intent(this, TestDemoService.class);
|
||||
stopService(intentStop);
|
||||
}
|
||||
|
||||
public void onStopTestServiceNoSettings(View view) {
|
||||
Intent intent = new Intent(this, TestService.class);
|
||||
public void onStopTestDemoServiceNoSettings(View view) {
|
||||
Intent intent = new Intent(this, TestDemoService.class);
|
||||
stopService(intent);
|
||||
}
|
||||
|
||||
public void onSartTestDemoBindService(View view) {
|
||||
Intent intent = new Intent(this, TestDemoBindService.class);
|
||||
intent.setAction(TestDemoBindService.ACTION_ENABLE);
|
||||
startService(intent);
|
||||
|
||||
}
|
||||
|
||||
public void onStopTestDemoBindService(View view) {
|
||||
Intent intent = new Intent(this, TestDemoBindService.class);
|
||||
intent.setAction(TestDemoBindService.ACTION_DISABLE);
|
||||
startService(intent);
|
||||
|
||||
Intent intentStop = new Intent(this, TestDemoBindService.class);
|
||||
stopService(intentStop);
|
||||
}
|
||||
|
||||
public void onStopTestDemoBindServiceNoSettings(View view) {
|
||||
Intent intent = new Intent(this, TestDemoBindService.class);
|
||||
stopService(intent);
|
||||
}
|
||||
}
|
||||
|
@@ -35,8 +35,7 @@ public class MainServiceBean extends BaseBean {
|
||||
@Override
|
||||
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
||||
super.writeThisToJsonWriter(jsonWriter);
|
||||
MainServiceBean bean = this;
|
||||
jsonWriter.name("isEnable").value(bean.isEnable());
|
||||
jsonWriter.name("isEnable").value(isEnable());
|
||||
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
package cc.winboll.studio.libappbase.bean;
|
||||
package cc.winboll.studio.appbase.beans;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/02/19 13:34:52
|
||||
* @Date 2025/03/07 12:47:22
|
||||
* @Describe TestServiceBean
|
||||
*/
|
||||
import android.util.JsonReader;
|
||||
@@ -10,13 +10,13 @@ import android.util.JsonWriter;
|
||||
import cc.winboll.studio.libappbase.BaseBean;
|
||||
import java.io.IOException;
|
||||
|
||||
public class TestServiceBean extends BaseBean {
|
||||
public class TestDemoBindServiceBean extends BaseBean {
|
||||
|
||||
public static final String TAG = "TestServiceBean";
|
||||
|
||||
boolean isEnable;
|
||||
|
||||
public TestServiceBean() {
|
||||
public TestDemoBindServiceBean() {
|
||||
this.isEnable = false;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class TestServiceBean extends BaseBean {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return TestServiceBean.class.getName();
|
||||
return TestDemoBindServiceBean.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
@@ -1,20 +1,22 @@
|
||||
package cc.winboll.studio.libappbase.bean;
|
||||
package cc.winboll.studio.appbase.beans;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/07 12:49:21
|
||||
* @Describe TestDemoServiceBean
|
||||
*/
|
||||
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 TestDemoServiceBean extends BaseBean {
|
||||
|
||||
public static final String TAG = "SimpleOperateSignalCenterServiceBean";
|
||||
public static final String TAG = "TestDemoServiceBean";
|
||||
|
||||
boolean isEnable;
|
||||
|
||||
public SimpleOperateSignalCenterServiceBean() {
|
||||
|
||||
public TestDemoServiceBean() {
|
||||
this.isEnable = false;
|
||||
}
|
||||
|
||||
@@ -28,7 +30,7 @@ public class SimpleOperateSignalCenterServiceBean extends BaseBean {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return SimpleOperateSignalCenterServiceBean.class.getName();
|
||||
return TestDemoServiceBean.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
@@ -10,45 +10,45 @@ import android.util.JsonWriter;
|
||||
import cc.winboll.studio.libappbase.BaseBean;
|
||||
import java.io.IOException;
|
||||
|
||||
public class SOSReportBean extends BaseBean {
|
||||
public class WinBollNewsBean extends BaseBean {
|
||||
|
||||
public static final String TAG = "APPSOSReportBean";
|
||||
public static final String TAG = "WinBollNewsBean";
|
||||
|
||||
protected String sosReport;
|
||||
protected String message;
|
||||
|
||||
public SOSReportBean() {
|
||||
this.sosReport = "";
|
||||
public WinBollNewsBean() {
|
||||
this.message = "";
|
||||
}
|
||||
|
||||
public SOSReportBean(String sosReport) {
|
||||
this.sosReport = sosReport;
|
||||
public WinBollNewsBean(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public void setSosReport(String sosReport) {
|
||||
this.sosReport = sosReport;
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getSosReport() {
|
||||
return sosReport;
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return SOSReportBean.class.getName();
|
||||
return WinBollNewsBean.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
||||
super.writeThisToJsonWriter(jsonWriter);
|
||||
jsonWriter.name("sosReport").value(getSosReport());
|
||||
jsonWriter.name("message").value(getMessage());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
|
||||
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
|
||||
if (name.equals("sosReport")) {
|
||||
setSosReport(jsonReader.nextString());
|
||||
if (name.equals("message")) {
|
||||
setMessage(jsonReader.nextString());
|
||||
} else {
|
||||
return false;
|
||||
}
|
@@ -11,28 +11,28 @@ import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import cc.winboll.studio.appbase.beans.SOSReportBean;
|
||||
import cc.winboll.studio.appbase.beans.WinBollNewsBean;
|
||||
import cc.winboll.studio.appbase.services.MainService;
|
||||
import cc.winboll.studio.appbase.widgets.SOSWidget;
|
||||
import cc.winboll.studio.appbase.widgets.APPNewsWidget;
|
||||
import cc.winboll.studio.libappbase.AppUtils;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.SOS;
|
||||
import cc.winboll.studio.libappbase.bean.APPSOSBean;
|
||||
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 {
|
||||
|
||||
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);
|
||||
@@ -43,74 +43,62 @@ public class MainReceiver extends BroadcastReceiver {
|
||||
String szAction = intent.getAction();
|
||||
if (szAction.equals(ACTION_BOOT_COMPLETED)) {
|
||||
ToastUtils.show("ACTION_BOOT_COMPLETED");
|
||||
} else if (szAction.equals(SOS.ACTION_BIND)) {
|
||||
} else if (szAction.equals(WinBoll.ACTION_BIND)) {
|
||||
LogUtils.d(TAG, "ACTION_BIND");
|
||||
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 szAPPSOSBean = intent.getStringExtra("APPSOSBean");
|
||||
LogUtils.d(TAG, String.format("szAPPSOSBean %s", szAPPSOSBean));
|
||||
if (szAPPSOSBean != null && !szAPPSOSBean.equals("")) {
|
||||
try {
|
||||
APPSOSBean bean = APPSOSBean.parseStringToBean(szAPPSOSBean, APPSOSBean.class);
|
||||
if (bean != null) {
|
||||
String sosPackage = bean.getSosPackage();
|
||||
LogUtils.d(TAG, String.format("sosPackage %s", sosPackage));
|
||||
String sosClassName = bean.getSosClassName();
|
||||
LogUtils.d(TAG, String.format("sosClassName %s", sosClassName));
|
||||
mwrService.get().bindSOSConnection(bean);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
String szAPPModel = intent.getStringExtra(WinBoll.EXTRA_APPMODEL);
|
||||
LogUtils.d(TAG, String.format("szAPPModel %s", szAPPModel));
|
||||
if (szAPPModel != null && !szAPPModel.equals("")) {
|
||||
try {
|
||||
APPModel bean = APPModel.parseStringToBean(szAPPModel, APPModel.class);
|
||||
if (bean != null) {
|
||||
String szAppPackageName = bean.getAppPackageName();
|
||||
LogUtils.d(TAG, String.format("szAppPackageName %s", szAppPackageName));
|
||||
String szAppMainServiveName = bean.getAppMainServiveName();
|
||||
LogUtils.d(TAG, String.format("szAppMainServiveName %s", szAppMainServiveName));
|
||||
mwrService.get().bindAPPModelConnection(bean);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
}
|
||||
} 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 szAPPSOSBean = intent.getStringExtra("APPSOSBean");
|
||||
LogUtils.d(TAG, String.format("szAPPSOSBean %s", szAPPSOSBean));
|
||||
if (szAPPSOSBean != null && !szAPPSOSBean.equals("")) {
|
||||
try {
|
||||
APPSOSBean bean = APPSOSBean.parseStringToBean(szAPPSOSBean, APPSOSBean.class);
|
||||
if (bean != null) {
|
||||
String sosPackage = bean.getSosPackage();
|
||||
LogUtils.d(TAG, String.format("sosPackage %s", sosPackage));
|
||||
String sosClassName = bean.getSosClassName();
|
||||
LogUtils.d(TAG, String.format("sosClassName %s", sosClassName));
|
||||
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(sosPackage, sosClassName));
|
||||
context.startService(intentService);
|
||||
Intent intentService = new Intent();
|
||||
intentService.setComponent(new ComponentName(szObjectPackageName, szObjectServiveName));
|
||||
context.startService(intentService);
|
||||
|
||||
String appName = AppUtils.getAppNameByPackageName(context, sosPackage);
|
||||
LogUtils.d(TAG, String.format("appName %s", appName));
|
||||
SOSReportBean appSOSReportBean = new SOSReportBean(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);
|
||||
appSOSReportBean.setSosReport(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());
|
||||
|
||||
SOSWidget.addAPPSOSReportBean(context, appSOSReportBean);
|
||||
|
||||
Intent intentWidget = new Intent(context, SOSWidget.class);
|
||||
intentWidget.setAction(SOSWidget.ACTION_RELOAD_REPORT);
|
||||
context.sendBroadcast(intentWidget);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
APPNewsWidget.addWinBollNewsBean(context, appWinBollNewsBean);
|
||||
|
||||
Intent intentWidget = new Intent(context, APPNewsWidget.class);
|
||||
intentWidget.setAction(APPNewsWidget.ACTION_RELOAD_REPORT);
|
||||
context.sendBroadcast(intentWidget);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
ToastUtils.show(szAction);
|
||||
@@ -123,9 +111,7 @@ public class MainReceiver extends BroadcastReceiver {
|
||||
IntentFilter filter=new IntentFilter();
|
||||
filter.addAction(ACTION_BOOT_COMPLETED);
|
||||
filter.addAction(SOS.ACTION_SOS);
|
||||
filter.addAction(SOS.ACTION_BIND);
|
||||
filter.addAction(SOS.ACTION_SERVICE_ENABLE);
|
||||
filter.addAction(SOS.ACTION_SERVICE_DISABLE);
|
||||
filter.addAction(WinBoll.ACTION_BIND);
|
||||
//filter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
||||
service.registerReceiver(this, filter);
|
||||
}
|
||||
|
@@ -23,10 +23,10 @@ import cc.winboll.studio.appbase.handlers.MainServiceHandler;
|
||||
import cc.winboll.studio.appbase.receivers.MainReceiver;
|
||||
import cc.winboll.studio.appbase.services.AssistantService;
|
||||
import cc.winboll.studio.appbase.threads.MainServiceThread;
|
||||
import cc.winboll.studio.appbase.widgets.SOSWidget;
|
||||
import cc.winboll.studio.appbase.widgets.APPNewsWidget;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.bean.APPSOSBean;
|
||||
import java.util.ArrayList;
|
||||
import cc.winboll.studio.libappbase.sos.APPModel;
|
||||
|
||||
public class MainService extends Service {
|
||||
|
||||
@@ -45,7 +45,7 @@ public class MainService extends Service {
|
||||
AssistantService mAssistantService;
|
||||
boolean isBound = false;
|
||||
MainReceiver mMainReceiver;
|
||||
ArrayList<SOSConnection> mSOSConnectionList;
|
||||
ArrayList<APPConnection> mAPPModelConnectionList;
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
@@ -60,7 +60,7 @@ public class MainService extends Service {
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
LogUtils.d(TAG, "onCreate()");
|
||||
mSOSConnectionList = new ArrayList<SOSConnection>();
|
||||
mAPPModelConnectionList = new ArrayList<APPConnection>();
|
||||
|
||||
_mControlCenterService = MainService.this;
|
||||
isServiceRunning = false;
|
||||
@@ -101,8 +101,8 @@ public class MainService extends Service {
|
||||
}
|
||||
|
||||
// 启动小部件
|
||||
Intent intentTimeWidget = new Intent(this, SOSWidget.class);
|
||||
intentTimeWidget.setAction(SOSWidget.ACTION_RELOAD_REPORT);
|
||||
Intent intentTimeWidget = new Intent(this, APPNewsWidget.class);
|
||||
intentTimeWidget.setAction(APPNewsWidget.ACTION_RELOAD_REPORT);
|
||||
this.sendBroadcast(intentTimeWidget);
|
||||
|
||||
startMainServiceThread();
|
||||
@@ -117,21 +117,11 @@ public class MainService extends Service {
|
||||
//
|
||||
void wakeupAndBindAssistant() {
|
||||
LogUtils.d(TAG, "wakeupAndBindAssistant()");
|
||||
// if (ServiceUtils.isServiceAlive(getApplicationContext(), AssistantService.class.getName()) == false) {
|
||||
// startService(new Intent(MainService.this, AssistantService.class));
|
||||
// //LogUtils.d(TAG, "call wakeupAndBindAssistant() : Binding... AssistantService");
|
||||
// bindService(new Intent(MainService.this, AssistantService.class), mMyServiceConnection, Context.BIND_IMPORTANT);
|
||||
// }
|
||||
|
||||
Intent intent = new Intent(this, AssistantService.class);
|
||||
startService(intent);
|
||||
// 绑定服务的Intent
|
||||
//Intent intent = new Intent(this, AssistantService.class);
|
||||
bindService(intent, mMyServiceConnection, Context.BIND_IMPORTANT);
|
||||
|
||||
// Intent intent = new Intent(this, AssistantService.class);
|
||||
// startService(intent);
|
||||
// LogUtils.d(TAG, "startService(intent)");
|
||||
// bindService(new Intent(this, AssistantService.class), mMyServiceConnection, Context.BIND_IMPORTANT);
|
||||
}
|
||||
|
||||
// 开启提醒铃声线程
|
||||
@@ -192,40 +182,40 @@ public class MainService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
public void bindSOSConnection(APPSOSBean bean) {
|
||||
LogUtils.d(TAG, "bindSOSConnection(...)");
|
||||
public void bindAPPModelConnection(APPModel bean) {
|
||||
LogUtils.d(TAG, "bindAPPModelConnection(...)");
|
||||
// 清理旧的绑定链接
|
||||
for (int i = mSOSConnectionList.size() - 1; i > -1; i--) {
|
||||
SOSConnection item = mSOSConnectionList.get(i);
|
||||
if (item.isBindToAPPSOSBean(bean)) {
|
||||
for (int i = mAPPModelConnectionList.size() - 1; i > -1; i--) {
|
||||
APPConnection item = mAPPModelConnectionList.get(i);
|
||||
if (item.isBindToAPP(bean)) {
|
||||
LogUtils.d(TAG, "Bind Servive exist.");
|
||||
unbindService(item);
|
||||
mSOSConnectionList.remove(i);
|
||||
mAPPModelConnectionList.remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
// 绑定服务
|
||||
SOSConnection sosConnection = new SOSConnection();
|
||||
APPConnection appConnection = new APPConnection();
|
||||
Intent intentService = new Intent();
|
||||
intentService.setComponent(new ComponentName(bean.getSosPackage(), bean.getSosClassName()));
|
||||
bindService(intentService, sosConnection, Context.BIND_IMPORTANT);
|
||||
mSOSConnectionList.add(sosConnection);
|
||||
intentService.setComponent(new ComponentName(bean.getAppPackageName(), bean.getAppMainServiveName()));
|
||||
bindService(intentService, appConnection, Context.BIND_IMPORTANT);
|
||||
mAPPModelConnectionList.add(appConnection);
|
||||
|
||||
Intent intentWidget = new Intent(this, SOSWidget.class);
|
||||
intentWidget.setAction(SOSWidget.ACTION_WAKEUP_SERVICE);
|
||||
APPSOSBean appSOSBean = new APPSOSBean(bean.getSosPackage(), bean.getSosClassName());
|
||||
Intent intentWidget = new Intent(this, APPNewsWidget.class);
|
||||
intentWidget.setAction(APPNewsWidget.ACTION_WAKEUP_SERVICE);
|
||||
APPModel appSOSBean = new APPModel(bean.getAppPackageName(), bean.getAppMainServiveName());
|
||||
intentWidget.putExtra("APPSOSBean", appSOSBean.toString());
|
||||
sendBroadcast(intentWidget);
|
||||
}
|
||||
|
||||
public class SOSConnection implements ServiceConnection {
|
||||
public class APPConnection implements ServiceConnection {
|
||||
|
||||
ComponentName mComponentName;
|
||||
|
||||
boolean isBindToAPPSOSBean(APPSOSBean bean) {
|
||||
boolean isBindToAPP(APPModel bean) {
|
||||
return mComponentName != null
|
||||
&& mComponentName.getClassName().equals(bean.getSosClassName())
|
||||
&& mComponentName.getPackageName().equals(bean.getSosPackage());
|
||||
&& mComponentName.getClassName().equals(bean.getAppMainServiveName())
|
||||
&& mComponentName.getPackageName().equals(bean.getAppPackageName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -241,13 +231,13 @@ public class MainService extends Service {
|
||||
LogUtils.d(TAG, String.format("onServiceDisconnected : \ngetClassName %s\ngetPackageName %s", name.getClassName(), name.getPackageName()));
|
||||
|
||||
// 尝试无参数启动一下服务
|
||||
String sosPackage = mComponentName.getPackageName();
|
||||
LogUtils.d(TAG, String.format("sosPackage %s", sosPackage));
|
||||
String sosClassName = mComponentName.getClassName();
|
||||
LogUtils.d(TAG, String.format("sosClassName %s", sosClassName));
|
||||
String appPackage = mComponentName.getPackageName();
|
||||
LogUtils.d(TAG, String.format("appPackage %s", appPackage));
|
||||
String appMainServiceClassName = mComponentName.getClassName();
|
||||
LogUtils.d(TAG, String.format("appMainServiceClassName %s", appMainServiceClassName));
|
||||
|
||||
Intent intentService = new Intent();
|
||||
intentService.setComponent(new ComponentName(sosPackage, sosClassName));
|
||||
intentService.setComponent(new ComponentName(appPackage, appMainServiceClassName));
|
||||
startService(intentService);
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,178 @@
|
||||
package cc.winboll.studio.appbase.services;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/07 12:45:49
|
||||
* @Describe 启动时申请绑定到APPBase主服务的服务示例
|
||||
*/
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import cc.winboll.studio.appbase.beans.TestDemoBindServiceBean;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.sos.WinBoll;
|
||||
import cc.winboll.studio.appbase.App;
|
||||
import cc.winboll.studio.libappbase.sos.SOS;
|
||||
|
||||
public class TestDemoBindService extends Service {
|
||||
|
||||
public static final String TAG = "TestDemoBindService";
|
||||
|
||||
public static final String ACTION_ENABLE = TestDemoBindService.class.getName() + ".ACTION_ENABLE";
|
||||
public static final String ACTION_DISABLE = TestDemoBindService.class.getName() + ".ACTION_DISABLE";
|
||||
|
||||
volatile static TestThread _TestThread;
|
||||
|
||||
volatile static boolean _IsRunning;
|
||||
|
||||
public synchronized static void setIsRunning(boolean isRunning) {
|
||||
_IsRunning = isRunning;
|
||||
}
|
||||
|
||||
public static boolean isRunning() {
|
||||
return _IsRunning;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return new MyBinder();
|
||||
}
|
||||
|
||||
public class MyBinder extends Binder {
|
||||
public TestDemoBindService getService() {
|
||||
return TestDemoBindService.this;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
LogUtils.d(TAG, "onCreate()");
|
||||
|
||||
run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
LogUtils.d(TAG, "onStartCommand(...)");
|
||||
TestDemoBindServiceBean bean = TestDemoBindServiceBean.loadBean(this, TestDemoBindServiceBean.class);
|
||||
if (bean == null) {
|
||||
bean = new TestDemoBindServiceBean();
|
||||
}
|
||||
|
||||
if (intent.getAction() != null) {
|
||||
if (intent.getAction().equals(ACTION_ENABLE)) {
|
||||
bean.setIsEnable(true);
|
||||
LogUtils.d(TAG, "setIsEnable(true);");
|
||||
TestDemoBindServiceBean.saveBean(this, bean);
|
||||
} else if (intent.getAction().equals(ACTION_DISABLE)) {
|
||||
bean.setIsEnable(false);
|
||||
LogUtils.d(TAG, "setIsEnable(false);");
|
||||
TestDemoBindServiceBean.saveBean(this, bean);
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
|
||||
return (bean.isEnable()) ? START_STICKY : super.onStartCommand(intent, flags, startId);
|
||||
//return super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
|
||||
void run() {
|
||||
LogUtils.d(TAG, "run()");
|
||||
TestDemoBindServiceBean bean = TestDemoBindServiceBean.loadBean(this, TestDemoBindServiceBean.class);
|
||||
if (bean == null) {
|
||||
bean = new TestDemoBindServiceBean();
|
||||
TestDemoBindServiceBean.saveBean(this, bean);
|
||||
}
|
||||
if (bean.isEnable()) {
|
||||
LogUtils.d(TAG, "run() bean.isEnable()");
|
||||
TestThread.getInstance(this).start();
|
||||
LogUtils.d(TAG, "_TestThread.start()");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
LogUtils.d(TAG, "onDestroy()");
|
||||
TestDemoBindServiceBean bean = TestDemoBindServiceBean.loadBean(this, TestDemoBindServiceBean.class);
|
||||
if (bean == null) {
|
||||
bean = new TestDemoBindServiceBean();
|
||||
}
|
||||
|
||||
TestThread.getInstance(this).setIsExit(true);
|
||||
|
||||
// 预防 APPBase 应用重启绑定失效。
|
||||
// 所以退出时检查本服务是否配置启用,如果启用就发送一个 SOS 信号。
|
||||
// 这样 APPBase 就会用组件方式启动本服务。
|
||||
if (bean.isEnable()) {
|
||||
if (App.isDebuging()) {
|
||||
SOS.sosToAppBaseBeta(this, TestDemoBindService.class.getName());
|
||||
} else {
|
||||
SOS.sosToAppBase(this, TestDemoBindService.class.getName());
|
||||
}
|
||||
}
|
||||
|
||||
_IsRunning = false;
|
||||
}
|
||||
|
||||
static class TestThread extends Thread {
|
||||
|
||||
volatile static TestThread _TestThread;
|
||||
Context mContext;
|
||||
volatile boolean isStarted = false;
|
||||
volatile boolean isExit = false;
|
||||
|
||||
TestThread(Context context) {
|
||||
super();
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public static synchronized TestThread getInstance(Context context) {
|
||||
if (_TestThread != null) {
|
||||
_TestThread.setIsExit(true);
|
||||
}
|
||||
_TestThread = new TestThread(context);
|
||||
|
||||
return _TestThread;
|
||||
}
|
||||
|
||||
public synchronized void setIsExit(boolean isExit) {
|
||||
this.isExit = isExit;
|
||||
}
|
||||
|
||||
public boolean isExit() {
|
||||
return isExit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (isStarted == false) {
|
||||
isStarted = true;
|
||||
super.run();
|
||||
LogUtils.d(TAG, "run() start");
|
||||
if (App.isDebuging()) {
|
||||
WinBoll.bindToAPPBaseBeta(mContext, TestDemoBindService.class.getName());
|
||||
} else {
|
||||
WinBoll.bindToAPPBase(mContext, TestDemoBindService.class.getName());
|
||||
}
|
||||
|
||||
while (!isExit()) {
|
||||
LogUtils.d(TAG, "run()");
|
||||
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
}
|
||||
|
||||
LogUtils.d(TAG, "run() exit");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,23 +1,25 @@
|
||||
package cc.winboll.studio.libappbase.services;
|
||||
package cc.winboll.studio.appbase.services;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/02/15 20:48:36
|
||||
* @Describe TestService
|
||||
* @Date 2025/03/07 12:39:24
|
||||
* @Describe 普通服务示例
|
||||
*/
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import cc.winboll.studio.appbase.beans.TestDemoServiceBean;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.SOS;
|
||||
import cc.winboll.studio.libappbase.bean.APPSOSBean;
|
||||
import cc.winboll.studio.libappbase.bean.TestServiceBean;
|
||||
import cc.winboll.studio.libappbase.sos.WinBoll;
|
||||
|
||||
public class TestService extends Service {
|
||||
public class TestDemoService extends Service {
|
||||
|
||||
public static final String TAG = "TestService";
|
||||
public static final String TAG = "TestDemoService";
|
||||
|
||||
public static final String ACTION_ENABLE = TestDemoService.class.getName() + ".ACTION_ENABLE";
|
||||
public static final String ACTION_DISABLE = TestDemoService.class.getName() + ".ACTION_DISABLE";
|
||||
|
||||
volatile static TestThread _TestThread;
|
||||
|
||||
@@ -37,8 +39,8 @@ public class TestService extends Service {
|
||||
}
|
||||
|
||||
public class MyBinder extends Binder {
|
||||
public TestService getService() {
|
||||
return TestService.this;
|
||||
public TestDemoService getService() {
|
||||
return TestDemoService.this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,29 +56,35 @@ public class TestService extends Service {
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
LogUtils.d(TAG, "onStartCommand(...)");
|
||||
TestServiceBean bean = TestServiceBean.loadBean(this, TestServiceBean.class);
|
||||
TestDemoServiceBean bean = TestDemoServiceBean.loadBean(this, TestDemoServiceBean.class);
|
||||
if (bean == null) {
|
||||
bean = new TestServiceBean();
|
||||
bean = new TestDemoServiceBean();
|
||||
}
|
||||
if (intent.getAction() != null && intent.getAction().equals(SOS.ACTION_SERVICE_ENABLE)) {
|
||||
bean.setIsEnable(true);
|
||||
TestServiceBean.saveBean(this, bean);
|
||||
run();
|
||||
} else if (intent.getAction() != null && intent.getAction().equals(SOS.ACTION_SERVICE_DISABLE)) {
|
||||
bean.setIsEnable(false);
|
||||
TestServiceBean.saveBean(this, bean);
|
||||
|
||||
if (intent.getAction() != null) {
|
||||
if (intent.getAction().equals(ACTION_ENABLE)) {
|
||||
bean.setIsEnable(true);
|
||||
LogUtils.d(TAG, "setIsEnable(true);");
|
||||
TestDemoServiceBean.saveBean(this, bean);
|
||||
} else if (intent.getAction().equals(ACTION_DISABLE)) {
|
||||
bean.setIsEnable(false);
|
||||
LogUtils.d(TAG, "setIsEnable(false);");
|
||||
TestDemoServiceBean.saveBean(this, bean);
|
||||
}
|
||||
}
|
||||
LogUtils.d(TAG, String.format("TestServiceBean.saveBean setIsEnable %s", bean.isEnable()));
|
||||
|
||||
run();
|
||||
|
||||
return (bean.isEnable()) ? START_STICKY : super.onStartCommand(intent, flags, startId);
|
||||
//return super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
|
||||
void run() {
|
||||
LogUtils.d(TAG, "run()");
|
||||
TestServiceBean bean = TestServiceBean.loadBean(this, TestServiceBean.class);
|
||||
TestDemoServiceBean bean = TestDemoServiceBean.loadBean(this, TestDemoServiceBean.class);
|
||||
if (bean == null) {
|
||||
bean = new TestServiceBean();
|
||||
TestServiceBean.saveBean(this, bean);
|
||||
bean = new TestDemoServiceBean();
|
||||
TestDemoServiceBean.saveBean(this, bean);
|
||||
}
|
||||
if (bean.isEnable()) {
|
||||
LogUtils.d(TAG, "run() bean.isEnable()");
|
||||
@@ -91,7 +99,7 @@ public class TestService extends Service {
|
||||
super.onDestroy();
|
||||
LogUtils.d(TAG, "onDestroy()");
|
||||
TestThread.getInstance(this).setIsExit(true);
|
||||
|
||||
|
||||
_IsRunning = false;
|
||||
}
|
||||
|
||||
@@ -130,7 +138,6 @@ public class TestService extends Service {
|
||||
isStarted = true;
|
||||
super.run();
|
||||
LogUtils.d(TAG, "run() start");
|
||||
SOS.bindToAPPService(mContext, new APPSOSBean(mContext.getPackageName(), TestService.class.getName()));
|
||||
|
||||
while (!isExit()) {
|
||||
LogUtils.d(TAG, "run()");
|
@@ -12,31 +12,32 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.widget.RemoteViews;
|
||||
import cc.winboll.studio.appbase.R;
|
||||
import cc.winboll.studio.appbase.beans.SOSReportBean;
|
||||
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.APPSOSBean;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import cc.winboll.studio.libappbase.sos.APPModel;
|
||||
import cc.winboll.studio.libappbase.sos.WinBoll;
|
||||
|
||||
public class SOSWidget extends AppWidgetProvider {
|
||||
public class APPNewsWidget extends AppWidgetProvider {
|
||||
|
||||
public static final String TAG = "SOSWidget";
|
||||
public static final String TAG = "APPNewsWidget";
|
||||
|
||||
public static final String ACTION_WAKEUP_SERVICE = "cc.winboll.studio.appbase.widgets.SOSWidget.ACTION_WAKEUP_SERVICE";
|
||||
public static final String ACTION_RELOAD_REPORT = "cc.winboll.studio.appbase.widgets.SOSWidget.ACTION_RELOAD_REPORT";
|
||||
public static final String ACTION_WAKEUP_SERVICE = APPNewsWidget.class.getName() + ".ACTION_WAKEUP_SERVICE";
|
||||
public static final String ACTION_RELOAD_REPORT = APPNewsWidget.class.getName() + ".ACTION_RELOAD_REPORT";
|
||||
|
||||
|
||||
volatile static ArrayList<SOSReportBean> _SOSReportBeanList;
|
||||
volatile static ArrayList<WinBollNewsBean> _WinBollNewsBeanList;
|
||||
final static int _MAX_PAGES = 10;
|
||||
final static int _OnePageLinesCount = 5;
|
||||
volatile static int _CurrentPageIndex = 0;
|
||||
|
||||
@Override
|
||||
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
|
||||
initAPPSOSReportBeanList(context);
|
||||
initWinBollNewsBeanList(context);
|
||||
for (int appWidgetId : appWidgetIds) {
|
||||
updateAppWidget(context, appWidgetManager, appWidgetId);
|
||||
}
|
||||
@@ -45,31 +46,31 @@ public class SOSWidget extends AppWidgetProvider {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
super.onReceive(context, intent);
|
||||
initAPPSOSReportBeanList(context);
|
||||
initWinBollNewsBeanList(context);
|
||||
if (intent.getAction().equals(ACTION_RELOAD_REPORT)) {
|
||||
LogUtils.d(TAG, "ACTION_RELOAD_REPORT");
|
||||
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
|
||||
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, SOSWidget.class));
|
||||
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, APPNewsWidget.class));
|
||||
for (int appWidgetId : appWidgetIds) {
|
||||
updateAppWidget(context, appWidgetManager, appWidgetId);
|
||||
}
|
||||
}else if (intent.getAction().equals(ACTION_WAKEUP_SERVICE)) {
|
||||
LogUtils.d(TAG, "ACTION_WAKEUP_SERVICE");
|
||||
String szAPPSOSBean = intent.getStringExtra("APPSOSBean");
|
||||
LogUtils.d(TAG, String.format("szAPPSOSBean %s", szAPPSOSBean));
|
||||
if (szAPPSOSBean != null && !szAPPSOSBean.equals("")) {
|
||||
String szAPPModel = intent.getStringExtra(WinBoll.EXTRA_APPMODEL);
|
||||
LogUtils.d(TAG, String.format("szAPPModel %s", szAPPModel));
|
||||
if (szAPPModel != null && !szAPPModel.equals("")) {
|
||||
try {
|
||||
APPSOSBean bean = APPSOSBean.parseStringToBean(szAPPSOSBean, APPSOSBean.class);
|
||||
APPModel bean = APPModel.parseStringToBean(szAPPModel, APPModel.class);
|
||||
if (bean != null) {
|
||||
String sosPackage = bean.getSosPackage();
|
||||
LogUtils.d(TAG, String.format("sosPackage %s", sosPackage));
|
||||
String sosClassName = bean.getSosClassName();
|
||||
LogUtils.d(TAG, String.format("sosClassName %s", sosClassName));
|
||||
String szAppPackageName = bean.getAppPackageName();
|
||||
LogUtils.d(TAG, String.format("szAppPackageName %s", szAppPackageName));
|
||||
String szAppMainServiveName = bean.getAppMainServiveName();
|
||||
LogUtils.d(TAG, String.format("szAppMainServiveName %s", szAppMainServiveName));
|
||||
|
||||
|
||||
String appName = AppUtils.getAppNameByPackageName(context, sosPackage);
|
||||
String appName = AppUtils.getAppNameByPackageName(context, szAppPackageName);
|
||||
LogUtils.d(TAG, String.format("appName %s", appName));
|
||||
SOSReportBean appSOSReportBean = new SOSReportBean(appName);
|
||||
WinBollNewsBean winBollNewsBean = new WinBollNewsBean(appName);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
|
||||
String currentTime = sdf.format(new Date());
|
||||
StringBuilder sbLine = new StringBuilder();
|
||||
@@ -77,12 +78,12 @@ public class SOSWidget extends AppWidgetProvider {
|
||||
sbLine.append(currentTime);
|
||||
sbLine.append("] Wake up ");
|
||||
sbLine.append(appName);
|
||||
appSOSReportBean.setSosReport(sbLine.toString());
|
||||
winBollNewsBean.setMessage(sbLine.toString());
|
||||
|
||||
addAPPSOSReportBean(context, appSOSReportBean);
|
||||
addWinBollNewsBean(context, winBollNewsBean);
|
||||
|
||||
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
|
||||
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, SOSWidget.class));
|
||||
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, APPNewsWidget.class));
|
||||
for (int appWidgetId : appWidgetIds) {
|
||||
updateAppWidget(context, appWidgetManager, appWidgetId);
|
||||
}
|
||||
@@ -97,53 +98,53 @@ public class SOSWidget extends AppWidgetProvider {
|
||||
//
|
||||
// 加入新报告信息
|
||||
//
|
||||
public synchronized static void addAPPSOSReportBean(Context context, SOSReportBean bean) {
|
||||
initAPPSOSReportBeanList(context);
|
||||
_SOSReportBeanList.add(0, bean);
|
||||
public synchronized static void addWinBollNewsBean(Context context, WinBollNewsBean bean) {
|
||||
initWinBollNewsBeanList(context);
|
||||
_WinBollNewsBeanList.add(0, bean);
|
||||
// 控制记录总数
|
||||
while (_SOSReportBeanList.size() > _MAX_PAGES * _OnePageLinesCount) {
|
||||
_SOSReportBeanList.remove(_SOSReportBeanList.size() - 1);
|
||||
while (_WinBollNewsBeanList.size() > _MAX_PAGES * _OnePageLinesCount) {
|
||||
_WinBollNewsBeanList.remove(_WinBollNewsBeanList.size() - 1);
|
||||
}
|
||||
SOSReportBean.saveBeanList(context, _SOSReportBeanList, SOSReportBean.class);
|
||||
WinBollNewsBean.saveBeanList(context, _WinBollNewsBeanList, WinBollNewsBean.class);
|
||||
}
|
||||
|
||||
synchronized static void initAPPSOSReportBeanList(Context context) {
|
||||
if (_SOSReportBeanList == null) {
|
||||
_SOSReportBeanList = new ArrayList<SOSReportBean>();
|
||||
SOSReportBean.loadBeanList(context, _SOSReportBeanList, SOSReportBean.class);
|
||||
synchronized static void initWinBollNewsBeanList(Context context) {
|
||||
if (_WinBollNewsBeanList == null) {
|
||||
_WinBollNewsBeanList = new ArrayList<WinBollNewsBean>();
|
||||
WinBollNewsBean.loadBeanList(context, _WinBollNewsBeanList, WinBollNewsBean.class);
|
||||
}
|
||||
if (_SOSReportBeanList == null) {
|
||||
_SOSReportBeanList = new ArrayList<SOSReportBean>();
|
||||
SOSReportBean.saveBeanList(context, _SOSReportBeanList, SOSReportBean.class);
|
||||
if (_WinBollNewsBeanList == null) {
|
||||
_WinBollNewsBeanList = new ArrayList<WinBollNewsBean>();
|
||||
WinBollNewsBean.saveBeanList(context, _WinBollNewsBeanList, WinBollNewsBean.class);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
|
||||
LogUtils.d(TAG, "updateAppWidget(...)");
|
||||
|
||||
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_sos);
|
||||
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_news);
|
||||
//设置按钮点击事件
|
||||
Intent intentPre = new Intent(context, SOSWidgetClickListener.class);
|
||||
intentPre.setAction(SOSWidgetClickListener.ACTION_PRE);
|
||||
Intent intentPre = new Intent(context, APPNewsWidgetClickListener.class);
|
||||
intentPre.setAction(APPNewsWidgetClickListener.ACTION_PRE);
|
||||
PendingIntent pendingIntentPre = PendingIntent.getBroadcast(context, 0, intentPre, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
views.setOnClickPendingIntent(R.id.widget_button_pre, pendingIntentPre);
|
||||
Intent intentNext = new Intent(context, SOSWidgetClickListener.class);
|
||||
intentNext.setAction(SOSWidgetClickListener.ACTION_NEXT);
|
||||
Intent intentNext = new Intent(context, APPNewsWidgetClickListener.class);
|
||||
intentNext.setAction(APPNewsWidgetClickListener.ACTION_NEXT);
|
||||
PendingIntent pendingIntentNext = PendingIntent.getBroadcast(context, 0, intentNext, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
views.setOnClickPendingIntent(R.id.widget_button_next, pendingIntentNext);
|
||||
|
||||
views.setTextViewText(R.id.infoTextView, getPageInfo());
|
||||
views.setTextViewText(R.id.sosReportTextView, getMessage());
|
||||
views.setTextViewText(R.id.tv_msg, getPageInfo());
|
||||
views.setTextViewText(R.id.tv_news, getMessage());
|
||||
appWidgetManager.updateAppWidget(appWidgetId, views);
|
||||
}
|
||||
|
||||
public static String getMessage() {
|
||||
ArrayList<String> msgTemp = new ArrayList<String>();
|
||||
if (_SOSReportBeanList != null) {
|
||||
if (_WinBollNewsBeanList != null) {
|
||||
int start = _OnePageLinesCount * _CurrentPageIndex;
|
||||
start = _SOSReportBeanList.size() > start ? start : _SOSReportBeanList.size() - 1;
|
||||
for (int i = start, j = 0; i < _SOSReportBeanList.size() && j < _OnePageLinesCount && start > -1; i++, j++) {
|
||||
msgTemp.add(_SOSReportBeanList.get(i).getSosReport());
|
||||
start = _WinBollNewsBeanList.size() > start ? start : _WinBollNewsBeanList.size() - 1;
|
||||
for (int i = start, j = 0; i < _WinBollNewsBeanList.size() && j < _OnePageLinesCount && start > -1; i++, j++) {
|
||||
msgTemp.add(_WinBollNewsBeanList.get(i).getMessage());
|
||||
}
|
||||
String message = String.join("\n", msgTemp);
|
||||
return message;
|
||||
@@ -152,33 +153,33 @@ public class SOSWidget extends AppWidgetProvider {
|
||||
}
|
||||
|
||||
public static void prePage(Context context) {
|
||||
if (_SOSReportBeanList != null) {
|
||||
if (_WinBollNewsBeanList != null) {
|
||||
if (_CurrentPageIndex > 0) {
|
||||
_CurrentPageIndex = _CurrentPageIndex - 1;
|
||||
}
|
||||
Intent intentWidget = new Intent(context, SOSWidget.class);
|
||||
intentWidget.setAction(SOSWidget.ACTION_RELOAD_REPORT);
|
||||
Intent intentWidget = new Intent(context, APPNewsWidget.class);
|
||||
intentWidget.setAction(APPNewsWidget.ACTION_RELOAD_REPORT);
|
||||
context.sendBroadcast(intentWidget);
|
||||
}
|
||||
}
|
||||
|
||||
public static void nextPage(Context context) {
|
||||
if (_SOSReportBeanList != null) {
|
||||
if ((_CurrentPageIndex + 1) * _OnePageLinesCount < _SOSReportBeanList.size()) {
|
||||
if (_WinBollNewsBeanList != null) {
|
||||
if ((_CurrentPageIndex + 1) * _OnePageLinesCount < _WinBollNewsBeanList.size()) {
|
||||
_CurrentPageIndex = _CurrentPageIndex + 1;
|
||||
}
|
||||
Intent intentWidget = new Intent(context, SOSWidget.class);
|
||||
intentWidget.setAction(SOSWidget.ACTION_RELOAD_REPORT);
|
||||
Intent intentWidget = new Intent(context, APPNewsWidget.class);
|
||||
intentWidget.setAction(APPNewsWidget.ACTION_RELOAD_REPORT);
|
||||
context.sendBroadcast(intentWidget);
|
||||
}
|
||||
}
|
||||
|
||||
String getPageInfo() {
|
||||
if (_SOSReportBeanList == null) {
|
||||
if (_WinBollNewsBeanList == null) {
|
||||
return "0/0";
|
||||
}
|
||||
int leftCount = _SOSReportBeanList.size() % _OnePageLinesCount;
|
||||
int currentPageCount = _SOSReportBeanList.size() / _OnePageLinesCount + (leftCount == 0 ?0: 1);
|
||||
int leftCount = _WinBollNewsBeanList.size() % _OnePageLinesCount;
|
||||
int currentPageCount = _WinBollNewsBeanList.size() / _OnePageLinesCount + (leftCount == 0 ?0: 1);
|
||||
return String.format("%d/%d", _CurrentPageIndex + 1, currentPageCount);
|
||||
}
|
||||
}
|
@@ -10,11 +10,11 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
|
||||
public class SOSWidgetClickListener extends BroadcastReceiver {
|
||||
public class APPNewsWidgetClickListener extends BroadcastReceiver {
|
||||
|
||||
public static final String TAG = "SOSWidgetClickListener";
|
||||
public static final String ACTION_PRE = "cc.winboll.studio.appbase.widgets.SOSWidgetClickListener.ACTION_PRE";
|
||||
public static final String ACTION_NEXT = "cc.winboll.studio.appbase.widgets.SOSWidgetClickListener.ACTION_NEXT";
|
||||
public static final String TAG = "APPNewsWidgetClickListener";
|
||||
public static final String ACTION_PRE = APPNewsWidgetClickListener.class.getName() + ".ACTION_PRE";
|
||||
public static final String ACTION_NEXT = APPNewsWidgetClickListener.class.getName() + ".ACTION_NEXT";
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
@@ -25,10 +25,10 @@ public class SOSWidgetClickListener extends BroadcastReceiver {
|
||||
}
|
||||
if (action.equals(ACTION_PRE)) {
|
||||
LogUtils.d(TAG, "ACTION_PRE");
|
||||
SOSWidget.prePage(context);
|
||||
APPNewsWidget.prePage(context);
|
||||
} else if (action.equals(ACTION_NEXT)) {
|
||||
LogUtils.d(TAG, "ACTION_NEXT");
|
||||
SOSWidget.nextPage(context);
|
||||
APPNewsWidget.nextPage(context);
|
||||
} else {
|
||||
LogUtils.d(TAG, String.format("action %s", action));
|
||||
}
|
@@ -1,149 +1,194 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center">
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/activitymainToolbar1"/>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1.0"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello, WinBoll!"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Android版本10的代号是“Q”,API级别是29。 Android 10开始谷歌不再公开使用甜品作为版本代号,但内部仍保留了大量与“Q”相关的元素。Android 10本身并没有严格对应某个特定的Java版本,但在开发Android 10应用时,通常可以使用Java 8或更高版本。
|
||||
|
||||
Java 8为Android开发带来了诸如Lambda表达式、方法引用等新特性,能提高开发效率和代码可读性,与Android 10开发适配良好。Java 9及更高版本也可用于Android 10开发,能使用一些新的语言特性和API,但可能需要注意兼容性和配置问题。"/>
|
||||
android:layout_weight="1.0">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right|center_vertical">
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Debug Mode"
|
||||
android:layout_weight="1.0"
|
||||
android:onClick="onSwitchDebugMode"
|
||||
android:id="@+id/activitymainCheckBox1"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Test Application CrashReport"
|
||||
android:textAllCaps="false"
|
||||
android:onClick="onTestApplicationCrashReport"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="400dp">
|
||||
android:orientation="vertical"
|
||||
android:gravity="center">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right">
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1.0"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<HorizontalScrollView
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello, WinBoll!"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Android版本10的代号是“Q”,API级别是29。 Android 10开始谷歌不再公开使用甜品作为版本代号,但内部仍保留了大量与“Q”相关的元素。Android 10本身并没有严格对应某个特定的Java版本,但在开发Android 10应用时,通常可以使用Java 8或更高版本。 Java 8为Android开发带来了诸如Lambda表达式、方法引用等新特性,能提高开发效率和代码可读性,与Android 10开发适配良好。Java 9及更高版本也可用于Android 10开发,能使用一些新的语言特性和API,但可能需要注意兼容性和配置问题。"/>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right|center_vertical">
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Debug Mode"
|
||||
android:layout_weight="1.0"
|
||||
android:onClick="onSwitchDebugMode"
|
||||
android:id="@+id/activitymainCheckBox1"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Test Application CrashReport"
|
||||
android:textAllCaps="false"
|
||||
android:onClick="onTestApplicationCrashReport"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="400dp">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right">
|
||||
|
||||
<HorizontalScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="SartTestDemoService"
|
||||
android:textAllCaps="false"
|
||||
android:onClick="onSartTestDemoService"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="StopTestDemoService"
|
||||
android:textAllCaps="false"
|
||||
android:onClick="onStopTestDemoService"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="StopTestDemoServiceNoSettings"
|
||||
android:textAllCaps="false"
|
||||
android:onClick="onStopTestDemoServiceNoSettings"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</HorizontalScrollView>
|
||||
|
||||
<HorizontalScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="SartTestDemoBindService"
|
||||
android:textAllCaps="false"
|
||||
android:onClick="onSartTestDemoBindService"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="StopTestDemoBindService"
|
||||
android:textAllCaps="false"
|
||||
android:onClick="onStopTestDemoBindService"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="StopTestDemoBindServiceNoSettings"
|
||||
android:textAllCaps="false"
|
||||
android:onClick="onStopTestDemoBindServiceNoSettings"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</HorizontalScrollView>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="StartCenter"
|
||||
android:textAllCaps="false"
|
||||
android:onClick="onStartCenter"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="StartTestService"
|
||||
android:text="StopCenter"
|
||||
android:textAllCaps="false"
|
||||
android:onClick="onStartTestService"/>
|
||||
android:onClick="onStopCenter"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="StopTestService"
|
||||
android:text="TestStopMainServiceWithoutSettingEnable"
|
||||
android:textAllCaps="false"
|
||||
android:onClick="onStopTestService"/>
|
||||
android:onClick="onTestStopMainServiceWithoutSettingEnable"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="StopTestServiceNoSettings"
|
||||
android:text="TestUseComponentStartService"
|
||||
android:textAllCaps="false"
|
||||
android:onClick="onStopTestServiceNoSettings"/>
|
||||
android:onClick="onTestUseComponentStartService"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="TestSOS"
|
||||
android:textAllCaps="false"
|
||||
android:onClick="onTestSOS"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</HorizontalScrollView>
|
||||
</ScrollView>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="StartCenter"
|
||||
android:textAllCaps="false"
|
||||
android:onClick="onStartCenter"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="StopCenter"
|
||||
android:textAllCaps="false"
|
||||
android:onClick="onStopCenter"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="TestStopWithoutSettingEnable"
|
||||
android:textAllCaps="false"
|
||||
android:onClick="onTestStopWithoutSettingEnable"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="TestStartWithString"
|
||||
android:textAllCaps="false"
|
||||
android:onClick="onTestStartWithString"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="SOS"
|
||||
android:textAllCaps="false"
|
||||
android:onClick="onSOS"/>
|
||||
<cc.winboll.studio.libappbase.LogView
|
||||
android:layout_height="500dp"
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/activitymainLogView1"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
</LinearLayout>
|
||||
|
||||
<cc.winboll.studio.libappbase.LogView
|
||||
android:layout_weight="1.0"
|
||||
android:layout_height="0dp"
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/activitymainLogView1"/>
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@@ -11,31 +11,40 @@
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right">
|
||||
android:gravity="right|center_vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/infoTextView"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="⇦"
|
||||
android:id="@+id/widget_button_pre"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_weight="1.0"
|
||||
android:text="WinBollNews"
|
||||
android:textStyle="bold"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:text="⇦"
|
||||
android:id="@+id/widget_button_pre"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:text="⇨"
|
||||
android:id="@+id/widget_button_next"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/tv_msg"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:id="@+id/sosReportTextView"
|
||||
android:id="@+id/tv_news"
|
||||
android:layout_weight="1.0"/>
|
||||
|
||||
</LinearLayout>
|
@@ -3,5 +3,5 @@
|
||||
android:minWidth="200dp"
|
||||
android:minHeight="100dp"
|
||||
android:updatePeriodMillis="1000"
|
||||
android:initialLayout="@layout/widget_sos">
|
||||
android:initialLayout="@layout/widget_news">
|
||||
</appwidget-provider>
|
||||
|
24
build.gradle
24
build.gradle
@@ -1,6 +1,12 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
buildscript {
|
||||
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/google/' }
|
||||
maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' }
|
||||
@@ -10,12 +16,6 @@ buildscript {
|
||||
mavenCentral()
|
||||
google()
|
||||
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 {
|
||||
classpath 'com.android.tools.build:gradle:7.2.1'
|
||||
@@ -26,6 +26,12 @@ buildscript {
|
||||
|
||||
allprojects {
|
||||
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://mirrors.tencent.com/repository/maven/tencent_public/"
|
||||
}
|
||||
@@ -42,12 +48,6 @@ allprojects {
|
||||
mavenCentral()
|
||||
google()
|
||||
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 {
|
||||
// 定义全局变量,常用于版本管理
|
||||
|
@@ -18,13 +18,13 @@ def genVersionName(def versionName){
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
buildToolsVersion "30.0.3"
|
||||
compileSdkVersion 32
|
||||
buildToolsVersion "33.0.3"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "cc.winboll.studio.contacts"
|
||||
minSdkVersion 26
|
||||
targetSdkVersion 29
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 30
|
||||
versionCode 1
|
||||
// versionName 更新后需要手动设置
|
||||
// 项目模块目录的 build.gradle 文件的 stageCount=0
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Wed Feb 26 04:37:17 HKT 2025
|
||||
stageCount=3
|
||||
#Tue Feb 25 00:17:29 HKT 2025
|
||||
stageCount=2
|
||||
libraryProject=
|
||||
baseVersion=1.0
|
||||
publishVersion=1.0.2
|
||||
publishVersion=1.0.1
|
||||
buildCount=0
|
||||
baseBetaVersion=1.0.3
|
||||
baseBetaVersion=1.0.2
|
||||
|
@@ -47,8 +47,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import android.content.DialogInterface;
|
||||
import cc.winboll.studio.contacts.activities.SettingsActivity;
|
||||
import cc.winboll.studio.contacts.beans.MainServiceBean;
|
||||
import cc.winboll.studio.contacts.services.MainService;
|
||||
|
||||
final public class MainActivity extends AppCompatActivity implements IWinBollActivity, ViewPager.OnPageChangeListener, View.OnClickListener {
|
||||
|
||||
@@ -142,15 +140,7 @@ final public class MainActivity extends AppCompatActivity implements IWinBollAct
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
MainServiceBean mMainServiceBean = MainServiceBean.loadBean(this, MainServiceBean.class);
|
||||
if (mMainServiceBean == null) {
|
||||
mMainServiceBean = new MainServiceBean();
|
||||
MainServiceBean.saveBean(this, mMainServiceBean);
|
||||
}
|
||||
if (mMainServiceBean.isEnable()) {
|
||||
MainService.startMainService(this);
|
||||
}
|
||||
MainService.startMainService(MainActivity.this);
|
||||
}
|
||||
|
||||
//初始化view,即显示的图片
|
||||
|
@@ -26,10 +26,6 @@ import cc.winboll.studio.libappbase.IWinBollActivity;
|
||||
import cc.winboll.studio.libappbase.bean.APPInfo;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import java.lang.reflect.Field;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
import cc.winboll.studio.contacts.beans.MainServiceBean;
|
||||
import cc.winboll.studio.contacts.services.MainService;
|
||||
|
||||
public class SettingsActivity extends AppCompatActivity implements IWinBollActivity {
|
||||
|
||||
@@ -37,12 +33,6 @@ public class SettingsActivity extends AppCompatActivity implements IWinBollActiv
|
||||
|
||||
Toolbar mToolbar;
|
||||
Switch swSilent;
|
||||
SeekBar msbVolume;
|
||||
TextView mtvVolume;
|
||||
int mnStreamMaxVolume;
|
||||
int mnStreamVolume;
|
||||
Switch mswMainService;
|
||||
|
||||
|
||||
@Override
|
||||
public APPInfo getAppInfo() {
|
||||
@@ -87,69 +77,6 @@ public class SettingsActivity extends AppCompatActivity implements IWinBollActiv
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
getSupportActionBar().setSubtitle(getTag());
|
||||
|
||||
mswMainService = findViewById(R.id.sw_mainservice);
|
||||
MainServiceBean mMainServiceBean = MainServiceBean.loadBean(this, MainServiceBean.class);
|
||||
mswMainService.setChecked(mMainServiceBean.isEnable());
|
||||
mswMainService.setOnClickListener(new View.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
// TODO: Implement this method
|
||||
if (mswMainService.isChecked()) {
|
||||
//ToastUtils.show("Is Checked");
|
||||
MainService.startMainService(SettingsActivity.this);
|
||||
} else {
|
||||
//ToastUtils.show("Not Checked");
|
||||
MainService.stopMainService(SettingsActivity.this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
msbVolume = findViewById(R.id.bellvolume);
|
||||
mtvVolume = findViewById(R.id.tv_volume);
|
||||
final AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
|
||||
|
||||
// 设置SeekBar的最大值为系统铃声音量的最大刻度
|
||||
mnStreamMaxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_RING);
|
||||
msbVolume.setMax(mnStreamMaxVolume);
|
||||
// 获取当前铃声音量并设置为SeekBar的初始进度
|
||||
mnStreamVolume = audioManager.getStreamVolume(AudioManager.STREAM_RING);
|
||||
msbVolume.setProgress(mnStreamVolume);
|
||||
|
||||
updateStreamVolumeTextView();
|
||||
|
||||
msbVolume.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
if (fromUser) {
|
||||
// 设置铃声音量
|
||||
audioManager.setStreamVolume(AudioManager.STREAM_RING, progress, 0);
|
||||
RingTongBean bean = RingTongBean.loadBean(SettingsActivity.this, RingTongBean.class);
|
||||
if (bean == null) {
|
||||
bean = new RingTongBean();
|
||||
}
|
||||
bean.setStreamVolume(progress);
|
||||
RingTongBean.saveBean(SettingsActivity.this, bean);
|
||||
mnStreamVolume = progress;
|
||||
updateStreamVolumeTextView();
|
||||
//Toast.makeText(SettingsActivity.this, "音量设置为: " + progress, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
// 当开始拖动SeekBar时的操作
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
// 当停止拖动SeekBar时的操作
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void updateStreamVolumeTextView() {
|
||||
mtvVolume.setText(String.format("%d/%d", mnStreamVolume, mnStreamMaxVolume));
|
||||
}
|
||||
|
||||
public void onDefaultPhone(View view) {
|
||||
|
@@ -12,26 +12,26 @@ import android.media.AudioManager;
|
||||
import android.util.JsonReader;
|
||||
|
||||
public class RingTongBean extends BaseBean {
|
||||
|
||||
|
||||
public static final String TAG = "AudioRingTongBean";
|
||||
|
||||
// 铃声音量
|
||||
int streamVolume;
|
||||
|
||||
// 模式
|
||||
int ringerMode;
|
||||
|
||||
public RingTongBean() {
|
||||
this.streamVolume = 100;
|
||||
this.ringerMode = AudioManager.RINGER_MODE_NORMAL;
|
||||
}
|
||||
|
||||
public RingTongBean(int streamVolume) {
|
||||
this.streamVolume = streamVolume;
|
||||
public RingTongBean(int ringerMode) {
|
||||
this.ringerMode = ringerMode;
|
||||
}
|
||||
|
||||
public void setStreamVolume(int streamVolume) {
|
||||
this.streamVolume = streamVolume;
|
||||
public void setRingerMode(int ringerMode) {
|
||||
this.ringerMode = ringerMode;
|
||||
}
|
||||
|
||||
public int getStreamVolume() {
|
||||
return streamVolume;
|
||||
public int getRingerMode() {
|
||||
return ringerMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -42,15 +42,15 @@ public class RingTongBean extends BaseBean {
|
||||
@Override
|
||||
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
||||
super.writeThisToJsonWriter(jsonWriter);
|
||||
jsonWriter.name("streamVolume").value(getStreamVolume());
|
||||
jsonWriter.name("ringerMode").value(getRingerMode());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
|
||||
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
|
||||
if (name.equals("streamVolume")) {
|
||||
setStreamVolume(jsonReader.nextInt());
|
||||
if (name.equals("ringerMode")) {
|
||||
setRingerMode(jsonReader.nextInt());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@@ -21,6 +21,8 @@ import cc.winboll.studio.libappbase.LogUtils;
|
||||
public class PhoneCallService extends InCallService {
|
||||
|
||||
public static final String TAG = "PhoneCallService";
|
||||
|
||||
private volatile int originalRingVolume;
|
||||
|
||||
private final Call.Callback callback = new Call.Callback() {
|
||||
@Override
|
||||
@@ -59,78 +61,39 @@ public class PhoneCallService extends InCallService {
|
||||
String phoneNumber = details.getHandle().getSchemeSpecificPart();
|
||||
|
||||
// 记录原始铃声音量
|
||||
//
|
||||
AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
|
||||
|
||||
// 恢复铃声音量,预防其他意外条件导致的音量变化问题
|
||||
//
|
||||
|
||||
// 读取应用配置,未配置就初始化配置文件
|
||||
RingTongBean bean = RingTongBean.loadBean(this, RingTongBean.class);
|
||||
if (bean == null) {
|
||||
// 初始化配置
|
||||
bean = new RingTongBean();
|
||||
RingTongBean.saveBean(this, bean);
|
||||
}
|
||||
// 如果当前音量和应用保存的不一致就恢复为应用设定值
|
||||
// 恢复铃声音量
|
||||
try {
|
||||
audioManager.setStreamVolume(AudioManager.STREAM_RING, bean.getStreamVolume(), 0);
|
||||
//audioManager.setMode(AudioManager.RINGER_MODE_NORMAL);
|
||||
} catch (java.lang.SecurityException e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
|
||||
originalRingVolume = audioManager.getStreamVolume(AudioManager.STREAM_RING);
|
||||
// 检查电话接收规则
|
||||
if (!Rules.getInstance(this).isAllowed(phoneNumber)) {
|
||||
// 调低音量
|
||||
try {
|
||||
audioManager.setStreamVolume(AudioManager.STREAM_RING, 0, 0);
|
||||
//audioManager.setMode(AudioManager.RINGER_MODE_SILENT);
|
||||
} catch (java.lang.SecurityException e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
// 预先静音
|
||||
audioManager.setStreamVolume(AudioManager.STREAM_RING, 0, 0);
|
||||
// 断开电话
|
||||
call.disconnect();
|
||||
// 停顿1秒,预防第一声铃声响动
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
LogUtils.d(TAG, "");
|
||||
}
|
||||
// 恢复铃声音量
|
||||
try {
|
||||
audioManager.setStreamVolume(AudioManager.STREAM_RING, bean.getStreamVolume(), 0);
|
||||
//audioManager.setMode(AudioManager.RINGER_MODE_NORMAL);
|
||||
} catch (java.lang.SecurityException e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
audioManager.setStreamVolume(AudioManager.STREAM_RING, originalRingVolume, 0);
|
||||
// 屏蔽电话结束
|
||||
return;
|
||||
}
|
||||
|
||||
// 正常接听电话
|
||||
PhoneCallActivity.actionStart(this, phoneNumber, callType);
|
||||
}
|
||||
}
|
||||
|
||||
void resumeStreamVolume(AudioManager audioManager, int originalRingVolume) {
|
||||
// 如果当前音量和应用保存的不一致就恢复为应用设定值
|
||||
RingTongBean bean = RingTongBean.loadBean(this, RingTongBean.class);
|
||||
if (bean == null) {
|
||||
bean = new RingTongBean();
|
||||
}
|
||||
if (originalRingVolume != bean.getStreamVolume()) {
|
||||
// 恢复铃声音量
|
||||
audioManager.setStreamVolume(AudioManager.STREAM_RING, bean.getStreamVolume(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCallRemoved(Call call) {
|
||||
super.onCallRemoved(call);
|
||||
|
||||
call.unregisterCallback(callback);
|
||||
PhoneCallManager.call = null;
|
||||
AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
|
||||
// 恢复铃声音量
|
||||
audioManager.setStreamVolume(AudioManager.STREAM_RING, originalRingVolume, 0);
|
||||
}
|
||||
|
||||
public enum CallType {
|
||||
|
@@ -9,11 +9,13 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.media.AudioManager;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
import cc.winboll.studio.contacts.services.MainService;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import java.lang.ref.WeakReference;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
|
||||
public class MainReceiver extends BroadcastReceiver {
|
||||
|
||||
@@ -41,7 +43,7 @@ public class MainReceiver extends BroadcastReceiver {
|
||||
public void registerAction(Context context) {
|
||||
IntentFilter filter=new IntentFilter();
|
||||
filter.addAction(ACTION_BOOT_COMPLETED);
|
||||
//filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
|
||||
//filter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
||||
context.registerReceiver(this, filter);
|
||||
}
|
||||
}
|
||||
|
@@ -30,9 +30,6 @@ import cc.winboll.studio.libappbase.bean.APPSOSBean;
|
||||
import cc.winboll.studio.contacts.dun.Rules;
|
||||
import android.media.AudioManager;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import cc.winboll.studio.contacts.beans.RingTongBean;
|
||||
|
||||
public class MainService extends Service {
|
||||
|
||||
@@ -51,8 +48,8 @@ public class MainService extends Service {
|
||||
AssistantService mAssistantService;
|
||||
boolean isBound = false;
|
||||
MainReceiver mMainReceiver;
|
||||
Timer mStreamVolumeCheckTimer;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return new MyBinder();
|
||||
@@ -74,35 +71,9 @@ public class MainService extends Service {
|
||||
mMyServiceConnection = new MyServiceConnection();
|
||||
}
|
||||
mMainServiceHandler = new MainServiceHandler(this);
|
||||
|
||||
// 铃声检查定时器
|
||||
mStreamVolumeCheckTimer = new Timer();
|
||||
mStreamVolumeCheckTimer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
|
||||
|
||||
// 恢复铃声音量,预防其他意外条件导致的音量变化问题
|
||||
//
|
||||
|
||||
// 读取应用配置,未配置就初始化配置文件
|
||||
RingTongBean bean = RingTongBean.loadBean(MainService.this, RingTongBean.class);
|
||||
if (bean == null) {
|
||||
// 初始化配置
|
||||
bean = new RingTongBean();
|
||||
RingTongBean.saveBean(MainService.this, bean);
|
||||
}
|
||||
// 如果当前音量和应用保存的不一致就恢复为应用设定值
|
||||
// 恢复铃声音量
|
||||
try {
|
||||
audioManager.setStreamVolume(AudioManager.STREAM_RING, bean.getStreamVolume(), 0);
|
||||
//audioManager.setMode(AudioManager.RINGER_MODE_NORMAL);
|
||||
} catch (java.lang.SecurityException e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
}
|
||||
}, 1000, 60000);
|
||||
|
||||
|
||||
|
||||
|
||||
// 运行服务内容
|
||||
mainService();
|
||||
}
|
||||
@@ -133,11 +104,11 @@ public class MainService extends Service {
|
||||
mMainReceiver = new MainReceiver(this);
|
||||
mMainReceiver.registerAction(this);
|
||||
}
|
||||
|
||||
|
||||
Rules.getInstance(this);
|
||||
//Rules.getInstance(this).add("18888888888", true);
|
||||
//Rules.getInstance(this).add("16769764848", true);
|
||||
|
||||
|
||||
startPhoneCallListener();
|
||||
|
||||
MainServiceThread.getInstance(this, mMainServiceHandler).start();
|
||||
@@ -166,7 +137,7 @@ public class MainService extends Service {
|
||||
// LogUtils.d(TAG, "startService(intent)");
|
||||
// bindService(new Intent(this, AssistantService.class), mMyServiceConnection, Context.BIND_IMPORTANT);
|
||||
}
|
||||
|
||||
|
||||
void startPhoneCallListener() {
|
||||
Intent callListener = new Intent(this, CallListenerService.class);
|
||||
startService(callListener);
|
||||
@@ -197,7 +168,7 @@ public class MainService extends Service {
|
||||
|
||||
// 停止主要进程
|
||||
MainServiceThread.getInstance(this, mMainServiceHandler).setIsExit(true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
super.onDestroy();
|
||||
|
@@ -18,25 +18,6 @@
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1.0">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="服务设置:"/>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<Switch
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="主要服务"
|
||||
android:id="@+id/sw_mainservice"
|
||||
android:layout_margin="10dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -64,32 +45,6 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="音量设置:"/>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:id="@+id/tv_volume"/>
|
||||
|
||||
<SeekBar
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:max="100"
|
||||
android:id="@+id/bellvolume"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
@@ -20,13 +20,27 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api 'com.github.getActivity:ToastUtils:10.5'
|
||||
|
||||
api 'androidx.appcompat:appcompat:1.3.1'
|
||||
api 'androidx.vectordrawable:vectordrawable:1.1.0'
|
||||
api 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
|
||||
api 'androidx.fragment:fragment:1.1.0'
|
||||
api 'com.google.android.material:material:1.1.0'
|
||||
|
||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
// SSH
|
||||
implementation 'com.jcraft:jsch:0.1.55'
|
||||
// Html 解析
|
||||
implementation 'org.jsoup:jsoup:1.13.1'
|
||||
// 二维码类库
|
||||
implementation 'com.google.zxing:core:3.4.1'
|
||||
implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
|
||||
// 应用介绍页类库
|
||||
implementation 'io.github.medyo:android-about-page:2.0.0'
|
||||
// 吐司类库
|
||||
implementation 'com.github.getActivity:ToastUtils:10.5'
|
||||
// 网络连接类库
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.4.1'
|
||||
|
||||
// Android 类库
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation 'androidx.viewpager:viewpager:1.0.0'
|
||||
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
|
||||
implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
|
||||
implementation 'androidx.fragment:fragment:1.1.0'
|
||||
implementation 'com.google.android.material:material:1.4.0'
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Tue Feb 25 16:51:09 HKT 2025
|
||||
stageCount=3
|
||||
#Sat Mar 08 04:46:23 HKT 2025
|
||||
stageCount=5
|
||||
libraryProject=libappbase
|
||||
baseVersion=2.0
|
||||
publishVersion=2.0.2
|
||||
baseVersion=2.1
|
||||
publishVersion=2.1.4
|
||||
buildCount=0
|
||||
baseBetaVersion=2.0.3
|
||||
baseBetaVersion=2.1.5
|
||||
|
@@ -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,24 +0,0 @@
|
||||
package cc.winboll.studio.libappbase;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2025/02/04 10:20:16
|
||||
* @Describe WinBoll Activity 接口
|
||||
*/
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import cc.winboll.studio.libappbase.bean.APPInfo;
|
||||
|
||||
public interface IWinBollActivity {
|
||||
|
||||
public static final String TAG = "IWinBollActivity";
|
||||
|
||||
// 获取当前具有 IWinBoll 特征的 AppCompatActivity 活动窗口
|
||||
AppCompatActivity getActivity();
|
||||
|
||||
abstract public APPInfo getAppInfo();
|
||||
abstract public String getTag();
|
||||
abstract Toolbar initToolBar();
|
||||
abstract boolean isEnableDisplayHomeAsUp();
|
||||
abstract boolean isAddWinBollToolBar();
|
||||
}
|
@@ -1,68 +0,0 @@
|
||||
package cc.winboll.studio.libappbase;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2024/08/12 15:07:58
|
||||
* @Describe WinBoll 应用日志窗口
|
||||
*/
|
||||
import android.os.Bundle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.bean.APPInfo;
|
||||
import cc.winboll.studio.libappbase.R;
|
||||
|
||||
public class LogActivity extends AppCompatActivity implements IWinBollActivity {
|
||||
|
||||
public static final String TAG = "LogActivity";
|
||||
|
||||
LogView mLogView;
|
||||
|
||||
@Override
|
||||
public AppCompatActivity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public APPInfo getAppInfo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Toolbar initToolBar() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnableDisplayHomeAsUp() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAddWinBollToolBar() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
LogUtils.d(TAG, "onCreate");
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_log);
|
||||
mLogView = findViewById(R.id.logview);
|
||||
|
||||
if (GlobalApplication.isDebuging()) { mLogView.start(); }
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
LogUtils.d(TAG, "onResume");
|
||||
super.onResume();
|
||||
mLogView.start();
|
||||
}
|
||||
}
|
@@ -38,7 +38,7 @@ public class LogUtils {
|
||||
static volatile boolean _IsInited = false;
|
||||
static Context _mContext;
|
||||
// 日志显示时间格式
|
||||
static SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat("[yyyyMMdd_HHmmSS]", Locale.getDefault());
|
||||
static SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat("[yyyyMMdd_HHmmss_SSS]", Locale.getDefault());
|
||||
// 应用日志文件夹
|
||||
static File _mfLogCacheDir;
|
||||
static File _mfLogDataDir;
|
||||
|
@@ -1,57 +0,0 @@
|
||||
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.APPSOSBean;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class SOS {
|
||||
|
||||
public static final String TAG = "SOS";
|
||||
|
||||
public static final String ACTION_SOS = SOS.class.getName() + ".ACTION_SOS";
|
||||
public static final String ACTION_BIND = SOS.class.getName() + ".ACTION_BIND";
|
||||
public static final String ACTION_SERVICE_ENABLE = SOS.class.getName() + ".ACTION_SERVICE_ENABLE";
|
||||
public static final String ACTION_SERVICE_DISABLE = SOS.class.getName() + ".ACTION_SERVICE_DISENABLE";
|
||||
|
||||
public static void sosWinBollService(Context context, APPSOSBean bean) {
|
||||
Intent intent = new Intent(ACTION_SOS);
|
||||
intent.putExtra("SOS", "Service");
|
||||
intent.putExtra("APPSOSBean", 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 bindToAPPService(Context context, APPSOSBean bean) {
|
||||
Intent intent = new Intent(ACTION_BIND);
|
||||
intent.putExtra("SOS", "Service");
|
||||
intent.putExtra("APPSOSBean", 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,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));
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
package cc.winboll.studio.libappbase;
|
||||
|
||||
|
@@ -1,142 +0,0 @@
|
||||
package cc.winboll.studio.libappbase.bean;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2025/01/20 14:19:02
|
||||
* @Describe 应用信息类
|
||||
*/
|
||||
import cc.winboll.studio.libappbase.R;
|
||||
import java.io.Serializable;
|
||||
|
||||
public class APPInfo implements Serializable {
|
||||
|
||||
public static final String TAG = "APPInfo";
|
||||
|
||||
// 应用名称
|
||||
String appName;
|
||||
// 应用图标
|
||||
int appIcon;
|
||||
// 应用描述
|
||||
String appDescription;
|
||||
// 应用Git仓库地址
|
||||
String appGitName;
|
||||
// 应用Git仓库拥有者
|
||||
String appGitOwner;
|
||||
// 应用Git仓库分支
|
||||
String appGitAPPBranch;
|
||||
// 应用Git仓库子项目文件夹
|
||||
String appGitAPPSubProjectFolder;
|
||||
// 应用主页
|
||||
String appHomePage;
|
||||
// 应用包名称
|
||||
String appAPKName;
|
||||
// 应用包存储文件夹名称
|
||||
String appAPKFolderName;
|
||||
|
||||
public APPInfo(String appName, int appIcon, String appDescription, String appGitName, String appGitOwner, String appGitAPPBranch, String appGitAPPSubProjectFolder, String appHomePage, String appAPKName, String appAPKFolderName) {
|
||||
this.appName = appName;
|
||||
this.appIcon = appIcon;
|
||||
this.appDescription = appDescription;
|
||||
this.appGitName = appGitName;
|
||||
this.appGitOwner = appGitOwner;
|
||||
this.appGitAPPBranch = appGitAPPBranch;
|
||||
this.appGitAPPSubProjectFolder = appGitAPPSubProjectFolder;
|
||||
this.appHomePage = appHomePage;
|
||||
this.appAPKName = appAPKName;
|
||||
this.appAPKFolderName = appAPKFolderName;
|
||||
}
|
||||
|
||||
public APPInfo() {
|
||||
this.appName = "WinBoll-APP";
|
||||
this.appIcon = R.drawable.ic_launcher;
|
||||
this.appDescription = "WinBoll APP";
|
||||
this.appGitName = "APP";
|
||||
this.appGitOwner = "Studio";
|
||||
this.appGitAPPBranch = "app";
|
||||
this.appGitAPPSubProjectFolder = "app";
|
||||
this.appHomePage = "https://www.winboll.cc/studio/details.php?app=APP";
|
||||
this.appAPKName = "APP";
|
||||
this.appAPKFolderName = "APP";
|
||||
}
|
||||
|
||||
public void setAppGitOwner(String appGitOwner) {
|
||||
this.appGitOwner = appGitOwner;
|
||||
}
|
||||
|
||||
public String getAppGitOwner() {
|
||||
return appGitOwner;
|
||||
}
|
||||
|
||||
public void setAppGitAPPBranch(String appGitAPPBranch) {
|
||||
this.appGitAPPBranch = appGitAPPBranch;
|
||||
}
|
||||
|
||||
public String getAppGitAPPBranch() {
|
||||
return appGitAPPBranch;
|
||||
}
|
||||
|
||||
public void setAppGitAPPSubProjectFolder(String appGitAPPSubProjectFolder) {
|
||||
this.appGitAPPSubProjectFolder = appGitAPPSubProjectFolder;
|
||||
}
|
||||
|
||||
public String getAppGitAPPSubProjectFolder() {
|
||||
return appGitAPPSubProjectFolder;
|
||||
}
|
||||
|
||||
public void setAppIcon(int appIcon) {
|
||||
this.appIcon = appIcon;
|
||||
}
|
||||
|
||||
public int getAppIcon() {
|
||||
return appIcon;
|
||||
}
|
||||
|
||||
public void setAppDescription(String appDescription) {
|
||||
this.appDescription = appDescription;
|
||||
}
|
||||
|
||||
public String getAppDescription() {
|
||||
return appDescription;
|
||||
}
|
||||
|
||||
public void setAppAPKFolderName(String appAPKFolderName) {
|
||||
this.appAPKFolderName = appAPKFolderName;
|
||||
}
|
||||
|
||||
public String getAppAPKFolderName() {
|
||||
return appAPKFolderName;
|
||||
}
|
||||
|
||||
public void setAppName(String appName) {
|
||||
this.appName = appName;
|
||||
}
|
||||
|
||||
public String getAppName() {
|
||||
return appName;
|
||||
}
|
||||
|
||||
public void setAppGitName(String appGitName) {
|
||||
this.appGitName = appGitName;
|
||||
}
|
||||
|
||||
public String getAppGitName() {
|
||||
return appGitName;
|
||||
}
|
||||
|
||||
public void setAppHomePage(String appHomePage) {
|
||||
this.appHomePage = appHomePage;
|
||||
}
|
||||
|
||||
public String getAppHomePage() {
|
||||
return appHomePage;
|
||||
}
|
||||
|
||||
public void setAppAPKName(String appAPKName) {
|
||||
this.appAPKName = appAPKName;
|
||||
}
|
||||
|
||||
public String getAppAPKName() {
|
||||
return appAPKName;
|
||||
}
|
||||
}
|
||||
|
@@ -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 APPSOSBean extends BaseBean {
|
||||
|
||||
public static final String TAG = "APPSOSBean";
|
||||
|
||||
protected String sosPackage;
|
||||
protected String sosClassName;
|
||||
|
||||
public APPSOSBean() {
|
||||
this.sosPackage = "";
|
||||
this.sosClassName = "";
|
||||
}
|
||||
|
||||
public APPSOSBean(String sosPackage, String sosClassName) {
|
||||
this.sosPackage = sosPackage;
|
||||
this.sosClassName = sosClassName;
|
||||
}
|
||||
|
||||
public void setSosPackage(String sosPackage) {
|
||||
this.sosPackage = sosPackage;
|
||||
}
|
||||
|
||||
public String getSosPackage() {
|
||||
return sosPackage;
|
||||
}
|
||||
|
||||
public void setSosClassName(String sosClassName) {
|
||||
this.sosClassName = sosClassName;
|
||||
}
|
||||
|
||||
public String getSosClassName() {
|
||||
return sosClassName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return APPSOSBean.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
||||
super.writeThisToJsonWriter(jsonWriter);
|
||||
jsonWriter.name("sosPackage").value(getSosPackage());
|
||||
jsonWriter.name("sosClassName").value(getSosClassName());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
|
||||
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
|
||||
if (name.equals("sosPackage")) {
|
||||
setSosPackage(jsonReader.nextString());
|
||||
} else if (name.equals("sosClassName")) {
|
||||
setSosClassName(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,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, genSOSObject(context.getPackageName(), sosService));
|
||||
intent.setPackage(szToPackage);
|
||||
LogUtils.d(TAG, String.format("ACTION_SOS :\nTo Package : %sSOS Service : %s\n", szToPackage, sosService));
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
public static SOSObject parseSOSObject(String szSOSObject) {
|
||||
try {
|
||||
return SOSObject.parseStringToBean(szSOSObject, SOSObject.class);
|
||||
} catch (IOException e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String sosObjectToString(SOSObject object) {
|
||||
return object.toString();
|
||||
}
|
||||
|
||||
public static String genSOSObject(String objectPackageName, String objectServiveName) {
|
||||
return (new SOSObject(objectPackageName, objectServiveName)).toString();
|
||||
}
|
||||
}
|
@@ -1,10 +1,10 @@
|
||||
package cc.winboll.studio.libappbase;
|
||||
|
||||
package cc.winboll.studio.libappbase.sos;
|
||||
|
||||
/**
|
||||
* @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;
|
||||
@@ -13,18 +13,19 @@ import android.os.IBinder;
|
||||
import android.os.IInterface;
|
||||
import android.os.Parcel;
|
||||
import android.os.RemoteException;
|
||||
import cc.winboll.studio.libappbase.bean.SimpleOperateSignalCenterServiceBean;
|
||||
import java.io.FileDescriptor;
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
|
||||
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;
|
||||
|
||||
SOSCenterServiceModel mSOSCenterServiceModel;
|
||||
static MainThread _MainThread;
|
||||
public static synchronized MainThread getMainThreadInstance() {
|
||||
if (_MainThread == null) {
|
||||
@@ -37,7 +38,7 @@ public class SimpleOperateSignalCenterService extends Service {
|
||||
public IBinder onBind(Intent intent) {
|
||||
return binder;
|
||||
}
|
||||
|
||||
|
||||
public class SOSBinder implements IBinder {
|
||||
|
||||
@Override
|
||||
@@ -81,21 +82,21 @@ 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;
|
||||
SOSCenterService getService() {
|
||||
return SOSCenterService.this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
LogUtils.d(TAG, "onCreate");
|
||||
mSimpleOperateSignalCenterServiceBean = SimpleOperateSignalCenterServiceBean.loadBean(this, SimpleOperateSignalCenterServiceBean.class);
|
||||
if(mSimpleOperateSignalCenterServiceBean == null) {
|
||||
mSimpleOperateSignalCenterServiceBean = new SimpleOperateSignalCenterServiceBean();
|
||||
SimpleOperateSignalCenterServiceBean.saveBean(this, mSimpleOperateSignalCenterServiceBean);
|
||||
mSOSCenterServiceModel = SOSCenterServiceModel.loadBean(this, SOSCenterServiceModel.class);
|
||||
if(mSOSCenterServiceModel == null) {
|
||||
mSOSCenterServiceModel = new SOSCenterServiceModel();
|
||||
SOSCenterServiceModel.saveBean(this, mSOSCenterServiceModel);
|
||||
}
|
||||
runMainThread();
|
||||
}
|
||||
@@ -103,21 +104,15 @@ 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);
|
||||
return mSOSCenterServiceModel.isEnable() ? Service.START_STICKY: super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
|
||||
void runMainThread() {
|
||||
mSimpleOperateSignalCenterServiceBean = SimpleOperateSignalCenterServiceBean.loadBean(this, SimpleOperateSignalCenterServiceBean.class);
|
||||
if (mSimpleOperateSignalCenterServiceBean.isEnable()
|
||||
mSOSCenterServiceModel = mSOSCenterServiceModel.loadBean(this, SOSCenterServiceModel.class);
|
||||
if (mSOSCenterServiceModel.isEnable()
|
||||
&& _MainThread == null) {
|
||||
getMainThreadInstance().start();
|
||||
}
|
||||
@@ -127,9 +122,9 @@ public class SimpleOperateSignalCenterService extends Service {
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
LogUtils.d(TAG, "onDestroy");
|
||||
mSimpleOperateSignalCenterServiceBean = SimpleOperateSignalCenterServiceBean.loadBean(this, SimpleOperateSignalCenterServiceBean.class);
|
||||
if (mSimpleOperateSignalCenterServiceBean.isEnable()) {
|
||||
LogUtils.d(TAG, "mSimpleOperateSignalCenterServiceBean.isEnable()");
|
||||
mSOSCenterServiceModel = SOSCenterServiceModel.loadBean(this, SOSCenterServiceModel.class);
|
||||
if (mSOSCenterServiceModel.isEnable()) {
|
||||
LogUtils.d(TAG, "mSOSCenterServiceModel.isEnable()");
|
||||
// ISOSAPP iSOSAPP = (ISOSAPP)getApplication();
|
||||
// iSOSAPP.helpISOSService(getISOSServiceIntentWhichAskForHelp());
|
||||
}
|
||||
@@ -141,22 +136,22 @@ public class SimpleOperateSignalCenterService extends Service {
|
||||
|
||||
public static void stopISOSService(Context context) {
|
||||
LogUtils.d(TAG, "stopISOSService");
|
||||
SimpleOperateSignalCenterServiceBean bean = new SimpleOperateSignalCenterServiceBean();
|
||||
SOSCenterServiceModel bean = new SOSCenterServiceModel();
|
||||
bean.setIsEnable(false);
|
||||
SimpleOperateSignalCenterServiceBean.saveBean(context, bean);
|
||||
context.stopService(new Intent(context, SimpleOperateSignalCenterService.class));
|
||||
SOSCenterServiceModel.saveBean(context, bean);
|
||||
context.stopService(new Intent(context, SOSCenterServiceModel.class));
|
||||
}
|
||||
|
||||
public static void startISOSService(Context context) {
|
||||
LogUtils.d(TAG, "startISOSService");
|
||||
SimpleOperateSignalCenterServiceBean bean = new SimpleOperateSignalCenterServiceBean();
|
||||
SOSCenterServiceModel bean = new SOSCenterServiceModel();
|
||||
bean.setIsEnable(true);
|
||||
SimpleOperateSignalCenterServiceBean.saveBean(context, bean);
|
||||
context.startService(new Intent(context, SimpleOperateSignalCenterService.class));
|
||||
SOSCenterServiceModel.saveBean(context, bean);
|
||||
context.startService(new Intent(context, SOSCenterServiceModel.class));
|
||||
}
|
||||
|
||||
|
||||
public String getMessage() {
|
||||
return "Hello from SimpleOperateSignalCenterService";
|
||||
return "Hello from SOSCenterServiceModel";
|
||||
}
|
||||
|
||||
static class MainThread extends Thread {
|
@@ -0,0 +1,69 @@
|
||||
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;
|
||||
|
||||
public class SOSCenterServiceModel extends BaseBean {
|
||||
|
||||
public static final String TAG = "SOSCenterServiceModel";
|
||||
|
||||
boolean isEnable;
|
||||
|
||||
public SOSCenterServiceModel() {
|
||||
this.isEnable = false;
|
||||
}
|
||||
|
||||
public void setIsEnable(boolean isEnable) {
|
||||
this.isEnable = isEnable;
|
||||
}
|
||||
|
||||
public boolean isEnable() {
|
||||
return isEnable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return SOSCenterServiceModel.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
||||
super.writeThisToJsonWriter(jsonWriter);
|
||||
jsonWriter.name("isEnable").value(isEnable());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
|
||||
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
|
||||
if (name.equals("isEnable")) {
|
||||
setIsEnable(jsonReader.nextBoolean());
|
||||
} 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,29 @@
|
||||
package cc.winboll.studio.libappbase.sos;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/02/27 14:04:35
|
||||
* @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 static final String TAG = "SOSCenterServiceReceiver";
|
||||
|
||||
public static final String ACTION_SOS = SOSCenterServiceReceiver.class.getName() + ".ACTION_SOS";
|
||||
|
||||
@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,39 @@
|
||||
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_APPMODEL";
|
||||
|
||||
public static void bindToAPPBase(Context context, String appMainService) {
|
||||
LogUtils.d(TAG, "bindToAPPBase(...)");
|
||||
String toPackage = "cc.winboll.studio.appbase";
|
||||
startBind(context, toPackage, appMainService);
|
||||
}
|
||||
|
||||
public static void bindToAPPBaseBeta(Context context, String appMainService) {
|
||||
LogUtils.d(TAG, "bindToAPPBaseBeta(...)");
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
@@ -17,7 +17,6 @@ import cc.winboll.studio.libappbase.utils.ServiceUtils;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
import cc.winboll.studio.libappbase.services.TestService;
|
||||
|
||||
public class StatusWidget extends AppWidgetProvider {
|
||||
|
||||
@@ -52,12 +51,12 @@ public class StatusWidget extends AppWidgetProvider {
|
||||
PendingIntent pendingIntentAppButton = PendingIntent.getBroadcast(context, 0, intentAppButton, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
views.setOnClickPendingIntent(R.id.ivapp, pendingIntentAppButton);
|
||||
|
||||
boolean isActive = ServiceUtils.isServiceRunning(context, TestService.class.getName());
|
||||
if (isActive) {
|
||||
views.setImageViewResource(R.id.ivapp, cc.winboll.studio.libappbase.R.drawable.ic_launcher);
|
||||
} else {
|
||||
views.setImageViewResource(R.id.ivapp, cc.winboll.studio.libappbase.R.drawable.ic_launcher_disable);
|
||||
}
|
||||
// boolean isActive = ServiceUtils.isServiceRunning(context, TestService.class.getName());
|
||||
// if (isActive) {
|
||||
// views.setImageViewResource(R.id.ivapp, cc.winboll.studio.libappbase.R.drawable.ic_launcher);
|
||||
// } else {
|
||||
// views.setImageViewResource(R.id.ivapp, cc.winboll.studio.libappbase.R.drawable.ic_launcher_disable);
|
||||
// }
|
||||
appWidgetManager.updateAppWidget(appWidgetId, views);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user