diff options
Diffstat (limited to 'cmds')
32 files changed, 1550 insertions, 373 deletions
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java index 3782136f5c73..0b4f25e2e73b 100644 --- a/cmds/am/src/com/android/commands/am/Am.java +++ b/cmds/am/src/com/android/commands/am/Am.java @@ -23,16 +23,19 @@ import android.app.IActivityManager; import android.app.IInstrumentationWatcher; import android.app.Instrumentation; import android.content.ComponentName; +import android.content.IIntentReceiver; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.os.ServiceManager; +import android.util.AndroidException; import android.view.IWindowManager; import java.io.File; import java.io.FileNotFoundException; +import java.net.URISyntaxException; import java.util.Iterator; import java.util.Set; @@ -45,16 +48,29 @@ public class Am { private boolean mDebugOption = false; + // These are magic strings understood by the Eclipse plugin. + private static final String FATAL_ERROR_CODE = "Error type 1"; + private static final String NO_SYSTEM_ERROR_CODE = "Error type 2"; + private static final String NO_CLASS_ERROR_CODE = "Error type 3"; + /** * Command-line entry point. * * @param args The command-line arguments */ public static void main(String[] args) { - (new Am()).run(args); + try { + (new Am()).run(args); + } catch (IllegalArgumentException e) { + showUsage(); + System.err.println("Error: " + e.getMessage()); + } catch (Exception e) { + System.err.println(e.toString()); + System.exit(1); + } } - private void run(String[] args) { + private void run(String[] args) throws Exception { if (args.length < 1) { showUsage(); return; @@ -62,16 +78,14 @@ public class Am { mAm = ActivityManagerNative.getDefault(); if (mAm == null) { - System.err.println("Error type 2"); - System.err.println("Error: Unable to connect to activity manager; is the system running?"); - showUsage(); - return; + System.err.println(NO_SYSTEM_ERROR_CODE); + throw new AndroidException("Can't connect to activity manager; is the system running?"); } mArgs = args; - String op = args[0]; mNextArg = 1; + if (op.equals("start")) { runStart(); } else if (op.equals("instrument")) { @@ -81,13 +95,11 @@ public class Am { } else if (op.equals("profile")) { runProfile(); } else { - System.err.println("Error: Unknown command: " + op); - showUsage(); - return; + throw new IllegalArgumentException("Unknown command: " + op); } } - private Intent makeIntent() { + private Intent makeIntent() throws URISyntaxException { Intent intent = new Intent(); boolean hasIntentInfo = false; @@ -95,186 +107,146 @@ public class Am { Uri data = null; String type = null; - try { - String opt; - while ((opt=nextOption()) != null) { - if (opt.equals("-a")) { - intent.setAction(nextOptionData()); - hasIntentInfo = true; - } else if (opt.equals("-d")) { - data = Uri.parse(nextOptionData()); - hasIntentInfo = true; - } else if (opt.equals("-t")) { - type = nextOptionData(); - hasIntentInfo = true; - } else if (opt.equals("-c")) { - intent.addCategory(nextOptionData()); - hasIntentInfo = true; - } else if (opt.equals("-e") || opt.equals("--es")) { - String key = nextOptionData(); - String value = nextOptionData(); - intent.putExtra(key, value); - hasIntentInfo = true; - } else if (opt.equals("--ei")) { - String key = nextOptionData(); - String value = nextOptionData(); - intent.putExtra(key, Integer.valueOf(value)); - hasIntentInfo = true; - } else if (opt.equals("--ez")) { - String key = nextOptionData(); - String value = nextOptionData(); - intent.putExtra(key, Boolean.valueOf(value)); - hasIntentInfo = true; - } else if (opt.equals("-n")) { - String str = nextOptionData(); - ComponentName cn = ComponentName.unflattenFromString(str); - if (cn == null) { - System.err.println("Error: Bad component name: " + str); - showUsage(); - return null; - } - intent.setComponent(cn); - hasIntentInfo = true; - } else if (opt.equals("-f")) { - String str = nextOptionData(); - intent.setFlags(Integer.decode(str).intValue()); - } else if (opt.equals("-D")) { - mDebugOption = true; - } else { - System.err.println("Error: Unknown option: " + opt); - showUsage(); - return null; - } + String opt; + while ((opt=nextOption()) != null) { + if (opt.equals("-a")) { + intent.setAction(nextArgRequired()); + hasIntentInfo = true; + } else if (opt.equals("-d")) { + data = Uri.parse(nextArgRequired()); + hasIntentInfo = true; + } else if (opt.equals("-t")) { + type = nextArgRequired(); + hasIntentInfo = true; + } else if (opt.equals("-c")) { + intent.addCategory(nextArgRequired()); + hasIntentInfo = true; + } else if (opt.equals("-e") || opt.equals("--es")) { + String key = nextArgRequired(); + String value = nextArgRequired(); + intent.putExtra(key, value); + hasIntentInfo = true; + } else if (opt.equals("--ei")) { + String key = nextArgRequired(); + String value = nextArgRequired(); + intent.putExtra(key, Integer.valueOf(value)); + hasIntentInfo = true; + } else if (opt.equals("--ez")) { + String key = nextArgRequired(); + String value = nextArgRequired(); + intent.putExtra(key, Boolean.valueOf(value)); + hasIntentInfo = true; + } else if (opt.equals("-n")) { + String str = nextArgRequired(); + ComponentName cn = ComponentName.unflattenFromString(str); + if (cn == null) throw new IllegalArgumentException("Bad component name: " + str); + intent.setComponent(cn); + hasIntentInfo = true; + } else if (opt.equals("-f")) { + String str = nextArgRequired(); + intent.setFlags(Integer.decode(str).intValue()); + } else if (opt.equals("-D")) { + mDebugOption = true; + } else { + System.err.println("Error: Unknown option: " + opt); + showUsage(); + return null; } - } catch (RuntimeException ex) { - System.err.println("Error: " + ex.toString()); - showUsage(); - return null; } intent.setDataAndType(data, type); String uri = nextArg(); if (uri != null) { - try { - Intent oldIntent = intent; - try { - intent = Intent.getIntent(uri); - } catch (java.net.URISyntaxException ex) { - System.err.println("Bad URI: " + uri); - showUsage(); - return null; - } - if (oldIntent.getAction() != null) { - intent.setAction(oldIntent.getAction()); - } - if (oldIntent.getData() != null || oldIntent.getType() != null) { - intent.setDataAndType(oldIntent.getData(), oldIntent.getType()); - } - Set cats = oldIntent.getCategories(); - if (cats != null) { - Iterator it = cats.iterator(); - while (it.hasNext()) { - intent.addCategory((String)it.next()); - } + Intent oldIntent = intent; + intent = Intent.getIntent(uri); + if (oldIntent.getAction() != null) { + intent.setAction(oldIntent.getAction()); + } + if (oldIntent.getData() != null || oldIntent.getType() != null) { + intent.setDataAndType(oldIntent.getData(), oldIntent.getType()); + } + Set cats = oldIntent.getCategories(); + if (cats != null) { + Iterator it = cats.iterator(); + while (it.hasNext()) { + intent.addCategory((String)it.next()); } - } catch (RuntimeException ex) { - System.err.println("Error creating from URI: " + ex.toString()); - showUsage(); - return null; } - } else if (!hasIntentInfo) { - System.err.println("Error: No intent supplied"); - showUsage(); - return null; + hasIntentInfo = true; } + if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied"); return intent; } - private void runStart() { + private void runStart() throws Exception { Intent intent = makeIntent(); - - if (intent != null) { - System.out.println("Starting: " + intent); - try { - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - // XXX should do something to determine the MIME type. - int res = mAm.startActivity(null, intent, intent.getType(), - null, 0, null, null, 0, false, mDebugOption); - switch (res) { - case IActivityManager.START_SUCCESS: - break; - case IActivityManager.START_SWITCHES_CANCELED: - System.err.println( - "Warning: Activity not started because the " - + " current activity is being kept for the user."); - break; - case IActivityManager.START_DELIVERED_TO_TOP: - System.err.println( - "Warning: Activity not started, intent has " - + "been delivered to currently running " - + "top-most instance."); - break; - case IActivityManager.START_RETURN_INTENT_TO_CALLER: - System.err.println( - "Warning: Activity not started because intent " - + "should be handled by the caller"); - break; - case IActivityManager.START_TASK_TO_FRONT: - System.err.println( - "Warning: Activity not started, its current " - + "task has been brought to the front"); - break; - case IActivityManager.START_INTENT_NOT_RESOLVED: - System.err.println( - "Error: Activity not started, unable to " - + "resolve " + intent.toString()); - break; - case IActivityManager.START_CLASS_NOT_FOUND: - System.err.println("Error type 3"); - System.err.println("Error: Activity class " + - intent.getComponent().toShortString() - + " does not exist."); - break; - case IActivityManager.START_FORWARD_AND_REQUEST_CONFLICT: - System.err.println( - "Error: Activity not started, you requested to " - + "both forward and receive its result"); - break; - case IActivityManager.START_PERMISSION_DENIED: - System.err.println( - "Error: Activity not started, you do not " - + "have permission to access it."); - break; - default: - System.err.println( - "Error: Activity not started, unknown error " - + "code " + res); - break; - } - } catch (RemoteException e) { - System.err.println("Error type 1"); + System.out.println("Starting: " + intent); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + // XXX should do something to determine the MIME type. + int res = mAm.startActivity(null, intent, intent.getType(), + null, 0, null, null, 0, false, mDebugOption); + switch (res) { + case IActivityManager.START_SUCCESS: + break; + case IActivityManager.START_SWITCHES_CANCELED: + System.err.println( + "Warning: Activity not started because the " + + " current activity is being kept for the user."); + break; + case IActivityManager.START_DELIVERED_TO_TOP: + System.err.println( + "Warning: Activity not started, intent has " + + "been delivered to currently running " + + "top-most instance."); + break; + case IActivityManager.START_RETURN_INTENT_TO_CALLER: + System.err.println( + "Warning: Activity not started because intent " + + "should be handled by the caller"); + break; + case IActivityManager.START_TASK_TO_FRONT: + System.err.println( + "Warning: Activity not started, its current " + + "task has been brought to the front"); + break; + case IActivityManager.START_INTENT_NOT_RESOLVED: System.err.println( "Error: Activity not started, unable to " - + "call on to activity manager service"); - } + + "resolve " + intent.toString()); + break; + case IActivityManager.START_CLASS_NOT_FOUND: + System.err.println(NO_CLASS_ERROR_CODE); + System.err.println("Error: Activity class " + + intent.getComponent().toShortString() + + " does not exist."); + break; + case IActivityManager.START_FORWARD_AND_REQUEST_CONFLICT: + System.err.println( + "Error: Activity not started, you requested to " + + "both forward and receive its result"); + break; + case IActivityManager.START_PERMISSION_DENIED: + System.err.println( + "Error: Activity not started, you do not " + + "have permission to access it."); + break; + default: + System.err.println( + "Error: Activity not started, unknown error code " + res); + break; } } - private void sendBroadcast() { + private void sendBroadcast() throws Exception { Intent intent = makeIntent(); - - if (intent != null) { - System.out.println("Broadcasting: " + intent); - try { - mAm.broadcastIntent(null, intent, null, null, 0, null, null, - null, true, false); - } catch (RemoteException e) { - } - } + IntentReceiver receiver = new IntentReceiver(); + System.out.println("Broadcasting: " + intent); + mAm.broadcastIntent(null, intent, null, receiver, 0, null, null, null, true, false); + receiver.waitForFinish(); } - private void runInstrument() { + private void runInstrument() throws Exception { String profileFile = null; boolean wait = false; boolean rawMode = false; @@ -283,46 +255,30 @@ public class Am { String argKey = null, argValue = null; IWindowManager wm = IWindowManager.Stub.asInterface(ServiceManager.getService("window")); - try { - String opt; - while ((opt=nextOption()) != null) { - if (opt.equals("-p")) { - profileFile = nextOptionData(); - } else if (opt.equals("-w")) { - wait = true; - } else if (opt.equals("-r")) { - rawMode = true; - } else if (opt.equals("-e")) { - argKey = nextOptionData(); - argValue = nextOptionData(); - args.putString(argKey, argValue); - } else if (opt.equals("--no_window_animation")) { - no_window_animation = true; - } else { - System.err.println("Error: Unknown option: " + opt); - showUsage(); - return; - } + String opt; + while ((opt=nextOption()) != null) { + if (opt.equals("-p")) { + profileFile = nextArgRequired(); + } else if (opt.equals("-w")) { + wait = true; + } else if (opt.equals("-r")) { + rawMode = true; + } else if (opt.equals("-e")) { + argKey = nextArgRequired(); + argValue = nextArgRequired(); + args.putString(argKey, argValue); + } else if (opt.equals("--no_window_animation")) { + no_window_animation = true; + } else { + System.err.println("Error: Unknown option: " + opt); + showUsage(); + return; } - } catch (RuntimeException ex) { - System.err.println("Error: " + ex.toString()); - showUsage(); - return; } - String cnArg = nextArg(); - if (cnArg == null) { - System.err.println("Error: No instrumentation component supplied"); - showUsage(); - return; - } - + String cnArg = nextArgRequired(); ComponentName cn = ComponentName.unflattenFromString(cnArg); - if (cn == null) { - System.err.println("Error: Bad component name: " + cnArg); - showUsage(); - return; - } + if (cn == null) throw new IllegalArgumentException("Bad component name: " + cnArg); InstrumentationWatcher watcher = null; if (wait) { @@ -331,22 +287,13 @@ public class Am { } float[] oldAnims = null; if (no_window_animation) { - try { - oldAnims = wm.getAnimationScales(); - wm.setAnimationScale(0, 0.0f); - wm.setAnimationScale(1, 0.0f); - } catch (RemoteException e) { - } + oldAnims = wm.getAnimationScales(); + wm.setAnimationScale(0, 0.0f); + wm.setAnimationScale(1, 0.0f); } - try { - if (!mAm.startInstrumentation(cn, profileFile, 0, args, watcher)) { - System.out.println("INSTRUMENTATION_FAILED: " + - cn.flattenToString()); - showUsage(); - return; - } - } catch (RemoteException e) { + if (!mAm.startInstrumentation(cn, profileFile, 0, args, watcher)) { + throw new AndroidException("INSTRUMENTATION_FAILED: " + cn.flattenToString()); } if (watcher != null) { @@ -356,9 +303,57 @@ public class Am { } if (oldAnims != null) { + wm.setAnimationScales(oldAnims); + } + } + + private void runProfile() throws Exception { + String profileFile = null; + boolean start = false; + String process = nextArgRequired(); + ParcelFileDescriptor fd = null; + + String cmd = nextArgRequired(); + if ("start".equals(cmd)) { + start = true; + profileFile = nextArgRequired(); + try { + fd = ParcelFileDescriptor.open( + new File(profileFile), + ParcelFileDescriptor.MODE_CREATE | + ParcelFileDescriptor.MODE_TRUNCATE | + ParcelFileDescriptor.MODE_READ_WRITE); + } catch (FileNotFoundException e) { + System.err.println("Error: Unable to open file: " + profileFile); + return; + } + } else if (!"stop".equals(cmd)) { + throw new IllegalArgumentException("Profile command " + cmd + " not valid"); + } + + if (!mAm.profileControl(process, start, profileFile, fd)) { + throw new AndroidException("PROFILE FAILED on process " + process); + } + } + + private class IntentReceiver extends IIntentReceiver.Stub { + private boolean mFinished = false; + + public synchronized void performReceive( + Intent intent, int rc, String data, Bundle ext, boolean ord) { + String line = "Broadcast completed: result=" + rc; + if (data != null) line = line + ", data=\"" + data + "\""; + if (ext != null) line = line + ", extras: " + ext; + System.out.println(line); + mFinished = true; + notifyAll(); + } + + public synchronized void waitForFinish() { try { - wm.setAnimationScales(oldAnims); - } catch (RemoteException e) { + while (!mFinished) wait(); + } catch (InterruptedException e) { + throw new IllegalStateException(e); } } } @@ -366,7 +361,7 @@ public class Am { private class InstrumentationWatcher extends IInstrumentationWatcher.Stub { private boolean mFinished = false; private boolean mRawMode = false; - + /** * Set or reset "raw mode". In "raw mode", all bundles are dumped. In "pretty mode", * if a bundle includes Instrumentation.REPORT_KEY_STREAMRESULT, just print that. @@ -375,7 +370,7 @@ public class Am { public void setRawOutput(boolean rawMode) { mRawMode = rawMode; } - + public void instrumentationStatus(ComponentName name, int resultCode, Bundle results) { synchronized (this) { // pretty printer mode? @@ -431,6 +426,7 @@ public class Am { } wait(1000); } catch (InterruptedException e) { + throw new IllegalStateException(e); } } } @@ -438,62 +434,11 @@ public class Am { } } - private void runProfile() { - String profileFile = null; - boolean start = false; - - String process = nextArg(); - if (process == null) { - System.err.println("Error: No profile process supplied"); - showUsage(); - return; - } - - ParcelFileDescriptor fd = null; - - String cmd = nextArg(); - if ("start".equals(cmd)) { - start = true; - profileFile = nextArg(); - if (profileFile == null) { - System.err.println("Error: No profile file path supplied"); - showUsage(); - return; - } - try { - fd = ParcelFileDescriptor.open( - new File(profileFile), - ParcelFileDescriptor.MODE_CREATE | - ParcelFileDescriptor.MODE_TRUNCATE | - ParcelFileDescriptor.MODE_READ_WRITE); - } catch (FileNotFoundException e) { - System.err.println("Error: Unable to open file: " + profileFile); - return; - } - } else if (!"stop".equals(cmd)) { - System.err.println("Error: Profile command " + cmd + " not valid"); - showUsage(); - return; - } - - try { - if (!mAm.profileControl(process, start, profileFile, fd)) { - System.err.println("PROFILE FAILED on process " + process); - return; - } - } catch (IllegalArgumentException e) { - System.out.println("PROFILE FAILED: " + e.getMessage()); - return; - } catch (IllegalStateException e) { - System.out.println("PROFILE FAILED: " + e.getMessage()); - return; - } catch (RemoteException e) { - System.out.println("PROFILE FAILED: activity manager gone"); - return; - } - } - private String nextOption() { + if (mCurArgData != null) { + String prev = mArgs[mNextArg - 1]; + throw new IllegalArgumentException("No argument expected after \"" + prev + "\""); + } if (mNextArg >= mArgs.length) { return null; } @@ -518,41 +463,52 @@ public class Am { return arg; } - private String nextOptionData() { + private String nextArg() { if (mCurArgData != null) { - return mCurArgData; - } - if (mNextArg >= mArgs.length) { + String arg = mCurArgData; + mCurArgData = null; + return arg; + } else if (mNextArg < mArgs.length) { + return mArgs[mNextArg++]; + } else { return null; } - String data = mArgs[mNextArg]; - mNextArg++; - return data; } - private String nextArg() { - if (mNextArg >= mArgs.length) { - return null; + private String nextArgRequired() { + String arg = nextArg(); + if (arg == null) { + String prev = mArgs[mNextArg - 1]; + throw new IllegalArgumentException("Argument expected after \"" + prev + "\""); } - String arg = mArgs[mNextArg]; - mNextArg++; return arg; } - private void showUsage() { - System.err.println("usage: am [start|broadcast|instrument|profile]"); - System.err.println(" am start [-D] INTENT"); - System.err.println(" am broadcast INTENT"); - System.err.println(" am instrument [-r] [-e <ARG_NAME> <ARG_VALUE>] [-p <PROF_FILE>]"); - System.err.println(" [-w] <COMPONENT> "); - System.err.println(" am profile <PROCESS> [start <PROF_FILE>|stop]"); - System.err.println(""); - System.err.println(" INTENT is described with:"); - System.err.println(" [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]"); - System.err.println(" [-c <CATEGORY> [-c <CATEGORY>] ...]"); - System.err.println(" [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]"); - System.err.println(" [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]"); - System.err.println(" [-e|--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]"); - System.err.println(" [-n <COMPONENT>] [-f <FLAGS>] [<URI>]"); + private static void showUsage() { + System.err.println( + "usage: am [subcommand] [options]\n" + + "\n" + + " start an Activity: am start [-D] <INTENT>\n" + + " -D: enable debugging\n" + + "\n" + + " send a broadcast Intent: am broadcast <INTENT>\n" + + "\n" + + " start an Instrumentation: am instrument [flags] <COMPONENT>\n" + + " -r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT)\n" + + " -e <NAME> <VALUE>: set argument <NAME> to <VALUE>\n" + + " -p <FILE>: write profiling data to <FILE>\n" + + " -w: wait for instrumentation to finish before returning\n" + + "\n" + + " start profiling: am profile <PROCESS> start <FILE>\n" + + " stop profiling: am profile <PROCESS> stop\n" + + "\n" + + " <INTENT> specifications include these flags:\n" + + " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]\n" + + " [-c <CATEGORY> [-c <CATEGORY>] ...]\n" + + " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]\n" + + " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]\n" + + " [-e|--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]\n" + + " [-n <COMPONENT>] [-f <FLAGS>] [<URI>]\n" + ); } } diff --git a/cmds/app_process/app_main.cpp b/cmds/app_process/app_main.cpp index d825d5a3a4dc..7decf9ae737d 100644 --- a/cmds/app_process/app_main.cpp +++ b/cmds/app_process/app_main.cpp @@ -7,8 +7,8 @@ #define LOG_TAG "appproc" -#include <utils/IPCThreadState.h> -#include <utils/ProcessState.h> +#include <binder/IPCThreadState.h> +#include <binder/ProcessState.h> #include <utils/Log.h> #include <cutils/process_name.h> #include <cutils/memory.h> diff --git a/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java b/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java index ee3ec1aa18fb..8c15d0b4ea13 100644 --- a/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java +++ b/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java @@ -268,7 +268,7 @@ public final class Bmgr { private void printRestoreSets(RestoreSet[] sets) { for (RestoreSet s : sets) { - System.out.println(" " + s.token + " : " + s.name); + System.out.println(" " + Long.toHexString(s.token) + " : " + s.name); } } @@ -294,7 +294,7 @@ public final class Bmgr { private void doRestore() { long token; try { - token = Long.parseLong(nextArg()); + token = Long.parseLong(nextArg(), 16); } catch (NumberFormatException e) { showUsage(); return; @@ -311,12 +311,13 @@ public final class Bmgr { return; } RestoreSet[] sets = mRestore.getAvailableRestoreSets(); - for (RestoreSet s : sets) { - if (s.token == token) { - System.out.println("Scheduling restore: " + s.name); - mRestore.performRestore(token, observer); - didRestore = true; - break; + if (sets != null) { + for (RestoreSet s : sets) { + if (s.token == token) { + System.out.println("Scheduling restore: " + s.name); + didRestore = (mRestore.performRestore(token, observer) == 0); + break; + } } } if (!didRestore) { @@ -327,21 +328,27 @@ public final class Bmgr { printRestoreSets(sets); } } + + // if we kicked off a restore successfully, we have to wait for it + // to complete before we can shut down the restore session safely + if (didRestore) { + synchronized (observer) { + while (!observer.done) { + try { + observer.wait(); + } catch (InterruptedException ex) { + } + } + } + } + + // once the restore has finished, close down the session and we're done mRestore.endRestoreSession(); } catch (RemoteException e) { System.err.println(e.toString()); System.err.println(BMGR_NOT_RUNNING_ERR); } - // now wait for it to be done - synchronized (observer) { - while (!observer.done) { - try { - observer.wait(); - } catch (InterruptedException ex) { - } - } - } System.out.println("done"); } diff --git a/cmds/bootanimation/Android.mk b/cmds/bootanimation/Android.mk index 9c94c2ef3cf9..3449de1fe737 100644 --- a/cmds/bootanimation/Android.mk +++ b/cmds/bootanimation/Android.mk @@ -12,12 +12,13 @@ ifeq ($(TARGET_SIMULATOR),true) endif endif +LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES + LOCAL_SHARED_LIBRARIES := \ libcutils \ libutils \ libui \ - libcorecg \ - libsgl \ + libskia \ libEGL \ libGLESv1_CM diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp index 2fb3f7994961..99e513cc0710 100644 --- a/cmds/bootanimation/BootAnimation.cpp +++ b/cmds/bootanimation/BootAnimation.cpp @@ -14,15 +14,13 @@ * limitations under the License. */ -#define LOG_TAG "BootAnimation" - #include <stdint.h> #include <sys/types.h> #include <math.h> #include <fcntl.h> #include <utils/misc.h> -#include <utils/IPCThreadState.h> +#include <binder/IPCThreadState.h> #include <utils/threads.h> #include <utils/Atomic.h> #include <utils/Errors.h> @@ -35,7 +33,8 @@ #include <ui/DisplayInfo.h> #include <ui/ISurfaceComposer.h> #include <ui/ISurfaceFlingerClient.h> -#include <ui/EGLNativeWindowSurface.h> +#include <ui/FramebufferNativeWindow.h> +#include <ui/EGLUtils.h> #include <core/SkBitmap.h> #include <images/SkImageDecoder.h> @@ -130,15 +129,19 @@ status_t BootAnimation::readyToRun() { return -1; // create the native surface - sp<Surface> s = session()->createSurface(getpid(), 0, dinfo.w, dinfo.h, - PIXEL_FORMAT_RGB_565, ISurfaceComposer::eGPU); + sp<SurfaceControl> control = session()->createSurface( + getpid(), 0, dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565); session()->openTransaction(); - s->setLayer(0x40000000); + control->setLayer(0x40000000); session()->closeTransaction(); + sp<Surface> s = control->getSurface(); + // initialize opengl and egl - const EGLint attribs[] = { EGL_RED_SIZE, 5, EGL_GREEN_SIZE, 6, - EGL_BLUE_SIZE, 5, EGL_DEPTH_SIZE, 0, EGL_NONE }; + const EGLint attribs[] = { + EGL_DEPTH_SIZE, 0, + EGL_NONE + }; EGLint w, h, dummy; EGLint numConfigs; EGLConfig config; @@ -148,21 +151,21 @@ status_t BootAnimation::readyToRun() { EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); eglInitialize(display, 0, 0); - eglChooseConfig(display, attribs, &config, 1, &numConfigs); - - mNativeWindowSurface = new EGLNativeWindowSurface(s); - surface = eglCreateWindowSurface(display, config, - mNativeWindowSurface.get(), NULL); - + EGLUtils::selectConfigForNativeWindow(display, attribs, s.get(), &config); + surface = eglCreateWindowSurface(display, config, s.get(), NULL); context = eglCreateContext(display, config, NULL, NULL); eglQuerySurface(display, surface, EGL_WIDTH, &w); eglQuerySurface(display, surface, EGL_HEIGHT, &h); - eglMakeCurrent(display, surface, surface, context); + + if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) + return NO_INIT; + mDisplay = display; mContext = context; mSurface = surface; mWidth = w; mHeight = h; + mFlingerSurfaceControl = control; mFlingerSurface = s; // initialize GL @@ -178,8 +181,8 @@ bool BootAnimation::threadLoop() { eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglDestroyContext(mDisplay, mContext); eglDestroySurface(mDisplay, mSurface); - mNativeWindowSurface.clear(); mFlingerSurface.clear(); + mFlingerSurfaceControl.clear(); eglTerminate(mDisplay); IPCThreadState::self()->stopProcess(); return r; @@ -200,8 +203,7 @@ bool BootAnimation::android() { const Rect updateRect(xc, yc, xc + mAndroid[0].w, yc + mAndroid[0].h); // draw and update only what we need - mNativeWindowSurface->setSwapRectangle(updateRect.left, - updateRect.top, updateRect.width(), updateRect.height()); + mFlingerSurface->setSwapRectangle(updateRect); glScissor(updateRect.left, mHeight - updateRect.bottom, updateRect.width(), updateRect.height()); diff --git a/cmds/bootanimation/BootAnimation.h b/cmds/bootanimation/BootAnimation.h index 42e9eed7d3eb..796077dc3e1d 100644 --- a/cmds/bootanimation/BootAnimation.h +++ b/cmds/bootanimation/BootAnimation.h @@ -34,7 +34,6 @@ class SkBitmap; namespace android { class AssetManager; -class EGLNativeWindowSurface; // --------------------------------------------------------------------------- @@ -68,8 +67,8 @@ private: EGLDisplay mDisplay; EGLDisplay mContext; EGLDisplay mSurface; + sp<SurfaceControl> mFlingerSurfaceControl; sp<Surface> mFlingerSurface; - sp<EGLNativeWindowSurface> mNativeWindowSurface; }; // --------------------------------------------------------------------------- diff --git a/cmds/bootanimation/bootanimation_main.cpp b/cmds/bootanimation/bootanimation_main.cpp index a8359c40d0d2..3c82fe52dba9 100644 --- a/cmds/bootanimation/bootanimation_main.cpp +++ b/cmds/bootanimation/bootanimation_main.cpp @@ -18,9 +18,10 @@ #include <cutils/properties.h> -#include <utils/IPCThreadState.h> -#include <utils/ProcessState.h> -#include <utils/IServiceManager.h> +#include <binder/IPCThreadState.h> +#include <binder/ProcessState.h> +#include <binder/IServiceManager.h> + #include <utils/Log.h> #include <utils/threads.h> diff --git a/cmds/dumpsys/Android.mk b/cmds/dumpsys/Android.mk index 0c623cc319c5..42b1b7365b1b 100644 --- a/cmds/dumpsys/Android.mk +++ b/cmds/dumpsys/Android.mk @@ -5,7 +5,9 @@ LOCAL_SRC_FILES:= \ dumpsys.cpp LOCAL_SHARED_LIBRARIES := \ - libutils + libutils \ + libbinder + ifeq ($(TARGET_OS),linux) LOCAL_CFLAGS += -DXP_UNIX diff --git a/cmds/dumpsys/dumpsys.cpp b/cmds/dumpsys/dumpsys.cpp index a62fe55600e9..945a690ae0ab 100644 --- a/cmds/dumpsys/dumpsys.cpp +++ b/cmds/dumpsys/dumpsys.cpp @@ -6,9 +6,9 @@ #define LOG_TAG "dumpsys" #include <utils/Log.h> -#include <utils/Parcel.h> -#include <utils/ProcessState.h> -#include <utils/IServiceManager.h> +#include <binder/Parcel.h> +#include <binder/ProcessState.h> +#include <binder/IServiceManager.h> #include <utils/TextOutput.h> #include <utils/Vector.h> diff --git a/cmds/keystore/netkeystore.c b/cmds/keystore/netkeystore.c index 637e0d87600d..bdd5960e9cff 100644 --- a/cmds/keystore/netkeystore.c +++ b/cmds/keystore/netkeystore.c @@ -242,6 +242,7 @@ static int set_read_timeout(int socket) { struct timeval tv; tv.tv_sec = READ_TIMEOUT; + tv.tv_usec = 0; if (setsockopt(socket, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof tv)) { LOGE("setsockopt failed"); diff --git a/cmds/keystore/netkeystore.h b/cmds/keystore/netkeystore.h index a87a667e9123..d80ddae419b1 100644 --- a/cmds/keystore/netkeystore.h +++ b/cmds/keystore/netkeystore.h @@ -19,6 +19,7 @@ #define __NETKEYSTORE_H__ #include <stdio.h> +#include <arpa/inet.h> #include <cutils/sockets.h> #include <cutils/log.h> @@ -68,6 +69,8 @@ static inline int read_marshal(int s, LPC_MARSHAL *cmd) LOGE("failed to read header\n"); return -1; } + cmd->len = ntohl(cmd->len); + cmd->opcode = ntohl(cmd->opcode); if (cmd->len > BUFFER_MAX) { LOGE("invalid size %d\n", cmd->len); return -1; @@ -82,11 +85,14 @@ static inline int read_marshal(int s, LPC_MARSHAL *cmd) static inline int write_marshal(int s, LPC_MARSHAL *cmd) { + int len = cmd->len; + cmd->len = htonl(cmd->len); + cmd->opcode = htonl(cmd->opcode); if (writex(s, cmd, 2 * sizeof(uint32_t))) { LOGE("failed to write marshal header\n"); return -1; } - if (writex(s, cmd->data, cmd->len)) { + if (writex(s, cmd->data, len)) { LOGE("failed to write marshal data\n"); return -1; } diff --git a/cmds/runtime/Android.mk b/cmds/runtime/Android.mk index 521eb2b2863e..6a72d1070850 100644 --- a/cmds/runtime/Android.mk +++ b/cmds/runtime/Android.mk @@ -10,6 +10,7 @@ LOCAL_SRC_FILES:= \ LOCAL_SHARED_LIBRARIES := \ libutils \ + libbinder \ libandroid_runtime \ libcutils \ libui \ diff --git a/cmds/runtime/ServiceManager.cpp b/cmds/runtime/ServiceManager.cpp index 758a95c07d56..b2bef07ff70e 100644 --- a/cmds/runtime/ServiceManager.cpp +++ b/cmds/runtime/ServiceManager.cpp @@ -9,9 +9,9 @@ #include <utils/Debug.h> #include <utils/Log.h> -#include <utils/Parcel.h> +#include <binder/Parcel.h> #include <utils/String8.h> -#include <utils/ProcessState.h> +#include <binder/ProcessState.h> #include <private/utils/Static.h> diff --git a/cmds/runtime/ServiceManager.h b/cmds/runtime/ServiceManager.h index d09cec8ddad8..090ca6de648b 100644 --- a/cmds/runtime/ServiceManager.h +++ b/cmds/runtime/ServiceManager.h @@ -4,7 +4,7 @@ #ifndef ANDROID_SERVICE_MANAGER_H #define ANDROID_SERVICE_MANAGER_H -#include <utils/IServiceManager.h> +#include <binder/IServiceManager.h> #include <utils/KeyedVector.h> #include <utils/threads.h> diff --git a/cmds/runtime/main_runtime.cpp b/cmds/runtime/main_runtime.cpp index 476f38a4d073..21e0e4d02662 100644 --- a/cmds/runtime/main_runtime.cpp +++ b/cmds/runtime/main_runtime.cpp @@ -7,9 +7,11 @@ #include "ServiceManager.h" #include "SignalHandler.h" -#include <utils.h> -#include <utils/IPCThreadState.h> -#include <utils/ProcessState.h> +#include <utils/threads.h> +#include <utils/Errors.h> + +#include <binder/IPCThreadState.h> +#include <binder/ProcessState.h> #include <utils/Log.h> #include <cutils/zygote.h> diff --git a/cmds/service/Android.mk b/cmds/service/Android.mk index 8c5005c1fbb1..275bbb2e17be 100644 --- a/cmds/service/Android.mk +++ b/cmds/service/Android.mk @@ -4,8 +4,7 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ service.cpp -LOCAL_SHARED_LIBRARIES := \ - libutils +LOCAL_SHARED_LIBRARIES := libutils libbinder ifeq ($(TARGET_OS),linux) LOCAL_CFLAGS += -DXP_UNIX diff --git a/cmds/service/service.cpp b/cmds/service/service.cpp index 859a9bf9f93c..32db83ba1dcb 100644 --- a/cmds/service/service.cpp +++ b/cmds/service/service.cpp @@ -3,9 +3,9 @@ * */ -#include <utils/Parcel.h> -#include <utils/ProcessState.h> -#include <utils/IServiceManager.h> +#include <binder/Parcel.h> +#include <binder/ProcessState.h> +#include <binder/IServiceManager.h> #include <utils/TextOutput.h> #include <getopt.h> diff --git a/cmds/servicemanager/service_manager.c b/cmds/servicemanager/service_manager.c index e4aa8b51cf2a..f3a471394b6a 100644 --- a/cmds/servicemanager/service_manager.c +++ b/cmds/servicemanager/service_manager.c @@ -30,6 +30,7 @@ static struct { { AID_MEDIA, "media.audio_flinger" }, { AID_MEDIA, "media.player" }, { AID_MEDIA, "media.camera" }, + { AID_MEDIA, "media.audio_policy" }, { AID_RADIO, "radio.phone" }, { AID_RADIO, "radio.sms" }, { AID_RADIO, "radio.phonesubinfo" }, diff --git a/cmds/stagefright/Android.mk b/cmds/stagefright/Android.mk new file mode 100644 index 000000000000..697d67a1233e --- /dev/null +++ b/cmds/stagefright/Android.mk @@ -0,0 +1,60 @@ +LOCAL_PATH:= $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES:= \ + JPEGSource.cpp \ + stagefright.cpp + +LOCAL_SHARED_LIBRARIES := \ + libstagefright + +LOCAL_C_INCLUDES:= \ + frameworks/base/media/libstagefright \ + $(TOP)/external/opencore/extern_libs_v2/khronos/openmax/include + +LOCAL_CFLAGS += -Wno-multichar + +LOCAL_MODULE:= stagefright + +include $(BUILD_EXECUTABLE) + +################################################################################ + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES:= \ + record.cpp + +LOCAL_SHARED_LIBRARIES := \ + libstagefright + +LOCAL_C_INCLUDES:= \ + frameworks/base/media/libstagefright \ + $(TOP)/external/opencore/extern_libs_v2/khronos/openmax/include + +LOCAL_CFLAGS += -Wno-multichar + +LOCAL_MODULE:= record + +include $(BUILD_EXECUTABLE) + +################################################################################ + +# include $(CLEAR_VARS) +# +# LOCAL_SRC_FILES:= \ +# play.cpp +# +# LOCAL_SHARED_LIBRARIES := \ +# libstagefright +# +# LOCAL_C_INCLUDES:= \ +# frameworks/base/media/libstagefright \ +# $(TOP)/external/opencore/extern_libs_v2/khronos/openmax/include +# +# LOCAL_CFLAGS += -Wno-multichar +# +# LOCAL_MODULE:= play +# +# include $(BUILD_EXECUTABLE) diff --git a/cmds/stagefright/JPEGSource.cpp b/cmds/stagefright/JPEGSource.cpp new file mode 100644 index 000000000000..a7994ed3594f --- /dev/null +++ b/cmds/stagefright/JPEGSource.cpp @@ -0,0 +1,233 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// #define LOG_NDEBUG 0 +#define LOG_TAG "JPEGSource" +#include <utils/Log.h> + +#include "JPEGSource.h" + +#include <media/stagefright/DataSource.h> +#include <media/stagefright/MediaBufferGroup.h> +#include <media/stagefright/MediaDebug.h> +#include <media/stagefright/MediaErrors.h> +#include <media/stagefright/MetaData.h> + +#define JPEG_SOF0 0xC0 /* nStart Of Frame N*/ +#define JPEG_SOF1 0xC1 /* N indicates which compression process*/ +#define JPEG_SOF2 0xC2 /* Only SOF0-SOF2 are now in common use*/ +#define JPEG_SOF3 0xC3 +#define JPEG_SOF5 0xC5 /* NB: codes C4 and CC are NOT SOF markers*/ +#define JPEG_SOF6 0xC6 +#define JPEG_SOF7 0xC7 +#define JPEG_SOF9 0xC9 +#define JPEG_SOF10 0xCA +#define JPEG_SOF11 0xCB +#define JPEG_SOF13 0xCD +#define JPEG_SOF14 0xCE +#define JPEG_SOF15 0xCF +#define JPEG_SOI 0xD8 /* nStart Of Image (beginning of datastream)*/ +#define JPEG_EOI 0xD9 /* End Of Image (end of datastream)*/ +#define JPEG_SOS 0xDA /* nStart Of Scan (begins compressed data)*/ +#define JPEG_JFIF 0xE0 /* Jfif marker*/ +#define JPEG_EXIF 0xE1 /* Exif marker*/ +#define JPEG_COM 0xFE /* COMment */ +#define JPEG_DQT 0xDB +#define JPEG_DHT 0xC4 +#define JPEG_DRI 0xDD + +namespace android { + +JPEGSource::JPEGSource(const sp<DataSource> &source) + : mSource(source), + mGroup(NULL), + mStarted(false), + mSize(0), + mWidth(0), + mHeight(0), + mOffset(0) { + CHECK_EQ(parseJPEG(), OK); + CHECK(mSource->getSize(&mSize) == OK); +} + +JPEGSource::~JPEGSource() { + if (mStarted) { + stop(); + } +} + +status_t JPEGSource::start(MetaData *) { + if (mStarted) { + return UNKNOWN_ERROR; + } + + mGroup = new MediaBufferGroup; + mGroup->add_buffer(new MediaBuffer(mSize)); + + mOffset = 0; + + mStarted = true; + + return OK; +} + +status_t JPEGSource::stop() { + if (!mStarted) { + return UNKNOWN_ERROR; + } + + delete mGroup; + mGroup = NULL; + + mStarted = false; + + return OK; +} + +sp<MetaData> JPEGSource::getFormat() { + sp<MetaData> meta = new MetaData; + meta->setCString(kKeyMIMEType, "image/jpeg"); + meta->setInt32(kKeyWidth, mWidth); + meta->setInt32(kKeyHeight, mHeight); + meta->setInt32(kKeyCompressedSize, mSize); + + return meta; +} + +status_t JPEGSource::read( + MediaBuffer **out, const ReadOptions *options) { + *out = NULL; + + int64_t seekTimeUs; + if (options != NULL && options->getSeekTo(&seekTimeUs)) { + return UNKNOWN_ERROR; + } + + MediaBuffer *buffer; + mGroup->acquire_buffer(&buffer); + + ssize_t n = mSource->read_at(mOffset, buffer->data(), mSize - mOffset); + + if (n <= 0) { + buffer->release(); + buffer = NULL; + + return UNKNOWN_ERROR; + } + + buffer->set_range(0, n); + + mOffset += n; + + *out = buffer; + + return OK; +} + +status_t JPEGSource::parseJPEG() { + mWidth = 0; + mHeight = 0; + + off_t i = 0; + + uint16_t soi; + if (!mSource->getUInt16(i, &soi)) { + return ERROR_IO; + } + + i += 2; + + if (soi != 0xffd8) { + return UNKNOWN_ERROR; + } + + for (;;) { + uint8_t marker; + if (mSource->read_at(i++, &marker, 1) != 1) { + return ERROR_IO; + } + + CHECK_EQ(marker, 0xff); + + if (mSource->read_at(i++, &marker, 1) != 1) { + return ERROR_IO; + } + + CHECK(marker != 0xff); + + uint16_t chunkSize; + if (!mSource->getUInt16(i, &chunkSize)) { + return ERROR_IO; + } + + i += 2; + + if (chunkSize < 2) { + return UNKNOWN_ERROR; + } + + switch (marker) { + case JPEG_SOS: + { + return (mWidth > 0 && mHeight > 0) ? OK : UNKNOWN_ERROR; + } + + case JPEG_EOI: + { + return UNKNOWN_ERROR; + } + + case JPEG_SOF0: + case JPEG_SOF1: + case JPEG_SOF3: + case JPEG_SOF5: + case JPEG_SOF6: + case JPEG_SOF7: + case JPEG_SOF9: + case JPEG_SOF10: + case JPEG_SOF11: + case JPEG_SOF13: + case JPEG_SOF14: + case JPEG_SOF15: + { + uint16_t width, height; + if (!mSource->getUInt16(i + 1, &height) + || !mSource->getUInt16(i + 3, &width)) { + return ERROR_IO; + } + + mWidth = width; + mHeight = height; + + i += chunkSize - 2; + break; + } + + default: + { + // Skip chunk + + i += chunkSize - 2; + + break; + } + } + } + + return OK; +} + +} // namespace android diff --git a/cmds/stagefright/JPEGSource.h b/cmds/stagefright/JPEGSource.h new file mode 100644 index 000000000000..051c0346f51a --- /dev/null +++ b/cmds/stagefright/JPEGSource.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef JPEG_SOURCE_H_ + +#define JPEG_SOURCE_H_ + +#include <media/stagefright/MediaSource.h> + +namespace android { + +class DataSource; +class MediaBufferGroup; + +struct JPEGSource : public MediaSource { + // Assumes ownership of "source". + JPEGSource(const sp<DataSource> &source); + + virtual status_t start(MetaData *params = NULL); + virtual status_t stop(); + virtual sp<MetaData> getFormat(); + + virtual status_t read( + MediaBuffer **buffer, const ReadOptions *options = NULL); + +protected: + virtual ~JPEGSource(); + +private: + sp<DataSource> mSource; + MediaBufferGroup *mGroup; + bool mStarted; + off_t mSize; + int32_t mWidth, mHeight; + off_t mOffset; + + status_t parseJPEG(); + + JPEGSource(const JPEGSource &); + JPEGSource &operator=(const JPEGSource &); +}; + +} // namespace android + +#endif // JPEG_SOURCE_H_ + diff --git a/cmds/stagefright/WaveWriter.h b/cmds/stagefright/WaveWriter.h new file mode 100644 index 000000000000..a0eb66e2b9bc --- /dev/null +++ b/cmds/stagefright/WaveWriter.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_WAVEWRITER_H_ + +#define ANDROID_WAVEWRITER_H_ + +namespace android { + +class WaveWriter { +public: + WaveWriter(const char *filename, + uint16_t num_channels, uint32_t sampling_rate) + : mFile(fopen(filename, "wb")), + mTotalBytes(0) { + fwrite("RIFFxxxxWAVEfmt \x10\x00\x00\x00\x01\x00", 1, 22, mFile); + write_u16(num_channels); + write_u32(sampling_rate); + write_u32(sampling_rate * num_channels * 2); + write_u16(num_channels * 2); + write_u16(16); + fwrite("dataxxxx", 1, 8, mFile); + } + + ~WaveWriter() { + fseek(mFile, 40, SEEK_SET); + write_u32(mTotalBytes); + + fseek(mFile, 4, SEEK_SET); + write_u32(36 + mTotalBytes); + + fclose(mFile); + mFile = NULL; + } + + void Append(const void *data, size_t size) { + fwrite(data, 1, size, mFile); + mTotalBytes += size; + } + +private: + void write_u16(uint16_t x) { + fputc(x & 0xff, mFile); + fputc(x >> 8, mFile); + } + + void write_u32(uint32_t x) { + write_u16(x & 0xffff); + write_u16(x >> 16); + } + + FILE *mFile; + size_t mTotalBytes; +}; + +} // namespace android + +#endif // ANDROID_WAVEWRITER_H_ diff --git a/cmds/stagefright/play.cpp b/cmds/stagefright/play.cpp new file mode 100644 index 000000000000..c6e778e1361d --- /dev/null +++ b/cmds/stagefright/play.cpp @@ -0,0 +1,295 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <binder/ProcessState.h> +#include <media/stagefright/OMXClient.h> +#include <media/stagefright/TimedEventQueue.h> +#include <media/stagefright/MPEG4Extractor.h> +#include <media/stagefright/MediaSource.h> +#include <media/stagefright/MetaData.h> +#include <media/stagefright/MmapSource.h> +#include <media/stagefright/OMXDecoder.h> + +using namespace android; + +struct NewPlayer { + NewPlayer(); + ~NewPlayer(); + + void setSource(const char *uri); + void start(); + void pause(); + void stop(); + +private: + struct PlayerEvent : public TimedEventQueue::Event { + PlayerEvent(NewPlayer *player, + void (NewPlayer::*method)(int64_t realtime_us)) + : mPlayer(player), + mMethod(method) { + } + + virtual void fire(TimedEventQueue *queue, int64_t realtime_us) { + (mPlayer->*mMethod)(realtime_us); + } + + private: + NewPlayer *mPlayer; + void (NewPlayer::*mMethod)(int64_t realtime_us); + + PlayerEvent(const PlayerEvent &); + PlayerEvent &operator=(const PlayerEvent &); + }; + + struct PlayVideoFrameEvent : public TimedEventQueue::Event { + PlayVideoFrameEvent(NewPlayer *player, MediaBuffer *buffer) + : mPlayer(player), + mBuffer(buffer) { + } + + virtual ~PlayVideoFrameEvent() { + if (mBuffer != NULL) { + mBuffer->release(); + mBuffer = NULL; + } + } + + virtual void fire(TimedEventQueue *queue, int64_t realtime_us) { + mPlayer->onPlayVideoFrame(realtime_us, mBuffer); + mBuffer = NULL; + } + + private: + NewPlayer *mPlayer; + MediaBuffer *mBuffer; + + PlayVideoFrameEvent(const PlayVideoFrameEvent &); + PlayVideoFrameEvent &operator=(const PlayVideoFrameEvent &); + }; + + OMXClient mClient; + + MPEG4Extractor *mExtractor; + MediaSource *mAudioSource; + OMXDecoder *mAudioDecoder; + MediaSource *mVideoSource; + OMXDecoder *mVideoDecoder; + + int32_t mVideoWidth, mVideoHeight; + + TimedEventQueue mQueue; + wp<TimedEventQueue::Event> mPlayVideoFrameEvent; + + int64_t mMediaTimeUsStart; + int64_t mRealTimeUsStart; + + void setAudioSource(MediaSource *source); + void setVideoSource(MediaSource *source); + + int64_t approxRealTime(int64_t mediatime_us) const; + + void onStart(int64_t realtime_us); + void onPause(int64_t realtime_us); + void onFetchVideoFrame(int64_t realtime_us); + void onPlayVideoFrame(int64_t realtime_us, MediaBuffer *buffer); + + static int64_t getMediaBufferTimeUs(MediaBuffer *buffer); + + NewPlayer(const NewPlayer &); + NewPlayer &operator=(const NewPlayer &); +}; + +NewPlayer::NewPlayer() + : mExtractor(NULL), + mAudioSource(NULL), + mAudioDecoder(NULL), + mVideoSource(NULL), + mVideoDecoder(NULL), + mVideoWidth(0), + mVideoHeight(0) { + status_t err = mClient.connect(); + assert(err == OK); +} + +NewPlayer::~NewPlayer() { + stop(); + + mClient.disconnect(); +} + +void NewPlayer::setSource(const char *uri) { + stop(); + + mExtractor = new MPEG4Extractor(new MmapSource(uri)); + + int num_tracks; + status_t err = mExtractor->countTracks(&num_tracks); + assert(err == OK); + + for (int i = 0; i < num_tracks; ++i) { + const sp<MetaData> meta = mExtractor->getTrackMetaData(i); + assert(meta != NULL); + + const char *mime; + if (!meta->findCString(kKeyMIMEType, &mime)) { + continue; + } + + bool is_audio = false; + bool is_acceptable = false; + if (!strncasecmp(mime, "audio/", 6)) { + is_audio = true; + is_acceptable = (mAudioSource == NULL); + } else if (!strncasecmp(mime, "video/", 6)) { + is_acceptable = (mVideoSource == NULL); + } + + if (!is_acceptable) { + continue; + } + + MediaSource *source; + if (mExtractor->getTrack(i, &source) != OK) { + continue; + } + + if (is_audio) { + setAudioSource(source); + } else { + setVideoSource(source); + } + } +} + +void NewPlayer::setAudioSource(MediaSource *source) { + mAudioSource = source; + + sp<MetaData> meta = source->getFormat(); + + mAudioDecoder = OMXDecoder::Create(&mClient, meta); + mAudioDecoder->setSource(source); +} + +void NewPlayer::setVideoSource(MediaSource *source) { + mVideoSource = source; + + sp<MetaData> meta = source->getFormat(); + + bool success = meta->findInt32(kKeyWidth, &mVideoWidth); + assert(success); + + success = meta->findInt32(kKeyHeight, &mVideoHeight); + assert(success); + + mVideoDecoder = OMXDecoder::Create(&mClient, meta); + mVideoDecoder->setSource(source); +} + +void NewPlayer::start() { + mQueue.start(); + mQueue.postEvent(new PlayerEvent(this, &NewPlayer::onStart)); +} + +void NewPlayer::pause() { + mQueue.postEvent(new PlayerEvent(this, &NewPlayer::onPause)); +} + +void NewPlayer::stop() { + mQueue.stop(); + + delete mVideoDecoder; + mVideoDecoder = NULL; + delete mVideoSource; + mVideoSource = NULL; + mVideoWidth = mVideoHeight = 0; + + delete mAudioDecoder; + mAudioDecoder = NULL; + delete mAudioSource; + mAudioSource = NULL; + + delete mExtractor; + mExtractor = NULL; +} + +int64_t NewPlayer::approxRealTime(int64_t mediatime_us) const { + return mRealTimeUsStart + (mediatime_us - mMediaTimeUsStart); +} + +void NewPlayer::onStart(int64_t realtime_us) { + mRealTimeUsStart = TimedEventQueue::getRealTimeUs(); + + if (mVideoDecoder != NULL) { + mQueue.postEvent(new PlayerEvent(this, &NewPlayer::onFetchVideoFrame)); + } +} + +void NewPlayer::onFetchVideoFrame(int64_t realtime_us) { + MediaBuffer *buffer; + status_t err = mVideoDecoder->read(&buffer); + assert(err == OK); + + int64_t mediatime_us = getMediaBufferTimeUs(buffer); + + sp<TimedEventQueue::Event> event = new PlayVideoFrameEvent(this, buffer); + mPlayVideoFrameEvent = event; + + mQueue.postTimedEvent(event, approxRealTime(mediatime_us)); +} + +// static +int64_t NewPlayer::getMediaBufferTimeUs(MediaBuffer *buffer) { + int32_t units, scale; + bool success = + buffer->meta_data()->findInt32(kKeyTimeUnits, &units); + assert(success); + success = + buffer->meta_data()->findInt32(kKeyTimeScale, &scale); + assert(success); + + return (int64_t)units * 1000000 / scale; +} + +void NewPlayer::onPlayVideoFrame(int64_t realtime_us, MediaBuffer *buffer) { + LOGI("playing video frame (mediatime: %.2f sec)\n", + getMediaBufferTimeUs(buffer) / 1E6); + fflush(stdout); + + buffer->release(); + buffer = NULL; + + mQueue.postEvent(new PlayerEvent(this, &NewPlayer::onFetchVideoFrame)); +} + +void NewPlayer::onPause(int64_t realtime_us) { +} + +int main(int argc, char **argv) { + android::ProcessState::self()->startThreadPool(); + + if (argc != 2) { + fprintf(stderr, "usage: %s filename\n", argv[0]); + return 1; + } + + NewPlayer player; + player.setSource(argv[1]); + player.start(); + sleep(10); + player.stop(); + + return 0; +} diff --git a/cmds/stagefright/record.cpp b/cmds/stagefright/record.cpp new file mode 100644 index 000000000000..cf2962bccb0e --- /dev/null +++ b/cmds/stagefright/record.cpp @@ -0,0 +1,222 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#undef NDEBUG +#include <assert.h> + +#include <binder/ProcessState.h> +#include <media/stagefright/CameraSource.h> +#include <media/stagefright/MediaBufferGroup.h> +#include <media/stagefright/MetaData.h> +#include <media/stagefright/MPEG4Extractor.h> +#include <media/stagefright/MPEG4Writer.h> +#include <media/stagefright/MmapSource.h> +#include <media/stagefright/OMXClient.h> +#include <media/stagefright/OMXCodec.h> +#include <media/stagefright/OMXDecoder.h> + +using namespace android; + +class DummySource : public MediaSource { +public: + DummySource(int width, int height) + : mWidth(width), + mHeight(height), + mSize((width * height * 3) / 2) { + mGroup.add_buffer(new MediaBuffer(mSize)); + } + + virtual sp<MetaData> getFormat() { + sp<MetaData> meta = new MetaData; + meta->setInt32(kKeyWidth, mWidth); + meta->setInt32(kKeyHeight, mHeight); + meta->setCString(kKeyMIMEType, "video/raw"); + + return meta; + } + + virtual status_t getMaxSampleSize(size_t *max_size) { + *max_size = mSize; + return OK; + } + + virtual status_t start(MetaData *params) { + return OK; + } + + virtual status_t stop() { + return OK; + } + + virtual status_t read( + MediaBuffer **buffer, const MediaSource::ReadOptions *options) { + status_t err = mGroup.acquire_buffer(buffer); + if (err != OK) { + return err; + } + + char x = (char)((double)rand() / RAND_MAX * 255); + memset((*buffer)->data(), x, mSize); + (*buffer)->set_range(0, mSize); + + return OK; + } + +protected: + virtual ~DummySource() {} + +private: + MediaBufferGroup mGroup; + int mWidth, mHeight; + size_t mSize; + + DummySource(const DummySource &); + DummySource &operator=(const DummySource &); +}; + +#define USE_OMX_CODEC 1 + +sp<MediaSource> createSource(const char *filename) { + sp<MediaSource> source; + + sp<MPEG4Extractor> extractor = + new MPEG4Extractor(new MmapSource(filename)); + + size_t num_tracks = extractor->countTracks(); + + sp<MetaData> meta; + for (size_t i = 0; i < num_tracks; ++i) { + meta = extractor->getTrackMetaData(i); + assert(meta.get() != NULL); + + const char *mime; + if (!meta->findCString(kKeyMIMEType, &mime)) { + continue; + } + + if (strncasecmp(mime, "video/", 6)) { + continue; + } + + source = extractor->getTrack(i); + break; + } + + return source; +} + +int main(int argc, char **argv) { + android::ProcessState::self()->startThreadPool(); + +#if 1 + if (argc != 2) { + fprintf(stderr, "usage: %s filename\n", argv[0]); + return 1; + } + + OMXClient client; + assert(client.connect() == android::OK); + +#if 0 + sp<MediaSource> source = createSource(argv[1]); + + if (source == NULL) { + fprintf(stderr, "Unable to find a suitable video track.\n"); + return 1; + } + + sp<MetaData> meta = source->getFormat(); + +#if USE_OMX_CODEC + sp<OMXCodec> decoder = OMXCodec::Create( + client.interface(), meta, false /* createEncoder */, source); +#else + sp<OMXDecoder> decoder = OMXDecoder::Create( + &client, meta, false /* createEncoder */, source); +#endif + + int width, height; + bool success = meta->findInt32(kKeyWidth, &width); + success = success && meta->findInt32(kKeyHeight, &height); + assert(success); +#else + int width = 320; + int height = 240; + sp<MediaSource> decoder = new DummySource(width, height); +#endif + + sp<MetaData> enc_meta = new MetaData; + // enc_meta->setCString(kKeyMIMEType, "video/3gpp"); + enc_meta->setCString(kKeyMIMEType, "video/mp4v-es"); + enc_meta->setInt32(kKeyWidth, width); + enc_meta->setInt32(kKeyHeight, height); + +#if USE_OMX_CODEC + sp<OMXCodec> encoder = + OMXCodec::Create( + client.interface(), enc_meta, true /* createEncoder */, decoder); +#else + sp<OMXDecoder> encoder = OMXDecoder::Create( + &client, enc_meta, true /* createEncoder */, decoder); +#endif + +#if 1 + sp<MPEG4Writer> writer = new MPEG4Writer("/sdcard/output.mp4"); + writer->addSource(enc_meta, encoder); + writer->start(); + sleep(20); + printf("stopping now.\n"); + writer->stop(); +#else + encoder->start(); + + MediaBuffer *buffer; + while (encoder->read(&buffer) == ::OK) { + printf("got an output frame of size %d\n", buffer->range_length()); + + buffer->release(); + buffer = NULL; + } + + encoder->stop(); +#endif + + client.disconnect(); +#endif + +#if 0 + CameraSource *source = CameraSource::Create(); + printf("source = %p\n", source); + + for (int i = 0; i < 100; ++i) { + MediaBuffer *buffer; + status_t err = source->read(&buffer); + assert(err == OK); + + printf("got a frame, data=%p, size=%d\n", + buffer->data(), buffer->range_length()); + + buffer->release(); + buffer = NULL; + } + + delete source; + source = NULL; +#endif + + return 0; +} + diff --git a/cmds/stagefright/stagefright.cpp b/cmds/stagefright/stagefright.cpp new file mode 100644 index 000000000000..6b2d8ad37002 --- /dev/null +++ b/cmds/stagefright/stagefright.cpp @@ -0,0 +1,246 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <sys/time.h> + +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#include <binder/IServiceManager.h> +#include <binder/ProcessState.h> +#include <media/IMediaPlayerService.h> +#include <media/stagefright/CachingDataSource.h> +#include <media/stagefright/HTTPDataSource.h> +#include <media/stagefright/MediaDebug.h> +#include <media/stagefright/MediaPlayerImpl.h> +#include <media/stagefright/MediaExtractor.h> +#include <media/stagefright/MediaSource.h> +#include <media/stagefright/MetaData.h> +#include <media/stagefright/MmapSource.h> +#include <media/stagefright/OMXClient.h> +#include <media/stagefright/OMXCodec.h> +#include <media/stagefright/OMXDecoder.h> + +#include "JPEGSource.h" + +using namespace android; + +static long gNumRepetitions; + +static int64_t getNowUs() { + struct timeval tv; + gettimeofday(&tv, NULL); + + return (int64_t)tv.tv_usec + tv.tv_sec * 1000000; +} + +#define USE_OMX_CODEC 1 + +static void playSource(OMXClient *client, const sp<MediaSource> &source) { + sp<MetaData> meta = source->getFormat(); + +#if !USE_OMX_CODEC + sp<OMXDecoder> decoder = OMXDecoder::Create( + client, meta, false /* createEncoder */, source); +#else + sp<OMXCodec> decoder = OMXCodec::Create( + client->interface(), meta, false /* createEncoder */, source); +#endif + + if (decoder == NULL) { + return; + } + + decoder->start(); + + int n = 0; + int64_t startTime = getNowUs(); + + long numIterationsLeft = gNumRepetitions; + MediaSource::ReadOptions options; + + while (numIterationsLeft-- > 0) { + MediaBuffer *buffer; + + for (;;) { + status_t err = decoder->read(&buffer, &options); + options.clearSeekTo(); + + if (err != OK) { + CHECK_EQ(buffer, NULL); + break; + } + + if ((n++ % 16) == 0) { + printf("."); + fflush(stdout); + } + + buffer->release(); + buffer = NULL; + } + + printf("$"); + fflush(stdout); + + options.setSeekTo(0); + } + + decoder->stop(); + printf("\n"); + + int64_t delay = getNowUs() - startTime; + printf("avg. %.2f fps\n", n * 1E6 / delay); + + printf("decoded a total of %d frame(s).\n", n); +} + +static void usage(const char *me) { + fprintf(stderr, "usage: %s\n", me); + fprintf(stderr, " -h(elp)\n"); + fprintf(stderr, " -a(udio)\n"); + fprintf(stderr, " -n repetitions\n"); + fprintf(stderr, " -l(ist) components\n"); +} + +int main(int argc, char **argv) { + android::ProcessState::self()->startThreadPool(); + + bool audioOnly = false; + bool listComponents = false; + gNumRepetitions = 1; + + int res; + while ((res = getopt(argc, argv, "han:l")) >= 0) { + switch (res) { + case 'a': + { + audioOnly = true; + break; + } + + case 'l': + { + listComponents = true; + break; + } + + case 'n': + { + char *end; + long x = strtol(optarg, &end, 10); + + if (*end != '\0' || end == optarg || x <= 0) { + x = 1; + } + + gNumRepetitions = x; + break; + } + + case '?': + case 'h': + default: + { + usage(argv[0]); + exit(1); + break; + } + } + } + + argc -= optind; + argv += optind; + + if (listComponents) { + sp<IServiceManager> sm = defaultServiceManager(); + sp<IBinder> binder = sm->getService(String16("media.player")); + sp<IMediaPlayerService> service = interface_cast<IMediaPlayerService>(binder); + + CHECK(service.get() != NULL); + + sp<IOMX> omx = service->createOMX(); + CHECK(omx.get() != NULL); + + List<String8> list; + omx->list_nodes(&list); + + for (List<String8>::iterator it = list.begin(); + it != list.end(); ++it) { + printf("%s\n", (*it).string()); + } + } + + DataSource::RegisterDefaultSniffers(); + + OMXClient client; + status_t err = client.connect(); + + for (int k = 0; k < argc; ++k) { + const char *filename = argv[k]; + + sp<DataSource> dataSource; + if (!strncasecmp("http://", filename, 7)) { + dataSource = new HTTPDataSource(filename); + dataSource = new CachingDataSource(dataSource, 64 * 1024, 10); + } else { + dataSource = new MmapSource(filename); + } + + bool isJPEG = false; + + size_t len = strlen(filename); + if (len >= 4 && !strcasecmp(filename + len - 4, ".jpg")) { + isJPEG = true; + } + + sp<MediaSource> mediaSource; + + if (isJPEG) { + mediaSource = new JPEGSource(dataSource); + } else { + sp<MediaExtractor> extractor = MediaExtractor::Create(dataSource); + + size_t numTracks = extractor->countTracks(); + + sp<MetaData> meta; + size_t i; + for (i = 0; i < numTracks; ++i) { + meta = extractor->getTrackMetaData(i); + + const char *mime; + meta->findCString(kKeyMIMEType, &mime); + + if (audioOnly && !strncasecmp(mime, "audio/", 6)) { + break; + } + + if (!audioOnly && !strncasecmp(mime, "video/", 6)) { + break; + } + } + + mediaSource = extractor->getTrack(i); + } + + playSource(&client, mediaSource); + } + + client.disconnect(); + + return 0; +} diff --git a/cmds/surfaceflinger/Android.mk b/cmds/surfaceflinger/Android.mk index 37c3d942414a..bfa58a1cbf7f 100644 --- a/cmds/surfaceflinger/Android.mk +++ b/cmds/surfaceflinger/Android.mk @@ -6,6 +6,7 @@ LOCAL_SRC_FILES:= \ LOCAL_SHARED_LIBRARIES := \ libsurfaceflinger \ + libbinder \ libutils LOCAL_C_INCLUDES := \ diff --git a/cmds/surfaceflinger/main_surfaceflinger.cpp b/cmds/surfaceflinger/main_surfaceflinger.cpp index 7c895783d762..d65072132783 100644 --- a/cmds/surfaceflinger/main_surfaceflinger.cpp +++ b/cmds/surfaceflinger/main_surfaceflinger.cpp @@ -1,6 +1,6 @@ -#include <utils/IPCThreadState.h> -#include <utils/ProcessState.h> -#include <utils/IServiceManager.h> +#include <binder/IPCThreadState.h> +#include <binder/ProcessState.h> +#include <binder/IServiceManager.h> #include <utils/Log.h> #include <SurfaceFlinger.h> diff --git a/cmds/svc/src/com/android/commands/svc/PowerCommand.java b/cmds/svc/src/com/android/commands/svc/PowerCommand.java index 2b54f549f389..e021012268c9 100644 --- a/cmds/svc/src/com/android/commands/svc/PowerCommand.java +++ b/cmds/svc/src/com/android/commands/svc/PowerCommand.java @@ -16,7 +16,10 @@ package com.android.commands.svc; +import android.os.Binder; +import android.os.IBinder; import android.os.IPowerManager; +import android.os.PowerManager; import android.os.ServiceManager; import android.os.RemoteException; import android.os.BatteryManager; @@ -60,7 +63,10 @@ public class PowerCommand extends Svc.Command { IPowerManager pm = IPowerManager.Stub.asInterface(ServiceManager.getService(Context.POWER_SERVICE)); try { + IBinder lock = new Binder(); + pm.acquireWakeLock(PowerManager.FULL_WAKE_LOCK, lock, "svc power"); pm.setStayOnSetting(val); + pm.releaseWakeLock(lock); } catch (RemoteException e) { System.err.println("Faild to set setting: " + e); diff --git a/cmds/system_server/Android.mk b/cmds/system_server/Android.mk index 0a684e86b1c7..ad537977d9eb 100644 --- a/cmds/system_server/Android.mk +++ b/cmds/system_server/Android.mk @@ -6,6 +6,7 @@ LOCAL_SRC_FILES:= \ LOCAL_SHARED_LIBRARIES := \ libutils \ + libbinder \ libsystem_server LOCAL_C_INCLUDES := \ diff --git a/cmds/system_server/library/Android.mk b/cmds/system_server/library/Android.mk index 580331a695af..1813d3e5ab0c 100644 --- a/cmds/system_server/library/Android.mk +++ b/cmds/system_server/library/Android.mk @@ -20,6 +20,7 @@ LOCAL_SHARED_LIBRARIES := \ libcameraservice \ libmediaplayerservice \ libutils \ + libbinder \ libcutils LOCAL_MODULE:= libsystem_server diff --git a/cmds/system_server/library/system_init.cpp b/cmds/system_server/library/system_init.cpp index 73b23e27e3bd..1d57fdcc4c77 100644 --- a/cmds/system_server/library/system_init.cpp +++ b/cmds/system_server/library/system_init.cpp @@ -8,15 +8,16 @@ #define LOG_TAG "sysproc" -#include <utils/IPCThreadState.h> -#include <utils/ProcessState.h> -#include <utils/IServiceManager.h> +#include <binder/IPCThreadState.h> +#include <binder/ProcessState.h> +#include <binder/IServiceManager.h> #include <utils/TextOutput.h> #include <utils/Log.h> #include <SurfaceFlinger.h> #include <AudioFlinger.h> #include <CameraService.h> +#include <AudioPolicyService.h> #include <MediaPlayerService.h> #include <android_runtime/AndroidRuntime.h> @@ -80,6 +81,9 @@ extern "C" status_t system_init() // Start the camera service CameraService::instantiate(); + + // Start the audio policy service + AudioPolicyService::instantiate(); } // And now start the Android runtime. We have to do this bit diff --git a/cmds/system_server/system_main.cpp b/cmds/system_server/system_main.cpp index ca16e5700622..543f650a4d22 100644 --- a/cmds/system_server/system_main.cpp +++ b/cmds/system_server/system_main.cpp @@ -9,7 +9,7 @@ #define LOG_TAG "sysproc" -#include <utils/IPCThreadState.h> +#include <binder/IPCThreadState.h> #include <utils/Log.h> #include <private/android_filesystem_config.h> |