summaryrefslogtreecommitdiff
path: root/cmds
diff options
context:
space:
mode:
Diffstat (limited to 'cmds')
-rw-r--r--cmds/am/src/com/android/commands/am/Am.java206
-rw-r--r--cmds/app_process/Android.mk31
-rw-r--r--cmds/app_process/app_main.cpp6
-rw-r--r--cmds/backup/Android.mk2
-rw-r--r--cmds/backup/backup.cpp16
-rw-r--r--cmds/bootanimation/Android.mk20
-rw-r--r--cmds/bootanimation/AudioPlayer.cpp11
-rw-r--r--cmds/bootanimation/AudioPlayer.h5
-rw-r--r--cmds/bootanimation/BootAnimation.cpp28
-rw-r--r--cmds/bootanimation/bootanimation_main.cpp14
-rw-r--r--cmds/content/src/com/android/commands/content/Content.java26
-rw-r--r--cmds/dpm/src/com/android/commands/dpm/Dpm.java18
-rw-r--r--cmds/idmap/Android.mk2
-rw-r--r--cmds/idmap/create.cpp11
-rw-r--r--cmds/idmap/inspect.cpp6
-rw-r--r--cmds/idmap/scan.cpp40
-rwxr-xr-xcmds/input/input2
-rw-r--r--cmds/interrupter/Android.mk4
-rw-r--r--cmds/media/src/com/android/commands/media/Media.java1
-rw-r--r--cmds/pm/src/com/android/commands/pm/Pm.java6
-rw-r--r--cmds/screencap/Android.mk12
-rw-r--r--cmds/screencap/screencap.cpp46
-rw-r--r--cmds/settings/src/com/android/commands/settings/SettingsCmd.java74
-rw-r--r--cmds/svc/src/com/android/commands/svc/DataCommand.java2
-rw-r--r--cmds/svc/src/com/android/commands/svc/WifiCommand.java2
-rw-r--r--cmds/uiautomator/library/Android.mk1
26 files changed, 417 insertions, 175 deletions
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java
index 2ea1d4d4f1d4..29ba1d7a146f 100644
--- a/cmds/am/src/com/android/commands/am/Am.java
+++ b/cmds/am/src/com/android/commands/am/Am.java
@@ -44,7 +44,6 @@ import android.net.Uri;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
-import android.os.IBinder;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.os.SELinux;
@@ -118,6 +117,8 @@ public class Am extends BaseCommand {
" am dumpheap [--user <USER_ID> current] [-n] <PROCESS> <FILE>\n" +
" am set-debug-app [-w] [--persistent] <PACKAGE>\n" +
" am clear-debug-app\n" +
+ " am set-watch-heap <PROCESS> <MEM-LIMIT>\n" +
+ " am clear-watch-heap\n" +
" am monitor [--gdb <port>]\n" +
" am hang [--allow-restart]\n" +
" am restart\n" +
@@ -132,10 +133,13 @@ public class Am extends BaseCommand {
" am stack start <DISPLAY_ID> <INTENT>\n" +
" am stack movetask <TASK_ID> <STACK_ID> [true|false]\n" +
" am stack resize <STACK_ID> <LEFT,TOP,RIGHT,BOTTOM>\n" +
+ " am stack split <STACK_ID> <v|h> [INTENT]\n" +
" am stack list\n" +
" am stack info <STACK_ID>\n" +
- " am lock-task <TASK_ID>\n" +
- " am lock-task stop\n" +
+ " am task lock <TASK_ID>\n" +
+ " am task lock stop\n" +
+ " am task resizeable <TASK_ID> [true|false]\n" +
+ " am task resize <TASK_ID> <LEFT,TOP,RIGHT,BOTTOM>\n" +
" am get-config\n" +
"\n" +
"am start: start an Activity. Options are:\n" +
@@ -209,6 +213,11 @@ public class Am extends BaseCommand {
"\n" +
"am clear-debug-app: clear the previously set-debug-app.\n" +
"\n" +
+ "am set-watch-heap: start monitoring pss size of <PROCESS>, if it is at or\n" +
+ " above <HEAP-LIMIT> then a heap dump is collected for the user to report\n" +
+ "\n" +
+ "am clear-watch-heap: clear the previously set-watch-heap.\n" +
+ "\n" +
"am bug-report: request bug report generation; will launch UI\n" +
" when done to select where it should be delivered.\n" +
"\n" +
@@ -244,13 +253,28 @@ public class Am extends BaseCommand {
"am stack movetask: move <TASK_ID> from its current stack to the top (true) or" +
" bottom (false) of <STACK_ID>.\n" +
"\n" +
- "am stack resize: change <STACK_ID> size and position to <LEFT,TOP,RIGHT,BOTTOM>.\n" +
+ "am stack resize: change <STACK_ID> size and position to <LEFT,TOP,RIGHT,BOTTOM>" +
+ ".\n" +
+ "\n" +
+ "am stack split: split <STACK_ID> into 2 stacks <v>ertically or <h>orizontally\n" +
+ " starting the new stack with [INTENT] if specified. If [INTENT] isn't\n" +
+ " specified and the current stack has more than one task, then the top task\n" +
+ " of the current task will be moved to the new stack. Command will also force\n" +
+ " all current tasks in both stacks to be resizeable.\n" +
"\n" +
"am stack list: list all of the activity stacks and their sizes.\n" +
"\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" +
+ "am task lock: bring <TASK_ID> to the front and don't allow other tasks to run\n" +
+ "\n" +
+ "am task lock stop: end the current task lock\n" +
+ "\n" +
+ "am task resizeable: change if <TASK_ID> is resizeable (true) or not (false).\n" +
+ "\n" +
+ "am task resize: makes sure <TASK_ID> is in a stack with the specified bounds.\n" +
+ " Forces the task to be resizeable and creates a stack if no existing stack\n" +
+ " has the specified bounds.\n" +
"\n" +
"am get-config: retrieve the configuration and any recent configurations\n" +
" of the device\n" +
@@ -325,6 +349,10 @@ public class Am extends BaseCommand {
runSetDebugApp();
} else if (op.equals("clear-debug-app")) {
runClearDebugApp();
+ } else if (op.equals("set-watch-heap")) {
+ runSetWatchHeap();
+ } else if (op.equals("clear-watch-heap")) {
+ runClearWatchHeap();
} else if (op.equals("bug-report")) {
runBugReport();
} else if (op.equals("monitor")) {
@@ -351,8 +379,8 @@ public class Am extends BaseCommand {
runStopUser();
} else if (op.equals("stack")) {
runStack();
- } else if (op.equals("lock-task")) {
- runLockTask();
+ } else if (op.equals("task")) {
+ runTask();
} else if (op.equals("get-config")) {
runGetConfig();
} else {
@@ -1155,6 +1183,17 @@ public class Am extends BaseCommand {
mAm.setDebugApp(null, false, true);
}
+ private void runSetWatchHeap() throws Exception {
+ String proc = nextArgRequired();
+ String limit = nextArgRequired();
+ mAm.setDumpHeapDebugLimit(proc, Long.parseLong(limit));
+ }
+
+ private void runClearWatchHeap() throws Exception {
+ String proc = nextArgRequired();
+ mAm.setDumpHeapDebugLimit(proc, -1);
+ }
+
private void runBugReport() throws Exception {
mAm.requestBugReport();
System.out.println("Your lovely bug report is being created; please be patient.");
@@ -1682,6 +1721,8 @@ public class Am extends BaseCommand {
runStackList();
} else if (op.equals("info")) {
runStackInfo();
+ } else if (op.equals("split")) {
+ runStackSplit();
} else {
showError("Error: unknown command '" + op + "'");
return;
@@ -1694,10 +1735,10 @@ public class Am extends BaseCommand {
Intent intent = makeIntent(UserHandle.USER_CURRENT);
try {
- IBinder homeActivityToken = mAm.getHomeActivityToken();
- IActivityContainer container = mAm.createActivityContainer(homeActivityToken, null);
- container.attachToDisplay(displayId);
- container.startActivity(intent);
+ IActivityContainer container = mAm.createStackOnDisplay(displayId);
+ if (container != null) {
+ container.startActivity(intent);
+ }
} catch (RemoteException e) {
}
}
@@ -1727,17 +1768,14 @@ public class Am extends BaseCommand {
private void runStackResize() throws Exception {
String stackIdStr = nextArgRequired();
int stackId = Integer.valueOf(stackIdStr);
- String leftStr = nextArgRequired();
- int left = Integer.valueOf(leftStr);
- String topStr = nextArgRequired();
- int top = Integer.valueOf(topStr);
- String rightStr = nextArgRequired();
- int right = Integer.valueOf(rightStr);
- String bottomStr = nextArgRequired();
- int bottom = Integer.valueOf(bottomStr);
+ final Rect bounds = getBounds();
+ if (bounds == null) {
+ System.err.println("Error: invalid input bounds");
+ return;
+ }
try {
- mAm.resizeStack(stackId, new Rect(left, top, right, bottom));
+ mAm.resizeStack(stackId, bounds);
} catch (RemoteException e) {
}
}
@@ -1762,7 +1800,79 @@ public class Am extends BaseCommand {
}
}
- private void runLockTask() throws Exception {
+ private void runStackSplit() throws Exception {
+ final int stackId = Integer.valueOf(nextArgRequired());
+ final String splitDirection = nextArgRequired();
+ Intent intent = null;
+ try {
+ intent = makeIntent(UserHandle.USER_CURRENT);
+ } catch (IllegalArgumentException e) {
+ // no intent supplied.
+ }
+
+ try {
+ final StackInfo currentStackInfo = mAm.getStackInfo(stackId);
+ // Calculate bounds for new and current stack.
+ final Rect currentStackBounds = new Rect(currentStackInfo.bounds);
+ final Rect newStackBounds = new Rect(currentStackInfo.bounds);
+ if ("v".equals(splitDirection)) {
+ currentStackBounds.right = newStackBounds.left = currentStackInfo.bounds.centerX();
+ } else if ("h".equals(splitDirection)) {
+ currentStackBounds.bottom = newStackBounds.top = currentStackInfo.bounds.centerY();
+ } else {
+ showError("Error: unknown split direction '" + splitDirection + "'");
+ return;
+ }
+
+ // Create new stack
+ IActivityContainer container = mAm.createStackOnDisplay(currentStackInfo.displayId);
+ if (container == null) {
+ showError("Error: Unable to create new stack...");
+ }
+
+ final int newStackId = container.getStackId();
+
+ if (intent != null) {
+ container.startActivity(intent);
+ } else if (currentStackInfo.taskIds != null && currentStackInfo.taskIds.length > 1) {
+ // Move top task over to new stack
+ mAm.moveTaskToStack(currentStackInfo.taskIds[currentStackInfo.taskIds.length - 1],
+ newStackId, true);
+ }
+
+ final StackInfo newStackInfo = mAm.getStackInfo(newStackId);
+
+ // Make all tasks in the stacks resizeable.
+ for (int taskId : currentStackInfo.taskIds) {
+ mAm.setTaskResizeable(taskId, true);
+ }
+
+ for (int taskId : newStackInfo.taskIds) {
+ mAm.setTaskResizeable(taskId, true);
+ }
+
+ // Resize stacks
+ mAm.resizeStack(currentStackInfo.stackId, currentStackBounds);
+ mAm.resizeStack(newStackInfo.stackId, newStackBounds);
+ } catch (RemoteException e) {
+ }
+ }
+
+ private void runTask() throws Exception {
+ String op = nextArgRequired();
+ if (op.equals("lock")) {
+ runTaskLock();
+ } else if (op.equals("resizeable")) {
+ runTaskResizeable();
+ } else if (op.equals("resize")) {
+ runTaskResize();
+ } else {
+ showError("Error: unknown command '" + op + "'");
+ return;
+ }
+ }
+
+ private void runTaskLock() throws Exception {
String taskIdStr = nextArgRequired();
try {
if (taskIdStr.equals("stop")) {
@@ -1777,6 +1887,32 @@ public class Am extends BaseCommand {
}
}
+ private void runTaskResizeable() throws Exception {
+ final String taskIdStr = nextArgRequired();
+ final int taskId = Integer.valueOf(taskIdStr);
+ final String resizeableStr = nextArgRequired();
+ final boolean resizeable = Boolean.valueOf(resizeableStr);
+
+ try {
+ mAm.setTaskResizeable(taskId, resizeable);
+ } catch (RemoteException e) {
+ }
+ }
+
+ private void runTaskResize() throws Exception {
+ final String taskIdStr = nextArgRequired();
+ final int taskId = Integer.valueOf(taskIdStr);
+ final Rect bounds = getBounds();
+ if (bounds == null) {
+ System.err.println("Error: invalid input bounds");
+ return;
+ }
+ try {
+ mAm.resizeTask(taskId, bounds);
+ } catch (RemoteException e) {
+ }
+ }
+
private List<Configuration> getRecentConfigurations(int days) {
IUsageStatsManager usm = IUsageStatsManager.Stub.asInterface(ServiceManager.getService(
Context.USAGE_STATS_SERVICE));
@@ -1873,4 +2009,32 @@ public class Am extends BaseCommand {
}
return fd;
}
+
+ private Rect getBounds() {
+ String leftStr = nextArgRequired();
+ int left = Integer.valueOf(leftStr);
+ String topStr = nextArgRequired();
+ int top = Integer.valueOf(topStr);
+ String rightStr = nextArgRequired();
+ int right = Integer.valueOf(rightStr);
+ String bottomStr = nextArgRequired();
+ int bottom = Integer.valueOf(bottomStr);
+ if (left < 0) {
+ System.err.println("Error: bad left arg: " + leftStr);
+ return null;
+ }
+ if (top < 0) {
+ System.err.println("Error: bad top arg: " + topStr);
+ return null;
+ }
+ if (right <= 0) {
+ System.err.println("Error: bad right arg: " + rightStr);
+ return null;
+ }
+ if (bottom <= 0) {
+ System.err.println("Error: bad bottom arg: " + bottomStr);
+ return null;
+ }
+ return new Rect(left, top, right, bottom);
+ }
}
diff --git a/cmds/app_process/Android.mk b/cmds/app_process/Android.mk
index 397a7d1649e9..dd5e0ea51bb1 100644
--- a/cmds/app_process/Android.mk
+++ b/cmds/app_process/Android.mk
@@ -3,17 +3,17 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
- app_main.cpp
+ app_main.cpp
LOCAL_LDFLAGS := -Wl,--version-script,art/sigchainlib/version-script.txt -Wl,--export-dynamic
LOCAL_SHARED_LIBRARIES := \
- libdl \
- libcutils \
- libutils \
- liblog \
- libbinder \
- libandroid_runtime
+ libdl \
+ libcutils \
+ libutils \
+ liblog \
+ libbinder \
+ libandroid_runtime
LOCAL_WHOLE_STATIC_LIBRARIES := libsigchain
@@ -21,6 +21,9 @@ LOCAL_MODULE:= app_process
LOCAL_MULTILIB := both
LOCAL_MODULE_STEM_32 := app_process32
LOCAL_MODULE_STEM_64 := app_process64
+
+LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code
+
include $(BUILD_EXECUTABLE)
# Create a symlink from app_process to app_process32 or 64
@@ -34,14 +37,14 @@ ifeq ($(TARGET_ARCH),arm)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
- app_main.cpp
+ app_main.cpp
LOCAL_SHARED_LIBRARIES := \
- libcutils \
- libutils \
- liblog \
- libbinder \
- libandroid_runtime
+ libcutils \
+ libutils \
+ liblog \
+ libbinder \
+ libandroid_runtime
LOCAL_WHOLE_STATIC_LIBRARIES := libsigchain
@@ -54,6 +57,8 @@ LOCAL_MODULE_PATH := $(TARGET_OUT_EXECUTABLES)/asan
LOCAL_MODULE_STEM := app_process
LOCAL_ADDRESS_SANITIZER := true
+LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code
+
include $(BUILD_EXECUTABLE)
endif # ifeq($(TARGET_ARCH),arm)
diff --git a/cmds/app_process/app_main.cpp b/cmds/app_process/app_main.cpp
index 1bb28c38ceef..c86fd5398dc3 100644
--- a/cmds/app_process/app_main.cpp
+++ b/cmds/app_process/app_main.cpp
@@ -24,7 +24,7 @@
namespace android {
-void app_usage()
+static void app_usage()
{
fprintf(stderr,
"Usage: app_process [java-options] cmd-dir start-class-name [options]\n");
@@ -146,8 +146,10 @@ static void maybeCreateDalvikCache() {
static const char kInstructionSet[] = "arm";
#elif defined(__i386__)
static const char kInstructionSet[] = "x86";
-#elif defined (__mips__)
+#elif defined (__mips__) && !defined(__LP64__)
static const char kInstructionSet[] = "mips";
+#elif defined (__mips__) && defined(__LP64__)
+ static const char kInstructionSet[] = "mips64";
#else
#error "Unknown instruction set"
#endif
diff --git a/cmds/backup/Android.mk b/cmds/backup/Android.mk
index 42e513345d9c..8e1508c9efe8 100644
--- a/cmds/backup/Android.mk
+++ b/cmds/backup/Android.mk
@@ -12,4 +12,6 @@ LOCAL_MODULE:= btool
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
LOCAL_MODULE_TAGS := optional
+LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code
+
include $(BUILD_EXECUTABLE)
diff --git a/cmds/backup/backup.cpp b/cmds/backup/backup.cpp
index ea1888beea2a..8d9b528ae6a9 100644
--- a/cmds/backup/backup.cpp
+++ b/cmds/backup/backup.cpp
@@ -25,8 +25,7 @@ using namespace android;
#include <unistd.h>
-int
-usage(int argc, const char** argv)
+static int usage(int /* argc */, const char** argv)
{
const char* p = argv[0];
@@ -44,15 +43,13 @@ usage(int argc, const char** argv)
return 1;
}
-int
-perform_full_backup()
+static int perform_full_backup()
{
printf("this would have written all of your data to stdout\n");
return 0;
}
-int
-perform_list(const char* filename)
+static int perform_list(const char* filename)
{
int err;
int fd;
@@ -78,7 +75,7 @@ perform_list(const char* filename)
size_t dataSize;
err = reader.ReadEntityHeader(&key, &dataSize);
if (err == 0) {
- printf(" entity: %s (%d bytes)\n", key.string(), dataSize);
+ printf(" entity: %s (%zu bytes)\n", key.string(), dataSize);
} else {
printf(" Error reading entity header\n");
}
@@ -95,14 +92,13 @@ perform_list(const char* filename)
return 0;
}
-int perform_print(const char* entityname, const char* filename)
+static int perform_print(const char* entityname, const char* filename)
{
printf("perform_print(%s, %s);", entityname, filename);
return 0;
}
-int
-main(int argc, const char** argv)
+int main(int argc, const char** argv)
{
if (argc <= 1) {
return perform_full_backup();
diff --git a/cmds/bootanimation/Android.mk b/cmds/bootanimation/Android.mk
index d6ecbe31f5e8..2ee586f2c3ca 100644
--- a/cmds/bootanimation/Android.mk
+++ b/cmds/bootanimation/Android.mk
@@ -2,22 +2,24 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
- bootanimation_main.cpp \
- AudioPlayer.cpp \
- BootAnimation.cpp
+ bootanimation_main.cpp \
+ AudioPlayer.cpp \
+ BootAnimation.cpp
LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
+LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code
+
LOCAL_C_INCLUDES += external/tinyalsa/include
LOCAL_SHARED_LIBRARIES := \
- libcutils \
- liblog \
- libandroidfw \
- libutils \
- libbinder \
+ libcutils \
+ liblog \
+ libandroidfw \
+ libutils \
+ libbinder \
libui \
- libskia \
+ libskia \
libEGL \
libGLESv1_CM \
libgui \
diff --git a/cmds/bootanimation/AudioPlayer.cpp b/cmds/bootanimation/AudioPlayer.cpp
index 471b77f227de..293213008d58 100644
--- a/cmds/bootanimation/AudioPlayer.cpp
+++ b/cmds/bootanimation/AudioPlayer.cpp
@@ -98,16 +98,16 @@ static bool setMixerValue(struct mixer* mixer, const char* name, const char* val
ALOGE("mixer_ctl_set_value failed for %s %d", name, intValue);
}
} else {
- ALOGE("Could not parse %s as int for %d", intValue, name);
+ ALOGE("Could not parse %s as int for %s", values, name);
}
break;
case MIXER_CTL_TYPE_ENUM:
if (sscanf(values, "%s", stringValue) == 1) {
if (mixer_ctl_set_enum_by_string(ctl, stringValue) != 0) {
- ALOGE("mixer_ctl_set_enum_by_string failed for %s %%s", name, stringValue);
+ ALOGE("mixer_ctl_set_enum_by_string failed for %s %s", name, stringValue);
}
} else {
- ALOGE("Could not parse %s as enum for %d", stringValue, name);
+ ALOGE("Could not parse %s as enum for %s", values, name);
}
break;
default:
@@ -193,7 +193,7 @@ bool AudioPlayer::init(const char* config)
return false;
}
-void AudioPlayer::playFile(struct FileMap* fileMap) {
+void AudioPlayer::playFile(FileMap* fileMap) {
// stop any currently playing sound
requestExitAndWait();
@@ -207,7 +207,6 @@ bool AudioPlayer::threadLoop()
struct pcm *pcm = NULL;
bool moreChunks = true;
const struct chunk_fmt* chunkFmt = NULL;
- void* buffer = NULL;
int bufferSize;
const uint8_t* wavData;
size_t wavLength;
@@ -306,7 +305,7 @@ bool AudioPlayer::threadLoop()
exit:
if (pcm)
pcm_close(pcm);
- mCurrentFile->release();
+ delete mCurrentFile;
mCurrentFile = NULL;
return false;
}
diff --git a/cmds/bootanimation/AudioPlayer.h b/cmds/bootanimation/AudioPlayer.h
index 7e82a07bc660..1def0aeac8d1 100644
--- a/cmds/bootanimation/AudioPlayer.h
+++ b/cmds/bootanimation/AudioPlayer.h
@@ -18,6 +18,7 @@
#define _BOOTANIMATION_AUDIOPLAYER_H
#include <utils/Thread.h>
+#include <utils/FileMap.h>
namespace android {
@@ -28,7 +29,7 @@ public:
virtual ~AudioPlayer();
bool init(const char* config);
- void playFile(struct FileMap* fileMap);
+ void playFile(FileMap* fileMap);
private:
virtual bool threadLoop();
@@ -39,7 +40,7 @@ private:
int mPeriodSize;
int mPeriodCount;
- struct FileMap* mCurrentFile;
+ FileMap* mCurrentFile;
};
} // namespace android
diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp
index b2474f2f18bc..bb25ec6d12d3 100644
--- a/cmds/bootanimation/BootAnimation.cpp
+++ b/cmds/bootanimation/BootAnimation.cpp
@@ -23,6 +23,7 @@
#include <fcntl.h>
#include <utils/misc.h>
#include <signal.h>
+#include <time.h>
#include <cutils/properties.h>
@@ -41,9 +42,13 @@
#include <gui/Surface.h>
#include <gui/SurfaceComposerClient.h>
+// TODO: Fix Skia.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
#include <SkBitmap.h>
#include <SkStream.h>
#include <SkImageDecoder.h>
+#pragma GCC diagnostic pop
#include <GLES/gl.h>
#include <GLES/glext.h>
@@ -57,10 +62,6 @@
#define SYSTEM_ENCRYPTED_BOOTANIMATION_FILE "/system/media/bootanimation-encrypted.zip"
#define EXIT_PROP_NAME "service.bootanim.exit"
-extern "C" int clock_nanosleep(clockid_t clock_id, int flags,
- const struct timespec *request,
- struct timespec *remain);
-
namespace android {
static const int ANIM_ENTRY_NAME_MAX = 256;
@@ -108,7 +109,7 @@ void BootAnimation::binderDied(const wp<IBinder>&)
status_t BootAnimation::initTexture(Texture* texture, AssetManager& assets,
const char* name) {
Asset* asset = assets.open(name, Asset::ACCESS_BUFFER);
- if (!asset)
+ if (asset == NULL)
return NO_INIT;
SkBitmap bitmap;
SkImageDecoder::DecodeMemory(asset->getBuffer(false), asset->getLength(),
@@ -167,7 +168,7 @@ status_t BootAnimation::initTexture(const Animation::Frame& frame)
SkBitmap bitmap;
SkMemoryStream stream(frame.map->getDataPtr(), frame.map->getDataLength());
SkImageDecoder* codec = SkImageDecoder::Factory(&stream);
- if (codec) {
+ if (codec != NULL) {
codec->setDitherImage(false);
codec->decode(&stream, &bitmap,
kN32_SkColorType,
@@ -178,7 +179,7 @@ status_t BootAnimation::initTexture(const Animation::Frame& frame)
// FileMap memory is never released until application exit.
// Release it now as the texture is already loaded and the memory used for
// the packed resource can be released.
- frame.map->release();
+ delete frame.map;
// ensure we can call getPixels(). No need to call unlock, since the
// bitmap will go out of scope when we return from this method.
@@ -255,7 +256,7 @@ status_t BootAnimation::readyToRun() {
EGL_DEPTH_SIZE, 0,
EGL_NONE
};
- EGLint w, h, dummy;
+ EGLint w, h;
EGLint numConfigs;
EGLConfig config;
EGLSurface surface;
@@ -445,7 +446,7 @@ bool BootAnimation::readFile(const char* name, String8& outString)
}
outString.setTo((char const*)entryMap->getDataPtr(), entryMap->getDataLength());
- entryMap->release();
+ delete entryMap;
return true;
}
@@ -473,7 +474,7 @@ bool BootAnimation::movie()
// Parse the description file
for (;;) {
const char* endl = strstr(s, "\n");
- if (!endl) break;
+ if (endl == NULL) break;
String8 line(s, endl - s);
const char* l = line.string();
int fps, width, height, count, pause;
@@ -575,7 +576,6 @@ bool BootAnimation::movie()
const int xc = (mWidth - animation.width) / 2;
const int yc = ((mHeight - animation.height) / 2);
- nsecs_t lastFrame = systemTime();
nsecs_t frameDuration = s2ns(1) / animation.fps;
Region clearReg(Rect(mWidth, mHeight));
@@ -623,9 +623,9 @@ bool BootAnimation::movie()
Region::const_iterator tail(clearReg.end());
glEnable(GL_SCISSOR_TEST);
while (head != tail) {
- const Rect& r(*head++);
- glScissor(r.left, mHeight - r.bottom,
- r.width(), r.height());
+ const Rect& r2(*head++);
+ glScissor(r2.left, mHeight - r2.bottom,
+ r2.width(), r2.height());
glClear(GL_COLOR_BUFFER_BIT);
}
glDisable(GL_SCISSOR_TEST);
diff --git a/cmds/bootanimation/bootanimation_main.cpp b/cmds/bootanimation/bootanimation_main.cpp
index 417e138b7041..48a34e7dbf62 100644
--- a/cmds/bootanimation/bootanimation_main.cpp
+++ b/cmds/bootanimation/bootanimation_main.cpp
@@ -16,31 +16,23 @@
#define LOG_TAG "BootAnimation"
-#include <cutils/properties.h>
-
#include <binder/IPCThreadState.h>
#include <binder/ProcessState.h>
#include <binder/IServiceManager.h>
-
+#include <cutils/properties.h>
+#include <sys/resource.h>
#include <utils/Log.h>
#include <utils/threads.h>
-#if defined(HAVE_PTHREADS)
-# include <pthread.h>
-# include <sys/resource.h>
-#endif
-
#include "BootAnimation.h"
using namespace android;
// ---------------------------------------------------------------------------
-int main(int argc, char** argv)
+int main()
{
-#if defined(HAVE_PTHREADS)
setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_DISPLAY);
-#endif
char value[PROPERTY_VALUE_MAX];
property_get("debug.sf.nobootanimation", value, "0");
diff --git a/cmds/content/src/com/android/commands/content/Content.java b/cmds/content/src/com/android/commands/content/Content.java
index bd34a9c2ed4b..c0ed8935dc2c 100644
--- a/cmds/content/src/com/android/commands/content/Content.java
+++ b/cmds/content/src/com/android/commands/content/Content.java
@@ -27,6 +27,7 @@ import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
import android.os.ParcelFileDescriptor;
+import android.os.Process;
import android.os.UserHandle;
import android.text.TextUtils;
@@ -426,6 +427,22 @@ public class Content {
}
}
+ public static String resolveCallingPackage() {
+ switch (Process.myUid()) {
+ case Process.ROOT_UID: {
+ return "root";
+ }
+
+ case Process.SHELL_UID: {
+ return "com.android.shell";
+ }
+
+ default: {
+ return null;
+ }
+ }
+ }
+
protected abstract void onExecute(IContentProvider provider) throws Exception;
}
@@ -439,7 +456,7 @@ public class Content {
@Override
public void onExecute(IContentProvider provider) throws Exception {
- provider.insert(null, mUri, mContentValues);
+ provider.insert(resolveCallingPackage(), mUri, mContentValues);
}
}
@@ -453,7 +470,7 @@ public class Content {
@Override
public void onExecute(IContentProvider provider) throws Exception {
- provider.delete(null, mUri, mWhere, null);
+ provider.delete(resolveCallingPackage(), mUri, mWhere, null);
}
}
@@ -532,7 +549,8 @@ public class Content {
@Override
public void onExecute(IContentProvider provider) throws Exception {
- Cursor cursor = provider.query(null, mUri, mProjection, mWhere, null, mSortOrder, null);
+ Cursor cursor = provider.query(resolveCallingPackage(), mUri, mProjection, mWhere,
+ null, mSortOrder, null);
if (cursor == null) {
System.out.println("No result found.");
return;
@@ -594,7 +612,7 @@ public class Content {
@Override
public void onExecute(IContentProvider provider) throws Exception {
- provider.update(null, mUri, mContentValues, mWhere, null);
+ provider.update(resolveCallingPackage(), mUri, mContentValues, mWhere, null);
}
}
diff --git a/cmds/dpm/src/com/android/commands/dpm/Dpm.java b/cmds/dpm/src/com/android/commands/dpm/Dpm.java
index 781fb965e08a..3d86ac1fa59f 100644
--- a/cmds/dpm/src/com/android/commands/dpm/Dpm.java
+++ b/cmds/dpm/src/com/android/commands/dpm/Dpm.java
@@ -52,7 +52,7 @@ public final class Dpm extends BaseCommand {
"usage: dpm [subcommand] [options]\n" +
"usage: dpm set-active-admin [ --user <USER_ID> ] <COMPONENT>\n" +
"usage: dpm set-device-owner <COMPONENT>\n" +
- "usage: dpm set-profile-owner <COMPONENT> <USER_ID>\n" +
+ "usage: dpm set-profile-owner [ --user <USER_ID> ] <COMPONENT>\n" +
"\n" +
"dpm set-active-admin: Sets the given component as active admin" +
" for an existing user.\n" +
@@ -125,23 +125,21 @@ public final class Dpm extends BaseCommand {
}
private void runSetProfileOwner() throws RemoteException {
- // To be refactored later to use parseArgs(boolean). Currently in use by existing tests.
- ComponentName component = parseComponentName(nextArgRequired());
- int userId = parseInt(nextArgRequired());
- mDevicePolicyManager.setActiveAdmin(component, true /*refreshing*/, userId);
+ parseArgs(true);
+ mDevicePolicyManager.setActiveAdmin(mComponent, true /*refreshing*/, mUserId);
try {
- if (!mDevicePolicyManager.setProfileOwner(component, "" /*ownerName*/, userId)) {
- throw new RuntimeException("Can't set component " + component.toShortString() +
- " as profile owner for user " + userId);
+ if (!mDevicePolicyManager.setProfileOwner(mComponent, "" /*ownerName*/, mUserId)) {
+ throw new RuntimeException("Can't set component " + mComponent.toShortString() +
+ " as profile owner for user " + mUserId);
}
} catch (Exception e) {
// Need to remove the admin that we just added.
- mDevicePolicyManager.removeActiveAdmin(component, userId);
+ mDevicePolicyManager.removeActiveAdmin(mComponent, mUserId);
throw e;
}
System.out.println("Success: Active admin and profile owner set to "
- + component.toShortString() + " for user " + userId);
+ + mComponent.toShortString() + " for user " + mUserId);
}
private ComponentName parseComponentName(String component) {
diff --git a/cmds/idmap/Android.mk b/cmds/idmap/Android.mk
index ffa83f2ba428..50ccb07a3826 100644
--- a/cmds/idmap/Android.mk
+++ b/cmds/idmap/Android.mk
@@ -25,4 +25,6 @@ LOCAL_C_INCLUDES := external/zlib
LOCAL_MODULE_TAGS := optional
+LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code
+
include $(BUILD_EXECUTABLE)
diff --git a/cmds/idmap/create.cpp b/cmds/idmap/create.cpp
index 593a1973669a..16532b8c901d 100644
--- a/cmds/idmap/create.cpp
+++ b/cmds/idmap/create.cpp
@@ -7,6 +7,7 @@
#include <utils/String8.h>
#include <fcntl.h>
+#include <sys/file.h>
#include <sys/stat.h>
using namespace android;
@@ -22,7 +23,7 @@ namespace {
if (entry == NULL) {
return -1;
}
- if (!zip->getEntryInfo(entry, NULL, NULL, NULL, NULL, NULL, (long*)crc)) {
+ if (!zip->getEntryInfo(entry, NULL, NULL, NULL, NULL, NULL, reinterpret_cast<long*>(crc))) {
return -1;
}
zip->releaseEntry(entry);
@@ -66,7 +67,7 @@ fail:
fprintf(stderr, "error: write: %s\n", strerror(errno));
return -1;
}
- bytesLeft -= w;
+ bytesLeft -= static_cast<size_t>(w);
}
return 0;
}
@@ -78,13 +79,13 @@ fail:
if (fstat(idmap_fd, &st) == -1) {
return true;
}
- if (st.st_size < N) {
+ if (st.st_size < static_cast<off_t>(N)) {
// file is empty or corrupt
return true;
}
char buf[N];
- ssize_t bytesLeft = N;
+ size_t bytesLeft = N;
if (lseek(idmap_fd, SEEK_SET, 0) < 0) {
return true;
}
@@ -93,7 +94,7 @@ fail:
if (r < 0) {
return true;
}
- bytesLeft -= r;
+ bytesLeft -= static_cast<size_t>(r);
if (bytesLeft == 0) {
break;
}
diff --git a/cmds/idmap/inspect.cpp b/cmds/idmap/inspect.cpp
index b9ac8a59de02..f6afc8594309 100644
--- a/cmds/idmap/inspect.cpp
+++ b/cmds/idmap/inspect.cpp
@@ -152,13 +152,13 @@ namespace {
printe("failed to get resource name id=0x%08x\n", res_id);
return UNKNOWN_ERROR;
}
- if (package) {
+ if (package != NULL) {
*package = String8(String16(data.package, data.packageLen));
}
- if (type) {
+ if (type != NULL) {
*type = String8(String16(data.type, data.typeLen));
}
- if (name) {
+ if (name != NULL) {
*name = String8(String16(data.name, data.nameLen));
}
return NO_ERROR;
diff --git a/cmds/idmap/scan.cpp b/cmds/idmap/scan.cpp
index 1153f38a9c02..197e36bd97af 100644
--- a/cmds/idmap/scan.cpp
+++ b/cmds/idmap/scan.cpp
@@ -64,30 +64,6 @@ namespace {
return String8(tmp);
}
- int mkdir_p(const String8& path, uid_t uid, gid_t gid)
- {
- static const mode_t mode =
- S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IXOTH;
- struct stat st;
-
- if (stat(path.string(), &st) == 0) {
- return 0;
- }
- if (mkdir_p(path.getPathDir(), uid, gid) < 0) {
- return -1;
- }
- if (mkdir(path.string(), 0755) != 0) {
- return -1;
- }
- if (chown(path.string(), uid, gid) == -1) {
- return -1;
- }
- if (chmod(path.string(), mode) == -1) {
- return -1;
- }
- return 0;
- }
-
int parse_overlay_tag(const ResXMLTree& parser, const char *target_package_name)
{
const size_t N = parser.getAttributeCount();
@@ -97,8 +73,8 @@ namespace {
size_t len;
String16 key(parser.getAttributeName(i, &len));
if (key == String16("targetPackage")) {
- const uint16_t *p = parser.getAttributeStringValue(i, &len);
- if (p) {
+ const char16_t *p = parser.getAttributeStringValue(i, &len);
+ if (p != NULL) {
target = String16(p, len);
}
} else if (key == String16("priority")) {
@@ -164,27 +140,27 @@ namespace {
return -1;
}
FileMap *dataMap = zip->createEntryFileMap(entry);
- if (!dataMap) {
+ if (dataMap == NULL) {
ALOGW("%s: failed to create FileMap\n", __FUNCTION__);
return -1;
}
char *buf = new char[uncompLen];
if (NULL == buf) {
- ALOGW("%s: failed to allocate %d byte\n", __FUNCTION__, uncompLen);
- dataMap->release();
+ ALOGW("%s: failed to allocate %zd byte\n", __FUNCTION__, uncompLen);
+ delete dataMap;
return -1;
}
StreamingZipInflater inflater(dataMap, uncompLen);
if (inflater.read(buf, uncompLen) < 0) {
- ALOGW("%s: failed to inflate %d byte\n", __FUNCTION__, uncompLen);
+ ALOGW("%s: failed to inflate %zd byte\n", __FUNCTION__, uncompLen);
delete[] buf;
- dataMap->release();
+ delete dataMap;
return -1;
}
int priority = parse_manifest(buf, uncompLen, target_package_name);
delete[] buf;
- dataMap->release();
+ delete dataMap;
return priority;
}
}
diff --git a/cmds/input/input b/cmds/input/input
index fa9dced0482d..7f1a18e369c6 100755
--- a/cmds/input/input
+++ b/cmds/input/input
@@ -3,5 +3,5 @@
#
base=/system
export CLASSPATH=$base/framework/input.jar
-exec app_process $base/bin com.android.commands.input.Input $*
+exec app_process $base/bin com.android.commands.input.Input "$@"
diff --git a/cmds/interrupter/Android.mk b/cmds/interrupter/Android.mk
index e324627517ec..97a96bfc8e25 100644
--- a/cmds/interrupter/Android.mk
+++ b/cmds/interrupter/Android.mk
@@ -7,6 +7,7 @@ LOCAL_SRC_FILES := \
LOCAL_MODULE := interrupter
LOCAL_MODULE_TAGS := eng tests
LOCAL_LDFLAGS := -ldl
+LOCAL_CFLAGS := -Wall -Werror -Wunused -Wunreachable-code
include $(BUILD_SHARED_LIBRARY)
@@ -17,5 +18,6 @@ LOCAL_SRC_FILES := \
LOCAL_MODULE := interrupter
LOCAL_MODULE_TAGS := eng tests
LOCAL_LDFLAGS := -ldl
+LOCAL_CFLAGS := -Wall -Werror -Wunused -Wunreachable-code
-include $(BUILD_HOST_SHARED_LIBRARY) \ No newline at end of file
+include $(BUILD_HOST_SHARED_LIBRARY)
diff --git a/cmds/media/src/com/android/commands/media/Media.java b/cmds/media/src/com/android/commands/media/Media.java
index 6a8fb05da98b..d7f23cb44098 100644
--- a/cmds/media/src/com/android/commands/media/Media.java
+++ b/cmds/media/src/com/android/commands/media/Media.java
@@ -24,7 +24,6 @@ import android.media.MediaMetadata;
import android.media.session.ISessionController;
import android.media.session.ISessionControllerCallback;
import android.media.session.ISessionManager;
-import android.media.session.MediaController;
import android.media.session.ParcelableVolumeInfo;
import android.media.session.PlaybackState;
import android.os.Bundle;
diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java
index 0a573ca9c734..c48a61817ed2 100644
--- a/cmds/pm/src/com/android/commands/pm/Pm.java
+++ b/cmds/pm/src/com/android/commands/pm/Pm.java
@@ -48,7 +48,6 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.IUserManager;
-import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
@@ -549,7 +548,10 @@ public final class Pm {
if (res != 0) {
Resources r = getResources(pii);
if (r != null) {
- return r.getString(res);
+ try {
+ return r.getString(res);
+ } catch (Resources.NotFoundException e) {
+ }
}
}
return null;
diff --git a/cmds/screencap/Android.mk b/cmds/screencap/Android.mk
index 5c11b7546f84..b0dc42250fae 100644
--- a/cmds/screencap/Android.mk
+++ b/cmds/screencap/Android.mk
@@ -2,13 +2,13 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
- screencap.cpp
+ screencap.cpp
LOCAL_SHARED_LIBRARIES := \
- libcutils \
- libutils \
- libbinder \
- libskia \
+ libcutils \
+ libutils \
+ libbinder \
+ libskia \
libui \
libgui
@@ -16,4 +16,6 @@ LOCAL_MODULE:= screencap
LOCAL_MODULE_TAGS := optional
+LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code
+
include $(BUILD_EXECUTABLE)
diff --git a/cmds/screencap/screencap.cpp b/cmds/screencap/screencap.cpp
index 6b2a0e2266b0..dbc35af2c22d 100644
--- a/cmds/screencap/screencap.cpp
+++ b/cmds/screencap/screencap.cpp
@@ -18,6 +18,8 @@
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
#include <linux/fb.h>
#include <sys/ioctl.h>
@@ -30,10 +32,12 @@
#include <ui/PixelFormat.h>
+// TODO: Fix Skia.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
#include <SkImageEncoder.h>
-#include <SkBitmap.h>
#include <SkData.h>
-#include <SkStream.h>
+#pragma GCC diagnostic pop
using namespace android;
@@ -86,6 +90,21 @@ static status_t vinfoToPixelFormat(const fb_var_screeninfo& vinfo,
return NO_ERROR;
}
+static status_t notifyMediaScanner(const char* fileName) {
+ String8 cmd("am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file://");
+ String8 fileUrl("\"");
+ fileUrl.append(fileName);
+ fileUrl.append("\"");
+ cmd.append(fileName);
+ cmd.append(" > /dev/null");
+ int result = system(cmd.string());
+ if (result < 0) {
+ fprintf(stderr, "Unable to broadcast intent for media scanner.\n");
+ return UNKNOWN_ERROR;
+ }
+ return NO_ERROR;
+}
+
int main(int argc, char** argv)
{
ProcessState::self()->startThreadPool();
@@ -112,10 +131,11 @@ int main(int argc, char** argv)
argv += optind;
int fd = -1;
+ const char* fn = NULL;
if (argc == 0) {
fd = dup(STDOUT_FILENO);
} else if (argc == 1) {
- const char* fn = argv[0];
+ fn = argv[0];
fd = open(fn, O_WRONLY | O_CREAT | O_TRUNC, 0664);
if (fd == -1) {
fprintf(stderr, "Error opening file: %s (%s)\n", fn, strerror(errno));
@@ -135,7 +155,7 @@ int main(int argc, char** argv)
void const* mapbase = MAP_FAILED;
ssize_t mapsize = -1;
- void const* base = 0;
+ void const* base = NULL;
uint32_t w, s, h, f;
size_t size = 0;
@@ -172,18 +192,18 @@ int main(int argc, char** argv)
}
}
- if (base) {
+ if (base != NULL) {
if (png) {
const SkImageInfo info = SkImageInfo::Make(w, h, flinger2skia(f),
kPremul_SkAlphaType);
- SkBitmap b;
- b.installPixels(info, const_cast<void*>(base), s*bytesPerPixel(f));
- SkDynamicMemoryWStream stream;
- SkImageEncoder::EncodeStream(&stream, b,
- SkImageEncoder::kPNG_Type, SkImageEncoder::kDefaultQuality);
- SkData* streamData = stream.copyToData();
- write(fd, streamData->data(), streamData->size());
- streamData->unref();
+ SkAutoTUnref<SkData> data(SkImageEncoder::EncodeData(info, base, s*bytesPerPixel(f),
+ SkImageEncoder::kPNG_Type, SkImageEncoder::kDefaultQuality));
+ if (data.get()) {
+ write(fd, data->data(), data->size());
+ }
+ if (fn != NULL) {
+ notifyMediaScanner(fn);
+ }
} else {
write(fd, &w, 4);
write(fd, &h, 4);
diff --git a/cmds/settings/src/com/android/commands/settings/SettingsCmd.java b/cmds/settings/src/com/android/commands/settings/SettingsCmd.java
index e6847a9946cf..c27d0c099b91 100644
--- a/cmds/settings/src/com/android/commands/settings/SettingsCmd.java
+++ b/cmds/settings/src/com/android/commands/settings/SettingsCmd.java
@@ -20,22 +20,28 @@ import android.app.ActivityManagerNative;
import android.app.IActivityManager;
import android.app.IActivityManager.ContentProviderHolder;
import android.content.IContentProvider;
+import android.database.Cursor;
import android.net.Uri;
import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
+import android.os.Process;
import android.os.RemoteException;
import android.os.UserHandle;
import android.provider.Settings;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
public final class SettingsCmd {
- static final String TAG = "settings";
enum CommandVerb {
UNSPECIFIED,
GET,
PUT,
- DELETE
+ DELETE,
+ LIST,
}
static String[] mArgs;
@@ -47,7 +53,7 @@ public final class SettingsCmd {
String mValue = null;
public static void main(String[] args) {
- if (args == null || args.length < 3) {
+ if (args == null || args.length < 2) {
printUsage();
return;
}
@@ -78,6 +84,8 @@ public final class SettingsCmd {
mVerb = CommandVerb.PUT;
} else if ("delete".equalsIgnoreCase(arg)) {
mVerb = CommandVerb.DELETE;
+ } else if ("list".equalsIgnoreCase(arg)) {
+ mVerb = CommandVerb.LIST;
} else {
// invalid
System.err.println("Invalid command: " + arg);
@@ -91,6 +99,10 @@ public final class SettingsCmd {
break; // invalid
}
mTable = arg.toLowerCase();
+ if (mVerb == CommandVerb.LIST) {
+ valid = true;
+ break;
+ }
} else if (mVerb == CommandVerb.GET || mVerb == CommandVerb.DELETE) {
mKey = arg;
if (mNextArg >= mArgs.length) {
@@ -144,6 +156,11 @@ public final class SettingsCmd {
System.out.println("Deleted "
+ deleteForUser(provider, mUser, mTable, mKey) + " rows");
break;
+ case LIST:
+ for (String line : listForUser(provider, mUser, mTable)) {
+ System.out.println(line);
+ }
+ break;
default:
System.err.println("Unspecified command");
break;
@@ -164,6 +181,34 @@ public final class SettingsCmd {
}
}
+ private List<String> listForUser(IContentProvider provider, int userHandle, String table) {
+ final Uri uri = "system".equals(table) ? Settings.System.CONTENT_URI
+ : "secure".equals(table) ? Settings.Secure.CONTENT_URI
+ : "global".equals(table) ? Settings.Global.CONTENT_URI
+ : null;
+ final ArrayList<String> lines = new ArrayList<String>();
+ if (uri == null) {
+ return lines;
+ }
+ try {
+ final Cursor cursor = provider.query(resolveCallingPackage(), uri, null, null, null,
+ null, null);
+ try {
+ while (cursor != null && cursor.moveToNext()) {
+ lines.add(cursor.getString(1) + "=" + cursor.getString(2));
+ }
+ } finally {
+ if (cursor != null) {
+ cursor.close();
+ }
+ }
+ Collections.sort(lines);
+ } catch (RemoteException e) {
+ System.err.println("List failed in " + table + " for user " + userHandle);
+ }
+ return lines;
+ }
+
private String nextArg() {
if (mNextArg >= mArgs.length) {
return null;
@@ -188,7 +233,7 @@ public final class SettingsCmd {
try {
Bundle arg = new Bundle();
arg.putInt(Settings.CALL_METHOD_USER_KEY, userHandle);
- Bundle b = provider.call(null, callGetCommand, key, arg);
+ Bundle b = provider.call(resolveCallingPackage(), callGetCommand, key, arg);
if (b != null) {
result = b.getPairValue();
}
@@ -213,7 +258,7 @@ public final class SettingsCmd {
Bundle arg = new Bundle();
arg.putString(Settings.NameValueTable.VALUE, value);
arg.putInt(Settings.CALL_METHOD_USER_KEY, userHandle);
- provider.call(null, callPutCommand, key, arg);
+ provider.call(resolveCallingPackage(), callPutCommand, key, arg);
} catch (RemoteException e) {
System.err.println("Can't set key " + key + " in " + table + " for user " + userHandle);
}
@@ -232,7 +277,7 @@ public final class SettingsCmd {
int num = 0;
try {
- num = provider.delete(null, targetUri, null, null);
+ num = provider.delete(resolveCallingPackage(), targetUri, null, null);
} catch (RemoteException e) {
System.err.println("Can't clear key " + key + " in " + table + " for user "
+ userHandle);
@@ -244,7 +289,24 @@ public final class SettingsCmd {
System.err.println("usage: settings [--user NUM] get namespace key");
System.err.println(" settings [--user NUM] put namespace key value");
System.err.println(" settings [--user NUM] delete namespace key");
+ System.err.println(" settings [--user NUM] list namespace");
System.err.println("\n'namespace' is one of {system, secure, global}, case-insensitive");
System.err.println("If '--user NUM' is not given, the operations are performed on the owner user.");
}
+
+ public static String resolveCallingPackage() {
+ switch (android.os.Process.myUid()) {
+ case Process.ROOT_UID: {
+ return "root";
+ }
+
+ case Process.SHELL_UID: {
+ return "com.android.shell";
+ }
+
+ default: {
+ return null;
+ }
+ }
+ }
}
diff --git a/cmds/svc/src/com/android/commands/svc/DataCommand.java b/cmds/svc/src/com/android/commands/svc/DataCommand.java
index 406e33b6545e..35510cfd38b1 100644
--- a/cmds/svc/src/com/android/commands/svc/DataCommand.java
+++ b/cmds/svc/src/com/android/commands/svc/DataCommand.java
@@ -18,8 +18,6 @@ package com.android.commands.svc;
import android.os.ServiceManager;
import android.os.RemoteException;
-import android.net.IConnectivityManager;
-import android.net.ConnectivityManager;
import android.content.Context;
import com.android.internal.telephony.ITelephony;
diff --git a/cmds/svc/src/com/android/commands/svc/WifiCommand.java b/cmds/svc/src/com/android/commands/svc/WifiCommand.java
index 39f0e35c3903..94214ff9694f 100644
--- a/cmds/svc/src/com/android/commands/svc/WifiCommand.java
+++ b/cmds/svc/src/com/android/commands/svc/WifiCommand.java
@@ -19,8 +19,6 @@ package com.android.commands.svc;
import android.os.ServiceManager;
import android.os.RemoteException;
import android.net.wifi.IWifiManager;
-import android.net.IConnectivityManager;
-import android.net.ConnectivityManager;
import android.content.Context;
public class WifiCommand extends Svc.Command {
diff --git a/cmds/uiautomator/library/Android.mk b/cmds/uiautomator/library/Android.mk
index 7cc0884e2bac..2123f25e9202 100644
--- a/cmds/uiautomator/library/Android.mk
+++ b/cmds/uiautomator/library/Android.mk
@@ -65,6 +65,7 @@ LOCAL_SOURCE_FILES_ALL_GENERATED := true
include $(BUILD_STATIC_JAVA_LIBRARY)
# Make sure to run droiddoc first to generate the stub source files.
$(full_classes_compiled_jar) : $(uiautomator_stubs_stamp)
+$(built_dex_intermediate) : $(uiautomator_stubs_stamp)
uiautomator_stubs_jar := $(full_classes_compiled_jar)
###############################################