Skip to content

Commit

Permalink
Small fix and warnings from the trace UI changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmuetschard committed May 3, 2018
1 parent dc6a0f0 commit 4e14db4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
16 changes: 11 additions & 5 deletions gapic/src/main/com/google/gapid/models/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,12 @@ public void addToRecent(String file) {
}

public String[] getRecent() {
return stream(recentFiles).map(file -> new File(file)).filter(File::exists)
.filter(File::canRead).map(File::getAbsolutePath).toArray(l -> new String[l]);
return stream(recentFiles)
.map(file -> new File(file))
.filter(File::exists)
.filter(File::canRead)
.map(File::getAbsolutePath)
.toArray(String[]::new);
}

public boolean analyticsEnabled() {
Expand Down Expand Up @@ -313,7 +317,8 @@ private static int[] getIntList(Properties properties, String name, int[] dflt)
}

try {
return stream(Splitter.on(',').split(value).spliterator(), false).mapToInt(Integer::parseInt)
return stream(Splitter.on(',').split(value).spliterator(), false)
.mapToInt(Integer::parseInt)
.toArray();
} catch (NumberFormatException e) {
return dflt;
Expand All @@ -328,7 +333,8 @@ private static double[] getDoubleList(Properties properties, String name, double

try {
return stream(Splitter.on(',').split(value).spliterator(), false)
.mapToDouble(Double::parseDouble).toArray();
.mapToDouble(Double::parseDouble)
.toArray();
} catch (NumberFormatException e) {
return dflt;
}
Expand All @@ -341,7 +347,7 @@ private static String[] getStringList(Properties properties, String name, String
}
return stream(
Splitter.on(',').trimResults().omitEmptyStrings().split(value).spliterator(), false)
.toArray(l -> new String[l]);
.toArray(String[]::new);
}

private static void setPoint(Properties properties, String name, Point point) {
Expand Down
8 changes: 4 additions & 4 deletions gapic/src/main/com/google/gapid/server/Tracer.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ public static abstract class TraceRequest {
public final boolean midExecution;
public final boolean disableBuffering;

public TraceRequest(Api api, File output, int frameCount, boolean midExecution, boolean disableBuffering) {
public TraceRequest(
Api api, File output, int frameCount, boolean midExecution, boolean disableBuffering) {
this.api = api;
this.output = output;
this.frameCount = frameCount;
Expand Down Expand Up @@ -174,10 +175,10 @@ public static class AndroidTraceRequest extends TraceRequest {
public final String intentArgs;
public final boolean clearCache;
public final boolean disablePcs;
public final boolean disableBuffering;

public AndroidTraceRequest(Api api, Device.Instance device, String action, String intentArgs,
File output, int frameCount, boolean midExecution, boolean disableBuffering, boolean clearCache, boolean disablePcs) {
File output, int frameCount, boolean midExecution, boolean disableBuffering,
boolean clearCache, boolean disablePcs) {
this(api, device, null, null, action, intentArgs, output, frameCount, midExecution,
disableBuffering, clearCache, disablePcs);
}
Expand All @@ -193,7 +194,6 @@ public AndroidTraceRequest(Api api, Device.Instance device, String pkg, String a
this.intentArgs = intentArgs;
this.clearCache = clearCache;
this.disablePcs = disablePcs;
this.disableBuffering = disableBuffering;
}

@Override
Expand Down
24 changes: 13 additions & 11 deletions gapic/src/main/com/google/gapid/views/TracerDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ private abstract static class SharedTraceInput extends Composite {
protected final Text file;
protected final Spinner frameCount;
protected final Button fromBeginning;
protected final Button traceWithoutBuffering;
protected final Button withoutBuffering;
protected boolean userHasChangedOutputFile = false;

public SharedTraceInput(Composite parent, Models models, Widgets widgets) {
Expand Down Expand Up @@ -306,7 +306,7 @@ protected void configureDialog(DirectoryDialog dialog) {
new GridData(SWT.FILL, SWT.FILL, true, false));

createLabel(this, "");
traceWithoutBuffering = withLayoutData(
withoutBuffering = withLayoutData(
createCheckbox(this, "Disable Buffering", models.settings.traceWithoutBuffering),
new GridData(SWT.FILL, SWT.FILL, true, false));

Expand Down Expand Up @@ -351,15 +351,16 @@ public TraceRequest getTraceRequest(Settings settings) {
settings.traceOutDir = directory.getText();
settings.traceFrameCount = frameCount.getSelection();
settings.traceMidExecution = !fromBeginning.getSelection();
settings.traceWithoutBuffering = traceWithoutBuffering.getSelection();
settings.traceWithoutBuffering = withoutBuffering.getSelection();

return getTraceRequest(settings, getSelectedApi(), getOutputFile(),
frameCount.getSelection(), !fromBeginning.getSelection(), traceWithoutBuffering.getSelection());
frameCount.getSelection(), !fromBeginning.getSelection(),
withoutBuffering.getSelection());
}

protected abstract TraceRequest getTraceRequest(
Settings settings, Tracer.Api traceApi, File output, int frames, boolean midExecution,
boolean traceWithoutBuffering);
boolean disableBuffering);

protected Tracer.Api getSelectedApi() {
return (Tracer.Api)api.getStructuredSelection().getFirstElement();
Expand Down Expand Up @@ -557,7 +558,7 @@ private void updateDevicesDropDown(Settings settings) {

@Override
protected TraceRequest getTraceRequest(Settings settings, Tracer.Api traceApi, File output,
int frames, boolean midExecution, boolean traceWithoutBuffering) {
int frames, boolean midExecution, boolean disableBuffering) {
String target = traceTarget.getText();
int actionSep = target.indexOf(":");
int pkgSep = target.indexOf("/");
Expand All @@ -573,11 +574,12 @@ protected TraceRequest getTraceRequest(Settings settings, Tracer.Api traceApi, F
String pkg = target.substring(actionSep + 1, pkgSep);
String activity = target.substring(pkgSep + 1);
return new AndroidTraceRequest(traceApi, getSelectedDevice(), pkg, activity, action,
arguments.getText(), output, frames, midExecution, traceWithoutBuffering, clearCache.getSelection(),
disablePcs.getSelection());
arguments.getText(), output, frames, midExecution, disableBuffering,
clearCache.getSelection(), disablePcs.getSelection());
} else {
return new AndroidTraceRequest(traceApi, getSelectedDevice(), target, arguments.getText(),
output, frames, midExecution, traceWithoutBuffering, clearCache.getSelection(), disablePcs.getSelection());
output, frames, midExecution, disableBuffering, clearCache.getSelection(),
disablePcs.getSelection());
}
}

Expand Down Expand Up @@ -677,15 +679,15 @@ public void addModifyListener(Listener listener) {

@Override
protected TraceRequest getTraceRequest(Settings settings, Tracer.Api traceApi, File output,
int frames, boolean midExecution, boolean traceWithoutBuffering) {
int frames, boolean midExecution, boolean disableBuffering) {
settings.traceExecutable = executable.getText();
settings.traceArgs = arguments.getText();
settings.traceCwd = cwd.getText();

return new DesktopTraceRequest(
new File(executable.getText()), arguments.getText(),
cwd.getText().isEmpty() ? null : new File(cwd.getText()), output, frames,
midExecution, traceWithoutBuffering);
midExecution, disableBuffering);
}
}
}
Expand Down

0 comments on commit 4e14db4

Please sign in to comment.