Merge "DO NOT MERGE ANYWHERE Add supports-multiwindow command to am." into cw-f-dev

This commit is contained in:
TreeHugger Robot
2016-11-04 19:49:23 +00:00
committed by Android (Google) Code Review

View File

@@ -48,7 +48,9 @@ import android.content.pm.InstrumentationInfo;
import android.content.pm.ParceledListSlice; import android.content.pm.ParceledListSlice;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.content.pm.UserInfo; import android.content.pm.UserInfo;
import android.content.res.AssetManager;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Rect; import android.graphics.Rect;
import android.os.Binder; import android.os.Binder;
import android.os.Build; import android.os.Build;
@@ -64,6 +66,7 @@ import android.os.UserHandle;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.AndroidException; import android.util.AndroidException;
import android.util.ArrayMap; import android.util.ArrayMap;
import android.util.DisplayMetrics;
import android.view.IWindowManager; import android.view.IWindowManager;
import com.android.internal.os.BaseCommand; import com.android.internal.os.BaseCommand;
@@ -361,6 +364,8 @@ public class Am extends BaseCommand {
"am send-trim-memory: send a memory trim event to a <PROCESS>.\n" + "am send-trim-memory: send a memory trim event to a <PROCESS>.\n" +
"\n" + "\n" +
"am get-current-user: returns id of the current foreground user.\n" + "am get-current-user: returns id of the current foreground user.\n" +
"\n" +
"am supports-multiwindow: returns true if the device supports multiwindow.\n" +
"\n" "\n"
); );
Intent.printIntentArgsHelp(pw, ""); Intent.printIntentArgsHelp(pw, "");
@@ -458,6 +463,8 @@ public class Am extends BaseCommand {
runSendTrimMemory(); runSendTrimMemory();
} else if (op.equals("get-current-user")) { } else if (op.equals("get-current-user")) {
runGetCurrentUser(); runGetCurrentUser();
} else if (op.equals("supports-multiwindow")) {
runSupportsMultiwindow();
} else { } else {
showError("Error: unknown command '" + op + "'"); showError("Error: unknown command '" + op + "'");
} }
@@ -2534,6 +2541,21 @@ public class Am extends BaseCommand {
System.out.println(currentUser.id); System.out.println(currentUser.id);
} }
private void runSupportsMultiwindow() throws Exception {
// system resources does not contain all the device configuration, construct it manually.
Configuration config = mAm.getConfiguration();
if (config == null) {
throw new AndroidException("Activity manager has no configuration");
}
final DisplayMetrics metrics = new DisplayMetrics();
metrics.setToDefaults();
Resources res = new Resources(AssetManager.getSystem(), metrics, config);
System.out.println(res.getBoolean(com.android.internal.R.bool.config_supportsMultiWindow));
}
/** /**
* Open the given file for sending into the system process. This verifies * Open the given file for sending into the system process. This verifies
* with SELinux that the system will have access to the file. * with SELinux that the system will have access to the file.