diff options
Diffstat (limited to 'cmds')
-rw-r--r-- | cmds/am/src/com/android/commands/am/Am.java | 96 | ||||
-rw-r--r-- | cmds/app_process/app_main.cpp | 29 | ||||
-rw-r--r-- | cmds/bootanimation/BootAnimation.cpp | 107 | ||||
-rw-r--r-- | cmds/bootanimation/BootAnimation.h | 3 |
4 files changed, 108 insertions, 127 deletions
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java index 0344d26..89e15d2 100644 --- a/cmds/am/src/com/android/commands/am/Am.java +++ b/cmds/am/src/com/android/commands/am/Am.java @@ -19,8 +19,9 @@ package com.android.commands.am; import android.app.ActivityManager; -import android.app.ActivityManager.StackBoxInfo; +import android.app.ActivityManager.StackInfo; import android.app.ActivityManagerNative; +import android.app.IActivityContainer; import android.app.IActivityController; import android.app.IActivityManager; import android.app.IInstrumentationWatcher; @@ -31,9 +32,11 @@ import android.content.IIntentReceiver; import android.content.Intent; import android.content.pm.IPackageManager; import android.content.pm.ResolveInfo; +import android.graphics.Rect; import android.net.Uri; import android.os.Binder; import android.os.Bundle; +import android.os.IBinder; import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.os.ServiceManager; @@ -106,11 +109,11 @@ public class Am extends BaseCommand { " am to-intent-uri [INTENT]\n" + " am switch-user <USER_ID>\n" + " am stop-user <USER_ID>\n" + - " am stack create <TASK_ID> <RELATIVE_STACK_BOX_ID> <POSITION> <WEIGHT>\n" + + " am stack start <DISPLAY_ID> <INTENT>\n" + " am stack movetask <TASK_ID> <STACK_ID> [true|false]\n" + - " am stack resize <STACK_ID> <WEIGHT>\n" + - " am stack boxes\n" + - " am stack box <STACK_BOX_ID>\n" + + " am stack resize <STACK_ID> <LEFT,TOP,RIGHT,BOTTOM>\n" + + " am stack list\n" + + " am stack info <STACK_ID>\n" + "\n" + "am start: start an Activity. Options are:\n" + " -D: enable debugging\n" + @@ -204,24 +207,16 @@ public class Am extends BaseCommand { "am stop-user: stop execution of USER_ID, not allowing it to run any\n" + " code until a later explicit switch to it.\n" + "\n" + - "am stack create: create a new stack relative to an existing one.\n" + - " <TASK_ID>: the task to populate the new stack with. Must exist.\n" + - " <RELATIVE_STACK_BOX_ID>: existing stack box's id.\n" + - " <POSITION>: 0: before <RELATIVE_STACK_BOX_ID>, per RTL/LTR configuration,\n" + - " 1: after <RELATIVE_STACK_BOX_ID>, per RTL/LTR configuration,\n" + - " 2: to left of <RELATIVE_STACK_BOX_ID>,\n" + - " 3: to right of <RELATIVE_STACK_BOX_ID>," + - " 4: above <RELATIVE_STACK_BOX_ID>, 5: below <RELATIVE_STACK_BOX_ID>\n" + - " <WEIGHT>: float between 0.2 and 0.8 inclusive.\n" + + "am stack start: start a new activity on <DISPLAY_ID> using <INTENT>.\n" + "\n" + "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> relative size to new <WEIGHT>.\n" + + "am stack resize: change <STACK_ID> size and position to <LEFT,TOP,RIGHT,BOTTOM>.\n" + "\n" + - "am stack boxes: list the hierarchy of stack boxes and their contents.\n" + + "am stack list: list all of the activity stacks and their sizes.\n" + "\n" + - "am stack box: list the hierarchy of stack boxes rooted at <STACK_BOX_ID>.\n" + + "am stack info: display the information about activity stack <STACK_ID>.\n" + "\n" + "<INTENT> specifications include these flags and arguments:\n" + " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]\n" + @@ -1546,35 +1541,32 @@ public class Am extends BaseCommand { private void runStack() throws Exception { String op = nextArgRequired(); - if (op.equals("create")) { - runStackCreate(); + if (op.equals("start")) { + runStackStart(); } else if (op.equals("movetask")) { runStackMoveTask(); } else if (op.equals("resize")) { - runStackBoxResize(); - } else if (op.equals("boxes")) { - runStackBoxes(); - } else if (op.equals("box")) { - runStackBoxInfo(); + runStackResize(); + } else if (op.equals("list")) { + runStackList(); + } else if (op.equals("info")) { + runStackInfo(); } else { showError("Error: unknown command '" + op + "'"); return; } } - private void runStackCreate() throws Exception { - String taskIdStr = nextArgRequired(); - int taskId = Integer.valueOf(taskIdStr); - String relativeToStr = nextArgRequired(); - int relativeTo = Integer.valueOf(relativeToStr); - String positionStr = nextArgRequired(); - int position = Integer.valueOf(positionStr); - String weightStr = nextArgRequired(); - float weight = Float.valueOf(weightStr); + private void runStackStart() throws Exception { + String displayIdStr = nextArgRequired(); + int displayId = Integer.valueOf(displayIdStr); + Intent intent = makeIntent(UserHandle.USER_CURRENT); try { - int stackId = mAm.createStack(taskId, relativeTo, position, weight); - System.out.println("createStack returned new stackId=" + stackId + "\n\n"); + IBinder homeActivityToken = mAm.getHomeActivityToken(); + IActivityContainer container = mAm.createActivityContainer(homeActivityToken, null); + container.attachToDisplay(displayId); + container.startActivity(intent); } catch (RemoteException e) { } } @@ -1601,34 +1593,40 @@ public class Am extends BaseCommand { } } - private void runStackBoxResize() throws Exception { - String stackBoxIdStr = nextArgRequired(); - int stackBoxId = Integer.valueOf(stackBoxIdStr); - String weightStr = nextArgRequired(); - float weight = Float.valueOf(weightStr); + 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); try { - mAm.resizeStackBox(stackBoxId, weight); + mAm.resizeStack(stackId, new Rect(left, top, right, bottom)); } catch (RemoteException e) { } } - private void runStackBoxes() throws Exception { + private void runStackList() throws Exception { try { - List<StackBoxInfo> stackBoxes = mAm.getStackBoxes(); - for (StackBoxInfo info : stackBoxes) { + List<StackInfo> stacks = mAm.getAllStackInfos(); + for (StackInfo info : stacks) { System.out.println(info); } } catch (RemoteException e) { } } - private void runStackBoxInfo() throws Exception { + private void runStackInfo() throws Exception { try { - String stackBoxIdStr = nextArgRequired(); - int stackBoxId = Integer.valueOf(stackBoxIdStr); - StackBoxInfo stackBoxInfo = mAm.getStackBoxInfo(stackBoxId); - System.out.println(stackBoxInfo); + String stackIdStr = nextArgRequired(); + int stackId = Integer.valueOf(stackIdStr); + StackInfo info = mAm.getStackInfo(stackId); + System.out.println(info); } catch (RemoteException e) { } } diff --git a/cmds/app_process/app_main.cpp b/cmds/app_process/app_main.cpp index 28752a5..8d2b739 100644 --- a/cmds/app_process/app_main.cpp +++ b/cmds/app_process/app_main.cpp @@ -7,7 +7,6 @@ #define LOG_TAG "appproc" -#include <cutils/properties.h> #include <binder/IPCThreadState.h> #include <binder/ProcessState.h> #include <utils/Log.h> @@ -15,7 +14,6 @@ #include <cutils/memory.h> #include <cutils/trace.h> #include <android_runtime/AndroidRuntime.h> -#include <sys/personality.h> #include <stdlib.h> #include <stdio.h> @@ -137,33 +135,6 @@ static void setArgv0(const char *argv0, const char *newArgv0) int main(int argc, char* const argv[]) { -#ifdef __arm__ - /* - * b/7188322 - Temporarily revert to the compat memory layout - * to avoid breaking third party apps. - * - * THIS WILL GO AWAY IN A FUTURE ANDROID RELEASE. - * - * http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=7dbaa466 - * changes the kernel mapping from bottom up to top-down. - * This breaks some programs which improperly embed - * an out of date copy of Android's linker. - */ - char value[PROPERTY_VALUE_MAX]; - property_get("ro.kernel.qemu", value, ""); - bool is_qemu = (strcmp(value, "1") == 0); - if ((getenv("NO_ADDR_COMPAT_LAYOUT_FIXUP") == NULL) && !is_qemu) { - int current = personality(0xFFFFFFFF); - if ((current & ADDR_COMPAT_LAYOUT) == 0) { - personality(current | ADDR_COMPAT_LAYOUT); - setenv("NO_ADDR_COMPAT_LAYOUT_FIXUP", "1", 1); - execv("/system/bin/app_process", argv); - return -1; - } - } - unsetenv("NO_ADDR_COMPAT_LAYOUT_FIXUP"); -#endif - // These are global variables in ProcessState.cpp mArgC = argc; mArgV = argv; diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp index ad4e4c8..1a2ab81 100644 --- a/cmds/bootanimation/BootAnimation.cpp +++ b/cmds/bootanimation/BootAnimation.cpp @@ -52,7 +52,6 @@ #include "BootAnimation.h" -#define USER_BOOTANIMATION_FILE "/data/local/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" @@ -63,14 +62,19 @@ extern "C" int clock_nanosleep(clockid_t clock_id, int flags, namespace android { +static const int ANIM_ENTRY_NAME_MAX = 256; + // --------------------------------------------------------------------------- -BootAnimation::BootAnimation() : Thread(false) +BootAnimation::BootAnimation() : Thread(false), mZip(NULL) { mSession = new SurfaceComposerClient(); } BootAnimation::~BootAnimation() { + if (mZip != NULL) { + delete mZip; + } } void BootAnimation::onFirstRef() { @@ -86,7 +90,7 @@ sp<SurfaceComposerClient> BootAnimation::session() const { } -void BootAnimation::binderDied(const wp<IBinder>& who) +void BootAnimation::binderDied(const wp<IBinder>&) { // woah, surfaceflinger died! ALOGD("SurfaceFlinger died, exiting..."); @@ -159,8 +163,8 @@ status_t BootAnimation::initTexture(void* buffer, size_t len) SkBitmap bitmap; SkMemoryStream stream(buffer, len); SkImageDecoder* codec = SkImageDecoder::Factory(&stream); - codec->setDitherImage(false); if (codec) { + codec->setDitherImage(false); codec->decode(&stream, &bitmap, SkBitmap::kARGB_8888_Config, SkImageDecoder::kDecodePixels_Mode); @@ -268,25 +272,21 @@ status_t BootAnimation::readyToRun() { mFlingerSurfaceControl = control; mFlingerSurface = s; - mAndroidAnimation = true; - - // If the device has encryption turned on or is in process + // If the device has encryption turned on or is in process // of being encrypted we show the encrypted boot animation. char decrypt[PROPERTY_VALUE_MAX]; property_get("vold.decrypt", decrypt, ""); bool encryptedAnimation = atoi(decrypt) != 0 || !strcmp("trigger_restart_min_framework", decrypt); + ZipFileRO* zipFile = NULL; if ((encryptedAnimation && (access(SYSTEM_ENCRYPTED_BOOTANIMATION_FILE, R_OK) == 0) && - (mZip.open(SYSTEM_ENCRYPTED_BOOTANIMATION_FILE) == NO_ERROR)) || - - ((access(USER_BOOTANIMATION_FILE, R_OK) == 0) && - (mZip.open(USER_BOOTANIMATION_FILE) == NO_ERROR)) || + ((zipFile = ZipFileRO::open(SYSTEM_ENCRYPTED_BOOTANIMATION_FILE)) != NULL)) || ((access(SYSTEM_BOOTANIMATION_FILE, R_OK) == 0) && - (mZip.open(SYSTEM_BOOTANIMATION_FILE) == NO_ERROR))) { - mAndroidAnimation = false; + ((zipFile = ZipFileRO::open(SYSTEM_BOOTANIMATION_FILE)) != NULL))) { + mZip = zipFile; } return NO_ERROR; @@ -295,15 +295,14 @@ status_t BootAnimation::readyToRun() { bool BootAnimation::threadLoop() { bool r; - if (mAndroidAnimation) { + // We have no bootanimation file, so we use the stock android logo + // animation. + if (mZip == NULL) { r = android(); } else { r = movie(); } - // No need to force exit anymore - property_set(EXIT_PROP_NAME, "0"); - eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglDestroyContext(mDisplay, mContext); eglDestroySurface(mDisplay, mSurface); @@ -392,11 +391,14 @@ void BootAnimation::checkExit() { bool BootAnimation::movie() { - ZipFileRO& zip(mZip); + ZipEntryRO desc = mZip->findEntryByName("desc.txt"); + ALOGE_IF(!desc, "couldn't find desc.txt"); + if (!desc) { + return false; + } - size_t numEntries = zip.getNumEntries(); - ZipEntryRO desc = zip.findEntryByName("desc.txt"); - FileMap* descMap = zip.createEntryFileMap(desc); + FileMap* descMap = mZip->createEntryFileMap(desc); + mZip->releaseEntry(desc); ALOGE_IF(!descMap, "descMap is null"); if (!descMap) { return false; @@ -415,7 +417,7 @@ bool BootAnimation::movie() String8 line(s, endl - s); const char* l = line.string(); int fps, width, height, count, pause; - char path[256]; + char path[ANIM_ENTRY_NAME_MAX]; char pathType; if (sscanf(l, "%d %d %d", &width, &height, &fps) == 3) { //LOGD("> w=%d, h=%d, fps=%d", width, height, fps); @@ -438,28 +440,37 @@ bool BootAnimation::movie() // read all the data structures const size_t pcount = animation.parts.size(); - for (size_t i=0 ; i<numEntries ; i++) { - char name[256]; - ZipEntryRO entry = zip.findEntryByIndex(i); - if (zip.getEntryFileName(entry, name, 256) == 0) { - const String8 entryName(name); - const String8 path(entryName.getPathDir()); - const String8 leaf(entryName.getPathLeaf()); - if (leaf.size() > 0) { - for (int j=0 ; j<pcount ; j++) { - if (path == animation.parts[j].path) { - int method; - // supports only stored png files - if (zip.getEntryInfo(entry, &method, 0, 0, 0, 0, 0)) { - if (method == ZipFileRO::kCompressStored) { - FileMap* map = zip.createEntryFileMap(entry); - if (map) { - Animation::Frame frame; - frame.name = leaf; - frame.map = map; - Animation::Part& part(animation.parts.editItemAt(j)); - part.frames.add(frame); - } + void *cookie = NULL; + if (!mZip->startIteration(&cookie)) { + return false; + } + + ZipEntryRO entry; + char name[ANIM_ENTRY_NAME_MAX]; + while ((entry = mZip->nextEntry(cookie)) != NULL) { + const int foundEntryName = mZip->getEntryFileName(entry, name, ANIM_ENTRY_NAME_MAX); + if (foundEntryName > ANIM_ENTRY_NAME_MAX || foundEntryName == -1) { + ALOGE("Error fetching entry file name"); + continue; + } + + const String8 entryName(name); + const String8 path(entryName.getPathDir()); + const String8 leaf(entryName.getPathLeaf()); + if (leaf.size() > 0) { + for (size_t j=0 ; j<pcount ; j++) { + if (path == animation.parts[j].path) { + int method; + // supports only stored png files + if (mZip->getEntryInfo(entry, &method, NULL, NULL, NULL, NULL, NULL)) { + if (method == ZipFileRO::kCompressStored) { + FileMap* map = mZip->createEntryFileMap(entry); + if (map) { + Animation::Frame frame; + frame.name = leaf; + frame.map = map; + Animation::Part& part(animation.parts.editItemAt(j)); + part.frames.add(frame); } } } @@ -468,6 +479,8 @@ bool BootAnimation::movie() } } + mZip->endIteration(cookie); + // clear screen glShadeModel(GL_FLAT); glDisable(GL_DITHER); @@ -494,7 +507,7 @@ bool BootAnimation::movie() Region clearReg(Rect(mWidth, mHeight)); clearReg.subtractSelf(Rect(xc, yc, xc+animation.width, yc+animation.height)); - for (int i=0 ; i<pcount ; i++) { + for (size_t i=0 ; i<pcount ; i++) { const Animation::Part& part(animation.parts[i]); const size_t fcount = part.frames.size(); glBindTexture(GL_TEXTURE_2D, 0); @@ -504,7 +517,7 @@ bool BootAnimation::movie() if(exitPending() && !part.playUntilComplete) break; - for (int j=0 ; j<fcount && (!exitPending() || part.playUntilComplete) ; j++) { + for (size_t j=0 ; j<fcount && (!exitPending() || part.playUntilComplete) ; j++) { const Animation::Frame& frame(part.frames[j]); nsecs_t lastFrame = systemTime(); @@ -564,7 +577,7 @@ bool BootAnimation::movie() // free the textures for this part if (part.count != 1) { - for (int j=0 ; j<fcount ; j++) { + for (size_t j=0 ; j<fcount ; j++) { const Animation::Frame& frame(part.frames[j]); glDeleteTextures(1, &frame.tid); } diff --git a/cmds/bootanimation/BootAnimation.h b/cmds/bootanimation/BootAnimation.h index fa908eb..22963c2 100644 --- a/cmds/bootanimation/BootAnimation.h +++ b/cmds/bootanimation/BootAnimation.h @@ -95,8 +95,7 @@ private: EGLDisplay mSurface; sp<SurfaceControl> mFlingerSurfaceControl; sp<Surface> mFlingerSurface; - bool mAndroidAnimation; - ZipFileRO mZip; + ZipFileRO *mZip; }; // --------------------------------------------------------------------------- |