This commit is contained in:
isPointer
2026-06-10 05:04:29 +06:00
committed by GitHub
parent 60b7f208bf
commit a354b2ca67
@@ -1,108 +1,100 @@
package com.antik.manifest;
import com.reandroid.apk.ApkModule;
import com.reandroid.app.AndroidManifest;
import com.reandroid.arsc.chunk.xml.AndroidManifestBlock;
import com.reandroid.arsc.chunk.xml.ResXmlElement;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@SuppressWarnings({"unchecked", "rawtypes"})
public class manifestP {
@SuppressWarnings({"unchecked", "rawtypes"})
public static void patch(ApkModule m) throws Exception {
public static void patch(ApkModule m) {
AndroidManifestBlock mf = m.getAndroidManifest();
if (mf == null)
{
return;
}
Boolean e = mf.isExtractNativeLibs();
if (e != null && e.booleanValue() == false) {
mf.setExtractNativeLibs(true);
if (mf == null) {
return;
}
ResXmlElement m_e = mf.getManifestElement();
if (m_e != null)
{
m_e.removeAttributesWithName("requiredSplitTypes");
m_e.removeAttributesWithName("splitTypes");
Boolean extractNativeLibs = mf.isExtractNativeLibs();
if (extractNativeLibs != null && !extractNativeLibs) {
mf.setExtractNativeLibs(true);
}
List md_r = Arrays.asList(new String[]{"com.android.stamp.source", "com.android.stamp.type", "com.android.vending.splits", "com.android.vending.derived.apk.id", "com.android.dynamic.apk.fused.modules", "com.android.vending.splits.required"});
ResXmlElement M_Element = mf.getManifestElement();
List act_r = Arrays.asList(new String[]{"com.pairip.licensecheck.LicenseActivity"});
if (M_Element != null) {
List pv_r = Arrays.asList(new String[]{"com.pairip.licensecheck.LicenseContentProvider"});
M_Element.removeAttributesWithId(AndroidManifest.ID_requiredSplitTypes);
M_Element.removeAttributesWithId(AndroidManifest.ID_splitTypes);
M_Element.removeAttributesWithId(AndroidManifest.ID_isSplitRequired);
M_Element.removeAttributesWithId(AndroidManifest.ID_isFeatureSplit);
Iterator i = mf.getApplicationElementsByTag("meta-data");
List rm_ls = new ArrayList();
while (i.hasNext()) {
ResXmlElement el = (ResXmlElement) i.next();
String n = AndroidManifestBlock.getAndroidNameValue(el);
if (md_r.contains(n)) {
rm_ls.add(el);
}
M_Element.removeAttributesWithName("requiredSplitTypes");
M_Element.removeAttributesWithName("splitTypes");
M_Element.removeAttributesWithName("isSplitRequired");
M_Element.removeAttributesWithName("isFeatureSplit");
M_Element.removeAttributesWithName("split");
}
int x = 0;
for (; x < rm_ls.size(); x = x + 1) {
ResXmlElement el = (ResXmlElement) rm_ls.get(x);
el.removeSelf();
}
List<String> metaDataToRemove = Arrays.asList(
"com.android.stamp.source",
"com.android.stamp.type",
"com.android.vending.splits",
"com.android.vending.derived.apk.id",
"com.android.dynamic.apk.fused.modules",
"com.android.vending.splits.required"
);
rm_ls.clear();
List<String> activitiesToRemove = Collections.singletonList(
"com.pairip.licensecheck.LicenseActivity"
);
i = mf.getApplicationElementsByTag("activity");
List<String> providersToRemove = Collections.singletonList(
"com.pairip.licensecheck.LicenseContentProvider"
);
while (i.hasNext()) {
List<String> permissionsToRemove = Collections.singletonList(
"com.android.vending.CHECK_LICENSE"
);
ResXmlElement el = (ResXmlElement) i.next();
RElementsByName(mf, "meta-data", metaDataToRemove);
String n = AndroidManifestBlock.getAndroidNameValue(el);
RElementsByName(mf, "activity", activitiesToRemove);
if (act_r.contains(n)) {
rm_ls.add(el);
}
}
RElementsByName(mf, "provider", providersToRemove);
for (x = 0; x < rm_ls.size(); x = x + 1) {
ResXmlElement el = (ResXmlElement) rm_ls.get(x);
el.removeSelf();
}
rm_ls.clear();
i = mf.getApplicationElementsByTag("provider");
while (i.hasNext()) {
ResXmlElement el = (ResXmlElement) i.next();
String n = AndroidManifestBlock.getAndroidNameValue(el);
if (pv_r.contains(n)) {
rm_ls.add(el);
}
}
for (x = 0; x < rm_ls.size(); x++) {
ResXmlElement el = (ResXmlElement) rm_ls.get(x);
el.removeSelf();
}
RElementsByName(mf, "uses-permission", permissionsToRemove);
m.setManifest(mf);
}
}
private static void RElementsByName(AndroidManifestBlock mf, String tag, List<String> namesToRemove) {
Iterator<ResXmlElement> Y_rator;
if ("uses-permission".equals(tag)) {
Y_rator = mf.getManifestElement().getElements(tag);
} else {
Y_rator = mf.getApplicationElementsByTag(tag);
}
List<ResXmlElement> elementsToRemove = new ArrayList<>();
while (Y_rator.hasNext()) {
ResXmlElement element = Y_rator.next();
String name = AndroidManifestBlock.getAndroidNameValue(element);
if (namesToRemove.contains(name)) {
elementsToRemove.add(element);
}
}
for (ResXmlElement element : elementsToRemove) {
element.removeSelf();
}
}
}