Merge branch 'appbase' into aes
This commit is contained in:
commit
39b16318f9
@ -29,7 +29,7 @@ android {
|
|||||||
// versionName 更新后需要手动设置
|
// versionName 更新后需要手动设置
|
||||||
// .winboll/winbollBuildProps.properties 文件的 stageCount=0
|
// .winboll/winbollBuildProps.properties 文件的 stageCount=0
|
||||||
// Gradle编译环境下合起来的 versionName 就是 "${versionName}.0"
|
// Gradle编译环境下合起来的 versionName 就是 "${versionName}.0"
|
||||||
versionName "2.0"
|
versionName "2.1"
|
||||||
if(true) {
|
if(true) {
|
||||||
versionName = genVersionName("${versionName}")
|
versionName = genVersionName("${versionName}")
|
||||||
}
|
}
|
||||||
@ -44,9 +44,13 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
api project(':libappbase')
|
implementation project(':libappbase')
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation 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.google.zxing:core:3.4.1'
|
||||||
implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
|
implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Thu Feb 27 02:34:13 GMT 2025
|
#Sat Mar 08 02:31:11 HKT 2025
|
||||||
stageCount=3
|
stageCount=2
|
||||||
libraryProject=libappbase
|
libraryProject=libappbase
|
||||||
baseVersion=2.0
|
baseVersion=2.1
|
||||||
publishVersion=2.0.2
|
publishVersion=2.1.1
|
||||||
buildCount=4
|
buildCount=0
|
||||||
baseBetaVersion=2.0.3
|
baseBetaVersion=2.1.2
|
||||||
|
@ -54,19 +54,25 @@
|
|||||||
<receiver android:name="cc.winboll.studio.appbase.receivers.MainReceiver">
|
<receiver android:name="cc.winboll.studio.appbase.receivers.MainReceiver">
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
|
||||||
<action android:name="cc.winboll.studio.appbase.receivers.MainReceiver"/>
|
<action android:name="cc.winboll.studio.appbase.receivers.MainReceiver"/>
|
||||||
|
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".widgets.WinBollNewsWidget"
|
android:name=".widgets.APPNewsWidget"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="cc.winboll.studio.appbase.widgets.WinBollNewsWidget.ACTION_WAKEUP_SERVICE"/>
|
|
||||||
<action android:name="cc.winboll.studio.appbase.widgets.WinBollNewsWidget.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"/>
|
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
|
||||||
|
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
@ -75,13 +81,13 @@
|
|||||||
|
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
<receiver android:name=".widgets.WinBollNewsWidgetClickListener">
|
<receiver android:name=".widgets.APPNewsWidgetClickListener">
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
|
||||||
<action android:name="cc.winboll.studio.appbase.widgets.WinBollNewsWidgetClickListener.ACTION_PRE"/>
|
<action android:name="cc.winboll.studio.appbase.widgets.APPNewsWidgetClickListener.ACTION_PRE"/>
|
||||||
|
|
||||||
<action android:name="cc.winboll.studio.appbase.widgets.WinBollNewsWidgetClickListener.ACTION_NEXT"/>
|
<action android:name="cc.winboll.studio.appbase.widgets.APPNewsWidgetClickListener.ACTION_NEXT"/>
|
||||||
|
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
@ -91,6 +97,11 @@
|
|||||||
android:name="android.max_aspect"
|
android:name="android.max_aspect"
|
||||||
android:value="4.0"/>
|
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>
|
</application>
|
||||||
|
|
||||||
|
@ -6,22 +6,23 @@ package cc.winboll.studio.appbase;
|
|||||||
* @Describe APPbase 应用类
|
* @Describe APPbase 应用类
|
||||||
*/
|
*/
|
||||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||||
import cc.winboll.studio.libappbase.SOSCSBroadcastReceiver;
|
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
|
import cc.winboll.studio.libappbase.sos.SOSCenterServiceReceiver;
|
||||||
|
import cc.winboll.studio.libappbase.sos.SOS;
|
||||||
|
|
||||||
public class App extends GlobalApplication {
|
public class App extends GlobalApplication {
|
||||||
|
|
||||||
public static final String TAG = "App";
|
public static final String TAG = "App";
|
||||||
|
|
||||||
SOSCSBroadcastReceiver mSOSCSBroadcastReceiver;
|
SOSCenterServiceReceiver mSOSCenterServiceReceiver;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
GlobalApplication.setIsDebuging(this, BuildConfig.DEBUG);
|
GlobalApplication.setIsDebuging(this, BuildConfig.DEBUG);
|
||||||
mSOSCSBroadcastReceiver = new SOSCSBroadcastReceiver();
|
mSOSCenterServiceReceiver = new SOSCenterServiceReceiver();
|
||||||
IntentFilter intentFilter = new IntentFilter();
|
IntentFilter intentFilter = new IntentFilter();
|
||||||
intentFilter.addAction(SOSCSBroadcastReceiver.ACTION_SOS);
|
intentFilter.addAction(SOS.ACTION_SOS);
|
||||||
registerReceiver(mSOSCSBroadcastReceiver, intentFilter);
|
registerReceiver(mSOSCenterServiceReceiver, intentFilter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package cc.winboll.studio.appbase;
|
package cc.winboll.studio.appbase;
|
||||||
|
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -9,15 +8,16 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import cc.winboll.studio.appbase.R;
|
import cc.winboll.studio.appbase.R;
|
||||||
import cc.winboll.studio.appbase.services.MainService;
|
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.GlobalApplication;
|
||||||
import cc.winboll.studio.libappbase.LogUtils;
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
import cc.winboll.studio.libappbase.LogView;
|
import cc.winboll.studio.libappbase.LogView;
|
||||||
import cc.winboll.studio.libappbase.WinBoll;
|
|
||||||
import cc.winboll.studio.libappbase.SimpleOperateSignalCenterService;
|
|
||||||
import cc.winboll.studio.libappbase.bean.APPNewsBean;
|
|
||||||
import cc.winboll.studio.libappbase.services.TestService;
|
|
||||||
import cc.winboll.studio.libappbase.widgets.StatusWidget;
|
import cc.winboll.studio.libappbase.widgets.StatusWidget;
|
||||||
import com.hjq.toast.ToastUtils;
|
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 {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@ -68,17 +68,17 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
MainService.stopMainService(this);
|
MainService.stopMainService(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTestStopWithoutSettingEnable(View view) {
|
public void onTestStopMainServiceWithoutSettingEnable(View view) {
|
||||||
LogUtils.d(TAG, "onTestStopWithoutSettingEnable");
|
LogUtils.d(TAG, "onTestStopMainServiceWithoutSettingEnable");
|
||||||
stopService(new Intent(this, SimpleOperateSignalCenterService.class));
|
stopService(new Intent(this, MainService.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTestStartWithString(View view) {
|
public void onTestUseComponentStartService(View view) {
|
||||||
LogUtils.d(TAG, "onTestStartWithString");
|
LogUtils.d(TAG, "onTestUseComponentStartService");
|
||||||
|
|
||||||
// 目标服务的包名和类名
|
// 目标服务的包名和类名
|
||||||
String packageName = this.getPackageName();
|
String packageName = this.getPackageName();
|
||||||
String serviceClassName = SimpleOperateSignalCenterService.class.getName();
|
String serviceClassName = TestDemoService.class.getName();
|
||||||
|
|
||||||
// 构建Intent
|
// 构建Intent
|
||||||
Intent intentService = new Intent();
|
Intent intentService = new Intent();
|
||||||
@ -87,30 +87,55 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
startService(intentService);
|
startService(intentService);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSOS(View view) {
|
public void onTestSOS(View view) {
|
||||||
Intent intent = new Intent(this, TestService.class);
|
Intent intent = new Intent(this, TestDemoService.class);
|
||||||
stopService(intent);
|
stopService(intent);
|
||||||
WinBoll.sosService(this, new APPNewsBean(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) {
|
public void onSartTestDemoService(View view) {
|
||||||
Intent intent = new Intent(this, TestService.class);
|
Intent intent = new Intent(this, TestDemoService.class);
|
||||||
intent.setAction(WinBoll.ACTION_SERVICE_ENABLE);
|
intent.setAction(TestDemoService.ACTION_ENABLE);
|
||||||
startService(intent);
|
startService(intent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onStopTestService(View view) {
|
public void onStopTestDemoService(View view) {
|
||||||
Intent intent = new Intent(this, TestService.class);
|
Intent intent = new Intent(this, TestDemoService.class);
|
||||||
intent.setAction(WinBoll.ACTION_SERVICE_DISABLE);
|
intent.setAction(TestDemoService.ACTION_DISABLE);
|
||||||
startService(intent);
|
startService(intent);
|
||||||
|
|
||||||
Intent intentStop = new Intent(this, TestService.class);
|
Intent intentStop = new Intent(this, TestDemoService.class);
|
||||||
stopService(intentStop);
|
stopService(intentStop);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onStopTestServiceNoSettings(View view) {
|
public void onStopTestDemoServiceNoSettings(View view) {
|
||||||
Intent intent = new Intent(this, TestService.class);
|
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);
|
stopService(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,7 @@ public class MainServiceBean extends BaseBean {
|
|||||||
@Override
|
@Override
|
||||||
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
||||||
super.writeThisToJsonWriter(jsonWriter);
|
super.writeThisToJsonWriter(jsonWriter);
|
||||||
MainServiceBean bean = this;
|
jsonWriter.name("isEnable").value(isEnable());
|
||||||
jsonWriter.name("isEnable").value(bean.isEnable());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package cc.winboll.studio.libappbase.bean;
|
package cc.winboll.studio.appbase.beans;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author ZhanGSKen@AliYun.Com
|
* @Author ZhanGSKen@AliYun.Com
|
||||||
* @Date 2025/02/19 13:34:52
|
* @Date 2025/03/07 12:47:22
|
||||||
* @Describe TestServiceBean
|
* @Describe TestServiceBean
|
||||||
*/
|
*/
|
||||||
import android.util.JsonReader;
|
import android.util.JsonReader;
|
||||||
@ -10,13 +10,13 @@ import android.util.JsonWriter;
|
|||||||
import cc.winboll.studio.libappbase.BaseBean;
|
import cc.winboll.studio.libappbase.BaseBean;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class TestServiceBean extends BaseBean {
|
public class TestDemoBindServiceBean extends BaseBean {
|
||||||
|
|
||||||
public static final String TAG = "TestServiceBean";
|
public static final String TAG = "TestServiceBean";
|
||||||
|
|
||||||
boolean isEnable;
|
boolean isEnable;
|
||||||
|
|
||||||
public TestServiceBean() {
|
public TestDemoBindServiceBean() {
|
||||||
this.isEnable = false;
|
this.isEnable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ public class TestServiceBean extends BaseBean {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return TestServiceBean.class.getName();
|
return TestDemoBindServiceBean.class.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -0,0 +1,68 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
public class TestDemoServiceBean extends BaseBean {
|
||||||
|
|
||||||
|
public static final String TAG = "TestDemoServiceBean";
|
||||||
|
|
||||||
|
boolean isEnable;
|
||||||
|
|
||||||
|
public TestDemoServiceBean() {
|
||||||
|
this.isEnable = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsEnable(boolean isEnable) {
|
||||||
|
this.isEnable = isEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnable() {
|
||||||
|
return isEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return TestDemoServiceBean.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;
|
||||||
|
}
|
||||||
|
}
|
@ -13,16 +13,18 @@ import android.content.Intent;
|
|||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import cc.winboll.studio.appbase.beans.WinBollNewsBean;
|
import cc.winboll.studio.appbase.beans.WinBollNewsBean;
|
||||||
import cc.winboll.studio.appbase.services.MainService;
|
import cc.winboll.studio.appbase.services.MainService;
|
||||||
import cc.winboll.studio.appbase.widgets.WinBollNewsWidget;
|
import cc.winboll.studio.appbase.widgets.APPNewsWidget;
|
||||||
import cc.winboll.studio.libappbase.AppUtils;
|
import cc.winboll.studio.libappbase.AppUtils;
|
||||||
import cc.winboll.studio.libappbase.LogUtils;
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
import cc.winboll.studio.libappbase.WinBoll;
|
|
||||||
import cc.winboll.studio.libappbase.bean.APPNewsBean;
|
|
||||||
import com.hjq.toast.ToastUtils;
|
import com.hjq.toast.ToastUtils;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import cc.winboll.studio.libappbase.sos.WinBoll;
|
||||||
|
import cc.winboll.studio.libappbase.sos.APPModel;
|
||||||
|
import cc.winboll.studio.libappbase.sos.SOS;
|
||||||
|
import cc.winboll.studio.libappbase.sos.SOSObject;
|
||||||
|
|
||||||
public class MainReceiver extends BroadcastReceiver {
|
public class MainReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
@ -45,49 +47,39 @@ public class MainReceiver extends BroadcastReceiver {
|
|||||||
LogUtils.d(TAG, "ACTION_BIND");
|
LogUtils.d(TAG, "ACTION_BIND");
|
||||||
LogUtils.d(TAG, String.format("context.getPackageName() %s", context.getPackageName()));
|
LogUtils.d(TAG, String.format("context.getPackageName() %s", context.getPackageName()));
|
||||||
LogUtils.d(TAG, String.format("intent.getAction() %s", intent.getAction()));
|
LogUtils.d(TAG, String.format("intent.getAction() %s", intent.getAction()));
|
||||||
String SOS = intent.getStringExtra("SOS");
|
String szAPPModel = intent.getStringExtra(WinBoll.EXTRA_APPMODEL);
|
||||||
LogUtils.d(TAG, String.format("SOS %s", SOS));
|
LogUtils.d(TAG, String.format("szAPPModel %s", szAPPModel));
|
||||||
if (SOS != null && SOS.equals("Service")) {
|
if (szAPPModel != null && !szAPPModel.equals("")) {
|
||||||
String szAPPSOSBean = intent.getStringExtra("APPSOSBean");
|
|
||||||
LogUtils.d(TAG, String.format("szAPPSOSBean %s", szAPPSOSBean));
|
|
||||||
if (szAPPSOSBean != null && !szAPPSOSBean.equals("")) {
|
|
||||||
try {
|
try {
|
||||||
APPNewsBean bean = APPNewsBean.parseStringToBean(szAPPSOSBean, APPNewsBean.class);
|
APPModel bean = APPModel.parseStringToBean(szAPPModel, APPModel.class);
|
||||||
if (bean != null) {
|
if (bean != null) {
|
||||||
String szNewsPackageName = bean.getNewsPackageName();
|
String szAppPackageName = bean.getAppPackageName();
|
||||||
LogUtils.d(TAG, String.format("szNewsPackageName %s", szNewsPackageName));
|
LogUtils.d(TAG, String.format("szAppPackageName %s", szAppPackageName));
|
||||||
String szNewsClassName = bean.getNewsClassName();
|
String szAppMainServiveName = bean.getAppMainServiveName();
|
||||||
LogUtils.d(TAG, String.format("szNewsClassName %s", szNewsClassName));
|
LogUtils.d(TAG, String.format("szAppMainServiveName %s", szAppMainServiveName));
|
||||||
mwrService.get().bindSOSConnection(bean);
|
mwrService.get().bindAPPModelConnection(bean);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (intent.getAction().equals(SOS.ACTION_SOS)) {
|
||||||
} else if (intent.getAction().equals(WinBoll.ACTION_SOS)) {
|
|
||||||
LogUtils.d(TAG, "ACTION_SOS");
|
LogUtils.d(TAG, "ACTION_SOS");
|
||||||
LogUtils.d(TAG, String.format("context.getPackageName() %s", context.getPackageName()));
|
String sos = intent.getStringExtra(SOS.EXTRA_OBJECT);
|
||||||
LogUtils.d(TAG, String.format("intent.getAction() %s", intent.getAction()));
|
LogUtils.d(TAG, String.format("SOS %s", sos));
|
||||||
String SOS = intent.getStringExtra("SOS");
|
if (sos != null && !sos.equals("")) {
|
||||||
LogUtils.d(TAG, String.format("SOS %s", SOS));
|
SOSObject bean = SOS.parseSOSObject(sos);
|
||||||
if (SOS != null && SOS.equals("Service")) {
|
|
||||||
String szAPPNewsBean = intent.getStringExtra("APPSOSBean");
|
|
||||||
LogUtils.d(TAG, String.format("szAPPNewsBean %s", szAPPNewsBean));
|
|
||||||
if (szAPPNewsBean != null && !szAPPNewsBean.equals("")) {
|
|
||||||
try {
|
|
||||||
APPNewsBean bean = APPNewsBean.parseStringToBean(szAPPNewsBean, APPNewsBean.class);
|
|
||||||
if (bean != null) {
|
if (bean != null) {
|
||||||
String szNewsPackageName = bean.getNewsPackageName();
|
String szObjectPackageName = bean.getObjectPackageName();
|
||||||
LogUtils.d(TAG, String.format("szNewsPackageName %s", szNewsPackageName));
|
LogUtils.d(TAG, String.format("szObjectPackageName %s", szObjectPackageName));
|
||||||
String szNewsClassName = bean.getNewsClassName();
|
String szObjectServiveName = bean.getObjectServiveName();
|
||||||
LogUtils.d(TAG, String.format("szNewsClassName %s", szNewsClassName));
|
LogUtils.d(TAG, String.format("szObjectServiveName %s", szObjectServiveName));
|
||||||
|
|
||||||
Intent intentService = new Intent();
|
Intent intentService = new Intent();
|
||||||
intentService.setComponent(new ComponentName(szNewsPackageName, szNewsClassName));
|
intentService.setComponent(new ComponentName(szObjectPackageName, szObjectServiveName));
|
||||||
context.startService(intentService);
|
context.startService(intentService);
|
||||||
|
|
||||||
String appName = AppUtils.getAppNameByPackageName(context, szNewsPackageName);
|
String appName = AppUtils.getAppNameByPackageName(context, szObjectPackageName);
|
||||||
LogUtils.d(TAG, String.format("appName %s", appName));
|
LogUtils.d(TAG, String.format("appName %s", appName));
|
||||||
WinBollNewsBean appWinBollNewsBean = new WinBollNewsBean(appName);
|
WinBollNewsBean appWinBollNewsBean = new WinBollNewsBean(appName);
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
|
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
|
||||||
@ -99,16 +91,14 @@ public class MainReceiver extends BroadcastReceiver {
|
|||||||
sbLine.append(appName);
|
sbLine.append(appName);
|
||||||
appWinBollNewsBean.setMessage(sbLine.toString());
|
appWinBollNewsBean.setMessage(sbLine.toString());
|
||||||
|
|
||||||
WinBollNewsWidget.addWinBollNewsBean(context, appWinBollNewsBean);
|
APPNewsWidget.addWinBollNewsBean(context, appWinBollNewsBean);
|
||||||
|
|
||||||
Intent intentWidget = new Intent(context, WinBollNewsWidget.class);
|
Intent intentWidget = new Intent(context, APPNewsWidget.class);
|
||||||
intentWidget.setAction(WinBollNewsWidget.ACTION_RELOAD_REPORT);
|
intentWidget.setAction(APPNewsWidget.ACTION_RELOAD_REPORT);
|
||||||
context.sendBroadcast(intentWidget);
|
context.sendBroadcast(intentWidget);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
|
||||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ToastUtils.show(szAction);
|
ToastUtils.show(szAction);
|
||||||
@ -120,10 +110,8 @@ public class MainReceiver extends BroadcastReceiver {
|
|||||||
public void registerAction(MainService service) {
|
public void registerAction(MainService service) {
|
||||||
IntentFilter filter=new IntentFilter();
|
IntentFilter filter=new IntentFilter();
|
||||||
filter.addAction(ACTION_BOOT_COMPLETED);
|
filter.addAction(ACTION_BOOT_COMPLETED);
|
||||||
filter.addAction(WinBoll.ACTION_SOS);
|
filter.addAction(SOS.ACTION_SOS);
|
||||||
filter.addAction(WinBoll.ACTION_BIND);
|
filter.addAction(WinBoll.ACTION_BIND);
|
||||||
filter.addAction(WinBoll.ACTION_SERVICE_ENABLE);
|
|
||||||
filter.addAction(WinBoll.ACTION_SERVICE_DISABLE);
|
|
||||||
//filter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
//filter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
||||||
service.registerReceiver(this, filter);
|
service.registerReceiver(this, filter);
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,10 @@ import cc.winboll.studio.appbase.handlers.MainServiceHandler;
|
|||||||
import cc.winboll.studio.appbase.receivers.MainReceiver;
|
import cc.winboll.studio.appbase.receivers.MainReceiver;
|
||||||
import cc.winboll.studio.appbase.services.AssistantService;
|
import cc.winboll.studio.appbase.services.AssistantService;
|
||||||
import cc.winboll.studio.appbase.threads.MainServiceThread;
|
import cc.winboll.studio.appbase.threads.MainServiceThread;
|
||||||
import cc.winboll.studio.appbase.widgets.WinBollNewsWidget;
|
import cc.winboll.studio.appbase.widgets.APPNewsWidget;
|
||||||
import cc.winboll.studio.libappbase.LogUtils;
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
import cc.winboll.studio.libappbase.bean.APPNewsBean;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import cc.winboll.studio.libappbase.sos.APPModel;
|
||||||
|
|
||||||
public class MainService extends Service {
|
public class MainService extends Service {
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ public class MainService extends Service {
|
|||||||
AssistantService mAssistantService;
|
AssistantService mAssistantService;
|
||||||
boolean isBound = false;
|
boolean isBound = false;
|
||||||
MainReceiver mMainReceiver;
|
MainReceiver mMainReceiver;
|
||||||
ArrayList<SOSConnection> mSOSConnectionList;
|
ArrayList<APPConnection> mAPPModelConnectionList;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBinder onBind(Intent intent) {
|
public IBinder onBind(Intent intent) {
|
||||||
@ -60,7 +60,7 @@ public class MainService extends Service {
|
|||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
LogUtils.d(TAG, "onCreate()");
|
LogUtils.d(TAG, "onCreate()");
|
||||||
mSOSConnectionList = new ArrayList<SOSConnection>();
|
mAPPModelConnectionList = new ArrayList<APPConnection>();
|
||||||
|
|
||||||
_mControlCenterService = MainService.this;
|
_mControlCenterService = MainService.this;
|
||||||
isServiceRunning = false;
|
isServiceRunning = false;
|
||||||
@ -101,8 +101,8 @@ public class MainService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 启动小部件
|
// 启动小部件
|
||||||
Intent intentTimeWidget = new Intent(this, WinBollNewsWidget.class);
|
Intent intentTimeWidget = new Intent(this, APPNewsWidget.class);
|
||||||
intentTimeWidget.setAction(WinBollNewsWidget.ACTION_RELOAD_REPORT);
|
intentTimeWidget.setAction(APPNewsWidget.ACTION_RELOAD_REPORT);
|
||||||
this.sendBroadcast(intentTimeWidget);
|
this.sendBroadcast(intentTimeWidget);
|
||||||
|
|
||||||
startMainServiceThread();
|
startMainServiceThread();
|
||||||
@ -117,21 +117,11 @@ public class MainService extends Service {
|
|||||||
//
|
//
|
||||||
void wakeupAndBindAssistant() {
|
void wakeupAndBindAssistant() {
|
||||||
LogUtils.d(TAG, "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);
|
Intent intent = new Intent(this, AssistantService.class);
|
||||||
startService(intent);
|
startService(intent);
|
||||||
// 绑定服务的Intent
|
// 绑定服务的Intent
|
||||||
//Intent intent = new Intent(this, AssistantService.class);
|
|
||||||
bindService(intent, mMyServiceConnection, Context.BIND_IMPORTANT);
|
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(APPNewsBean bean) {
|
public void bindAPPModelConnection(APPModel bean) {
|
||||||
LogUtils.d(TAG, "bindSOSConnection(...)");
|
LogUtils.d(TAG, "bindAPPModelConnection(...)");
|
||||||
// 清理旧的绑定链接
|
// 清理旧的绑定链接
|
||||||
for (int i = mSOSConnectionList.size() - 1; i > -1; i--) {
|
for (int i = mAPPModelConnectionList.size() - 1; i > -1; i--) {
|
||||||
SOSConnection item = mSOSConnectionList.get(i);
|
APPConnection item = mAPPModelConnectionList.get(i);
|
||||||
if (item.isBindToAPPSOSBean(bean)) {
|
if (item.isBindToAPP(bean)) {
|
||||||
LogUtils.d(TAG, "Bind Servive exist.");
|
LogUtils.d(TAG, "Bind Servive exist.");
|
||||||
unbindService(item);
|
unbindService(item);
|
||||||
mSOSConnectionList.remove(i);
|
mAPPModelConnectionList.remove(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 绑定服务
|
// 绑定服务
|
||||||
SOSConnection sosConnection = new SOSConnection();
|
APPConnection appConnection = new APPConnection();
|
||||||
Intent intentService = new Intent();
|
Intent intentService = new Intent();
|
||||||
intentService.setComponent(new ComponentName(bean.getNewsPackageName(), bean.getNewsClassName()));
|
intentService.setComponent(new ComponentName(bean.getAppPackageName(), bean.getAppMainServiveName()));
|
||||||
bindService(intentService, sosConnection, Context.BIND_IMPORTANT);
|
bindService(intentService, appConnection, Context.BIND_IMPORTANT);
|
||||||
mSOSConnectionList.add(sosConnection);
|
mAPPModelConnectionList.add(appConnection);
|
||||||
|
|
||||||
Intent intentWidget = new Intent(this, WinBollNewsWidget.class);
|
Intent intentWidget = new Intent(this, APPNewsWidget.class);
|
||||||
intentWidget.setAction(WinBollNewsWidget.ACTION_WAKEUP_SERVICE);
|
intentWidget.setAction(APPNewsWidget.ACTION_WAKEUP_SERVICE);
|
||||||
APPNewsBean appSOSBean = new APPNewsBean(bean.getNewsPackageName(), bean.getNewsClassName());
|
APPModel appSOSBean = new APPModel(bean.getAppPackageName(), bean.getAppMainServiveName());
|
||||||
intentWidget.putExtra("APPSOSBean", appSOSBean.toString());
|
intentWidget.putExtra("APPSOSBean", appSOSBean.toString());
|
||||||
sendBroadcast(intentWidget);
|
sendBroadcast(intentWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SOSConnection implements ServiceConnection {
|
public class APPConnection implements ServiceConnection {
|
||||||
|
|
||||||
ComponentName mComponentName;
|
ComponentName mComponentName;
|
||||||
|
|
||||||
boolean isBindToAPPSOSBean(APPNewsBean bean) {
|
boolean isBindToAPP(APPModel bean) {
|
||||||
return mComponentName != null
|
return mComponentName != null
|
||||||
&& mComponentName.getClassName().equals(bean.getNewsClassName())
|
&& mComponentName.getClassName().equals(bean.getAppMainServiveName())
|
||||||
&& mComponentName.getPackageName().equals(bean.getNewsPackageName());
|
&& mComponentName.getPackageName().equals(bean.getAppPackageName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -241,13 +231,13 @@ public class MainService extends Service {
|
|||||||
LogUtils.d(TAG, String.format("onServiceDisconnected : \ngetClassName %s\ngetPackageName %s", name.getClassName(), name.getPackageName()));
|
LogUtils.d(TAG, String.format("onServiceDisconnected : \ngetClassName %s\ngetPackageName %s", name.getClassName(), name.getPackageName()));
|
||||||
|
|
||||||
// 尝试无参数启动一下服务
|
// 尝试无参数启动一下服务
|
||||||
String sosPackage = mComponentName.getPackageName();
|
String appPackage = mComponentName.getPackageName();
|
||||||
LogUtils.d(TAG, String.format("sosPackage %s", sosPackage));
|
LogUtils.d(TAG, String.format("appPackage %s", appPackage));
|
||||||
String sosClassName = mComponentName.getClassName();
|
String appMainServiceClassName = mComponentName.getClassName();
|
||||||
LogUtils.d(TAG, String.format("sosClassName %s", sosClassName));
|
LogUtils.d(TAG, String.format("appMainServiceClassName %s", appMainServiceClassName));
|
||||||
|
|
||||||
Intent intentService = new Intent();
|
Intent intentService = new Intent();
|
||||||
intentService.setComponent(new ComponentName(sosPackage, sosClassName));
|
intentService.setComponent(new ComponentName(appPackage, appMainServiceClassName));
|
||||||
startService(intentService);
|
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,22 +1,25 @@
|
|||||||
package cc.winboll.studio.libappbase.services;
|
package cc.winboll.studio.appbase.services;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author ZhanGSKen@AliYun.Com
|
* @Author ZhanGSKen@AliYun.Com
|
||||||
* @Date 2025/02/15 20:48:36
|
* @Date 2025/03/07 12:39:24
|
||||||
* @Describe TestService
|
* @Describe 普通服务示例
|
||||||
*/
|
*/
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
import cc.winboll.studio.appbase.beans.TestDemoServiceBean;
|
||||||
import cc.winboll.studio.libappbase.LogUtils;
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
import cc.winboll.studio.libappbase.bean.TestServiceBean;
|
|
||||||
import cc.winboll.studio.libappbase.sos.WinBoll;
|
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;
|
volatile static TestThread _TestThread;
|
||||||
|
|
||||||
@ -36,8 +39,8 @@ public class TestService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class MyBinder extends Binder {
|
public class MyBinder extends Binder {
|
||||||
public TestService getService() {
|
public TestDemoService getService() {
|
||||||
return TestService.this;
|
return TestDemoService.this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,29 +56,35 @@ public class TestService extends Service {
|
|||||||
@Override
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
LogUtils.d(TAG, "onStartCommand(...)");
|
LogUtils.d(TAG, "onStartCommand(...)");
|
||||||
TestServiceBean bean = TestServiceBean.loadBean(this, TestServiceBean.class);
|
TestDemoServiceBean bean = TestDemoServiceBean.loadBean(this, TestDemoServiceBean.class);
|
||||||
if (bean == null) {
|
if (bean == null) {
|
||||||
bean = new TestServiceBean();
|
bean = new TestDemoServiceBean();
|
||||||
}
|
}
|
||||||
// if (intent.getAction() != null && intent.getAction().equals(WinBoll.ACTION_SERVICE_ENABLE)) {
|
|
||||||
// bean.setIsEnable(true);
|
if (intent.getAction() != null) {
|
||||||
// TestServiceBean.saveBean(this, bean);
|
if (intent.getAction().equals(ACTION_ENABLE)) {
|
||||||
// run();
|
bean.setIsEnable(true);
|
||||||
// } else if (intent.getAction() != null && intent.getAction().equals(WinBoll.ACTION_SERVICE_DISABLE)) {
|
LogUtils.d(TAG, "setIsEnable(true);");
|
||||||
// bean.setIsEnable(false);
|
TestDemoServiceBean.saveBean(this, bean);
|
||||||
// TestServiceBean.saveBean(this, bean);
|
} else if (intent.getAction().equals(ACTION_DISABLE)) {
|
||||||
// }
|
bean.setIsEnable(false);
|
||||||
LogUtils.d(TAG, String.format("TestServiceBean.saveBean setIsEnable %s", bean.isEnable()));
|
LogUtils.d(TAG, "setIsEnable(false);");
|
||||||
|
TestDemoServiceBean.saveBean(this, bean);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
run();
|
||||||
|
|
||||||
return (bean.isEnable()) ? START_STICKY : super.onStartCommand(intent, flags, startId);
|
return (bean.isEnable()) ? START_STICKY : super.onStartCommand(intent, flags, startId);
|
||||||
//return super.onStartCommand(intent, flags, startId);
|
//return super.onStartCommand(intent, flags, startId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void run() {
|
void run() {
|
||||||
LogUtils.d(TAG, "run()");
|
LogUtils.d(TAG, "run()");
|
||||||
TestServiceBean bean = TestServiceBean.loadBean(this, TestServiceBean.class);
|
TestDemoServiceBean bean = TestDemoServiceBean.loadBean(this, TestDemoServiceBean.class);
|
||||||
if (bean == null) {
|
if (bean == null) {
|
||||||
bean = new TestServiceBean();
|
bean = new TestDemoServiceBean();
|
||||||
TestServiceBean.saveBean(this, bean);
|
TestDemoServiceBean.saveBean(this, bean);
|
||||||
}
|
}
|
||||||
if (bean.isEnable()) {
|
if (bean.isEnable()) {
|
||||||
LogUtils.d(TAG, "run() bean.isEnable()");
|
LogUtils.d(TAG, "run() bean.isEnable()");
|
||||||
@ -129,7 +138,6 @@ public class TestService extends Service {
|
|||||||
isStarted = true;
|
isStarted = true;
|
||||||
super.run();
|
super.run();
|
||||||
LogUtils.d(TAG, "run() start");
|
LogUtils.d(TAG, "run() start");
|
||||||
WinBoll.bindToAPPBase(mContext, new APPNewsBean(mContext.getPackageName(), TestService.class.getName()));
|
|
||||||
|
|
||||||
while (!isExit()) {
|
while (!isExit()) {
|
||||||
LogUtils.d(TAG, "run()");
|
LogUtils.d(TAG, "run()");
|
@ -15,18 +15,19 @@ import cc.winboll.studio.appbase.R;
|
|||||||
import cc.winboll.studio.appbase.beans.WinBollNewsBean;
|
import cc.winboll.studio.appbase.beans.WinBollNewsBean;
|
||||||
import cc.winboll.studio.libappbase.AppUtils;
|
import cc.winboll.studio.libappbase.AppUtils;
|
||||||
import cc.winboll.studio.libappbase.LogUtils;
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
import cc.winboll.studio.libappbase.bean.APPNewsBean;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import cc.winboll.studio.libappbase.sos.APPModel;
|
||||||
|
import cc.winboll.studio.libappbase.sos.WinBoll;
|
||||||
|
|
||||||
public class WinBollNewsWidget extends AppWidgetProvider {
|
public class APPNewsWidget extends AppWidgetProvider {
|
||||||
|
|
||||||
public static final String TAG = "WinBollNewsWidget";
|
public static final String TAG = "APPNewsWidget";
|
||||||
|
|
||||||
public static final String ACTION_WAKEUP_SERVICE = "cc.winboll.studio.appbase.widgets.WinBollNewsWidget.ACTION_WAKEUP_SERVICE";
|
public static final String ACTION_WAKEUP_SERVICE = APPNewsWidget.class.getName() + ".ACTION_WAKEUP_SERVICE";
|
||||||
public static final String ACTION_RELOAD_REPORT = "cc.winboll.studio.appbase.widgets.WinBollNewsWidget.ACTION_RELOAD_REPORT";
|
public static final String ACTION_RELOAD_REPORT = APPNewsWidget.class.getName() + ".ACTION_RELOAD_REPORT";
|
||||||
|
|
||||||
|
|
||||||
volatile static ArrayList<WinBollNewsBean> _WinBollNewsBeanList;
|
volatile static ArrayList<WinBollNewsBean> _WinBollNewsBeanList;
|
||||||
@ -49,25 +50,25 @@ public class WinBollNewsWidget extends AppWidgetProvider {
|
|||||||
if (intent.getAction().equals(ACTION_RELOAD_REPORT)) {
|
if (intent.getAction().equals(ACTION_RELOAD_REPORT)) {
|
||||||
LogUtils.d(TAG, "ACTION_RELOAD_REPORT");
|
LogUtils.d(TAG, "ACTION_RELOAD_REPORT");
|
||||||
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
|
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
|
||||||
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, WinBollNewsWidget.class));
|
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, APPNewsWidget.class));
|
||||||
for (int appWidgetId : appWidgetIds) {
|
for (int appWidgetId : appWidgetIds) {
|
||||||
updateAppWidget(context, appWidgetManager, appWidgetId);
|
updateAppWidget(context, appWidgetManager, appWidgetId);
|
||||||
}
|
}
|
||||||
}else if (intent.getAction().equals(ACTION_WAKEUP_SERVICE)) {
|
}else if (intent.getAction().equals(ACTION_WAKEUP_SERVICE)) {
|
||||||
LogUtils.d(TAG, "ACTION_WAKEUP_SERVICE");
|
LogUtils.d(TAG, "ACTION_WAKEUP_SERVICE");
|
||||||
String szWinBollNewsBean = intent.getStringExtra("WinBollNewsBean");
|
String szAPPModel = intent.getStringExtra(WinBoll.EXTRA_APPMODEL);
|
||||||
LogUtils.d(TAG, String.format("szWinBollNewsBean %s", szWinBollNewsBean));
|
LogUtils.d(TAG, String.format("szAPPModel %s", szAPPModel));
|
||||||
if (szWinBollNewsBean != null && !szWinBollNewsBean.equals("")) {
|
if (szAPPModel != null && !szAPPModel.equals("")) {
|
||||||
try {
|
try {
|
||||||
APPNewsBean bean = APPNewsBean.parseStringToBean(szWinBollNewsBean, APPNewsBean.class);
|
APPModel bean = APPModel.parseStringToBean(szAPPModel, APPModel.class);
|
||||||
if (bean != null) {
|
if (bean != null) {
|
||||||
String szNewsPackageName = bean.getNewsPackageName();
|
String szAppPackageName = bean.getAppPackageName();
|
||||||
LogUtils.d(TAG, String.format("szNewsPackageName %s", szNewsPackageName));
|
LogUtils.d(TAG, String.format("szAppPackageName %s", szAppPackageName));
|
||||||
String szNewsClassName = bean.getNewsClassName();
|
String szAppMainServiveName = bean.getAppMainServiveName();
|
||||||
LogUtils.d(TAG, String.format("szNewsClassName %s", szNewsClassName));
|
LogUtils.d(TAG, String.format("szAppMainServiveName %s", szAppMainServiveName));
|
||||||
|
|
||||||
|
|
||||||
String appName = AppUtils.getAppNameByPackageName(context, szNewsPackageName);
|
String appName = AppUtils.getAppNameByPackageName(context, szAppPackageName);
|
||||||
LogUtils.d(TAG, String.format("appName %s", appName));
|
LogUtils.d(TAG, String.format("appName %s", appName));
|
||||||
WinBollNewsBean winBollNewsBean = new WinBollNewsBean(appName);
|
WinBollNewsBean winBollNewsBean = new WinBollNewsBean(appName);
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
|
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
|
||||||
@ -82,7 +83,7 @@ public class WinBollNewsWidget extends AppWidgetProvider {
|
|||||||
addWinBollNewsBean(context, winBollNewsBean);
|
addWinBollNewsBean(context, winBollNewsBean);
|
||||||
|
|
||||||
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
|
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
|
||||||
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, WinBollNewsWidget.class));
|
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, APPNewsWidget.class));
|
||||||
for (int appWidgetId : appWidgetIds) {
|
for (int appWidgetId : appWidgetIds) {
|
||||||
updateAppWidget(context, appWidgetManager, appWidgetId);
|
updateAppWidget(context, appWidgetManager, appWidgetId);
|
||||||
}
|
}
|
||||||
@ -123,12 +124,12 @@ public class WinBollNewsWidget extends AppWidgetProvider {
|
|||||||
|
|
||||||
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_news);
|
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_news);
|
||||||
//设置按钮点击事件
|
//设置按钮点击事件
|
||||||
Intent intentPre = new Intent(context, WinBollNewsWidgetClickListener.class);
|
Intent intentPre = new Intent(context, APPNewsWidgetClickListener.class);
|
||||||
intentPre.setAction(WinBollNewsWidgetClickListener.ACTION_PRE);
|
intentPre.setAction(APPNewsWidgetClickListener.ACTION_PRE);
|
||||||
PendingIntent pendingIntentPre = PendingIntent.getBroadcast(context, 0, intentPre, PendingIntent.FLAG_UPDATE_CURRENT);
|
PendingIntent pendingIntentPre = PendingIntent.getBroadcast(context, 0, intentPre, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
views.setOnClickPendingIntent(R.id.widget_button_pre, pendingIntentPre);
|
views.setOnClickPendingIntent(R.id.widget_button_pre, pendingIntentPre);
|
||||||
Intent intentNext = new Intent(context, WinBollNewsWidgetClickListener.class);
|
Intent intentNext = new Intent(context, APPNewsWidgetClickListener.class);
|
||||||
intentNext.setAction(WinBollNewsWidgetClickListener.ACTION_NEXT);
|
intentNext.setAction(APPNewsWidgetClickListener.ACTION_NEXT);
|
||||||
PendingIntent pendingIntentNext = PendingIntent.getBroadcast(context, 0, intentNext, PendingIntent.FLAG_UPDATE_CURRENT);
|
PendingIntent pendingIntentNext = PendingIntent.getBroadcast(context, 0, intentNext, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
views.setOnClickPendingIntent(R.id.widget_button_next, pendingIntentNext);
|
views.setOnClickPendingIntent(R.id.widget_button_next, pendingIntentNext);
|
||||||
|
|
||||||
@ -156,8 +157,8 @@ public class WinBollNewsWidget extends AppWidgetProvider {
|
|||||||
if (_CurrentPageIndex > 0) {
|
if (_CurrentPageIndex > 0) {
|
||||||
_CurrentPageIndex = _CurrentPageIndex - 1;
|
_CurrentPageIndex = _CurrentPageIndex - 1;
|
||||||
}
|
}
|
||||||
Intent intentWidget = new Intent(context, WinBollNewsWidget.class);
|
Intent intentWidget = new Intent(context, APPNewsWidget.class);
|
||||||
intentWidget.setAction(WinBollNewsWidget.ACTION_RELOAD_REPORT);
|
intentWidget.setAction(APPNewsWidget.ACTION_RELOAD_REPORT);
|
||||||
context.sendBroadcast(intentWidget);
|
context.sendBroadcast(intentWidget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -167,8 +168,8 @@ public class WinBollNewsWidget extends AppWidgetProvider {
|
|||||||
if ((_CurrentPageIndex + 1) * _OnePageLinesCount < _WinBollNewsBeanList.size()) {
|
if ((_CurrentPageIndex + 1) * _OnePageLinesCount < _WinBollNewsBeanList.size()) {
|
||||||
_CurrentPageIndex = _CurrentPageIndex + 1;
|
_CurrentPageIndex = _CurrentPageIndex + 1;
|
||||||
}
|
}
|
||||||
Intent intentWidget = new Intent(context, WinBollNewsWidget.class);
|
Intent intentWidget = new Intent(context, APPNewsWidget.class);
|
||||||
intentWidget.setAction(WinBollNewsWidget.ACTION_RELOAD_REPORT);
|
intentWidget.setAction(APPNewsWidget.ACTION_RELOAD_REPORT);
|
||||||
context.sendBroadcast(intentWidget);
|
context.sendBroadcast(intentWidget);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,11 +10,11 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import cc.winboll.studio.libappbase.LogUtils;
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
|
|
||||||
public class WinBollNewsWidgetClickListener extends BroadcastReceiver {
|
public class APPNewsWidgetClickListener extends BroadcastReceiver {
|
||||||
|
|
||||||
public static final String TAG = "WinBollNewsWidgetClickListener";
|
public static final String TAG = "APPNewsWidgetClickListener";
|
||||||
public static final String ACTION_PRE = "cc.winboll.studio.appbase.widgets.WinBollNewsWidgetClickListener.ACTION_PRE";
|
public static final String ACTION_PRE = APPNewsWidgetClickListener.class.getName() + ".ACTION_PRE";
|
||||||
public static final String ACTION_NEXT = "cc.winboll.studio.appbase.widgets.WinBollNewsWidgetClickListener.ACTION_NEXT";
|
public static final String ACTION_NEXT = APPNewsWidgetClickListener.class.getName() + ".ACTION_NEXT";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
@ -25,10 +25,10 @@ public class WinBollNewsWidgetClickListener extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
if (action.equals(ACTION_PRE)) {
|
if (action.equals(ACTION_PRE)) {
|
||||||
LogUtils.d(TAG, "ACTION_PRE");
|
LogUtils.d(TAG, "ACTION_PRE");
|
||||||
WinBollNewsWidget.prePage(context);
|
APPNewsWidget.prePage(context);
|
||||||
} else if (action.equals(ACTION_NEXT)) {
|
} else if (action.equals(ACTION_NEXT)) {
|
||||||
LogUtils.d(TAG, "ACTION_NEXT");
|
LogUtils.d(TAG, "ACTION_NEXT");
|
||||||
WinBollNewsWidget.nextPage(context);
|
APPNewsWidget.nextPage(context);
|
||||||
} else {
|
} else {
|
||||||
LogUtils.d(TAG, String.format("action %s", action));
|
LogUtils.d(TAG, String.format("action %s", action));
|
||||||
}
|
}
|
@ -1,17 +1,27 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
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:orientation="vertical"
|
||||||
android:gravity="center">
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<androidx.appcompat.widget.Toolbar
|
<androidx.appcompat.widget.Toolbar
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/activitymainToolbar1"/>
|
android:id="@+id/activitymainToolbar1"/>
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1.0">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:gravity="center">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -27,9 +37,7 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Android版本10的代号是“Q”,API级别是29。 Android 10开始谷歌不再公开使用甜品作为版本代号,但内部仍保留了大量与“Q”相关的元素。Android 10本身并没有严格对应某个特定的Java版本,但在开发Android 10应用时,通常可以使用Java 8或更高版本。
|
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,但可能需要注意兼容性和配置问题。"/>
|
||||||
|
|
||||||
Java 8为Android开发带来了诸如Lambda表达式、方法引用等新特性,能提高开发效率和代码可读性,与Android 10开发适配良好。Java 9及更高版本也可用于Android 10开发,能使用一些新的语言特性和API,但可能需要注意兼容性和配置问题。"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
@ -76,23 +84,57 @@ Java 8为Android开发带来了诸如Lambda表达式、方法引用等新特性
|
|||||||
<Button
|
<Button
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="StartTestService"
|
android:text="SartTestDemoService"
|
||||||
android:textAllCaps="false"
|
android:textAllCaps="false"
|
||||||
android:onClick="onStartTestService"/>
|
android:onClick="onSartTestDemoService"/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="StopTestService"
|
android:text="StopTestDemoService"
|
||||||
android:textAllCaps="false"
|
android:textAllCaps="false"
|
||||||
android:onClick="onStopTestService"/>
|
android:onClick="onStopTestDemoService"/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="StopTestServiceNoSettings"
|
android:text="StopTestDemoServiceNoSettings"
|
||||||
android:textAllCaps="false"
|
android:textAllCaps="false"
|
||||||
android:onClick="onStopTestServiceNoSettings"/>
|
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>
|
</LinearLayout>
|
||||||
|
|
||||||
@ -115,35 +157,38 @@ Java 8为Android开发带来了诸如Lambda表达式、方法引用等新特性
|
|||||||
<Button
|
<Button
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="TestStopWithoutSettingEnable"
|
android:text="TestStopMainServiceWithoutSettingEnable"
|
||||||
android:textAllCaps="false"
|
android:textAllCaps="false"
|
||||||
android:onClick="onTestStopWithoutSettingEnable"/>
|
android:onClick="onTestStopMainServiceWithoutSettingEnable"/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="TestStartWithString"
|
android:text="TestUseComponentStartService"
|
||||||
android:textAllCaps="false"
|
android:textAllCaps="false"
|
||||||
android:onClick="onTestStartWithString"/>
|
android:onClick="onTestUseComponentStartService"/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="SOS"
|
android:text="TestSOS"
|
||||||
android:textAllCaps="false"
|
android:textAllCaps="false"
|
||||||
android:onClick="onSOS"/>
|
android:onClick="onTestSOS"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
<cc.winboll.studio.libappbase.LogView
|
<cc.winboll.studio.libappbase.LogView
|
||||||
android:layout_weight="1.0"
|
android:layout_height="500dp"
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:id="@+id/activitymainLogView1"/>
|
android:id="@+id/activitymainLogView1"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
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.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
|
// Nexus Maven 库地址
|
||||||
|
// "WinBoll Release"
|
||||||
|
maven { url "https://nexus.winboll.cc/repository/maven-public/" }
|
||||||
|
// "WinBoll Snapshot"
|
||||||
|
maven { url "https://nexus.winboll.cc/repository/maven-snapshots/" }
|
||||||
|
|
||||||
maven { url 'https://maven.aliyun.com/repository/public/' }
|
maven { url 'https://maven.aliyun.com/repository/public/' }
|
||||||
maven { url 'https://maven.aliyun.com/repository/google/' }
|
maven { url 'https://maven.aliyun.com/repository/google/' }
|
||||||
maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' }
|
maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' }
|
||||||
@ -10,12 +16,6 @@ buildscript {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
google()
|
google()
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
// Nexus Maven 库地址
|
|
||||||
// "WinBoll Release"
|
|
||||||
maven { url "https://nexus.winboll.cc/repository/maven-public/" }
|
|
||||||
// "WinBoll Snapshot"
|
|
||||||
maven { url "https://nexus.winboll.cc/repository/maven-snapshots/" }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:7.2.1'
|
classpath 'com.android.tools.build:gradle:7.2.1'
|
||||||
@ -26,6 +26,12 @@ buildscript {
|
|||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
|
// Nexus Maven 库地址
|
||||||
|
// "WinBoll Release"
|
||||||
|
maven { url "https://nexus.winboll.cc/repository/maven-public/" }
|
||||||
|
// "WinBoll Snapshot"
|
||||||
|
maven { url "https://nexus.winboll.cc/repository/maven-snapshots/" }
|
||||||
|
|
||||||
maven {
|
maven {
|
||||||
url "https://mirrors.tencent.com/repository/maven/tencent_public/"
|
url "https://mirrors.tencent.com/repository/maven/tencent_public/"
|
||||||
}
|
}
|
||||||
@ -42,12 +48,6 @@ allprojects {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
google()
|
google()
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
// Nexus Maven 库地址
|
|
||||||
// "WinBoll Release"
|
|
||||||
maven { url "https://nexus.winboll.cc/repository/maven-public/" }
|
|
||||||
// "WinBoll Snapshot"
|
|
||||||
maven { url "https://nexus.winboll.cc/repository/maven-snapshots/" }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
ext {
|
ext {
|
||||||
// 定义全局变量,常用于版本管理
|
// 定义全局变量,常用于版本管理
|
||||||
|
@ -22,6 +22,10 @@ android {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation 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.google.zxing:core:3.4.1'
|
||||||
implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
|
implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Thu Feb 27 02:21:32 GMT 2025
|
#Sat Mar 08 02:31:02 HKT 2025
|
||||||
stageCount=3
|
stageCount=2
|
||||||
libraryProject=libappbase
|
libraryProject=libappbase
|
||||||
baseVersion=2.0
|
baseVersion=2.1
|
||||||
publishVersion=2.0.2
|
publishVersion=2.1.1
|
||||||
buildCount=4
|
buildCount=0
|
||||||
baseBetaVersion=2.0.3
|
baseBetaVersion=2.1.2
|
||||||
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -34,13 +34,13 @@ public class SOS {
|
|||||||
static void sos(Context context, String szToPackage, String sosService) {
|
static void sos(Context context, String szToPackage, String sosService) {
|
||||||
LogUtils.d(TAG, "sos(...)");
|
LogUtils.d(TAG, "sos(...)");
|
||||||
Intent intent = new Intent(ACTION_SOS);
|
Intent intent = new Intent(ACTION_SOS);
|
||||||
intent.putExtra(EXTRA_OBJECT, genSOSObjectString(context.getPackageName(), sosService));
|
intent.putExtra(EXTRA_OBJECT, genSOSObject(context.getPackageName(), sosService));
|
||||||
intent.setPackage(szToPackage);
|
intent.setPackage(szToPackage);
|
||||||
LogUtils.d(TAG, String.format("ACTION_SOS :\nTo Package : %sSOS Service : %s\n", szToPackage, sosService));
|
LogUtils.d(TAG, String.format("ACTION_SOS :\nTo Package : %sSOS Service : %s\n", szToPackage, sosService));
|
||||||
context.sendBroadcast(intent);
|
context.sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SOSObject stringToSOSObject(String szSOSObject) {
|
public static SOSObject parseSOSObject(String szSOSObject) {
|
||||||
try {
|
try {
|
||||||
return SOSObject.parseStringToBean(szSOSObject, SOSObject.class);
|
return SOSObject.parseStringToBean(szSOSObject, SOSObject.class);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -49,11 +49,11 @@ public class SOS {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static String sosObjectToString(SOSObject object) {
|
public static String sosObjectToString(SOSObject object) {
|
||||||
return object.toString();
|
return object.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
static String genSOSObjectString(String objectPackageName, String objectServiveName) {
|
public static String genSOSObject(String objectPackageName, String objectServiveName) {
|
||||||
return (new SOSObject(objectPackageName, objectServiveName)).toString();
|
return (new SOSObject(objectPackageName, objectServiveName)).toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
package cc.winboll.studio.libappbase.sos;
|
package cc.winboll.studio.libappbase.sos;
|
||||||
|
|
||||||
import android.app.Service;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.IBinder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author ZhanGSKen@AliYun.Com
|
* @Author ZhanGSKen@AliYun.Com
|
||||||
* @Date 2025/02/27 14:00:21
|
* @Date 2025/02/27 14:00:21
|
||||||
@ -17,8 +13,11 @@ import android.os.IBinder;
|
|||||||
import android.os.IInterface;
|
import android.os.IInterface;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import cc.winboll.studio.libappbase.bean.SimpleOperateSignalCenterServiceBean;
|
|
||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
|
import android.app.Service;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.IBinder;
|
||||||
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
|
|
||||||
public class SOSCenterService extends Service {
|
public class SOSCenterService extends Service {
|
||||||
|
|
||||||
@ -26,7 +25,7 @@ public class SOSCenterService extends Service {
|
|||||||
|
|
||||||
private final IBinder binder =(IBinder)new SOSBinder();
|
private final IBinder binder =(IBinder)new SOSBinder();
|
||||||
|
|
||||||
SimpleOperateSignalCenterServiceBean mSimpleOperateSignalCenterServiceBean;
|
SOSCenterServiceModel mSOSCenterServiceModel;
|
||||||
static MainThread _MainThread;
|
static MainThread _MainThread;
|
||||||
public static synchronized MainThread getMainThreadInstance() {
|
public static synchronized MainThread getMainThreadInstance() {
|
||||||
if (_MainThread == null) {
|
if (_MainThread == null) {
|
||||||
@ -85,8 +84,8 @@ public class SOSCenterService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final String TAG = "SOSBinder";
|
public static final String TAG = "SOSBinder";
|
||||||
SimpleOperateSignalCenterService getService() {
|
SOSCenterService getService() {
|
||||||
return SimpleOperateSignalCenterService.this;
|
return SOSCenterService.this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,10 +93,10 @@ public class SOSCenterService extends Service {
|
|||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
LogUtils.d(TAG, "onCreate");
|
LogUtils.d(TAG, "onCreate");
|
||||||
mSimpleOperateSignalCenterServiceBean = SimpleOperateSignalCenterServiceBean.loadBean(this, SimpleOperateSignalCenterServiceBean.class);
|
mSOSCenterServiceModel = SOSCenterServiceModel.loadBean(this, SOSCenterServiceModel.class);
|
||||||
if(mSimpleOperateSignalCenterServiceBean == null) {
|
if(mSOSCenterServiceModel == null) {
|
||||||
mSimpleOperateSignalCenterServiceBean = new SimpleOperateSignalCenterServiceBean();
|
mSOSCenterServiceModel = new SOSCenterServiceModel();
|
||||||
SimpleOperateSignalCenterServiceBean.saveBean(this, mSimpleOperateSignalCenterServiceBean);
|
SOSCenterServiceModel.saveBean(this, mSOSCenterServiceModel);
|
||||||
}
|
}
|
||||||
runMainThread();
|
runMainThread();
|
||||||
}
|
}
|
||||||
@ -108,12 +107,12 @@ public class SOSCenterService extends Service {
|
|||||||
|
|
||||||
runMainThread();
|
runMainThread();
|
||||||
|
|
||||||
return mSimpleOperateSignalCenterServiceBean.isEnable() ? Service.START_STICKY: super.onStartCommand(intent, flags, startId);
|
return mSOSCenterServiceModel.isEnable() ? Service.START_STICKY: super.onStartCommand(intent, flags, startId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void runMainThread() {
|
void runMainThread() {
|
||||||
mSimpleOperateSignalCenterServiceBean = SimpleOperateSignalCenterServiceBean.loadBean(this, SimpleOperateSignalCenterServiceBean.class);
|
mSOSCenterServiceModel = mSOSCenterServiceModel.loadBean(this, SOSCenterServiceModel.class);
|
||||||
if (mSimpleOperateSignalCenterServiceBean.isEnable()
|
if (mSOSCenterServiceModel.isEnable()
|
||||||
&& _MainThread == null) {
|
&& _MainThread == null) {
|
||||||
getMainThreadInstance().start();
|
getMainThreadInstance().start();
|
||||||
}
|
}
|
||||||
@ -123,9 +122,9 @@ public class SOSCenterService extends Service {
|
|||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
LogUtils.d(TAG, "onDestroy");
|
LogUtils.d(TAG, "onDestroy");
|
||||||
mSimpleOperateSignalCenterServiceBean = SimpleOperateSignalCenterServiceBean.loadBean(this, SimpleOperateSignalCenterServiceBean.class);
|
mSOSCenterServiceModel = SOSCenterServiceModel.loadBean(this, SOSCenterServiceModel.class);
|
||||||
if (mSimpleOperateSignalCenterServiceBean.isEnable()) {
|
if (mSOSCenterServiceModel.isEnable()) {
|
||||||
LogUtils.d(TAG, "mSimpleOperateSignalCenterServiceBean.isEnable()");
|
LogUtils.d(TAG, "mSOSCenterServiceModel.isEnable()");
|
||||||
// ISOSAPP iSOSAPP = (ISOSAPP)getApplication();
|
// ISOSAPP iSOSAPP = (ISOSAPP)getApplication();
|
||||||
// iSOSAPP.helpISOSService(getISOSServiceIntentWhichAskForHelp());
|
// iSOSAPP.helpISOSService(getISOSServiceIntentWhichAskForHelp());
|
||||||
}
|
}
|
||||||
@ -137,22 +136,22 @@ public class SOSCenterService extends Service {
|
|||||||
|
|
||||||
public static void stopISOSService(Context context) {
|
public static void stopISOSService(Context context) {
|
||||||
LogUtils.d(TAG, "stopISOSService");
|
LogUtils.d(TAG, "stopISOSService");
|
||||||
SimpleOperateSignalCenterServiceBean bean = new SimpleOperateSignalCenterServiceBean();
|
SOSCenterServiceModel bean = new SOSCenterServiceModel();
|
||||||
bean.setIsEnable(false);
|
bean.setIsEnable(false);
|
||||||
SimpleOperateSignalCenterServiceBean.saveBean(context, bean);
|
SOSCenterServiceModel.saveBean(context, bean);
|
||||||
context.stopService(new Intent(context, SimpleOperateSignalCenterService.class));
|
context.stopService(new Intent(context, SOSCenterServiceModel.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void startISOSService(Context context) {
|
public static void startISOSService(Context context) {
|
||||||
LogUtils.d(TAG, "startISOSService");
|
LogUtils.d(TAG, "startISOSService");
|
||||||
SimpleOperateSignalCenterServiceBean bean = new SimpleOperateSignalCenterServiceBean();
|
SOSCenterServiceModel bean = new SOSCenterServiceModel();
|
||||||
bean.setIsEnable(true);
|
bean.setIsEnable(true);
|
||||||
SimpleOperateSignalCenterServiceBean.saveBean(context, bean);
|
SOSCenterServiceModel.saveBean(context, bean);
|
||||||
context.startService(new Intent(context, SimpleOperateSignalCenterService.class));
|
context.startService(new Intent(context, SOSCenterServiceModel.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return "Hello from SimpleOperateSignalCenterService";
|
return "Hello from SOSCenterServiceModel";
|
||||||
}
|
}
|
||||||
|
|
||||||
static class MainThread extends Thread {
|
static class MainThread extends Thread {
|
||||||
|
@ -1,24 +1,25 @@
|
|||||||
package cc.winboll.studio.libappbase.sos;
|
package cc.winboll.studio.libappbase.sos;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author ZhanGSKen@AliYun.Com
|
* @Author ZhanGSKen@AliYun.Com
|
||||||
* @Date 2025/02/27 14:04:35
|
* @Date 2025/02/27 14:04:35
|
||||||
* @Describe SOSCenterServiceReceiver
|
* @Describe SOSCenterServiceReceiver
|
||||||
*/
|
*/
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
|
|
||||||
public class SOSCenterServiceReceiver extends BroadcastReceiver {
|
public class SOSCenterServiceReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
public static final String TAG = "SOSCenterServiceReceiver";
|
public static final String TAG = "SOSCenterServiceReceiver";
|
||||||
|
|
||||||
public static final String ACTION_SOS = SOSCenterServiceReceiver.class.getName() + ".ACTION_SOS";
|
public static final String ACTION_SOS = SOSCenterServiceReceiver.class.getName() + ".ACTION_SOS";
|
||||||
public static final String
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
if (action.equals(ACTION_SOS)) {
|
if (action.equals(ACTION_SOS)) {
|
||||||
|
|
||||||
// 处理接收到的广播消息
|
// 处理接收到的广播消息
|
||||||
LogUtils.d(TAG, String.format("Action %s \n%s\n%s", action));
|
LogUtils.d(TAG, String.format("Action %s \n%s\n%s", action));
|
||||||
} else {
|
} else {
|
||||||
|
@ -14,14 +14,16 @@ public class WinBoll {
|
|||||||
public static final String TAG = "WinBoll";
|
public static final String TAG = "WinBoll";
|
||||||
|
|
||||||
public static final String ACTION_BIND = WinBoll.class.getName() + ".ACTION_BIND";
|
public static final String ACTION_BIND = WinBoll.class.getName() + ".ACTION_BIND";
|
||||||
public static final String EXTRA_APPMODEL = "EXTRA_APP";
|
public static final String EXTRA_APPMODEL = "EXTRA_APPMODEL";
|
||||||
|
|
||||||
public static void bindToAPPBase(Context context, String appMainService) {
|
public static void bindToAPPBase(Context context, String appMainService) {
|
||||||
|
LogUtils.d(TAG, "bindToAPPBase(...)");
|
||||||
String toPackage = "cc.winboll.studio.appbase";
|
String toPackage = "cc.winboll.studio.appbase";
|
||||||
startBind(context, toPackage, appMainService);
|
startBind(context, toPackage, appMainService);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void bindToAPPBaseBeta(Context context, String appMainService) {
|
public static void bindToAPPBaseBeta(Context context, String appMainService) {
|
||||||
|
LogUtils.d(TAG, "bindToAPPBaseBeta(...)");
|
||||||
String toPackage = "cc.winboll.studio.appbase.beta";
|
String toPackage = "cc.winboll.studio.appbase.beta";
|
||||||
startBind(context, toPackage, appMainService);
|
startBind(context, toPackage, appMainService);
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ import cc.winboll.studio.libappbase.utils.ServiceUtils;
|
|||||||
import com.hjq.toast.ToastUtils;
|
import com.hjq.toast.ToastUtils;
|
||||||
import android.content.ServiceConnection;
|
import android.content.ServiceConnection;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import cc.winboll.studio.libappbase.services.TestService;
|
|
||||||
|
|
||||||
public class StatusWidget extends AppWidgetProvider {
|
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);
|
PendingIntent pendingIntentAppButton = PendingIntent.getBroadcast(context, 0, intentAppButton, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
views.setOnClickPendingIntent(R.id.ivapp, pendingIntentAppButton);
|
views.setOnClickPendingIntent(R.id.ivapp, pendingIntentAppButton);
|
||||||
|
|
||||||
boolean isActive = ServiceUtils.isServiceRunning(context, TestService.class.getName());
|
// boolean isActive = ServiceUtils.isServiceRunning(context, TestService.class.getName());
|
||||||
if (isActive) {
|
// if (isActive) {
|
||||||
views.setImageViewResource(R.id.ivapp, cc.winboll.studio.libappbase.R.drawable.ic_launcher);
|
// views.setImageViewResource(R.id.ivapp, cc.winboll.studio.libappbase.R.drawable.ic_launcher);
|
||||||
} else {
|
// } else {
|
||||||
views.setImageViewResource(R.id.ivapp, cc.winboll.studio.libappbase.R.drawable.ic_launcher_disable);
|
// views.setImageViewResource(R.id.ivapp, cc.winboll.studio.libappbase.R.drawable.ic_launcher_disable);
|
||||||
}
|
// }
|
||||||
appWidgetManager.updateAppWidget(appWidgetId, views);
|
appWidgetManager.updateAppWidget(appWidgetId, views);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user