wip on native library to disable app nap

This commit is contained in:
Zlatin Balevsky
2021-04-02 07:23:20 +01:00
parent 7c26f48311
commit de556658f6
4 changed files with 42 additions and 0 deletions

View File

@ -25,6 +25,9 @@ if [ -z ${I2P_BUILD_NUMBER} ]; then
exit 1
fi
JAVA_HOME="$(/usr/libexec/java_home)"
echo "JAVA_HOME is $JAVA_HOME"
echo "cleaning"
./clean.sh
@ -45,6 +48,9 @@ cd build
jar -cf launcher.jar net
cd ..
echo "compiling native lib"
cc -mmacosx-version-min=10.9 -I"$JAVA_HOME/include" -I"$JAVA_HOME/include/darwin" -Ic -o build/libMacLauncher.jnilib -shared c/net_i2p_router_MacLauncher.c
echo "signing jbigi libs"
mkdir jbigi
cp $I2P_JARS/jbigi.jar jbigi
@ -62,6 +68,7 @@ echo "preparing to invoke jpackage for I2P version $I2P_VERSION build $I2P_BUILD
cp "$I2P_PKG/Start I2P Router.app/Contents/Resources/i2p.icns" build/I2P.icns
cp "$I2P_PKG/Start I2P Router.app/Contents/Resources/i2p.icns" build/I2P-volume.icns
# cp I2P-dmg-setup.scpt build/
cp $I2P_PKG/LICENSE.txt build
cp resources/Info.plist.template build/Info.plist
@ -83,9 +90,11 @@ for i in i2prouter lib locale man wrapper.config eepget runplain.sh postinstall.
rm -rf I2P.app/Contents/Resources/$i
done
cp $HERE/resources/GPLv2+CE.txt I2P.app/Contents/Resources/licenses/LICENSE-JRE.txt
cp $HERE/build/libMacLauncher.jnilib I2P.app/Contents/Resources
echo "signing the runtime libraries"
find I2P.app -name *.dylib -exec codesign --force -s $I2P_SIGNER -v '{}' \;
find I2P.app -name *.jnilib -exec codesign --force -s $I2P_SIGNER -v '{}' \;
echo "signing the bundle"
codesign --force -d --deep -f \

View File

@ -0,0 +1,8 @@
#include "net_i2p_router_MacLauncher.h"
#include <stdio.h>
JNIEXPORT void JNICALL Java_net_i2p_router_MacLauncher_disableAppNap
(JNIEnv *jnienv, jclass c)
{
printf("worked!\n");
}

View File

@ -0,0 +1,21 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class net_i2p_router_MacLauncher */
#ifndef _Included_net_i2p_router_MacLauncher
#define _Included_net_i2p_router_MacLauncher
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: net_i2p_router_MacLauncher
* Method: disableAppNap
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_net_i2p_router_MacLauncher_disableAppNap
(JNIEnv *, jclass);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -26,6 +26,10 @@ public class MacLauncher {
System.setProperty("mac.bundle.location", bundleLocation.getAbsolutePath());
System.setProperty("router.pid", String.valueOf(ProcessHandle.current().pid()));
System.load(resources.getAbsolutePath() + "/libMacLauncher.jnilib");
disableAppNap();
RouterLaunch.main(args);
}
private static native void disableAppNap();
}