更新应用打开按钮的启动数据。
This commit is contained in:
parent
b64a229ab1
commit
df55608eb3
@ -29,7 +29,7 @@ android {
|
|||||||
// versionName 更新后需要手动设置
|
// versionName 更新后需要手动设置
|
||||||
// .winboll/winbollBuildProps.properties 文件的 stageCount=0
|
// .winboll/winbollBuildProps.properties 文件的 stageCount=0
|
||||||
// Gradle编译环境下合起来的 versionName 就是 "${versionName}.0"
|
// Gradle编译环境下合起来的 versionName 就是 "${versionName}.0"
|
||||||
versionName "15.0"
|
versionName "15.2"
|
||||||
if(true) {
|
if(true) {
|
||||||
versionName = genVersionName("${versionName}")
|
versionName = genVersionName("${versionName}")
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Wed Apr 02 12:47:46 GMT 2025
|
#Wed Apr 02 13:23:10 GMT 2025
|
||||||
stageCount=1
|
stageCount=0
|
||||||
libraryProject=
|
libraryProject=
|
||||||
baseVersion=15.0
|
baseVersion=15.2
|
||||||
publishVersion=15.0.0
|
publishVersion=15.2.0
|
||||||
buildCount=7
|
buildCount=3
|
||||||
baseBetaVersion=15.0.1
|
baseBetaVersion=15.2.1
|
||||||
|
@ -2,7 +2,6 @@ package cc.winboll.studio.autoinstaller;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
@ -15,6 +14,7 @@ import android.widget.Switch;
|
|||||||
import android.widget.TextClock;
|
import android.widget.TextClock;
|
||||||
import androidx.core.content.FileProvider;
|
import androidx.core.content.FileProvider;
|
||||||
import cc.winboll.studio.autoinstaller.MainActivity;
|
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.models.AppConfigs;
|
||||||
import cc.winboll.studio.autoinstaller.services.MainService;
|
import cc.winboll.studio.autoinstaller.services.MainService;
|
||||||
import cc.winboll.studio.autoinstaller.utils.NotificationUtil;
|
import cc.winboll.studio.autoinstaller.utils.NotificationUtil;
|
||||||
@ -32,6 +32,7 @@ public class MainActivity extends Activity {
|
|||||||
|
|
||||||
private static final int INSTALL_PERMISSION_CODE = 1;
|
private static final int INSTALL_PERMISSION_CODE = 1;
|
||||||
|
|
||||||
|
ArrayList<APKModel> _APKModelList = new ArrayList<APKModel>();
|
||||||
LogView mLogView;
|
LogView mLogView;
|
||||||
TextClock mTextClock;
|
TextClock mTextClock;
|
||||||
EditText mEditText;
|
EditText mEditText;
|
||||||
@ -131,8 +132,17 @@ 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) {
|
public void onOpenAPP(View view) {
|
||||||
if (mszInstalledPackageName.trim().equals("")) {
|
String szInstalledPackageName = getLastApkPackageName();
|
||||||
|
if (szInstalledPackageName.trim().equals("")) {
|
||||||
ToastUtils.show("Installed APP package name is null.");
|
ToastUtils.show("Installed APP package name is null.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -252,8 +262,6 @@ public class MainActivity extends Activity {
|
|||||||
Intent intentService = new Intent(MainActivity.this, MainService.class);
|
Intent intentService = new Intent(MainActivity.this, MainService.class);
|
||||||
//intentService.putExtra(MainService.EXTRA_APKFILEPATH, szAPKFilePath);
|
//intentService.putExtra(MainService.EXTRA_APKFILEPATH, szAPKFilePath);
|
||||||
startService(intentService);
|
startService(intentService);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -14,6 +14,7 @@ import android.widget.Toast;
|
|||||||
import androidx.core.content.FileProvider;
|
import androidx.core.content.FileProvider;
|
||||||
import cc.winboll.studio.autoinstaller.FileListener;
|
import cc.winboll.studio.autoinstaller.FileListener;
|
||||||
import cc.winboll.studio.autoinstaller.MainActivity;
|
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.models.AppConfigs;
|
||||||
import cc.winboll.studio.autoinstaller.services.AssistantService;
|
import cc.winboll.studio.autoinstaller.services.AssistantService;
|
||||||
import cc.winboll.studio.autoinstaller.services.MainService;
|
import cc.winboll.studio.autoinstaller.services.MainService;
|
||||||
@ -24,11 +25,13 @@ import cc.winboll.studio.libappbase.LogUtils;
|
|||||||
import com.hjq.toast.ToastUtils;
|
import com.hjq.toast.ToastUtils;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class MainService extends Service {
|
public class MainService extends Service {
|
||||||
|
|
||||||
public static String TAG = "MainService";
|
public static String TAG = "MainService";
|
||||||
|
|
||||||
|
ArrayList<APKModel> _APKModelList = new ArrayList<APKModel>();
|
||||||
private static boolean _mIsServiceAlive;
|
private static boolean _mIsServiceAlive;
|
||||||
//String mszAPKFilePath;
|
//String mszAPKFilePath;
|
||||||
//String mszAPKFileName;
|
//String mszAPKFileName;
|
||||||
@ -177,6 +180,9 @@ public class MainService extends Service {
|
|||||||
// 调用[应用信息查看器]打开应用包
|
// 调用[应用信息查看器]打开应用包
|
||||||
//
|
//
|
||||||
private void installAPK(String szAPKFilePath) {
|
private void installAPK(String szAPKFilePath) {
|
||||||
|
String szAPKPackageName = PackageUtil.getPackageNameFromApk(this, szAPKFilePath);
|
||||||
|
saveAPKInfo(szAPKPackageName);
|
||||||
|
|
||||||
long nTimeNow = System.currentTimeMillis();
|
long nTimeNow = System.currentTimeMillis();
|
||||||
/*SimpleDateFormat dateFormat = new SimpleDateFormat(
|
/*SimpleDateFormat dateFormat = new SimpleDateFormat(
|
||||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault());
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault());
|
||||||
@ -211,15 +217,24 @@ public class MainService extends Service {
|
|||||||
//
|
//
|
||||||
void installAPK2(String szAPKFilePath) {
|
void installAPK2(String szAPKFilePath) {
|
||||||
LogUtils.d(TAG, "installAPK2()");
|
LogUtils.d(TAG, "installAPK2()");
|
||||||
|
String szAPKPackageName = PackageUtil.getPackageNameFromApk(this, szAPKFilePath);
|
||||||
|
saveAPKInfo(szAPKPackageName);
|
||||||
|
|
||||||
Intent intent = new Intent(this, MainActivity.class);
|
Intent intent = new Intent(this, MainActivity.class);
|
||||||
intent.setAction(MainActivity.ACTION_NEW_INSTALLTASK);
|
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.putExtra(MainActivity.EXTRA_INSTALLED_APKFILEPATH, szAPKFilePath);
|
||||||
// Intent.ACTION_VIEW);
|
// Intent.ACTION_VIEW);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
this.startActivity(intent);
|
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 {
|
static class MyHandler extends Handler {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user