You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
My brain hurts...
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
package com.topjohnwu.magisk.module;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class Module {
|
||||
|
||||
private String mRemoveFile;
|
||||
@@ -18,7 +25,16 @@ public class Module {
|
||||
private String mId;
|
||||
private int mVersionCode;
|
||||
|
||||
public Module(String path) {
|
||||
public Module(String path, Context context) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
Map<String,?> keys = prefs.getAll();
|
||||
|
||||
for(Map.Entry<String,?> entry : keys.entrySet()){
|
||||
|
||||
if(entry.getValue().toString().contains(path)) {
|
||||
Log.d("Magisk", "Hey, look a matching path, this guy's name is " + entry.getKey().replace("path_",""));
|
||||
}
|
||||
}
|
||||
mRemoveFile = path + "/remove";
|
||||
mDisableFile = path + "/disable";
|
||||
for (String line : Utils.readFile(path + "/module.prop")) {
|
||||
|
||||
@@ -11,38 +11,43 @@ import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class Repo {
|
||||
public String name;
|
||||
public String baseUrl, zipUrl,manifestUrl, logUrl;
|
||||
public String manifest, version, moduleName, moduleDescription, moduleAuthor, moduleAuthorUrl;
|
||||
public Boolean usesRoot,usesXposed;
|
||||
public String baseUrl, zipUrl, manifestUrl, logUrl, manifest, version, moduleName, moduleDescription, moduleAuthor, moduleAuthorUrl;
|
||||
public Date lastUpdate;
|
||||
public Boolean usesRoot, usesXposed;
|
||||
private Context appContext;
|
||||
private SharedPreferences prefs;
|
||||
|
||||
|
||||
public Repo(String name, String url, Context context) {
|
||||
public Repo(String name, String url, Date updated, Context context) {
|
||||
appContext = context;
|
||||
this.name = name;
|
||||
this.baseUrl = url;
|
||||
prefs = PreferenceManager.getDefaultSharedPreferences(appContext);
|
||||
this.lastUpdate = updated;
|
||||
this.fetch();
|
||||
|
||||
}
|
||||
|
||||
public Repo(String moduleName, String moduleDescription, String zipUrl) {
|
||||
public Repo(String moduleName, String moduleDescription, String zipUrl, Date lastUpdated, Context context) {
|
||||
Log.d("Magisk", "Hey, I'm a repo! My name is " + moduleName);
|
||||
appContext = context;
|
||||
this.zipUrl = zipUrl;
|
||||
this.moduleDescription = moduleDescription;
|
||||
this.moduleName = moduleName;
|
||||
prefs = PreferenceManager.getDefaultSharedPreferences(appContext);
|
||||
this.lastUpdate = lastUpdated;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void fetch() {
|
||||
|
||||
prefs = PreferenceManager.getDefaultSharedPreferences(appContext);
|
||||
WebRequest webreq = new WebRequest();
|
||||
// Construct initial url for contents
|
||||
Log.d("Magisk","Manifest string is: " + baseUrl + "/contents/");
|
||||
Log.d("Magisk", "Manifest string is: " + baseUrl + "/contents/");
|
||||
String repoString = webreq.makeWebServiceCall(baseUrl + "/contents/", WebRequest.GET);
|
||||
|
||||
try {
|
||||
@@ -63,13 +68,13 @@ public class Repo {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Log.d("Magisk","Inner fetch: " + repoString);
|
||||
Log.d("Magisk", "Inner fetch: " + repoString);
|
||||
try {
|
||||
WebRequest jsonReq = new WebRequest();
|
||||
// Construct initial url for contents
|
||||
String manifestString = webreq.makeWebServiceCall(this.manifestUrl, WebRequest.GET);
|
||||
JSONObject manifestObject = new JSONObject(manifestString);
|
||||
Log.d("Magisk","Object: " +manifestObject.toString());
|
||||
Log.d("Magisk", "Object: " + manifestObject.toString());
|
||||
version = manifestObject.getString("versionCode");
|
||||
moduleName = manifestObject.getString("moduleName");
|
||||
moduleDescription = manifestObject.getString("moduleDescription");
|
||||
@@ -84,9 +89,13 @@ public class Repo {
|
||||
+ "\"usesRoot\":\"" + usesRoot + "\","
|
||||
+ "\"usesXposed\":\"" + usesXposed + "\","
|
||||
+ "\"zipUrl\":\"" + zipUrl + "\","
|
||||
+ "\"lastUpdate\":\"" + lastUpdate + "\","
|
||||
+ "\"logUrl\":\"" + logUrl + "\"}]";
|
||||
editor.putString("module_" + moduleName,prefsString);
|
||||
editor.putBoolean("hasCachedRepos",true);
|
||||
editor.putString("module_" + moduleName, prefsString);
|
||||
editor.putBoolean("hasCachedRepos", true);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
|
||||
editor.putString("updated", sdf.toString());
|
||||
Log.d("Magisk", "Storing Preferences: " + prefsString);
|
||||
editor.apply();
|
||||
|
||||
} catch (JSONException e) {
|
||||
@@ -116,6 +125,4 @@ public class Repo {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user