Merge "Changes Activity to use Dumpable for "legacy" cases."
This commit is contained in:
@@ -7209,7 +7209,7 @@ public class Activity extends ContextThemeWrapper
|
||||
// Handle special cases
|
||||
switch (args[0]) {
|
||||
case "--autofill":
|
||||
getAutofillClientController().dumpAutofillManager(prefix, writer);
|
||||
dumpAutofillManager(prefix, writer, args);
|
||||
return;
|
||||
case "--contentcapture":
|
||||
dumpContentCaptureManager(prefix, writer);
|
||||
@@ -7277,10 +7277,6 @@ public class Activity extends ContextThemeWrapper
|
||||
|
||||
mHandler.getLooper().dump(new PrintWriterPrinter(writer), prefix);
|
||||
|
||||
getAutofillClientController().dumpAutofillManager(prefix, writer);
|
||||
dumpContentCaptureManager(prefix, writer);
|
||||
dumpUiTranslation(prefix, writer);
|
||||
|
||||
ResourcesManager.getInstance().dump(prefix, writer);
|
||||
|
||||
if (mDumpableContainer != null) {
|
||||
@@ -7288,21 +7284,26 @@ public class Activity extends ContextThemeWrapper
|
||||
}
|
||||
}
|
||||
|
||||
void dumpContentCaptureManager(String prefix, PrintWriter writer) {
|
||||
final ContentCaptureManager cm = getContentCaptureManager();
|
||||
if (cm != null) {
|
||||
cm.dump(prefix, writer);
|
||||
} else {
|
||||
writer.print(prefix); writer.println("No ContentCaptureManager");
|
||||
}
|
||||
private void dumpContentCaptureManager(String prefix, PrintWriter writer) {
|
||||
getContentCaptureManager();
|
||||
dumpLegacyDumpable(prefix, writer, ContentCaptureManager.DUMPABLE_NAME, /* args= */ null);
|
||||
}
|
||||
|
||||
void dumpUiTranslation(String prefix, PrintWriter writer) {
|
||||
if (mUiTranslationController != null) {
|
||||
mUiTranslationController.dump(prefix, writer);
|
||||
} else {
|
||||
writer.print(prefix); writer.println("No UiTranslationController");
|
||||
private void dumpUiTranslation(String prefix, PrintWriter writer) {
|
||||
dumpLegacyDumpable(prefix, writer, UiTranslationController.DUMPABLE_NAME, /* args= */ null);
|
||||
}
|
||||
|
||||
private void dumpAutofillManager(String prefix, PrintWriter writer, String[] args) {
|
||||
dumpLegacyDumpable(prefix, writer, AutofillClientController.DUMPABLE_NAME, args);
|
||||
}
|
||||
|
||||
private void dumpLegacyDumpable(@NonNull String prefix, @NonNull PrintWriter writer,
|
||||
@NonNull String dumpableName, @Nullable String[] args) {
|
||||
if (mDumpableContainer == null) {
|
||||
writer.print(prefix); writer.print("no "); writer.println(dumpableName);
|
||||
return;
|
||||
}
|
||||
mDumpableContainer.dumpOneDumpable(prefix, writer, dumpableName, args);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,8 +35,6 @@ public interface Dumpable {
|
||||
return getClass().getName();
|
||||
}
|
||||
|
||||
//TODO(b/149254050): decide whether it should take a ParcelFileDescription as well.
|
||||
|
||||
/**
|
||||
* Dumps the internal state into the given {@code writer}.
|
||||
*
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Dumpable;
|
||||
import android.util.Log;
|
||||
import android.util.Slog;
|
||||
import android.view.KeyEvent;
|
||||
@@ -43,7 +44,7 @@ import java.util.Arrays;
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public final class AutofillClientController implements AutofillManager.AutofillClient {
|
||||
public final class AutofillClientController implements AutofillManager.AutofillClient, Dumpable {
|
||||
|
||||
private static final String TAG = "AutofillClientController";
|
||||
|
||||
@@ -54,6 +55,8 @@ public final class AutofillClientController implements AutofillManager.AutofillC
|
||||
public static final String AUTOFILL_RESET_NEEDED = "@android:autofillResetNeeded";
|
||||
public static final String AUTO_FILL_AUTH_WHO_PREFIX = "@android:autoFillAuth:";
|
||||
|
||||
public static final String DUMPABLE_NAME = "AutofillManager";
|
||||
|
||||
/** The last autofill id that was returned from {@link #getNextAutofillId()} */
|
||||
public int mLastAutofillId = View.LAST_APP_AUTOFILL_ID;
|
||||
|
||||
@@ -73,6 +76,7 @@ public final class AutofillClientController implements AutofillManager.AutofillC
|
||||
*/
|
||||
public AutofillClientController(Activity activity) {
|
||||
mActivity = activity;
|
||||
activity.addDumpable(this);
|
||||
}
|
||||
|
||||
private AutofillManager getAutofillManager() {
|
||||
@@ -280,10 +284,14 @@ public final class AutofillClientController implements AutofillManager.AutofillC
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints autofill related information for the Activity.
|
||||
*/
|
||||
public void dumpAutofillManager(String prefix, PrintWriter writer) {
|
||||
@Override
|
||||
public String getDumpableName() {
|
||||
return DUMPABLE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dump(PrintWriter writer, String[] args) {
|
||||
final String prefix = "";
|
||||
final AutofillManager afm = getAutofillManager();
|
||||
if (afm != null) {
|
||||
afm.dump(prefix, writer);
|
||||
|
||||
@@ -29,6 +29,7 @@ import android.annotation.SystemService;
|
||||
import android.annotation.TestApi;
|
||||
import android.annotation.UiThread;
|
||||
import android.annotation.UserIdInt;
|
||||
import android.app.Activity;
|
||||
import android.app.Service;
|
||||
import android.content.ComponentName;
|
||||
import android.content.ContentCaptureOptions;
|
||||
@@ -41,6 +42,7 @@ import android.os.Looper;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.util.Dumpable;
|
||||
import android.util.Log;
|
||||
import android.util.Slog;
|
||||
import android.view.View;
|
||||
@@ -215,6 +217,9 @@ public final class ContentCaptureManager {
|
||||
/** @hide */
|
||||
public static final boolean DEBUG = false;
|
||||
|
||||
/** @hide */
|
||||
public static final String DUMPABLE_NAME = "ContentCaptureManager";
|
||||
|
||||
/** Error happened during the data sharing session. */
|
||||
public static final int DATA_SHARE_ERROR_UNKNOWN = 1;
|
||||
|
||||
@@ -402,6 +407,9 @@ public final class ContentCaptureManager {
|
||||
mService = Objects.requireNonNull(service, "service cannot be null");
|
||||
mOptions = Objects.requireNonNull(options, "options cannot be null");
|
||||
|
||||
if (context instanceof Activity) {
|
||||
((Activity) context).addDumpable(new Dumper());
|
||||
}
|
||||
ContentCaptureHelper.setLoggingLevel(mOptions.loggingLevel);
|
||||
|
||||
if (sVerbose) Log.v(TAG, "Constructor for " + context.getPackageName());
|
||||
@@ -740,28 +748,37 @@ public final class ContentCaptureManager {
|
||||
return resultReceiver;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public void dump(String prefix, PrintWriter pw) {
|
||||
pw.print(prefix); pw.println("ContentCaptureManager");
|
||||
final String prefix2 = prefix + " ";
|
||||
synchronized (mLock) {
|
||||
pw.print(prefix2); pw.print("isContentCaptureEnabled(): ");
|
||||
pw.println(isContentCaptureEnabled());
|
||||
pw.print(prefix2); pw.print("Debug: "); pw.print(sDebug);
|
||||
pw.print(" Verbose: "); pw.println(sVerbose);
|
||||
pw.print(prefix2); pw.print("Context: "); pw.println(mContext);
|
||||
pw.print(prefix2); pw.print("User: "); pw.println(mContext.getUserId());
|
||||
pw.print(prefix2); pw.print("Service: "); pw.println(mService);
|
||||
pw.print(prefix2); pw.print("Flags: "); pw.println(mFlags);
|
||||
pw.print(prefix2); pw.print("Options: "); mOptions.dumpShort(pw); pw.println();
|
||||
if (mMainSession != null) {
|
||||
final String prefix3 = prefix2 + " ";
|
||||
pw.print(prefix2); pw.println("Main session:");
|
||||
mMainSession.dump(prefix3, pw);
|
||||
} else {
|
||||
pw.print(prefix2); pw.println("No sessions");
|
||||
// NOTE: ContentCaptureManager cannot implement it directly as it would be exposed as public API
|
||||
private final class Dumper implements Dumpable {
|
||||
@Override
|
||||
public void dump(@NonNull PrintWriter pw, @Nullable String[] args) {
|
||||
String prefix = "";
|
||||
pw.print(prefix); pw.println("ContentCaptureManager");
|
||||
final String prefix2 = prefix + " ";
|
||||
synchronized (mLock) {
|
||||
pw.print(prefix2); pw.print("isContentCaptureEnabled(): ");
|
||||
pw.println(isContentCaptureEnabled());
|
||||
pw.print(prefix2); pw.print("Debug: "); pw.print(sDebug);
|
||||
pw.print(" Verbose: "); pw.println(sVerbose);
|
||||
pw.print(prefix2); pw.print("Context: "); pw.println(mContext);
|
||||
pw.print(prefix2); pw.print("User: "); pw.println(mContext.getUserId());
|
||||
pw.print(prefix2); pw.print("Service: "); pw.println(mService);
|
||||
pw.print(prefix2); pw.print("Flags: "); pw.println(mFlags);
|
||||
pw.print(prefix2); pw.print("Options: "); mOptions.dumpShort(pw); pw.println();
|
||||
if (mMainSession != null) {
|
||||
final String prefix3 = prefix2 + " ";
|
||||
pw.print(prefix2); pw.println("Main session:");
|
||||
mMainSession.dump(prefix3, pw);
|
||||
} else {
|
||||
pw.print(prefix2); pw.println("No sessions");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDumpableName() {
|
||||
return DUMPABLE_NAME;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,6 +33,7 @@ import android.os.HandlerThread;
|
||||
import android.os.Process;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.ArraySet;
|
||||
import android.util.Dumpable;
|
||||
import android.util.IntArray;
|
||||
import android.util.Log;
|
||||
import android.util.LongSparseArray;
|
||||
@@ -62,11 +63,15 @@ import java.util.function.BiConsumer;
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public class UiTranslationController {
|
||||
public class UiTranslationController implements Dumpable {
|
||||
|
||||
public static final boolean DEBUG = Log.isLoggable(UiTranslationManager.LOG_TAG, Log.DEBUG);
|
||||
|
||||
/** @hide */
|
||||
public static final String DUMPABLE_NAME = "UiTranslationController";
|
||||
|
||||
private static final String TAG = "UiTranslationController";
|
||||
|
||||
@NonNull
|
||||
private final Activity mActivity;
|
||||
@NonNull
|
||||
@@ -104,6 +109,7 @@ public class UiTranslationController {
|
||||
Process.THREAD_PRIORITY_FOREGROUND);
|
||||
mWorkerThread.start();
|
||||
mWorkerHandler = mWorkerThread.getThreadHandler();
|
||||
activity.addDumpable(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -206,10 +212,14 @@ public class UiTranslationController {
|
||||
mLastRequestAutofillIds.addAll(views);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to dump the translation information for Activity.
|
||||
*/
|
||||
public void dump(String outerPrefix, PrintWriter pw) {
|
||||
@Override
|
||||
public String getDumpableName() {
|
||||
return DUMPABLE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dump(PrintWriter pw, String[] args) {
|
||||
String outerPrefix = "";
|
||||
pw.print(outerPrefix); pw.println("UiTranslationController:");
|
||||
final String pfx = outerPrefix + " ";
|
||||
pw.print(pfx); pw.print("activity: "); pw.print(mActivity);
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.android.internal.util.dump;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Dumpable;
|
||||
import android.util.DumpableContainer;
|
||||
@@ -38,7 +37,6 @@ public final class DumpableContainerImpl implements DumpableContainer {
|
||||
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
@Nullable
|
||||
private final ArrayMap<String, Dumpable> mDumpables = new ArrayMap<>();
|
||||
|
||||
@Override
|
||||
@@ -64,7 +62,7 @@ public final class DumpableContainerImpl implements DumpableContainer {
|
||||
* Dumps the number of dumpable, without a newline.
|
||||
*/
|
||||
private int dumpNumberDumpables(IndentingPrintWriter writer) {
|
||||
int size = mDumpables == null ? 0 : mDumpables.size();
|
||||
int size = mDumpables.size();
|
||||
if (size == 0) {
|
||||
writer.print("No dumpables");
|
||||
} else {
|
||||
@@ -102,7 +100,7 @@ public final class DumpableContainerImpl implements DumpableContainer {
|
||||
ipw.println();
|
||||
return;
|
||||
}
|
||||
ipw.println(": ");
|
||||
ipw.println(":");
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
String dumpableName = mDumpables.keyAt(i);
|
||||
|
||||
Reference in New Issue
Block a user