diff --git a/aes/build.properties b/aes/build.properties index ec4f107..597a06b 100644 --- a/aes/build.properties +++ b/aes/build.properties @@ -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 diff --git a/aes/src/main/java/cc/winboll/studio/aes/AboutActivity.java b/aes/src/main/java/cc/winboll/studio/aes/AboutActivity.java index 228cd19..d720549 100644 --- a/aes/src/main/java/cc/winboll/studio/aes/AboutActivity.java +++ b/aes/src/main/java/cc/winboll/studio/aes/AboutActivity.java @@ -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"; diff --git a/appbase/build.properties b/appbase/build.properties index 3cb59e8..18395f7 100644 --- a/appbase/build.properties +++ b/appbase/build.properties @@ -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 diff --git a/appbase/src/main/java/cc/winboll/studio/appbase/WinBoLLActivityBase.java b/appbase/src/main/java/cc/winboll/studio/appbase/WinBoLLActivityBase.java deleted file mode 100644 index 71b4e40..0000000 --- a/appbase/src/main/java/cc/winboll/studio/appbase/WinBoLLActivityBase.java +++ /dev/null @@ -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); - } -} diff --git a/apputils/src/main/java/cc/winboll/studio/apputils/TestStringToQRCodeViewActivity.java b/apputils/src/main/java/cc/winboll/studio/apputils/TestStringToQRCodeViewActivity.java deleted file mode 100644 index a77addd..0000000 --- a/apputils/src/main/java/cc/winboll/studio/apputils/TestStringToQRCodeViewActivity.java +++ /dev/null @@ -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); - } -} diff --git a/autoinstaller/build.gradle b/autoinstaller/build.gradle index ba56e67..d91dba5 100644 --- a/autoinstaller/build.gradle +++ b/autoinstaller/build.gradle @@ -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' + } diff --git a/autoinstaller/build.properties b/autoinstaller/build.properties index 1db8525..d987d28 100644 --- a/autoinstaller/build.properties +++ b/autoinstaller/build.properties @@ -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 diff --git a/autoinstaller/src/main/AndroidManifest.xml b/autoinstaller/src/main/AndroidManifest.xml index 0da8a10..c496adb 100644 --- a/autoinstaller/src/main/AndroidManifest.xml +++ b/autoinstaller/src/main/AndroidManifest.xml @@ -23,6 +23,8 @@ + + + android:theme="@style/MyAppTheme"> + + + + + + + + + + _APKModelList = new ArrayList(); 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); + } } } diff --git a/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/models/APKModel.java b/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/models/APKModel.java new file mode 100644 index 0000000..cd7c225 --- /dev/null +++ b/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/models/APKModel.java @@ -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; + } +} diff --git a/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/beans/AppConfigs.java b/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/models/AppConfigs.java similarity index 71% rename from autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/beans/AppConfigs.java rename to autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/models/AppConfigs.java index f06959f..4924860 100644 --- a/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/beans/AppConfigs.java +++ b/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/models/AppConfigs.java @@ -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 @@ -121,20 +137,35 @@ public class AppConfigs implements Serializable { static String getDataPath(Context context) { 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); + } } diff --git a/appbase/src/main/java/cc/winboll/studio/appbase/models/WinBoLLNewsBean.java b/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/models/MainServiceBean.java similarity index 61% rename from appbase/src/main/java/cc/winboll/studio/appbase/models/WinBoLLNewsBean.java rename to autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/models/MainServiceBean.java index 8d70a3a..f3c484a 100644 --- a/appbase/src/main/java/cc/winboll/studio/appbase/models/WinBoLLNewsBean.java +++ b/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/models/MainServiceBean.java @@ -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 { - - public static final String TAG = "WinBoLLNewsBean"; - - protected String message; - - public WinBoLLNewsBean() { - this.message = ""; +/** + * @Author ZhanGSKen@AliYun.Com + * @Date 2025/04/15 09:27:39 + * @Describe MainServiceBean + */ +public class MainServiceBean extends BaseBean { + + public static final String TAG = "MainServiceBean"; + + boolean isEnable; + + 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; } diff --git a/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/receivers/MainReceiver.java b/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/receivers/MainReceiver.java index b2cf4a4..a226fe0 100644 --- a/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/receivers/MainReceiver.java +++ b/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/receivers/MainReceiver.java @@ -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()); diff --git a/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/services/AssistantService.java b/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/services/AssistantService.java index 54b83aa..c91a811 100644 --- a/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/services/AssistantService.java +++ b/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/services/AssistantService.java @@ -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(); } diff --git a/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/services/MainService.java b/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/services/MainService.java index 2531088..2a08f54 100644 --- a/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/services/MainService.java +++ b/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/services/MainService.java @@ -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 _APKModelList = new ArrayList(); 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(); + } + } } diff --git a/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/utils/NotificationUtil.java b/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/utils/NotificationUtil.java index 310d648..151648f 100644 --- a/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/utils/NotificationUtil.java +++ b/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/utils/NotificationUtil.java @@ -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) //设置红色 diff --git a/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/utils/PackageUtil.java b/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/utils/PackageUtil.java index 33fcdb0..8edc94d 100644 --- a/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/utils/PackageUtil.java +++ b/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/utils/PackageUtil.java @@ -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); + } + } + + } } diff --git a/autoinstaller/src/main/res/drawable/ic_android.xml b/autoinstaller/src/main/res/drawable/ic_android.xml new file mode 100644 index 0000000..6c69cd1 --- /dev/null +++ b/autoinstaller/src/main/res/drawable/ic_android.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/autoinstaller/src/main/res/drawable/ic_cloud.xml b/autoinstaller/src/main/res/drawable/ic_cloud.xml new file mode 100644 index 0000000..c116648 --- /dev/null +++ b/autoinstaller/src/main/res/drawable/ic_cloud.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/autoinstaller/src/main/res/drawable/ic_cloud_outline.xml b/autoinstaller/src/main/res/drawable/ic_cloud_outline.xml new file mode 100644 index 0000000..a8ed00c --- /dev/null +++ b/autoinstaller/src/main/res/drawable/ic_cloud_outline.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/autoinstaller/src/main/res/layout/activity_main.xml b/autoinstaller/src/main/res/layout/activity_main.xml index de79fc6..d4327fd 100644 --- a/autoinstaller/src/main/res/layout/activity_main.xml +++ b/autoinstaller/src/main/res/layout/activity_main.xml @@ -132,7 +132,7 @@ - AutoInstaller + AutoInstaller diff --git a/autoinstaller/src/main/res/values/styles.xml b/autoinstaller/src/main/res/values/styles.xml new file mode 100644 index 0000000..e11b9da --- /dev/null +++ b/autoinstaller/src/main/res/values/styles.xml @@ -0,0 +1,13 @@ + + + + + diff --git a/autoinstaller/src/main/res/values/themes.xml b/autoinstaller/src/main/res/values/themes.xml deleted file mode 100644 index 89d5280..0000000 --- a/autoinstaller/src/main/res/values/themes.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - \ No newline at end of file diff --git a/build.gradle b/build.gradle index ab63fe7..c73b4af 100644 --- a/build.gradle +++ b/build.gradle @@ -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/" } diff --git a/libaes/build.gradle b/libaes/build.gradle index 84124b2..6e72c8e 100644 --- a/libaes/build.gradle +++ b/libaes/build.gradle @@ -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' } diff --git a/libaes/build.properties b/libaes/build.properties index 83303dd..597a06b 100644 --- a/libaes/build.properties +++ b/libaes/build.properties @@ -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 diff --git a/libaes/src/main/AndroidManifest.xml b/libaes/src/main/AndroidManifest.xml index d8cbd79..7c90bad 100644 --- a/libaes/src/main/AndroidManifest.xml +++ b/libaes/src/main/AndroidManifest.xml @@ -5,27 +5,34 @@ - - - - - - - - + \ No newline at end of file diff --git a/libaes/src/main/java/cc/winboll/studio/libaes/beans/WinBoLLClientServiceBean.java b/libaes/src/main/java/cc/winboll/studio/libaes/beans/WinBoLLClientServiceBean.java new file mode 100644 index 0000000..32bb757 --- /dev/null +++ b/libaes/src/main/java/cc/winboll/studio/libaes/beans/WinBoLLClientServiceBean.java @@ -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(); + } +} diff --git a/libaes/src/main/java/cc/winboll/studio/libaes/winboll/AssistantService.java b/libaes/src/main/java/cc/winboll/studio/libaes/winboll/AssistantService.java index f2f8028..572a4aa 100644 --- a/libaes/src/main/java/cc/winboll/studio/libaes/winboll/AssistantService.java +++ b/libaes/src/main/java/cc/winboll/studio/libaes/winboll/AssistantService.java @@ -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 { diff --git a/libaes/src/main/java/cc/winboll/studio/libaes/winboll/WinBoLLClientService.java b/libaes/src/main/java/cc/winboll/studio/libaes/winboll/WinBoLLClientService.java new file mode 100644 index 0000000..d4e93a6 --- /dev/null +++ b/libaes/src/main/java/cc/winboll/studio/libaes/winboll/WinBoLLClientService.java @@ -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; + } + +} \ No newline at end of file diff --git a/libaes/src/main/java/cc/winboll/studio/libaes/winboll/WinBoLLServiceStatusView.java b/libaes/src/main/java/cc/winboll/studio/libaes/winboll/WinBoLLServiceStatusView.java new file mode 100644 index 0000000..14a56e2 --- /dev/null +++ b/libaes/src/main/java/cc/winboll/studio/libaes/winboll/WinBoLLServiceStatusView.java @@ -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) { + + } +} diff --git a/libappbase/build.properties b/libappbase/build.properties index faa715a..18395f7 100644 --- a/libappbase/build.properties +++ b/libappbase/build.properties @@ -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 diff --git a/libappbase/src/main/java/cc/winboll/studio/libappbase/sos/WinBoLL.java b/libappbase/src/main/java/cc/winboll/studio/libappbase/sos/WinBoLL.java deleted file mode 100644 index 080c7e0..0000000 --- a/libappbase/src/main/java/cc/winboll/studio/libappbase/sos/WinBoLL.java +++ /dev/null @@ -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); - } - -} diff --git a/libappbase/src/main/java/cc/winboll/studio/libappbase/winboll/IWinBoLLActivity.java b/libappbase/src/main/java/cc/winboll/studio/libappbase/winboll/IWinBoLLActivity.java deleted file mode 100644 index 4bed92a..0000000 --- a/libappbase/src/main/java/cc/winboll/studio/libappbase/winboll/IWinBoLLActivity.java +++ /dev/null @@ -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(); -} diff --git a/libappbase/src/main/java/cc/winboll/studio/libappbase/winboll/WinBoLLActivityManager.java b/libappbase/src/main/java/cc/winboll/studio/libappbase/winboll/WinBoLLActivityManager.java deleted file mode 100644 index 013ee8f..0000000 --- a/libappbase/src/main/java/cc/winboll/studio/libappbase/winboll/WinBoLLActivityManager.java +++ /dev/null @@ -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 _mapIWinBoLLList; - volatile IWinBoLLActivity mFirstIWinBoLLActivity; - - WinBoLLActivityManager(GlobalApplication application) { - mGlobalApplication = application; - _mapIWinBoLLList = new HashMap(); - } - - 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 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 void startWinBoLLActivity(Context context, Class clazz) { - try { - // 如果窗口已存在就重启窗口 - String tag = ((IWinBoLLActivity)clazz.newInstance()).getTag(); - LogUtils.d(TAG, String.format("startWinBoLLActivity(Context context, Class clazz) tag is %s", tag)); - if (isActive(tag)) { - resumeActivity(context, tag); - return; - } - //ToastUtils.show("startWinBoLLActivity(Context context, Class 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 void startWinBoLLActivity(Context context, Intent intent, Class clazz) { - try { - // 如果窗口已存在就重启窗口 - String tag = ((IWinBoLLActivity)clazz.newInstance()).getTag(); - LogUtils.d(TAG, String.format("startWinBoLLActivity(Context context, Intent intent, Class 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 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 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 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 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 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 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> iterator = _mapIWinBoLLList.entrySet().iterator(); - while (iterator.hasNext()) { - Map.Entry 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."); - } - } -} diff --git a/powerbell/build.properties b/powerbell/build.properties index d85e3c3..c6ca083 100644 --- a/powerbell/build.properties +++ b/powerbell/build.properties @@ -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 diff --git a/powerbell/src/main/java/cc/winboll/studio/powerbell/services/ControlCenterService.java b/powerbell/src/main/java/cc/winboll/studio/powerbell/services/ControlCenterService.java index 926fb71..d073071 100644 --- a/powerbell/src/main/java/cc/winboll/studio/powerbell/services/ControlCenterService.java +++ b/powerbell/src/main/java/cc/winboll/studio/powerbell/services/ControlCenterService.java @@ -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,9 +116,17 @@ public class ControlCenterService extends Service { mControlCenterServiceReceiver = new ControlCenterServiceReceiver(this); mControlCenterServiceReceiver.registerAction(this); } - startRemindThread(mAppConfigUtils.mAppConfigBean); - ToastUtils.show("Service Is Start."); - LogUtils.i(TAG, "Service Is Start."); + + 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); + } } diff --git a/powerbell/src/main/java/cc/winboll/studio/powerbell/utils/NotificationHelper.java b/powerbell/src/main/java/cc/winboll/studio/powerbell/utils/NotificationHelper.java index cc62c37..48b3816 100644 --- a/powerbell/src/main/java/cc/winboll/studio/powerbell/utils/NotificationHelper.java +++ b/powerbell/src/main/java/cc/winboll/studio/powerbell/utils/NotificationHelper.java @@ -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)