Skip to content

Commit 7524e4f

Browse files
Merge branch 'allow-errors' into dependabot/gradle/allow-errors/com.squareup.retrofit2-retrofit-3.0.0
2 parents e268ed4 + 74bc1c1 commit 7524e4f

File tree

33 files changed

+689
-214
lines changed

33 files changed

+689
-214
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ jobs:
7676
7777
- uses: r0adkll/[email protected]
7878
name: Sign app APK
79+
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push' || github.event_name == 'workflow_dispatch'
7980
id: sign_app
8081
with:
8182
releaseDirectory: app/build/outputs/apk/release
@@ -87,11 +88,18 @@ jobs:
8788
BUILD_TOOLS_VERSION: "35.0.0"
8889

8990
- name: Rename APK
91+
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push' || github.event_name == 'workflow_dispatch'
9092
run: |
9193
ls -al app/build/outputs/apk/release
9294
echo "Signed APK: ${{steps.sign_app.outputs.signedReleaseFile}}"
9395
cp ${{steps.sign_app.outputs.signedReleaseFile}} KernelFlasher_${{ env.NEW_VERSION_CODE }}.apk
9496
97+
- name: Rename APK
98+
if: github.repository != github.event.pull_request.head.repo.full_name && github.event_name == 'pull_request'
99+
run: |
100+
ls -al app/build/outputs/apk/release
101+
cp ./app/build/outputs/apk/release/app-release-unsigned.apk KernelFlasher_${{ env.NEW_VERSION_CODE }}.apk
102+
95103
- name: Upload APK
96104
uses: actions/[email protected]
97105
with:

app/build.gradle

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ android {
3333
}
3434
buildTypes {
3535
release {
36-
minifyEnabled false
36+
minifyEnabled true
37+
shrinkResources true
38+
zipAlignEnabled false
39+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
3740
}
3841
}
3942
sourceSets {
@@ -42,6 +45,7 @@ android {
4245
}
4346
}
4447
buildFeatures {
48+
compose true
4549
aidl true
4650
}
4751
compileOptions {
@@ -50,9 +54,8 @@ android {
5054
}
5155
kotlinOptions {
5256
jvmTarget = '17'
53-
}
54-
buildFeatures {
55-
compose true
57+
freeCompilerArgs += "-Xno-param-assertions"
58+
freeCompilerArgs += "-Xno-call-assertions"
5659
}
5760
composeOptions {
5861
kotlinCompilerExtensionVersion libs.versions.compose.compiler.get()
@@ -64,6 +67,12 @@ android {
6467
jniLibs {
6568
useLegacyPackaging true
6669
}
70+
dex {
71+
useLegacyPackaging true
72+
}
73+
}
74+
androidResources {
75+
generateLocaleConfig = true
6776
}
6877
namespace 'com.github.capntrips.kernelflasher'
6978
}

app/proguard-rules.pro

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# GENERAL
2+
-dontobfuscate
3+
-keepattributes Signature
4+
-keepattributes RuntimeVisibleAnnotations
5+
6+
# ANDROID INTERFACES / AIDL
7+
-keep class com.github.capntrips.kernelflasher.FilesystemService
8+
-keep class * implements android.os.IInterface
9+
-keepclassmembers class * {
10+
public static ** asInterface(android.os.IBinder);
11+
}
12+
13+
# Prevent R8 from stripping native methods used via JNI
14+
-keepclasseswithmembernames class * {
15+
native <methods>;
16+
}
17+
18+
# Keep RootShell library (libsu)
19+
-keep class com.topjohnwu.superuser.** { *; }
20+
21+
# RETROFIT2
22+
-keep interface com.github.capntrips.kernelflasher.GitHubApi { *; }
23+
-keep class retrofit2.** { *; }
24+
-dontwarn retrofit2.**
25+
26+
# ============ GSON ============
27+
-keep class com.google.gson.** { *; }
28+
-keep class com.github.capntrips.kernelflasher.AppUpdater$* { *; }
29+
30+
# Keep all fields/methods annotated with Gson's @SerializedName
31+
-keepclassmembers class * {
32+
@com.google.gson.annotations.SerializedName <fields>;
33+
}
34+
35+
# ============ KOTLIN ============
36+
-keep class kotlin.Metadata { *; }
37+
-keepattributes RuntimeVisibleAnnotations,RuntimeInvisibleAnnotations,RuntimeVisibleParameterAnnotations,RuntimeInvisibleParameterAnnotations,Exceptions,InnerClasses,EnclosingMethod,Signature,SourceFile,LineNumberTable,*Annotation*,Deprecated,SourceDir,CompilationID,LocalVariableTable,LocalVariableTypeTable,Module*
38+
-keepclassmembers class **.AppUpdater$GitHubRelease {
39+
<fields>;
40+
}
41+
-keepclassmembers class **.AppUpdater$GitHubAsset {
42+
<fields>;
43+
}
44+
45+
# ============ COROUTINES ============
46+
-keepclassmembers class kotlinx.coroutines.BuildConfig { public static final boolean DEBUG; }
47+
-keep class kotlinx.** { *; }
48+
-dontwarn kotlinx.**
49+
50+
# ============ DOWNLOAD MANAGER & BROADCAST RECEIVER ============
51+
-keep class com.github.capntrips.kernelflasher.AppUpdater { *; }
52+
-keepclassmembers class com.github.capntrips.kernelflasher.AppUpdater { *; }
53+
54+
# Keep VectorDrawableCompat to avoid crashes or inflation errors
55+
-keep class androidx.vectordrawable.graphics.drawable.VectorDrawableCompat { *; }

app/src/main/AndroidManifest.xml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,31 @@
1818
<activity
1919
android:name=".MainActivity"
2020
android:exported="true"
21+
android:launchMode="singleTop"
2122
android:theme="@style/Theme.MainSplashScreen">
2223
<intent-filter>
2324
<action android:name="android.intent.action.MAIN" />
24-
2525
<category android:name="android.intent.category.LAUNCHER" />
2626
</intent-filter>
27+
<intent-filter>
28+
<action android:name="android.intent.action.VIEW" />
29+
<category android:name="android.intent.category.DEFAULT" />
30+
<category android:name="android.intent.category.BROWSABLE" />
31+
<data android:scheme="content" android:mimeType="application/zip" />
32+
<data android:scheme="file" android:mimeType="application/zip" />
33+
</intent-filter>
34+
<intent-filter>
35+
<action android:name="android.intent.action.VIEW" />
36+
<category android:name="android.intent.category.DEFAULT" />
37+
<category android:name="android.intent.category.BROWSABLE" />
38+
<data android:mimeType="application/zip" />
39+
<data android:scheme="file" />
40+
<data android:scheme="content" />
41+
<data android:host="*" />
42+
<data android:pathPattern=".*\\.zip" />
43+
</intent-filter>
2744
</activity>
45+
<service android:name=".FilesystemService" android:exported="false" tools:ignore="Instantiatable" />
2846
</application>
2947

3048
</manifest>

app/src/main/assets/flash_ak3.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
#!/system/bin/sh
22

33
## setup for testing:
4-
unzip -p "$Z" tools*/busybox > $F/busybox;
4+
unzip -p "$Z" tools*/busybox > $F/busybox_ak;
55
unzip -p "$Z" META-INF/com/google/android/update-binary > $F/update-binary;
66
##
77

8-
chmod 755 $F/busybox;
8+
chmod 755 $F/busybox_ak;
9+
$F/busybox_ak >/dev/null 2>&1
10+
if [ $? -eq 0 ]; then
11+
mv $F/busybox $F/busybox_orig
12+
mv $F/busybox_ak $F/busybox
13+
fi
914
$F/busybox chmod 755 $F/update-binary;
1015
$F/busybox chown root:root $F/busybox $F/update-binary;
1116

@@ -18,6 +23,9 @@ $F/busybox mkdir -p $TMP;
1823
$F/busybox mount -t tmpfs -o noatime tmpfs $TMP;
1924
#$F/busybox mount | $F/busybox grep -q " $TMP " || exit 1;
2025

26+
PATTERN='\$[Bb][Bb] chmod -R 755 tools bin;';
27+
sed -i "/$PATTERN/i cp -f \"\$F/busybox\" \$AKHOME/tools;" "$F/update-binary";
28+
2129
# update-binary <RECOVERY_API_VERSION> <OUTFD> <ZIPFILE>
2230
AKHOME=$TMP/anykernel $F/busybox ash $F/update-binary 3 1 "$Z";
2331
RC=$?;
@@ -26,6 +34,7 @@ $F/busybox umount $TMP;
2634
$F/busybox rm -rf $TMP;
2735
$F/busybox mount -o ro,remount -t auto /;
2836
$F/busybox rm -f $F/update-binary $F/busybox;
37+
mv $F/busybox_orig $F/busybox
2938

3039
# work around libsu not cleanly accepting return or exit as last line
3140
safereturn() { return $RC; }

app/src/main/assets/flash_ak3_mkbootfs.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
#!/system/bin/sh
22

33
## setup for testing:
4-
unzip -p "$Z" tools*/busybox > $F/busybox;
4+
unzip -p "$Z" tools*/busybox > $F/busybox_ak;
55
unzip -p "$Z" META-INF/com/google/android/update-binary > $F/update-binary;
66
##
77

8-
chmod 755 $F/busybox;
8+
chmod 755 $F/busybox_ak;
9+
$F/busybox_ak >/dev/null 2>&1
10+
if [ $? -eq 0 ]; then
11+
mv $F/busybox $F/busybox_orig
12+
mv $F/busybox_ak $F/busybox
13+
fi
914
$F/busybox chmod 755 $F/update-binary;
1015
$F/busybox chown root:root $F/busybox $F/update-binary;
1116

@@ -20,6 +25,7 @@ $F/busybox mount -t tmpfs -o noatime tmpfs $TMP;
2025

2126
PATTERN='\$[Bb][Bb] chmod -R 755 tools bin;';
2227
sed -i "/$PATTERN/i cp -f \"\$F/mkbootfs\" \$AKHOME/tools;" "$F/update-binary";
28+
sed -i "/$PATTERN/i cp -f \"\$F/busybox\" \$AKHOME/tools;" "$F/update-binary";
2329

2430
# update-binary <RECOVERY_API_VERSION> <OUTFD> <ZIPFILE>
2531
AKHOME=$TMP/anykernel $F/busybox ash $F/update-binary 3 1 "$Z";
@@ -29,6 +35,7 @@ $F/busybox umount $TMP;
2935
$F/busybox rm -rf $TMP;
3036
$F/busybox mount -o ro,remount -t auto /;
3137
$F/busybox rm -f $F/update-binary $F/busybox;
38+
mv $F/busybox_orig $F/busybox
3239

3340
# work around libsu not cleanly accepting return or exit as last line
3441
safereturn() { return $RC; }

0 commit comments

Comments
 (0)