本文整理汇总了Java中com.android.ddmlib.Client类的典型用法代码示例。如果您正苦于以下问题:Java Client类的具体用法?Java Client怎么用?Java Client使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Client类属于com.android.ddmlib包,在下文中一共展示了Client类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateProcessList
import com.android.ddmlib.Client; //导入依赖的package包/类
/**
* Updates the process list
*/
public void updateProcessList() {
if (logListener != null) {
UIUtil.invokeLaterIfNeeded(() -> {
try {
if (device != null && logListener != null) {
List<Client> clients = Lists.newArrayList(device.getClients());
clients.sort(new ClientCellRenderer.ClientComparator());
logListener.onProcessList(toLogProcess(clients));
}
} catch (Exception ignored) {
}
});
}
}
示例2: observeForDeviceChange
import com.android.ddmlib.Client; //导入依赖的package包/类
/**
* Observe for deviec state changes
*/
private void observeForDeviceChange() {
deviceSelectionListener =
new DeviceContext.DeviceSelectionListener() {
@Override
public void deviceSelected(@Nullable IDevice device) {
notifyDeviceUpdated(device);
}
@Override
public void deviceChanged(@NotNull IDevice device, int changeMask) {
if ((changeMask & IDevice.CHANGE_STATE) == IDevice.CHANGE_STATE) {
notifyDeviceUpdated(device);
}
}
@Override
public void clientSelected(@Nullable final Client c) {
}
};
deviceContext.addListener(deviceSelectionListener, this);
AndroidDebugBridge.addClientChangeListener(this);
AndroidDebugBridge.addDeviceChangeListener(this);
AndroidDebugBridge.addDebugBridgeChangeListener(this);
}
示例3: getProcessName
import com.android.ddmlib.Client; //导入依赖的package包/类
/**
* Get a reference to the name of the process with the given ID. The
* reference may contain a null-object, couldn't be retrieved, but may be
* available later.
*
* @param device Device, where the process runs.
* @param pid ID of the process.
* @return A reference to a string containing the process name or
* {@code null}, if the process couldn't be retrieved yet.
*/
private String[] getProcessName(IDevice device, int pid) {
Map<Integer, String[]> cache = processNameCache.get(device.getSerialNumber());
if (cache == null) {
cache = new HashMap<>();
processNameCache.put(device.getSerialNumber(), cache);
}
String[] nameref = cache.get(pid);
if (nameref == null) {
nameref = new String[1];
cache.put(pid, nameref);
}
if (nameref[0] == null) {
for (Client client : device.getClients()) {
ClientData data = client.getClientData();
if (data.getPid() == pid) {
nameref[0] = data.getClientDescription();
}
}
}
return nameref;
}
示例4: doOKAction
import com.android.ddmlib.Client; //导入依赖的package包/类
@Override
protected void doOKAction() {
final PropertiesComponent properties = PropertiesComponent.getInstance(myProject);
final IDevice selectedDevice = getSelectedDevice();
if (selectedDevice == null) {
return;
}
final Client selectedClient = getSelectedClient();
if (selectedClient == null) {
return;
}
super.doOKAction();
properties.setValue(DEBUGGABLE_DEVICE_PROPERTY, selectedDevice.getName());
properties.setValue(DEBUGGABLE_PROCESS_PROPERTY, selectedClient.getClientData().getClientDescription());
properties.setValue(SHOW_ALL_PROCESSES_PROPERTY, Boolean.toString(myShowAllProcessesCheckBox.isSelected()));
final String debugPort = Integer.toString(selectedClient.getDebuggerListenPort());
closeOldSessionAndRun(debugPort);
}
示例5: renderClient
import com.android.ddmlib.Client; //导入依赖的package包/类
private static void renderClient(@NotNull Client c, ColoredTextContainer container) {
ClientData cd = c.getClientData();
String name = cd.getClientDescription();
if (name == null) {
return;
}
Pair<String, String> app = splitApplicationName(name);
container.append(app.getFirst(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
container.append(app.getSecond(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
if (cd.isValidUserId() && cd.getUserId() != 0) {
container.append(String.format(" (user %1$d)", cd.getUserId()), SimpleTextAttributes.GRAY_ATTRIBUTES);
}
container.append(String.format(" (%1$d)", cd.getPid()), SimpleTextAttributes.GRAY_ATTRIBUTES);
if (!c.isValid()) {
container.append(" [DEAD]", SimpleTextAttributes.GRAYED_BOLD_ATTRIBUTES);
}
}
示例6: setSelected
import com.android.ddmlib.Client; //导入依赖的package包/类
@Override
protected void setSelected(@NotNull Client c) {
long now = System.currentTimeMillis();
if (c.getClientData().getAllocationStatus() == ClientData.AllocationTrackingStatus.ON) {
c.requestAllocationDetails();
c.enableAllocationTracker(false);
if (myEvent == null) {
// Unexpected end of tracking, start now:
myEvent = myEvents.start(now, MemoryMonitorView.EVENT_ALLOC);
}
myEvent.stop(now);
myEvent = null;
} else {
c.enableAllocationTracker(true);
if (myEvent != null) {
// TODO add support for different end types (error, etc)
myEvent.stop(now);
}
myEvent = myEvents.start(now, MemoryMonitorView.EVENT_ALLOC);
}
c.requestAllocationStatus();
}
示例7: update
import com.android.ddmlib.Client; //导入依赖的package包/类
@Override
public final void update(AnActionEvent e) {
super.update(e);
Presentation presentation = e.getPresentation();
Client c = myDeviceContext.getSelectedClient();
if (c == null || !c.isValid()) {
presentation.setEnabled(false);
return;
}
String text = getActiveText(c);
presentation.setText(text);
presentation.setEnabled(true);
}
示例8: onSuccess
import com.android.ddmlib.Client; //导入依赖的package包/类
@Override
public void onSuccess(@NotNull final byte[] data, @NotNull Client client) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
try {
CaptureService service = CaptureService.getInstance(myProject);
service.createCapture(AllocationCaptureType.class, data);
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
});
}
});
}
示例9: initializeClientCombo
import com.android.ddmlib.Client; //导入依赖的package包/类
private void initializeClientCombo() {
myClientCombo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
if (myIgnoreActionEvents) return;
Client client = (Client)myClientCombo.getSelectedItem();
if (client != null) {
myPreferredClients.put(client.getDevice().getName(), client.getClientData().getClientDescription());
}
myDeviceContext.fireClientSelected(client);
}
});
myClientCombo.setRenderer(new ClientCellRenderer("No Debuggable Applications"));
Dimension size = myClientCombo.getMinimumSize();
myClientCombo.setMinimumSize(new Dimension(250, size.height));
}
示例10: onSuccess
import com.android.ddmlib.Client; //导入依赖的package包/类
@Override
public void onSuccess(@NotNull final byte[] data, @NotNull Client client) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
try {
CaptureService service = CaptureService.getInstance(myProject);
service.createCapture(VmTraceCaptureType.class, data);
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
});
}
});
}
示例11: waitForProcess
import com.android.ddmlib.Client; //导入依赖的package包/类
@NotNull
public ProcessListFixture waitForProcess(@NotNull final String packageName) {
pause(new Condition("Wait for the process list to show the package name.") {
@Override
public boolean test() {
//noinspection ConstantConditions
return execute(new GuiQuery<Boolean>() {
@Override
protected Boolean executeInEDT() throws Throwable {
ListModel model = target().getModel();
int size = model.getSize();
for (int i = 0; i < size; ++i) {
Client client = (Client)model.getElementAt(i);
String clientDescription = client.getClientData().getClientDescription();
if (packageName.equals(clientDescription)) {
return true;
}
}
return false;
}
});
}
}, LONG_TIMEOUT);
return this;
}
示例12: selectItem
import com.android.ddmlib.Client; //导入依赖的package包/类
@Override
@NotNull
public ProcessListFixture selectItem(@Nullable final String packageName) {
clearSelection();
assertNotNull(packageName);
Integer index = execute(new GuiQuery<Integer>() {
@Override
protected Integer executeInEDT() throws Throwable {
for (int i = 0; i < target().getModel().getSize(); ++i) {
Client client = (Client)target().getModel().getElementAt(i);
if (packageName.equals(client.getClientData().getClientDescription())) {
return i;
}
}
return -1;
}
});
assertNotNull(index);
assertThat(index).isGreaterThanOrEqualTo(0);
selectItem(index);
return this;
}
示例13: clientSelected
import com.android.ddmlib.Client; //导入依赖的package包/类
/**
* Sent when a new client is selected. The new client can be accessed
* with {@link #getCurrentClient()}.
*/
@Override
public void clientSelected() {
if (mAllocationTable.isDisposed()) {
return;
}
Client client = getCurrentClient();
mStackTracePanel.setCurrentClient(client);
mStackTracePanel.setViewerInput(null); // always empty on client selection change.
if (client != null) {
setUpButtons(true /* enabled */, client.getClientData().getAllocationStatus());
} else {
setUpButtons(false /* enabled */, AllocationTrackingStatus.OFF);
}
mAllocationViewer.setInput(client);
}
示例14: addToImportedSnapshots
import com.android.ddmlib.Client; //导入依赖的package包/类
private void addToImportedSnapshots(NativeHeapSnapshot snapshot) {
Client c = getCurrentClient();
if (c == null) {
return;
}
Integer pid = c.getClientData().getPid();
List<NativeHeapSnapshot> importedSnapshots = mImportedSnapshotsPerPid.get(pid);
if (importedSnapshots == null) {
importedSnapshots = new ArrayList<NativeHeapSnapshot>();
}
importedSnapshots.add(snapshot);
mImportedSnapshotsPerPid.put(pid, importedSnapshots);
}
示例15: clientChanged
import com.android.ddmlib.Client; //导入依赖的package包/类
/**
* Sent when an existing client information changed.
* <p/>
* This is sent from a non UI thread.
* @param client the updated client.
* @param changeMask the bit mask describing the changed properties. It can contain
* any of the following values: {@link Client#CHANGE_INFO}, {@link Client#CHANGE_NAME}
* {@link Client#CHANGE_DEBUGGER_STATUS}, {@link Client#CHANGE_THREAD_MODE},
* {@link Client#CHANGE_THREAD_DATA}, {@link Client#CHANGE_HEAP_MODE},
* {@link Client#CHANGE_HEAP_DATA}, {@link Client#CHANGE_NATIVE_HEAP_DATA}
*
* @see IClientChangeListener#clientChanged(Client, int)
*/
@Override
public void clientChanged(final Client client, int changeMask) {
if (client == getCurrentClient()) {
if ((changeMask & Client.CHANGE_HEAP_MODE) == Client.CHANGE_HEAP_MODE ||
(changeMask & Client.CHANGE_HEAP_DATA) == Client.CHANGE_HEAP_DATA) {
try {
mTop.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
clientSelected();
}
});
} catch (SWTException e) {
// display is disposed (app is quitting most likely), we do nothing.
}
}
}
}