summaryrefslogtreecommitdiff
path: root/cmds
diff options
context:
space:
mode:
Diffstat (limited to 'cmds')
-rw-r--r--cmds/am/src/com/android/commands/am/Am.java3
-rw-r--r--cmds/bootanimation/BootAnimation.cpp21
-rw-r--r--cmds/content/src/com/android/commands/content/Content.java146
-rw-r--r--cmds/input/src/com/android/commands/input/Input.java41
-rw-r--r--cmds/media/src/com/android/commands/media/Media.java12
-rw-r--r--cmds/svc/src/com/android/commands/svc/WifiCommand.java2
-rw-r--r--cmds/wm/src/com/android/commands/wm/Wm.java27
7 files changed, 183 insertions, 69 deletions
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java
index d6c00589e7c2..91334bd87296 100644
--- a/cmds/am/src/com/android/commands/am/Am.java
+++ b/cmds/am/src/com/android/commands/am/Am.java
@@ -2523,8 +2523,7 @@ public class Am extends BaseCommand {
return;
}
if (!mAm.setProcessMemoryTrimLevel(proc, userId, level)) {
- System.err.println("Error: Failure to set the level - probably Unknown Process: " +
- proc);
+ System.err.println("Unknown error: failed to set trim level");
}
}
diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp
index c9211939ec6c..3c2efd891e1a 100644
--- a/cmds/bootanimation/BootAnimation.cpp
+++ b/cmds/bootanimation/BootAnimation.cpp
@@ -49,8 +49,8 @@
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#include <SkBitmap.h>
+#include <SkImage.h>
#include <SkStream.h>
-#include <SkImageDecoder.h>
#pragma GCC diagnostic pop
#include <GLES/gl.h>
@@ -139,8 +139,10 @@ status_t BootAnimation::initTexture(Texture* texture, AssetManager& assets,
if (asset == NULL)
return NO_INIT;
SkBitmap bitmap;
- SkImageDecoder::DecodeMemory(asset->getBuffer(false), asset->getLength(),
- &bitmap, kUnknown_SkColorType, SkImageDecoder::kDecodePixels_Mode);
+ sk_sp<SkData> data = SkData::MakeWithoutCopy(asset->getBuffer(false),
+ asset->getLength());
+ sk_sp<SkImage> image = SkImage::MakeFromEncoded(data);
+ image->asLegacyBitmap(&bitmap, SkImage::kRO_LegacyBitmapMode);
asset->close();
delete asset;
@@ -192,15 +194,10 @@ status_t BootAnimation::initTexture(Texture* texture, AssetManager& assets,
status_t BootAnimation::initTexture(FileMap* map, int* width, int* height)
{
SkBitmap bitmap;
- SkMemoryStream stream(map->getDataPtr(), map->getDataLength());
- SkImageDecoder* codec = SkImageDecoder::Factory(&stream);
- if (codec != NULL) {
- codec->setDitherImage(false);
- codec->decode(&stream, &bitmap,
- kN32_SkColorType,
- SkImageDecoder::kDecodePixels_Mode);
- delete codec;
- }
+ sk_sp<SkData> data = SkData::MakeWithoutCopy(map->getDataPtr(),
+ map->getDataLength());
+ sk_sp<SkImage> image = SkImage::MakeFromEncoded(data);
+ image->asLegacyBitmap(&bitmap, SkImage::kRO_LegacyBitmapMode);
// FileMap memory is never released until application exit.
// Release it now as the texture is already loaded and the memory used for
diff --git a/cmds/content/src/com/android/commands/content/Content.java b/cmds/content/src/com/android/commands/content/Content.java
index d43b8c564e96..c7474a11651c 100644
--- a/cmds/content/src/com/android/commands/content/Content.java
+++ b/cmds/content/src/com/android/commands/content/Content.java
@@ -72,59 +72,64 @@ import libcore.io.IoUtils;
public class Content {
private static final String USAGE =
- "usage: adb shell content [subcommand] [options]\n"
- + "\n"
- + "usage: adb shell content insert --uri <URI> [--user <USER_ID>]"
- + " --bind <BINDING> [--bind <BINDING>...]\n"
- + " <URI> a content provider URI.\n"
- + " <BINDING> binds a typed value to a column and is formatted:\n"
- + " <COLUMN_NAME>:<TYPE>:<COLUMN_VALUE> where:\n"
- + " <TYPE> specifies data type such as:\n"
- + " b - boolean, s - string, i - integer, l - long, f - float, d - double\n"
- + " Note: Omit the value for passing an empty string, e.g column:s:\n"
- + " Example:\n"
- + " # Add \"new_setting\" secure setting with value \"new_value\".\n"
- + " adb shell content insert --uri content://settings/secure --bind name:s:new_setting"
- + " --bind value:s:new_value\n"
- + "\n"
- + "usage: adb shell content update --uri <URI> [--user <USER_ID>] [--where <WHERE>]\n"
- + " <WHERE> is a SQL style where clause in quotes (You have to escape single quotes"
- + " - see example below).\n"
- + " Example:\n"
- + " # Change \"new_setting\" secure setting to \"newer_value\".\n"
- + " adb shell content update --uri content://settings/secure --bind"
- + " value:s:newer_value --where \"name=\'new_setting\'\"\n"
- + "\n"
- + "usage: adb shell content delete --uri <URI> [--user <USER_ID>] --bind <BINDING>"
- + " [--bind <BINDING>...] [--where <WHERE>]\n"
- + " Example:\n"
- + " # Remove \"new_setting\" secure setting.\n"
- + " adb shell content delete --uri content://settings/secure "
- + "--where \"name=\'new_setting\'\"\n"
- + "\n"
- + "usage: adb shell content query --uri <URI> [--user <USER_ID>]"
- + " [--projection <PROJECTION>] [--where <WHERE>] [--sort <SORT_ORDER>]\n"
- + " <PROJECTION> is a list of colon separated column names and is formatted:\n"
- + " <COLUMN_NAME>[:<COLUMN_NAME>...]\n"
- + " <SORT_ORDER> is the order in which rows in the result should be sorted.\n"
- + " Example:\n"
- + " # Select \"name\" and \"value\" columns from secure settings where \"name\" is "
- + "equal to \"new_setting\" and sort the result by name in ascending order.\n"
- + " adb shell content query --uri content://settings/secure --projection name:value"
- + " --where \"name=\'new_setting\'\" --sort \"name ASC\"\n"
- + "\n"
- + "usage: adb shell content call --uri <URI> --method <METHOD> [--arg <ARG>]\n"
- + " [--extra <BINDING> ...]\n"
- + " <METHOD> is the name of a provider-defined method\n"
- + " <ARG> is an optional string argument\n"
- + " <BINDING> is like --bind above, typed data of the form <KEY>:{b,s,i,l,f,d}:<VAL>\n"
- + "\n"
- + "usage: adb shell content read --uri <URI> [--user <USER_ID>]\n"
- + " Example:\n"
- + " # cat default ringtone to a file, then pull to host\n"
- + " adb shell 'content read --uri content://settings/system/ringtone >"
- + " /mnt/sdcard/tmp.ogg' && adb pull /mnt/sdcard/tmp.ogg\n"
- + "\n";
+ "usage: adb shell content [subcommand] [options]\n"
+ + "\n"
+ + "usage: adb shell content insert --uri <URI> [--user <USER_ID>]"
+ + " --bind <BINDING> [--bind <BINDING>...]\n"
+ + " <URI> a content provider URI.\n"
+ + " <BINDING> binds a typed value to a column and is formatted:\n"
+ + " <COLUMN_NAME>:<TYPE>:<COLUMN_VALUE> where:\n"
+ + " <TYPE> specifies data type such as:\n"
+ + " b - boolean, s - string, i - integer, l - long, f - float, d - double\n"
+ + " Note: Omit the value for passing an empty string, e.g column:s:\n"
+ + " Example:\n"
+ + " # Add \"new_setting\" secure setting with value \"new_value\".\n"
+ + " adb shell content insert --uri content://settings/secure --bind name:s:new_setting"
+ + " --bind value:s:new_value\n"
+ + "\n"
+ + "usage: adb shell content update --uri <URI> [--user <USER_ID>] [--where <WHERE>]\n"
+ + " <WHERE> is a SQL style where clause in quotes (You have to escape single quotes"
+ + " - see example below).\n"
+ + " Example:\n"
+ + " # Change \"new_setting\" secure setting to \"newer_value\".\n"
+ + " adb shell content update --uri content://settings/secure --bind"
+ + " value:s:newer_value --where \"name=\'new_setting\'\"\n"
+ + "\n"
+ + "usage: adb shell content delete --uri <URI> [--user <USER_ID>] --bind <BINDING>"
+ + " [--bind <BINDING>...] [--where <WHERE>]\n"
+ + " Example:\n"
+ + " # Remove \"new_setting\" secure setting.\n"
+ + " adb shell content delete --uri content://settings/secure "
+ + "--where \"name=\'new_setting\'\"\n"
+ + "\n"
+ + "usage: adb shell content query --uri <URI> [--user <USER_ID>]"
+ + " [--projection <PROJECTION>] [--where <WHERE>] [--sort <SORT_ORDER>]\n"
+ + " <PROJECTION> is a list of colon separated column names and is formatted:\n"
+ + " <COLUMN_NAME>[:<COLUMN_NAME>...]\n"
+ + " <SORT_ORDER> is the order in which rows in the result should be sorted.\n"
+ + " Example:\n"
+ + " # Select \"name\" and \"value\" columns from secure settings where \"name\" is "
+ + "equal to \"new_setting\" and sort the result by name in ascending order.\n"
+ + " adb shell content query --uri content://settings/secure --projection name:value"
+ + " --where \"name=\'new_setting\'\" --sort \"name ASC\"\n"
+ + "\n"
+ + "usage: adb shell content call --uri <URI> --method <METHOD> [--arg <ARG>]\n"
+ + " [--extra <BINDING> ...]\n"
+ + " <METHOD> is the name of a provider-defined method\n"
+ + " <ARG> is an optional string argument\n"
+ + " <BINDING> is like --bind above, typed data of the form <KEY>:{b,s,i,l,f,d}:<VAL>\n"
+ + "\n"
+ + "usage: adb shell content read --uri <URI> [--user <USER_ID>]\n"
+ + " Example:\n"
+ + " # cat default ringtone to a file, then pull to host\n"
+ + " adb shell 'content read --uri content://settings/system/ringtone >"
+ + " /mnt/sdcard/tmp.ogg' && adb pull /mnt/sdcard/tmp.ogg\n"
+ + "\n"
+ + "usage: adb shell content gettype --uri <URI> [--user <USER_ID>]\n"
+ + " Example:\n"
+ + " # Show the mime-type of the URI\n"
+ + " adb shell content gettype --uri content://media/internal/audio/media/\n"
+ + "\n";
private static class Parser {
private static final String ARGUMENT_INSERT = "insert";
@@ -133,6 +138,7 @@ public class Content {
private static final String ARGUMENT_QUERY = "query";
private static final String ARGUMENT_CALL = "call";
private static final String ARGUMENT_READ = "read";
+ private static final String ARGUMENT_GET_TYPE = "gettype";
private static final String ARGUMENT_WHERE = "--where";
private static final String ARGUMENT_BIND = "--bind";
private static final String ARGUMENT_URI = "--uri";
@@ -172,6 +178,8 @@ public class Content {
return parseCallCommand();
} else if (ARGUMENT_READ.equals(operation)) {
return parseReadCommand();
+ } else if (ARGUMENT_GET_TYPE.equals(operation)) {
+ return parseGetTypeCommand();
} else {
throw new IllegalArgumentException("Unsupported operation: " + operation);
}
@@ -291,6 +299,26 @@ public class Content {
return new CallCommand(uri, userId, method, arg, values);
}
+ private GetTypeCommand parseGetTypeCommand() {
+ Uri uri = null;
+ int userId = UserHandle.USER_SYSTEM;
+
+ for (String argument; (argument = mTokenizer.nextArg()) != null;) {
+ if (ARGUMENT_URI.equals(argument)) {
+ uri = Uri.parse(argumentValueRequired(argument));
+ } else if (ARGUMENT_USER.equals(argument)) {
+ userId = Integer.parseInt(argumentValueRequired(argument));
+ } else {
+ throw new IllegalArgumentException("Unsupported argument: " + argument);
+ }
+ }
+ if (uri == null) {
+ throw new IllegalArgumentException("Content provider URI not specified."
+ + " Did you specify --uri argument?");
+ }
+ return new GetTypeCommand(uri, userId);
+ }
+
private ReadCommand parseReadCommand() {
Uri uri = null;
int userId = UserHandle.USER_SYSTEM;
@@ -511,6 +539,18 @@ public class Content {
}
}
+ private static class GetTypeCommand extends Command {
+ public GetTypeCommand(Uri uri, int userId) {
+ super(uri, userId);
+ }
+
+ @Override
+ public void onExecute(IContentProvider provider) throws Exception {
+ String type = provider.getType(mUri);
+ System.out.println("Result: " + type);
+ }
+ }
+
private static class ReadCommand extends Command {
public ReadCommand(Uri uri, int userId) {
super(uri, userId);
diff --git a/cmds/input/src/com/android/commands/input/Input.java b/cmds/input/src/com/android/commands/input/Input.java
index 754d3f510bbd..9ee11f8571e2 100644
--- a/cmds/input/src/com/android/commands/input/Input.java
+++ b/cmds/input/src/com/android/commands/input/Input.java
@@ -23,6 +23,7 @@ import android.view.InputDevice;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.MotionEvent;
+import android.view.ViewConfiguration;
import java.util.HashMap;
import java.util.Map;
@@ -118,6 +119,19 @@ public class Input {
duration);
return;
}
+ } else if (command.equals("draganddrop")) {
+ int duration = -1;
+ inputSource = getSource(inputSource, InputDevice.SOURCE_TOUCHSCREEN);
+ switch (length) {
+ case 6:
+ duration = Integer.parseInt(args[index+5]);
+ case 5:
+ sendDragAndDrop(inputSource,
+ Float.parseFloat(args[index+1]), Float.parseFloat(args[index+2]),
+ Float.parseFloat(args[index+3]), Float.parseFloat(args[index+4]),
+ duration);
+ return;
+ }
} else if (command.equals("press")) {
inputSource = getSource(inputSource, InputDevice.SOURCE_TRACKBALL);
if (length == 1) {
@@ -216,6 +230,31 @@ public class Input {
injectMotionEvent(inputSource, MotionEvent.ACTION_UP, now, x2, y2, 0.0f);
}
+ private void sendDragAndDrop(int inputSource, float x1, float y1, float x2, float y2,
+ int dragDuration) {
+ if (dragDuration < 0) {
+ dragDuration = 300;
+ }
+ long now = SystemClock.uptimeMillis();
+ injectMotionEvent(inputSource, MotionEvent.ACTION_DOWN, now, x1, y1, 1.0f);
+ try {
+ Thread.sleep(ViewConfiguration.getLongPressTimeout());
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ now = SystemClock.uptimeMillis();
+ long startTime = now;
+ long endTime = startTime + dragDuration;
+ while (now < endTime) {
+ long elapsedTime = now - startTime;
+ float alpha = (float) elapsedTime / dragDuration;
+ injectMotionEvent(inputSource, MotionEvent.ACTION_MOVE, now, lerp(x1, x2, alpha),
+ lerp(y1, y2, alpha), 1.0f);
+ now = SystemClock.uptimeMillis();
+ }
+ injectMotionEvent(inputSource, MotionEvent.ACTION_UP, now, x2, y2, 0.0f);
+ }
+
/**
* Sends a simple zero-pressure move event.
*
@@ -294,6 +333,8 @@ public class Input {
System.err.println(" tap <x> <y> (Default: touchscreen)");
System.err.println(" swipe <x1> <y1> <x2> <y2> [duration(ms)]"
+ " (Default: touchscreen)");
+ System.err.println(" draganddrop <x1> <y1> <x2> <y2> [duration(ms)]"
+ + " (Default: touchscreen)");
System.err.println(" press (Default: trackball)");
System.err.println(" roll <dx> <dy> (Default: trackball)");
}
diff --git a/cmds/media/src/com/android/commands/media/Media.java b/cmds/media/src/com/android/commands/media/Media.java
index d7f23cb44098..0e0ecd0ba068 100644
--- a/cmds/media/src/com/android/commands/media/Media.java
+++ b/cmds/media/src/com/android/commands/media/Media.java
@@ -57,6 +57,7 @@ public class Media extends BaseCommand {
(new Media()).run(args);
}
+ @Override
public void onShowUsage(PrintStream out) {
out.println(
"usage: media [subcommand] [options]\n" +
@@ -73,6 +74,7 @@ public class Media extends BaseCommand {
);
}
+ @Override
public void onRun() throws Exception {
mSessionService = ISessionManager.Stub.asInterface(ServiceManager.checkService(
Context.MEDIA_SESSION_SERVICE));
@@ -222,6 +224,16 @@ public class Media extends BaseCommand {
System.out.println("onVolumeInfoChanged " + info);
}
+ @Override
+ public void onRepeatModeChanged(int repeatMode) throws RemoteException {
+ System.out.println("onRepeatModeChanged " + repeatMode);
+ }
+
+ @Override
+ public void onShuffleModeChanged(boolean enabled) throws RemoteException {
+ System.out.println("onShuffleModeChanged " + enabled);
+ }
+
void printUsageMessage() {
try {
System.out.println("V2Monitoring session " + mController.getTag()
diff --git a/cmds/svc/src/com/android/commands/svc/WifiCommand.java b/cmds/svc/src/com/android/commands/svc/WifiCommand.java
index 94214ff9694f..633dd9787cb1 100644
--- a/cmds/svc/src/com/android/commands/svc/WifiCommand.java
+++ b/cmds/svc/src/com/android/commands/svc/WifiCommand.java
@@ -52,7 +52,7 @@ public class WifiCommand extends Svc.Command {
IWifiManager wifiMgr
= IWifiManager.Stub.asInterface(ServiceManager.getService(Context.WIFI_SERVICE));
try {
- wifiMgr.setWifiEnabled(flag);
+ wifiMgr.setWifiEnabled("com.android.shell", flag);
}
catch (RemoteException e) {
System.err.println("Wi-Fi operation failed: " + e);
diff --git a/cmds/wm/src/com/android/commands/wm/Wm.java b/cmds/wm/src/com/android/commands/wm/Wm.java
index 383cd01ddcd6..84fb626cc4c6 100644
--- a/cmds/wm/src/com/android/commands/wm/Wm.java
+++ b/cmds/wm/src/com/android/commands/wm/Wm.java
@@ -21,16 +21,22 @@ package com.android.commands.wm;
import android.content.Context;
import android.graphics.Point;
import android.graphics.Rect;
+import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.util.AndroidException;
import android.util.DisplayMetrics;
+import android.system.Os;
import android.view.Display;
import android.view.IWindowManager;
import com.android.internal.os.BaseCommand;
+import java.io.FileDescriptor;
+import java.io.FileInputStream;
+import java.io.DataInputStream;
import java.io.PrintStream;
+import java.lang.Runtime;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -69,7 +75,9 @@ public class Wm extends BaseCommand {
"wm screen-capture: enable/disable screen capture.\n" +
"\n" +
"wm dismiss-keyguard: dismiss the keyguard, prompting the user for auth if " +
- "necessary.\n"
+ "necessary.\n" +
+ "\n" +
+ "wm surface-trace: log surface commands to stdout in a binary format.\n"
);
}
@@ -96,12 +104,29 @@ public class Wm extends BaseCommand {
runSetScreenCapture();
} else if (op.equals("dismiss-keyguard")) {
runDismissKeyguard();
+ } else if (op.equals("surface-trace")) {
+ runSurfaceTrace();
} else {
showError("Error: unknown command '" + op + "'");
return;
}
}
+ private void runSurfaceTrace() throws Exception {
+ ParcelFileDescriptor pfd = ParcelFileDescriptor.dup(FileDescriptor.out);
+ mWm.enableSurfaceTrace(pfd);
+
+ try {
+ // No one is going to wake us up, we are just waiting on SIGINT. Otherwise
+ // the WM can happily continue writing to our stdout.
+ synchronized (this) {
+ this.wait();
+ }
+ } finally {
+ mWm.disableSurfaceTrace();
+ }
+ }
+
private void runSetScreenCapture() throws Exception {
String userIdStr = nextArg();
String enableStr = nextArg();