Merge "Decrease default number of partitions from 64 to 10." into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
203ec51e2b
@@ -20,6 +20,7 @@ import static android.Manifest.permission.MANAGE_AUTO_FILL;
|
||||
import static android.content.Context.AUTOFILL_MANAGER_SERVICE;
|
||||
|
||||
import static com.android.server.autofill.Helper.sDebug;
|
||||
import static com.android.server.autofill.Helper.sPartitionMaxCount;
|
||||
import static com.android.server.autofill.Helper.sVerbose;
|
||||
import static com.android.server.autofill.Helper.bundleToString;
|
||||
|
||||
@@ -397,6 +398,21 @@ public final class AutofillManagerService extends SystemService {
|
||||
}
|
||||
}
|
||||
|
||||
// Called by Shell command.
|
||||
public int getMaxPartitions() {
|
||||
synchronized (mLock) {
|
||||
return sPartitionMaxCount;
|
||||
}
|
||||
}
|
||||
|
||||
// Called by Shell command.
|
||||
public void setMaxPartitions(int max) {
|
||||
Slog.i(TAG, "setMaxPartitions(): " + max);
|
||||
synchronized (mLock) {
|
||||
sPartitionMaxCount = max;
|
||||
}
|
||||
}
|
||||
|
||||
private void setDebugLocked(boolean debug) {
|
||||
com.android.server.autofill.Helper.sDebug = debug;
|
||||
android.view.autofill.Helper.sDebug = debug;
|
||||
@@ -628,6 +644,7 @@ public final class AutofillManagerService extends SystemService {
|
||||
pw.print("Debug mode: "); pw.println(oldDebug);
|
||||
pw.print("Verbose mode: "); pw.println(sVerbose);
|
||||
pw.print("Disabled users: "); pw.println(mDisabledUsers);
|
||||
pw.print("Max partitions per session: "); pw.println(sPartitionMaxCount);
|
||||
final int size = mServicesCache.size();
|
||||
pw.print("Cached services: ");
|
||||
if (size == 0) {
|
||||
|
||||
@@ -70,9 +70,15 @@ public final class AutofillManagerServiceShellCommand extends ShellCommand {
|
||||
pw.println(" get log_level ");
|
||||
pw.println(" Gets the Autofill log level (off | debug | verbose).");
|
||||
pw.println("");
|
||||
pw.println(" get max_partitions");
|
||||
pw.println(" Gets the maximum number of partitions per session.");
|
||||
pw.println("");
|
||||
pw.println(" set log_level [off | debug | verbose]");
|
||||
pw.println(" Sets the Autofill log level.");
|
||||
pw.println("");
|
||||
pw.println(" set max_partitions number");
|
||||
pw.println(" Sets the maximum number of partitions per session.");
|
||||
pw.println("");
|
||||
pw.println(" list sessions [--user USER_ID]");
|
||||
pw.println(" List all pending sessions.");
|
||||
pw.println("");
|
||||
@@ -86,9 +92,33 @@ public final class AutofillManagerServiceShellCommand extends ShellCommand {
|
||||
}
|
||||
|
||||
private int requestGet(PrintWriter pw) {
|
||||
if (!isNextArgLogLevel(pw, "get")) {
|
||||
return -1;
|
||||
final String what = getNextArgRequired();
|
||||
switch(what) {
|
||||
case "log_level":
|
||||
return getLogLevel(pw);
|
||||
case "max_partitions":
|
||||
return getMaxPartitions(pw);
|
||||
default:
|
||||
pw.println("Invalid set: " + what);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
private int requestSet(PrintWriter pw) {
|
||||
final String what = getNextArgRequired();
|
||||
|
||||
switch(what) {
|
||||
case "log_level":
|
||||
return setLogLevel(pw);
|
||||
case "max_partitions":
|
||||
return setMaxPartitions();
|
||||
default:
|
||||
pw.println("Invalid set: " + what);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
private int getLogLevel(PrintWriter pw) {
|
||||
final int logLevel = mService.getLogLevel();
|
||||
switch (logLevel) {
|
||||
case AutofillManager.FLAG_ADD_CLIENT_VERBOSE:
|
||||
@@ -106,11 +136,8 @@ public final class AutofillManagerServiceShellCommand extends ShellCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private int requestSet(PrintWriter pw) {
|
||||
if (!isNextArgLogLevel(pw, "set")) {
|
||||
return -1;
|
||||
}
|
||||
final String logLevel = getNextArg();
|
||||
private int setLogLevel(PrintWriter pw) {
|
||||
final String logLevel = getNextArgRequired();
|
||||
switch (logLevel.toLowerCase()) {
|
||||
case "verbose":
|
||||
mService.setLogLevel(AutofillManager.FLAG_ADD_CLIENT_VERBOSE);
|
||||
@@ -127,6 +154,16 @@ public final class AutofillManagerServiceShellCommand extends ShellCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private int getMaxPartitions(PrintWriter pw) {
|
||||
pw.println(mService.getMaxPartitions());
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int setMaxPartitions() {
|
||||
mService.setMaxPartitions(Integer.parseInt(getNextArgRequired()));
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int requestDestroy(PrintWriter pw) {
|
||||
if (!isNextArgSessions(pw)) {
|
||||
return -1;
|
||||
|
||||
@@ -26,16 +26,23 @@ public final class Helper {
|
||||
|
||||
/**
|
||||
* Defines a logging flag that can be dynamically changed at runtime using
|
||||
* {@code cmd autofill debug [on|off]}.
|
||||
* {@code cmd autofill set log_level debug}.
|
||||
*/
|
||||
public static boolean sDebug = false;
|
||||
|
||||
/**
|
||||
* Defines a logging flag that can be dynamically changed at runtime using
|
||||
* {@code cmd autofill verbose [on|off]}.
|
||||
* {@code cmd autofill set log_level verbose}.
|
||||
*/
|
||||
public static boolean sVerbose = false;
|
||||
|
||||
/**
|
||||
* Maximum number of partitions that can be allowed in a session.
|
||||
*
|
||||
* <p>Can be modified using {@code cmd autofill set max_partitions}.
|
||||
*/
|
||||
static int sPartitionMaxCount = 10;
|
||||
|
||||
private Helper() {
|
||||
throw new UnsupportedOperationException("contains static members only");
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import static android.view.autofill.AutofillManager.ACTION_VIEW_ENTERED;
|
||||
import static android.view.autofill.AutofillManager.ACTION_VIEW_EXITED;
|
||||
|
||||
import static com.android.server.autofill.Helper.sDebug;
|
||||
import static com.android.server.autofill.Helper.sPartitionMaxCount;
|
||||
import static com.android.server.autofill.Helper.sVerbose;
|
||||
import static com.android.server.autofill.ViewState.STATE_AUTOFILLED;
|
||||
import static com.android.server.autofill.ViewState.STATE_RESTARTED_SESSION;
|
||||
@@ -162,6 +163,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
||||
@GuardedBy("mLock")
|
||||
private boolean mIsSaving;
|
||||
|
||||
|
||||
/**
|
||||
* Receiver of assist data from the app's {@link Activity}.
|
||||
*/
|
||||
@@ -933,7 +935,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
||||
}
|
||||
}
|
||||
|
||||
private static final int PARTITION_MAX_COUNT = 64;
|
||||
/**
|
||||
* Determines if a new partition should be started for an id.
|
||||
*
|
||||
@@ -947,8 +948,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
||||
}
|
||||
|
||||
final int numResponses = mResponses.size();
|
||||
if (numResponses >= PARTITION_MAX_COUNT) {
|
||||
Slog.e(TAG, "Cannot create more than 64 partitions. Not creating a new partition.");
|
||||
if (numResponses >= sPartitionMaxCount) {
|
||||
Slog.e(TAG, "Not starting a new partition on " + id + " because session " + this.id
|
||||
+ " reached maximum of " + sPartitionMaxCount);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user