feat(Utils): Use more Contexts for activities/services to avoid NullPointerException in Context.getResources()

This commit is contained in:
inotia00
2025-01-15 22:12:29 +09:00
parent f540fb8cc5
commit e5361e90fe
7 changed files with 175 additions and 2 deletions

View File

@ -359,7 +359,17 @@ public class Utils {
//
// Info level also helps debug if a patch hook is called before
// the context is set since debug logging is off by default.
Logger.initializationInfo(Utils.class, "Set context: " + appContext);
StringBuilder sb = new StringBuilder();
sb.append("Set context: ");
sb.append(appContext);
StackTraceElement[] stackTraceElement = Thread.currentThread().getStackTrace();
if (stackTraceElement.length > 3) {
sb.append("\n");
sb.append("Called from method: ");
sb.append(stackTraceElement[3]);
}
Logger.initializationInfo(Utils.class, sb.toString());
}
public static void setClipboard(@NonNull String text) {