Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit 37227ad

Browse files
committed
Major installer rework + rework AnyKernel3 install system.
1 parent 19182a2 commit 37227ad

File tree

7 files changed

+182
-75
lines changed

7 files changed

+182
-75
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
## AnyKernel3 (AK3), and AnyKernel2/AnyKernel 2.0 (AK2) Scripts License:
2+
#
3+
# AnyKernel (versions 2.0/2 and later) Android image modifying scripts.
4+
# Copyright (c) 2019 Chris Renshaw (osm0sis @ xda-developers),
5+
# and additional contributors per readily available commit history/credits.
6+
# All rights reserved.
7+
#
8+
# Redistribution and use in source and binary forms, with or without
9+
# modification, are permitted (subject to the limitations in the disclaimer
10+
# below) provided that the following conditions are met:
11+
#
12+
# * Redistributions of source code must retain the above copyright notice,
13+
# this list of conditions and the following disclaimer.
14+
#
15+
# * Redistributions in binary form must reproduce the above copyright
16+
# notice, this list of conditions and the following disclaimer in the
17+
# documentation and/or other materials provided with the distribution.
18+
#
19+
# * Neither the name of the copyright holder nor the names of its
20+
# contributors may be used to endorse or promote products derived from this
21+
# software without specific prior written permission.
22+
#
23+
# NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY
24+
# THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
25+
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
27+
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
28+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
31+
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
32+
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34+
# POSSIBILITY OF SUCH DAMAGE.
35+
#
36+
37+
if [ -z "$AK3TMPFS" ]; then
38+
echo "AK3TMPFS is not defined? Are you running FoxMMM?"
39+
exit 1
40+
fi
41+
42+
if [ ! -e "$AK3TMPFS" ]; then
43+
mkdir $AK3TMPFS
44+
chmod 755 $AK3TMPFS
45+
fi
46+
47+
ZIPFILE=$3;
48+
49+
# Mount tmpfs early
50+
mount -t tmpfs -o size=400M,noatime tmpfs $AK3TMPFS;
51+
mount | grep -q " $AK3TMPFS " || exit 1;
52+
53+
unzip -p $Z tools*/busybox > $AK3TMPFS/busybox;
54+
unzip -p $Z META-INF/com/google/android/update-binary > $AK3TMPFS/update-binary;
55+
##
56+
57+
chmod 755 $AK3TMPFS/busybox;
58+
$AK3TMPFS/busybox chmod 755 $AK3TMPFS/update-binary;
59+
$AK3TMPFS/busybox chown root:root $AK3TMPFS/busybox $AK3TMPFS/update-binary;
60+
61+
# work around Android passing the app what is actually a non-absolute path
62+
AK3TMPFS=$($AK3TMPFS/busybox readlink -f $AK3TMPFS);
63+
64+
# AK3 allows the zip to be flashed from anywhere so avoids any need to remount /
65+
if $AK3TMPFS/busybox grep -q AnyKernel3 $AK3TMPFS/update-binary; then
66+
# work around more restrictive upstream SELinux policies for Magisk <19306
67+
magiskpolicy --live "allow kernel app_data_file file write" || true;
68+
TMP=$AK3TMPFS/tmp;
69+
else
70+
echo "Module is not an AnyKernel3 module!"
71+
exit 1
72+
fi;
73+
74+
# update-binary <RECOVERY_API_VERSION> <OUTFD> <ZIPFILE>
75+
ASH_STANDALONE=1 AKHOME=$AK3TMPFS/anykernel $AK3TMPFS/busybox ash $AK3TMPFS/update-binary 3 1 "$Z";
76+
RC=$?;
77+
78+
# Original script delete all generated files,
79+
# But we just need to unmount as we store everything inside tmpfs
80+
umount $TMP;
81+
82+
return $RC;

app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyRepoData.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected boolean prepare() {
7070
// Implementation details discussed on telegram
7171
long time = System.currentTimeMillis();
7272
if (this.androidacyBlockade > time) return false;
73-
this.androidacyBlockade = time + 5_000L;
73+
this.androidacyBlockade = time + 30_000L;
7474
String cookies = AndroidacyRepoData.getCookies();
7575
int start = cookies == null ? -1 : cookies.indexOf("USER=");
7676
String token = null;
@@ -150,8 +150,9 @@ protected List<RepoModule> populate(JSONObject jsonObject) throws JSONException
150150
for (int i = 0; i < len; i++) {
151151
jsonObject = jsonArray.getJSONObject(i);
152152
String moduleId = jsonObject.getString("codename");
153-
// Deny remote modules ids shorter than 3 chars
154-
if (moduleId.length() < 3) continue;
153+
// Deny remote modules ids shorter than 3 chars or containing null char or space
154+
if (moduleId.length() < 3 || moduleId.indexOf('\0') != -1 ||
155+
moduleId.indexOf(' ') != -1 || "ak3-helper".equals(moduleId)) continue;
155156
long lastUpdate = jsonObject.getLong("updated_at") * 1000;
156157
lastLastUpdate = Math.max(lastLastUpdate, lastUpdate);
157158
RepoModule repoModule = this.moduleHashMap.get(moduleId);

0 commit comments

Comments
 (0)