use of android.util.Printer in project android_frameworks_base by AOSPA.
the class InputMethodManagerService method dump.
@Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) {
pw.println("Permission Denial: can't dump InputMethodManager from from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid());
return;
}
IInputMethod method;
ClientState client;
ClientState focusedWindowClient;
final Printer p = new PrintWriterPrinter(pw);
synchronized (mMethodMap) {
p.println("Current Input Method Manager state:");
int N = mMethodList.size();
p.println(" Input Methods:");
for (int i = 0; i < N; i++) {
InputMethodInfo info = mMethodList.get(i);
p.println(" InputMethod #" + i + ":");
info.dump(p, " ");
}
p.println(" Clients:");
for (ClientState ci : mClients.values()) {
p.println(" Client " + ci + ":");
p.println(" client=" + ci.client);
p.println(" inputContext=" + ci.inputContext);
p.println(" sessionRequested=" + ci.sessionRequested);
p.println(" curSession=" + ci.curSession);
}
p.println(" mCurMethodId=" + mCurMethodId);
client = mCurClient;
p.println(" mCurClient=" + client + " mCurSeq=" + mCurSeq);
p.println(" mCurFocusedWindow=" + mCurFocusedWindow);
focusedWindowClient = mCurFocusedWindowClient;
p.println(" mCurFocusedWindowClient=" + focusedWindowClient);
p.println(" mCurId=" + mCurId + " mHaveConnect=" + mHaveConnection + " mBoundToMethod=" + mBoundToMethod);
p.println(" mCurToken=" + mCurToken);
p.println(" mCurIntent=" + mCurIntent);
method = mCurMethod;
p.println(" mCurMethod=" + mCurMethod);
p.println(" mEnabledSession=" + mEnabledSession);
p.println(" mImeWindowVis=" + imeWindowStatusToString(mImeWindowVis));
p.println(" mShowRequested=" + mShowRequested + " mShowExplicitlyRequested=" + mShowExplicitlyRequested + " mShowForced=" + mShowForced + " mInputShown=" + mInputShown);
p.println(" mCurUserActionNotificationSequenceNumber=" + mCurUserActionNotificationSequenceNumber);
p.println(" mSystemReady=" + mSystemReady + " mInteractive=" + mIsInteractive);
p.println(" mSettingsObserver=" + mSettingsObserver);
p.println(" mSwitchingController:");
mSwitchingController.dump(p);
p.println(" mSettings:");
mSettings.dumpLocked(p, " ");
}
p.println(" ");
if (client != null) {
pw.flush();
try {
client.client.asBinder().dump(fd, args);
} catch (RemoteException e) {
p.println("Input method client dead: " + e);
}
} else {
p.println("No input method client.");
}
if (focusedWindowClient != null && client != focusedWindowClient) {
p.println(" ");
p.println("Warning: Current input method client doesn't match the last focused. " + "window.");
p.println("Dumping input method client in the last focused window just in case.");
p.println(" ");
pw.flush();
try {
focusedWindowClient.client.asBinder().dump(fd, args);
} catch (RemoteException e) {
p.println("Input method client in focused window dead: " + e);
}
}
p.println(" ");
if (method != null) {
pw.flush();
try {
method.asBinder().dump(fd, args);
} catch (RemoteException e) {
p.println("Input method service dead: " + e);
}
} else {
p.println("No input method service.");
}
}
use of android.util.Printer in project android_frameworks_base by ResurrectionRemix.
the class Looper method loop.
/**
* Run the message queue in this thread. Be sure to call
* {@link #quit()} to end the loop.
*/
public static void loop() {
final Looper me = myLooper();
if (me == null) {
throw new RuntimeException("No Looper; Looper.prepare() wasn't called on this thread.");
}
final MessageQueue queue = me.mQueue;
// Make sure the identity of this thread is that of the local process,
// and keep track of what that identity token actually is.
Binder.clearCallingIdentity();
final long ident = Binder.clearCallingIdentity();
for (; ; ) {
// might block
Message msg = queue.next();
if (msg == null) {
// No message indicates that the message queue is quitting.
return;
}
// This must be in a local variable, in case a UI event sets the logger
final Printer logging = me.mLogging;
if (logging != null) {
logging.println(">>>>> Dispatching to " + msg.target + " " + msg.callback + ": " + msg.what);
}
final long traceTag = me.mTraceTag;
if (traceTag != 0 && Trace.isTagEnabled(traceTag)) {
Trace.traceBegin(traceTag, msg.target.getTraceName(msg));
}
try {
msg.target.dispatchMessage(msg);
} finally {
if (traceTag != 0) {
Trace.traceEnd(traceTag);
}
}
if (logging != null) {
logging.println("<<<<< Finished to " + msg.target + " " + msg.callback);
}
// Make sure that during the course of dispatching the
// identity of the thread wasn't corrupted.
final long newIdent = Binder.clearCallingIdentity();
if (ident != newIdent) {
Log.wtf(TAG, "Thread identity changed from 0x" + Long.toHexString(ident) + " to 0x" + Long.toHexString(newIdent) + " while dispatching to " + msg.target.getClass().getName() + " " + msg.callback + " what=" + msg.what);
}
msg.recycleUnchecked();
}
}
use of android.util.Printer in project android_frameworks_base by ResurrectionRemix.
the class InputMethodManagerService method dump.
@Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) {
pw.println("Permission Denial: can't dump InputMethodManager from from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid());
return;
}
IInputMethod method;
ClientState client;
ClientState focusedWindowClient;
final Printer p = new PrintWriterPrinter(pw);
synchronized (mMethodMap) {
p.println("Current Input Method Manager state:");
int N = mMethodList.size();
p.println(" Input Methods:");
for (int i = 0; i < N; i++) {
InputMethodInfo info = mMethodList.get(i);
p.println(" InputMethod #" + i + ":");
info.dump(p, " ");
}
p.println(" Clients:");
for (ClientState ci : mClients.values()) {
p.println(" Client " + ci + ":");
p.println(" client=" + ci.client);
p.println(" inputContext=" + ci.inputContext);
p.println(" sessionRequested=" + ci.sessionRequested);
p.println(" curSession=" + ci.curSession);
}
p.println(" mCurMethodId=" + mCurMethodId);
client = mCurClient;
p.println(" mCurClient=" + client + " mCurSeq=" + mCurSeq);
p.println(" mCurFocusedWindow=" + mCurFocusedWindow);
focusedWindowClient = mCurFocusedWindowClient;
p.println(" mCurFocusedWindowClient=" + focusedWindowClient);
p.println(" mCurId=" + mCurId + " mHaveConnect=" + mHaveConnection + " mBoundToMethod=" + mBoundToMethod);
p.println(" mCurToken=" + mCurToken);
p.println(" mCurIntent=" + mCurIntent);
method = mCurMethod;
p.println(" mCurMethod=" + mCurMethod);
p.println(" mEnabledSession=" + mEnabledSession);
p.println(" mImeWindowVis=" + imeWindowStatusToString(mImeWindowVis));
p.println(" mShowRequested=" + mShowRequested + " mShowExplicitlyRequested=" + mShowExplicitlyRequested + " mShowForced=" + mShowForced + " mInputShown=" + mInputShown);
p.println(" mCurUserActionNotificationSequenceNumber=" + mCurUserActionNotificationSequenceNumber);
p.println(" mSystemReady=" + mSystemReady + " mInteractive=" + mIsInteractive);
p.println(" mSettingsObserver=" + mSettingsObserver);
p.println(" mSwitchingController:");
mSwitchingController.dump(p);
p.println(" mSettings:");
mSettings.dumpLocked(p, " ");
}
p.println(" ");
if (client != null) {
pw.flush();
try {
client.client.asBinder().dump(fd, args);
} catch (RemoteException e) {
p.println("Input method client dead: " + e);
}
} else {
p.println("No input method client.");
}
if (focusedWindowClient != null && client != focusedWindowClient) {
p.println(" ");
p.println("Warning: Current input method client doesn't match the last focused. " + "window.");
p.println("Dumping input method client in the last focused window just in case.");
p.println(" ");
pw.flush();
try {
focusedWindowClient.client.asBinder().dump(fd, args);
} catch (RemoteException e) {
p.println("Input method client in focused window dead: " + e);
}
}
p.println(" ");
if (method != null) {
pw.flush();
try {
method.asBinder().dump(fd, args);
} catch (RemoteException e) {
p.println("Input method service dead: " + e);
}
} else {
p.println("No input method service.");
}
}
use of android.util.Printer in project android_frameworks_base by ResurrectionRemix.
the class IntentResolver method dumpMap.
boolean dumpMap(PrintWriter out, String titlePrefix, String title, String prefix, ArrayMap<String, F[]> map, String packageName, boolean printFilter, boolean collapseDuplicates) {
final String eprefix = prefix + " ";
final String fprefix = prefix + " ";
final ArrayMap<Object, MutableInt> found = new ArrayMap<>();
boolean printedSomething = false;
Printer printer = null;
for (int mapi = 0; mapi < map.size(); mapi++) {
F[] a = map.valueAt(mapi);
final int N = a.length;
boolean printedHeader = false;
F filter;
if (collapseDuplicates && !printFilter) {
found.clear();
for (int i = 0; i < N && (filter = a[i]) != null; i++) {
if (packageName != null && !isPackageForFilter(packageName, filter)) {
continue;
}
Object label = filterToLabel(filter);
int index = found.indexOfKey(label);
if (index < 0) {
found.put(label, new MutableInt(1));
} else {
found.valueAt(index).value++;
}
}
for (int i = 0; i < found.size(); i++) {
if (title != null) {
out.print(titlePrefix);
out.println(title);
title = null;
}
if (!printedHeader) {
out.print(eprefix);
out.print(map.keyAt(mapi));
out.println(":");
printedHeader = true;
}
printedSomething = true;
dumpFilterLabel(out, fprefix, found.keyAt(i), found.valueAt(i).value);
}
} else {
for (int i = 0; i < N && (filter = a[i]) != null; i++) {
if (packageName != null && !isPackageForFilter(packageName, filter)) {
continue;
}
if (title != null) {
out.print(titlePrefix);
out.println(title);
title = null;
}
if (!printedHeader) {
out.print(eprefix);
out.print(map.keyAt(mapi));
out.println(":");
printedHeader = true;
}
printedSomething = true;
dumpFilter(out, fprefix, filter);
if (printFilter) {
if (printer == null) {
printer = new PrintWriterPrinter(out);
}
filter.dump(printer, fprefix + " ");
}
}
}
}
return printedSomething;
}
use of android.util.Printer in project android_frameworks_base by ResurrectionRemix.
the class Ime method runList.
/**
* Execute the list sub-command.
*/
private void runList() {
String opt;
boolean all = false;
boolean brief = false;
while ((opt = nextOption()) != null) {
if (opt.equals("-a")) {
all = true;
} else if (opt.equals("-s")) {
brief = true;
} else {
System.err.println("Error: Unknown option: " + opt);
showUsage();
return;
}
}
List<InputMethodInfo> methods;
if (!all) {
try {
methods = mImm.getEnabledInputMethodList();
} catch (RemoteException e) {
System.err.println(e.toString());
System.err.println(IMM_NOT_RUNNING_ERR);
return;
}
} else {
try {
methods = mImm.getInputMethodList();
} catch (RemoteException e) {
System.err.println(e.toString());
System.err.println(IMM_NOT_RUNNING_ERR);
return;
}
}
if (methods != null) {
Printer pr = new PrintStreamPrinter(System.out);
for (int i = 0; i < methods.size(); i++) {
InputMethodInfo imi = methods.get(i);
if (brief) {
System.out.println(imi.getId());
} else {
System.out.println(imi.getId() + ":");
imi.dump(pr, " ");
}
}
}
}
Aggregations