Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions src/io/flutter/run/LaunchState.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
Expand Down Expand Up @@ -171,16 +170,12 @@ protected RunContentDescriptor launch(@NotNull ExecutionEnvironment env) throws
final String nameWithDeviceName = descriptor.getDisplayName() + " (" + device.deviceName() + ")";

try {
// There is no public way to set display name so we resort to reflection.
final Field f = descriptor.getClass().getDeclaredField("myDisplayNameView");
f.setAccessible(true);
Object viewInstance = f.get(descriptor);
if (viewInstance != null) {
final Method setValueMethod = viewInstance.getClass().getMethod("setValue", Object.class);
setValueMethod.invoke(viewInstance, nameWithDeviceName);
}
// RunContentDescriptor.setDisplayName() is protected, so we use reflection to call it.
final Method setDisplayName = RunContentDescriptor.class.getDeclaredMethod("setDisplayName", String.class);
setDisplayName.setAccessible(true);
setDisplayName.invoke(descriptor, nameWithDeviceName);
}
catch (IllegalAccessException | InvocationTargetException | NoSuchFieldException | NoSuchMethodException e) {
catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
FlutterUtils.info(LOG, "Error setting display name", e, true);
}

Expand Down
Loading