feat: complete reverse engineering, standard Maven structure, detailed code annotations and IoT-M platform architecture

This commit is contained in:
rick committed 2026-11-16 14:35:53 +08:00
1 parent e8dc09fb3c
commit cd6a4c70e7
3045 files changed
+566733 -1

No files matched your search

@@ -0,0 +1,229 @@
package com.midm.model.file;
import com.google.api.client.util.Strings;
import com.google.gson.annotations.Expose;
import com.midm.model.org.User;
import com.mitac.cell.db.DbObject;
import com.mitac.cell.io.McApkFile;
import com.mitac.cell.io.McFile;
import java.util.List;
import java.util.UUID;
import net.dongliu.apk.parser.bean.ApkMeta;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.Document;
@Document
public class AppFile extends BaseFile {
private DbObject appInfo;
private DbObject updateOptions;
@Transient
@Expose(
serialize = false
)
private boolean generateIcon;
public AppFile() {
this.generateIcon = true;
}
public AppFile(User user, UUID fileUuid, McFile file) {
this(user, fileUuid, file, true);
}
public AppFile(User user, UUID fileUuid, McFile file, boolean generateIcon) {
super(user, fileUuid, file);
this.generateIcon = true;
this.generateIcon = generateIcon;
this.setAppInfo(file);
}
public boolean isApk() {
return !Strings.isNullOrEmpty(this.getPackageName());
}
public boolean hasSystemPermission() {
return "android.uid.system".equals(this.getSharedUserId());
}
public DbObject getAppInfo() {
if (this.appInfo == null) {
this.appInfo = new DbObject();
}
return this.appInfo;
}
public void setAppInfo(DbObject appInfo) {
this.appInfo = appInfo;
}
public void setAppInfo(String key, Object value) {
this.getAppInfo().append(key, value);
}
public DbObject getUpdateOptions() {
if (this.updateOptions == null) {
this.updateOptions = new DbObject();
}
return this.updateOptions;
}
public void setUpdateOptions(DbObject updateOptions) {
this.updateOptions = updateOptions;
}
public void setUpdateOptions(String key, Object value) {
this.getUpdateOptions().append(key, value);
}
public boolean isMitacApp() {
return this.getPackageName().toLowerCase().contains("mitac");
}
public String getPackageName() {
return this.getAppInfo().getString("packageName");
}
public void setPackageName(String packageName) {
this.setAppInfo("packageName", packageName);
}
public String getSharedUserId() {
return this.getAppInfo().getString("sharedUid");
}
public void setSharedUserId(String sharedUid) {
if (!Strings.isNullOrEmpty(sharedUid)) {
this.setAppInfo("sharedUid", sharedUid);
}
}
public String getLabel() {
return this.getAppInfo().getString("label");
}
public void setLabel(String label) {
this.setAppInfo("label", label);
}
public String getIconName() {
return this.getAppInfo().getString("iconName");
}
public void setIconName(String iconName) {
this.setAppInfo("iconName", iconName);
}
public long getVersionCode() {
return this.getAppInfo().getLong("versionCode");
}
public void setVersionCode(long versionCode) {
this.setAppInfo("versionCode", versionCode);
}
public String getVersionName() {
return this.getAppInfo().getString("versionName");
}
public void setVersionName(String versionName) {
this.setAppInfo("versionName", versionName);
}
public int getMinSdkVersion() {
return this.getAppInfo().getInteger("minSdkVersion", -1);
}
public void setMinSdkVersion(String minSdkVersion) {
if (!Strings.isNullOrEmpty(minSdkVersion)) {
this.setMinSdkVersion(Integer.parseInt(minSdkVersion));
}
}
public void setMinSdkVersion(int minSdkVersion) {
this.setAppInfo("minSdkVersion", minSdkVersion);
}
public int getMaxSdkVersion() {
return this.getAppInfo().getInteger("maxSdkVersion", -1);
}
public void setMaxSdkVersion(String maxSdkVersion) {
if (!Strings.isNullOrEmpty(maxSdkVersion)) {
this.setAppInfo("maxSdkVersion", Integer.parseInt(maxSdkVersion));
}
}
public int getTargetSdkVersion() {
return this.getAppInfo().getInteger("targetSdkVersion", -1);
}
public void setTargetSdkVersion(String targetSdkVersion) {
if (Strings.isNullOrEmpty(targetSdkVersion)) {
this.getAppInfo().remove("targetSdkVersion");
} else {
this.setAppInfo("targetSdkVersion", Integer.parseInt(targetSdkVersion));
}
}
public List getUserPermission() {
return this.getAppInfo().getList("userPermission", String.class);
}
public void setUserPermission(List userPermission) {
this.setAppInfo("userPermission", userPermission);
}
public String getCertMd5() {
return this.getAppInfo().getString("certMd5");
}
public void setCertMd5(String certMd5) {
if (!Strings.isNullOrEmpty(certMd5)) {
this.setAppInfo("certMd5", certMd5);
}
}
public void setAppInfo(McFile file) {
try {
McApkFile apkFile = new McApkFile(file);
ApkMeta meta = apkFile.getApkMeta();
this.setSharedUserId(meta.getSharedUserId());
this.setPackageName(meta.getPackageName());
String label = meta.getLabel();
if (Strings.isNullOrEmpty(label)) {
label = meta.getPackageName();
}
this.setLabel(label);
this.setVersionCode(meta.getVersionCode());
this.setVersionName(meta.getVersionName());
this.setUserPermission(meta.getUsesPermissions());
this.setMinSdkVersion(meta.getMinSdkVersion());
this.setMaxSdkVersion(meta.getMaxSdkVersion());
this.setTargetSdkVersion(meta.getTargetSdkVersion());
this.setCertMd5(apkFile.getCertMd5());
this.setName(this.getLabel());
if (this.generateIcon) {
apkFile.saveIcon(file.getPath() + ".png");
}
apkFile.close();
} catch (Exception var5) {
}
}
public void minify() {
super.minify();
this.setUserPermission((List)null);
this.setTargetSdkVersion((String)null);
this.setVersionName((String)null);
}
}