Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use TransportPaths class instead of static path variables #354

Merged
merged 8 commits into from
Oct 15, 2024

Conversation

pankinkun
Copy link
Collaborator

No description provided.

@pankinkun pankinkun requested a review from breed October 8, 2024 22:51
@pankinkun pankinkun requested a review from darrensh3n October 9, 2024 05:26
import java.nio.file.Path;

@Getter
@Setter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't want setters because once the paths are initialized, we don't want them to change, and we probably don't want getters either since the fields are public.

@Setter
public class TransportPaths{
@Getter
public Path fromClient;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make the fields final.

@@ -3,6 +3,11 @@
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.SEVERE;

import android.content.Context;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why were these imports added? you probably want to run the optimized imports helper.

@@ -181,4 +183,8 @@ TransportWifiDirectService getService() {
return TransportWifiDirectService.this;
}
}

public void setTransportPaths(TransportPaths transportPaths) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think we want this. we might end up with a race condition. TransportWifiDirectService should probably make it's own TransportPaths in onStartCommand()

@@ -42,12 +43,12 @@ public RpcServer(BundleExchangeServiceImpl.BundleExchangeEventListener listener)
this.listener = listener;
}

public void startServer(Context context) {
public void startServer(Context context, TransportPaths transportPaths) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you still need to pass the context?

import java.nio.file.Path;
import java.util.logging.Logger;

import static java.util.logging.Level.SEVERE;

@Getter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can get rid of the getters too.

@Getter
public Path toServer;
public final Path toServer;

public TransportPaths(Path rootDir){
this.toServer = rootDir.resolve("BundleTransmission/server");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since toServer is the same as fromClient, you should pick only one and delete the other, otherwise bug fixes to one might not propagate to the other.

Comment on lines 29 to 35
public Path getToClient(){ return clientPath; }

public Path getToServer(){ return serverPath; }

public Path getFromClient(){ return serverPath; }

public Path getFromServer(){ return clientPath; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think you should have these getters. the code will be confusing with an inconsistent use of getFromServer and getToClient for the same path. just make the member variables public.

Files.createDirectories(serverPath);
}
} catch (Exception e) {
logger.log(SEVERE, "Failed to get inventory", e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure what this message means. perhaps "Failed to create transport storage directories" is better?

Comment on lines 12 to 13
private final Path clientPath;
private final Path serverPath;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make public. change to toClientPath and toServerPath to get the directions clear.

Comment on lines 6 to 8
import android.os.Handler;
import android.os.Looper;
import android.widget.Toast;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did these get added? did you use the optimize imports tool?

@pankinkun pankinkun merged commit 61f3141 into main Oct 15, 2024
1 check passed
@pankinkun pankinkun deleted the transport-paths-fix branch October 15, 2024 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants