Merge remote-tracking branch 'origin/appbase' into contacts

This commit is contained in:
ZhanGSKen 2025-05-04 19:49:28 +08:00
commit ddb6b53189
42 changed files with 628 additions and 698 deletions

View File

@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Tue Apr 29 15:14:41 HKT 2025
#Sat May 03 11:34:58 GMT 2025
stageCount=1
libraryProject=libaes
baseVersion=15.6
publishVersion=15.6.0
buildCount=0
buildCount=9
baseBetaVersion=15.6.1

View File

@ -10,13 +10,14 @@ import android.content.Context;
import android.os.Bundle;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import cc.winboll.studio.libaes.winboll.APPInfo;
import cc.winboll.studio.libaes.winboll.AboutView;
import cc.winboll.studio.libappbase.GlobalApplication;
import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity;
public class AboutActivity extends WinBoLLActivity implements IWinBoLLActivity {
public class AboutActivity extends AppCompatActivity implements IWinBoLLActivity {
public static final String TAG = "AboutActivity";

View File

@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Tue Apr 29 14:47:34 HKT 2025
#Sat May 03 10:32:21 GMT 2025
stageCount=7
libraryProject=libappbase
baseVersion=15.7
publishVersion=15.7.6
buildCount=0
buildCount=4
baseBetaVersion=15.7.7

View File

@ -1,81 +0,0 @@
package cc.winboll.studio.appbase;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/03/28 15:34:16
* @Describe 应用活动窗口基类
*/
import android.app.Activity;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.view.MenuItem;
import cc.winboll.studio.appbase.App;
import cc.winboll.studio.appbase.R;
import cc.winboll.studio.libappbase.GlobalApplication;
import cc.winboll.studio.libappbase.dialogs.YesNoAlertDialog;
import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity;
import cc.winboll.studio.libappbase.winboll.WinBoLLActivityManager;
public class WinBoLLActivityBase extends Activity implements IWinBoLLActivity {
public static final String TAG = "WinBoLLActivityBase";
@Override
public Activity getActivity() {
return this;
}
@Override
public String getTag() {
return TAG;
}
WinBoLLActivityManager getWinBoLLActivityManager() {
return WinBoLLActivityManager.getInstance(GlobalApplication.getInstance());
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWinBoLLActivityManager().add(this);
}
@Override
public void onPostCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onPostCreate(savedInstanceState, persistentState);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == cc.winboll.studio.appbase.R.id.item_log) {
GlobalApplication.getWinBoLLActivityManager().startLogActivity(this);
return true;
} else if(item.getItemId() == cc.winboll.studio.appbase.R.id.item_minimal) {
//moveTaskToBack(true);
exit();
}
// 在switch语句中处理每个ID并在处理完后返回true未处理的情况返回false
return super.onOptionsItemSelected(item);
}
void exit() {
YesNoAlertDialog.show(this, "Exit " + getString(R.string.app_name), "Close all activity and exit?", new YesNoAlertDialog.OnDialogResultListener(){
@Override
public void onYes() {
App.getWinBoLLActivityManager().finishAll();
}
@Override
public void onNo() {
}
});
}
@Override
protected void onDestroy() {
super.onDestroy();
getWinBoLLActivityManager().registeRemove(this);
}
}

View File

@ -1,36 +0,0 @@
package cc.winboll.studio.apputils;
/**
* @Author ZhanGSKen@QQ.COM
* @Date 2025/01/17 19:50:46
*/
import android.app.Activity;
import android.os.Bundle;
import android.widget.Toolbar;
import cc.winboll.studio.apputils.R;
import cc.winboll.studio.libapputils.views.StringToQrCodeView;
public class TestStringToQRCodeViewActivity extends Activity {
public static final String TAG = "TestStringToQrCodeViewActivity";
StringToQrCodeView mStringToQrCodeView;
//
// @Override
// public Activity getActivity() {
// return this;
// }
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_teststringtoqrcodeview);
// 初始化工具栏
Toolbar mToolbar = findViewById(R.id.toolbar);
mToolbar.setSubtitle(TAG);
setActionBar(mToolbar);
mStringToQrCodeView = findViewById(R.id.activityteststringtoqrcodeviewStringToQrCodeView1);
}
}

View File

@ -19,7 +19,7 @@ def genVersionName(def versionName){
android {
compileSdkVersion 32
buildToolsVersion "33.0.3"
buildToolsVersion "32.0.0"
defaultConfig {
applicationId "cc.winboll.studio.autoinstaller"
@ -29,7 +29,7 @@ android {
// versionName
// .winboll/winbollBuildProps.properties stageCount=0
// Gradle编译环境下合起来的 versionName "${versionName}.0"
versionName "5.0"
versionName "15.2"
if(true) {
versionName = genVersionName("${versionName}")
}
@ -41,30 +41,33 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
}
dependencies {
api 'cc.winboll.studio:winboll-shared:1.1.0'
api 'io.github.medyo:android-about-page:2.0.0'
api 'com.github.getActivity:ToastUtils:10.5'
api 'com.jcraft:jsch:0.1.55'
api 'org.jsoup:jsoup:1.13.1'
api 'com.squareup.okhttp3:okhttp:4.4.1'
api 'androidx.appcompat:appcompat:1.0.0'
api 'androidx.fragment:fragment:1.0.0'
api 'com.google.android.material:material:1.0.0'
api 'androidx.vectordrawable:vectordrawable-animated:1.0.0'
api 'androidx.lifecycle:lifecycle-livedata:1.0.0'
//api 'cc.winboll.studio:libaes:6.3.2'
//api 'cc.winboll.studio:libapputils:8.3.8'
api fileTree(dir: 'libs', include: ['*.jar'])
api 'cc.winboll.studio:libaes:15.6.0'
api 'cc.winboll.studio:libapputils:15.3.4'
api 'cc.winboll.studio:libappbase:15.7.6'
// SSH
api 'com.jcraft:jsch:0.1.55'
// Html
api 'org.jsoup:jsoup:1.13.1'
//
api 'com.google.zxing:core:3.4.1'
api 'com.journeyapps:zxing-android-embedded:3.6.0'
//
api 'io.github.medyo:android-about-page:2.0.0'
//
api 'com.github.getActivity:ToastUtils:10.5'
//
api 'com.squareup.okhttp3:okhttp:4.4.1'
// AndroidX
api 'androidx.appcompat:appcompat:1.1.0'
api 'com.google.android.material:material:1.4.0'
//api 'androidx.viewpager:viewpager:1.0.0'
//api 'androidx.vectordrawable:vectordrawable:1.1.0'
//api 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
//api 'androidx.fragment:fragment:1.1.0'
}

View File

@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Thu Jan 02 02:39:56 HKT 2025
stageCount=4
#Sun May 04 05:32:00 GMT 2025
stageCount=1
libraryProject=
baseVersion=5.0
publishVersion=5.0.3
buildCount=0
baseBetaVersion=5.0.4
baseVersion=15.2
publishVersion=15.2.0
buildCount=74
baseBetaVersion=15.2.1

View File

@ -24,6 +24,8 @@
<!-- MANAGE_EXTERNAL_STORAGE -->
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<application
android:name=".App"
android:allowBackup="true"
@ -33,7 +35,7 @@
android:persistent="true"
android:supportsRtl="true"
android:requestLegacyExternalStorage="true"
android:theme="@style/Theme.Application">
android:theme="@style/MyAppTheme">
<activity
android:name=".MainActivity"
@ -54,6 +56,21 @@
<service android:name=".services.AssistantService"/>
<service
android:name=".AppBaseTileService"
android:exported="true"
android:label="@string/tileservice_name"
android:icon="@drawable/ic_launcher"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE"/>
</intent-filter>
</service>
<receiver
android:name=".receivers.MainReceiver"
android:enabled="true"

View File

@ -6,22 +6,23 @@ package cc.winboll.studio.autoinstaller;
* @Describe 全局应用类
*/
import android.view.Gravity;
import cc.winboll.studio.libappbase.GlobalApplication;
import com.hjq.toast.ToastUtils;
import cc.winboll.studio.shared.app.WinBollApplication;
import com.hjq.toast.style.WhiteToastStyle;
public class App extends WinBollApplication {
public class App extends GlobalApplication {
public static final String TAG = "App";
@Override
public void onCreate() {
super.onCreate();
setIsDebug(BuildConfig.DEBUG);
// 初始化 Toast 框架
ToastUtils.init(this);
// 设置 Toast 布局样式
ToastUtils.setView(R.layout.toast_custom_view);
//ToastUtils.setStyle(new WhiteToastStyle());
//ToastUtils.setView(R.layout.view_toast);
ToastUtils.setStyle(new WhiteToastStyle());
ToastUtils.setGravity(Gravity.BOTTOM, 0, 200);
}
}

View File

@ -0,0 +1,12 @@
package cc.winboll.studio.autoinstaller;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/04/15 09:24:46
* @Describe 磁贴工具服务类
*/
import android.service.quicksettings.Tile;
import android.service.quicksettings.TileService;
import cc.winboll.studio.autoinstaller.models.AppConfigs;

View File

@ -1,7 +1,7 @@
package cc.winboll.studio.autoinstaller;
import android.os.FileObserver;
import cc.winboll.studio.shared.log.LogUtils;
import cc.winboll.studio.libappbase.LogUtils;
public class FileListener extends FileObserver {
public final static String TAG = "FileListener";

View File

@ -6,21 +6,24 @@ import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.SimpleAdapter;
import android.widget.Switch;
import android.widget.TextClock;
import android.widget.Toast;
import androidx.core.content.FileProvider;
import cc.winboll.studio.shared.log.LogUtils;
import cc.winboll.studio.shared.log.LogView;
import cc.winboll.studio.autoinstaller.MainActivity;
import cc.winboll.studio.autoinstaller.beans.AppConfigs;
import cc.winboll.studio.autoinstaller.models.APKModel;
import cc.winboll.studio.autoinstaller.models.AppConfigs;
import cc.winboll.studio.autoinstaller.services.MainService;
import cc.winboll.studio.autoinstaller.utils.NotificationUtil;
import cc.winboll.studio.autoinstaller.utils.PackageUtil;
import cc.winboll.studio.autoinstaller.views.ListViewForScrollView;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.LogView;
import com.hjq.toast.ToastUtils;
import java.io.File;
import java.util.ArrayList;
@ -30,8 +33,13 @@ import java.util.Map;
public class MainActivity extends Activity {
public static final String TAG = "MainActivity";
public static final int MSG_UPDATE_STATUS = 0;
private static final int INSTALL_PERMISSION_CODE = 1;
static MainActivity _MainActivity;
ArrayList<APKModel> _APKModelList = new ArrayList<APKModel>();
LogView mLogView;
TextClock mTextClock;
EditText mEditText;
@ -60,9 +68,11 @@ public class MainActivity extends Activity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
_MainActivity = this;
initView();
if (getIntent().getAction().equals(ACTION_NEW_INSTALLTASK)) {
String action = getIntent().getAction();
if ((action != null) && action.equals(ACTION_NEW_INSTALLTASK)) {
mszInstalledPackageName = getIntent().getStringExtra(EXTRA_INSTALLED_PACKAGENAME);
mszInstalledAPKFilePath = getIntent().getStringExtra(EXTRA_INSTALLED_APKFILEPATH);
installAPK();
@ -76,11 +86,7 @@ public class MainActivity extends Activity {
mLogView = findViewById(R.id.logview);
mLogView.start();
AppConfigs appConfigs = AppConfigs.loadAppConfigs(this);
if (appConfigs == null) {
appConfigs = new AppConfigs();
AppConfigs.saveAppConfigs(this, appConfigs);
}
AppConfigs appConfigs = AppConfigs.getInstance(this).loadAppConfigs(this);
if (appConfigs.getSetupMode() == AppConfigs.SetupMode.WATCHOUTPUTINSTALLER) {
((RadioButton)findViewById(R.id.activitymainRadioButton1)).setChecked(true);
@ -131,23 +137,44 @@ public class MainActivity extends Activity {
}
String getLastApkPackageName() {
APKModel.loadBeanList(this, _APKModelList, APKModel.class);
if (_APKModelList.size() > 0) {
return _APKModelList.get(_APKModelList.size() - 1).getApkPackageName();
}
return "";
}
public void onOpenAPP(View view) {
if (mszInstalledPackageName.trim().equals("")) {
String szInstalledPackageName = getLastApkPackageName();
LogUtils.d(TAG, "szInstalledPackageName : " + szInstalledPackageName);
if (szInstalledPackageName.trim().equals("")) {
ToastUtils.show("Installed APP package name is null.");
return;
}
Intent intent = getPackageManager().getLaunchIntentForPackage(mszInstalledPackageName);
if (intent != null) {
startActivity(intent);
} else {
// 若没能获取到启动意图可进行相应提示等操作比如跳转到应用商店让用户下载该应用示例
Intent marketIntent = new Intent(Intent.ACTION_VIEW);
marketIntent.setData(Uri.parse("market://details?id=" + mszInstalledPackageName));
startActivity(marketIntent);
}
PackageUtil.openAPP(this, szInstalledPackageName);
}
// public void onOpenAPP(View view) {
// String szInstalledPackageName = getLastApkPackageName();
// if (szInstalledPackageName.trim().equals("")) {
// ToastUtils.show("Installed APP package name is null.");
// return;
// }
//
// Intent intent = getPackageManager().getLaunchIntentForPackage(mszInstalledPackageName);
// if (intent != null) {
// //ToastUtils.show("startActivity");
// startActivity(intent);
// } else {
// // 若没能获取到启动意图可进行相应提示等操作比如跳转到应用商店让用户下载该应用示例
// Intent marketIntent = new Intent(Intent.ACTION_VIEW);
// marketIntent.setData(Uri.parse("market://details?id=" + mszInstalledPackageName));
// startActivity(marketIntent);
// }
// }
public void onInstallAPK(View view) {
installAPK();
}
@ -185,17 +212,22 @@ public class MainActivity extends Activity {
}
public void onLockPath(View view) {
AppConfigs appConfigs = AppConfigs.loadAppConfigs(this);
Switch sw = (Switch)view;
if (sw.isChecked()) {
setMainServiceStatus(sw.isChecked());
}
public void setMainServiceStatus(boolean isEnable) {
AppConfigs appConfigs = AppConfigs.getInstance(this).loadAppConfigs(this);
Switch sw = (Switch)findViewById(R.id.activitymainSwitch1);
if (isEnable) {
String szFilePath = mEditText.getText().toString();
// 设置空路径时退出
//
if (szFilePath.trim().equals("")) {
sw.setChecked(false);
Toast.makeText(getApplication(), "监控路径为空。", Toast.LENGTH_SHORT).show();
ToastUtils.show("监控路径为空。");
return;
}
@ -236,7 +268,7 @@ public class MainActivity extends Activity {
stopWatchingFile();
}
AppConfigs.saveAppConfigs(this, appConfigs);
AppConfigs.getInstance(this).saveAppConfigs(this, appConfigs);
}
void stopWatchingFile() {
@ -251,8 +283,6 @@ public class MainActivity extends Activity {
Intent intentService = new Intent(MainActivity.this, MainService.class);
//intentService.putExtra(MainService.EXTRA_APKFILEPATH, szAPKFilePath);
startService(intentService);
}
/*
@ -298,7 +328,7 @@ public class MainActivity extends Activity {
}*/
public void onChangeSetupMode(View view) {
AppConfigs appConfigs = AppConfigs.loadAppConfigs(this);
AppConfigs appConfigs = AppConfigs.getInstance(this).loadAppConfigs(this);
if (view.getId() == R.id.activitymainRadioButton1) {
appConfigs.setSetupMode(AppConfigs.SetupMode.WATCHOUTPUTINSTALLER);
@ -307,6 +337,42 @@ public class MainActivity extends Activity {
appConfigs.setSetupMode(AppConfigs.SetupMode.NEWAPKINFONEWAPKINFO);
((RadioButton)findViewById(R.id.activitymainRadioButton1)).setChecked(false);
}
AppConfigs.saveAppConfigs(this, appConfigs);
AppConfigs.getInstance(this).saveAppConfigs(this, appConfigs);
}
// 定义Handler
static Handler _Handler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (msg.what == MSG_UPDATE_STATUS) {
if (_MainActivity != null) {
boolean isEnableMainService = (boolean)msg.obj;
// 处理消息这里更新 MainService 的状态
_MainActivity.setMainServiceStatus(isEnableMainService);
}
}
}
};
static void updateMainServiceStatus(boolean isEnable) {
if (_Handler != null) {
Message msg = new Message();
msg.obj = isEnable;
msg.what = MSG_UPDATE_STATUS;
_Handler.sendMessage(msg);
}
}
public static void stopMainService() {
if (_MainActivity != null && _Handler != null) {
updateMainServiceStatus(false);
}
}
public static void startMainService() {
if (_MainActivity != null && _Handler != null) {
updateMainServiceStatus(true);
}
}
}

View File

@ -0,0 +1,75 @@
package cc.winboll.studio.autoinstaller.models;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/04/02 20:50:29
* @Describe 监控的 APK 安装文件对应的应用信息数据模型
*/
import android.util.JsonReader;
import android.util.JsonWriter;
import cc.winboll.studio.libappbase.BaseBean;
import java.io.IOException;
public class APKModel extends BaseBean {
public static final String TAG = "APPModel";
// 每次更新的 APK 文件对应的应用包名称
String apkPackageName;
public APKModel() {
this.apkPackageName = "";
}
public APKModel(String apkPackageName) {
this.apkPackageName = apkPackageName;
}
public void setApkPackageName(String apkPackageName) {
this.apkPackageName = apkPackageName;
}
public String getApkPackageName() {
return apkPackageName;
}
@Override
public String getName() {
return APKModel.class.getName();
}
@Override
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
super.writeThisToJsonWriter(jsonWriter);
jsonWriter.name("appPackageName").value(getApkPackageName());
}
@Override
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
if (name.equals("appPackageName")) {
setApkPackageName(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;
}
}

View File

@ -1,4 +1,4 @@
package cc.winboll.studio.autoinstaller.beans;
package cc.winboll.studio.autoinstaller.models;
/**
* @Author ZhanGSKen@QQ.COM
@ -8,13 +8,14 @@ package cc.winboll.studio.autoinstaller.beans;
import android.content.Context;
import android.util.JsonReader;
import android.util.JsonWriter;
import cc.winboll.studio.autoinstaller.beans.AppConfigs;
import cc.winboll.studio.autoinstaller.models.AppConfigs;
import cc.winboll.studio.autoinstaller.utils.FileUtil;
import cc.winboll.studio.libappbase.LogUtils;
import com.hjq.toast.ToastUtils;
import java.io.IOException;
import java.io.Serializable;
import java.io.StringReader;
import java.io.StringWriter;
import cc.winboll.studio.shared.log.LogUtils;
public class AppConfigs implements Serializable {
@ -26,6 +27,21 @@ public class AppConfigs implements Serializable {
NEWAPKINFONEWAPKINFO // 调用[应用信息查看器]打开应用包
};
static volatile AppConfigs _AppConfigs;
Context mContext;
AppConfigs(Context context) {
mContext = context.getApplicationContext();
}
public static synchronized AppConfigs getInstance(Context context) {
if (_AppConfigs == null) {
_AppConfigs = new AppConfigs(context);
_AppConfigs.loadAppConfigs(_AppConfigs.mContext);
}
return _AppConfigs;
}
// 监控文件路径
private String watchingFilePath = "";
@ -85,8 +101,8 @@ public class AppConfigs implements Serializable {
return "";
}
public static AppConfigs parseAppConfigs(String szAppConfigs) {
AppConfigs appConfigs = new AppConfigs();
public AppConfigs parseAppConfigs(String szAppConfigs) {
AppConfigs appConfigs = new AppConfigs(mContext);
// 创建 JsonWriter 对象
StringReader stringReader = new StringReader(szAppConfigs);
JsonReader jsonReader = new
@ -122,19 +138,34 @@ public class AppConfigs implements Serializable {
return context.getExternalFilesDir(TAG) + "/" + TAG + ".json";
}
public static AppConfigs loadAppConfigs(Context context) {
public AppConfigs loadAppConfigs() {
AppConfigs appConfigs = null;
try {
String szJson = FileUtil.readFile(getDataPath(context));
appConfigs = AppConfigs.parseAppConfigs(szJson);
String szJson = FileUtil.readFile(getDataPath(mContext));
appConfigs = AppConfigs.getInstance(mContext).parseAppConfigs(szJson);
} catch (IOException e) {
LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace());
}
return appConfigs;
}
public static void saveAppConfigs(Context context, AppConfigs appConfigs) {
public AppConfigs loadAppConfigs(Context context) {
AppConfigs appConfigs = null;
try {
String szJson = FileUtil.readFile(getDataPath(context.getApplicationContext()));
appConfigs = AppConfigs.getInstance(mContext).parseAppConfigs(szJson);
if(appConfigs != null) {
_AppConfigs = appConfigs;
}
} catch (IOException e) {
LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace());
}
return _AppConfigs;
}
public void saveAppConfigs(Context context, AppConfigs appConfigs) {
try {
ToastUtils.show(String.format("AppConfigs set enable service to %s", appConfigs.isEnableService()));
//LogUtils.d(TAG, "appConfigs is : " + appConfigs.toString());
String szJson = appConfigs.toString();
FileUtil.writeFile(getDataPath(context), szJson);
@ -142,4 +173,8 @@ public class AppConfigs implements Serializable {
LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace());
}
}
public void saveAppConfigs() {
saveAppConfigs(mContext, this);
}
}

View File

@ -1,54 +1,49 @@
package cc.winboll.studio.appbase.models;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/02/17 10:05:09
* @Describe APPSOSReportBean
*/
package cc.winboll.studio.autoinstaller.models;
import android.util.JsonReader;
import android.util.JsonWriter;
import cc.winboll.studio.libappbase.BaseBean;
import java.io.IOException;
public class WinBoLLNewsBean extends BaseBean {
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/04/15 09:27:39
* @Describe MainServiceBean
*/
public class MainServiceBean extends BaseBean {
public static final String TAG = "WinBoLLNewsBean";
public static final String TAG = "MainServiceBean";
protected String message;
boolean isEnable;
public WinBoLLNewsBean() {
this.message = "";
public MainServiceBean() {
this.isEnable = false;
}
public WinBoLLNewsBean(String message) {
this.message = message;
public void setIsEnable(boolean isEnable) {
this.isEnable = isEnable;
}
public void setMessage(String message) {
this.message = message;
}
public String getMessage() {
return message;
public boolean isEnable() {
return isEnable;
}
@Override
public String getName() {
return WinBoLLNewsBean.class.getName();
return MainServiceBean.class.getName();
}
@Override
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
super.writeThisToJsonWriter(jsonWriter);
jsonWriter.name("message").value(getMessage());
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("message")) {
setMessage(jsonReader.nextString());
if (name.equals("isEnable")) {
setIsEnable(jsonReader.nextBoolean());
} else {
return false;
}

View File

@ -4,9 +4,9 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import cc.winboll.studio.autoinstaller.beans.AppConfigs;
import cc.winboll.studio.autoinstaller.models.AppConfigs;
import cc.winboll.studio.autoinstaller.services.MainService;
import cc.winboll.studio.shared.log.LogUtils;
import cc.winboll.studio.libappbase.LogUtils;
/**
* @Author ZhanGSKen@QQ.COM
@ -23,7 +23,7 @@ public class MainReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
String szAction = intent.getAction();
if (szAction.equals(ACTION_BOOT_COMPLETED)) {
AppConfigs appConfigs = AppConfigs.loadAppConfigs(context);
AppConfigs appConfigs = AppConfigs.getInstance(context).loadAppConfigs(context);
if (appConfigs.isEnableService()) {
Intent intentService = new Intent(context, MainService.class);
//intentService.putExtra(MainService.EXTRA_APKFILEPATH, appConfigs.getWatchingFilePath());

View File

@ -6,7 +6,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import cc.winboll.studio.autoinstaller.beans.AppConfigs;
import cc.winboll.studio.autoinstaller.models.AppConfigs;
import cc.winboll.studio.autoinstaller.utils.ServiceUtil;
/**
@ -46,7 +46,7 @@ public class AssistantService extends Service {
public int onStartCommand(Intent intent, int flags, int startId) {
//LogUtils.d(TAG, "call onStartCommand(...)");
run();
AppConfigs appConfigs = AppConfigs.loadAppConfigs(AssistantService.this);
AppConfigs appConfigs = AppConfigs.getInstance(AssistantService.this).loadAppConfigs(AssistantService.this);
return appConfigs.isEnableService() ? Service.START_STICKY: super.onStartCommand(intent, flags, startId);
}
@ -68,7 +68,7 @@ public class AssistantService extends Service {
//
void run() {
//LogUtils.d(TAG, "call run()");
AppConfigs appConfigs = AppConfigs.loadAppConfigs(AssistantService.this);
AppConfigs appConfigs = AppConfigs.getInstance(AssistantService.this).loadAppConfigs(AssistantService.this);
if (appConfigs.isEnableService()) {
if (mIsThreadAlive == false) {
// 设置运行状态
@ -101,7 +101,7 @@ public class AssistantService extends Service {
@Override
public void onServiceDisconnected(ComponentName name) {
//LogUtils.d(TAG, "call onServiceDisconnected(...)");
AppConfigs appConfigs = AppConfigs.loadAppConfigs(AssistantService.this);
AppConfigs appConfigs = AppConfigs.getInstance(AssistantService.this).loadAppConfigs(AssistantService.this);
if (appConfigs.isEnableService()) {
wakeupAndBindMain();
}

View File

@ -10,25 +10,32 @@ import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.service.quicksettings.Tile;
import android.service.quicksettings.TileService;
import android.widget.Toast;
import androidx.core.content.FileProvider;
import cc.winboll.studio.shared.log.LogUtils;
import cc.winboll.studio.autoinstaller.FileListener;
import cc.winboll.studio.autoinstaller.MainActivity;
import cc.winboll.studio.autoinstaller.beans.AppConfigs;
import cc.winboll.studio.autoinstaller.R;
import cc.winboll.studio.autoinstaller.models.APKModel;
import cc.winboll.studio.autoinstaller.models.AppConfigs;
import cc.winboll.studio.autoinstaller.services.AssistantService;
import cc.winboll.studio.autoinstaller.services.MainService;
import cc.winboll.studio.autoinstaller.utils.NotificationUtil;
import cc.winboll.studio.autoinstaller.utils.PackageUtil;
import cc.winboll.studio.autoinstaller.utils.ServiceUtil;
import com.hjq.toast.ToastUtils;
import cc.winboll.studio.libappbase.LogUtils;
import java.io.File;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
public class MainService extends Service {
public static String TAG = "MainService";
Context mContext;
ArrayList<APKModel> _APKModelList = new ArrayList<APKModel>();
private static boolean _mIsServiceAlive;
//String mszAPKFilePath;
//String mszAPKFileName;
@ -47,6 +54,7 @@ public class MainService extends Service {
@Override
public void onCreate() {
super.onCreate();
mContext = this;
LogUtils.d(TAG, "onCreate()");
_mIsServiceAlive = false;
mHandler = new MyHandler(MainService.this);
@ -55,11 +63,14 @@ public class MainService extends Service {
}
run();
// 初始化磁贴工具服务
MainTileService mainTileService = new MainTileService(this);
}
private void run() {
AppConfigs appConfigs = AppConfigs.loadAppConfigs(MainService.this);
AppConfigs appConfigs = AppConfigs.getInstance(MainService.this).loadAppConfigs(MainService.this);
if (appConfigs.isEnableService()) {
if (_mIsServiceAlive == false) {
// 设置运行状态
@ -74,7 +85,8 @@ public class MainService extends Service {
startWatchingFile(appConfigs.getWatchingFilePath());
LogUtils.d(TAG, "running...");
//LogUtils.d(TAG, "running...");
//ToastUtils.show("running...");
} else {
LogUtils.d(TAG, "_mIsServiceAlive is " + Boolean.toString(_mIsServiceAlive));
@ -94,6 +106,7 @@ public class MainService extends Service {
}
_mIsServiceAlive = false;
LogUtils.d(TAG, "onDestroy()");
mContext = null;
}
@Override
@ -101,7 +114,7 @@ public class MainService extends Service {
LogUtils.d(TAG, "onStartCommand");
run();
AppConfigs appConfigs = AppConfigs.loadAppConfigs(MainService.this);
AppConfigs appConfigs = AppConfigs.getInstance(MainService.this).loadAppConfigs(MainService.this);
return appConfigs.isEnableService() ? Service.START_STICKY: super.onStartCommand(intent, flags, startId);
}
@ -118,7 +131,7 @@ public class MainService extends Service {
@Override
public void onServiceDisconnected(ComponentName name) {
//LogUtils.d(TAG, "call onServiceConnected(...)");
AppConfigs appConfigs = AppConfigs.loadAppConfigs(MainService.this);
AppConfigs appConfigs = AppConfigs.getInstance(MainService.this).loadAppConfigs(MainService.this);
if (appConfigs.isEnableService()) {
// 唤醒守护进程
wakeupAndBindAssistant();
@ -160,7 +173,7 @@ public class MainService extends Service {
});
mFileListener.startWatching();
ToastUtils.show("Start watching.");
//ToastUtils.show("Start watching.");
} else {
// 父级文件夹不存在就提示用户
Toast.makeText(getApplication(), fParentDir.toString() + " no exist.", Toast.LENGTH_SHORT).show();
@ -176,6 +189,9 @@ public class MainService extends Service {
// 调用[应用信息查看器]打开应用包
//
private void installAPK(String szAPKFilePath) {
String szAPKPackageName = PackageUtil.getPackageNameFromApk(this, szAPKFilePath);
saveAPKInfo(szAPKPackageName);
long nTimeNow = System.currentTimeMillis();
/*SimpleDateFormat dateFormat = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss", Locale.getDefault());
@ -210,15 +226,24 @@ public class MainService extends Service {
//
void installAPK2(String szAPKFilePath) {
LogUtils.d(TAG, "installAPK2()");
String szAPKPackageName = PackageUtil.getPackageNameFromApk(this, szAPKFilePath);
saveAPKInfo(szAPKPackageName);
Intent intent = new Intent(this, MainActivity.class);
intent.setAction(MainActivity.ACTION_NEW_INSTALLTASK);
intent.putExtra(MainActivity.EXTRA_INSTALLED_PACKAGENAME, PackageUtil.getPackageNameFromApk(this, szAPKFilePath));
intent.putExtra(MainActivity.EXTRA_INSTALLED_PACKAGENAME, szAPKPackageName);
intent.putExtra(MainActivity.EXTRA_INSTALLED_APKFILEPATH, szAPKFilePath);
// Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
}
void saveAPKInfo(String szApkPackageName) {
APKModel.loadBeanList(this, _APKModelList, APKModel.class);
_APKModelList.add(new APKModel(szApkPackageName));
APKModel.saveBeanList(this, _APKModelList, APKModel.class);
}
//
//
static class MyHandler extends Handler {
@ -231,7 +256,7 @@ public class MainService extends Service {
switch (message.what) {
case MSG_INSTALL_APK:
{
AppConfigs appConfigs = AppConfigs.loadAppConfigs(theActivity);
AppConfigs appConfigs = AppConfigs.getInstance(theActivity).loadAppConfigs(theActivity);
if (appConfigs.getSetupMode() == AppConfigs.SetupMode.WATCHOUTPUTINSTALLER) {
theActivity.installAPK2((String)message.obj);
} else if (appConfigs.getSetupMode() == AppConfigs.SetupMode.NEWAPKINFONEWAPKINFO) {
@ -245,4 +270,21 @@ public class MainService extends Service {
super.handleMessage(message);
}
}
static class MainTileService extends TileService {
Context mContext;
MainTileService(Context context) {
mContext = context;
}
@Override
public void onStartListening() {
super.onStartListening();
Tile tile = getQsTile();
tile.setIcon(android.graphics.drawable.Icon.createWithResource(this, R.drawable.ic_android));
// 更新磁贴状态
tile.setState((mContext == null || mContext.getApplicationContext() == null )?Tile.STATE_INACTIVE: Tile.STATE_ACTIVE);
tile.updateTile();
}
}
}

View File

@ -55,8 +55,9 @@ public class NotificationUtil {
Notification mForegroundNotification = new Notification.Builder(service, szServiceChannelID)
.setAutoCancel(true)
.setContentTitle(service.getString(R.string.app_name))
.setContentText(service.TAG + " is started.")
//.setContentTitle(service.getString(R.string.app_name))
.setContentTitle(service.TAG + " is started.")
//.setContentText(service.TAG + " is started.")
.setWhen(System.currentTimeMillis())
.setSmallIcon(R.drawable.ic_launcher)
//设置红色

View File

@ -6,9 +6,11 @@ package cc.winboll.studio.autoinstaller.utils;
* @Describe 一个获取安卓APK安装文件的应用包名的函数
*/
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import cc.winboll.studio.shared.log.LogUtils;
import android.content.pm.ResolveInfo;
import cc.winboll.studio.libappbase.LogUtils;
public class PackageUtil {
@ -27,4 +29,20 @@ public class PackageUtil {
}
return "";
}
public static void openAPP(Context context, String packageName) {
// 这里假设要打开微信微信的包名是com.tencent.mm
//String packageName = "com.tencent.mm";
LogUtils.d(TAG, "packageName : " + packageName);
PackageManager packageManager = context.getPackageManager();
Intent intent = packageManager.getLaunchIntentForPackage(packageName);
if (intent != null) {
ResolveInfo resolveInfo = packageManager.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
if (resolveInfo != null) {
LogUtils.d(TAG, "startActivity...");
context.startActivity(intent);
}
}
}
}

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="#FF000000"
android:pathData="M16.61,15.15C16.15,15.15 15.77,14.78 15.77,14.32S16.15,13.5 16.61,13.5H16.61C17.07,13.5 17.45,13.86 17.45,14.32C17.45,14.78 17.07,15.15 16.61,15.15M7.41,15.15C6.95,15.15 6.57,14.78 6.57,14.32C6.57,13.86 6.95,13.5 7.41,13.5H7.41C7.87,13.5 8.24,13.86 8.24,14.32C8.24,14.78 7.87,15.15 7.41,15.15M16.91,10.14L18.58,7.26C18.67,7.09 18.61,6.88 18.45,6.79C18.28,6.69 18.07,6.75 18,6.92L16.29,9.83C14.95,9.22 13.5,8.9 12,8.91C10.47,8.91 9,9.24 7.73,9.82L6.04,6.91C5.95,6.74 5.74,6.68 5.57,6.78C5.4,6.87 5.35,7.08 5.44,7.25L7.1,10.13C4.25,11.69 2.29,14.58 2,18H22C21.72,14.59 19.77,11.7 16.91,10.14H16.91Z"/>
</vector>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="#ff000000"
android:pathData="M6.5,20Q4.22,20 2.61,18.43 1,16.85 1,14.58 1,12.63 2.17,11.1 3.35,9.57 5.25,9.15 5.88,6.85 7.75,5.43 9.63,4 12,4 14.93,4 16.96,6.04 19,8.07 19,11 20.73,11.2 21.86,12.5 23,13.78 23,15.5 23,17.38 21.69,18.69 20.38,20 18.5,20Z"/>
</vector>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="#ff000000"
android:pathData="M6.5,20Q4.22,20 2.61,18.43 1,16.85 1,14.58 1,12.63 2.17,11.1 3.35,9.57 5.25,9.15 5.88,6.85 7.75,5.43 9.63,4 12,4 14.93,4 16.96,6.04 19,8.07 19,11 20.73,11.2 21.86,12.5 23,13.78 23,15.5 23,17.38 21.69,18.69 20.38,20 18.5,20M6.5,18H18.5Q19.55,18 20.27,17.27 21,16.55 21,15.5 21,14.45 20.27,13.73 19.55,13 18.5,13H17V11Q17,8.93 15.54,7.46 14.08,6 12,6 9.93,6 8.46,7.46 7,8.93 7,11H6.5Q5.05,11 4.03,12.03 3,13.05 3,14.5 3,15.95 4.03,17 5.05,18 6.5,18M12,12Z"/>
</vector>

View File

@ -132,7 +132,7 @@
</LinearLayout>
<cc.winboll.studio.shared.log.LogView
<cc.winboll.studio.libappbase.LogView
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="200dp"

View File

@ -1,3 +1,4 @@
<resources>
<string name="app_name">AutoInstaller</string>
<string name="tileservice_name">AutoInstaller</string>
</resources>

View File

@ -0,0 +1,13 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="MyAppTheme" parent="APPBaseTheme">
<item name="attrColorPrimary">@color/colorPrimary</item>
<item name="themeGlobalCrashActivity">@style/MyGlobalCrashActivityTheme</item>
</style>
<style name="MyGlobalCrashActivityTheme" parent="GlobalCrashActivityTheme">
<item name="colorTittle">#FFFFFFFF</item>
<item name="colorTittleBackgound">#FF00A4B3</item>
<item name="colorText">#FFFFFFFF</item>
<item name="colorTextBackgound">#FF000000</item>
</style>
</resources>

View File

@ -1,14 +0,0 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Application" parent="android:Theme.Material.Light.DarkActionBar">
<!-- Primary brand color. -->
<item name="android:colorPrimary">@color/purple_500</item>
<!-- Secondary brand color. -->
<item name="android:colorSecondary">@color/teal_200</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">@color/purple_700</item>
<!-- Customize your theme here. -->
</style>
</resources>

View File

@ -2,7 +2,7 @@
buildscript {
repositories {
// Maven ~/.m2/repository
mavenLocal()
//mavenLocal()
//
maven { url "file:///sdcard/.m2/repository" }
@ -31,6 +31,11 @@ buildscript {
allprojects {
repositories {
// Maven ~/.m2/repository
//mavenLocal()
//
maven { url "file:///sdcard/.m2/repository" }
// Nexus Maven
// "WinBoLL Release"
maven { url "https://nexus.winboll.cc/repository/maven-public/" }

View File

@ -21,6 +21,9 @@ android {
dependencies {
api fileTree(dir: 'libs', include: ['*.jar'])
//api 'cc.winboll.studio:libaes:15.6.0'
api 'cc.winboll.studio:libapputils:15.3.4'
api 'cc.winboll.studio:libappbase:15.7.6'
//
api 'com.github.getActivity:ToastUtils:10.5'
@ -50,7 +53,4 @@ dependencies {
//api 'androidx.vectordrawable:vectordrawable:1.1.0'
//api 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
//api 'androidx.fragment:fragment:1.1.0'
api 'cc.winboll.studio:libapputils:15.3.4'
api 'cc.winboll.studio:libappbase:15.7.6'
}

View File

@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Tue Apr 29 15:14:21 HKT 2025
#Sat May 03 11:34:58 GMT 2025
stageCount=1
libraryProject=libaes
baseVersion=15.6
publishVersion=15.6.0
buildCount=0
buildCount=9
baseBetaVersion=15.6.1

View File

@ -5,25 +5,32 @@
<application>
<activity android:name="cc.winboll.studio.libaes.unittests.SecondaryLibraryActivity"
<activity
android:name="cc.winboll.studio.libaes.unittests.SecondaryLibraryActivity"
android:exported="true"/>
<activity android:name="cc.winboll.studio.libaes.unittests.TestDrawerFragmentActivity"
<activity
android:name="cc.winboll.studio.libaes.unittests.TestDrawerFragmentActivity"
android:exported="true"/>
<activity android:name="cc.winboll.studio.libaes.unittests.TestAToolbarActivity"
<activity
android:name="cc.winboll.studio.libaes.unittests.TestAToolbarActivity"
android:exported="true"/>
<activity android:name="cc.winboll.studio.libaes.unittests.TestASupportToolbarActivity"
<activity
android:name="cc.winboll.studio.libaes.unittests.TestASupportToolbarActivity"
android:exported="true"/>
<service android:name="cc.winboll.studio.libaes.winboll.WinBoLLClientService"
<service
android:name="cc.winboll.studio.libaes.winboll.WinBoLLClientService"
android:exported="true"/>
<service android:name="cc.winboll.studio.libaes.winboll.AssistantService"
<service
android:name="cc.winboll.studio.libaes.winboll.AssistantService"
android:exported="true"/>
<service android:name="cc.winboll.studio.libaes.winboll.WinBoLLMail"
<service
android:name="cc.winboll.studio.libaes.winboll.WinBoLLMail"
android:exported="true"/>
</application>

View File

@ -0,0 +1,78 @@
package cc.winboll.studio.libaes.beans;
/**
* @Author ZhanGSKen
* @Date 2025/05/03 19:16
*/
import android.content.Context;
import android.util.JsonReader;
import android.util.JsonWriter;
import cc.winboll.studio.libappbase.BaseBean;
import java.io.IOException;
public class WinBoLLClientServiceBean extends BaseBean {
public static final String TAG = "WinBoLLClientServiceBean";
// 服务是否正在使用中
boolean isEnable;
public WinBoLLClientServiceBean() {
this.isEnable = false;
}
public WinBoLLClientServiceBean(boolean isEnable) {
this.isEnable = isEnable;
}
public void setIsEnable(boolean isEnable) {
this.isEnable = isEnable;
}
public boolean isEnable() {
return isEnable;
}
@Override
public String getName() {
return WinBoLLClientServiceBean.class.getName();
}
@Override
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
super.writeThisToJsonWriter(jsonWriter);
WinBoLLClientServiceBean bean = this;
//jsonWriter.name("logLevel").value(bean.getLogLevel().ordinal());
}
@Override
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
// if (name.equals("logLevel")) {
// setLogLevel(LogUtils.LOG_LEVEL.values()[jsonReader.nextInt()]);
// } 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;
}
public static WinBoLLClientServiceBean loadWinBoLLClientServiceBean(Context context) {
return new WinBoLLClientServiceBean();
}
}

View File

@ -11,7 +11,8 @@ import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import cc.winboll.studio.libaes.winboll.WinBoLLClientService;
import cc.winboll.studio.libaes.beans.WinBoLLClientServiceBean;
import cc.winboll.studio.libaes.winboll.AssistantService;
import cc.winboll.studio.libappbase.utils.ServiceUtils;
public class AssistantService extends Service {

View File

@ -0,0 +1,21 @@
package cc.winboll.studio.libaes.winboll;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
/**
* @Author ZhanGSKen
* @Date 2025/05/03 19:28
*/
public class WinBoLLClientService extends Service {
public static final String TAG = "WinBoLLClientService";
@Override
public IBinder onBind(Intent intent) {
return null;
}
}

View File

@ -0,0 +1,38 @@
package cc.winboll.studio.libaes.winboll;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;
/**
* @Author ZhanGSKen
* @Date 2025/05/03 19:14
*/
public class WinBoLLServiceStatusView extends LinearLayout {
public static final String TAG = "WinBoLLServiceStatusView";
public WinBoLLServiceStatusView(Context context) {
super(context);
}
public WinBoLLServiceStatusView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public WinBoLLServiceStatusView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public WinBoLLServiceStatusView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
void setServerHost(String szWinBoLLServerHost) {
}
void setAuthInfo(String szDevUserName, String szDevUserPassword) {
}
}

View File

@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Tue Apr 29 14:47:16 HKT 2025
#Sat May 03 10:32:21 GMT 2025
stageCount=7
libraryProject=libappbase
baseVersion=15.7
publishVersion=15.7.6
buildCount=0
buildCount=4
baseBetaVersion=15.7.7

View File

@ -1,39 +0,0 @@
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);
}
}

View File

@ -1,18 +0,0 @@
package cc.winboll.studio.libappbase.winboll;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/03/24 08:23:40
* @Describe WinBoLL 活动窗口通用接口
*/
import android.app.Activity;
import android.widget.Toolbar;
public interface IWinBoLLActivity {
public static final String TAG = "IWinBoLLActivity";
// 获取活动窗口
abstract public Activity getActivity();
abstract public String getTag();
}

View File

@ -1,356 +0,0 @@
package cc.winboll.studio.libappbase.winboll;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/03/24 08:25:43
* @Describe 应用活动窗口管理器
* 参考
* android 类似微信小程序多任务窗口 设置 TaskDescription 修改 icon label
* https://blog.csdn.net/qq_29364417/article/details/109379915?app_version=6.4.2&code=app_1562916241&csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22109379915%22%2C%22source%22%3A%22weixin_38986226%22%7D&uLinkId=usr1mkqgl919blen&utm_source=app
*/
import android.app.ActivityManager;
import android.app.TaskStackBuilder;
import android.content.Context;
import android.content.Intent;
import cc.winboll.studio.libappbase.GlobalApplication;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.utils.ToastUtils;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class WinBoLLActivityManager {
public static final String TAG = "WinBoLLActivityManager";
public static final String EXTRA_TAG = "EXTRA_TAG";
public static enum WinBoLLUI_TYPE {
Aplication, // 退出应用后保持最近任务栏任务记录主窗口
Service // 退出应用后清理所有最近任务栏任务记录窗口
};
// 应用类型标志
static volatile WinBoLLUI_TYPE _mWinBoLLUI_TYPE = WinBoLLUI_TYPE.Service;
GlobalApplication mGlobalApplication;
static volatile WinBoLLActivityManager _Instance;
static volatile Map<String, IWinBoLLActivity> _mapIWinBoLLList;
volatile IWinBoLLActivity mFirstIWinBoLLActivity;
WinBoLLActivityManager(GlobalApplication application) {
mGlobalApplication = application;
_mapIWinBoLLList = new HashMap<String, IWinBoLLActivity>();
}
public static synchronized WinBoLLActivityManager getInstance(GlobalApplication application) {
LogUtils.d(TAG, "getInstance");
if (_Instance == null) {
LogUtils.d(TAG, "_Instance == null");
_Instance = new WinBoLLActivityManager(application);
}
return _Instance;
}
//
// 设置 WinBoLL 应用 UI 类型
//
public synchronized static void setWinBoLLUI_TYPE(WinBoLLUI_TYPE mWinBoLLUI_TYPE) {
_mWinBoLLUI_TYPE = mWinBoLLUI_TYPE;
}
//
// 获取 WinBoLL 应用 UI 类型
//
public synchronized static WinBoLLUI_TYPE getWinBoLLUI_TYPE() {
return _mWinBoLLUI_TYPE;
}
//
// 把Activity添加到管理中
//
public <T extends IWinBoLLActivity> void add(T iWinBoLL) {
String tag = ((IWinBoLLActivity)iWinBoLL).getTag();
LogUtils.d(TAG, String.format("add(T iWinBoLL) tag is %s", tag));
if (isActive(tag)) {
LogUtils.d(TAG, String.format("isActive(tag) is true, tag : %s.", tag));
} else {
// 设置起始活动窗口以便最后退出时提问
if (mFirstIWinBoLLActivity == null && _mapIWinBoLLList.size() == 0) {
LogUtils.d(TAG, "Set firstIWinBoLLActivity, iWinBoLL.getTag() is %s" + iWinBoLL.getTag());
mFirstIWinBoLLActivity = iWinBoLL;
}
// 添加到活动窗口列表
_mapIWinBoLLList.put(iWinBoLL.getTag(), iWinBoLL);
LogUtils.d(TAG, String.format("Add activity : %s\n_mapActivityList.size() : %d", iWinBoLL.getTag(), _mapIWinBoLLList.size()));
}
}
//
// activity: null
// intent.putExtra 函数 EXTRA_TAG 参数为 tag
// activity: 不为 null
// intent.putExtra 函数 "tag" 参数为 activity.getTag()
//
public <T extends IWinBoLLActivity> void startWinBoLLActivity(Context context, Class<T> clazz) {
try {
// 如果窗口已存在就重启窗口
String tag = ((IWinBoLLActivity)clazz.newInstance()).getTag();
LogUtils.d(TAG, String.format("startWinBoLLActivity(Context context, Class<T> clazz) tag is %s", tag));
if (isActive(tag)) {
resumeActivity(context, tag);
return;
}
//ToastUtils.show("startWinBoLLActivity(Context context, Class<T> clazz)");
// 新建一个任务窗口
Intent intent = new Intent(context, clazz);
//打开多任务窗口 flags
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(EXTRA_TAG, tag);
context.startActivity(intent);
} catch (InstantiationException | IllegalAccessException e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
}
public <T extends IWinBoLLActivity> void startWinBoLLActivity(Context context, Intent intent, Class<T> clazz) {
try {
// 如果窗口已存在就重启窗口
String tag = ((IWinBoLLActivity)clazz.newInstance()).getTag();
LogUtils.d(TAG, String.format("startWinBoLLActivity(Context context, Intent intent, Class<T> clazz) tag is %s", tag));
if (isActive(tag)) {
resumeActivity(context, tag);
return;
}
// 新建一个任务窗口
//Intent intent = new Intent(context, clazz);
//打开多任务窗口 flags
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(EXTRA_TAG, tag);
context.startActivity(intent);
} catch (InstantiationException | IllegalAccessException e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
}
public <T extends IWinBoLLActivity> void startLogActivity(Context context) {
// 如果窗口已存在就重启窗口
String tag = LogActivity.TAG;
if (isActive(tag)) {
resumeActivity(context, tag);
return;
}
// 新建一个任务窗口
Intent intent = new Intent(context, LogActivity.class);
//打开多任务窗口 flags
// Define the bounds.
// Rect bounds = new Rect(0, 0, 800, 200);
// // Set the bounds as an activity option.
// ActivityOptions options = ActivityOptions.makeBasic();
// options.setLaunchBounds(bounds);
intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
intent.putExtra(EXTRA_TAG, tag);
//context.startActivity(intent, options.toBundle());
context.startActivity(intent);
}
public boolean isFirstIWinBoLLActivity(IWinBoLLActivity iWinBoLLActivity) {
return mFirstIWinBoLLActivity != null && mFirstIWinBoLLActivity == iWinBoLLActivity;
}
//
// 判断 tag绑定的 MyActivity是否存在
//
public boolean isActive(String tag) {
LogUtils.d(TAG, String.format("isActive(String tag) tag is %s", tag));
//printIWinBoLLListInfo();
IWinBoLLActivity iWinBoLL = getIWinBoLL(tag);
if (iWinBoLL != null) {
//LogUtils.d(TAG, "isActive(...) activity != null tag " + tag);
//ToastUtils.show("activity != null tag " + tag);
//判断是否为 BaseActivity,如果已经销毁则移除
if (iWinBoLL.getActivity().isFinishing() || iWinBoLL.getActivity().isDestroyed()) {
_mapIWinBoLLList.remove(iWinBoLL.getTag());
//_mWinBoLLActivityList.remove(activity);
LogUtils.d(TAG, String.format("isActive(...) remove activity.\ntag : %s", tag));
return false;
} else {
LogUtils.d(TAG, String.format("isActive(...) activity is exist.\ntag : %s", tag));
return true;
}
} else {
LogUtils.d(TAG, String.format("isActive(...) iWinBoLL is null tag by %s", tag));
return false;
}
}
static IWinBoLLActivity getIWinBoLL(String tag) {
LogUtils.d(TAG, String.format("getIWinBoLL(String tag) %s", tag));
return _mapIWinBoLLList.get(tag);
}
//
// 找到tag 绑定的 BaseActivity 通过 getTaskId() 移动到前台
//
public <T extends IWinBoLLActivity> void resumeActivity(Context context, String tag) {
LogUtils.d(TAG, "resumeActivity(Context context, String tag)");
T iWinBoLL = (T)getIWinBoLL(tag);
LogUtils.d(TAG, String.format("iWinBoLL.getTag() %s", iWinBoLL.getTag()));
//LogUtils.d(TAG, "activity " + activity.getTag());
if (iWinBoLL != null && !iWinBoLL.getActivity().isFinishing() && !iWinBoLL.getActivity().isDestroyed()) {
resumeActivity(context, iWinBoLL);
}
}
//
// 找到tag 绑定的 BaseActivity 通过 getTaskId() 移动到前台
//
public <T extends IWinBoLLActivity> void resumeActivity(Context context, T iWinBoLL) {
LogUtils.d(TAG, "resumeActivity(Context context, T iWinBoLL)");
ActivityManager am = (ActivityManager) mGlobalApplication.getSystemService(Context.ACTIVITY_SERVICE);
//返回启动它的根任务home 或者 MainActivity
Intent intent = new Intent(mGlobalApplication, iWinBoLL.getClass());
TaskStackBuilder stackBuilder = TaskStackBuilder.create(mGlobalApplication);
stackBuilder.addNextIntentWithParentStack(intent);
stackBuilder.startActivities();
//moveTaskToFront(YourTaskId, 0);
//ToastUtils.show("resumeActivity am.moveTaskToFront");
LogUtils.d(TAG, String.format("iWinBoLL.getActivity().getTaskId() %d", iWinBoLL.getActivity().getTaskId()));
am.moveTaskToFront(iWinBoLL.getActivity().getTaskId(), ActivityManager.MOVE_TASK_NO_USER_ACTION);
LogUtils.d(TAG, "am.moveTaskToFront");
}
//
// 结束所有 Activity
//
public void finishAll() {
try {
for (String key : _mapIWinBoLLList.keySet()) {
//System.out.println("Key: " + key + ", Value: " + _mapActivityList.get(key));
IWinBoLLActivity iWinBoLL = _mapIWinBoLLList.get(key);
//ToastUtils.show("finishAll() activity");
if (iWinBoLL != null && !iWinBoLL.getActivity().isFinishing() && !iWinBoLL.getActivity().isDestroyed()) {
//ToastUtils.show("activity != null ...");
if (getWinBoLLUI_TYPE() == WinBoLLUI_TYPE.Service) {
// 结束窗口和最近任务栏, 建议前台服务类应用使用可以方便用户再次调用 UI 操作
iWinBoLL.getActivity().finishAndRemoveTask();
//ToastUtils.show("finishAll() activity.finishAndRemoveTask();");
} else if (getWinBoLLUI_TYPE() == WinBoLLUI_TYPE.Aplication) {
// 结束窗口保留最近任务栏建议前台服务类应用使用可以保持应用的系统自觉性
iWinBoLL.getActivity().finish();
//ToastUtils.show("finishAll() activity.finish();");
} else {
LogUtils.d(TAG, "WinBoLLApplication.WinBoLLUI_TYPE error.");
//ToastUtils.show("WinBoLLApplication.WinBoLLUI_TYPE error.");
}
}
}
} catch (Exception e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
}
//
// 结束指定Activity
//
public <T extends IWinBoLLActivity> void finish(T iWinBoLL) {
try {
if (iWinBoLL != null && !iWinBoLL.getActivity().isFinishing() && !iWinBoLL.getActivity().isDestroyed()) {
//根据tag 移除 MyActivity
//String tag= activity.getTag();
//_mWinBoLLActivityList.remove(tag);
//ToastUtils.show("remove");
//ToastUtils.show("_mWinBoLLActivityArrayMap.size() " + Integer.toString(_mWinBoLLActivityArrayMap.size()));
// 窗口回调规则
// [] 当前窗口位置 >> 调度出的窗口位置
// [0] 1 2 3 4 >> 1
// 0 1 [2] 3 4 >> 1
// 0 1 2 [3] 4 >> 2
// 0 1 2 3 [4] >> 3
// [0] >> 直接关闭当前窗口
//LogUtils.d(TAG, "finish no yet.");
IWinBoLLActivity preIWinBoLL = getPreIWinBoLL(iWinBoLL);
iWinBoLL.getActivity().finish();
if (preIWinBoLL != null) {
resumeActivity(mGlobalApplication, preIWinBoLL);
}
}
} catch (Exception e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
}
//
// 获取窗口队列中的前一个窗口
//
IWinBoLLActivity getPreIWinBoLL(IWinBoLLActivity iWinBoLL) {
try {
boolean bingo = false;
IWinBoLLActivity preIWinBoLL = null;
for (Map.Entry<String, IWinBoLLActivity> entity : _mapIWinBoLLList.entrySet()) {
if (entity.getKey().equals(iWinBoLL.getTag())) {
bingo = true;
//LogUtils.d(TAG, "bingo");
break;
}
preIWinBoLL = entity.getValue();
}
if (bingo) {
return preIWinBoLL;
}
} catch (Exception e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
return null;
}
//
// 从管理列表中移除管理项
//
public <T extends IWinBoLLActivity> boolean registeRemove(T activity) {
IWinBoLLActivity iWinBoLLTest = _mapIWinBoLLList.get(activity.getTag());
if (iWinBoLLTest != null) {
_mapIWinBoLLList.remove(activity.getTag());
return true;
}
return false;
}
//
// 打印管理列表项列表里的信息
//
public static void printIWinBoLLListInfo() {
//LogUtils.d(TAG, "printAvtivityListInfo");
if (!_mapIWinBoLLList.isEmpty()) {
StringBuilder sb = new StringBuilder("Map entries : " + Integer.toString(_mapIWinBoLLList.size()));
Iterator<Map.Entry<String, IWinBoLLActivity>> iterator = _mapIWinBoLLList.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, IWinBoLLActivity> entry = iterator.next();
sb.append("\nKey: " + entry.getKey() + ", \nValue: " + entry.getValue().getTag());
//ToastUtils.show("\nKey: " + entry.getKey() + ", Value: " + entry.getValue().getTag());
}
sb.append("\nMap entries end.");
LogUtils.d(TAG, sb.toString());
} else {
LogUtils.d(TAG, "The map is empty.");
}
}
}

View File

@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Tue Apr 29 12:41:13 GMT 2025
stageCount=0
#Sat May 03 06:21:11 GMT 2025
stageCount=1
libraryProject=
baseVersion=15.3
publishVersion=15.3.0
buildCount=4
buildCount=5
baseBetaVersion=15.3.1

View File

@ -32,6 +32,8 @@ import cc.winboll.studio.powerbell.utils.AppConfigUtils;
import cc.winboll.studio.powerbell.utils.NotificationHelper;
import cc.winboll.studio.powerbell.utils.ServiceUtils;
import cc.winboll.studio.powerbell.utils.StringUtils;
import android.os.Handler;
import android.os.Looper;
public class ControlCenterService extends Service {
@ -114,10 +116,18 @@ public class ControlCenterService extends Service {
mControlCenterServiceReceiver = new ControlCenterServiceReceiver(this);
mControlCenterServiceReceiver.registerAction(this);
}
new Handler(Looper.getMainLooper()).postDelayed(new Runnable(){
@Override
public void run() {
startRemindThread(mAppConfigUtils.mAppConfigBean);
ToastUtils.show("Service Is Start.");
LogUtils.i(TAG, "Service Is Start.");
}
}, 2000);
}
}
String getValuesString() {

View File

@ -83,8 +83,9 @@ public class NotificationHelper {
Notification notification = new NotificationCompat.Builder(mContext, CHANNEL_ID_FOREGROUND)
.setSmallIcon(R.drawable.ic_launcher)
.setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), R.drawable.ic_launcher))
.setContentTitle(title)
.setContentText(content)
//.setContentTitle(title + "\n" + content)
.setContentTitle(content)
//.setContentText(content)
.setContentIntent(pendingIntent)
.setPriority(NotificationCompat.PRIORITY_LOW)
.setOngoing(true)