use of io.github.muntashirakon.AppManager.details.struct.AppDetailsItem in project AppManager by MuntashirAkon.
the class AppDetailsViewModel method loadSignatures.
@SuppressWarnings("deprecation")
@WorkerThread
private void loadSignatures() {
List<AppDetailsItem<X509Certificate>> appDetailsItems = new ArrayList<>();
if (mApkFile == null) {
mSignatures.postValue(appDetailsItems);
return;
}
try {
File idsigFile = mApkFile.getIdsigFile();
ApkVerifier.Builder builder = new ApkVerifier.Builder(mApkFile.getBaseEntry().getRealCachedFile());
if (idsigFile != null) {
builder.setV4SignatureFile(idsigFile);
}
ApkVerifier apkVerifier = builder.build();
mApkVerifierResult = apkVerifier.verify();
// Get signer certificates
List<X509Certificate> certificates = mApkVerifierResult.getSignerCertificates();
if (certificates != null && certificates.size() > 0) {
for (X509Certificate certificate : certificates) {
AppDetailsItem<X509Certificate> item = new AppDetailsItem<>(certificate);
item.name = "Signer Certificate";
appDetailsItems.add(item);
}
if (mIsExternalApk && mPackageInfo.signatures == null) {
List<Signature> signatures = new ArrayList<>(certificates.size());
for (X509Certificate certificate : certificates) {
try {
signatures.add(new Signature(certificate.getEncoded()));
} catch (CertificateEncodingException ignore) {
}
}
mPackageInfo.signatures = signatures.toArray(new Signature[0]);
}
} else {
// noinspection ConstantConditions Null is deliberately set here to get at least one row
appDetailsItems.add(new AppDetailsItem<>(null));
}
// Get source stamp certificate
if (mApkVerifierResult.isSourceStampVerified()) {
ApkVerifier.Result.SourceStampInfo sourceStampInfo = mApkVerifierResult.getSourceStampInfo();
X509Certificate certificate = sourceStampInfo.getCertificate();
if (certificate != null) {
AppDetailsItem<X509Certificate> item = new AppDetailsItem<>(certificate);
item.name = "SourceStamp Certificate";
appDetailsItems.add(item);
}
}
SigningCertificateLineage lineage = mApkVerifierResult.getSigningCertificateLineage();
if (lineage != null) {
certificates = lineage.getCertificatesInLineage();
if (certificates != null && certificates.size() > 0) {
for (X509Certificate certificate : certificates) {
AppDetailsItem<X509Certificate> item = new AppDetailsItem<>(certificate);
item.name = "Certificate for Lineage";
appDetailsItems.add(item);
}
}
}
} catch (IOException | ApkFormatException | NoSuchAlgorithmException e) {
e.printStackTrace();
}
mSignatures.postValue(appDetailsItems);
}
use of io.github.muntashirakon.AppManager.details.struct.AppDetailsItem in project AppManager by MuntashirAkon.
the class AppDetailsViewModel method loadPermissions.
@WorkerThread
private void loadPermissions() {
synchronized (mPermissionItems) {
mPermissionItems.clear();
if (getPackageInfoInternal() == null || mPackageInfo.permissions == null) {
// No custom permissions
mPermissions.postValue(mPermissionItems);
return;
}
for (PermissionInfo permissionInfo : mPackageInfo.permissions) {
AppDetailsItem<PermissionInfo> appDetailsItem = new AppDetailsItem<>(permissionInfo);
appDetailsItem.name = permissionInfo.name;
mPermissionItems.add(appDetailsItem);
}
mPermissions.postValue(filterAndSortPermissions(mPermissionItems));
}
}
use of io.github.muntashirakon.AppManager.details.struct.AppDetailsItem in project AppManager by MuntashirAkon.
the class AppDetailsViewModel method loadConfigurations.
@WorkerThread
private void loadConfigurations() {
List<AppDetailsItem<ConfigurationInfo>> appDetailsItems = new ArrayList<>();
if (getPackageInfoInternal() == null || mPackageInfo.configPreferences != null) {
for (ConfigurationInfo configurationInfo : mPackageInfo.configPreferences) {
AppDetailsItem<ConfigurationInfo> appDetailsItem = new AppDetailsItem<>(configurationInfo);
appDetailsItems.add(appDetailsItem);
}
}
mConfigurations.postValue(appDetailsItems);
}
use of io.github.muntashirakon.AppManager.details.struct.AppDetailsItem in project AppManager by MuntashirAkon.
the class AppDetailsViewModel method loadSharedLibraries.
@WorkerThread
private void loadSharedLibraries() {
List<AppDetailsItem<?>> appDetailsItems = new ArrayList<>();
if (getPackageInfoInternal() == null) {
mSharedLibraries.postValue(appDetailsItems);
return;
}
ApplicationInfo info = mPackageInfo.applicationInfo;
if (info.sharedLibraryFiles != null) {
for (String sharedLibrary : info.sharedLibraryFiles) {
File sharedLib = new File(sharedLibrary);
AppDetailsItem<?> appDetailsItem = new AppDetailsItem<>(sharedLib);
appDetailsItem.name = sharedLib.getName();
appDetailsItems.add(appDetailsItem);
}
}
List<ApkFile.Entry> entries = mApkFile.getEntries();
for (ApkFile.Entry entry : entries) {
if (entry.type == ApkFile.APK_BASE || entry.type == ApkFile.APK_SPLIT_FEATURE || entry.type == ApkFile.APK_SPLIT_ABI || entry.type == ApkFile.APK_SPLIT_UNKNOWN) {
// Scan for .so files
NativeLibraries nativeLibraries;
try (InputStream is = entry.getRealInputStream()) {
try {
nativeLibraries = new NativeLibraries(is);
} catch (IOException e) {
// Maybe zip error, Try without InputStream
nativeLibraries = new NativeLibraries(entry.getRealCachedFile());
}
for (NativeLibraries.NativeLib nativeLib : nativeLibraries.getLibs()) {
AppDetailsItem<?> appDetailsItem = new AppDetailsItem<>(nativeLib);
appDetailsItem.name = nativeLib.getName();
appDetailsItems.add(appDetailsItem);
}
} catch (Throwable th) {
Log.e(TAG, th);
}
}
}
Collections.sort(appDetailsItems, (o1, o2) -> o1.name.compareToIgnoreCase(o2.name));
mSharedLibraries.postValue(appDetailsItems);
}
use of io.github.muntashirakon.AppManager.details.struct.AppDetailsItem in project AppManager by MuntashirAkon.
the class AppDetailsViewModel method loadFeatures.
@WorkerThread
private void loadFeatures() {
List<AppDetailsItem<FeatureInfo>> appDetailsItems = new ArrayList<>();
if (getPackageInfoInternal() == null || mPackageInfo.reqFeatures == null) {
// No required features
mFeatures.postValue(appDetailsItems);
return;
}
for (FeatureInfo fi : mPackageInfo.reqFeatures) {
if (fi.name == null)
fi.name = OPEN_GL_ES;
}
Arrays.sort(mPackageInfo.reqFeatures, (o1, o2) -> o1.name.compareToIgnoreCase(o2.name));
for (FeatureInfo featureInfo : mPackageInfo.reqFeatures) {
AppDetailsItem<FeatureInfo> appDetailsItem = new AppDetailsItem<>(featureInfo);
appDetailsItem.name = featureInfo.name;
appDetailsItems.add(appDetailsItem);
}
mFeatures.postValue(appDetailsItems);
}
Aggregations