-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add LOKI as submodules add "lokiaboot" and "lokipatch" partition properties to fstab patch partitions marked as "lokipatch" before flashing
- Loading branch information
Showing
8 changed files
with
167 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "sub_projects/Loki"] | ||
path = sub_projects/Loki | ||
url = https://github.com/efidroid/modules_loki.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
LOCAL_PATH := $(call my-dir) | ||
|
||
include $(CLEAR_VARS) | ||
LOCAL_MODULE := loki-wrapper | ||
LOCAL_SRC_FILES := loki_wrapper.c | ||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../../sub_projects/Loki | ||
LOCAL_STATIC_LIBRARIES := libloki_static | ||
include $(BUILD_SHARED_LIBRARY) | ||
|
||
include $(LOCAL_PATH)/../../../../sub_projects/Loki/Android.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include <jni.h> | ||
#include <loki.h> | ||
|
||
JNIEXPORT jint JNICALL | ||
Java_org_efidroid_efidroidmanager_LokiTool_lokiPatch(JNIEnv *env, jobject instance, | ||
jstring partitionLabel_, jstring abootImage_, | ||
jstring inImage_, jstring outImage_) { | ||
const char *partitionLabel = (*env)->GetStringUTFChars(env, partitionLabel_, 0); | ||
const char *abootImage = (*env)->GetStringUTFChars(env, abootImage_, 0); | ||
const char *inImage = (*env)->GetStringUTFChars(env, inImage_, 0); | ||
const char *outImage = (*env)->GetStringUTFChars(env, outImage_, 0); | ||
|
||
int ret = loki_patch(partitionLabel,abootImage,inImage,outImage); | ||
|
||
(*env)->ReleaseStringUTFChars(env, partitionLabel_, partitionLabel); | ||
(*env)->ReleaseStringUTFChars(env, abootImage_, abootImage); | ||
(*env)->ReleaseStringUTFChars(env, inImage_, inImage); | ||
(*env)->ReleaseStringUTFChars(env, outImage_, outImage); | ||
|
||
return ret; | ||
} | ||
|
||
JNIEXPORT jint JNICALL | ||
Java_org_efidroid_efidroidmanager_LokiTool_lokiFlash(JNIEnv *env, jobject instance, | ||
jstring partitionLabel_, jstring image_) { | ||
const char *partitionLabel = (*env)->GetStringUTFChars(env, partitionLabel_, 0); | ||
const char *image = (*env)->GetStringUTFChars(env, image_, 0); | ||
|
||
int ret = loki_flash(partitionLabel, image); | ||
|
||
(*env)->ReleaseStringUTFChars(env, partitionLabel_, partitionLabel); | ||
(*env)->ReleaseStringUTFChars(env, image_, image); | ||
|
||
return ret; | ||
} |
46 changes: 46 additions & 0 deletions
46
app/src/main/java/org/efidroid/efidroidmanager/LokiTool.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.efidroid.efidroidmanager; | ||
|
||
import android.util.Log; | ||
|
||
import com.stericson.roottools.RootTools; | ||
import static com.android.volley.VolleyLog.TAG; | ||
|
||
public class LokiTool { | ||
public enum PartitionLabel { | ||
BOOT("boot"), | ||
RECOVERY("recovery"); | ||
|
||
String mLabel; | ||
PartitionLabel(String s) { | ||
mLabel=s; | ||
} | ||
public String getLabel() { | ||
return mLabel; | ||
} | ||
} | ||
|
||
static { | ||
System.loadLibrary("loki-wrapper"); | ||
} | ||
|
||
private LokiTool() {} | ||
|
||
private static native int lokiPatch(String partitionLabel, String bootloaderImage, | ||
String inImage, String outImage); | ||
private static native int lokiFlash(String partitionLabel, String image); | ||
|
||
public static boolean patchImage(PartitionLabel label, String bootloaderImage, | ||
String inImage, String outImage) { | ||
return lokiPatch(label.getLabel(),bootloaderImage,inImage,outImage) == 0; | ||
} | ||
|
||
public static boolean flashImage(PartitionLabel label, String image) { | ||
//root required for flashing | ||
boolean isRootAccess = RootTools.isAccessGiven(); | ||
if (!isRootAccess) { | ||
Log.e(TAG, "flashImage: cannot get root privileges"); | ||
return false; | ||
} | ||
return lokiFlash(label.getLabel(), image) == 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters