feat: complete reverse engineering, standard Maven structure, detailed code annotations and IoT-M platform architecture
This commit is contained in:
1 parent
e8dc09fb3c
commit
cd6a4c70e7
3045 files changed
+566733
-1
No files matched your search
@@ -0,0 +1,289 @@
|
||||
package com.midm.model.device;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.midm.model.file.AppFile;
|
||||
import com.mitac.cell.db.DbObject;
|
||||
import com.mitac.cell.utils.McJsonUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
import org.springframework.data.mongodb.core.mapping.Field;
|
||||
|
||||
public class ProfileApps {
|
||||
private List install;
|
||||
@Transient
|
||||
@Expose(
|
||||
serialize = false
|
||||
)
|
||||
private List installApp;
|
||||
private List uninstall;
|
||||
@SerializedName("add_appwidget")
|
||||
@Field("add_appwidget")
|
||||
private List appWidget;
|
||||
private List widget;
|
||||
@SerializedName("grant_all")
|
||||
@Field("grant_all")
|
||||
private List grantAll;
|
||||
private List disabled;
|
||||
@SerializedName("wifi_only")
|
||||
@Field("wifi_only")
|
||||
private List wifiOnly;
|
||||
@SerializedName("white_list")
|
||||
@Field("white_list")
|
||||
private List whiteList;
|
||||
@SerializedName("black_list")
|
||||
@Field("black_list")
|
||||
private List blackList;
|
||||
|
||||
public List getInstall() {
|
||||
return this.install;
|
||||
}
|
||||
|
||||
public void setInstall(List install) {
|
||||
this.install = install;
|
||||
}
|
||||
|
||||
public void setToOldFormat() {
|
||||
this.install = this.getInstallUuids();
|
||||
}
|
||||
|
||||
public List getInstallApp() {
|
||||
if (this.installApp == null && this.install != null) {
|
||||
this.initInstallApp();
|
||||
}
|
||||
|
||||
return this.installApp;
|
||||
}
|
||||
|
||||
public void initInstallApp() {
|
||||
if (this.install != null && !this.install.isEmpty()) {
|
||||
if (this.install.get(0) instanceof InstallApp) {
|
||||
this.installApp = this.install;
|
||||
} else {
|
||||
this.installApp = (List)McJsonUtils.toObject(McJsonUtils.toJsonElement(this.install), (new TypeToken() {
|
||||
}).getType());
|
||||
this.install = this.installApp;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setInstallApp(List installApp) {
|
||||
this.installApp = installApp;
|
||||
}
|
||||
|
||||
public boolean hasInstallApps() {
|
||||
this.getInstallApp();
|
||||
return this.installApp != null && !this.installApp.isEmpty();
|
||||
}
|
||||
|
||||
public InstallApp getInstallApp(String packageName) {
|
||||
if (!this.hasInstallApps()) {
|
||||
return null;
|
||||
} else {
|
||||
for(InstallApp app : this.installApp) {
|
||||
if (packageName.equals(app.getPackageName())) {
|
||||
return app;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean removeInstallApp(UUID appUuid) {
|
||||
if (this.hasInstallApps()) {
|
||||
Iterator<InstallApp> it = this.installApp.iterator();
|
||||
|
||||
while(it.hasNext()) {
|
||||
if (((InstallApp)it.next()).uuid.equals(appUuid)) {
|
||||
it.remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public List getInstallUuids() {
|
||||
return this.installApp != null ? (List)this.installApp.stream().map((app) -> app.getUuid()).collect(Collectors.toList()) : null;
|
||||
}
|
||||
|
||||
public List getUninstall() {
|
||||
return this.toDbList(this.uninstall);
|
||||
}
|
||||
|
||||
public void setUninstall(List uninstall) {
|
||||
this.uninstall = uninstall;
|
||||
}
|
||||
|
||||
public List getAppWidget() {
|
||||
return this.appWidget;
|
||||
}
|
||||
|
||||
public void setAppWidget(List addAppWidget) {
|
||||
this.appWidget = addAppWidget;
|
||||
}
|
||||
|
||||
public List getWidget() {
|
||||
return this.widget;
|
||||
}
|
||||
|
||||
public void setWidget(List widget) {
|
||||
this.widget = widget;
|
||||
}
|
||||
|
||||
public List getGrantAll() {
|
||||
return this.toDbList(this.grantAll);
|
||||
}
|
||||
|
||||
public void setGrantAll(List grantAll) {
|
||||
this.grantAll = grantAll;
|
||||
}
|
||||
|
||||
public List getDisabled() {
|
||||
return this.toDbList(this.disabled);
|
||||
}
|
||||
|
||||
public void setDisabled(List disabled) {
|
||||
this.disabled = disabled;
|
||||
}
|
||||
|
||||
public List getWifiOnly() {
|
||||
return this.toDbList(this.wifiOnly);
|
||||
}
|
||||
|
||||
public void setWifiOnly(List wifiOnly) {
|
||||
this.wifiOnly = wifiOnly;
|
||||
}
|
||||
|
||||
public List getWhiteList() {
|
||||
return this.toDbList(this.whiteList);
|
||||
}
|
||||
|
||||
public void setWhiteList(List whiteList) {
|
||||
this.whiteList = whiteList;
|
||||
}
|
||||
|
||||
public List getBlackList() {
|
||||
return this.toDbList(this.blackList);
|
||||
}
|
||||
|
||||
public void setBlackList(List blackList) {
|
||||
this.blackList = blackList;
|
||||
}
|
||||
|
||||
public List getPackageList(List apps) {
|
||||
return apps != null ? (List)apps.stream().map((app) -> app.getString("package")).collect(Collectors.toList()) : null;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return (this.install == null || this.install.isEmpty()) && (this.uninstall == null || this.uninstall.isEmpty()) && (this.appWidget == null || this.appWidget.isEmpty()) && (this.widget == null || this.widget.isEmpty()) && (this.grantAll == null || this.grantAll.isEmpty()) && (this.disabled == null || this.disabled.isEmpty()) && (this.wifiOnly == null || this.wifiOnly.isEmpty()) && (this.whiteList == null || this.whiteList.isEmpty()) && (this.blackList == null || this.blackList.isEmpty());
|
||||
}
|
||||
|
||||
private List toDbList(List list) {
|
||||
if (list != null && !list.isEmpty()) {
|
||||
List<DbObject> dbList = new ArrayList();
|
||||
list.forEach((item) -> {
|
||||
if (item instanceof DbObject) {
|
||||
dbList.add((DbObject)item);
|
||||
} else if (item instanceof Map) {
|
||||
dbList.add(new DbObject((Map)item));
|
||||
}
|
||||
|
||||
});
|
||||
return dbList;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class InstallApp {
|
||||
private UUID uuid;
|
||||
private String packageName;
|
||||
@SerializedName("silent_install")
|
||||
@Field("silent_install")
|
||||
private Boolean silentInstall = true;
|
||||
@SerializedName("grant_all")
|
||||
@Field("grant_all")
|
||||
private Boolean grantAll = false;
|
||||
@SerializedName("starts_on_update")
|
||||
@Field("starts_on_update")
|
||||
private Boolean startsOnUpdate = false;
|
||||
@SerializedName("reboots_on_update")
|
||||
@Field("reboots_on_update")
|
||||
private Boolean rebootsOnUpdate = false;
|
||||
|
||||
public InstallApp() {
|
||||
}
|
||||
|
||||
public InstallApp(AppFile appFile) {
|
||||
this.uuid = appFile.getFileUuid();
|
||||
this.packageName = appFile.getPackageName();
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
public void setUuid(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return this.packageName;
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
||||
public Boolean getSilentInstall() {
|
||||
return this.silentInstall;
|
||||
}
|
||||
|
||||
public void setSilentInstall(Boolean silentInstall) {
|
||||
this.silentInstall = silentInstall;
|
||||
}
|
||||
|
||||
public Boolean getGrantAll() {
|
||||
return this.grantAll;
|
||||
}
|
||||
|
||||
public void setGrantAll(Boolean grantAll) {
|
||||
this.grantAll = grantAll;
|
||||
}
|
||||
|
||||
public Boolean getStartsOnUpdate() {
|
||||
return this.startsOnUpdate;
|
||||
}
|
||||
|
||||
public void setStartsOnUpdate(Boolean startsOnUpdate) {
|
||||
this.startsOnUpdate = startsOnUpdate;
|
||||
}
|
||||
|
||||
public Boolean getRebootsOnUpdate() {
|
||||
return this.rebootsOnUpdate;
|
||||
}
|
||||
|
||||
public void setRebootsOnUpdate(Boolean rebootsOnUpdate) {
|
||||
this.rebootsOnUpdate = rebootsOnUpdate;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof InstallApp)) {
|
||||
return false;
|
||||
} else {
|
||||
InstallApp installApp = (InstallApp)obj;
|
||||
return this.uuid.equals(installApp.uuid) && this.packageName.equals(installApp.packageName) && this.silentInstall == installApp.silentInstall && this.grantAll == installApp.grantAll && this.startsOnUpdate == installApp.startsOnUpdate && this.rebootsOnUpdate == installApp.rebootsOnUpdate;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user