如何在 spring 引导应用程序中读取和存储 apk 元数据
How to read and store apk metadata in spring boot application
我们正在开发 Android 商店。它是基于 Spring 的后端原型,我们使用开源项目 Aurora 的客户端:https://gitlab.com/AuroraOSS/AuroraStore
我们必须在 Nexus 中存储一些关于我们上传的 apk 的信息。
我们的第一个问题是如何在 Spring 应用程序中读取 AndroidManifest.xml?有没有可用的maven模块?
第二个问题是我们如何管理数据库中的 Android 信息?例如,在 Android Studio 下,我们有通常用于 Java Android 项目的 PackageInfo。但是我们必须为应用程序存储这些信息吗?我们怎么点它?
package android.content.pm;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable.Creator;
import androidx.annotation.RecentlyNonNull;
public class PackageInfo implements Parcelable {
@RecentlyNonNull
public static final Creator<PackageInfo> CREATOR = null;
public static final int INSTALL_LOCATION_AUTO = 0;
public static final int INSTALL_LOCATION_INTERNAL_ONLY = 1;
public static final int INSTALL_LOCATION_PREFER_EXTERNAL = 2;
public static final int REQUESTED_PERMISSION_GRANTED = 2;
public ActivityInfo[] activities;
public ApplicationInfo applicationInfo;
public int baseRevisionCode;
public ConfigurationInfo[] configPreferences;
public FeatureGroupInfo[] featureGroups;
public long firstInstallTime;
public int[] gids;
public int installLocation = 1;
public InstrumentationInfo[] instrumentation;
public boolean isApex;
public long lastUpdateTime;
public String packageName;
public PermissionInfo[] permissions;
public ProviderInfo[] providers;
public ActivityInfo[] receivers;
public FeatureInfo[] reqFeatures;
public String[] requestedPermissions;
public int[] requestedPermissionsFlags;
public ServiceInfo[] services;
public String sharedUserId;
public int sharedUserLabel;
/** @deprecated */
@Deprecated
public Signature[] signatures;
public SigningInfo signingInfo;
public String[] splitNames;
public int[] splitRevisionCodes;
/** @deprecated */
@Deprecated
public int versionCode;
public String versionName;
public PackageInfo() {
throw new RuntimeException("Stub!");
}
public long getLongVersionCode() {
throw new RuntimeException("Stub!");
}
public void setLongVersionCode(long longVersionCode) {
throw new RuntimeException("Stub!");
}
public String toString() {
throw new RuntimeException("Stub!");
}
public int describeContents() {
throw new RuntimeException("Stub!");
}
public void writeToParcel(Parcel dest, int parcelableFlags) {
throw new RuntimeException("Stub!");
}
}
提前致谢。
编辑:
要读取 apk 元数据,我们找到了这个模块:
https://github.com/hsiafan/apk-parser
<dependency>
<groupId>net.dongliu</groupId>
<artifactId>apk-parser</artifactId>
<version>2.6.9</version>
</dependency>
我们找到这个插件https://github.com/hsiafan/apk-parser来解析信息。
<dependency>
<groupId>net.dongliu</groupId>
<artifactId>apk-parser</artifactId>
<version>2.6.9</version>
</dependency>
然后根据提供的文档,我们检索所有信息并保存在数据库中
我们正在开发 Android 商店。它是基于 Spring 的后端原型,我们使用开源项目 Aurora 的客户端:https://gitlab.com/AuroraOSS/AuroraStore
我们必须在 Nexus 中存储一些关于我们上传的 apk 的信息。 我们的第一个问题是如何在 Spring 应用程序中读取 AndroidManifest.xml?有没有可用的maven模块?
第二个问题是我们如何管理数据库中的 Android 信息?例如,在 Android Studio 下,我们有通常用于 Java Android 项目的 PackageInfo。但是我们必须为应用程序存储这些信息吗?我们怎么点它?
package android.content.pm;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable.Creator;
import androidx.annotation.RecentlyNonNull;
public class PackageInfo implements Parcelable {
@RecentlyNonNull
public static final Creator<PackageInfo> CREATOR = null;
public static final int INSTALL_LOCATION_AUTO = 0;
public static final int INSTALL_LOCATION_INTERNAL_ONLY = 1;
public static final int INSTALL_LOCATION_PREFER_EXTERNAL = 2;
public static final int REQUESTED_PERMISSION_GRANTED = 2;
public ActivityInfo[] activities;
public ApplicationInfo applicationInfo;
public int baseRevisionCode;
public ConfigurationInfo[] configPreferences;
public FeatureGroupInfo[] featureGroups;
public long firstInstallTime;
public int[] gids;
public int installLocation = 1;
public InstrumentationInfo[] instrumentation;
public boolean isApex;
public long lastUpdateTime;
public String packageName;
public PermissionInfo[] permissions;
public ProviderInfo[] providers;
public ActivityInfo[] receivers;
public FeatureInfo[] reqFeatures;
public String[] requestedPermissions;
public int[] requestedPermissionsFlags;
public ServiceInfo[] services;
public String sharedUserId;
public int sharedUserLabel;
/** @deprecated */
@Deprecated
public Signature[] signatures;
public SigningInfo signingInfo;
public String[] splitNames;
public int[] splitRevisionCodes;
/** @deprecated */
@Deprecated
public int versionCode;
public String versionName;
public PackageInfo() {
throw new RuntimeException("Stub!");
}
public long getLongVersionCode() {
throw new RuntimeException("Stub!");
}
public void setLongVersionCode(long longVersionCode) {
throw new RuntimeException("Stub!");
}
public String toString() {
throw new RuntimeException("Stub!");
}
public int describeContents() {
throw new RuntimeException("Stub!");
}
public void writeToParcel(Parcel dest, int parcelableFlags) {
throw new RuntimeException("Stub!");
}
}
提前致谢。
编辑: 要读取 apk 元数据,我们找到了这个模块: https://github.com/hsiafan/apk-parser
<dependency>
<groupId>net.dongliu</groupId>
<artifactId>apk-parser</artifactId>
<version>2.6.9</version>
</dependency>
我们找到这个插件https://github.com/hsiafan/apk-parser来解析信息。
<dependency>
<groupId>net.dongliu</groupId>
<artifactId>apk-parser</artifactId>
<version>2.6.9</version>
</dependency>
然后根据提供的文档,我们检索所有信息并保存在数据库中