Skip to content

Commit

Permalink
Add mieru plugin (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
enfein authored Jan 9, 2024
1 parent 9bce443 commit a380a48
Show file tree
Hide file tree
Showing 20 changed files with 176 additions and 1 deletion.
18 changes: 18 additions & 0 deletions app_mieru/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
}

setupAll()

android {
defaultConfig {
applicationId = "moe.matsuri.exe.mieru"
versionCode = 1
versionName = "2.2.0"
splits.abi {
reset()
include("arm64-v8a", "x86_64")
}
}
}
47 changes: 47 additions & 0 deletions app_mieru/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="moe.matsuri.exe.mieru"
android:installLocation="internalOnly"
tools:ignore="MissingLeanbackLauncher">

<uses-feature
android:name="android.software.leanback"
android:required="false" />
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />

<application
android:allowBackup="false"
android:extractNativeLibs="true"
android:icon="@mipmap/ic_launcher"
android:label="Mieru For NekoBox"
android:roundIcon="@mipmap/ic_launcher_round">
<provider
android:name=".BinaryProvider"
android:authorities="moe.matsuri.exe.mieru.BinaryProvider"
android:directBootAware="true"
android:exported="true"
tools:ignore="ExportedContentProvider">
<intent-filter>
<action android:name="io.nekohasekai.sagernet.plugin.ACTION_NATIVE_PLUGIN" />
</intent-filter>
<intent-filter>
<action android:name="io.nekohasekai.sagernet.plugin.ACTION_NATIVE_PLUGIN" />
<data
android:host="moe.matsuri.lite"
android:path="/mieru-plugin"
android:scheme="plugin" />
</intent-filter>

<meta-data
android:name="io.nekohasekai.sagernet.plugin.id"
android:value="mieru-plugin" />
<meta-data
android:name="io.nekohasekai.sagernet.plugin.executable_path"
android:value="libmieru.so" />
</provider>
</application>

</manifest>
41 changes: 41 additions & 0 deletions app_mieru/src/main/java/moe/matsuri/exe/mieru/BinaryProvider.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/******************************************************************************
* Copyright (C) 2022 by nekohasekai <contact-git@sekai.icu> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
******************************************************************************/

package moe.matsuri.exe.mieru

import android.net.Uri
import android.os.ParcelFileDescriptor
import io.nekohasekai.sagernet.plugin.NativePluginProvider
import io.nekohasekai.sagernet.plugin.PathProvider
import java.io.File
import java.io.FileNotFoundException

class BinaryProvider : NativePluginProvider() {
override fun populateFiles(provider: PathProvider) {
provider.addPath("mieru-plugin", 0b111101101)
}

override fun getExecutable() = context!!.applicationInfo.nativeLibraryDir + "/libmieru.so"
override fun openFile(uri: Uri): ParcelFileDescriptor = when (uri.path) {
"/mieru-plugin" -> ParcelFileDescriptor.open(
File(getExecutable()),
ParcelFileDescriptor.MODE_READ_ONLY
)
else -> throw FileNotFoundException()
}
}
30 changes: 30 additions & 0 deletions app_mieru/src/main/res/drawable/ic_launcher_foreground.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="405"
android:viewportHeight="172.80006">
<group
android:scaleX="0.46"
android:scaleY="0.19626674"
android:translateX="109.35"
android:translateY="75.69858">
<group android:translateY="106.12804">
<path
android:pathData="M41.3125,-104L4.171875,-104L4.171875,-97.21875L6.90625,-97.21875C15.109375,-97.078125,17.84375,-96.640625,18.859375,-95.203125C19.859375,-93.90625,19.859375,-93.765625,19.859375,-86.265625L19.859375,-31.109375C19.859375,-11.515625,17.125,-7.484375,3.15625,-6.765625L3.15625,-0L44.203125,-0L44.203125,-6.765625C30.375,-7.484375,27.640625,-11.515625,27.640625,-31.109375L27.640625,-94.765625L61.90625,-0L67.671875,-0L99.78125,-94.765625L99.78125,-17.703125C99.78125,-10.359375,99.78125,-10.078125,98.921875,-8.640625C97.765625,-7.1875,95.03125,-6.765625,86.828125,-6.765625L84.234375,-6.765625L84.234375,-0L131.46875,-0L131.46875,-6.765625L128.875,-6.765625C120.65625,-6.765625,117.921875,-7.1875,116.78125,-8.640625C115.90625,-10.078125,115.90625,-10.21875,115.90625,-17.703125L115.90625,-86.265625C115.90625,-93.625,115.90625,-93.90625,116.78125,-95.203125C117.921875,-96.640625,120.65625,-97.078125,128.875,-97.21875L131.46875,-97.21875L131.46875,-104L95.3125,-104L68.96875,-27.21875L41.3125,-104Z"
android:fillColor="#FFFFFF" />
<path
android:pathData="M165.65625,-67.125L138.57812,-65.546875L138.57812,-59.34375L145.92188,-59.34375C151.40625,-59.203125,152.125,-58.34375,152.125,-52.140625L152.125,-17.71875L152.125,-10.9375C151.96875,-8.78125,151.82812,-7.921875,151.25,-7.1875C150.25,-5.890625,147.51562,-5.328125,141.3125,-5.171875L140.3125,-5.171875L140.3125,0L177.60938,0L177.60938,-5.171875L176.59375,-5.171875C166.95312,-5.46875,165.65625,-6.1875,165.65625,-11.375L165.65625,-17.71875L165.65625,-67.125ZM158.89062,-103C154.28125,-103,150.53125,-99.25,150.53125,-94.640625C150.53125,-90.03125,154.28125,-86.28125,158.75,-86.28125C163.5,-86.28125,167.23438,-90.03125,167.23438,-94.640625C167.23438,-99.25,163.5,-103,158.89062,-103Z"
android:fillColor="#FFFFFF" />
<path
android:pathData="M247.95312,-32C248.09375,-53.671875,235.85938,-69,218.28125,-69C199.85938,-69,186.03125,-52.953125,186.03125,-31.28125C186.03125,-11.40625,199.14062,2,218.57812,2C232.40625,2,242.04688,-4.765625,247.95312,-18.171875L242.90625,-20.859375C237,-10,230.95312,-5.765625,221.3125,-5.765625C213.96875,-5.765625,208.64062,-8.734375,204.89062,-15.078125C202.29688,-19.296875,201.15625,-24.234375,201.29688,-32L247.95312,-32ZM201.4375,-38.1875C201.4375,-42.671875,202.01562,-45.859375,203.45312,-49.90625C206.48438,-58.609375,211.09375,-62.796875,218.14062,-62.796875C226.78125,-62.796875,232.54688,-55.125,232.54688,-43.390625C232.54688,-39.34375,231.25,-38.1875,226.64062,-38.1875L201.4375,-38.1875Z"
android:fillColor="#FFFFFF" />
<path
android:pathData="M281.5,-66.828125L256.01562,-65.25L256.01562,-59.078125L261.92188,-59.078125C267.39062,-58.9375,268.10938,-58.078125,268.10938,-51.921875L268.10938,-17.640625L268.10938,-10.90625C267.96875,-8.75,267.82812,-7.890625,267.25,-7.171875C266.23438,-5.890625,263.35938,-5.3125,257.17188,-5.171875L256.59375,-5.171875L256.59375,0L295.04688,0L295.04688,-5.171875L292.45312,-5.171875C282.79688,-5.453125,281.5,-6.171875,281.5,-11.328125L281.5,-17.640625L281.5,-19.078125C281.64062,-43.171875,290.28125,-61.53125,301.51562,-62.09375C299.5,-59.796875,298.92188,-58.375,298.92188,-55.640625C298.92188,-51.0625,302.23438,-47.75,306.84375,-47.75C312.17188,-47.75,315.625,-51.625,315.625,-57.359375C315.625,-64.390625,310.73438,-69,303.10938,-69C294.03125,-69,286.25,-61.8125,281.5,-49.046875L281.5,-66.828125Z"
android:fillColor="#FFFFFF" />
<path
android:pathData="M376.3125,1.015625L402.53125,0L402.53125,-6.171875L398.92188,-6.171875C390.57812,-6.46875,389.85938,-7.328125,389.85938,-16.671875L389.85938,-67L362.78125,-65.40625L362.78125,-59.21875L370.125,-59.21875C375.59375,-59.078125,376.3125,-58.21875,376.3125,-52.03125L376.3125,-34.359375C376.3125,-26.15625,375.45312,-21.265625,373.29688,-16.671875C370.26562,-10.359375,364.51562,-6.78125,357.45312,-6.78125C352.98438,-6.78125,349.25,-8.359375,347.375,-11.21875C345.5,-13.9375,345.21875,-15.375,345.21875,-23.265625L345.21875,-67L320.01562,-65.40625L320.01562,-59.234375L325.48438,-59.234375C330.95312,-59.09375,331.6875,-58.234375,331.6875,-52.078125L331.6875,-21.109375C331.6875,-13.796875,332.25,-10.5,334.42188,-7.203125C338.29688,-1.296875,345.21875,2,353.85938,2C363.35938,2,369.98438,-1.875,376.3125,-11.078125L376.3125,1.015625Z"
android:fillColor="#FFFFFF" />
</group>
</group>
</vector>
6 changes: 6 additions & 0 deletions app_mieru/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>

<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions app_mieru/src/main/res/values/ic_launcher_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#E91E63</color>
</resources>
20 changes: 20 additions & 0 deletions download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ unzip_naive() {
rm -rf tmp*
}

unzip_mieru() {
rm -rf tmp
mkdir -p tmp
tar -xf tmp.tar.gz -C tmp

mv tmp/mieru "$1"/libmieru.so
rm -rf tmp*
}

download_xray() {
VERSION="v1.7.5"
mkdir_libs "app_xray/libs"
Expand Down Expand Up @@ -119,4 +128,15 @@ download_naive() {
unzip_naive x86_64
}

download_mieru() {
TAG="v2.2.0"
VERSION="2.2.0"
mkdir_libs "app_mieru/libs"

curl -Lso tmp.tar.gz "https://github.com/enfein/mieru/releases/download/${TAG}/mieru_${VERSION}_android_arm64.tar.gz"
unzip_mieru arm64-v8a
curl -Lso tmp.tar.gz "https://github.com/enfein/mieru/releases/download/${TAG}/mieru_${VERSION}_android_amd64.tar.gz"
unzip_mieru x86_64
}

download_"$1"
1 change: 1 addition & 0 deletions js/make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -e
[ $1 == "tuic" ] && exit
[ $1 == "tuic5" ] && exit
[ $1 == "naive" ] && exit
[ $1 == "mieru" ] && exit

HTML=../app_$1/html
SRC=./plugin_$1
Expand Down
3 changes: 2 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ include ':app_hysteria'
include ':app_tuic'
include ':app_tuic5'
include ':app_juicity'
include ':app_naive'
include ':app_naive'
include ':app_mieru'

0 comments on commit a380a48

Please sign in to comment.