diff options
Diffstat (limited to 'cmds')
-rw-r--r-- | cmds/am/src/com/android/commands/am/Am.java | 42 | ||||
-rw-r--r-- | cmds/bootanimation/Android.mk | 3 | ||||
-rw-r--r-- | cmds/bootanimation/BootAnimation.cpp | 15 | ||||
-rw-r--r-- | cmds/bu/src/com/android/commands/bu/Backup.java | 9 | ||||
-rw-r--r-- | cmds/content/src/com/android/commands/content/Content.java | 63 | ||||
-rw-r--r-- | cmds/idmap/scan.cpp | 3 | ||||
-rw-r--r-- | cmds/pm/src/com/android/commands/pm/Pm.java | 75 | ||||
-rw-r--r-- | cmds/screencap/Android.mk | 7 | ||||
-rw-r--r-- | cmds/screencap/screencap.cpp | 2 |
9 files changed, 188 insertions, 31 deletions
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java index 89e15d2..6b55b7b 100644 --- a/cmds/am/src/com/android/commands/am/Am.java +++ b/cmds/am/src/com/android/commands/am/Am.java @@ -114,6 +114,8 @@ public class Am extends BaseCommand { " am stack resize <STACK_ID> <LEFT,TOP,RIGHT,BOTTOM>\n" + " am stack list\n" + " am stack info <STACK_ID>\n" + + " am lock-task <TASK_ID>\n" + + " am lock-task stop\n" + "\n" + "am start: start an Activity. Options are:\n" + " -D: enable debugging\n" + @@ -218,6 +220,8 @@ public class Am extends BaseCommand { "\n" + "am stack info: display the information about activity stack <STACK_ID>.\n" + "\n" + + "am lock-task: bring <TASK_ID> to the front and don't allow other tasks to run\n" + + "\n" + "<INTENT> specifications include these flags and arguments:\n" + " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]\n" + " [-c <CATEGORY> [-c <CATEGORY>] ...]\n" + @@ -232,8 +236,11 @@ public class Am extends BaseCommand { " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]\n" + " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]\n" + " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]\n" + + " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]\n" + + " (to embed a comma into a string escape it using \"\\,\")\n" + " [-n <COMPONENT>] [-f <FLAGS>]\n" + " [--grant-read-uri-permission] [--grant-write-uri-permission]\n" + + " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]\n" + " [--debug-log-resolution] [--exclude-stopped-packages]\n" + " [--include-stopped-packages]\n" + " [--activity-brought-to-front] [--activity-clear-top]\n" + @@ -307,6 +314,8 @@ public class Am extends BaseCommand { runStopUser(); } else if (op.equals("stack")) { runStack(); + } else if (op.equals("lock-task")) { + runLockTask(); } else { showError("Error: unknown command '" + op + "'"); } @@ -419,6 +428,15 @@ public class Am extends BaseCommand { } intent.putExtra(key, list); hasIntentInfo = true; + } else if (opt.equals("--esa")) { + String key = nextArgRequired(); + String value = nextArgRequired(); + // Split on commas unless they are preceeded by an escape. + // The escape character must be escaped for the string and + // again for the regex, thus four escape characters become one. + String[] strings = value.split("(?<!\\\\),"); + intent.putExtra(key, strings); + hasIntentInfo = true; } else if (opt.equals("--ez")) { String key = nextArgRequired(); String value = nextArgRequired(); @@ -438,6 +456,10 @@ public class Am extends BaseCommand { intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); } else if (opt.equals("--grant-write-uri-permission")) { intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); + } else if (opt.equals("--grant-persistable-uri-permission")) { + intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION); + } else if (opt.equals("--grant-prefix-uri-permission")) { + intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION); } else if (opt.equals("--exclude-stopped-packages")) { intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES); } else if (opt.equals("--include-stopped-packages")) { @@ -727,6 +749,11 @@ public class Am extends BaseCommand { "Error: Activity not started, you do not " + "have permission to access it."); break; + case ActivityManager.START_NOT_VOICE_COMPATIBLE: + out.println( + "Error: Activity not started, voice control not allowed for: " + + intent); + break; default: out.println( "Error: Activity not started, unknown error code " + res); @@ -1630,4 +1657,19 @@ public class Am extends BaseCommand { } catch (RemoteException e) { } } + + private void runLockTask() throws Exception { + String taskIdStr = nextArgRequired(); + try { + if (taskIdStr.equals("stop")) { + mAm.stopLockTaskMode(); + } else { + int taskId = Integer.valueOf(taskIdStr); + mAm.startLockTaskMode(taskId); + } + System.err.println("Activity manager is " + (mAm.isInLockTaskMode() ? "" : "not ") + + "in lockTaskMode"); + } catch (RemoteException e) { + } + } } diff --git a/cmds/bootanimation/Android.mk b/cmds/bootanimation/Android.mk index dd987e0..c4fe6cf 100644 --- a/cmds/bootanimation/Android.mk +++ b/cmds/bootanimation/Android.mk @@ -19,9 +19,6 @@ LOCAL_SHARED_LIBRARIES := \ libGLESv1_CM \ libgui -LOCAL_C_INCLUDES := \ - $(call include-path-for, corecg graphics) - LOCAL_MODULE:= bootanimation ifdef TARGET_32_BIT_SURFACEFLINGER diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp index 1a2ab81..1780e03 100644 --- a/cmds/bootanimation/BootAnimation.cpp +++ b/cmds/bootanimation/BootAnimation.cpp @@ -36,15 +36,14 @@ #include <ui/Rect.h> #include <ui/Region.h> #include <ui/DisplayInfo.h> -#include <ui/FramebufferNativeWindow.h> #include <gui/ISurfaceComposer.h> #include <gui/Surface.h> #include <gui/SurfaceComposerClient.h> -#include <core/SkBitmap.h> -#include <core/SkStream.h> -#include <core/SkImageDecoder.h> +#include <SkBitmap.h> +#include <SkStream.h> +#include <SkImageDecoder.h> #include <GLES/gl.h> #include <GLES/glext.h> @@ -52,6 +51,7 @@ #include "BootAnimation.h" +#define OEM_BOOTANIMATION_FILE "/oem/media/bootanimation.zip" #define SYSTEM_BOOTANIMATION_FILE "/system/media/bootanimation.zip" #define SYSTEM_ENCRYPTED_BOOTANIMATION_FILE "/system/media/bootanimation-encrypted.zip" #define EXIT_PROP_NAME "service.bootanim.exit" @@ -127,7 +127,7 @@ status_t BootAnimation::initTexture(Texture* texture, AssetManager& assets, glGenTextures(1, &texture->name); glBindTexture(GL_TEXTURE_2D, texture->name); - switch (bitmap.getConfig()) { + switch (bitmap.config()) { case SkBitmap::kA8_Config: glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_ALPHA, GL_UNSIGNED_BYTE, p); @@ -185,7 +185,7 @@ status_t BootAnimation::initTexture(void* buffer, size_t len) if (tw < w) tw <<= 1; if (th < h) th <<= 1; - switch (bitmap.getConfig()) { + switch (bitmap.config()) { case SkBitmap::kARGB_8888_Config: if (tw != w || th != h) { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tw, th, 0, GL_RGBA, @@ -284,6 +284,9 @@ status_t BootAnimation::readyToRun() { (access(SYSTEM_ENCRYPTED_BOOTANIMATION_FILE, R_OK) == 0) && ((zipFile = ZipFileRO::open(SYSTEM_ENCRYPTED_BOOTANIMATION_FILE)) != NULL)) || + ((access(OEM_BOOTANIMATION_FILE, R_OK) == 0) && + ((zipFile = ZipFileRO::open(OEM_BOOTANIMATION_FILE)) != NULL)) || + ((access(SYSTEM_BOOTANIMATION_FILE, R_OK) == 0) && ((zipFile = ZipFileRO::open(SYSTEM_BOOTANIMATION_FILE)) != NULL))) { mZip = zipFile; diff --git a/cmds/bu/src/com/android/commands/bu/Backup.java b/cmds/bu/src/com/android/commands/bu/Backup.java index 73fd660..2673031 100644 --- a/cmds/bu/src/com/android/commands/bu/Backup.java +++ b/cmds/bu/src/com/android/commands/bu/Backup.java @@ -68,6 +68,7 @@ public final class Backup { boolean saveObbs = false; boolean saveShared = false; boolean doEverything = false; + boolean doWidgets = false; boolean allIncludesSystem = true; String arg; @@ -89,6 +90,10 @@ public final class Backup { allIncludesSystem = true; } else if ("-nosystem".equals(arg)) { allIncludesSystem = false; + } else if ("-widgets".equals(arg)) { + doWidgets = true; + } else if ("-nowidgets".equals(arg)) { + doWidgets = false; } else if ("-all".equals(arg)) { doEverything = true; } else { @@ -114,8 +119,8 @@ public final class Backup { try { fd = ParcelFileDescriptor.adoptFd(socketFd); String[] packArray = new String[packages.size()]; - mBackupManager.fullBackup(fd, saveApks, saveObbs, saveShared, doEverything, - allIncludesSystem, packages.toArray(packArray)); + mBackupManager.fullBackup(fd, saveApks, saveObbs, saveShared, doWidgets, + doEverything, allIncludesSystem, packages.toArray(packArray)); } catch (RemoteException e) { Log.e(TAG, "Unable to invoke backup manager for backup"); } finally { diff --git a/cmds/content/src/com/android/commands/content/Content.java b/cmds/content/src/com/android/commands/content/Content.java index e66bdf4..948c9a2 100644 --- a/cmds/content/src/com/android/commands/content/Content.java +++ b/cmds/content/src/com/android/commands/content/Content.java @@ -26,9 +26,17 @@ import android.net.Uri; import android.os.Binder; import android.os.Bundle; import android.os.IBinder; +import android.os.ParcelFileDescriptor; import android.os.UserHandle; import android.text.TextUtils; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import libcore.io.IoUtils; + /** * This class is a command line utility for manipulating content. A client * can insert, update, and remove records in a content provider. For example, @@ -109,6 +117,12 @@ public class Content { + " <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"; private static class Parser { @@ -117,6 +131,7 @@ public class Content { private static final String ARGUMENT_UPDATE = "update"; 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_WHERE = "--where"; private static final String ARGUMENT_BIND = "--bind"; private static final String ARGUMENT_URI = "--uri"; @@ -154,6 +169,8 @@ public class Content { return parseQueryCommand(); } else if (ARGUMENT_CALL.equals(operation)) { return parseCallCommand(); + } else if (ARGUMENT_READ.equals(operation)) { + return parseReadCommand(); } else { throw new IllegalArgumentException("Unsupported operation: " + operation); } @@ -273,6 +290,25 @@ public class Content { return new CallCommand(uri, userId, method, arg, values); } + private ReadCommand parseReadCommand() { + Uri uri = null; + int userId = UserHandle.USER_OWNER; + 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 ReadCommand(uri, userId); + } + public QueryCommand parseQueryCommand() { Uri uri = null; int userId = UserHandle.USER_OWNER; @@ -458,6 +494,31 @@ public class Content { } } + private static class ReadCommand extends Command { + public ReadCommand(Uri uri, int userId) { + super(uri, userId); + } + + @Override + public void onExecute(IContentProvider provider) throws Exception { + final ParcelFileDescriptor fd = provider.openFile(null, mUri, "r", null); + copy(new FileInputStream(fd.getFileDescriptor()), System.out); + } + + private static void copy(InputStream is, OutputStream os) throws IOException { + final byte[] buffer = new byte[8 * 1024]; + int read; + try { + while ((read = is.read(buffer)) > -1) { + os.write(buffer, 0, read); + } + } finally { + IoUtils.closeQuietly(is); + IoUtils.closeQuietly(os); + } + } + } + private static class QueryCommand extends DeleteCommand { final String[] mProjection; final String mSortOrder; @@ -498,7 +559,7 @@ public class Content { columnValue = String.valueOf(cursor.getFloat(columnIndex)); break; case Cursor.FIELD_TYPE_INTEGER: - columnValue = String.valueOf(cursor.getInt(columnIndex)); + columnValue = String.valueOf(cursor.getLong(columnIndex)); break; case Cursor.FIELD_TYPE_STRING: columnValue = cursor.getString(columnIndex); diff --git a/cmds/idmap/scan.cpp b/cmds/idmap/scan.cpp index c5fc941..1153f38 100644 --- a/cmds/idmap/scan.cpp +++ b/cmds/idmap/scan.cpp @@ -119,7 +119,8 @@ namespace { int parse_manifest(const void *data, size_t size, const char *target_package_name) { - ResXMLTree parser(data, size); + ResXMLTree parser; + parser.setTo(data, size); if (parser.getError() != NO_ERROR) { ALOGD("%s failed to init xml parser, error=0x%08x\n", __FUNCTION__, parser.getError()); return -1; diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java index d1ded10..5454b46 100644 --- a/cmds/pm/src/com/android/commands/pm/Pm.java +++ b/cmds/pm/src/com/android/commands/pm/Pm.java @@ -18,13 +18,14 @@ package com.android.commands.pm; import android.app.ActivityManager; import android.app.ActivityManagerNative; +import android.app.IActivityManager; import android.content.ComponentName; import android.content.pm.ApplicationInfo; import android.content.pm.ContainerEncryptionParams; import android.content.pm.FeatureInfo; import android.content.pm.IPackageDataObserver; import android.content.pm.IPackageDeleteObserver; -import android.content.pm.IPackageInstallObserver; +import android.content.pm.IPackageInstallObserver2; import android.content.pm.IPackageManager; import android.content.pm.InstrumentationInfo; import android.content.pm.PackageInfo; @@ -38,7 +39,9 @@ import android.content.pm.VerificationParams; import android.content.res.AssetManager; import android.content.res.Resources; import android.net.Uri; +import android.os.Bundle; import android.os.IUserManager; +import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; @@ -698,14 +701,23 @@ public final class Pm { ActivityManager.dumpPackageStateStatic(FileDescriptor.out, pkg); } - class PackageInstallObserver extends IPackageInstallObserver.Stub { + class PackageInstallObserver extends IPackageInstallObserver2.Stub { boolean finished; int result; + String extraPermission; + String extraPackage; - public void packageInstalled(String name, int status) { + @Override + public void packageInstalled(String name, Bundle extras, int status) { synchronized( this) { finished = true; result = status; + if (status == PackageManager.INSTALL_FAILED_DUPLICATE_PERMISSION) { + extraPermission = extras.getString( + PackageManager.EXTRA_FAILURE_EXISTING_PERMISSION); + extraPackage = extras.getString( + PackageManager.EXTRA_FAILURE_EXISTING_PACKAGE); + } notifyAll(); } } @@ -715,7 +727,8 @@ public final class Pm { * Converts a failure code into a string by using reflection to find a matching constant * in PackageManager. */ - private String installFailureToString(int result) { + private String installFailureToString(PackageInstallObserver obs) { + final int result = obs.result; Field[] fields = PackageManager.class.getFields(); for (Field f: fields) { if (f.getType() == int.class) { @@ -730,7 +743,16 @@ public final class Pm { // get the int value and compare it to result. try { if (result == f.getInt(null)) { - return fieldName; + StringBuilder sb = new StringBuilder(64); + sb.append(fieldName); + if (obs.extraPermission != null) { + sb.append(" perm="); + sb.append(obs.extraPermission); + } + if (obs.extraPackage != null) { + sb.append(" pkg=" + obs.extraPackage); + } + return sb.toString(); } } catch (IllegalAccessException e) { // this shouldn't happen since we only look for public static fields. @@ -954,7 +976,7 @@ public final class Pm { VerificationParams verificationParams = new VerificationParams(verificationURI, originatingURI, referrerURI, VerificationParams.NO_UID, null); - mPm.installPackageWithVerificationAndEncryption(apkURI, obs, installFlags, + mPm.installPackageWithVerificationAndEncryptionEtc(apkURI, null, obs, installFlags, installerPackageName, verificationParams, encryptionParams); synchronized (obs) { @@ -968,7 +990,7 @@ public final class Pm { System.out.println("Success"); } else { System.err.println("Failure [" - + installFailureToString(obs.result) + + installFailureToString(obs) + "]"); } } @@ -1011,6 +1033,27 @@ public final class Pm { public void runCreateUser() { String name; + int userId = -1; + int flags = 0; + String opt; + while ((opt = nextOption()) != null) { + if ("--profileOf".equals(opt)) { + String optionData = nextOptionData(); + if (optionData == null || !isNumber(optionData)) { + System.err.println("Error: no USER_ID specified"); + showUsage(); + return; + } else { + userId = Integer.parseInt(optionData); + } + } else if ("--managed".equals(opt)) { + flags |= UserInfo.FLAG_MANAGED_PROFILE; + } else { + System.err.println("Error: unknown option " + opt); + showUsage(); + return; + } + } String arg = nextArg(); if (arg == null) { System.err.println("Error: no user name specified."); @@ -1018,7 +1061,16 @@ public final class Pm { } name = arg; try { - final UserInfo info = mUm.createUser(name, 0); + UserInfo info = null; + if (userId < 0) { + info = mUm.createUser(name, flags); + } else { + if (Process.myUid() != 0) { + System.err.println("Error: not running as root."); + return; + } + info = mUm.createProfileForUser(name, flags, userId); + } if (info != null) { System.out.println("Success: created user id " + info.id); } else { @@ -1058,13 +1110,16 @@ public final class Pm { public void runListUsers() { try { + IActivityManager am = ActivityManagerNative.getDefault(); + List<UserInfo> users = mUm.getUsers(false); if (users == null) { System.err.println("Error: couldn't get users"); } else { System.out.println("Users:"); for (int i = 0; i < users.size(); i++) { - System.out.println("\t" + users.get(i).toString()); + String running = am.isUserRunning(users.get(i).id, false) ? " running" : ""; + System.out.println("\t" + users.get(i).toString() + running); } } } catch (RemoteException e) { @@ -1530,7 +1585,7 @@ public final class Pm { System.err.println(" pm get-install-location"); System.err.println(" pm set-permission-enforced PERMISSION [true|false]"); System.err.println(" pm trim-caches DESIRED_FREE_SPACE"); - System.err.println(" pm create-user USER_NAME"); + System.err.println(" pm create-user [--relatedTo USER_ID] [--managed] USER_NAME"); System.err.println(" pm remove-user USER_ID"); System.err.println(" pm get-max-users"); System.err.println(""); diff --git a/cmds/screencap/Android.mk b/cmds/screencap/Android.mk index ca8008b..5c11b75 100644 --- a/cmds/screencap/Android.mk +++ b/cmds/screencap/Android.mk @@ -16,11 +16,4 @@ LOCAL_MODULE:= screencap LOCAL_MODULE_TAGS := optional -LOCAL_C_INCLUDES += \ - external/skia/include/core \ - external/skia/include/effects \ - external/skia/include/images \ - external/skia/src/ports \ - external/skia/include/utils - include $(BUILD_EXECUTABLE) diff --git a/cmds/screencap/screencap.cpp b/cmds/screencap/screencap.cpp index a57de01..2efe4d3 100644 --- a/cmds/screencap/screencap.cpp +++ b/cmds/screencap/screencap.cpp @@ -141,7 +141,7 @@ int main(int argc, char** argv) ScreenshotClient screenshot; sp<IBinder> display = SurfaceComposerClient::getBuiltInDisplay(displayId); - if (display != NULL && screenshot.update(display) == NO_ERROR) { + if (display != NULL && screenshot.update(display, false) == NO_ERROR) { base = screenshot.getPixels(); w = screenshot.getWidth(); h = screenshot.getHeight(); |