这是indexloc提供的服务,不要输入任何密码
Skip to content

Commit 4e9f154

Browse files
Fixed: Fix NullPointerException in TermuxFloatSessionClient.checkForFontAndColors()
``` com.termux.window E/Logger.TermuxFloatSessionClient: Error in checkForFontAndColors(): java.lang.NullPointerException: Attempt to invoke virtual method 'com.termux.terminal.TerminalSession com.termux.shared.termux.shell.command.runner.terminal.TermuxSession.getTerminalSession()' on a null object reference at com.termux.window.TermuxFloatSessionClient.checkForFontAndColors(TermuxFloatSessionClient.java:166) at com.termux.window.TermuxFloatSessionClient.onReload(TermuxFloatSessionClient.java:66) at com.termux.window.TermuxFloatView.reloadViewStyling(TermuxFloatView.java:361) at com.termux.window.TermuxFloatService.createTermuxSession(TermuxFloatService.java:235) at com.termux.window.TermuxFloatService.initializeFloatView(TermuxFloatService.java:179) at com.termux.window.TermuxFloatService.onStartCommand(TermuxFloatService.java:55) at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4320) at android.app.ActivityThread.access$1800(ActivityThread.java:237) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1951) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7664) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) ```
1 parent ecfea83 commit 4e9f154

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

app/src/main/java/com/termux/window/TermuxFloatService.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.termux.shared.shell.TermuxShellEnvironmentClient;
2323
import com.termux.shared.termux.TermuxConstants;
2424
import com.termux.shared.termux.TermuxConstants.TERMUX_FLOAT_APP.TERMUX_FLOAT_SERVICE;
25+
import com.termux.terminal.TerminalSession;
2526

2627
public class TermuxFloatService extends Service {
2728

@@ -237,8 +238,12 @@ public synchronized TermuxSession createTermuxSession(ExecutionCommand execution
237238
return newTermuxSession;
238239
}
239240

240-
public TermuxSession getSession() {
241+
public TermuxSession getTermuxSession() {
241242
return mSession;
242243
}
243244

245+
public TerminalSession getCurrentSession() {
246+
return mSession != null ? mSession.getTerminalSession() : null;
247+
}
248+
244249
}

app/src/main/java/com/termux/window/TermuxFloatSessionClient.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,11 @@ public void checkForFontAndColors() {
163163
}
164164

165165
TerminalColors.COLOR_SCHEME.updateWith(props);
166-
TerminalSession session = mService.getSession().getTerminalSession();
166+
TerminalSession session = mService.getCurrentSession();
167167
if (session != null && session.getEmulator() != null) {
168168
session.getEmulator().mColors.reset();
169169
}
170+
170171
updateBackgroundColor();
171172

172173
final Typeface newTypeface = (fontFile.exists() && fontFile.length() > 0) ? Typeface.createFromFile(fontFile) : Typeface.MONOSPACE;
@@ -178,7 +179,8 @@ public void checkForFontAndColors() {
178179

179180
public void updateBackgroundColor() {
180181
//if (!mView.isVisible()) return;
181-
TerminalSession session = mService.getSession().getTerminalSession();
182+
183+
TerminalSession session = mService.getCurrentSession();
182184
if (session != null && session.getEmulator() != null) {
183185
mView.getTerminalView().setBackgroundColor(session.getEmulator().mColors.mCurrentColors[TextStyle.COLOR_INDEX_BACKGROUND]);
184186
}

0 commit comments

Comments
 (0)