diff --git a/autoinstaller/build.gradle b/autoinstaller/build.gradle index a17dbc7..75ba7ae 100644 --- a/autoinstaller/build.gradle +++ b/autoinstaller/build.gradle @@ -29,7 +29,7 @@ android { // versionName 更新后需要手动设置 // .winboll/winbollBuildProps.properties 文件的 stageCount=0 // Gradle编译环境下合起来的 versionName 就是 "${versionName}.0" - versionName "15.0" + versionName "15.2" if(true) { versionName = genVersionName("${versionName}") } diff --git a/autoinstaller/build.properties b/autoinstaller/build.properties index d068ef7..4398898 100644 --- a/autoinstaller/build.properties +++ b/autoinstaller/build.properties @@ -1,8 +1,8 @@ #Created by .winboll/winboll_app_build.gradle -#Wed Apr 02 12:47:46 GMT 2025 -stageCount=1 +#Wed Apr 02 13:23:10 GMT 2025 +stageCount=0 libraryProject= -baseVersion=15.0 -publishVersion=15.0.0 -buildCount=7 -baseBetaVersion=15.0.1 +baseVersion=15.2 +publishVersion=15.2.0 +buildCount=3 +baseBetaVersion=15.2.1 diff --git a/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/MainActivity.java b/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/MainActivity.java index 3b5356e..63aefc3 100644 --- a/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/MainActivity.java +++ b/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/MainActivity.java @@ -2,7 +2,6 @@ package cc.winboll.studio.autoinstaller; import android.app.Activity; import android.content.Intent; -import android.content.pm.PackageManager; import android.graphics.Color; import android.net.Uri; import android.os.Build; @@ -15,6 +14,7 @@ import android.widget.Switch; import android.widget.TextClock; import androidx.core.content.FileProvider; import cc.winboll.studio.autoinstaller.MainActivity; +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; @@ -31,7 +31,8 @@ public class MainActivity extends Activity { public static final String TAG = "MainActivity"; private static final int INSTALL_PERMISSION_CODE = 1; - + + ArrayList _APKModelList = new ArrayList(); LogView mLogView; TextClock mTextClock; EditText mEditText; @@ -131,12 +132,21 @@ 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(); + if (szInstalledPackageName.trim().equals("")) { ToastUtils.show("Installed APP package name is null."); return; } - + Intent intent = getPackageManager().getLaunchIntentForPackage(mszInstalledPackageName); if (intent != null) { //ToastUtils.show("startActivity"); @@ -252,8 +262,6 @@ public class MainActivity extends Activity { Intent intentService = new Intent(MainActivity.this, MainService.class); //intentService.putExtra(MainService.EXTRA_APKFILEPATH, szAPKFilePath); startService(intentService); - - } /* 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/services/MainService.java b/autoinstaller/src/main/java/cc/winboll/studio/autoinstaller/services/MainService.java index 6c06133..5370b69 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 @@ -14,6 +14,7 @@ import android.widget.Toast; import androidx.core.content.FileProvider; import cc.winboll.studio.autoinstaller.FileListener; import cc.winboll.studio.autoinstaller.MainActivity; +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; @@ -24,11 +25,13 @@ import cc.winboll.studio.libappbase.LogUtils; import com.hjq.toast.ToastUtils; import java.io.File; import java.lang.ref.WeakReference; +import java.util.ArrayList; public class MainService extends Service { public static String TAG = "MainService"; + ArrayList _APKModelList = new ArrayList(); private static boolean _mIsServiceAlive; //String mszAPKFilePath; //String mszAPKFileName; @@ -177,6 +180,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()); @@ -211,15 +217,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 {