From d86e52c90e5a1d0dfa46f9c9ed8a91f26942bb7b Mon Sep 17 00:00:00 2001 From: areteruhiro <108941410+areteruhiro@users.noreply.github.com> Date: Mon, 14 Oct 2024 10:15:31 +0900 Subject: [PATCH 01/12] Create Archived --- .../github/chipppppppppp/lime/hooks/Archived | 284 ++++++++++++++++++ 1 file changed, 284 insertions(+) create mode 100644 app/src/main/java/io/github/chipppppppppp/lime/hooks/Archived diff --git a/app/src/main/java/io/github/chipppppppppp/lime/hooks/Archived b/app/src/main/java/io/github/chipppppppppp/lime/hooks/Archived new file mode 100644 index 00000000..706e8403 --- /dev/null +++ b/app/src/main/java/io/github/chipppppppppp/lime/hooks/Archived @@ -0,0 +1,284 @@ +package io.github.chipppppppppp.lime.hooks; + +import android.app.AndroidAppHelper; +import android.app.Application; +import android.content.Context; +import android.content.pm.PackageManager; +import android.database.Cursor; +import android.database.sqlite.SQLiteDatabase; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; + +import de.robv.android.xposed.XC_MethodHook; +import de.robv.android.xposed.XposedBridge; +import de.robv.android.xposed.XposedHelpers; +import de.robv.android.xposed.callbacks.XC_LoadPackage; +import io.github.chipppppppppp.lime.LimeOptions; +import io.github.chipppppppppp.lime.Main; + +public class Archived implements IHook { + + + @Override + public void hook(LimeOptions limeOptions, XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable { + + XposedBridge.hookAllMethods(Application.class, "onCreate", new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + Application appContext = (Application) param.thisObject; + + if (appContext == null) { + XposedBridge.log("appContext is null!"); + return; + } + + + File dbFile = appContext.getDatabasePath("naver_line"); + + if (dbFile.exists()) { + SQLiteDatabase.OpenParams.Builder builder = new SQLiteDatabase.OpenParams.Builder(); + builder.addOpenFlags(SQLiteDatabase.OPEN_READWRITE); + SQLiteDatabase.OpenParams dbParams = builder.build(); + + + SQLiteDatabase db = SQLiteDatabase.openDatabase(dbFile, dbParams); + + + hookSAMethod(loadPackageParam,db,appContext); + hookMessageDeletion(loadPackageParam, appContext, db); + } else { + XposedBridge.log("Database file does not exist: " + dbFile); + } + } + + }); +} + private void hookMessageDeletion(XC_LoadPackage.LoadPackageParam loadPackageParam, Context context, SQLiteDatabase db) { + try { + XposedBridge.hookAllMethods( + loadPackageParam.classLoader.loadClass(Constants.RESPONSE_HOOK.className), + Constants.RESPONSE_HOOK.methodName, + new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + String paramValue = param.args[1].toString(); + if (paramValue.contains("SEND_CHAT_HIDDEN")) { + String talkId = extractTalkId(paramValue); + if (talkId != null) { + + saveTalkIdToFile(talkId, context); + updateArchivedChatsFromFile(db, context); + } + } + } + }); + } catch (ClassNotFoundException e) { + XposedBridge.log("Class not found: " + e.getMessage()); + } + } + + + + + + private void hookSAMethod(XC_LoadPackage.LoadPackageParam loadPackageParam,SQLiteDatabase db, Context context) { + + Class targetClass = XposedHelpers.findClass("SA.Q", loadPackageParam.classLoader); + + + XposedBridge.hookAllMethods(targetClass, "invokeSuspend", new XC_MethodHook() { + @Override + protected void beforeHookedMethod(MethodHookParam param) throws Throwable { + + XposedBridge.log("invokeSuspend method is called with parameters: " + param.args[0]); + + + Context appContext = AndroidAppHelper.currentApplication(); + if (appContext == null) { + XposedBridge.log("Context is null"); + return; + } + + + File dbFile = appContext.getDatabasePath("naver_line"); + SQLiteDatabase db = null; + + if (dbFile.exists()) { + SQLiteDatabase.OpenParams.Builder builder = new SQLiteDatabase.OpenParams.Builder(); + builder.addOpenFlags(SQLiteDatabase.OPEN_READWRITE); + SQLiteDatabase.OpenParams dbParams = builder.build(); + db = SQLiteDatabase.openDatabase(dbFile, dbParams); + } else { + XposedBridge.log("Database file does not exist: " + dbFile.getPath()); + return; + } + + + List chatIds = readChatIdsFromFile(appContext); + for (String chatId : chatIds) { + if (!chatId.isEmpty()) { + updateIsArchived(db, chatId); + } + } + + + if (db != null) { + db.close(); + } + } + }); + + + } + + + + private List readChatIdsFromFile(Context context) { + List chatIds = new ArrayList<>(); + File file = new File(context.getFilesDir(), "hidelist.txt"); + + try (BufferedReader reader = new BufferedReader(new FileReader(file))) { + String line; + while ((line = reader.readLine()) != null) { + chatIds.add(line.trim()); + } + XposedBridge.log("Read chatIds from file: " + chatIds); + } catch (IOException e) { + XposedBridge.log("Error reading chatIds from file: " + e.getMessage()); + } + + return chatIds; + } + + + private void saveTalkIdToFile(String talkId, Context context) { + File dir = context.getFilesDir(); + if (!dir.exists()) { + dir.mkdirs(); + } + + File file = new File(dir, "hidelist.txt"); + + try { + + if (!file.exists()) { + file.createNewFile(); + } + + try (FileWriter writer = new FileWriter(file, true)) { + writer.write(talkId + "\n"); + XposedBridge.log("Saved talkId: " + talkId + " to file."); + } + } catch (IOException e) { + XposedBridge.log("Error saving talkId to file: " + e.getMessage()); + } + } + + + + private void updateArchivedChatsFromFile(SQLiteDatabase db, Context context) { + File file = new File(context.getFilesDir(), "hidelist.txt"); + if (!file.exists()) { + XposedBridge.log("hidelist.txt does not exist."); + return; + } + + try (BufferedReader reader = new BufferedReader(new FileReader(file))) { + String chatId; + while ((chatId = reader.readLine()) != null) { + chatId = chatId.trim(); + if (!chatId.isEmpty()) { + updateIsArchived(db, chatId); + } + } + } catch (IOException e) { + XposedBridge.log("Error reading from hidelist.txt: " + e.getMessage()); + } + } + + private String extractTalkId(String paramValue) { + String talkId = null; + XposedBridge.log("Extracting talkId from paramValue: " + paramValue); + + String messageStart = "reqSeq:0,"; + int messageStartIndex = paramValue.indexOf(messageStart); + if (messageStartIndex != -1) { + String messagePart = paramValue.substring(messageStartIndex); + String fromPrefix = "param1:"; + int fromIndex = messagePart.indexOf(fromPrefix); + + if (fromIndex != -1) { + int endIndex = messagePart.indexOf(",", fromIndex); + if (endIndex == -1) { + endIndex = messagePart.indexOf(")", fromIndex); + } + if (endIndex != -1) { + talkId = messagePart.substring(fromIndex + fromPrefix.length(), endIndex).trim(); + XposedBridge.log("Extracted talkId: " + talkId); + } + } + } + + if (talkId == null) { + XposedBridge.log("No talkId found in the provided paramValue."); + } + + return talkId; + } + + private String queryDatabase(SQLiteDatabase db, String query, String... selectionArgs) { + if (db == null) { + XposedBridge.log("Database is not initialized."); + return null; + } + try (Cursor cursor = db.rawQuery(query, selectionArgs)) { + if (cursor.moveToFirst()) { + return cursor.getString(0); + } + } catch (Exception e) { + XposedBridge.log("Error querying database: " + e.getMessage()); + } + return null; + } + + private void updateDatabase(SQLiteDatabase db, String query, Object... bindArgs) { + if (db == null) { + XposedBridge.log("Database is not initialized."); + return; + } + + try { + db.beginTransaction(); + db.execSQL(query, bindArgs); + db.setTransactionSuccessful(); + XposedBridge.log("Executed update query: " + query); + } catch (Exception e) { + XposedBridge.log("Error executing update query: " + e.getMessage()); + } finally { + db.endTransaction(); + } + } + + private void updateIsArchived(SQLiteDatabase db, String chatId) { + + String updateQuery = "UPDATE chat SET is_archived = 1 WHERE chat_id = ?"; + + updateDatabase(db, updateQuery, chatId); + XposedBridge.log("Executed update query for chatId: " + chatId); + + String selectQuery = "SELECT is_archived FROM chat WHERE chat_id = ?"; + String result = queryDatabase(db, selectQuery, chatId); + + if (result != null) { + XposedBridge.log("is_archived for chatId " + chatId + " is now: " + result); + } else { + XposedBridge.log("No chat found with chatId: " + chatId); + } + } +} From 37f1edd24f0355d92c151de0a52d69f7b04a4d9e Mon Sep 17 00:00:00 2001 From: areteruhiro <108941410+areteruhiro@users.noreply.github.com> Date: Mon, 14 Oct 2024 11:10:36 +0900 Subject: [PATCH 02/12] Update Archived --- .../github/chipppppppppp/lime/hooks/Archived | 168 ++++++++++-------- 1 file changed, 92 insertions(+), 76 deletions(-) diff --git a/app/src/main/java/io/github/chipppppppppp/lime/hooks/Archived b/app/src/main/java/io/github/chipppppppppp/lime/hooks/Archived index 706e8403..d9b5a02c 100644 --- a/app/src/main/java/io/github/chipppppppppp/lime/hooks/Archived +++ b/app/src/main/java/io/github/chipppppppppp/lime/hooks/Archived @@ -7,6 +7,7 @@ import android.content.pm.PackageManager; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import java.io.BufferedReader; +import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; @@ -27,17 +28,17 @@ public class Archived implements IHook { @Override public void hook(LimeOptions limeOptions, XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable { - XposedBridge.hookAllMethods(Application.class, "onCreate", new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { Application appContext = (Application) param.thisObject; if (appContext == null) { - XposedBridge.log("appContext is null!"); return; } + // moduleContextの定義 + Context moduleContext = appContext; // 必要に応じて変更 File dbFile = appContext.getDatabasePath("naver_line"); @@ -46,66 +47,96 @@ public class Archived implements IHook { builder.addOpenFlags(SQLiteDatabase.OPEN_READWRITE); SQLiteDatabase.OpenParams dbParams = builder.build(); - SQLiteDatabase db = SQLiteDatabase.openDatabase(dbFile, dbParams); - - hookSAMethod(loadPackageParam,db,appContext); - hookMessageDeletion(loadPackageParam, appContext, db); + hookSAMethod(loadPackageParam, db, appContext); + hookMessageDeletion(loadPackageParam, appContext, db, moduleContext); // moduleContextを渡す } else { - XposedBridge.log("Database file does not exist: " + dbFile); } } - }); -} - private void hookMessageDeletion(XC_LoadPackage.LoadPackageParam loadPackageParam, Context context, SQLiteDatabase db) { + } + + private void hookMessageDeletion(XC_LoadPackage.LoadPackageParam loadPackageParam, Context context, SQLiteDatabase db,Context moduleContext) { try { + + XposedBridge.hookAllMethods( - loadPackageParam.classLoader.loadClass(Constants.RESPONSE_HOOK.className), - Constants.RESPONSE_HOOK.methodName, + loadPackageParam.classLoader.loadClass(Constants.REQUEST_HOOK.className), + Constants.REQUEST_HOOK.methodName, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { String paramValue = param.args[1].toString(); - if (paramValue.contains("SEND_CHAT_HIDDEN")) { + if (paramValue.contains("hidden:true")) { String talkId = extractTalkId(paramValue); if (talkId != null) { - saveTalkIdToFile(talkId, context); - updateArchivedChatsFromFile(db, context); + updateArchivedChatsFromFile(db, context,moduleContext); } } + if (paramValue.contains("hidden:false")) { + String talkId = extractTalkId(paramValue); + if (talkId != null) { + + deleteTalkIdFromFile(talkId, context); + updateArchivedChatsFromFile(db, context,moduleContext); + } + } + } }); + } catch (ClassNotFoundException e) { - XposedBridge.log("Class not found: " + e.getMessage()); } } + private void deleteTalkIdFromFile(String talkId, Context moduleContext) { + File dir = moduleContext.getFilesDir(); // moduleContextを使用 + File file = new File(dir, "hidelist.txt"); + if (file.exists()) { + try { + List lines = new ArrayList<>(); + BufferedReader reader = new BufferedReader(new FileReader(file)); + String line; + while ((line = reader.readLine()) != null) { + if (!line.trim().equals(talkId)) { + lines.add(line); + } + } + reader.close(); + + BufferedWriter writer = new BufferedWriter(new FileWriter(file)); + for (String remainingLine : lines) { + writer.write(remainingLine); + writer.newLine(); + } + writer.close(); + } catch (IOException e) { + } + } else { + } + } - private void hookSAMethod(XC_LoadPackage.LoadPackageParam loadPackageParam,SQLiteDatabase db, Context context) { - Class targetClass = XposedHelpers.findClass("SA.Q", loadPackageParam.classLoader); + private void hookSAMethod(XC_LoadPackage.LoadPackageParam loadPackageParam, SQLiteDatabase db, Context context) { + Class targetClass = XposedHelpers.findClass("SA.Q", loadPackageParam.classLoader); + XposedBridge.hookAllMethods(targetClass, "invokeSuspend", new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { - - XposedBridge.log("invokeSuspend method is called with parameters: " + param.args[0]); + - Context appContext = AndroidAppHelper.currentApplication(); if (appContext == null) { - XposedBridge.log("Context is null"); return; } - File dbFile = appContext.getDatabasePath("naver_line"); SQLiteDatabase db = null; @@ -115,50 +146,44 @@ public class Archived implements IHook { SQLiteDatabase.OpenParams dbParams = builder.build(); db = SQLiteDatabase.openDatabase(dbFile, dbParams); } else { - XposedBridge.log("Database file does not exist: " + dbFile.getPath()); return; } - - - List chatIds = readChatIdsFromFile(appContext); + List chatIds = readChatIdsFromFile(appContext, context); // 変更点 for (String chatId : chatIds) { if (!chatId.isEmpty()) { updateIsArchived(db, chatId); } } - if (db != null) { db.close(); } } }); - - } - private List readChatIdsFromFile(Context context) { + private List readChatIdsFromFile(Context context,Context moduleContext) { List chatIds = new ArrayList<>(); - File file = new File(context.getFilesDir(), "hidelist.txt"); + File dir = moduleContext.getFilesDir(); // moduleContextを使用 + File file = new File(dir, "hidelist.txt"); try (BufferedReader reader = new BufferedReader(new FileReader(file))) { String line; while ((line = reader.readLine()) != null) { chatIds.add(line.trim()); } - XposedBridge.log("Read chatIds from file: " + chatIds); } catch (IOException e) { - XposedBridge.log("Error reading chatIds from file: " + e.getMessage()); + } return chatIds; } - private void saveTalkIdToFile(String talkId, Context context) { - File dir = context.getFilesDir(); + private void saveTalkIdToFile(String talkId, Context moduleContext) { + File dir = moduleContext.getFilesDir(); // moduleContextを使用 if (!dir.exists()) { dir.mkdirs(); } @@ -166,26 +191,34 @@ public class Archived implements IHook { File file = new File(dir, "hidelist.txt"); try { - if (!file.exists()) { file.createNewFile(); } - try (FileWriter writer = new FileWriter(file, true)) { - writer.write(talkId + "\n"); - XposedBridge.log("Saved talkId: " + talkId + " to file."); + List existingIds = new ArrayList<>(); + try (BufferedReader reader = new BufferedReader(new FileReader(file))) { + String line; + while ((line = reader.readLine()) != null) { + existingIds.add(line.trim()); + } + } catch (IOException e) { + } + if (!existingIds.contains(talkId.trim())) { + try (FileWriter writer = new FileWriter(file, true)) { + writer.write(talkId + "\n"); + } } } catch (IOException e) { - XposedBridge.log("Error saving talkId to file: " + e.getMessage()); } } - private void updateArchivedChatsFromFile(SQLiteDatabase db, Context context) { - File file = new File(context.getFilesDir(), "hidelist.txt"); + private void updateArchivedChatsFromFile(SQLiteDatabase db, Context context,Context moduleContext) { + File dir = moduleContext.getFilesDir(); // moduleContextを使用 + File file = new File(dir, "hidelist.txt"); + if (!file.exists()) { - XposedBridge.log("hidelist.txt does not exist."); return; } @@ -198,35 +231,29 @@ public class Archived implements IHook { } } } catch (IOException e) { - XposedBridge.log("Error reading from hidelist.txt: " + e.getMessage()); + } } private String extractTalkId(String paramValue) { String talkId = null; - XposedBridge.log("Extracting talkId from paramValue: " + paramValue); - - String messageStart = "reqSeq:0,"; - int messageStartIndex = paramValue.indexOf(messageStart); - if (messageStartIndex != -1) { - String messagePart = paramValue.substring(messageStartIndex); - String fromPrefix = "param1:"; - int fromIndex = messagePart.indexOf(fromPrefix); - - if (fromIndex != -1) { - int endIndex = messagePart.indexOf(",", fromIndex); - if (endIndex == -1) { - endIndex = messagePart.indexOf(")", fromIndex); - } - if (endIndex != -1) { - talkId = messagePart.substring(fromIndex + fromPrefix.length(), endIndex).trim(); - XposedBridge.log("Extracted talkId: " + talkId); - } + String requestPrefix = "setChatHiddenStatusRequest:SetChatHiddenStatusRequest(reqSeq:0, chatMid:"; + int startIndex = paramValue.indexOf(requestPrefix); + + if (startIndex != -1) { + int chatMidStartIndex = startIndex + requestPrefix.length(); + int endIndex = paramValue.indexOf(",", chatMidStartIndex); + if (endIndex == -1) { + endIndex = paramValue.indexOf(")", chatMidStartIndex); + } + if (endIndex != -1) { + talkId = paramValue.substring(chatMidStartIndex, endIndex).trim(); + } } if (talkId == null) { - XposedBridge.log("No talkId found in the provided paramValue."); + } return talkId; @@ -234,7 +261,7 @@ public class Archived implements IHook { private String queryDatabase(SQLiteDatabase db, String query, String... selectionArgs) { if (db == null) { - XposedBridge.log("Database is not initialized."); + return null; } try (Cursor cursor = db.rawQuery(query, selectionArgs)) { @@ -242,43 +269,32 @@ public class Archived implements IHook { return cursor.getString(0); } } catch (Exception e) { - XposedBridge.log("Error querying database: " + e.getMessage()); } return null; } private void updateDatabase(SQLiteDatabase db, String query, Object... bindArgs) { if (db == null) { - XposedBridge.log("Database is not initialized."); return; } - try { db.beginTransaction(); db.execSQL(query, bindArgs); db.setTransactionSuccessful(); - XposedBridge.log("Executed update query: " + query); } catch (Exception e) { - XposedBridge.log("Error executing update query: " + e.getMessage()); } finally { db.endTransaction(); } } private void updateIsArchived(SQLiteDatabase db, String chatId) { - String updateQuery = "UPDATE chat SET is_archived = 1 WHERE chat_id = ?"; - updateDatabase(db, updateQuery, chatId); - XposedBridge.log("Executed update query for chatId: " + chatId); String selectQuery = "SELECT is_archived FROM chat WHERE chat_id = ?"; String result = queryDatabase(db, selectQuery, chatId); - if (result != null) { - XposedBridge.log("is_archived for chatId " + chatId + " is now: " + result); } else { - XposedBridge.log("No chat found with chatId: " + chatId); } } } From 6e7ee889d8d1121bc7526f64e25cbdc8cc3f3ac3 Mon Sep 17 00:00:00 2001 From: areteruhiro <108941410+areteruhiro@users.noreply.github.com> Date: Mon, 14 Oct 2024 11:17:19 +0900 Subject: [PATCH 03/12] Update LimeOptions.java MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit オプションの追加 --- .../main/java/io/github/chipppppppppp/lime/LimeOptions.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/github/chipppppppppp/lime/LimeOptions.java b/app/src/main/java/io/github/chipppppppppp/lime/LimeOptions.java index 547b0541..73a410e4 100644 --- a/app/src/main/java/io/github/chipppppppppp/lime/LimeOptions.java +++ b/app/src/main/java/io/github/chipppppppppp/lime/LimeOptions.java @@ -33,6 +33,8 @@ public Option(String name, int id, boolean checked) { public Option blockTracking = new Option("block_tracking", R.string.switch_block_tracking, false); public Option stopVersionCheck = new Option("stop_version_check", R.string.switch_stop_version_check, false); public Option outputCommunication = new Option("output_communication", R.string.switch_output_communication, false); + public Option Archived = new Option("Archived_message", R.string.switch_archived, false); + public Option[] options = { removeVoom, @@ -54,6 +56,7 @@ public Option(String name, int id, boolean checked) { removeKeepUnread, blockTracking, stopVersionCheck, - outputCommunication + outputCommunication, + Archived }; } From 17842c309a873e5bdb0234bfe848b4f1a960b30c Mon Sep 17 00:00:00 2001 From: areteruhiro <108941410+areteruhiro@users.noreply.github.com> Date: Mon, 14 Oct 2024 11:25:22 +0900 Subject: [PATCH 04/12] Update Main.java --- app/src/main/java/io/github/chipppppppppp/lime/Main.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/github/chipppppppppp/lime/Main.java b/app/src/main/java/io/github/chipppppppppp/lime/Main.java index 4f913893..a64e6da2 100644 --- a/app/src/main/java/io/github/chipppppppppp/lime/Main.java +++ b/app/src/main/java/io/github/chipppppppppp/lime/Main.java @@ -11,6 +11,7 @@ import de.robv.android.xposed.callbacks.XC_LayoutInflated; import de.robv.android.xposed.callbacks.XC_LoadPackage; import io.github.chipppppppppp.lime.hooks.AddRegistrationOptions; +import io.github.chipppppppppp.lime.hooks.Archived; import io.github.chipppppppppp.lime.hooks.BlockTracking; import io.github.chipppppppppp.lime.hooks.CheckHookTargetVersion; import io.github.chipppppppppp.lime.hooks.Constants; @@ -33,6 +34,7 @@ import io.github.chipppppppppp.lime.hooks.SpoofAndroidId; import io.github.chipppppppppp.lime.hooks.SpoofUserAgent; + public class Main implements IXposedHookLoadPackage, IXposedHookInitPackageResources, IXposedHookZygoteInit { public static String modulePath; @@ -61,7 +63,8 @@ public class Main implements IXposedHookLoadPackage, IXposedHookInitPackageResou new KeepUnread(), new BlockTracking(), new ModifyResponse(), - new OutputRequest() + new OutputRequest(), + new Archived() }; public void handleLoadPackage(@NonNull XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable { From 7c0c61b53c4231638ecb0604698c03bb855a2b30 Mon Sep 17 00:00:00 2001 From: areteruhiro <108941410+areteruhiro@users.noreply.github.com> Date: Mon, 14 Oct 2024 11:27:57 +0900 Subject: [PATCH 05/12] Update Archived MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit オプションの追加 --- .../java/io/github/chipppppppppp/lime/hooks/Archived | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/github/chipppppppppp/lime/hooks/Archived b/app/src/main/java/io/github/chipppppppppp/lime/hooks/Archived index d9b5a02c..e0d836ee 100644 --- a/app/src/main/java/io/github/chipppppppppp/lime/hooks/Archived +++ b/app/src/main/java/io/github/chipppppppppp/lime/hooks/Archived @@ -1,5 +1,7 @@ package io.github.chipppppppppp.lime.hooks; +import static io.github.chipppppppppp.lime.Main.limeOptions; + import android.app.AndroidAppHelper; import android.app.Application; import android.content.Context; @@ -28,6 +30,7 @@ public class Archived implements IHook { @Override public void hook(LimeOptions limeOptions, XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable { + if (!limeOptions.Archived.checked) return; XposedBridge.hookAllMethods(Application.class, "onCreate", new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { @@ -36,9 +39,7 @@ public class Archived implements IHook { if (appContext == null) { return; } - - // moduleContextの定義 - Context moduleContext = appContext; // 必要に応じて変更 + Context moduleContext = appContext; File dbFile = appContext.getDatabasePath("naver_line"); @@ -56,8 +57,8 @@ public class Archived implements IHook { } }); } - private void hookMessageDeletion(XC_LoadPackage.LoadPackageParam loadPackageParam, Context context, SQLiteDatabase db,Context moduleContext) { + if (!limeOptions.Archived.checked) return; try { @@ -130,7 +131,7 @@ public class Archived implements IHook { XposedBridge.hookAllMethods(targetClass, "invokeSuspend", new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { - + Context appContext = AndroidAppHelper.currentApplication(); if (appContext == null) { From 056eb9187924f834d8de569fff57755d2f6f57dd Mon Sep 17 00:00:00 2001 From: areteruhiro <108941410+areteruhiro@users.noreply.github.com> Date: Mon, 14 Oct 2024 11:29:01 +0900 Subject: [PATCH 06/12] Update LimeOptions.java --- .../main/java/io/github/chipppppppppp/lime/LimeOptions.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/github/chipppppppppp/lime/LimeOptions.java b/app/src/main/java/io/github/chipppppppppp/lime/LimeOptions.java index 73a410e4..c3a3ceae 100644 --- a/app/src/main/java/io/github/chipppppppppp/lime/LimeOptions.java +++ b/app/src/main/java/io/github/chipppppppppp/lime/LimeOptions.java @@ -53,10 +53,11 @@ public Option(String name, int id, boolean checked) { preventMarkAsRead, preventUnsendMessage, sendMuteMessage, + Archived, removeKeepUnread, blockTracking, stopVersionCheck, - outputCommunication, - Archived + outputCommunication + }; } From 348dec23aaebf33ffaeb7734f8480ab3ea766478 Mon Sep 17 00:00:00 2001 From: areteruhiro <108941410+areteruhiro@users.noreply.github.com> Date: Mon, 14 Oct 2024 13:37:32 +0900 Subject: [PATCH 07/12] Rename Archived to Archived.java --- .../github/chipppppppppp/lime/hooks/{Archived => Archived.java} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/src/main/java/io/github/chipppppppppp/lime/hooks/{Archived => Archived.java} (100%) diff --git a/app/src/main/java/io/github/chipppppppppp/lime/hooks/Archived b/app/src/main/java/io/github/chipppppppppp/lime/hooks/Archived.java similarity index 100% rename from app/src/main/java/io/github/chipppppppppp/lime/hooks/Archived rename to app/src/main/java/io/github/chipppppppppp/lime/hooks/Archived.java From 1a992c988fe322fa2eea3f1c99fce3ca74ba00c9 Mon Sep 17 00:00:00 2001 From: areteruhiro <108941410+areteruhiro@users.noreply.github.com> Date: Mon, 14 Oct 2024 21:48:06 +0900 Subject: [PATCH 08/12] Update strings.xml --- app/src/main/res/values-ja/strings.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 87713198..5ac58c9e 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -15,6 +15,10 @@ 強制停止とキャッシュの削除が必要です Android ID を偽装 Android ID の偽装は自己責任です + アプリのバージョン偽装は自己責任です + Device名 + OS 名 + OS バージョン バージョン不適合のため一部機能が利用できません 最大バージョンに偽装 設定を LINE に埋め込まない (設定は同期されません) From 094fd91147ca8720aa0532283f76f53c3d492ebf Mon Sep 17 00:00:00 2001 From: areteruhiro <108941410+areteruhiro@users.noreply.github.com> Date: Mon, 14 Oct 2024 21:50:09 +0900 Subject: [PATCH 09/12] Update strings.xml --- app/src/main/res/values/strings.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5e406085..90cf8974 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -15,6 +15,11 @@ Forced stop and cache clearing are required Spoof Android ID Spoofing Android ID is at your own risk + Spoofing LINE Version is at your own risk + Device name + OS name + OS version + App version Some functions are not available due to version incompatibility Disguise as the highest version Do not embed options in LINE (options will not be synchronized) From 409ebb2f8e23e267ae0a9df70872f22fd72df410 Mon Sep 17 00:00:00 2001 From: areteruhiro <108941410+areteruhiro@users.noreply.github.com> Date: Mon, 14 Oct 2024 22:00:49 +0900 Subject: [PATCH 10/12] Update Archived.java --- .../chipppppppppp/lime/hooks/Archived.java | 196 ++++++------------ 1 file changed, 62 insertions(+), 134 deletions(-) diff --git a/app/src/main/java/io/github/chipppppppppp/lime/hooks/Archived.java b/app/src/main/java/io/github/chipppppppppp/lime/hooks/Archived.java index e0d836ee..7e99b824 100644 --- a/app/src/main/java/io/github/chipppppppppp/lime/hooks/Archived.java +++ b/app/src/main/java/io/github/chipppppppppp/lime/hooks/Archived.java @@ -5,16 +5,15 @@ import android.app.AndroidAppHelper; import android.app.Application; import android.content.Context; -import android.content.pm.PackageManager; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; + import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; -import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; @@ -23,45 +22,37 @@ import de.robv.android.xposed.XposedHelpers; import de.robv.android.xposed.callbacks.XC_LoadPackage; import io.github.chipppppppppp.lime.LimeOptions; -import io.github.chipppppppppp.lime.Main; public class Archived implements IHook { - @Override public void hook(LimeOptions limeOptions, XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable { if (!limeOptions.Archived.checked) return; + XposedBridge.hookAllMethods(Application.class, "onCreate", new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { Application appContext = (Application) param.thisObject; - - if (appContext == null) { - return; - } - Context moduleContext = appContext; + if (appContext == null) return; File dbFile = appContext.getDatabasePath("naver_line"); + if (!dbFile.exists()) return; - if (dbFile.exists()) { - SQLiteDatabase.OpenParams.Builder builder = new SQLiteDatabase.OpenParams.Builder(); - builder.addOpenFlags(SQLiteDatabase.OPEN_READWRITE); - SQLiteDatabase.OpenParams dbParams = builder.build(); - - SQLiteDatabase db = SQLiteDatabase.openDatabase(dbFile, dbParams); + SQLiteDatabase.OpenParams dbParams = new SQLiteDatabase.OpenParams.Builder() + .addOpenFlags(SQLiteDatabase.OPEN_READWRITE) + .build(); + SQLiteDatabase db = SQLiteDatabase.openDatabase(dbFile, dbParams); - hookSAMethod(loadPackageParam, db, appContext); - hookMessageDeletion(loadPackageParam, appContext, db, moduleContext); // moduleContextを渡す - } else { - } + hookSAMethod(loadPackageParam, db, appContext); + hookMessageDeletion(loadPackageParam, appContext, db, appContext); } }); } - private void hookMessageDeletion(XC_LoadPackage.LoadPackageParam loadPackageParam, Context context, SQLiteDatabase db,Context moduleContext) { - if (!limeOptions.Archived.checked) return; - try { + private void hookMessageDeletion(XC_LoadPackage.LoadPackageParam loadPackageParam, Context context, SQLiteDatabase db, Context moduleContext) { + if (!limeOptions.Archived.checked) return; + try { XposedBridge.hookAllMethods( loadPackageParam.classLoader.loadClass(Constants.REQUEST_HOOK.className), Constants.REQUEST_HOOK.methodName, @@ -69,132 +60,96 @@ private void hookMessageDeletion(XC_LoadPackage.LoadPackageParam loadPackagePara @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { String paramValue = param.args[1].toString(); - if (paramValue.contains("hidden:true")) { - String talkId = extractTalkId(paramValue); - if (talkId != null) { - saveTalkIdToFile(talkId, context); - updateArchivedChatsFromFile(db, context,moduleContext); - } - } - if (paramValue.contains("hidden:false")) { - String talkId = extractTalkId(paramValue); - if (talkId != null) { + String talkId = extractTalkId(paramValue); + if (talkId == null) return; - deleteTalkIdFromFile(talkId, context); - updateArchivedChatsFromFile(db, context,moduleContext); - } + if (paramValue.contains("hidden:true")) { + saveTalkIdToFile(talkId, context); + } else if (paramValue.contains("hidden:false")) { + deleteTalkIdFromFile(talkId, context); } + updateArchivedChatsFromFile(db, context, moduleContext); } }); - - } catch (ClassNotFoundException e) { + } catch (ClassNotFoundException ignored) { } } private void deleteTalkIdFromFile(String talkId, Context moduleContext) { - File dir = moduleContext.getFilesDir(); // moduleContextを使用 - File file = new File(dir, "hidelist.txt"); + File file = new File(moduleContext.getFilesDir(), "hidelist.txt"); + if (!file.exists()) return; - if (file.exists()) { - try { - List lines = new ArrayList<>(); - BufferedReader reader = new BufferedReader(new FileReader(file)); + try { + List lines = new ArrayList<>(); + try (BufferedReader reader = new BufferedReader(new FileReader(file))) { String line; while ((line = reader.readLine()) != null) { if (!line.trim().equals(talkId)) { lines.add(line); } } - reader.close(); + } - BufferedWriter writer = new BufferedWriter(new FileWriter(file)); + try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) { for (String remainingLine : lines) { writer.write(remainingLine); writer.newLine(); } - writer.close(); - } catch (IOException e) { } - } else { + } catch (IOException ignored) { } } - - - - - private void hookSAMethod(XC_LoadPackage.LoadPackageParam loadPackageParam, SQLiteDatabase db, Context context) { Class targetClass = XposedHelpers.findClass("SA.Q", loadPackageParam.classLoader); XposedBridge.hookAllMethods(targetClass, "invokeSuspend", new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { - - Context appContext = AndroidAppHelper.currentApplication(); - if (appContext == null) { - return; - } + if (appContext == null) return; File dbFile = appContext.getDatabasePath("naver_line"); - SQLiteDatabase db = null; - - if (dbFile.exists()) { - SQLiteDatabase.OpenParams.Builder builder = new SQLiteDatabase.OpenParams.Builder(); - builder.addOpenFlags(SQLiteDatabase.OPEN_READWRITE); - SQLiteDatabase.OpenParams dbParams = builder.build(); - db = SQLiteDatabase.openDatabase(dbFile, dbParams); - } else { - return; - } - List chatIds = readChatIdsFromFile(appContext, context); // 変更点 + if (!dbFile.exists()) return; + + SQLiteDatabase.OpenParams dbParams = new SQLiteDatabase.OpenParams.Builder() + .addOpenFlags(SQLiteDatabase.OPEN_READWRITE) + .build(); + SQLiteDatabase db = SQLiteDatabase.openDatabase(dbFile, dbParams); + + List chatIds = readChatIdsFromFile(appContext, context); for (String chatId : chatIds) { if (!chatId.isEmpty()) { updateIsArchived(db, chatId); } } - if (db != null) { - db.close(); - } + if (db != null) db.close(); } }); } - - - private List readChatIdsFromFile(Context context,Context moduleContext) { + private List readChatIdsFromFile(Context context, Context moduleContext) { List chatIds = new ArrayList<>(); - File dir = moduleContext.getFilesDir(); // moduleContextを使用 - File file = new File(dir, "hidelist.txt"); + File file = new File(moduleContext.getFilesDir(), "hidelist.txt"); try (BufferedReader reader = new BufferedReader(new FileReader(file))) { String line; while ((line = reader.readLine()) != null) { chatIds.add(line.trim()); } - } catch (IOException e) { - + } catch (IOException ignored) { } return chatIds; } - private void saveTalkIdToFile(String talkId, Context moduleContext) { - File dir = moduleContext.getFilesDir(); // moduleContextを使用 - if (!dir.exists()) { - dir.mkdirs(); - } - - File file = new File(dir, "hidelist.txt"); + File file = new File(moduleContext.getFilesDir(), "hidelist.txt"); try { - if (!file.exists()) { - file.createNewFile(); - } + if (!file.exists()) file.createNewFile(); List existingIds = new ArrayList<>(); try (BufferedReader reader = new BufferedReader(new FileReader(file))) { @@ -202,26 +157,20 @@ private void saveTalkIdToFile(String talkId, Context moduleContext) { while ((line = reader.readLine()) != null) { existingIds.add(line.trim()); } - } catch (IOException e) { } + if (!existingIds.contains(talkId.trim())) { try (FileWriter writer = new FileWriter(file, true)) { writer.write(talkId + "\n"); } } - } catch (IOException e) { + } catch (IOException ignored) { } } - - - private void updateArchivedChatsFromFile(SQLiteDatabase db, Context context,Context moduleContext) { - File dir = moduleContext.getFilesDir(); // moduleContextを使用 - File file = new File(dir, "hidelist.txt"); - - if (!file.exists()) { - return; - } + private void updateArchivedChatsFromFile(SQLiteDatabase db, Context context, Context moduleContext) { + File file = new File(moduleContext.getFilesDir(), "hidelist.txt"); + if (!file.exists()) return; try (BufferedReader reader = new BufferedReader(new FileReader(file))) { String chatId; @@ -231,58 +180,40 @@ private void updateArchivedChatsFromFile(SQLiteDatabase db, Context context,Cont updateIsArchived(db, chatId); } } - } catch (IOException e) { - + } catch (IOException ignored) { } } private String extractTalkId(String paramValue) { - String talkId = null; String requestPrefix = "setChatHiddenStatusRequest:SetChatHiddenStatusRequest(reqSeq:0, chatMid:"; int startIndex = paramValue.indexOf(requestPrefix); + if (startIndex == -1) return null; - if (startIndex != -1) { - int chatMidStartIndex = startIndex + requestPrefix.length(); - int endIndex = paramValue.indexOf(",", chatMidStartIndex); - if (endIndex == -1) { - endIndex = paramValue.indexOf(")", chatMidStartIndex); - } - if (endIndex != -1) { - talkId = paramValue.substring(chatMidStartIndex, endIndex).trim(); + int chatMidStartIndex = startIndex + requestPrefix.length(); + int endIndex = paramValue.indexOf(",", chatMidStartIndex); + if (endIndex == -1) endIndex = paramValue.indexOf(")", chatMidStartIndex); - } - } - - if (talkId == null) { - - } - - return talkId; + return endIndex != -1 ? paramValue.substring(chatMidStartIndex, endIndex).trim() : null; } private String queryDatabase(SQLiteDatabase db, String query, String... selectionArgs) { - if (db == null) { + if (db == null) return null; - return null; - } try (Cursor cursor = db.rawQuery(query, selectionArgs)) { - if (cursor.moveToFirst()) { - return cursor.getString(0); - } - } catch (Exception e) { + if (cursor.moveToFirst()) return cursor.getString(0); + } catch (Exception ignored) { } return null; } private void updateDatabase(SQLiteDatabase db, String query, Object... bindArgs) { - if (db == null) { - return; - } + if (db == null) return; + try { db.beginTransaction(); db.execSQL(query, bindArgs); db.setTransactionSuccessful(); - } catch (Exception e) { + } catch (Exception ignored) { } finally { db.endTransaction(); } @@ -293,9 +224,6 @@ private void updateIsArchived(SQLiteDatabase db, String chatId) { updateDatabase(db, updateQuery, chatId); String selectQuery = "SELECT is_archived FROM chat WHERE chat_id = ?"; - String result = queryDatabase(db, selectQuery, chatId); - if (result != null) { - } else { - } + queryDatabase(db, selectQuery, chatId); } } From 3e7211c2711f1d6ba7c9a49e5a7f6cf43841bf8c Mon Sep 17 00:00:00 2001 From: areteruhiro <108941410+areteruhiro@users.noreply.github.com> Date: Mon, 14 Oct 2024 22:01:37 +0900 Subject: [PATCH 11/12] Delete app/src/main/res/values/strings.xml --- app/src/main/res/values/strings.xml | 53 ----------------------------- 1 file changed, 53 deletions(-) delete mode 100644 app/src/main/res/values/strings.xml diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml deleted file mode 100644 index 90cf8974..00000000 --- a/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,53 +0,0 @@ - - LIME - - OK - Cancel - - - Clean LINE. - - - Error - Module not enabled! - Options - Restarting now... - Forced stop and cache clearing are required - Spoof Android ID - Spoofing Android ID is at your own risk - Spoofing LINE Version is at your own risk - Device name - OS name - OS version - App version - Some functions are not available due to version incompatibility - Disguise as the highest version - Do not embed options in LINE (options will not be synchronized) - Remove the VOOM icon - Remove the wallet icon - Remove the news or call icon - Distribute the icons on the bottom bar evenly - Extend the clickable area of the icons on the bottom bar - Remove the icon labels on the bottom bar - Remove ads - Remove recommendations - Remove LYP Premium recommendations - Remove tbe service labels - Remove the \"Mute chat\" action from notifications - Redirect WebView to the default browser - Open in the browser app - Always prevent marking as read - Always send mute messages - Prevent messages from unsending - Remove the \"Keep unread\" switch from the menu in the top right corner of the chat tab - Block tracking communications - Stop checking LINE version - Output communication contents to log (for developers) - Modify requests - Modify responses - Copy - Paste - - - Keep unread - From f6064184443ab79e4077d7cadc2030732bd4ee6e Mon Sep 17 00:00:00 2001 From: areteruhiro <108941410+areteruhiro@users.noreply.github.com> Date: Mon, 14 Oct 2024 22:01:49 +0900 Subject: [PATCH 12/12] Delete app/src/main/res/values-ja/strings.xml --- app/src/main/res/values-ja/strings.xml | 52 -------------------------- 1 file changed, 52 deletions(-) delete mode 100644 app/src/main/res/values-ja/strings.xml diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml deleted file mode 100644 index 5ac58c9e..00000000 --- a/app/src/main/res/values-ja/strings.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - OK - キャンセル - - - LINE をクリーンに。 - - - エラー - モジュールが有効化されていません! - 設定 - アプリを再起動しています... - 強制停止とキャッシュの削除が必要です - Android ID を偽装 - Android ID の偽装は自己責任です - アプリのバージョン偽装は自己責任です - Device名 - OS 名 - OS バージョン - バージョン不適合のため一部機能が利用できません - 最大バージョンに偽装 - 設定を LINE に埋め込まない (設定は同期されません) - VOOM アイコンを削除 - ウォレットアイコンを削除 - ニュースまたは通話アイコンを削除 - ボトムバーのアイコンを均等に配置 - ボトムバーのアイコンの当たり判定を拡張する - ボトムバーのアイコンのラベルを削除 - 広告を削除 - おすすめを削除 - LYP プレミアムのおすすめを削除 - サービスのラベルを削除 - 通知から \"通知をオフ\" アクションを削除 - WebView を既定のブラウザにリダイレクト - ブラウザアプリで開く - 常に既読をつけない - 常にミュートメッセージとして送信 - 送信取り消しを拒否 - トーク画面右上のメニューにある「未読のまま閲覧」スイッチを削除 - トラッキング通信をブロック - LINE バージョンの確認を停止 - 通信内容をログに出力 (開発者用) - リクエストを改変 - レスポンスを改変 - コピー - ペースト - - - 未読のまま閲覧 -