当前位置: 首页>>代码示例>>Java>>正文


Java OnLineListener类代码示例

本文整理汇总了Java中eu.chainfire.libsuperuser.StreamGobbler.OnLineListener的典型用法代码示例。如果您正苦于以下问题:Java OnLineListener类的具体用法?Java OnLineListener怎么用?Java OnLineListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OnLineListener类属于eu.chainfire.libsuperuser.StreamGobbler包,在下文中一共展示了OnLineListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processLine

import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
 * Process a normal STDOUT/STDERR line
 * 
 * @param line Line to process
 * @param listener Callback to call or null
 */
private synchronized void processLine(String line, OnLineListener listener) {
    if (listener != null) {
        if (handler != null) {
            final String fLine = line;
            final OnLineListener fListener = listener;

            startCallback();
            handler.post(new Runnable() {
                @Override
                public void run() {
                    try {
                        fListener.onLine(fLine);
                    } finally {
                        endCallback();
                    }
                }
            });
        } else {
            listener.onLine(line);
        }
    }
}
 
开发者ID:staf621,项目名称:ki4a,代码行数:29,代码来源:Shell.java

示例2: processLine

import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
 * Process a normal STDOUT/STDERR line
 *
 * @param line     Line to process
 * @param listener Callback to call or null
 */
private synchronized void processLine(String line, OnLineListener listener) {
    if (listener != null) {
        if (handler != null) {
            final String fLine = line;
            final OnLineListener fListener = listener;

            startCallback();
            handler.post(new Runnable() {
                @Override
                public void run() {
                    try {
                        fListener.onLine(fLine);
                    } finally {
                        endCallback();
                    }
                }
            });
        } else {
            listener.onLine(line);
        }
    }
}
 
开发者ID:cumtsmart,项目名称:MostTool,代码行数:29,代码来源:Shell.java

示例3: processLine

import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
 * Process a normal STDOUT/STDERR line
 * 
 * @param line Line to process
 * @param listener Callback to call or null
 */
private synchronized void processLine(String line, OnLineListener listener) {
	if (listener != null) {
		if (handler != null) {
			final String fLine = line;
			final OnLineListener fListener = listener;
			
			startCallback();
			handler.post(new Runnable() {								
				@Override
				public void run() {
					try {
						fListener.onLine(fLine);
					} finally {
						endCallback();
					}
				}
			});
		} else {
			listener.onLine(line);
		}
	}			
}
 
开发者ID:TheZ3ro,项目名称:WiFiPV,代码行数:29,代码来源:Shell.java

示例4: processLine

import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
 * Process a normal STDOUT/STDERR line
 * 
 * @param line Line to process
 * @param listener Callback to call or null
 */
private synchronized void processLine(String line, OnLineListener listener) {
    if (listener != null) {
        if (handler != null) {
            final String fLine = line;
            final OnLineListener fListener = listener;

            startCallback();
            handler.post(new Runnable() {								
                @Override
                public void run() {
                    try {
                        fListener.onLine(fLine);
                    } finally {
                        endCallback();
                    }
                }
            });
        } else {
            listener.onLine(line);
        }
    }			
}
 
开发者ID:Neraud,项目名称:PADListener,代码行数:29,代码来源:Shell.java

示例5: processLine

import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
 * Process a normal STDOUT/STDERR line
 *
 * @param line Line to process
 * @param listener Callback to call or null
 */
private synchronized void processLine(String line, OnLineListener listener) {
    if (listener != null) {
        if (handler != null) {
            final String fLine = line;
            final OnLineListener fListener = listener;

            startCallback();
            handler.post(new Runnable() {
                @Override
                public void run() {
                    try {
                        fListener.onLine(fLine);
                    } finally {
                        endCallback();
                    }
                }
            });
        } else {
            listener.onLine(line);
        }
    }
}
 
开发者ID:omerjerk,项目名称:RemoteDroid,代码行数:29,代码来源:Shell.java

示例6: open

import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
 * Internal call that launches the shell, starts gobbling, and stars executing commands.
 * See {@link Shell.Interactive}
 * 
 * @return Opened successfully ?
 */
private synchronized boolean open() {
	if (BuildConfig.DEBUG) Debug.log(String.format("[%s%%] START", shell.toUpperCase()));
	
	try {
		// setup our process, retrieve STDIN stream, and STDOUT/STDERR gobblers
		if (environment.size() == 0) {
			process = Runtime.getRuntime().exec(shell);
		} else {
			Map<String, String> newEnvironment = new HashMap<String, String>();
			newEnvironment.putAll(System.getenv());
			newEnvironment.putAll(environment);
			int i = 0;
            String[] env = new String[newEnvironment.size()];
            for (Map.Entry<String, String> entry : newEnvironment.entrySet()) {
            	env[i] = entry.getKey() + "=" + entry.getValue();
                i++;		            
            }
            process = Runtime.getRuntime().exec(shell, env);
		}
	
		STDIN = new DataOutputStream(process.getOutputStream());
		STDOUT = new StreamGobbler(shell.toUpperCase() + "-", process.getInputStream(), new OnLineListener() {					
			@Override
			public void onLine(String line) {
				if (line.startsWith(command.marker)) {
					try {
						lastExitCode = Integer.valueOf(line.substring(command.marker.length() + 1), 10);
					} catch (Exception e) {						
					}
					lastMarkerSTDOUT = command.marker;										
					processMarker();
				} else {
					addBuffer(line);					
					processLine(line, onSTDOUTLineListener);
				}
			}
		});
		STDERR = new StreamGobbler(shell.toUpperCase() + "*", process.getErrorStream(), new OnLineListener() {					
			@Override
			public void onLine(String line) {
				if (line.startsWith(command.marker)) {
					lastMarkerSTDERR = command.marker;
					processMarker();
				} else {
					if (wantSTDERR) addBuffer(line);					
					processLine(line, onSTDERRLineListener);
				}
			}
		});
		
		// start gobbling and write our commands to the shell
		STDOUT.start();
		STDERR.start();

		running = true;
		closed = false;
		
		runNextCommand();

		return true;
	} catch (IOException e) {
		// shell probably not found
		return false;
	}
}
 
开发者ID:TheZ3ro,项目名称:WiFiPV,代码行数:72,代码来源:Shell.java

示例7: open

import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
 * Internal call that launches the shell, starts gobbling, and starts executing commands.
 * See {@link eu.chainfire.libsuperuser.Shell.Interactive}
 * 
 * @return Opened successfully ?
 */
private synchronized boolean open() {
    Debug.log(String.format("[%s%%] START", shell.toUpperCase(Locale.ENGLISH)));

    try {
        // setup our process, retrieve STDIN stream, and STDOUT/STDERR gobblers
        if (environment.size() == 0) {
            process = Runtime.getRuntime().exec(shell);
        } else {
            Map<String, String> newEnvironment = new HashMap<String, String>();
            newEnvironment.putAll(System.getenv());
            newEnvironment.putAll(environment);
            int i = 0;
            String[] env = new String[newEnvironment.size()];
            for (Map.Entry<String, String> entry : newEnvironment.entrySet()) {
                env[i] = entry.getKey() + "=" + entry.getValue();
                i++;		            
            }
            process = Runtime.getRuntime().exec(shell, env);
        }

        STDIN = new DataOutputStream(process.getOutputStream());
        STDOUT = new StreamGobbler(shell.toUpperCase(Locale.ENGLISH) + "-", process.getInputStream(), new OnLineListener() {					
            @Override
            public void onLine(String line) {
                synchronized (Interactive.this) {
                    if (command == null) {
                        return;
                    }
                    if (line.startsWith(command.marker)) {
                        try {
                            lastExitCode = Integer.valueOf(line.substring(command.marker.length() + 1), 10);
                        } catch (Exception e) {
                        }
                        lastMarkerSTDOUT = command.marker;
                        processMarker();
                    } else {
                        addBuffer(line);
                        processLine(line, onSTDOUTLineListener);
                    }
                }
            }
        });
        STDERR = new StreamGobbler(shell.toUpperCase(Locale.ENGLISH) + "*", process.getErrorStream(), new OnLineListener() {					
            @Override
            public void onLine(String line) {
                synchronized (Interactive.this) {
                    if (command == null) {
                        return;
                    }
                    if (line.startsWith(command.marker)) {
                        lastMarkerSTDERR = command.marker;
                        processMarker();
                    } else {
                        if (wantSTDERR) addBuffer(line);
                        processLine(line, onSTDERRLineListener);
                    }
                }
            }
        });

        // start gobbling and write our commands to the shell
        STDOUT.start();
        STDERR.start();

        running = true;
        closed = false;

        runNextCommand();

        return true;
    } catch (IOException e) {
        // shell probably not found
        return false;
    }
}
 
开发者ID:Neraud,项目名称:PADListener,代码行数:82,代码来源:Shell.java

示例8: open

import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
 * Internal call that launches the shell, starts gobbling, and starts executing commands.
 * See {@link Shell.Interactive}
 * 
 * @return Opened successfully ?
 */
private synchronized boolean open() {
    Debug.log(String.format("[%s%%] START", shell.toUpperCase(Locale.ENGLISH)));

    try {
        // setup our process, retrieve STDIN stream, and STDOUT/STDERR gobblers
        if (environment.size() == 0) {
            process = Runtime.getRuntime().exec(shell);
        } else {
            Map<String, String> newEnvironment = new HashMap<String, String>();
            newEnvironment.putAll(System.getenv());
            newEnvironment.putAll(environment);
            int i = 0;
            String[] env = new String[newEnvironment.size()];
            for (Map.Entry<String, String> entry : newEnvironment.entrySet()) {
                env[i] = entry.getKey() + "=" + entry.getValue();
                i++;		            
            }
            process = Runtime.getRuntime().exec(shell, env);
        }

        STDIN = new DataOutputStream(process.getOutputStream());
        STDOUT = new StreamGobbler(shell.toUpperCase(Locale.ENGLISH) + "-", process.getInputStream(), new OnLineListener() {					
            @Override
            public void onLine(String line) {
                synchronized (Interactive.this) {
                    if (command == null) {
                        return;
                    }
                    if (line.startsWith(command.marker)) {
                        try {
                            lastExitCode = Integer.valueOf(line.substring(command.marker.length() + 1), 10);
                        } catch (Exception e) {
                        }
                        lastMarkerSTDOUT = command.marker;
                        processMarker();
                    } else {
                        addBuffer(line);
                        processLine(line, onSTDOUTLineListener);
                    }
                }
            }
        });
        STDERR = new StreamGobbler(shell.toUpperCase(Locale.ENGLISH) + "*", process.getErrorStream(), new OnLineListener() {					
            @Override
            public void onLine(String line) {
                synchronized (Interactive.this) {
                    if (command == null) {
                        return;
                    }
                    if (line.startsWith(command.marker)) {
                        lastMarkerSTDERR = command.marker;
                        processMarker();
                    } else {
                        if (wantSTDERR) addBuffer(line);
                        processLine(line, onSTDERRLineListener);
                    }
                }
            }
        });

        // start gobbling and write our commands to the shell
        STDOUT.start();
        STDERR.start();

        running = true;
        closed = false;

        runNextCommand();

        return true;
    } catch (IOException e) {
        // shell probably not found
        return false;
    }
}
 
开发者ID:ColtonDRG,项目名称:Android-SudoInstaller,代码行数:82,代码来源:Shell.java

示例9: open

import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
 * Internal call that launches the shell, starts gobbling, and starts executing commands.
 * See {@link Shell.Interactive}
 * 
 * @return Opened successfully ?
 */
private synchronized boolean open() {
	Debug.log(String.format("[%s%%] START", shell.toUpperCase(Locale.ENGLISH)));
	
	try {
		// setup our process, retrieve STDIN stream, and STDOUT/STDERR gobblers
		if (environment.size() == 0) {
			process = Runtime.getRuntime().exec(shell);
		} else {
			Map<String, String> newEnvironment = new HashMap<String, String>();
			newEnvironment.putAll(System.getenv());
			newEnvironment.putAll(environment);
			int i = 0;
            String[] env = new String[newEnvironment.size()];
            for (Map.Entry<String, String> entry : newEnvironment.entrySet()) {
            	env[i] = entry.getKey() + "=" + entry.getValue();
                i++;		            
            }
            process = Runtime.getRuntime().exec(shell, env);
		}
	
		STDIN = new DataOutputStream(process.getOutputStream());
		STDOUT = new StreamGobbler(shell.toUpperCase(Locale.ENGLISH) + "-", process.getInputStream(), new OnLineListener() {					
			@Override
			public void onLine(String line) {
				synchronized (Interactive.this) {
					if (command == null) {
						return;
					}
					if (line.startsWith(command.marker)) {
						try {
							lastExitCode = Integer.valueOf(line.substring(command.marker.length() + 1), 10);
						} catch (Exception e) {
						}
						lastMarkerSTDOUT = command.marker;
						processMarker();
					} else {
						addBuffer(line);
						processLine(line, onSTDOUTLineListener);
					}
				}
			}
		});
		STDERR = new StreamGobbler(shell.toUpperCase(Locale.ENGLISH) + "*", process.getErrorStream(), new OnLineListener() {					
			@Override
			public void onLine(String line) {
				synchronized (Interactive.this) {
					if (command == null) {
						return;
					}
					if (line.startsWith(command.marker)) {
						lastMarkerSTDERR = command.marker;
						processMarker();
					} else {
						if (wantSTDERR) addBuffer(line);
						processLine(line, onSTDERRLineListener);
					}
				}
			}
		});
		
		// start gobbling and write our commands to the shell
		STDOUT.start();
		STDERR.start();

		running = true;
		closed = false;
		
		runNextCommand();

		return true;
	} catch (IOException e) {
		// shell probably not found
		return false;
	}
}
 
开发者ID:darshakframework,项目名称:darshak,代码行数:82,代码来源:Shell.java

示例10: open

import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
 * Internal call that launches the shell, starts gobbling, and starts executing commands.
 * See {@link Shell.Interactive}
 *
 * @return Opened successfully ?
 */
private synchronized boolean open() {
    Debug.log(String.format("[%s%%] START", shell.toUpperCase(Locale.ENGLISH)));

    try {
        // setup our process, retrieve STDIN stream, and STDOUT/STDERR gobblers
        if (environment.size() == 0) {
            process = Runtime.getRuntime().exec(shell);
        } else {
            Map<String, String> newEnvironment = new HashMap<String, String>();
            newEnvironment.putAll(System.getenv());
            newEnvironment.putAll(environment);
            int i = 0;
            String[] env = new String[newEnvironment.size()];
            for (Map.Entry<String, String> entry : newEnvironment.entrySet()) {
                env[i] = entry.getKey() + "=" + entry.getValue();
                i++;
            }
            process = Runtime.getRuntime().exec(shell, env);
        }

        STDIN = new DataOutputStream(process.getOutputStream());
        STDOUT = new StreamGobbler(shell.toUpperCase(Locale.ENGLISH) + "-", process.getInputStream(), new OnLineListener() {
            @Override
            public void onLine(String line) {
                synchronized (Interactive.this) {
                    if (command == null) {
                        return;
                    }
                    if (line.startsWith(command.marker)) {
                        try {
                            lastExitCode = Integer.valueOf(line.substring(command.marker.length() + 1), 10);
                        } catch (Exception e) {
                        }
                        lastMarkerSTDOUT = command.marker;
                        processMarker();
                    } else {
                        addBuffer(line);
                        processLine(line, onSTDOUTLineListener);
                    }
                }
            }
        });
        STDERR = new StreamGobbler(shell.toUpperCase(Locale.ENGLISH) + "*", process.getErrorStream(), new OnLineListener() {
            @Override
            public void onLine(String line) {
                synchronized (Interactive.this) {
                    if (command == null) {
                        return;
                    }
                    if (line.startsWith(command.marker)) {
                        lastMarkerSTDERR = command.marker;
                        processMarker();
                    } else {
                        if (wantSTDERR) addBuffer(line);
                        processLine(line, onSTDERRLineListener);
                    }
                }
            }
        });

        // start gobbling and write our commands to the shell
        STDOUT.start();
        STDERR.start();

        running = true;
        closed = false;

        runNextCommand();

        return true;
    } catch (IOException e) {
        // shell probably not found
        return false;
    }
}
 
开发者ID:coxande,项目名称:WifiPasswordRecover,代码行数:82,代码来源:Shell.java

示例11: open

import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
 * Internal call that launches the shell, starts gobbling, and stars executing commands.
 * See {@link Shell.Interactive}
 * 
 * @return Opened successfully ?
 */
private synchronized boolean open() {
	//if (BuildConfig.DEBUG) Debug.log(String.format("[%s%%] START", shell.toUpperCase()));
	
	try {
		// setup our process, retrieve STDIN stream, and STDOUT/STDERR gobblers
		if (environment.size() == 0) {
			process = Runtime.getRuntime().exec(shell);
		} else {
			Map<String, String> newEnvironment = new HashMap<String, String>();
			newEnvironment.putAll(System.getenv());
			newEnvironment.putAll(environment);
			int i = 0;
            String[] env = new String[newEnvironment.size()];
            for (Map.Entry<String, String> entry : newEnvironment.entrySet()) {
            	env[i] = entry.getKey() + "=" + entry.getValue();
                i++;		            
            }
            process = Runtime.getRuntime().exec(shell, env);
		}
	
		STDIN = new DataOutputStream(process.getOutputStream());
		STDOUT = new StreamGobbler(shell.toUpperCase() + "-", process.getInputStream(), new OnLineListener() {					
			@Override
			public void onLine(String line) {
				if (line.startsWith(command.marker)) {
					try {
						lastExitCode = Integer.valueOf(line.substring(command.marker.length() + 1), 10);
					} catch (Exception e) {						
					}
					lastMarkerSTDOUT = command.marker;										
					processMarker();
				} else {
					addBuffer(line);					
					processLine(line, onSTDOUTLineListener);
				}
			}
		});
		STDERR = new StreamGobbler(shell.toUpperCase() + "*", process.getErrorStream(), new OnLineListener() {					
			@Override
			public void onLine(String line) {
				if (line.startsWith(command.marker)) {
					lastMarkerSTDERR = command.marker;
					processMarker();
				} else {
					if (wantSTDERR) addBuffer(line);					
					processLine(line, onSTDERRLineListener);
				}
			}
		});
		
		// start gobbling and write our commands to the shell
		STDOUT.start();
		STDERR.start();

		running = true;
		closed = false;
		
		runNextCommand();

		return true;
	} catch (IOException e) {
		// shell probably not found
		return false;
	}
}
 
开发者ID:RoliSoft,项目名称:RS-Text-Forwarder-Android-Client,代码行数:72,代码来源:Shell.java

示例12: setOnSTDOUTLineListener

import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
 * <p>
 * Set a callback called for every line output to STDOUT by the shell
 * </p>
 * <p>
 * The thread on which the callback executes is dependent on various
 * factors, see {@link Shell.Interactive} for further details
 * </p>
 * 
 * @param onLineListener Callback to be called for each line
 * @return This Builder object for method chaining
 */
public Builder setOnSTDOUTLineListener(OnLineListener onLineListener) {
    this.onSTDOUTLineListener = onLineListener;
    return this;
}
 
开发者ID:staf621,项目名称:ki4a,代码行数:17,代码来源:Shell.java

示例13: setOnSTDERRLineListener

import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
 * <p>
 * Set a callback called for every line output to STDERR by the shell
 * </p>
 * <p>
 * The thread on which the callback executes is dependent on various
 * factors, see {@link Shell.Interactive} for further details
 * </p>
 * 
 * @param onLineListener Callback to be called for each line
 * @return This Builder object for method chaining
 */
public Builder setOnSTDERRLineListener(OnLineListener onLineListener) {
    this.onSTDERRLineListener = onLineListener;
    return this;
}
 
开发者ID:staf621,项目名称:ki4a,代码行数:17,代码来源:Shell.java

示例14: setOnSTDOUTLineListener

import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
 * <p>
 * Set a callback called for every line output to STDOUT by the shell
 * </p>
 * <p>
 * The thread on which the callback executes is dependent on various
 * factors, see {@link Shell.Interactive} for further details
 * </p>
 *
 * @param onLineListener Callback to be called for each line
 * @return This Builder object for method chaining
 */
public Builder setOnSTDOUTLineListener(OnLineListener onLineListener) {
    this.onSTDOUTLineListener = onLineListener;
    return this;
}
 
开发者ID:cumtsmart,项目名称:MostTool,代码行数:17,代码来源:Shell.java

示例15: setOnSTDERRLineListener

import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
 * <p>
 * Set a callback called for every line output to STDERR by the shell
 * </p>
 * <p>
 * The thread on which the callback executes is dependent on various
 * factors, see {@link Shell.Interactive} for further details
 * </p>
 *
 * @param onLineListener Callback to be called for each line
 * @return This Builder object for method chaining
 */
public Builder setOnSTDERRLineListener(OnLineListener onLineListener) {
    this.onSTDERRLineListener = onLineListener;
    return this;
}
 
开发者ID:cumtsmart,项目名称:MostTool,代码行数:17,代码来源:Shell.java


注:本文中的eu.chainfire.libsuperuser.StreamGobbler.OnLineListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。