Fix: Choose service according to embedded module

Improve startup resilience by selecting the application service according to availability: catch Throwable from manager lookup and clear service on failure, then if service is null check hasEmbeddedModules(context) to prefer IntegrApplicationService when embedded modules exist, otherwise use NeoLocalApplicationService. Also refine logging levels/messages (info on success, warn on failure) to provide clearer diagnostics.
This commit is contained in:
NkBe 2026-02-11 21:36:13 +08:00
parent f2713a342b
commit 7844b99b3a
No known key found for this signature in database
GPG Key ID: 9FACEE0DB6DF678E
1 changed files with 13 additions and 5 deletions

View File

@ -115,13 +115,21 @@ public class LSPApplication {
} }
SharedPreferences shared = context.getSharedPreferences("npatch", Context.MODE_PRIVATE); SharedPreferences shared = context.getSharedPreferences("npatch", Context.MODE_PRIVATE);
shared.edit().putString("modules", moduleArr.toString()).apply(); shared.edit().putString("modules", moduleArr.toString()).apply();
Log.e(TAG, "Success update module scope"); Log.i(TAG, "Success update module scope from Manager");
} catch (Exception e) { } catch (Throwable e) {
Log.e(TAG, "Failed to connect to manager, fallback to fixed local service"); Log.w(TAG, "Failed to connect to manager: " + e.getMessage());
service = null;
}
}
if (service == null) {
if (hasEmbeddedModules(context)) {
Log.i(TAG, "Using Integrated Service (Embedded Modules Found)");
service = new IntegrApplicationService(context);
} else {
Log.i(TAG, "Using NeoLocal Service (Cached Config)");
service = new NeoLocalApplicationService(context); service = new NeoLocalApplicationService(context);
} }
} else {
service = new IntegrApplicationService(context);
} }
disableProfile(context); disableProfile(context);