fix: extend service bind timeout and improve getPrefsPath

This commit is contained in:
NkBe 2025-10-29 21:40:12 +08:00
parent 094be621af
commit c30f588b50
No known key found for this signature in database
GPG Key ID: 525137026FF031DF
1 changed files with 7 additions and 3 deletions

View File

@ -71,7 +71,7 @@ public class RemoteApplicationService implements ILSPApplicationService {
var userHandle = (UserHandle) getUserMethod.invoke(context);
bindServiceAsUserMethod.invoke(context, intent, conn, Context.BIND_AUTO_CREATE, handler, userHandle);
}
boolean success = latch.await(1, TimeUnit.SECONDS);
boolean success = latch.await(3, TimeUnit.SECONDS);
if (!success) {
// Attempt to unbind the service before throwing a timeout for cleanup
@ -106,8 +106,12 @@ public class RemoteApplicationService implements ILSPApplicationService {
}
@Override
public String getPrefsPath(String packageName) {
return new File(Environment.getDataDirectory(), "data/" + packageName + "/shared_prefs/").getAbsolutePath();
public String getPrefsPath(String packageName) throws RemoteException {
if (service != null) {
return service.getPrefsPath(packageName);
}
Log.e(TAG, "Manager service null, 無法取得遠端首選項路徑.");
throw new RemoteException("Manager service is unavailable for getPrefsPath.");
}
@Override