Merge "Add a new permission for user space VPN applications."
diff --git a/api/current.txt b/api/current.txt
index 91dbd4b..630c6c7 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -476,6 +476,7 @@
field public static final int hint = 16843088; // 0x1010150
field public static final int homeAsUpIndicator = 16843531; // 0x101030b
field public static final int homeLayout = 16843549; // 0x101031d
+ field public static final int horizontalDirection = 16843628; // 0x101036c
field public static final int horizontalDivider = 16843053; // 0x101012d
field public static final int horizontalGap = 16843327; // 0x101023f
field public static final int horizontalScrollViewStyle = 16843603; // 0x1010353
@@ -10951,6 +10952,7 @@
public class TrafficStats {
ctor public TrafficStats();
+ method public static void clearThreadStatsTag();
method public static long getMobileRxBytes();
method public static long getMobileRxPackets();
method public static long getMobileTxBytes();
@@ -10971,6 +10973,9 @@
method public static long getUidUdpRxPackets(int);
method public static long getUidUdpTxBytes(int);
method public static long getUidUdpTxPackets(int);
+ method public static void setThreadStatsTag(java.lang.String);
+ method public static void tagSocket(java.net.Socket) throws java.net.SocketException;
+ method public static void untagSocket(java.net.Socket) throws java.net.SocketException;
field public static final int UNSUPPORTED = -1; // 0xffffffff
}
diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c
index 53cae41..b0d764f 100644
--- a/cmds/dumpstate/dumpstate.c
+++ b/cmds/dumpstate/dumpstate.c
@@ -133,6 +133,13 @@
"su", "root", "wlutil", "counters", NULL);
#endif
+ char ril_dumpstate_timeout[PROPERTY_VALUE_MAX] = {0};
+ property_get("ril.dumpstate.timeout", ril_dumpstate_timeout, "30");
+ if (strlen(ril_dumpstate_timeout) > 0) {
+ run_command("DUMP VENDOR RIL LOGS", atoi(ril_dumpstate_timeout),
+ "su", "root", "vril-dump", NULL);
+ }
+
print_properties();
run_command("KERNEL LOG", 20, "dmesg", NULL);
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 02b6619..87369ab 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -1760,6 +1760,11 @@
*/
private void initActionBar() {
Window window = getWindow();
+
+ // Initializing the window decor can change window feature flags.
+ // Make sure that we have the correct set before performing the test below.
+ window.getDecorView();
+
if (isChild() || !window.hasFeature(Window.FEATURE_ACTION_BAR) || mActionBar != null) {
return;
}
diff --git a/core/java/android/gesture/Gesture.java b/core/java/android/gesture/Gesture.java
index 300cd28..c6a2a87 100755
--- a/core/java/android/gesture/Gesture.java
+++ b/core/java/android/gesture/Gesture.java
@@ -36,7 +36,7 @@
/**
* A gesture is a hand-drawn shape on a touch screen. It can have one or multiple strokes.
* Each stroke is a sequence of timed points. A user-defined gesture can be recognized by
- * a GestureLibrary and a built-in alphabet gesture can be recognized by a LetterRecognizer.
+ * a GestureLibrary.
*/
public class Gesture implements Parcelable {
diff --git a/core/java/android/net/TrafficStats.java b/core/java/android/net/TrafficStats.java
index eca06c5..7ee7a81 100644
--- a/core/java/android/net/TrafficStats.java
+++ b/core/java/android/net/TrafficStats.java
@@ -16,11 +16,10 @@
package android.net;
-import android.util.Log;
+import dalvik.system.BlockGuard;
-import java.io.File;
-import java.io.RandomAccessFile;
-import java.io.IOException;
+import java.net.Socket;
+import java.net.SocketException;
/**
* Class that provides network traffic statistics. These statistics include
@@ -37,6 +36,63 @@
public final static int UNSUPPORTED = -1;
/**
+ * Set active tag to use when accounting {@link Socket} traffic originating
+ * from the current thread. Only one active tag per thread is supported.
+ * <p>
+ * Changes only take effect during subsequent calls to
+ * {@link #tagSocket(Socket)}.
+ */
+ public static void setThreadStatsTag(String tag) {
+ BlockGuard.setThreadSocketStatsTag(tag);
+ }
+
+ public static void clearThreadStatsTag() {
+ BlockGuard.setThreadSocketStatsTag(null);
+ }
+
+ /**
+ * Set specific UID to use when accounting {@link Socket} traffic
+ * originating from the current thread. Designed for use when performing an
+ * operation on behalf of another application.
+ * <p>
+ * Changes only take effect during subsequent calls to
+ * {@link #tagSocket(Socket)}.
+ * <p>
+ * To take effect, caller must hold
+ * {@link android.Manifest.permission#UPDATE_DEVICE_STATS} permission.
+ *
+ * {@hide}
+ */
+ public static void setThreadStatsUid(int uid) {
+ BlockGuard.setThreadSocketStatsUid(uid);
+ }
+
+ /** {@hide} */
+ public static void clearThreadStatsUid() {
+ BlockGuard.setThreadSocketStatsUid(-1);
+ }
+
+ /**
+ * Tag the given {@link Socket} with any statistics parameters active for
+ * the current thread. Subsequent calls always replace any existing
+ * parameters. When finished, call {@link #untagSocket(Socket)} to remove
+ * statistics parameters.
+ *
+ * @see #setThreadStatsTag(String)
+ * @see #setThreadStatsUid(int)
+ */
+ public static void tagSocket(Socket socket) throws SocketException {
+ BlockGuard.tagSocketFd(socket.getFileDescriptor$());
+ }
+
+ /**
+ * Remove any statistics parameters from the given {@link Socket}.
+ */
+ public static void untagSocket(Socket socket) throws SocketException {
+ BlockGuard.untagSocketFd(socket.getFileDescriptor$());
+ }
+
+ /**
* Get the total number of packets transmitted through the mobile interface.
*
* @return number of packets. If the statistics are not supported by this device,
diff --git a/core/java/android/os/Environment.java b/core/java/android/os/Environment.java
index e308c2c..6b58877 100644
--- a/core/java/android/os/Environment.java
+++ b/core/java/android/os/Environment.java
@@ -16,12 +16,13 @@
package android.os;
-import java.io.File;
-
import android.content.res.Resources;
import android.os.storage.IMountService;
+import android.os.storage.StorageVolume;
import android.util.Log;
+import java.io.File;
+
/**
* Provides access to environment variables.
*/
@@ -35,7 +36,25 @@
private static final Object mLock = new Object();
- private volatile static Boolean mIsExternalStorageEmulated = null;
+ private volatile static StorageVolume mPrimaryVolume = null;
+
+ private static StorageVolume getPrimaryVolume() {
+ if (mPrimaryVolume == null) {
+ synchronized (mLock) {
+ if (mPrimaryVolume == null) {
+ try {
+ IMountService mountService = IMountService.Stub.asInterface(ServiceManager
+ .getService("mount"));
+ Parcelable[] volumes = mountService.getVolumeList();
+ mPrimaryVolume = (StorageVolume)volumes[0];
+ } catch (Exception e) {
+ Log.e(TAG, "couldn't talk to MountService", e);
+ }
+ }
+ }
+ }
+ return mPrimaryVolume;
+ }
/**
* Gets the Android root directory.
@@ -338,54 +357,54 @@
}
/**
- * getExternalStorageState() returns MEDIA_REMOVED if the media is not present.
+ * {@link #getExternalStorageState()} returns MEDIA_REMOVED if the media is not present.
*/
public static final String MEDIA_REMOVED = "removed";
/**
- * getExternalStorageState() returns MEDIA_UNMOUNTED if the media is present
+ * {@link #getExternalStorageState()} returns MEDIA_UNMOUNTED if the media is present
* but not mounted.
*/
public static final String MEDIA_UNMOUNTED = "unmounted";
/**
- * getExternalStorageState() returns MEDIA_CHECKING if the media is present
+ * {@link #getExternalStorageState()} returns MEDIA_CHECKING if the media is present
* and being disk-checked
*/
public static final String MEDIA_CHECKING = "checking";
/**
- * getExternalStorageState() returns MEDIA_NOFS if the media is present
+ * {@link #getExternalStorageState()} returns MEDIA_NOFS if the media is present
* but is blank or is using an unsupported filesystem
*/
public static final String MEDIA_NOFS = "nofs";
/**
- * getExternalStorageState() returns MEDIA_MOUNTED if the media is present
+ * {@link #getExternalStorageState()} returns MEDIA_MOUNTED if the media is present
* and mounted at its mount point with read/write access.
*/
public static final String MEDIA_MOUNTED = "mounted";
/**
- * getExternalStorageState() returns MEDIA_MOUNTED_READ_ONLY if the media is present
+ * {@link #getExternalStorageState()} returns MEDIA_MOUNTED_READ_ONLY if the media is present
* and mounted at its mount point with read only access.
*/
public static final String MEDIA_MOUNTED_READ_ONLY = "mounted_ro";
/**
- * getExternalStorageState() returns MEDIA_SHARED if the media is present
+ * {@link #getExternalStorageState()} returns MEDIA_SHARED if the media is present
* not mounted, and shared via USB mass storage.
*/
public static final String MEDIA_SHARED = "shared";
/**
- * getExternalStorageState() returns MEDIA_BAD_REMOVAL if the media was
+ * {@link #getExternalStorageState()} returns MEDIA_BAD_REMOVAL if the media was
* removed before it was unmounted.
*/
public static final String MEDIA_BAD_REMOVAL = "bad_removal";
/**
- * getExternalStorageState() returns MEDIA_UNMOUNTABLE if the media is present
+ * {@link #getExternalStorageState()} returns MEDIA_UNMOUNTABLE if the media is present
* but cannot be mounted. Typically this happens if the file system on the
* media is corrupted.
*/
@@ -416,9 +435,8 @@
* <p>See {@link #getExternalStorageDirectory()} for more information.
*/
public static boolean isExternalStorageRemovable() {
- if (isExternalStorageEmulated()) return false;
- return Resources.getSystem().getBoolean(
- com.android.internal.R.bool.config_externalStorageRemovable);
+ StorageVolume volume = getPrimaryVolume();
+ return (volume != null && volume.isRemovable());
}
/**
@@ -435,23 +453,8 @@
* android.content.ComponentName, boolean)} for additional details.
*/
public static boolean isExternalStorageEmulated() {
- if (mIsExternalStorageEmulated == null) {
- synchronized (mLock) {
- if (mIsExternalStorageEmulated == null) {
- boolean externalStorageEmulated;
- try {
- IMountService mountService = IMountService.Stub.asInterface(ServiceManager
- .getService("mount"));
- externalStorageEmulated = mountService.isExternalStorageEmulated();
- mIsExternalStorageEmulated = Boolean.valueOf(externalStorageEmulated);
- } catch (Exception e) {
- Log.e(TAG, "couldn't talk to MountService", e);
- return false;
- }
- }
- }
- }
- return mIsExternalStorageEmulated;
+ StorageVolume volume = getPrimaryVolume();
+ return (volume != null && volume.isEmulated());
}
static File getDirectory(String variableName, String defaultPath) {
diff --git a/core/java/android/os/storage/IMountService.java b/core/java/android/os/storage/IMountService.java
index 27da3c3..c2dc8ae 100644
--- a/core/java/android/os/storage/IMountService.java
+++ b/core/java/android/os/storage/IMountService.java
@@ -20,7 +20,9 @@
import android.os.IBinder;
import android.os.IInterface;
import android.os.Parcel;
+import android.os.Parcelable;
import android.os.RemoteException;
+import android.os.storage.StorageVolume;
/**
* WARNING! Update IMountService.h and IMountService.cpp if you change this
@@ -638,15 +640,15 @@
return _result;
}
- public String[] getVolumeList() throws RemoteException {
+ public Parcelable[] getVolumeList() throws RemoteException {
Parcel _data = Parcel.obtain();
Parcel _reply = Parcel.obtain();
- String[] _result;
+ Parcelable[] _result;
try {
_data.writeInterfaceToken(DESCRIPTOR);
mRemote.transact(Stub.TRANSACTION_getVolumeList, _data, _reply, 0);
_reply.readException();
- _result = _reply.readStringArray();
+ _result = _reply.readParcelableArray(StorageVolume.class.getClassLoader());
} finally {
_reply.recycle();
_data.recycle();
@@ -1024,9 +1026,9 @@
}
case TRANSACTION_getVolumeList: {
data.enforceInterface(DESCRIPTOR);
- String[] result = getVolumeList();
+ Parcelable[] result = getVolumeList();
reply.writeNoException();
- reply.writeStringArray(result);
+ reply.writeParcelableArray(result, 0);
return true;
}
}
@@ -1207,5 +1209,5 @@
/**
* Returns list of all mountable volumes.
*/
- public String[] getVolumeList() throws RemoteException;
+ public Parcelable[] getVolumeList() throws RemoteException;
}
diff --git a/core/java/android/os/storage/StorageManager.java b/core/java/android/os/storage/StorageManager.java
index 234057b..6fd1d00 100644
--- a/core/java/android/os/storage/StorageManager.java
+++ b/core/java/android/os/storage/StorageManager.java
@@ -19,6 +19,7 @@
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
+import android.os.Parcelable;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.Log;
@@ -545,12 +546,34 @@
* Returns list of all mountable volumes.
* @hide
*/
- public String[] getVolumeList() {
+ public StorageVolume[] getVolumeList() {
try {
- return mMountService.getVolumeList();
+ Parcelable[] list = mMountService.getVolumeList();
+ if (list == null) return new StorageVolume[0];
+ int length = list.length;
+ StorageVolume[] result = new StorageVolume[length];
+ for (int i = 0; i < length; i++) {
+ result[i] = (StorageVolume)list[i];
+ }
+ return result;
} catch (RemoteException e) {
Log.e(TAG, "Failed to get volume list", e);
return null;
}
}
+
+ /**
+ * Returns list of paths for all mountable volumes.
+ * @hide
+ */
+ public String[] getVolumePaths() {
+ StorageVolume[] volumes = getVolumeList();
+ if (volumes == null) return null;
+ int count = volumes.length;
+ String[] paths = new String[count];
+ for (int i = 0; i < count; i++) {
+ paths[i] = volumes[i].getPath();
+ }
+ return paths;
+ }
}
diff --git a/core/java/android/os/storage/StorageVolume.aidl b/core/java/android/os/storage/StorageVolume.aidl
new file mode 100644
index 0000000..d689917
--- /dev/null
+++ b/core/java/android/os/storage/StorageVolume.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2011, 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.
+ */
+
+package android.os.storage;
+
+parcelable StorageVolume;
diff --git a/core/java/android/os/storage/StorageVolume.java b/core/java/android/os/storage/StorageVolume.java
new file mode 100644
index 0000000..d79f6c8
--- /dev/null
+++ b/core/java/android/os/storage/StorageVolume.java
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+package android.os.storage;
+
+import android.os.Bundle;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.util.Log;
+
+/**
+ * A class representing a storage volume
+ * @hide
+ */
+public class StorageVolume implements Parcelable {
+
+ private static final String TAG = "StorageVolume";
+
+ private final String mPath;
+ private final String mDescription;
+ private final boolean mRemovable;
+ private final boolean mEmulated;
+ private final int mMtpReserveSpace;
+
+ public StorageVolume(String path, String description,
+ boolean removable, boolean emulated,
+ int mtpReserveSpace) {
+ mPath = path;
+ mDescription = description;
+ mRemovable = removable;
+ mEmulated = emulated;
+ mMtpReserveSpace = mtpReserveSpace;
+ }
+
+ /**
+ * Returns the mount path for the volume.
+ *
+ * @return the mount path
+ */
+ public String getPath() {
+ return mPath;
+ }
+
+ /**
+ * Returns a user visible description of the volume.
+ *
+ * @return the volume description
+ */
+ public String getDescription() {
+ return mDescription;
+ }
+
+ /**
+ * Returns true if the volume is removable.
+ *
+ * @return is removable
+ */
+ public boolean isRemovable() {
+ return mRemovable;
+ }
+
+ /**
+ * Returns true if the volume is emulated.
+ *
+ * @return is removable
+ */
+ public boolean isEmulated() {
+ return mEmulated;
+ }
+
+ /**
+ * Number of megabytes of space to leave unallocated by MTP.
+ * MTP will subtract this value from the free space it reports back
+ * to the host via GetStorageInfo, and will not allow new files to
+ * be added via MTP if there is less than this amount left free in the storage.
+ * If MTP has dedicated storage this value should be zero, but if MTP is
+ * sharing storage with the rest of the system, set this to a positive value
+ * to ensure that MTP activity does not result in the storage being
+ * too close to full.
+ *
+ * @return MTP reserve space
+ */
+ public int getMtpReserveSpace() {
+ return mMtpReserveSpace;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof StorageVolume && mPath != null) {
+ StorageVolume volume = (StorageVolume)obj;
+ return (mPath.equals(volume.mPath));
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return mPath.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return mPath;
+ }
+
+ public static final Parcelable.Creator<StorageVolume> CREATOR =
+ new Parcelable.Creator<StorageVolume>() {
+ public StorageVolume createFromParcel(Parcel in) {
+ String path = in.readString();
+ String description = in.readString();
+ int removable = in.readInt();
+ int emulated = in.readInt();
+ int mtpReserveSpace = in.readInt();
+ return new StorageVolume(path, description,
+ removable == 1, emulated == 1, mtpReserveSpace);
+ }
+
+ public StorageVolume[] newArray(int size) {
+ return new StorageVolume[size];
+ }
+ };
+
+ public int describeContents() {
+ return 0;
+ }
+
+ public void writeToParcel(Parcel parcel, int flags) {
+ parcel.writeString(mPath);
+ parcel.writeString(mDescription);
+ parcel.writeInt(mRemovable ? 1 : 0);
+ parcel.writeInt(mEmulated ? 1 : 0);
+ parcel.writeInt(mMtpReserveSpace);
+ }
+}
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index b524ad6..ecb6bbb 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -951,6 +951,43 @@
static final int PARENT_SAVE_DISABLED_MASK = 0x20000000;
/**
+ * Horizontal direction of this view is from Left to Right.
+ * Use with {@link #setHorizontalDirection}.
+ * {@hide}
+ */
+ public static final int HORIZONTAL_DIRECTION_LTR = 0x00000000;
+
+ /**
+ * Horizontal direction of this view is from Right to Left.
+ * Use with {@link #setHorizontalDirection}.
+ * {@hide}
+ */
+ public static final int HORIZONTAL_DIRECTION_RTL = 0x40000000;
+
+ /**
+ * Horizontal direction of this view is inherited from its parent.
+ * Use with {@link #setHorizontalDirection}.
+ * {@hide}
+ */
+ public static final int HORIZONTAL_DIRECTION_INHERIT = 0x80000000;
+
+ /**
+ * Horizontal direction of this view is from deduced from the default language
+ * script for the locale. Use with {@link #setHorizontalDirection}.
+ * {@hide}
+ */
+ public static final int HORIZONTAL_DIRECTION_LOCALE = 0xC0000000;
+
+ /**
+ * Mask for use with setFlags indicating bits used for horizontalDirection.
+ * {@hide}
+ */
+ static final int HORIZONTAL_DIRECTION_MASK = 0xC0000000;
+
+ private static final int[] HORIZONTAL_DIRECTION_FLAGS = { HORIZONTAL_DIRECTION_LTR,
+ HORIZONTAL_DIRECTION_RTL, HORIZONTAL_DIRECTION_INHERIT, HORIZONTAL_DIRECTION_LOCALE};
+
+ /**
* View flag indicating whether {@link #addFocusables(ArrayList, int, int)}
* should add all focusable Views regardless if they are focusable in touch mode.
*/
@@ -2598,6 +2635,13 @@
viewFlagMasks |= VISIBILITY_MASK;
}
break;
+ case com.android.internal.R.styleable.View_horizontalDirection:
+ final int layoutDirection = a.getInt(attr, 0);
+ if (layoutDirection != 0) {
+ viewFlagValues |= HORIZONTAL_DIRECTION_FLAGS[layoutDirection];
+ viewFlagMasks |= HORIZONTAL_DIRECTION_MASK;
+ }
+ break;
case com.android.internal.R.styleable.View_drawingCacheQuality:
final int cacheQuality = a.getInt(attr, 0);
if (cacheQuality != 0) {
@@ -3545,7 +3589,6 @@
* Example: Adding formatted date string to an accessibility event in addition
* to the text added by the super implementation.
* </p><p><pre><code>
- * @Override
* public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
* super.onPopulateAccessibilityEvent(event);
* final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_WEEKDAY;
@@ -3573,7 +3616,6 @@
* Example: Setting the password property of an event in addition
* to properties set by the super implementation.
* </p><p><pre><code>
- * @Override
* public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
* super.onInitializeAccessibilityEvent(event);
* event.setPassword(true);
@@ -4074,6 +4116,41 @@
}
/**
+ * Returns the horizontal direction for this view.
+ *
+ * @return One of {@link #HORIZONTAL_DIRECTION_LTR},
+ * {@link #HORIZONTAL_DIRECTION_RTL},
+ * {@link #HORIZONTAL_DIRECTION_INHERIT} or
+ * {@link #HORIZONTAL_DIRECTION_LOCALE}.
+ * @attr ref android.R.styleable#View_horizontalDirection
+ * @hide
+ */
+ @ViewDebug.ExportedProperty(mapping = {
+ @ViewDebug.IntToString(from = HORIZONTAL_DIRECTION_LTR, to = "LTR"),
+ @ViewDebug.IntToString(from = HORIZONTAL_DIRECTION_RTL, to = "RTL"),
+ @ViewDebug.IntToString(from = HORIZONTAL_DIRECTION_INHERIT, to = "INHERIT"),
+ @ViewDebug.IntToString(from = HORIZONTAL_DIRECTION_LOCALE, to = "LOCALE")
+ })
+ public int getHorizontalDirection() {
+ return mViewFlags & HORIZONTAL_DIRECTION_MASK;
+ }
+
+ /**
+ * Set the horizontal direction for this view.
+ *
+ * @param horizontalDirection One of {@link #HORIZONTAL_DIRECTION_LTR},
+ * {@link #HORIZONTAL_DIRECTION_RTL},
+ * {@link #HORIZONTAL_DIRECTION_INHERIT} or
+ * {@link #HORIZONTAL_DIRECTION_LOCALE}.
+ * @attr ref android.R.styleable#View_horizontalDirection
+ * @hide
+ */
+ @RemotableViewMethod
+ public void setHorizontalDirection(int horizontalDirection) {
+ setFlags(horizontalDirection, HORIZONTAL_DIRECTION_MASK);
+ }
+
+ /**
* If this view doesn't do any drawing on its own, set this flag to
* allow further optimizations. By default, this flag is not set on
* View, but could be set on some View subclasses such as ViewGroup.
@@ -5875,6 +5952,10 @@
mParent.recomputeViewAttributes(this);
}
}
+
+ if ((changed & HORIZONTAL_DIRECTION_MASK) != 0) {
+ requestLayout();
+ }
}
/**
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index f84b33b..6937573 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -587,6 +587,7 @@
return false;
}
final boolean propagate = onRequestSendAccessibilityEvent(child, event);
+ //noinspection SimplifiableIfStatement
if (!propagate) {
return false;
}
@@ -1243,6 +1244,7 @@
mHoveredChild = null;
} else {
// Pointer is still within the child.
+ //noinspection ConstantConditions
handled |= dispatchTransformedGenericPointerEvent(event, mHoveredChild);
}
}
@@ -1306,6 +1308,7 @@
// Handle the event only if leaf. This guarantees that
// the leafs (or any custom class that returns true from
// this method) will get a change to process the hover.
+ //noinspection SimplifiableIfStatement
if (getChildCount() == 0) {
return super.onHoverEvent(event);
}
@@ -1879,7 +1882,7 @@
* @see #FOCUS_BEFORE_DESCENDANTS
* @see #FOCUS_AFTER_DESCENDANTS
* @see #FOCUS_BLOCK_DESCENDANTS
- * @see #onRequestFocusInDescendants
+ * @see #onRequestFocusInDescendants(int, android.graphics.Rect)
*/
@Override
public boolean requestFocus(int direction, Rect previouslyFocusedRect) {
@@ -2093,10 +2096,10 @@
}
/**
- * Perform dispatching of a {@link #restoreHierarchyState thaw()} to only this view,
- * not to its children. For use when overriding
- * {@link #dispatchRestoreInstanceState dispatchThaw()} to allow subclasses to thaw
- * their own state but not the state of their children.
+ * Perform dispatching of a {@link #restoreHierarchyState(android.util.SparseArray)}
+ * to only this view, not to its children. For use when overriding
+ * {@link #dispatchRestoreInstanceState(android.util.SparseArray)} to allow
+ * subclasses to thaw their own state but not the state of their children.
*
* @param container the container
*/
diff --git a/core/java/android/widget/PopupWindow.java b/core/java/android/widget/PopupWindow.java
index de32c2b..1e1a043 100644
--- a/core/java/android/widget/PopupWindow.java
+++ b/core/java/android/widget/PopupWindow.java
@@ -392,11 +392,11 @@
mContentView = contentView;
- if (mContext == null) {
+ if (mContext == null && mContentView != null) {
mContext = mContentView.getContext();
}
- if (mWindowManager == null) {
+ if (mWindowManager == null && mContentView != null) {
mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
}
}
@@ -939,7 +939,9 @@
* @param p the layout parameters of the popup's content view
*/
private void invokePopup(WindowManager.LayoutParams p) {
- p.packageName = mContext.getPackageName();
+ if (mContext != null) {
+ p.packageName = mContext.getPackageName();
+ }
mWindowManager.addView(mPopupView, p);
}
diff --git a/core/java/android/widget/SimpleCursorAdapter.java b/core/java/android/widget/SimpleCursorAdapter.java
index 3d2a252..c5c6c69 100644
--- a/core/java/android/widget/SimpleCursorAdapter.java
+++ b/core/java/android/widget/SimpleCursorAdapter.java
@@ -338,6 +338,12 @@
@Override
public Cursor swapCursor(Cursor c) {
+ // super.swapCursor() will notify observers before we have
+ // a valid mapping, make sure we have a mapping before this
+ // happens
+ if (mFrom == null) {
+ findColumns(mOriginalFrom);
+ }
Cursor res = super.swapCursor(c);
// rescan columns in case cursor layout is different
findColumns(mOriginalFrom);
@@ -358,7 +364,13 @@
public void changeCursorAndColumns(Cursor c, String[] from, int[] to) {
mOriginalFrom = from;
mTo = to;
- super.changeCursor(c);
+ // super.changeCursor() will notify observers before we have
+ // a valid mapping, make sure we have a mapping before this
+ // happens
+ if (mFrom == null) {
+ findColumns(mOriginalFrom);
+ }
+ super.changeCursor(c);
findColumns(mOriginalFrom);
}
diff --git a/core/jni/android/graphics/Canvas.cpp b/core/jni/android/graphics/Canvas.cpp
index 9d9196e..f5f26be 100644
--- a/core/jni/android/graphics/Canvas.cpp
+++ b/core/jni/android/graphics/Canvas.cpp
@@ -770,7 +770,7 @@
jint count = end - start;
sp<TextLayoutCacheValue> value = gTextLayoutCache.getValue(
- paint, textArray, start, count, count, flags);
+ paint, textArray, start, count, end, flags);
if (value == NULL) {
LOGE("Cannot get TextLayoutCache value");
return ;
diff --git a/core/jni/android/graphics/Paint.cpp b/core/jni/android/graphics/Paint.cpp
index 768b836..64749e9 100644
--- a/core/jni/android/graphics/Paint.cpp
+++ b/core/jni/android/graphics/Paint.cpp
@@ -335,8 +335,8 @@
const jchar* textArray = env->GetCharArrayElements(text, NULL);
jfloat result = 0;
#if RTL_USE_HARFBUZZ
- TextLayout::getTextRunAdvances(paint, textArray, index, count, count, paint->getFlags(),
- NULL /* dont need all advances */, result);
+ TextLayout::getTextRunAdvances(paint, textArray, index, count, textLength,
+ paint->getFlags(), NULL /* dont need all advances */, result);
#else
// we double count, since measureText wants a byteLength
SkScalar width = paint->measureText(textArray + index, count << 1);
@@ -362,8 +362,8 @@
jfloat width = 0;
#if RTL_USE_HARFBUZZ
- TextLayout::getTextRunAdvances(paint, textArray, 0, count, count, paint->getFlags(),
- NULL /* dont need all advances */, width);
+ TextLayout::getTextRunAdvances(paint, textArray, start, count, end,
+ paint->getFlags(), NULL /* dont need all advances */, width);
#else
width = SkScalarToFloat(paint->measureText(textArray + start, count << 1));
@@ -381,8 +381,8 @@
size_t textLength = env->GetStringLength(text);
jfloat width = 0;
#if RTL_USE_HARFBUZZ
- TextLayout::getTextRunAdvances(paint, textArray, 0, textLength, textLength, paint->getFlags(),
- NULL /* dont need all advances */, width);
+ TextLayout::getTextRunAdvances(paint, textArray, 0, textLength, textLength,
+ paint->getFlags(), NULL /* dont need all advances */, width);
#else
width = SkScalarToFloat(paint->measureText(textArray, textLength << 1));
#endif
@@ -396,8 +396,8 @@
#if RTL_USE_HARFBUZZ
jfloat totalAdvance;
- TextLayout::getTextRunAdvances(paint, text, 0, count, count, paint->getFlags(),
- widthsArray, totalAdvance);
+ TextLayout::getTextRunAdvances(paint, text, 0, count, count,
+ paint->getFlags(), widthsArray, totalAdvance);
#else
SkScalar* scalarArray = (SkScalar*)widthsArray;
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index dac3bd2..2bb3e83 100755
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -1913,6 +1913,22 @@
more information. -->
<enum name="hardware" value="2" />
</attr>
+
+ <!-- Defines the direction of layout drawing. This typically is associated with writing
+ direction of the language script used. The possible values are Left-to-Right,
+ Right-to-Left, Locale and Inherit from parent view. If there is nothing to inherit,
+ Locale is used. Locale fallsback to 'en-US'. Left-to-Right is the direction used in
+ 'en-US'. The default for this attribute is 'inherit'. -->
+ <attr name="horizontalDirection">
+ <!-- Left-to-Right -->
+ <enum name="ltr" value="0" />
+ <!-- Right-to-Left -->
+ <enum name="rtl" value="1" />
+ <!-- Inherit from parent -->
+ <enum name="inherit" value="2" />
+ <!-- Locale -->
+ <enum name="locale" value="3" />
+ </attr>
</declare-styleable>
<!-- Attributes that can be used with a {@link android.view.ViewGroup} or any
@@ -4956,4 +4972,21 @@
<!-- Y coordinate of the icon hot spot. -->
<attr name="hotSpotY" format="float" />
</declare-styleable>
+
+ <declare-styleable name="Storage">
+ <!-- path to mount point for the storage -->
+ <attr name="mountPoint" format="string" />
+ <!-- user visible description of the storage -->
+ <attr name="storageDescription" format="string" />
+ <!-- true if the storage is the primary external storage -->
+ <attr name="primary" format="boolean" />
+ <!-- true if the storage is removable -->
+ <attr name="removable" format="boolean" />
+ <!-- true if the storage is emulated via the FUSE sdcard daemon -->
+ <attr name="emulated" format="boolean" />
+ <!-- number of megabytes of storage MTP should reserve for free storage
+ (used for emulated storage that is shared with system's data partition) -->
+ <attr name="mtpReserve" format="integer" />
+ </declare-styleable>
+
</resources>
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 652d791..8ad8f67 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -1667,6 +1667,7 @@
<public type="attr" name="textEditSuggestionsBottomWindowLayout" />
<public type="attr" name="textEditSuggestionsTopWindowLayout" />
<public type="attr" name="textEditSuggestionItemLayout" />
+ <public type="attr" name="horizontalDirection" />
<public type="attr" name="fullBackupAgent" />
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 3c95bfd..158d524 100755
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -2828,4 +2828,13 @@
<string name="action_bar_up_description">Navigate up</string>
<!-- Content description for the action menu overflow button. [CHAR LIMIT=NONE] -->
<string name="action_menu_overflow_description">More options</string>
+
+ <!-- Storage description for internal storage. [CHAR LIMIT=NONE] -->
+ <string name="storage_internal">Internal Storage</string>
+
+ <!-- Storage description for the SD card. [CHAR LIMIT=NONE] -->
+ <string name="storage_sd_card">SD Card</string>
+
+ <!-- Storage description for USB storage. [CHAR LIMIT=NONE] -->
+ <string name="storage_usb">USB storage</string>
</resources>
diff --git a/core/res/res/xml/storage_list.xml b/core/res/res/xml/storage_list.xml
new file mode 100644
index 0000000..944bb3a
--- /dev/null
+++ b/core/res/res/xml/storage_list.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+**
+** Copyright 2011, 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.
+*/
+-->
+
+<!-- The <device> element should contain one or more <storage> elements.
+ Exactly one of these should have the attribute primary="true".
+ This storage will be the primary external storage and should have mountPoint="/mnt/sdcard".
+ Each storage should have both a mountPoint and storageDescription attribute.
+ The following attributes are optional:
+
+ primary: (boolean) this storage is the primary external storage
+ removable: (boolean) this is removable storage (for example, a real SD card)
+ emulated: (boolean) the storage is emulated via the FUSE sdcard daemon
+ mtpReserve: (integer) number of megabytes of storage MTP should reserve for free storage
+ (used for emulated storage that is shared with system's data partition)
+
+ A storage should not have both emulated and removable set to true
+-->
+
+<StorageList xmlns:android="http://schemas.android.com/apk/res/android">
+ <!-- removable is not set in nosdcard product -->
+ <storage android:mountPoint="/mnt/sdcard"
+ android:storageDescription="@string/storage_usb"
+ android:primary="true" />
+</StorageList>
diff --git a/docs/html/community/index.html b/docs/html/community/index.html
new file mode 100644
index 0000000..fb2a0d35
--- /dev/null
+++ b/docs/html/community/index.html
@@ -0,0 +1,10 @@
+<html>
+<head>
+<meta http-equiv="refresh" content="0;url=http://developer.android.com/resources/community-groups.html">
+<title>Redirecting...</title>
+</head>
+<body>
+<p>You should have been redirected. Please <a
+href="http://developer.android.com/resources/community-groups.html">click here</a>.</p>
+</body>
+</html>
\ No newline at end of file
diff --git a/docs/html/community/index.jd b/docs/html/community/index.jd
deleted file mode 100644
index 23203c1..0000000
--- a/docs/html/community/index.jd
+++ /dev/null
@@ -1,127 +0,0 @@
-community=true
-page.title=Community
-@jd:body
-
- <div id="mainBodyFluid">
-<h1>Community</h1>
-<p>Welcome to the Android developers community! We're glad you're here and invite you to participate in these discussions. Before posting, please read the <a href="http://source.android.com/community/groups-charter.html">Groups Charter</a> that covers the community guidelines.</p>
-
-<p class="note"><strong>Note:</strong> If you are seeking discussion about Android source code (not application development),
-then please refer to the <a href="http://source.android.com/community">Open Source Project Mailing lists</a>.</p>
-
-<p style="margin-bottom:.5em"><strong>Contents</strong></p>
-<ol class="toc">
- <li><a href="#BeforeYouPost">Before you post</a></li>
- <li><a href="#ApplicationDeveloperLists">Application developer mailing lists</a></li>
- <li><a href="#UsingEmail">Using email with the mailing lists</a></li>
- <li><a href="#UsingIRC">Using IRC</a></li>
-</ol>
-
-<h2 id="BeforeYouPost">Before you post</h2>
-<p>Before writing a post, please try the following:</p>
-
-<ol>
-<li><a href="{@docRoot}guide/appendix/faq/index.html">Read the FAQs</a> The most common questions about developing Android applications are addressed in this frequently updated list.</li>
-<li><strong>Type in keywords of your questions in the main Android site's search bar</strong> (such as the one above). This search encompasses all previous discussions, across all groups, as well as the full contents of the site, documentation, and blogs. Chances are good that somebody has run into the same issue before.</li>
-<li><b>Search the mailing list archives</b> to see whether your questions have already been discussed.
- </li>
-</ol>
-
-<p>If you can't find your answer, then we encourage you to address the community.
-As you write your post, please do the following:
-<ol>
-<li><b>Read
-the <a href="http://source.android.com/community/groups-charter.html">mailing list charter</a></b> that covers the community guidelines.
-</li>
-<li><b>Select the most appropriate mailing list for your question</b>. There are several different lists for
-developers, described below.</li>
-<li>
- <b>Be very clear</b> about your question
-in the subject -- it helps everyone, both those trying to answer your
-question as well as those who may be looking for information in the
-future.</li>
-<li><b>Give plenty of details</b> in your post to
-help others understand your problem. Code or log snippets, as well as
-pointers to screenshots, may also be helpful. For a great guide to
-phrasing your questions, read <a href="http://www.catb.org/%7Eesr/faqs/smart-questions.html">How To Ask Questions The Smart Way</a>.
- </li>
-</ol>
-
-
-<h3 id="ApplicationDeveloperLists">Application developer mailing lists</h3>
-<ul>
-<li><b>Android beginners</b> - You're new to Android application development. You want to figure out how to get started with the Android SDK and the basic Android APIs? Start here. This list is open to any discussion around beginner-type questions for developers using the SDK; this is a great way to get up and running with your new application on the Android platform. Ask about getting your development environment set up, get help with the first steps of Android development (your first User Interface, your first permission, your first file on the Android filesystem, your first app on the Android Market...). Be sure to check the archives first before asking new questions. Please avoid advanced subjects, which belong on android-developers, and user questions, which will get a better reception on android-discuss.
-<ul>
-<li>Subscribe using Google Groups: <a href="http://groups.google.com/group/android-beginners">android-beginners</a></li>
-<li>Subscribe via email: <a href="mailto:android-beginners-subscribe@googlegroups.com">android-beginners-subscribe@googlegroups.com</a></li>
-</ul>
-</li>
-
-<li><b>Android developers</b> - You're now an experienced Android application developer. You've grasped the basics of Android app development, you're comfortable using the SDK, now you want to move to advanced topics. Get help here with troubleshooting applications, advice on implementation, and strategies for improving your application's performance and user experience. This is the not the right place to discuss user issues (use android-discuss for that) or beginner questions with the Android SDK (use android-beginners for that).
-<ul>
-<li>Subscribe using Google Groups: <a href="http://groups.google.com/group/android-developers">android-developers</a></li>
-<li>Subscribe via email: <a href="mailto:android-developers-subscribe@googlegroups.com">android-developers-subscribe@googlegroups.com</a></li>
-</ul>
-</li>
-
-<li><b>Android discuss</b> - The "water cooler" of Android discussion. You can discuss just about anything Android-related here, ideas for the Android platform, announcements about your applications, discussions about Android devices, community resources... As long as your discussion is related to Android, it's on-topic here. However, if you have a discussion here that could belong on another list, you are probably not reaching all of your target audience here and may want to consider shifting to a more targeted list.
-<ul>
-<li>Subscribe using Google Groups: <a href="http://groups.google.com/group/android-discuss">android-discuss</a></li>
-<li>Subscribe via email: <a href="mailto:android-discuss-subscribe@googlegroups.com">android-discuss-subscribe@googlegroups.com</a></li>
-</ul>
-</li>
-
-<li><b>Android ndk</b> - A place for discussing the Android NDK and topics related to using native code in Android applications.
-<ul>
-<li>Subscribe using Google Groups: <a href="http://groups.google.com/group/android-ndk">android-ndk</a></li>
-<li>Subscribe via email: <a href="mailto:android-ndk-subscribe@googlegroups.com">android-ndk-subscribe@googlegroups.com</a></li>
-</ul>
-</li>
-
-<li><b>Android security discuss</b> - A place for open discussion on secure development, emerging security concerns, and best practices for and by android developers. Please don't disclose vulnerabilities directly on this list, you'd be putting all Android users at risk.
-<ul>
-<li>Subscribe using Google Groups: <a href="http://groups.google.com/group/android-security-discuss">android-security-discuss</a></li>
-<li>Subscribe via email: <a href="mailto:android-security-discuss@googlegroups.com">android-security-discuss@googlegroups.com</a></li>
-</ul>
-</li>
-
-<li><b>Android security announce</b> - A low-volume group for security-related announcements by the Android Security Team.
-<ul>
-<li>Subscribe using Google Groups: <a href="http://groups.google.com/group/android-security-announce">android-security-announce</a></li>
-<li>Subscribe via email: <a href="mailto:android-security-announce-subscribe@googlegroups.com">android-security-announce-subscribe@googlegroups.com</a></li>
-</ul>
-</li>
-
-<li><b>Android Market Help Forum</b> - A web-based discussion forum where you can ask questions or report issues relating to Android Market.
-<ul>
-<li>URL: <a href="http://www.google.com/support/forum/p/Android+Market?hl=en">http://www.google.com/support/forum/p/Android+Market?hl=en</a></li>
-</ul>
-</li>
-
-</ul>
-
-
-
-<h2 id="UsingEmail">Using email with the mailing lists</h2>
-<p>Instead of using the <a href="http://groups.google.com/">Google Groups</a> site, you can use your email client of choice to participate in the mailing lists.</p>
-<p>To subscribe to a group without using the Google Groups site, use the link under "subscribe via email" in the lists above.</p>
-<p>To set up how you receive mailing list postings by email:</p>
-
-<ol><li>Sign into the group via the Google Groups site. For example, for the android-framework group you would visit <a href="http://groups.google.com/group/android-framework">http://groups.google.com/group/android-framework</a>.</li>
-<li>Click "Edit
-my membership" on the right side.</li>
-<li>Under "How do
-you want to read this group?" select one of the email options. </li>
-</ol>
-
-<h2 id="UsingIRC">Using IRC</h2>
-<p>The Android community is using the #android channel on the irc.freenode.net server.
-</p>
-
-
-
-
-
-
-
-</div>
diff --git a/docs/html/guide/samples/index.html b/docs/html/guide/samples/index.html
new file mode 100644
index 0000000..f4acdbf
--- /dev/null
+++ b/docs/html/guide/samples/index.html
@@ -0,0 +1,10 @@
+<html>
+<head>
+<meta http-equiv="refresh" content="0;url=http://developer.android.com/resources/browser.html?tag=sample">
+<title>Redirecting...</title>
+</head>
+<body>
+<p>You should have been redirected. Please <a
+href="http://developer.android.com/resources/browser.html?tag=sample">click here</a>.</p>
+</body>
+</html>
\ No newline at end of file
diff --git a/docs/html/guide/samples/index.jd b/docs/html/guide/samples/index.jd
deleted file mode 100644
index 4b9334f..0000000
--- a/docs/html/guide/samples/index.jd
+++ /dev/null
@@ -1,15 +0,0 @@
-guide=true
-page.title=Sample Code
-@jd:body
-
-
-<script type="text/javascript">
- window.location = toRoot + "resources/browser.html?tag=sample";
-</script>
-
-<p><strong>This document has moved. Please go to <a
-href="http://developer.android.com/resources/browser.html?tag=sample">List of Sample
-Apps</a>.</strong></p>
-
-
-
diff --git a/docs/html/guide/topics/usb/adk.jd b/docs/html/guide/topics/usb/adk.jd
index 44d7fc2..8aaa65c 100644
--- a/docs/html/guide/topics/usb/adk.jd
+++ b/docs/html/guide/topics/usb/adk.jd
@@ -6,7 +6,9 @@
<h2>In this document</h2>
<ol>
+ <li><a href="#components">ADK Components</a></li>
<li>
+
<a href="#getting-started">Getting Started with the ADK</a>
<ol>
@@ -54,16 +56,28 @@
</li>
</ol>
- <h2>Where to Buy</h2>
+
+
+ <h2>See also</h2>
+
+ <ol>
+ <li><a href="http://www.youtube.com/watch?v=s7szcpXf2rE">Google I/O Session Video</a></li>
+ <li><a href="{@docRoot}guide/topics/usb/accessory.html">USB Accessory Dev Guide</a></li>
+ </ol>
+
+ <h2>Where to buy</h2>
<ol>
<li><a href=
- "http://www.rt-shop.sakura.ne.jp/rt-shop/index.php?main_page=product_info&products_id=2731&language=en">
+ "http://www.rt-net.jp/shop/index.php?main_page=product_info&cPath=3_4&products_id=1">
RT Corp</a></li>
<li><a href=
"http://www.microchip.com/android">
Microchip</a></li>
+
+ <li><a href="https://store.diydrones.com/ProductDetails.asp?ProductCode=BR-PhoneDrone">
+ DIY Drones</a></li>
</ol>
</div>
</div>
@@ -79,7 +93,7 @@
released Android-powered devices are only capable of acting as a USB device and cannot initiate
connections with external USB devices. Android Open Accessory support overcomes this limitation
and allows you to build accessories that can interact with an assortment of Android-powered
- devices by allowing the accessory initiate the connection.</p>
+ devices by allowing the accessory to initiate the connection.</p>
<p class="note"><strong>Note:</strong> Accessory mode is ultimately dependent on the device's
hardware and not all devices will support accessory mode. Devices that support accessory mode can
@@ -87,20 +101,29 @@
Android manifest. For more information, see the <a href=
"{@docRoot}guide/topics/usb/accessory.html#manifest">USB Accessory</a> Developer Guide.</p>
+ <p>The following list of distributers are currently producing Android Open Accessory compatible
+ development boards:</p>
+
+ <ul>
+ <li><a href="http://www.rt-net.jp/shop/index.php?main_page=product_info&cPath=3_4&products_id=1">
+ RT Corp</a> provides an Arduino-compatible board based on the Android ADK board design.</li>
+ <li><a href="http://www.microchip.com/android">Microchip</a> provides a A PIC based USB
+ microcontroller board.</li>
+ <li><a href="https://store.diydrones.com/ProductDetails.asp?ProductCode=BR-PhoneDrone">DIY
+ Drones</a> provides an Arduino-compatible board geared towards RC (radio controlled) and UAV
+ (unmanned aerial vehicle) enthusiasts.</li>
+ </ul>
+
+ <p>We expect more hardware distributers to create a variety of kits, so please stay tuned for
+ further developments.</p>
+
+ <h2 id="components">ADK Components</h2>
<p>The Android Open Accessory Development Kit (ADK) provides an implementation of an Android USB
accessory that is based on the <a href="http://www.arduino.cc/">Arduino open source electronics
prototyping platform</a>, the accessory's hardware design files, code that implements the
accessory's firmware, and the Android application that interacts with the accessory. The hardware
- design files and code are contained in the <a href=
- "https://dl-ssl.google.com/android/adk/adk_release_0506.zip">ADK package download</a>. You can
- <a href=
- "http://www.rt-shop.sakura.ne.jp/rt-shop/index.php?main_page=product_info&products_id=2731&language=en">buy
- the hardware components</a> of the ADK if you do not already have them. There is also a <a href=
- "http://www.microchip.com/android">
- PIC based USB microcontroller</a> that is not based on the ADK design, but that you can still use
- to create your own Android open accessories. We expect more hardware distributers to create a
- variety of kits, so please stay tuned for further developments.</p>
-
+ design files and firmware code are contained in the <a href=
+ "https://dl-ssl.google.com/android/adk/adk_release_0512.zip">ADK package download</a>.</p>
<p>The main hardware and software components of the ADK include:</p>
<ul>
@@ -138,7 +161,6 @@
how to setup communication with the device.</li>
<li>Other third party libraries to support the ADK board's functionality:
-
<ul>
<li><a href="http://www.arduino.cc/playground/Main/CapSense">CapSense library</a></li>
@@ -150,11 +172,12 @@
<li><a href="http://www.arduino.cc/playground/Code/Spi">Spi library</a></li>
<li><a href="http://www.arduino.cc/en/Reference/Wire">Wire library</a></li>
+
+ <li>An Android application, DemoKit, that communicates with the ADK board and shield. The
+ source for this project is in the <code>app/</code> directory.</li>
</ul>
</li>
- <li>An Android application, DemoKit, that communicates with the ADK board and shield. The
- source for this project is in the <code>app/</code> directory.</li>
</ul>
<h2 id="getting-started">Getting Started with the ADK</h2>
@@ -172,7 +195,7 @@
libraries to sense human capacitance. This is needed for the capacative button that is located
on the ADK shield.</li>
- <li><a href="">The ADK package</a>: contains the firmware for the ADK board and hardware design
+ <li><a href="https://dl-ssl.google.com/android/adk/adk_release_0512.zip">The ADK package</a>: contains the firmware for the ADK board and hardware design
files for the ADK board and shield.</li>
</ul>
@@ -190,7 +213,7 @@
otherwise.</p>
</li>
- <li><a href="https://dl-ssl.google.com/android/adk/adk_release_0506.zip">Download</a> and
+ <li><a href="https://dl-ssl.google.com/android/adk/adk_release_0512.zip">Download</a> and
extract the ADK package to a directory of your choice. You should have an <code>app</code>,
<code>firmware</code>, and <code>hardware</code> directories.</li>
@@ -419,7 +442,7 @@
mode, the accessory cannot discern whether the device supports accessory mode and is not in that
state, or if the device does not support accessory mode at all. This is because devices that
support accessory mode but aren't in it initially report the device's manufacturer vendor ID and
- product ID, and not the special Google ones. In either case, the accessory should try to start
+ product ID, and not the special Android Open Accessory ones. In either case, the accessory should try to start
the device into accessory mode to figure out if the device supports it. The following steps
explain how to do this:</p>
diff --git a/docs/html/guide/tutorials/hello-world.html b/docs/html/guide/tutorials/hello-world.html
new file mode 100644
index 0000000..55187bd
--- /dev/null
+++ b/docs/html/guide/tutorials/hello-world.html
@@ -0,0 +1,10 @@
+<html>
+<head>
+<meta http-equiv="refresh" content="0;url=http://developer.android.com/resources/tutorials/hello-world.html">
+<title>Redirecting...</title>
+</head>
+<body>
+<p>You should have been redirected. Please <a
+href="http://developer.android.com/resources/tutorials/hello-world.html">click here</a>.</p>
+</body>
+</html>
\ No newline at end of file
diff --git a/docs/html/guide/tutorials/hello-world.jd b/docs/html/guide/tutorials/hello-world.jd
deleted file mode 100644
index 11e6497..0000000
--- a/docs/html/guide/tutorials/hello-world.jd
+++ /dev/null
@@ -1,569 +0,0 @@
-page.title=Hello, World
-@jd:body
-
-<div id="qv-wrapper">
- <div id="qv">
- <h2>In this document</h2>
- <ol>
- <li><a href="#avd">Create an AVD</a></li>
- <li><a href="#create">Create the Project</a></li>
- <li><a href="#ui">Construct the UI</a></li>
- <li><a href="#run">Run the Code</a></li>
- <li><a href="#upgrading">Upgrade the UI to an XML Layout</a></li>
- <li><a href="#debugging">Debug Your Project</a></li>
- <li><a href="#noeclipse">Creating the Project Without Eclipse</a></li>
- </ol>
- </div>
-</div>
-
-<p>As a developer, you know that the first impression
-of a development framework is how easy it is to write "Hello,
-World." Well, on Android, it's pretty easy.
-It's particularly easy if you're using Eclipse as your IDE, because we've provided a
-great plugin that handles your project creation and management to greatly speed-up your
-development cycles.</p>
-
-<p>If you are not using Eclipse, the tools provided by the Android SDK are accessible
-on the command line, so you can choose your IDE or text editor.
-For more information about developing with the Android SDK tools, see
-the <a href="{@docRoot}guide/developing/index.html">Overview</a>
-section for developing on Android.</p>
-
-<p>Before you start, you should already have the very latest SDK installed, and if you're using
-Eclipse, you should have installed the ADT plugin as well. If you have not installed these, see
-<a href="{@docRoot}sdk/installing.html">Installing the Android SDK</a> and return
-here when you've completed the installation.</p>
-
-<h2 id="avd">Create an AVD</h2>
-
-<div class="sidebox-wrapper">
- <div class="sidebox">
- <p>To learn more about how to use AVDs and the options
- available to you, refer to the
- <a href="{@docRoot}guide/developing/tools/avd.html">Android
- Virtual Devices</a> document.</p>
- </div>
-</div>
-
-<p>In this tutorial, you will run your application in the Android Emulator.
-Before you can launch the emulator, you must create an
-Android Virtual Device (AVD). An AVD defines the system image and
-device settings used by the emulator.</p>
-
-<p>To create an AVD, use the "android" tool provided in the Android SDK.
-Open a command prompt or terminal, navigate to the
-<code>tools/</code> directory in the SDK package and execute:
-<pre>
-android create avd --target 2 --name my_avd
-</pre>
-
-<p>The tool now asks if you would like to create a custom hardware profile.
-For the time being, press Return to skip it ("no" is the default response).
-That's it. This configures an AVD named "my_avd" that uses the Android 1.5
-platform. The AVD is now ready for use in the emulator.</p>
-
-<p>In the above command, the <code>--target</code> option is required
-and specifies the deployment target to run on the emulator.
-The <code>--name</code> option is also required and defines the
-name for the new AVD.</p>
-
-
-<h2 id="create">Create a New Android Project</h2>
-
-<p>After you've created an AVD, the next step is to start a new
-Android project in Eclipse.</p>
-
-<ol>
- <li>From Eclipse, select <strong>File > New > Project</strong>.
- <p>If the ADT
- Plugin for Eclipse has been successfully installed, the resulting dialog
- should have a folder labeled "Android" which should contain
- "Android Project". (After you create one or more Android projects, an entry for
- "Android XML File" will also be available.)</p>
- </li>
-
- <li>Select "Android Project" and click <strong>Next</strong>.<br/>
- <a href="images/hello_world_0.png"><img src="images/hello_world_0.png" style="height:230px" alt="" /></a>
- </li>
-
- <li>Fill in the project details with the following values:
- <ul>
- <li><em>Project name:</em> HelloAndroid</li>
- <li><em>Application name:</em> Hello, Android</li>
- <li><em>Package name:</em> com.example.helloandroid (or your own private namespace)</li>
- <li><em>Create Activity:</em> HelloAndroid</li>
- <li><em>Min SDK Version:</em> 2</li>
- </ul>
- <p>Click <strong>Finish</strong>.</p>
-
- <a href="images/hello_world_1.png"><img src="images/hello_world_1.png" style="height:230px" alt="" /></a>
-
- <p>Here is a description of each field:</p>
-
- <dl>
- <dt><em>Project Name</em></dt>
- <dd>This is the Eclipse Project name — the name of the directory
- that will contain the project files.</dd>
- <dt><em>Application Name</em></dt>
- <dd>This is the human-readable title for your application — the name that
- will appear on the Android device.</dd>
- <dt><em>Package Name</em></dt>
- <dd>This is the package namespace (following the same rules as for
- packages in the Java programming language) that you want all your source code to
- reside under. This also sets the package name under which the stub
- Activity will be generated.
- <p>Your package name must be unique across
- all packages installed on the Android system; for this reason, it's very
- important to use a standard domain-style package for your
- applications. The example above uses the "com.example" namespace, which is
- a namespace reserved for example documentation —
- when you develop your own applications, you should use a namespace that's
- appropriate to your organization or entity.</p></dd>
- <dt><em>Create Activity</em></dt>
- <dd>This is the name for the class stub that will be generated by the plugin.
- This will be a subclass of Android's {@link android.app.Activity} class. An
- Activity is simply a class that can run and do work. It can create a UI if it
- chooses, but it doesn't need to. As the checkbox suggests, this is optional, but an
- Activity is almost always used as the basis for an application.</dd>
- <dt><em>Min SDK Version</em></dt>
- <dd>This value specifies the minimum API Level required by your application. If the API Level
- entered here matches the API Level provided by one of the available targets,
- then that Build Target will be automatically selected (in this case, entering
- "2" as the API Level will select the Android 1.1 target). With each new
- version of the Android system image and Android SDK, there have likely been
- additions or changes made to the APIs. When this occurs, a new API Level is assigned
- to the system image to regulate which applications are allowed to be run. If an
- application requires an API Level that is <em>higher</em> than the level supported
- by the device, then the application will not be installed.</dd>
- </dl>
-
- <p><em>Other fields</em>: The checkbox for "Use default location" allows you to change
- the location on disk where the project's files will be generated and stored. "Build Target"
- is the platform target that your application will be compiled against
- (this should be selected automatically, based on your Min SDK Version).</p>
-
- <p class="note">Notice that the "Build Target" you've selected uses the Android 1.1
- platform. This means that your application will be compiled against the Android 1.1
- platform library. If you recall, the AVD created above runs on the Android 1.5 platform.
- These don't have to match; Android applications are forward-compatible, so an application
- built against the 1.1 platform library will run normally on the 1.5 platform. The reverse
- is not true.</p>
- </li>
-</ol>
-
-<p>Your Android project is now ready. It should be visible in the Package
-Explorer on the left.
-Open the <code>HelloAndroid.java</code> file, located inside <em>HelloAndroid > src >
-com.example.helloandroid</em>). It should look like this:</p>
-
-<pre>
-package com.example.helloandroid;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-public class HelloAndroid extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- }
-}</pre>
-
-<p>Notice that the class is based on the {@link android.app.Activity} class. An Activity is a
-single application entity that is used to perform actions. An application may have many separate
-activities, but the user interacts with them one at a time. The
-{@link android.app.Activity#onCreate(Bundle) onCreate()} method
-will be called by the Android system when your Activity starts —
-it is where you should perform all initialization and UI setup. An activity is not required to
-have a user interface, but usually will.</p>
-
-<p>Now let's modify some code! </p>
-
-
-<h2 id="ui">Construct the UI</h2>
-
-<p>Take a look at the revised code below and then make the same changes to your HelloAndroid class.
-The bold items are lines that have been added.</p>
-
-<pre>
-package com.android.helloandroid;
-
-import android.app.Activity;
-import android.os.Bundle;
-<strong>import android.widget.TextView;</strong>
-
-public class HelloAndroid extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- <strong>TextView tv = new TextView(this);
- tv.setText("Hello, Android");
- setContentView(tv);</strong>
- }
-}</pre>
-
-<p class="note"><strong>Tip:</strong> An easy way to add import packages to your project is
-to press <strong>Ctrl-Shift-O</strong> (<strong>Cmd-Shift-O</strong>, on Mac). This is an Eclipse
-shortcut that identifies missing packages based on your code and adds them for you.</p>
-
-<p>An Android user interface is composed of hierarchies of objects called
-Views. A {@link android.view.View} is a drawable object used as an element in your UI layout,
-such as a button, image, or (in this case) a text label. Each of these objects is a subclass
-of the View class and the subclass that handles text is {@link android.widget.TextView}.</p>
-
-<p>In this change, you create a TextView with the class constructor, which accepts
-an Android {@link android.content.Context} instance as its parameter. A
-Context is a handle to the system; it provides services like
-resolving resources, obtaining access to databases and preferences, and so
-on. The Activity class inherits from Context, and because your
-HelloAndroid class is a subclass of Activity, it is also a Context. So, you can
-pass <code>this</code> as your Context reference to the TextView.</p>
-
-<p>Next, you define the text content with
-{@link android.widget.TextView setText(CharSequence) setText()}.</p>
-
-<p>Finally, you pass the TextView to
-{@link android.app.Activity#setContentView(View) setContentView()} in order to
-display it as the content for the Activity UI. If your Activity doesn't
-call this method, then no UI is present and the system will display a blank
-screen.</p>
-
-<p>There it is — "Hello, World" in Android! The next step, of course, is
-to see it running.</p>
-
-
-<h2 id="run">Run the Application</h2>
-
-<p>The Eclipse plugin makes it very easy to run your applications:</p>
-
-<ol>
- <li>Select <strong>Run > Run</strong>.</li>
- <li>Select "Android Application".</li>
-</ol>
-
-<div class="sidebox-wrapper">
- <div class="sidebox">
- <p>To learn more about creating and editing run configurations in Eclipse, refer to
- <a href="{@docRoot}guide/developing/eclipse-adt.html#RunConfig">Developing In Eclipse,
- with ADT</a>.</p>
- </div>
-</div>
-
-<p>The Eclipse ADT will automatically create a new run configuration for your project
-and the Android Emulator will automatically launch. Once the emulator is booted up,
-your application will appear after a moment. You should now see something like this:</p>
-
- <a href="images/hello_world_5.png"><img src="images/hello_world_5.png" style="height:230px" alt="" /></a>
-
-<p>The "Hello, Android" you see in the grey bar is actually the application title. The Eclipse plugin
-creates this automatically (the string is defined in the <code>res/values/strings.xml</code> file and referenced
-by your <code>AndroidManifest.xml</code> file). The text below the title is the actual text that you have
-created in the TextView object.</p>
-
-<p>That concludes the basic "Hello World" tutorial, but you should continue reading for some more
-valuable information about developing Android applications.</p>
-
-
-<h2 id="upgrading">Upgrade the UI to an XML Layout</h2>
-
-<p>The "Hello, World" example you just completed uses what is called a "programmatic"
-UI layout. This means that you constructed and built your application's UI
-directly in source code. If you've done much UI programming, you're
-probably familiar with how brittle that approach can sometimes be: small
-changes in layout can result in big source-code headaches. It's also very
-easy to forget to properly connect Views together, which can result in errors in
-your layout and wasted time debugging your code.</p>
-
-<p>That's why Android provides an alternate UI construction model: XML-based
-layout files. The easiest way to explain this concept is to show an
-example. Here's an XML layout file that is identical in behavior to the
-programmatically-constructed example:</p>
-
-<pre><?xml version="1.0" encoding="utf-8"?>
-<TextView xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:text="@string/hello"/></pre>
-
-<p>The general structure of an Android XML layout file is simple: it's a tree
-of XML elements, wherein each node is the name of a View class
-(this example, however, is just one View element). You can use the
-name of any class that extends {@link android.view.View} as an element in your XML layouts,
-including custom View classes you define in your own code. This
-structure makes it very easy to quickly build up UIs, using a more simple
-structure and syntax than you would use in a programmatic layout. This model is inspired
-by the web development model, wherein you can separate the presentation of your
-application (its UI) from the application logic used to fetch and fill in data.</p>
-
-<p>In the above XML example, there's just one View element: the <code>TextView</code>,
-which has four XML attributes. Here's a summary of what they mean:</p>
-
-<table>
- <tbody>
- <tr>
- <th>
- Attribute
- </th>
- <th>
- Meaning
- </th>
- </tr>
- <tr>
- <td>
- <code>xmlns:android</code>
- </td>
- <td>
- This is an XML namespace declaration that tells the Android tools that you are going to refer to common attributes defined in the Android namespace. The outermost tag in every Android layout file must have this attribute.<br>
- </td>
- </tr>
- <tr>
- <td>
- <code>android:layout_width</code>
- </td>
- <td>
- This attribute defines how much of the available width on the screen this View should consume.
-In this case, it's the only View so you want it to take up the entire screen, which is what a value of "fill_parent" means.<br>
- </td>
- </tr>
- <tr>
- <td>
- <code>android:layout_height</code>
- </td>
- <td>
- This is just like android:layout_width, except that it refers to available screen height.
- </td>
- </tr>
- <tr>
- <td>
- <code>android:text</code>
- </td>
- <td>
- This sets the text that the TextView should display. In this example, you use a string
- resource instead of a hard-coded string value.
- The <em>hello</em> string is defined in the <em>res/values/strings.xml</em> file. This is the
- recommended practice for inserting strings to your application, because it makes the localization
- of your application to other languages graceful, without need to hard-code changes to the layout file.
- For more information, see <a href="{@docRoot}guide/topics/resources/resources-i18n.html">Resources
- and Internationalization</a>.
- </td>
- </tr>
- </tbody>
-</table>
-
-
-<p>These XML layout files belong in the <code>res/layout/</code> directory of your project. The "res" is
-short for "resources" and the directory contains all the non-code assets that
-your application requires. In addition to layout files, resources also include assets
-such as images, sounds, and localized strings.</p>
-
-<div class="sidebox-wrapper">
-<div class="sidebox">
- <h2>Landscape layout</h2>
- <p>When you want a different design for landscape, put your layout XML file
- inside /res/layout-land. Android will automatically look here when the layout changes.
- Without this special landscape layout defined, Android will stretch the default layout.</p>
-</div>
-</div>
-
-<p>The Eclipse plugin automatically creates one of these layout files for you: main.xml.
-In the "Hello World" application you just completed, this file was ignored and you created a
-layout programmatically. This was meant to teach you more
-about the Android framework, but you should almost always define your layout
-in an XML file instead of in your code.
-The following procedures will instruct you how to change your
-existing application to use an XML layout.</p>
-
-<ol>
- <li>In the Eclipse Package Explorer, expand the
-<code>/res/layout/</code> folder and open <code>main.xml</code> (once opened, you might need to click
-the "main.xml" tab at the bottom of the window to see the XML source). Replace the contents with
-the following XML:
-
-<pre><?xml version="1.0" encoding="utf-8"?>
-<TextView xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:text="@string/hello"/></pre>
-<p>Save the file.</p>
-</li>
-
-<li>Inside the <code>res/values/</code> folder, open <code>strings.xml</code>.
-This is where you should save all default text strings for your user interface. If you're using Eclipse, then
-ADT will have started you with two strings, <em>hello</em> and <em>app_name</em>.
-Revise <em>hello</em> to something else. Perhaps "Hello, Android! I am a string resource!"
-The entire file should now look like this:
-<pre>
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="hello">Hello, Android! I am a string resource!</string>
- <string name="app_name">Hello, Android</string>
-</resources>
-</pre>
-</li>
-
-<li>Now open and modify your <code>HelloAndroid</code> class use the
-XML layout. Edit the file to look like this:
-<pre>
-package com.example.helloandroid;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-public class HelloAndroid extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- }
-}</pre>
-
-<p>When you make this change, type it by hand to try the
-code-completion feature. As you begin typing "R.layout.main" the plugin will offer you
-suggestions. You'll find that it helps in a lot of situations.</p>
-
-<p>Instead of passing <code>setContentView()</code> a View object, you give it a reference
-to the layout resource.
-The resource is identified as <code>R.layout.main</code>, which is actually a compiled object representation of
-the layout defined in <code>/res/layout/main.xml</code>. The Eclipse plugin automatically creates this reference for
-you inside the project's R.java class. If you're not using Eclipse, then the R.java class will be generated for you
-when you run Ant to build the application. (More about the R class in a moment.)</p>
-</li>
-</ol>
-
-<p>Now re-run your application — because you've created a launch configuration, all
-you need to do is click the green arrow icon to run, or select
-<strong>Run > Run History > Android Activity</strong>. Other than the change to the TextView
-string, the application looks the same. After all, the point was to show that the two different
-layout approaches produce identical results.</p>
-
-<p class="note"><strong>Tip:</strong> Use the shortcut <strong>Ctrl-F11</strong>
-(<strong>Cmd-Shift-F11</strong>, on Mac) to run your currently visible application.</p>
-
-<p>Continue reading for an introduction
-to debugging and a little more information on using other IDEs. When you're ready to learn more,
-read <a href="{@docRoot}guide/topics/fundamentals.html">Application
-Fundamentals</a> for an introduction to all the elements that make Android applications work.
-Also refer to the <a href="{@docRoot}guide/index.html">Developer's Guide</a>
-introduction page for an overview of the <em>Dev Guide</em> documentation.</p>
-
-
-<div class="special">
-<h3>R class</h3>
-<p>In Eclipse, open the file named <code>R.java</code> (in the <code>gen/</code> [Generated Java Files] folder).
-It should look something like this:</p>
-
-<pre>
-package com.example.helloandroid;
-
-public final class R {
- public static final class attr {
- }
- public static final class drawable {
- public static final int icon=0x7f020000;
- }
- public static final class layout {
- public static final int main=0x7f030000;
- }
- public static final class string {
- public static final int app_name=0x7f040001;
- public static final int hello=0x7f040000;
- }
-}
-</pre>
-
-<p>A project's <code>R.java</code> file is an index into all the resources defined in the
-file. You use this class in your source code as a sort of short-hand
-way to refer to resources you've included in your project. This is
-particularly powerful with the code-completion features of IDEs like Eclipse
-because it lets you quickly and interactively locate the specific reference
-you're looking for.</p>
-
-<p>It's possible yours looks slighly different than this (perhaps the hexadecimal values are different).
-For now, notice the inner class named "layout", and its
-member field "main". The Eclipse plugin noticed the XML
-layout file named main.xml and generated a class for it here. As you add other
-resources to your project (such as strings in the <code>res/values/string.xml</code> file or drawables inside
-the <code>res/drawable/</code> direcory) you'll see <code>R.java</code> change to keep up.</p>
-<p>When not using Eclipse, this class file will be generated for you at build time (with the Ant tool).</p>
-<p><em>You should never edit this file by hand.</em></p>
-</div>
-
-<h2 id="debugging">Debug Your Project</h2>
-
-<p>The Android Plugin for Eclipse also has excellent integration with the Eclipse
-debugger. To demonstrate this, introduce a bug into
-your code. Change your HelloAndroid source code to look like this:</p>
-
-<pre>
-package com.android.helloandroid;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-public class HelloAndroid extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- Object o = null;
- o.toString();
- setContentView(R.layout.main);
- }
-}</pre>
-
-<p>This change simply introduces a NullPointerException into your code. If
-you run your application again, you'll eventually see this:</p>
-
- <a href="images/hello_world_8.png"><img src="images/hello_world_8.png" style="height:230px" alt="" /></a>
-
-<p>Press "Force Quit" to terminate the application and close the emulator window.</p>
-
-<p>To find out more about the error, set a breakpoint in your source code
-on the line <code>Object o = null;</code> (double-click on the marker bar next to the source code line). Then select <strong>Run > Debug History > Hello,
-Android</strong> from the menu to enter debug mode. Your app will restart in the
-emulator, but this time it will suspend when it reaches the breakpoint you
-set. You can then step through the code in Eclipse's Debug Perspective,
-just as you would for any other application.</p>
-
- <a href="images/hello_world_9.png"><img src="images/hello_world_9.png" style="height:230px" alt="" /></a>
-
-
-<h2 id="noeclipse">Creating the Project without Eclipse</h2>
-
- <p>If you don't use Eclipse (such as if you prefer another IDE, or simply use text
- editors and command line tools) then the Eclipse plugin can't help you.
- Don't worry though — you don't lose any functionality just because you don't
- use Eclipse.</p>
-
- <p>The Android Plugin for Eclipse is really just a wrapper around a set of tools
- included with the Android SDK. (These tools, like the emulator, aapt, adb,
- ddms, and others are <a href="{@docRoot}guide/developing/tools/index.html">documented elsewhere.</a>)
- Thus, it's possible to
- wrap those tools with another tool, such as an 'ant' build file.</p>
-
- <p>The Android SDK includes a tool named "android" that can be
- used to create all the source code and directory stubs for your project, as well
- as an ant-compatible <code>build.xml</code> file. This allows you to build your project
- from the command line, or integrate it with the IDE of your choice.</p>
-
- <p>For example, to create a HelloAndroid project similar to the one created
- in Eclipse, use this command:</p>
-
- <pre>
-android create project \
- --package com.android.helloandroid \
- --activity HelloAndroid \
- --target 2 \
- --path <em><path-to-your-project></em>/HelloAndroid
-</pre>
-
- <p>This creates the required folders and files for the project at the location
- defined by the <em>path</em>.</p>
-
- <p>For more information on how to use the SDK tools to create and build projects on the command line, read
-<a href="{@docRoot}guide/developing/projects/index.html">Creating and Managing Projects on the Command Line</a> and
-<a href="{@docRoot}guide/developing/building/building-cmdline.html">Building and Running Apps on the Command Line</a>.</p>
diff --git a/docs/html/guide/tutorials/index.html b/docs/html/guide/tutorials/index.html
index 4881acf..e412dec 100644
--- a/docs/html/guide/tutorials/index.html
+++ b/docs/html/guide/tutorials/index.html
@@ -1,8 +1,10 @@
<html>
<head>
-<meta http-equiv="refresh" content="0;url=../index.html">
+<meta http-equiv="refresh" content="0;url=http://developer.android.com/resources/browser.html?tag=tutorial">
+<title>Redirecting...</title>
</head>
<body>
-<a href="../index.html">click here</a> if you are not redirected.
+<p>You should have been redirected. Please <a
+href="http://developer.android.com/resources/browser.html?tag=tutorial">click here</a>.</p>
</body>
</html>
\ No newline at end of file
diff --git a/docs/html/guide/tutorials/localization/index.html b/docs/html/guide/tutorials/localization/index.html
new file mode 100644
index 0000000..2ea6661
--- /dev/null
+++ b/docs/html/guide/tutorials/localization/index.html
@@ -0,0 +1,10 @@
+<html>
+<head>
+<meta http-equiv="refresh" content="0;url=http://developer.android.com/resources/tutorials/localization/index.html">
+<title>Redirecting...</title>
+</head>
+<body>
+<p>You should have been redirected. Please <a
+href="http://developer.android.com/resources/tutorials/localization/index.html">click here</a>.</p>
+</body>
+</html>
\ No newline at end of file
diff --git a/docs/html/guide/tutorials/localization/index.jd b/docs/html/guide/tutorials/localization/index.jd
deleted file mode 100755
index 8a60814..0000000
--- a/docs/html/guide/tutorials/localization/index.jd
+++ /dev/null
@@ -1,593 +0,0 @@
-page.title=Hello, L10N
-@jd:body
-
-<div id="qv-wrapper">
- <div id="qv">
- <h2>In this document</h2>
- <ol>
- <li><a href="#unlocalized">Create an Unlocalized App</a>
- <ol>
- <li><a href="#create">Create the Project and Layout</a></li>
- <li><a href="#default">Create Default Resources</a></li>
- </ol>
- </li>
- <li><a href="#run">Run the Unlocalized App</a></li>
- <li><a href="#plan">Plan the Localization</a></li>
- <li><a href="#localize">Localize the App</a>
- <ol>
- <li><a href="#localize_strings">Localize the Strings</a></li>
- <li><a href="#localize_images">Localize the Images</a></li>
- </ol>
- </li>
- <li><a href="#test_localized">Run and Test the Localized App</a></li>
- </ol>
- <h2>See also</h2>
- <ol>
-<li>{@link android.widget.Button}</li>
-<li>{@link android.widget.TextView}</li>
-<li>{@link android.app.AlertDialog}</li>
-</ol>
- </div>
-</div>
-
-<p>In this tutorial, we will create a Hello, L10N application that uses the
-Android framework to selectively load resources. Then we will localize the
-application by adding resources to the <code>res/</code> directory. </p>
-
-<p>This tutorial uses the practices described in the <a
-href="{@docRoot}guide/topics/resources/localization.html">Localization</a>
-document. </p>
-
-
-<h2 id="unlocalized">Create an Unlocalized Application</h2>
-
-<p>The first version of the Hello, L10N application will use only the default
-resource directories (<code>res/drawable</code>, <code>res/layout</code>, and
-<code>res/values</code>). These resources are not localized — they are the
-graphics, layout, and strings that we expect the application to use most often.
-When a user runs the application in the default locale, or in a locale that the
-application does not specifically support, the application will load resources
-from these default directories.</p>
-
-<p>The application consists of a simple user interface that displays two
-{@link android.widget.TextView} objects and a {@link android.widget.Button} image with a
- background image of a national flag. When clicked, the button displays an
-{@link android.app.AlertDialog} object that shows additional text. </p>
-
-<h3 id="create">Create the Project and Layout</h3>
-
-<p>For this application, the default language will be British English and the
-default location the United Kingdom. </p>
-
-<ol>
- <li>Start a new project and Activity called "HelloL10N." If you are
-using Eclipse, fill out these values in the New Android Project wizard:
- <ul>
- <li><em>Project name:</em> HelloL10N</li>
- <li><em>Application name:</em> Hello, L10N</li>
- <li><em>Package name:</em> com.example.hellol10n (or your own private
-namespace)</li>
- <li><em>Create Activity:</em> HelloL10N</li>
- <li><em>Min SDK Version:</em> 3</li>
- </ul>
- <p>The basic project contains a <code>res/</code> directory with
-subdirectories for the three most common types of resources: graphics
-(<code>res/drawable/</code>), layouts (<code>res/layout/</code>) and strings
-(<code>res/values/</code>). Most of the localization work you do later in this
-tutorial will involve adding more subdirectories to the <code>res/</code>
-directory.</p>
- <img src="{@docRoot}images/hello_l10n/plain_project.png" alt="plain project" width="194"
-height="229">
- </li>
- <li>Open the <code>res/layout/main.xml</code> file and replace it with the
-following code:
- <pre><?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- >
-<TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:gravity="center_horizontal"
- android:text="@string/text_a"
- />
-<TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:gravity="center_horizontal"
- android:text="@string/text_b"
- />
-<Button
- android:id="@+id/flag_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- />
-</LinearLayout>
- </pre>
-
- <p>The LinearLayout has two {@link android.widget.TextView} objects that will
-display localized text and one {@link android.widget.Button} that shows a flag.
-</p>
- </li>
-</ol>
-
-<h3 id="default">Create Default Resources</h3>
-
-<p>The layout refers to resources that need to be defined. </p>
-
-<ol>
- <li>Create default text strings. To do this, open the <code>res/values/strings.xml</code> file and replace it with the following code:<br>
- <pre><?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="app_name">Hello, L10N</string>
- <string name="text_a">Shall I compare thee to a summer"'"s day?</string>
- <string name="text_b">Thou art more lovely and more temperate.</string>
- <string name="dialog_title">No Localisation</string>
- <string name="dialog_text">This dialog box"'"s strings are not localised. For every locale, the text here will come from values/strings.xml.</string>
-</resources></pre>
-
- <p>This code provides British English text for each string that the application
-will use. When we localize this application, we will provide alternate text in
-German, French, and Japanese for some of the strings.</p>
- </li>
- <li>Add a default flag graphic to the <code>res/drawable</code> folder by
-saving <a href="../../../images/hello_l10n/flag.png">flag.png</a> as
-<code>res/drawable/flag.png</code>. When the application is not localized, it
-will show a British flag.<br>
-
- </li>
- <li>Open HelloL10N.java (in the <code>src/</code> directory) and add the
-following code inside the <code>onCreate()</code> method (after
-<code>setContentView</code>).
-
- <pre>// assign flag.png to the button, loading correct flag image for current locale
-Button b;
-(b = (Button)findViewById(R.id.flag_button)).setBackgroundDrawable(this.getResources().getDrawable(R.drawable.flag));
-
-// build dialog box to display when user clicks the flag
-AlertDialog.Builder builder = new AlertDialog.Builder(this);
-builder.setMessage(R.string.dialog_text)
- .setCancelable(false)
- .setTitle(R.string.dialog_title)
- .setPositiveButton("Done", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- dialog.dismiss();
- }
- });
-final AlertDialog alert = builder.create();
-
-// set click listener on the flag to show the dialog box
-b.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- alert.show();
- }
- });</pre>
-
- <p class="note"><strong>Tip:</strong> In Eclipse, use
-<strong>Ctrl-Shift-O</strong> (<strong>Cmd-Shift-O</strong>, on Mac) to find and
-add missing import packages to your project, then save the HelloL10N.java
-file.</p>
-
- <p>The code that you added does the following:</p>
-
- <ul>
- <li>It assigns the correct flag icon to the button.
- For now, no resources are defined other than the default, so this code
-will always assign the contents of <code>res/drawable/flag.png</code> (the
-British flag) as the flag icon, no matter what the locale. Once we add more
-flags for different locales, this code will sometimes assign a different flag.
-</li>
- <li>It creates an {@link android.app.AlertDialog} object and sets a click listener so that when the
-user clicks the button, the AlertDialog will display.
- We will not localize the dialog text;
-the AlertDialog will always display the <code>dialog_text</code> that is located
-within <code>res/values/strings.xml</code>. </li>
- </ul>
-
- </li>
-</ol>
-
-<p>The project structure now looks like this:</p>
-
- <img src="{@docRoot}images/hello_l10n/nonlocalized_project.png" alt="nonlocalized" width="394"
-height="320">
-
-<p class="note"><strong>Tip:</strong> If you will want to run the application on
-a device and not just on an emulator, open <code>AndroidManifest.xml</code> and
-add <code>android:debuggable="true"</code> inside the
-<code><application></code> element. For information about setting up the
-device itself so it can run applications from your system, see <a
-href="{@docRoot}guide/developing/device.html">Developing on a Device</a>.</p>
-
-
-<h2 id="run">Run the Unlocalized Application</h2>
-
-<p>Save the project and run the application to see how it works. No matter what
-locale your device or emulator is set to, the application runs the same way. It
-should look something like this:</p>
-
-<table border="0" cellspacing="0" cellpadding="30">
- <tr>
- <th scope="col">The unlocalized application, running in any locale:</th>
- <th scope="col">After clicking the flag, in any locale:</th>
- </tr>
- <tr>
- <td valign="top"><img src="{@docRoot}images/hello_l10n/nonlocalized_screenshot1.png"
-alt="nonlocalized" width="321" height="366"></td>
- <td><img src="{@docRoot}images/hello_l10n/nonlocalized_screenshot2.png" alt="nonlocalized2"
-width="321" height="366"></td>
- </tr>
-</table>
-<h2 id="plan">Plan the Localization</h2>
-<p>The first step in localizing an application is to plan how the application
-will render differently in different locales. In this application, the default
-locale will be the United Kingdom. We will add some locale-specific information
-for Germany, France, Canada, Japan, and the United States. Table 1 shows the
-plan for how the application will appear in different locales.</p>
-
-<p class="caption">Table 1</p>
-
-<table border="0" cellspacing="0" cellpadding="10">
- <tr>
- <th scope="col" valign="bottom">Region /<br />
- Language</th>
- <th scope="col">United Kingdom</th>
- <th scope="col">Germany</th>
- <th scope="col">France</th>
- <th scope="col">Canada</th>
- <th scope="col">Japan</th>
- <th scope="col">United States</th>
- <th scope="col">Other Location</th>
- </tr>
- <tr>
- <th scope="row"><br>
- English</th>
- <td> British English text; British flag <em>(default)</em></td>
- <td><em>-</em></td>
- <td><em>-</em></td>
- <td> British English text; Canadian flag</td>
- <td>-</td>
- <td> British English text; U.S. flag</td>
- <td> British English text; British flag <em>(default)</em></td>
- </tr>
- <tr>
- <th scope="row">German</th>
- <td>-</td>
- <td>German text for <code>app_name</code>, <code>text_a</code> and
-<code>text_b</code>; German flag</td>
- <td>-</td>
- <td>-</td>
- <td>-</td>
- <td>-</td>
- <td>German text for <code>app_name</code>, <code>text_a</code> and
-<code>text_b</code>; British flag</td>
- </tr>
- <tr>
- <th scope="row">French</th>
- <td>-</td>
- <td>-</td>
- <td>French text for <code>app_name</code>, <code>text_a</code> and
-<code>text_b</code>; French flag</td>
- <td>French text for <code>app_name</code>, <code>text_a</code> and
-<code>text_b</code>; Canadian flag</td>
- <td>-</td>
- <td>-</td>
- <td>French text for <code>app_name</code>, <code>text_a</code> and
-<code>text_b</code>; British flag</td>
- </tr>
- <tr>
- <th scope="row">Japanese</th>
- <td>-</td>
- <td>-</td>
- <td>-</td>
- <td>-</td>
- <td>Japanese text for <code>text_a</code> and <code>text_b</code>; Japanese
-flag</td>
- <td>-</td>
- <td>Japanese text for <code>text_a</code> and <code>text_b</code>; British
-flag</td>
- </tr>
- <tr>
- <th scope="row">Other Language</th>
- <td>-</td>
- <td>-</td>
- <td>-</td>
- <td>-</td>
- <td>-</td>
- <td>-</td>
- <td> British English text; British flag <em>(default)</em></td>
- </tr>
-</table>
-
-<p class="note"> Note that other behaviors are possible; for example, the
-application could support Canadian English or U.S. English text. But given the
-small amount of text involved, adding more versions of English would not make
-this application more useful.</p>
-
-<p>As shown in the table above, the plan calls for five flag icons in addition
-to the British flag that is already in the <code>res/drawable/</code> folder. It
-also calls for three sets of text strings other than the text that is in
-<code>res/values/strings.xml</code>.</p>
-
-<p>Table 2 shows where the needed text strings and flag icons will go, and
-specifies which ones will be loaded for which locales. (For more about the
-locale codes, <em></em>see <a
-href="{@docRoot}guide/topics/resources/resources-i18n.html#AlternateResources">
-Alternate Resources</a>.)</p>
-<p class="caption" id="table2">Table 2</p>
-
-<table border="1" cellspacing="0" cellpadding="5">
- <tr>
- <th scope="col">Locale Code</th>
- <th scope="col">Language / Country</th>
- <th scope="col">Location of strings.xml</th>
- <th scope="col">Location of flag.png</th>
- </tr>
- <tr>
- <td><em>Default</em></td>
- <td>English / United Kingdom</td>
- <td>res/values/</td>
- <td>res/drawable/</td>
- </tr>
- <tr>
- <td>de-rDE</td>
- <td>German / Germany</td>
- <td>res/values-de/</td>
- <td>res/drawable-de-rDE/</td>
- </tr>
- <tr>
- <td>fr-rFR</td>
- <td>French / France</td>
- <td>res/values-fr/</td>
- <td>res/drawable-fr-rFR/</td>
- </tr>
- <tr>
- <td>fr-rCA</td>
- <td>French / Canada</td>
- <td>res/values-fr/</td>
- <td>res/drawable-fr-rCA/</td>
- </tr>
- <tr>
- <td>en-rCA</td>
- <td>English / Canada</td>
- <td><em>(res/values/)</em></td>
- <td>res/drawable-en-rCA/</td>
- </tr>
- <tr>
- <td>ja-rJP</td>
- <td>Japanese / Japan</td>
- <td>res/values-ja/</td>
- <td>res/drawable-ja-rJP/</td>
- </tr>
- <tr>
- <td>en-rUS</td>
- <td>English / United States</td>
- <td><em>(res/values/)</em></td>
- <td>res/drawable-en-rUS/</td>
- </tr>
-</table>
-
-<p class="note"><strong>Tip: </strong>A folder qualifer cannot specify a region
-without a language. Having a folder named <code>res/drawable-rCA/</code>,
-for example, will prevent the application from compiling. </p>
-
-<p>At run time, the application will select a set of resources to load based on the locale
-that is set in the user's device. In cases where no locale-specific resources
-are available, the application will fall back on the defaults. </p>
-
-<p>For example, assume that the device's language is set to German and its
-location to Switzerland. Because this application does not have a
-<code>res/drawable-de-rCH/</code> directory with a <code>flag.png</code> file in it, the system
-will fall back on the default, which is the UK flag located in
-<code>res/drawable/flag.png</code>. The language used will be German. Showing a
-British flag to German speakers in Switzerland is not ideal, but for now we will
-just leave the behavior as it is. There are several ways you could improve this
-application's behavior if you wanted to:</p>
-
-<ul>
- <li>Use a generic default icon. In this application, it might be something
-that represents Shakespeare. </li>
- <li>Create a <code>res/drawable-de/</code> folder that includes an icon that
-the application will use whenever the language is set to German but the location
-is not Germany. </li>
-</ul>
-
-
-<h2 id="localize">Localize the Application</h2>
-
-<h3 id="localize_strings">Localize the Strings</h3>
-
-<p>The application requires three more <code>strings.xml</code> files, one
-each for German, French, and Japanese. To create these resource files within
-Eclipse:</p>
-
-<ol>
-<li>Select <strong>File</strong> > <strong>New</strong> > <strong>Android
-XML File</strong> to open the New Android XML File wizard. You can also open
-the wizard by clicking its icon in the toolbar:<br />
-<img src="{@docRoot}images/hello_l10n/xml_file_wizard_shortcut.png"
-alt="file_wizard_shortcut" width="297"
-height="90" style="margin:15px"></li>
- <li>Select L10N for the Project field, and type <code>strings.xml</code> into
-the File field. In the left-hand list, select Language, then click the right arrow.<br>
-<img src="{@docRoot}images/hello_l10n/xml_wizard1.png" alt="res_file_copy" width="335"
-height="406" style="margin:15px"></li>
- <li>Type <code>de</code> in the Language box and click Finish.<br>
- <img src="{@docRoot}images/hello_l10n/xml_wizard2.png" alt="res_file_copy" width="306"
-height="179">
-<p>A new file, <code>res/values-de/strings.xml</code>, now appears among the project
-files.</p></li>
-<li>Repeat the steps twice more, for the language codes <code>fr</code> and
- <code>ja</code>.
-Now the project includes these new skeleton files: <br />
- <code>res/<strong>values-de</strong>/strings.xml</code><br />
- <code>res/<strong>values-fr</strong>/strings.xml</code><br />
- <code>res/<strong>values-ja</strong>/strings.xml</code><br />
- </li>
- <li>Add localized text to the new files. To do
-this, open the <code>res/values-<em><qualifier></em>/strings.xml</code> files and
-replace the code as follows:</li>
-</ol>
-
-<table border="0" cellspacing="0" cellpadding="0">
- <tr>
- <th scope="col">File</th>
- <th scope="col">Replace the contents with the following code:</th>
- </tr>
- <tr>
- <td><code>res/values-de/strings.xml</code></td>
- <td><pre><?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="app_name">Hallo, Lokalisierung</string>
- <string name="text_a">Soll ich dich einem Sommertag vergleichen,</string>
- <string name="text_b">Der du viel lieblicher und sanfter bist?</string>
-</resources></pre></td>
- </tr>
- <tr>
- <td><code>res/values-fr/strings.xml</code></td>
- <td><pre><?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="app_name">Bonjour, Localisation</string>
- <string name="text_a">Irai-je te comparer au jour d'été?</string>
- <string name="text_b">Tu es plus tendre et bien plus tempéré.</string>
-</resources> </pre></td>
- </tr>
- <tr>
- <td><code>res/values-ja/strings.xml</code></td>
- <td>
-<pre><?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="text_a">あなたをなにかにたとえるとしたら夏の一日でしょうか?</string>
- <string name="text_b">だがあなたはもっと美しく、もっとおだやかです。</string>
-</resources></pre></td>
- </tr>
-</table>
-
-<p class="note"><b>Tip:</b> In the
-<code>values-<em><qualifier></em>/strings.xml</code> files, you only need to
-include text for strings that are different from the default strings. For
-example, when the application runs on a device that is configured for Japanese,
-the plan is for <code>text_a</code> and <code>text_b</code> to be in Japanese
-while all the other text is in English, so
-<code>res/values-ja/strings.xml</code> only needs to include <code>text_a</code>
-and <code>text_b</code>.</p>
-
-<h3 id="localize_images">Localize the Images</h3>
-
-<p>As shown in <a href="#table2">Table 2</a>, the application needs six more
-drawable folders, each containing a <code>flag.png</code> icon. Add the needed
-icons and folders to your project:</p>
-
-<ol>
- <li>Save this <a href="../../../images/hello_l10n/drawable-de-rDE/flag.png">German flag icon</a>
-as <code>res/drawable-de-rDE/flag.png</code> in the application's project
-workspace.
- <p>For example:</p>
- <ol>
- <li>Click the link to open the flag image.</li>
- <li>Save the image in
-<code><em>your-workspace</em>/HelloL10N/res/drawable-de-rDE/</code> .</li>
- </ol>
- </li>
- <li>Save this <a href="../../../images/hello_l10n/drawable-fr-rFR/flag.png">French flag icon</a>
-as <code>res/drawable-fr-rFR/flag.png</code> in the application's project
-workspace. </li>
- <li>Save this <a href="../../../images/hello_l10n/drawable-fr-rCA/flag.png">Canadian flag icon</a>
-as <code>res/drawable-fr-rCA/flag.png</code> in the project workspace. </li>
- <li>Save the <a href="../../../images/hello_l10n/drawable-en-rCA/flag.png">Canadian flag icon</a>
-again, this time as <code>res/drawable-en-rCA/flag.png</code> in the project
-workspace. (Why not have just <em>one</em> folder that contains the Canadian
-flag? Because a folder qualifer cannot specify a region without a language.
-You cannot have a folder named <code>drawable-rCA/</code>; instead you must
-create two separate folders, one for each of the Canadian languages represented
-in the application.)</li>
- <li>Save this <a href="../../../images/hello_l10n/drawable-ja-rJP/flag.png">Japanese flag icon</a>
-as <code>res/drawable-ja-rJP/flag.png</code> in the project workspace. </li>
- <li>Save this <a href="../../../images/hello_l10n/drawable-en-rUS/flag.png">United States flag
-icon</a> as <code>res/drawable-en-rUS/flag.png</code> in the project workspace.
- </li>
-</ol>
-
-<p>If you are using Eclipse, refresh the project (F5). The new
-<code>res/drawable-<em><qualifier></em>/</code> folders should appear in the
-project view. </p>
-
-
-<h2 id="test_localized">Run and Test the Localized Application</h2>
-
-<p>Once you've added the localized string and image resources, you are ready to
- run the application and test its handling of them. To change the locale
- on a device or in the emulator, use the Settings
-application (Home > Menu > Settings > Locale & text > Select
-locale). Depending on how a device was configured, it might not offer any
-alternate locales via the Settings application, or might offer only a few. The
-emulator, on the other hand, will offer a selection of all the locales that are
-available in the Android system image. </p>
-
-<p>To set the emulator to a locale that is not available in the system image,
-use the Custom Locale application, which is available in the Application
-tab:</p>
-
-<p><img src="{@docRoot}images/hello_l10n/custom_locale_app.png" alt="custom locale app" width="163"
-height="158" style="margin-left:15px"></p>
-
-<p>To switch to a new locale, long-press a locale name:</p>
-
-<p><img src="{@docRoot}images/hello_l10n/using_custom_locale.png" alt="using custom locale"
-width="512" height="299" style="margin-left:15px"></p>
-
-<p>For a list of locales available on different versions of the Android platform,
-refer to the platform notes documents, listed under "Downloadable SDK Components"
-in the "SDK" tab. For example, <a
-href="{@docRoot}sdk/android-2.0.html#locs">Android 2.0 locales</a>.</p>
-
-<p>Run the application for each of the expected locales, plus one unexpected
-locale. Here are some of the results you should see:</p>
-
-<table border="0" cellspacing="0" cellpadding="05">
- <tr>
- <th scope="col">Locale</th>
- <th scope="col">Opening screen of application</th>
- </tr>
- <tr>
- <td>German / Germany
- <br />Specifically supported by the Hello, L10N application.</td>
- <td><img src="{@docRoot}images/hello_l10n/german_screenshot.png" alt="custom locale app"
-width="321" height="175" align="right"
-style="margin-left:10px;margin-right:20px"></td>
- </tr>
- <tr>
- <td>French / Canada
- <br />Specifically supported by the Hello, L10N application.</td>
- <td><img src="{@docRoot}images/hello_l10n/frenchCA_screenshot.png" alt="custom locale app"
-width="321" height="175" align="right"
-style="margin-left:10px;margin-right:20px"></td>
- </tr>
- <tr>
- <td>German / Switzerland
- <br />Only the language is specifically supported by
-the Hello, L10N application.</td>
- <td><img src="{@docRoot}images/hello_l10n/germanCH_screenshot.png" alt="custom locale app"
-width="321" height="175" align="right"
-style="margin-left:10px;margin-right:20px">`</td>
- </tr>
- <tr>
- <td>Japanese
- <br />Specifically supported by the Hello, L10N application.
- </td>
- <td><img src="{@docRoot}images/hello_l10n/japanese_screenshot.png" alt="custom locale app"
-width="321" height="220" align="right"
-style="margin-left:10px;margin-right:20px">`</td>
- </tr>
- <tr>
- <td>Romansh / Switzerland (custom locale <code>rm_CH</code>)
- <br />Not specifically supported by the Hello, L10N
-application, so the application uses the default resources.</td>
- <td><img src="{@docRoot}images/hello_l10n/romanshCH_screenshot.png" alt="custom locale app"
-width="321" height="175" align="right"
-style="margin-left:10px;margin-right:20px"></td>
- </tr>
-</table>
diff --git a/docs/html/guide/tutorials/notepad/index.html b/docs/html/guide/tutorials/notepad/index.html
new file mode 100644
index 0000000..01e4d09
--- /dev/null
+++ b/docs/html/guide/tutorials/notepad/index.html
@@ -0,0 +1,10 @@
+<html>
+<head>
+<meta http-equiv="refresh" content="0;url=http://developer.android.com/resources/tutorials/notepad/index.html">
+<title>Redirecting...</title>
+</head>
+<body>
+<p>You should have been redirected. Please <a
+href="http://developer.android.com/resources/tutorials/notepad/index.html">click here</a>.</p>
+</body>
+</html>
\ No newline at end of file
diff --git a/docs/html/guide/tutorials/notepad/index.jd b/docs/html/guide/tutorials/notepad/index.jd
deleted file mode 100644
index f569314..0000000
--- a/docs/html/guide/tutorials/notepad/index.jd
+++ /dev/null
@@ -1,142 +0,0 @@
-page.title=Notepad Tutorial
-@jd:body
-
-
-<p>This tutorial on writing a notepad application gives you a "hands-on" introduction
-to the Android framework and the tools you use to build applications on it.
-Starting from a preconfigured project file, it guides you through the process of
-developing a simple notepad application and provides concrete examples of how to
-set up the project, develop the application logic and user interface, and then
-compile and run the application. </p>
-
-<p>The tutorial presents the application development as a set of
-exercises (see below), each consisting of several steps. You should follow
-the steps in each exercise to gradually build and refine your
-application. The exercises explain each step in detail and provide all the
-sample code you need to complete the application. </p>
-
-<p>When you are finished with the tutorial, you will have created a functioning
-Android application and will have learned many of the most important
-concepts in Android development. If you want to add more complex features to
-your application, you can examine the code in an alternative implementation
-of a Note Pad application, in the
-<a href="{@docRoot}resources/samples/index.html">Sample Code</a> section. </p>
-
-
-<a name="who"></a>
-<h2>Who Should Use this Tutorial</h2>
-
-<p>This tutorial is designed for experienced developers, especially those with
-knowledge of the Java programming language. If you haven't written Java
-applications before, you can still use the tutorial, but you might need to work
-at a slower pace. </p>
-
-<p>Also note that this tutorial uses
-the Eclipse development environment, with the Android plugin installed. If you
-are not using Eclipse, you can follow the exercises and build the application,
-but you will need to determine how to accomplish the Eclipse-specific
-steps in your environment. </p>
-
-<a name="preparing"></a>
-<h2>Preparing for the Exercises</h2>
-
-<p>The tutorial assumes that you have some familiarity with basic Android
-application concepts and terminology. If you are not, you
-should read <a href="{@docRoot}guide/topics/fundamentals.html">Application
-Fundamentals</a> before continuing. </p>
-
-<p>This tutorial also builds on the introductory information provided in the
-<a href="{@docRoot}resources/tutorials/hello-world.html">Hello World</a>
-tutorial, which explains how to set up your Eclipse environment
-for building Android applications. We recommend you complete the Hello World
-tutorial before starting this one.</p>
-
-<p>To prepare for this lesson:</p>
-
-<ol>
- <li>Download the <a href="codelab/NotepadCodeLab.zip">project
- exercises archive (.zip)</a>.</li>
- <li>Unpack the archive file to a suitable location on your machine.</li>
- <li>Open the <code>NotepadCodeLab</code> folder.</li>
-</ol>
-
-<p>Inside the <code>NotepadCodeLab</code> folder, you should see six project
-files: <code>Notepadv1</code>,
- <code>Notepadv2</code>, <code>Notepadv3</code>,
- <code>Notepadv1Solution</code>, <code>Notepadv2Solution</code>
- and <code>Notepadv3Solution</code>. The <code>Notepadv#</code> projects are
-the starting points for each of the exercises, while the
-<code>Notepadv#Solution</code> projects are the exercise
- solutions. If you are having trouble with a particular exercise, you
- can compare your current work against the exercise solution.</p>
-
-<a name="exercises"></a>
-<h2> Exercises</h2>
-
- <p>The table below lists the tutorial exercises and describes the development
-areas that each covers. Each exercise assumes that you have completed any
-previous exercises.</p>
-
- <table border="0" style="padding:4px;spacing:2px;" summary="This
-table lists the
-tutorial examples and describes what each covers. ">
- <tr>
- <th width="120"><a href="{@docRoot}resources/tutorials/notepad/notepad-ex1.html">Exercise
-1</a></th>
- <td>Start here. Construct a simple notes list that lets the user add new notes but not
-edit them. Demonstrates the basics of <code>ListActivity</code> and creating
-and handling
- menu options. Uses a SQLite database to store the notes.</td>
- </tr>
- <tr>
- <th><a href="{@docRoot}resources/tutorials/notepad/notepad-ex2.html">Exercise 2</a></th>
- <td>Add a second Activity to the
-application. Demonstrates constructing a
-new Activity, adding it to the Android manifest, passing data between the
-activities, and using more advanced screen layout. Also shows how to
-invoke another Activity to return a result, using
-<code>startActivityForResult()</code>.</td>
- </tr>
- <tr>
- <th><a href="{@docRoot}resources/tutorials/notepad/notepad-ex3.html">Exercise 3</a></th>
- <td>Add handling of life-cycle events to
-the application, to let it
-maintain application state across the life cycle. </td>
- </tr>
- <tr>
- <th><a href="{@docRoot}resources/tutorials/notepad/notepad-extra-credit.html">Extra
-Credit</a></th>
- <td>Demonstrates how to use the Eclipse
-debugger and how you can use it to
-view life-cycle events as they are generated. This section is optional but
-highly recommended.</td>
- </tr>
-</table>
-
-
-<a name="other"></a>
-<h2>Other Resources and Further Learning</h2>
-<ul>
-<li>For a lighter but broader introduction to concepts not covered in the
-tutorial,
-take a look at <a href="{@docRoot}resources/faq/commontasks.html">Common Android Tasks</a>.</li>
-<li>The Android SDK includes a variety of fully functioning sample applications
-that make excellent opportunities for further learning. You can find the sample
-applications in the <code>samples/</code> directory of your downloaded SDK, or browser them
-here, in the <a href="{@docRoot}resources/samples/index.html">Sample Code</a> section.</li>
-<li>This tutorial draws from the full Notepad application included in the
-<code>samples/</code> directory of the SDK, though it does not match it exactly.
-When you are done with the tutorial,
-it is highly recommended that you take a closer look at this version of the Notepad
-application,
-as it demonstrates a variety of interesting additions for your application,
-such as:</li>
- <ul>
- <li>Setting up a custom striped list for the list of notes.</li>
- <li>Creating a custom text edit view that overrides the <code>draw()</code>
- method to make it look like a lined notepad.</li>
- <li>Implementing a full <code>ContentProvider</code> for notes.</li>
- <li>Reverting and discarding edits instead of just automatically saving
- them.</li>
- </ul>
-</ul>
diff --git a/docs/html/guide/tutorials/views/index.html b/docs/html/guide/tutorials/views/index.html
new file mode 100644
index 0000000..41d6796
--- /dev/null
+++ b/docs/html/guide/tutorials/views/index.html
@@ -0,0 +1,10 @@
+<html>
+<head>
+<meta http-equiv="refresh" content="0;url=http://developer.android.com/resources/tutorials/views/index.html">
+<title>Redirecting...</title>
+</head>
+<body>
+<p>You should have been redirected. Please <a
+href="http://developer.android.com/resources/tutorials/views/index.html">click here</a>.</p>
+</body>
+</html>
\ No newline at end of file
diff --git a/docs/html/guide/tutorials/views/index.jd b/docs/html/guide/tutorials/views/index.jd
deleted file mode 100644
index 4e76ab9..0000000
--- a/docs/html/guide/tutorials/views/index.jd
+++ /dev/null
@@ -1,118 +0,0 @@
-page.title=Hello, Views
-@jd:body
-
-<style>
-.view {float:left; margin:10px; font-size:120%; font-weight:bold;}
-.view img {border:1px solid black; margin:5px 0 0; padding:5px;}
-</style>
-
-<p>This collection of "Hello World"-style tutorials is designed
-to get you quickly started with common Android Views and widgets. The aim is to let you copy and paste
-these kinds of boring bits so you can focus on developing the code that makes your Android application rock.
-Of course, we'll discuss some of the given code so that it all makes sense.</p>
-
-<p>Note that a certain amount of knowledge is assumed for these tutorials. If you haven't
-completed the <a href="{@docRoot}resources/tutorials/hello-world.html">Hello, World</a> tutorial,
-please do so—it will teach you many things you should know about basic
-Android development and Eclipse features. More specifically, you should know:</p>
-<ul>
- <li>How to create a new Android project.</li>
- <li>The basic structure of an Android project (resource files, layout files, etc.).</li>
- <li>The essential components of an {@link android.app.Activity}.</li>
- <li>How to build and run a project.</li>
-</ul>
-<p>Please, also notice that, in order to make these tutorials simple, some may
-not convey the better Android coding practices. In particular, many of them
-use hard-coded strings in the layout files—the better practice is to reference strings from
-your strings.xml file.</p>
-<p>With this knowledge, you're ready to begin, so take your pick.</p>
-
-<div>
-
-<div class="view">
-<a href="hello-linearlayout.html">LinearLayout</a><br/>
-<a href="hello-linearlayout.html"><img src="images/hello-linearlayout.png" height="285" width="200" /></a>
-</div>
-<div class="view">
-<a href="hello-relativelayout.html">RelativeLayout</a><br/>
-<a href="hello-relativelayout.html"><img src="images/hello-relativelayout.png" height="285" width="200" /></a>
-</div>
-<div class="view">
-<a href="hello-tablelayout.html">TableLayout</a><br/>
-<a href="hello-tablelayout.html"><img src="images/hello-tablelayout.png" height="285" width="200" /></a>
-</div>
-
-<div class="view">
-<a href="hello-datepicker.html">DatePicker</a><br/>
-<a href="hello-datepicker.html"><img src="images/hello-datepicker.png" height="285" width="200" /></a>
-</div>
-
-<div class="view">
-<a href="hello-timepicker.html">TimePicker</a><br/>
-<a href="hello-timepicker.html"><img src="images/hello-timepicker.png" height="285" width="200" /></a>
-</div>
-<div class="view">
-<a href="hello-formstuff.html">Form Stuff</a><br/>
-<a href="hello-formstuff.html"><img src="images/hello-formstuff.png" height="285" width="200" /></a>
-</div>
-<div class="view">
-<a href="hello-spinner.html">Spinner</a><br/>
-<a href="hello-spinner.html"><img src="images/hello-spinner.png" height="285" width="200" /></a>
-</div>
-
-<div class="view">
-<a href="hello-autocomplete.html">AutoComplete</a><br/>
-<a href="hello-autocomplete.html"><img src="images/hello-autocomplete.png" height="285" width="200" /></a>
-</div>
-<div class="view">
-<a href="hello-listview.html">ListView</a><br/>
-<a href="hello-listview.html"><img src="images/hello-listview.png" height="285" width="200" /></a>
-</div>
-<div class="view">
-<a href="hello-gridview.html">GridView</a><br/>
-<a href="hello-gridview.html"><img src="images/hello-gridview.png" height="285" width="200" /></a>
-</div>
-
-<div class="view">
-<a href="hello-gallery.html">Gallery</a><br/>
-<a href="hello-gallery.html"><img src="images/hello-gallery.png" height="285" width="200" /></a>
-</div>
-
-<div class="view">
-<a href="hello-tabwidget.html">TabWidget</a><br/>
-<a href="hello-tabwidget.html"><img src="images/hello-tabwidget.png" height="285" width="200" /></a>
-</div>
-
-<div class="view">
-<a href="hello-mapview.html">MapView</a><br/>
-<a href="hello-mapview.html"><img src="images/hello-mapview.png" height="285" width="200" /></a>
-</div>
-
-<div class="view">
-<a href="hello-webview.html">WebView</a><br/>
-<a href="hello-webview.html"><img src="images/hello-webview.png" height="285" width="200" /></a>
-</div>
-
-<!--
-TODO
-
-<div class="view">
-<a href="hello-popupwindow.html">PopupWindow<br/>
-<img src="images/hello-popupwindow.png" height="285" width="200" /></a>
-</div>
-<div class="view">
-<a href="hello-tabhost.html">TabHost / TabWidget<br/>
-<img src="images/hello-tabhost.png" height="285" width="200" /></a>
-</div>
-ProgressBar; RatingBar; FrameLayout
-
--->
-
-<p class="note" style="clear:left">
-There are plenty more Views and widgets available. See the {@link android.view.View} class
-for more on View layouts, and the {@link android.widget widget package}
-for more useful widgets. And for more raw code samples, visit the
-<a href="{@docRoot}guide/samples/ApiDemos/src/com/example/android/apis/view/index.html">Api Demos</a>.
-These can also be found offline, in <code>/<sdk>/samples/ApiDemos</code>.</p>
-</div>
-
diff --git a/docs/html/index.jd b/docs/html/index.jd
index d5f19a1..eeeedd0 100644
--- a/docs/html/index.jd
+++ b/docs/html/index.jd
@@ -15,10 +15,11 @@
alt="Android at Google IO 2011" width="200px"
style="padding-left:22px;padding-bottom:15px;padding-top:15px;"/>
<div id="announcement" style="width:275px">
- <p>Google I/O is a two-day developer event that will take place May 10-11 at Moscone Center, San
-Francisco. The agenda includes several sessions about Android, presented by Android engineers and
-other team members.</p><p><a href="http://www.google.com/events/io/2011/sessions.html">Learn
-more »</a></p>
+ <p>Thanks to everybody who joined us at Google I/O! If you couldn't make it or would like to
+review any of the Android sessions, they're now available on YouTube at the <a
+href="http://www.youtube.com/googledevelopers">Google Developers</a> channel, along with the keynote
+and other developer sessions. You can also find all the Google I/O Android sessions on this site, on
+the <a href="{@docRoot}videos/index.html">Videos</a> page.</p>
</div> <!-- end annoucement -->
</div> <!-- end annoucement-block -->
</div><!-- end topAnnouncement -->
diff --git a/docs/html/sdk/android-3.1.jd b/docs/html/sdk/android-3.1.jd
index 57fe1eb..992b7d1 100644
--- a/docs/html/sdk/android-3.1.jd
+++ b/docs/html/sdk/android-3.1.jd
@@ -107,8 +107,8 @@
USB. </p>
<p>The stack and APIs distinguish two basic types of USB hardware, based on
-whether the platform iself is acting as host or the external hardware is acting
-as host: </p>
+whether the Android-powered device is acting as host or the external hardware
+is acting as host: </p>
<ul>
<li>A <em>USB device</em> is a piece of connected hardware that depends on the
diff --git a/docs/html/sdk/oem-usb.jd b/docs/html/sdk/oem-usb.jd
index c94668f5..27e742a 100644
--- a/docs/html/sdk/oem-usb.jd
+++ b/docs/html/sdk/oem-usb.jd
@@ -36,6 +36,11 @@
href="http://www.acer.com/worldwide/support/mobile.html">http://www.acer.com/worldwide/support/mobile.html</a>
</td></tr>
<tr>
+ <td style="font-variant:small-caps">alcatel one touch</td>
+ <td><a
+href="http://www.alcatel-mobilephones.com/global/Android-Downloads">http://www.alcatel-mobilephones.com/global/Android-Downloads</a></td>
+ </tr>
+ <tr>
<td>Asus</td>
<td><a href="http://support.asus.com/download/">http://support.asus.com/download/</a></td>
</tr>
diff --git a/docs/html/videos/index.jd b/docs/html/videos/index.jd
index 50bdb46..7f5df78 100644
--- a/docs/html/videos/index.jd
+++ b/docs/html/videos/index.jd
@@ -37,12 +37,12 @@
* Each playlist ID is paired with a custom video description.
*/
var featured = {
-// Android UI design patterns
- 'M1ZBjlCRfz0' : "The Android user experience team provides suggestions for how to make your applications more useable and engaging.",
-// The world of ListView
- 'wDBM6wVEO70' : "ListView is a common widget that's customizable, but can be tricky to polish, so this talk shows how you can provide the best performance.",
-// Debugging Arts of the Ninja Masters
- 'Dgnx0E7m1GQ' : "The Android SDK includes tools to debug your apps like a ninja. Enter the dojo and become a master at debugging your apps."
+// Android Development Tools
+ 'Oq05KqjXTvs' : "The team behind the Android Development Tools demonstrate several powerful features for app development, including new capabilities in the Eclipse layout editor.",
+// Android UIs for phones and tablets
+ 'WGIU2JX1U5Y' : "This talk from the Android UI team explains several design patterns that the team recommends you use when designing your application for screens of all sizes.",
+// Android Protips
+ 'twmuBbC_oB8' : "In this talk, you'll learn how to create a well polished app that abides by several key virtues, using advanced development techniques and some lesser known APIs."
};
/* When an event on the browser history occurs (back, forward, load),
@@ -177,7 +177,7 @@
for (var i in ids) {
var script = "<script type='text/javascript' src='http://gdata.youtube.com/feeds/api/playlists/"
+ ids[i] +
- "?v=2&alt=json-in-script&callback=renderPlaylist'><\/script>";
+ "?v=2&alt=json-in-script&max-results=50&callback=renderPlaylist'><\/script>";
$("body").append(script);
}
}
diff --git a/include/media/MediaProfiles.h b/include/media/MediaProfiles.h
index f2107ec..ed26e63 100644
--- a/include/media/MediaProfiles.h
+++ b/include/media/MediaProfiles.h
@@ -150,6 +150,12 @@
*/
Vector<int> getImageEncodingQualityLevels(int cameraId) const;
+ /**
+ * Returns the start time offset (in ms) for the given camera Id.
+ * If the given camera Id does not exist, -1 will be returned.
+ */
+ int getStartTimeOffsetMs(int cameraId) const;
+
private:
enum {
// Camcorder profiles (high/low) and timelapse profiles (high/low)
@@ -332,6 +338,8 @@
static int getCameraId(const char **atts);
+ void addStartTimeOffset(int cameraId, const char **atts);
+
ImageEncodingQualityLevels* findImageEncodingQualityLevels(int cameraId) const;
void addImageEncodingQualityLevel(int cameraId, const char** atts);
@@ -408,6 +416,7 @@
Vector<VideoDecoderCap*> mVideoDecoders;
Vector<output_format> mEncoderOutputFileFormats;
Vector<ImageEncodingQualityLevels *> mImageEncodingQualityLevels;
+ KeyedVector<int, int> mStartTimeOffsets;
typedef struct {
bool mHasRefProfile; // Refers to an existing profile
diff --git a/include/media/stagefright/MPEG4Writer.h b/include/media/stagefright/MPEG4Writer.h
index 4b5674e..1764306 100644
--- a/include/media/stagefright/MPEG4Writer.h
+++ b/include/media/stagefright/MPEG4Writer.h
@@ -55,6 +55,10 @@
status_t setInterleaveDuration(uint32_t duration);
int32_t getTimeScale() const { return mTimeScale; }
+ status_t setGeoData(int latitudex10000, int longitudex10000);
+ void setStartTimeOffsetMs(int ms) { mStartTimeOffsetMs = ms; }
+ int32_t getStartTimeOffsetMs() const { return mStartTimeOffsetMs; }
+
protected:
virtual ~MPEG4Writer();
@@ -79,6 +83,10 @@
uint32_t mInterleaveDurationUs;
int32_t mTimeScale;
int64_t mStartTimestampUs;
+ int mLatitudex10000;
+ int mLongitudex10000;
+ bool mAreGeoTagsAvailable;
+ int32_t mStartTimeOffsetMs;
Mutex mLock;
@@ -169,6 +177,10 @@
void writeMvhdBox(int64_t durationUs);
void writeMoovBox(int64_t durationUs);
void writeFtypBox(const MetaData *param);
+ void writeUdtaBox();
+ void writeGeoDataBox();
+ void writeLatitude(int degreex10000);
+ void writeLongitude(int degreex10000);
void sendSessionSummary();
MPEG4Writer(const MPEG4Writer &);
diff --git a/libs/utils/BackupHelpers.cpp b/libs/utils/BackupHelpers.cpp
index cfb013e..e15875f 100644
--- a/libs/utils/BackupHelpers.cpp
+++ b/libs/utils/BackupHelpers.cpp
@@ -468,6 +468,19 @@
sprintf(buf + 148, "%06o", sum); // the trailing space is already in place
}
+// Returns number of bytes written
+static int write_pax_header_entry(char* buf, const char* key, const char* value) {
+ // start with the size of "1 key=value\n"
+ int len = strlen(key) + strlen(value) + 4;
+ if (len > 9) len++;
+ if (len > 99) len++;
+ if (len > 999) len++;
+ // since PATH_MAX is 4096 we don't expect to have to generate any single
+ // header entry longer than 9999 characters
+
+ return sprintf(buf, "%d %s=%s\n", len, key, value);
+}
+
int write_tarfile(const String8& packageName, const String8& domain,
const String8& rootpath, const String8& filepath, BackupDataWriter* writer)
{
@@ -525,8 +538,7 @@
}
// Good to go -- first construct the standard tar header at the start of the buffer
- memset(buf, 0, 512); // tar header is 512 bytes
- memset(paxHeader, 0, 512);
+ memset(buf, 0, BUFSIZE);
// Magic fields for the ustar file format
strcat(buf + 257, "ustar");
@@ -602,24 +614,20 @@
// If we're using a pax extended header, build & write that here; lengths are
// already preflighted
if (needExtended) {
+ char sizeStr[32]; // big enough for a 64-bit unsigned value in decimal
+ char* p = paxData;
+
// construct the pax extended header data block
memset(paxData, 0, BUFSIZE - (paxData - buf));
- char* p = paxData;
int len;
// size header -- calc len in digits by actually rendering the number
// to a string - brute force but simple
- len = sprintf(p, "%lld", s.st_size) + 8; // 8 for "1 size=" and final LF
- if (len >= 10) len++;
-
- memset(p, 0, 512);
- p += sprintf(p, "%d size=%lld\n", len, s.st_size);
+ snprintf(sizeStr, sizeof(sizeStr), "%lld", s.st_size);
+ p += write_pax_header_entry(p, "size", sizeStr);
// fullname was generated above with the ustar paths
- len = fullname.length() + 8; // 8 for "1 path=" and final LF
- if (len >= 10) len++;
- if (len >= 100) len++;
- p += sprintf(p, "%d path=%s\n", len, fullname.string());
+ p += write_pax_header_entry(p, "path", fullname.string());
// Now we know how big the pax data is
int paxLen = p - paxData;
diff --git a/media/java/android/media/MediaRecorder.java b/media/java/android/media/MediaRecorder.java
index 9593f30..961ee1e 100644
--- a/media/java/android/media/MediaRecorder.java
+++ b/media/java/android/media/MediaRecorder.java
@@ -347,6 +347,40 @@
}
/**
+ * Store the geodata (latitude and longitude) in the output file.
+ * This method should be called before prepare(). The geodata is
+ * stored in udta box if the output format is OutputFormat.THREE_GPP
+ * or OutputFormat.MPEG_4, and is ignored for other output formats.
+ * The geodata is stored according to ISO-6709 standard.
+ *
+ * @param latitude latitude in degrees. Its value must be in the
+ * range [-90, 90].
+ * @param longitude longitude in degrees. Its value must be in the
+ * range [-180, 180].
+ *
+ * @throws IllegalArgumentException if the given latitude or
+ * longitude is out of range.
+ *
+ * {@hide}
+ */
+ public void setGeoData(float latitude, float longitude) {
+ int latitudex10000 = (int) (latitude * 10000 + 0.5);
+ int longitudex10000 = (int) (longitude * 10000 + 0.5);
+
+ if (latitudex10000 > 900000 || latitudex10000 < -900000) {
+ String msg = "Unsupported latitude: " + latitude;
+ throw new IllegalArgumentException(msg);
+ }
+ if (longitudex10000 > 1800000 || longitudex10000 < -1800000) {
+ String msg = "Unsupported longitude: " + longitude;
+ throw new IllegalArgumentException(msg);
+ }
+
+ setParameter("param-geotag-latitude=" + latitudex10000);
+ setParameter("param-geotag-longitude=" + longitudex10000);
+ }
+
+ /**
* Sets the format of the output file produced during recording. Call this
* after setAudioSource()/setVideoSource() but before prepare().
*
diff --git a/media/java/android/mtp/MtpStorage.java b/media/java/android/mtp/MtpStorage.java
index 33146e7..21a18ca 100644
--- a/media/java/android/mtp/MtpStorage.java
+++ b/media/java/android/mtp/MtpStorage.java
@@ -29,12 +29,15 @@
private final String mPath;
private final String mDescription;
private final long mReserveSpace;
+ private final boolean mRemovable;
- public MtpStorage(int id, String path, String description, long reserveSpace) {
+ public MtpStorage(int id, String path, String description,
+ long reserveSpace, boolean removable) {
mStorageId = id;
mPath = path;
mDescription = description;
mReserveSpace = reserveSpace;
+ mRemovable = removable;
}
/**
@@ -86,4 +89,12 @@
return mReserveSpace;
}
+ /**
+ * Returns true if the storage is removable.
+ *
+ * @return is removable
+ */
+ public final boolean isRemovable() {
+ return mRemovable;
+ }
}
diff --git a/media/jni/android_mtp_MtpServer.cpp b/media/jni/android_mtp_MtpServer.cpp
index 84c2c7e..4d84cb7 100644
--- a/media/jni/android_mtp_MtpServer.cpp
+++ b/media/jni/android_mtp_MtpServer.cpp
@@ -47,6 +47,7 @@
static jfieldID field_MtpStorage_path;
static jfieldID field_MtpStorage_description;
static jfieldID field_MtpStorage_reserveSpace;
+static jfieldID field_MtpStorage_removable;
static Mutex sMutex;
@@ -245,12 +246,13 @@
jstring path = (jstring)env->GetObjectField(jstorage, field_MtpStorage_path);
jstring description = (jstring)env->GetObjectField(jstorage, field_MtpStorage_description);
jlong reserveSpace = env->GetLongField(jstorage, field_MtpStorage_reserveSpace);
+ jboolean removable = env->GetBooleanField(jstorage, field_MtpStorage_removable);
const char *pathStr = env->GetStringUTFChars(path, NULL);
if (pathStr != NULL) {
const char *descriptionStr = env->GetStringUTFChars(description, NULL);
if (descriptionStr != NULL) {
- MtpStorage* storage = new MtpStorage(storageID, pathStr, descriptionStr, reserveSpace);
+ MtpStorage* storage = new MtpStorage(storageID, pathStr, descriptionStr, reserveSpace, removable);
thread->addStorage(storage);
env->ReleaseStringUTFChars(path, pathStr);
env->ReleaseStringUTFChars(description, descriptionStr);
@@ -322,7 +324,12 @@
}
field_MtpStorage_reserveSpace = env->GetFieldID(clazz, "mReserveSpace", "J");
if (field_MtpStorage_reserveSpace == NULL) {
- LOGE("Can't find MtpStorage.mStorageId");
+ LOGE("Can't find MtpStorage.mReserveSpace");
+ return -1;
+ }
+ field_MtpStorage_removable = env->GetFieldID(clazz, "mRemovable", "Z");
+ if (field_MtpStorage_removable == NULL) {
+ LOGE("Can't find MtpStorage.mRemovable");
return -1;
}
clazz_MtpStorage = (jclass)env->NewGlobalRef(clazz);
diff --git a/media/libmedia/MediaProfiles.cpp b/media/libmedia/MediaProfiles.cpp
index e6f3a33..069bbb7 100644
--- a/media/libmedia/MediaProfiles.cpp
+++ b/media/libmedia/MediaProfiles.cpp
@@ -356,6 +356,18 @@
return atoi(atts[1]);
}
+void MediaProfiles::addStartTimeOffset(int cameraId, const char** atts)
+{
+ int offsetTimeMs = 700;
+ if (atts[2]) {
+ CHECK(!strcmp("startOffsetMs", atts[2]));
+ offsetTimeMs = atoi(atts[3]);
+ }
+
+ LOGV("%s: cameraId=%d, offset=%d ms", __func__, cameraId, offsetTimeMs);
+ mStartTimeOffsets.replaceValueFor(cameraId, offsetTimeMs);
+}
+
/*static*/ void
MediaProfiles::startElementHandler(void *userData, const char *name, const char **atts)
{
@@ -380,6 +392,7 @@
profiles->mEncoderOutputFileFormats.add(createEncoderOutputFileFormat(atts));
} else if (strcmp("CamcorderProfiles", name) == 0) {
profiles->mCurrentCameraId = getCameraId(atts);
+ profiles->addStartTimeOffset(profiles->mCurrentCameraId, atts);
} else if (strcmp("EncoderProfile", name) == 0) {
profiles->mCamcorderProfiles.add(
createCamcorderProfile(profiles->mCurrentCameraId, atts, profiles->mCameraIds));
@@ -997,6 +1010,16 @@
return result;
}
+int MediaProfiles::getStartTimeOffsetMs(int cameraId) const {
+ int offsetTimeMs = -1;
+ ssize_t index = mStartTimeOffsets.indexOfKey(cameraId);
+ if (index >= 0) {
+ offsetTimeMs = mStartTimeOffsets.valueFor(cameraId);
+ }
+ LOGV("%s: offsetTime=%d ms and cameraId=%d", offsetTimeMs, cameraId);
+ return offsetTimeMs;
+}
+
MediaProfiles::~MediaProfiles()
{
CHECK("destructor should never be called" == 0);
diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp
index f21474f..978571c 100644
--- a/media/libmediaplayerservice/StagefrightRecorder.cpp
+++ b/media/libmediaplayerservice/StagefrightRecorder.cpp
@@ -593,6 +593,26 @@
return OK;
}
+status_t StagefrightRecorder::setParamGeoDataLongitude(
+ int32_t longitudex10000) {
+
+ if (longitudex10000 > 1800000 || longitudex10000 < -1800000) {
+ return BAD_VALUE;
+ }
+ mLongitudex10000 = longitudex10000;
+ return OK;
+}
+
+status_t StagefrightRecorder::setParamGeoDataLatitude(
+ int32_t latitudex10000) {
+
+ if (latitudex10000 > 900000 || latitudex10000 < -900000) {
+ return BAD_VALUE;
+ }
+ mLatitudex10000 = latitudex10000;
+ return OK;
+}
+
status_t StagefrightRecorder::setParameter(
const String8 &key, const String8 &value) {
LOGV("setParameter: key (%s) => value (%s)", key.string(), value.string());
@@ -621,6 +641,16 @@
if (safe_strtoi32(value.string(), &use64BitOffset)) {
return setParam64BitFileOffset(use64BitOffset != 0);
}
+ } else if (key == "param-geotag-longitude") {
+ int32_t longitudex10000;
+ if (safe_strtoi32(value.string(), &longitudex10000)) {
+ return setParamGeoDataLongitude(longitudex10000);
+ }
+ } else if (key == "param-geotag-latitude") {
+ int32_t latitudex10000;
+ if (safe_strtoi32(value.string(), &latitudex10000)) {
+ return setParamGeoDataLatitude(latitudex10000);
+ }
} else if (key == "param-track-time-status") {
int64_t timeDurationUs;
if (safe_strtoi64(value.string(), &timeDurationUs)) {
@@ -1412,6 +1442,10 @@
reinterpret_cast<MPEG4Writer *>(writer.get())->
setInterleaveDuration(mInterleaveDurationUs);
}
+ if (mLongitudex10000 > -3600000 && mLatitudex10000 > -3600000) {
+ reinterpret_cast<MPEG4Writer *>(writer.get())->
+ setGeoData(mLatitudex10000, mLongitudex10000);
+ }
if (mMaxFileDurationUs != 0) {
writer->setMaxFileDuration(mMaxFileDurationUs);
}
@@ -1419,6 +1453,12 @@
writer->setMaxFileSize(mMaxFileSizeBytes);
}
+ mStartTimeOffsetMs = mEncoderProfiles->getStartTimeOffsetMs(mCameraId);
+ if (mStartTimeOffsetMs > 0) {
+ reinterpret_cast<MPEG4Writer *>(writer.get())->
+ setStartTimeOffsetMs(mStartTimeOffsetMs);
+ }
+
writer->setListener(mListener);
*mediaWriter = writer;
return OK;
@@ -1625,6 +1665,7 @@
mAudioTimeScale = -1;
mVideoTimeScale = -1;
mCameraId = 0;
+ mStartTimeOffsetMs = -1;
mVideoEncoderProfile = -1;
mVideoEncoderLevel = -1;
mMaxFileDurationUs = 0;
@@ -1638,6 +1679,8 @@
mIsMetaDataStoredInVideoBuffers = false;
mEncoderProfiles = MediaProfiles::getInstance();
mRotationDegrees = 0;
+ mLatitudex10000 = -3600000;
+ mLongitudex10000 = -3600000;
mOutputFd = -1;
mOutputFdAux = -1;
@@ -1711,6 +1754,8 @@
result.append(buffer);
snprintf(buffer, SIZE, " Camera Id: %d\n", mCameraId);
result.append(buffer);
+ snprintf(buffer, SIZE, " Start time offset (ms): %d\n", mStartTimeOffsetMs);
+ result.append(buffer);
snprintf(buffer, SIZE, " Encoder: %d\n", mVideoEncoder);
result.append(buffer);
snprintf(buffer, SIZE, " Encoder profile: %d\n", mVideoEncoderProfile);
diff --git a/media/libmediaplayerservice/StagefrightRecorder.h b/media/libmediaplayerservice/StagefrightRecorder.h
index 15ef6e24..aa67aa7 100644
--- a/media/libmediaplayerservice/StagefrightRecorder.h
+++ b/media/libmediaplayerservice/StagefrightRecorder.h
@@ -97,6 +97,9 @@
int64_t mMaxFileDurationUs;
int64_t mTrackEveryTimeDurationUs;
int32_t mRotationDegrees; // Clockwise
+ int32_t mLatitudex10000;
+ int32_t mLongitudex10000;
+ int32_t mStartTimeOffsetMs;
bool mCaptureTimeLapse;
int64_t mTimeBetweenTimeLapseFrameCaptureUs;
@@ -160,6 +163,8 @@
status_t setParamMaxFileDurationUs(int64_t timeUs);
status_t setParamMaxFileSizeBytes(int64_t bytes);
status_t setParamMovieTimeScale(int32_t timeScale);
+ status_t setParamGeoDataLongitude(int32_t longitudex10000);
+ status_t setParamGeoDataLatitude(int32_t latitudex10000);
void clipVideoBitRate();
void clipVideoFrameRate();
void clipVideoFrameWidth();
diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp
index fdd2f68..9dc83a6 100644
--- a/media/libstagefright/MPEG4Writer.cpp
+++ b/media/libstagefright/MPEG4Writer.cpp
@@ -257,7 +257,11 @@
mOffset(0),
mMdatOffset(0),
mEstimatedMoovBoxSize(0),
- mInterleaveDurationUs(1000000) {
+ mInterleaveDurationUs(1000000),
+ mLatitudex10000(0),
+ mLongitudex10000(0),
+ mAreGeoTagsAvailable(false),
+ mStartTimeOffsetMs(-1) {
mFd = open(filename, O_CREAT | O_LARGEFILE | O_TRUNC | O_RDWR);
if (mFd >= 0) {
@@ -276,7 +280,11 @@
mOffset(0),
mMdatOffset(0),
mEstimatedMoovBoxSize(0),
- mInterleaveDurationUs(1000000) {
+ mInterleaveDurationUs(1000000),
+ mLatitudex10000(0),
+ mLongitudex10000(0),
+ mAreGeoTagsAvailable(false),
+ mStartTimeOffsetMs(-1) {
}
MPEG4Writer::~MPEG4Writer() {
@@ -724,6 +732,9 @@
void MPEG4Writer::writeMoovBox(int64_t durationUs) {
beginBox("moov");
writeMvhdBox(durationUs);
+ if (mAreGeoTagsAvailable) {
+ writeUdtaBox();
+ }
int32_t id = 1;
for (List<Track *>::iterator it = mTracks.begin();
it != mTracks.end(); ++it, ++id) {
@@ -921,6 +932,77 @@
write(s, 1, 4);
}
+
+// Written in +/-DD.DDDD format
+void MPEG4Writer::writeLatitude(int degreex10000) {
+ bool isNegative = (degreex10000 < 0);
+ char sign = isNegative? '-': '+';
+
+ // Handle the whole part
+ char str[9];
+ int wholePart = degreex10000 / 10000;
+ if (wholePart == 0) {
+ snprintf(str, 5, "%c%.2d.", sign, wholePart);
+ } else {
+ snprintf(str, 5, "%+.2d.", wholePart);
+ }
+
+ // Handle the fractional part
+ int fractionalPart = degreex10000 - (wholePart * 10000);
+ if (fractionalPart < 0) {
+ fractionalPart = -fractionalPart;
+ }
+ snprintf(&str[4], 5, "%.4d", fractionalPart);
+
+ // Do not write the null terminator
+ write(str, 1, 8);
+}
+
+// Written in +/- DDD.DDDD format
+void MPEG4Writer::writeLongitude(int degreex10000) {
+ bool isNegative = (degreex10000 < 0);
+ char sign = isNegative? '-': '+';
+
+ // Handle the whole part
+ char str[10];
+ int wholePart = degreex10000 / 10000;
+ if (wholePart == 0) {
+ snprintf(str, 6, "%c%.3d.", sign, wholePart);
+ } else {
+ snprintf(str, 6, "%+.3d.", wholePart);
+ }
+
+ // Handle the fractional part
+ int fractionalPart = degreex10000 - (wholePart * 10000);
+ if (fractionalPart < 0) {
+ fractionalPart = -fractionalPart;
+ }
+ snprintf(&str[5], 5, "%.4d", fractionalPart);
+
+ // Do not write the null terminator
+ write(str, 1, 9);
+}
+
+/*
+ * Geodata is stored according to ISO-6709 standard.
+ * latitudex10000 is latitude in degrees times 10000, and
+ * longitudex10000 is longitude in degrees times 10000.
+ * The range for the latitude is in [-90, +90], and
+ * The range for the longitude is in [-180, +180]
+ */
+status_t MPEG4Writer::setGeoData(int latitudex10000, int longitudex10000) {
+ // Is latitude or longitude out of range?
+ if (latitudex10000 < -900000 || latitudex10000 > 900000 ||
+ longitudex10000 < -1800000 || longitudex10000 > 1800000) {
+ return BAD_VALUE;
+ }
+
+ mLatitudex10000 = latitudex10000;
+ mLongitudex10000 = longitudex10000;
+ mAreGeoTagsAvailable = true;
+ return OK;
+}
+
void MPEG4Writer::write(const void *data, size_t size) {
write(data, 1, size);
}
@@ -1345,10 +1427,15 @@
* session, and it also helps eliminate the "recording" sound for
* camcorder applications.
*
- * Ideally, this platform-specific value should be defined
- * in media_profiles.xml file
+ * If client does not set the start time offset, we fall back to
+ * use the default initial delay value.
*/
- startTimeUs += kInitialDelayTimeUs;
+ int64_t startTimeOffsetUs = mOwner->getStartTimeOffsetMs() * 1000LL;
+ if (startTimeOffsetUs < 0) { // Start time offset was not set
+ startTimeOffsetUs = kInitialDelayTimeUs;
+ }
+ startTimeUs += startTimeOffsetUs;
+ LOGI("Start time offset: %lld us", startTimeOffsetUs);
}
meta->setInt64(kKeyTime, startTimeUs);
@@ -2154,13 +2241,20 @@
trackNum | MEDIA_RECORDER_TRACK_INFO_ENCODED_FRAMES,
mNumSamples);
- // The system delay time excluding the requested initial delay that
- // is used to eliminate the recording sound.
- int64_t initialDelayUs =
- mFirstSampleTimeRealUs - mStartTimeRealUs - kInitialDelayTimeUs;
- mOwner->notify(MEDIA_RECORDER_TRACK_EVENT_INFO,
+ {
+ // The system delay time excluding the requested initial delay that
+ // is used to eliminate the recording sound.
+ int64_t startTimeOffsetUs = mOwner->getStartTimeOffsetMs() * 1000LL;
+ if (startTimeOffsetUs < 0) { // Start time offset was not set
+ startTimeOffsetUs = kInitialDelayTimeUs;
+ }
+ int64_t initialDelayUs =
+ mFirstSampleTimeRealUs - mStartTimeRealUs - startTimeOffsetUs;
+
+ mOwner->notify(MEDIA_RECORDER_TRACK_EVENT_INFO,
trackNum | MEDIA_RECORDER_TRACK_INFO_INITIAL_DELAY_MS,
(initialDelayUs) / 1000);
+ }
if (hasMultipleTracks) {
mOwner->notify(MEDIA_RECORDER_TRACK_EVENT_INFO,
@@ -2722,4 +2816,29 @@
mOwner->endBox(); // stco or co64
}
+void MPEG4Writer::writeUdtaBox() {
+ beginBox("udta");
+ writeGeoDataBox();
+ endBox();
+}
+
+/*
+ * Geodata is stored according to ISO-6709 standard.
+ */
+void MPEG4Writer::writeGeoDataBox() {
+ beginBox("\xA9xyz");
+ /*
+ * For historical reasons, any user data start
+ * with "\0xA9", must be followed by its assoicated
+ * language code.
+ * 0x0012: locale en
+ * 0x15c7: language 5575
+ */
+ writeInt32(0x001215c7);
+ writeLatitude(mLatitudex10000);
+ writeLongitude(mLongitudex10000);
+ writeInt8(0x2F);
+ endBox();
+}
+
} // namespace android
diff --git a/media/libstagefright/codecs/aacdec/Android.mk b/media/libstagefright/codecs/aacdec/Android.mk
index 5ef54fd..359a2ec 100644
--- a/media/libstagefright/codecs/aacdec/Android.mk
+++ b/media/libstagefright/codecs/aacdec/Android.mk
@@ -176,6 +176,6 @@
libstagefright_omx libstagefright_foundation libutils
LOCAL_MODULE := libstagefright_soft_aacdec
-LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libstagefright/codecs/amrnb/dec/Android.mk b/media/libstagefright/codecs/amrnb/dec/Android.mk
index 296cae4..5862abc 100644
--- a/media/libstagefright/codecs/amrnb/dec/Android.mk
+++ b/media/libstagefright/codecs/amrnb/dec/Android.mk
@@ -79,6 +79,6 @@
libstagefright_amrnb_common
LOCAL_MODULE := libstagefright_soft_amrdec
-LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libstagefright/codecs/avc/dec/Android.mk b/media/libstagefright/codecs/avc/dec/Android.mk
index afecdc4..4d4533b 100644
--- a/media/libstagefright/codecs/avc/dec/Android.mk
+++ b/media/libstagefright/codecs/avc/dec/Android.mk
@@ -50,7 +50,7 @@
libstagefright libstagefright_omx libstagefright_foundation libutils
LOCAL_MODULE := libstagefright_soft_avcdec
-LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libstagefright/codecs/g711/dec/Android.mk b/media/libstagefright/codecs/g711/dec/Android.mk
index b6953bc..6e98559 100644
--- a/media/libstagefright/codecs/g711/dec/Android.mk
+++ b/media/libstagefright/codecs/g711/dec/Android.mk
@@ -26,6 +26,6 @@
libstagefright libstagefright_omx libstagefright_foundation libutils
LOCAL_MODULE := libstagefright_soft_g711dec
-LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libstagefright/codecs/m4v_h263/dec/Android.mk b/media/libstagefright/codecs/m4v_h263/dec/Android.mk
index 65b642c..f1bec08 100644
--- a/media/libstagefright/codecs/m4v_h263/dec/Android.mk
+++ b/media/libstagefright/codecs/m4v_h263/dec/Android.mk
@@ -71,6 +71,6 @@
libstagefright libstagefright_omx libstagefright_foundation libutils
LOCAL_MODULE := libstagefright_soft_mpeg4dec
-LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libstagefright/codecs/mp3dec/Android.mk b/media/libstagefright/codecs/mp3dec/Android.mk
index 2d35183..229988e 100644
--- a/media/libstagefright/codecs/mp3dec/Android.mk
+++ b/media/libstagefright/codecs/mp3dec/Android.mk
@@ -77,6 +77,6 @@
libstagefright_mp3dec
LOCAL_MODULE := libstagefright_soft_mp3dec
-LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libstagefright/codecs/on2/dec/Android.mk b/media/libstagefright/codecs/on2/dec/Android.mk
index 1b3088f..832b885 100644
--- a/media/libstagefright/codecs/on2/dec/Android.mk
+++ b/media/libstagefright/codecs/on2/dec/Android.mk
@@ -37,7 +37,7 @@
libstagefright libstagefright_omx libstagefright_foundation libutils
LOCAL_MODULE := libstagefright_soft_vpxdec
-LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libstagefright/codecs/vorbis/dec/Android.mk b/media/libstagefright/codecs/vorbis/dec/Android.mk
index 06f0079..9251229 100644
--- a/media/libstagefright/codecs/vorbis/dec/Android.mk
+++ b/media/libstagefright/codecs/vorbis/dec/Android.mk
@@ -32,7 +32,7 @@
libstagefright_foundation libutils
LOCAL_MODULE := libstagefright_soft_vorbisdec
-LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libstagefright/colorconversion/SoftwareRenderer.cpp b/media/libstagefright/colorconversion/SoftwareRenderer.cpp
index ee861484..a4e8ee4 100644
--- a/media/libstagefright/colorconversion/SoftwareRenderer.cpp
+++ b/media/libstagefright/colorconversion/SoftwareRenderer.cpp
@@ -56,9 +56,21 @@
}
int halFormat;
+ size_t bufWidth, bufHeight;
+
switch (mColorFormat) {
+ case OMX_COLOR_FormatYUV420Planar:
+ {
+ halFormat = HAL_PIXEL_FORMAT_YV12;
+ bufWidth = (mWidth + 1) & ~1;
+ bufHeight = (mHeight + 1) & ~1;
+ break;
+ }
+
default:
halFormat = HAL_PIXEL_FORMAT_RGB_565;
+ bufWidth = mWidth;
+ bufHeight = mHeight;
mConverter = new ColorConverter(
mColorFormat, OMX_COLOR_Format16bitRGB565);
@@ -80,8 +92,8 @@
// Width must be multiple of 32???
CHECK_EQ(0, native_window_set_buffers_geometry(
mNativeWindow.get(),
- mCropRight - mCropLeft + 1,
- mCropBottom - mCropTop + 1,
+ bufWidth,
+ bufHeight,
halFormat));
uint32_t transform;
@@ -97,6 +109,14 @@
CHECK_EQ(0, native_window_set_buffers_transform(
mNativeWindow.get(), transform));
}
+
+ android_native_rect_t crop;
+ crop.left = mCropLeft;
+ crop.top = mCropTop;
+ crop.right = mCropRight + 1;
+ crop.bottom = mCropBottom + 1;
+
+ CHECK_EQ(0, native_window_set_crop(mNativeWindow.get(), &crop));
}
SoftwareRenderer::~SoftwareRenderer() {
@@ -104,6 +124,11 @@
mConverter = NULL;
}
+static int ALIGN(int x, int y) {
+ // y must be a power of 2.
+ return (x + y - 1) & ~(y - 1);
+}
+
void SoftwareRenderer::render(
const void *data, size_t size, void *platformPrivate) {
ANativeWindowBuffer *buf;
@@ -127,14 +152,40 @@
mConverter->convert(
data,
mWidth, mHeight,
- mCropLeft, mCropTop, mCropRight, mCropBottom,
+ 0, 0, mWidth - 1, mHeight - 1,
dst,
buf->stride, buf->height,
- 0, 0,
- mCropRight - mCropLeft,
- mCropBottom - mCropTop);
+ 0, 0, mWidth - 1, mHeight - 1);
} else {
- TRESPASS();
+ CHECK_EQ(mColorFormat, OMX_COLOR_FormatYUV420Planar);
+
+ const uint8_t *src_y = (const uint8_t *)data;
+ const uint8_t *src_u = (const uint8_t *)data + mWidth * mHeight;
+ const uint8_t *src_v = src_u + (mWidth / 2 * mHeight / 2);
+
+ uint8_t *dst_y = (uint8_t *)dst;
+ size_t dst_y_size = buf->stride * buf->height;
+ size_t dst_c_stride = ALIGN(buf->stride / 2, 16);
+ size_t dst_c_size = dst_c_stride * buf->height / 2;
+ uint8_t *dst_v = dst_y + dst_y_size;
+ uint8_t *dst_u = dst_v + dst_c_size;
+
+ for (int y = 0; y < mHeight; ++y) {
+ memcpy(dst_y, src_y, mWidth);
+
+ src_y += mWidth;
+ dst_y += buf->stride;
+ }
+
+ for (int y = 0; y < (mHeight + 1) / 2; ++y) {
+ memcpy(dst_u, src_u, (mWidth + 1) / 2);
+ memcpy(dst_v, src_v, (mWidth + 1) / 2);
+
+ src_u += mWidth / 2;
+ src_v += mWidth / 2;
+ dst_u += dst_c_stride;
+ dst_v += dst_c_stride;
+ }
}
CHECK_EQ(0, mapper.unlock(buf->handle));
diff --git a/media/mtp/MtpStorage.cpp b/media/mtp/MtpStorage.cpp
index fff0b5f..fef8066 100644
--- a/media/mtp/MtpStorage.cpp
+++ b/media/mtp/MtpStorage.cpp
@@ -33,12 +33,13 @@
namespace android {
MtpStorage::MtpStorage(MtpStorageID id, const char* filePath,
- const char* description, uint64_t reserveSpace)
+ const char* description, uint64_t reserveSpace, bool removable)
: mStorageID(id),
mFilePath(filePath),
mDescription(description),
mMaxCapacity(0),
- mReserveSpace(reserveSpace)
+ mReserveSpace(reserveSpace),
+ mRemovable(removable)
{
LOGV("MtpStorage id: %d path: %s\n", id, filePath);
}
@@ -47,7 +48,7 @@
}
int MtpStorage::getType() const {
- return MTP_STORAGE_FIXED_RAM;
+ return (mRemovable ? MTP_STORAGE_REMOVABLE_RAM : MTP_STORAGE_FIXED_RAM);
}
int MtpStorage::getFileSystemType() const {
diff --git a/media/mtp/MtpStorage.h b/media/mtp/MtpStorage.h
index d6ad25f..3e4f40d 100644
--- a/media/mtp/MtpStorage.h
+++ b/media/mtp/MtpStorage.h
@@ -33,10 +33,12 @@
uint64_t mMaxCapacity;
// amount of free space to leave unallocated
uint64_t mReserveSpace;
+ bool mRemovable;
public:
MtpStorage(MtpStorageID id, const char* filePath,
- const char* description, uint64_t reserveSpace);
+ const char* description, uint64_t reserveSpace,
+ bool removable);
virtual ~MtpStorage();
inline MtpStorageID getStorageID() const { return mStorageID; }
@@ -47,6 +49,7 @@
uint64_t getFreeSpace();
const char* getDescription() const;
inline const char* getPath() const { return (const char *)mFilePath; }
+ inline bool isRemovable() const { return mRemovable; }
};
}; // namespace android
diff --git a/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java b/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java
index 805b905..4b42067 100644
--- a/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java
+++ b/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java
@@ -24,7 +24,6 @@
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
-import android.os.Looper;
import android.os.Message;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -77,7 +76,7 @@
public void handleMessage(Message msg) {
switch (msg.what) {
case MSG_START_BACKUP: {
- Toast.makeText(mContext, "!!! Backup starting !!!", Toast.LENGTH_LONG);
+ Toast.makeText(mContext, "!!! Backup starting !!!", Toast.LENGTH_LONG).show();
}
break;
@@ -88,12 +87,13 @@
break;
case MSG_END_BACKUP: {
- Toast.makeText(mContext, "!!! Backup ended !!!", Toast.LENGTH_SHORT);
+ Toast.makeText(mContext, "!!! Backup ended !!!", Toast.LENGTH_SHORT).show();
+ finish();
}
break;
case MSG_START_RESTORE: {
- Toast.makeText(mContext, "!!! Restore starting !!!", Toast.LENGTH_LONG);
+ Toast.makeText(mContext, "!!! Restore starting !!!", Toast.LENGTH_LONG).show();
}
break;
@@ -102,11 +102,13 @@
break;
case MSG_END_RESTORE: {
- Toast.makeText(mContext, "!!! Restore ended !!!", Toast.LENGTH_SHORT);
+ Toast.makeText(mContext, "!!! Restore ended !!!", Toast.LENGTH_SHORT).show();
+ finish();
}
break;
case MSG_TIMEOUT: {
+ Toast.makeText(mContext, "!!! TIMED OUT !!!", Toast.LENGTH_LONG).show();
}
break;
}
diff --git a/packages/SystemUI/res/drawable-mdpi/panel_notification.png b/packages/SystemUI/res/drawable-mdpi/panel_notification.png
deleted file mode 100644
index 3789f3c..0000000
--- a/packages/SystemUI/res/drawable-mdpi/panel_notification.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-nodpi/panel_notification.png b/packages/SystemUI/res/drawable-nodpi/panel_notification.png
deleted file mode 100644
index 437deff..0000000
--- a/packages/SystemUI/res/drawable-nodpi/panel_notification.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable/panel_notification_tiled.xml b/packages/SystemUI/res/drawable/panel_notification_tiled.xml
deleted file mode 100644
index 9d41e28..0000000
--- a/packages/SystemUI/res/drawable/panel_notification_tiled.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 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.
--->
-
-<bitmap
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:src="@drawable/panel_notification"
- android:tileMode="repeat"
- />
-
diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java
index a334dbb..77c2a44 100644
--- a/services/java/com/android/server/BackupManagerService.java
+++ b/services/java/com/android/server/BackupManagerService.java
@@ -1710,8 +1710,7 @@
IApplicationThread.BACKUP_MODE_FULL);
if (agent != null) {
try {
- ApplicationInfo app = mPackageManager.getApplicationInfo(
- pkg.packageName, 0);
+ ApplicationInfo app = pkg.applicationInfo;
boolean sendApk = mIncludeApks
&& ((app.flags & ApplicationInfo.FLAG_FORWARD_LOCK) == 0)
&& ((app.flags & ApplicationInfo.FLAG_SYSTEM) == 0 ||
@@ -1742,9 +1741,6 @@
} else {
if (DEBUG) Slog.d(TAG, "Full backup success: " + pkg.packageName);
}
- } catch (NameNotFoundException e) {
- Slog.e(TAG, "Package exists but not app info; skipping: "
- + pkg.packageName);
} catch (IOException e) {
Slog.e(TAG, "Error backing up " + pkg.packageName, e);
}
@@ -1816,8 +1812,11 @@
// unbind and tidy up even on timeout or failure, just in case
mActivityManager.unbindBackupAgent(app);
- // The agent was running with a stub Application object, so shut it down
- if (app.uid != Process.SYSTEM_UID) {
+ // The agent was running with a stub Application object, so shut it down.
+ // !!! We hardcode the confirmation UI's package name here rather than use a
+ // manifest flag! TODO something less direct.
+ if (app.uid != Process.SYSTEM_UID
+ && !pkg.packageName.equals("com.android.backupconfirm")) {
if (DEBUG) Slog.d(TAG, "Backup complete, killing host process");
mActivityManager.killApplicationProcess(app.processName, app.uid);
} else {
diff --git a/services/java/com/android/server/MountService.java b/services/java/com/android/server/MountService.java
index c18ccc8..03d5728 100644
--- a/services/java/com/android/server/MountService.java
+++ b/services/java/com/android/server/MountService.java
@@ -17,6 +17,7 @@
package com.android.server;
import com.android.internal.app.IMediaContainerService;
+import com.android.internal.util.XmlUtils;
import com.android.server.am.ActivityManagerService;
import com.android.server.pm.PackageManagerService;
@@ -29,6 +30,9 @@
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.content.res.ObbInfo;
+import android.content.res.Resources;
+import android.content.res.TypedArray;
+import android.content.res.XmlResourceParser;
import android.net.Uri;
import android.os.Binder;
import android.os.Environment;
@@ -37,6 +41,7 @@
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
+import android.os.Parcelable;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
@@ -47,8 +52,14 @@
import android.os.storage.IObbActionListener;
import android.os.storage.OnObbStateChangeListener;
import android.os.storage.StorageResultCode;
+import android.os.storage.StorageVolume;
import android.text.TextUtils;
+import android.util.AttributeSet;
import android.util.Slog;
+import android.util.Xml;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
import java.io.FileDescriptor;
import java.io.IOException;
@@ -149,6 +160,8 @@
private Context mContext;
private NativeDaemonConnector mConnector;
+ private final ArrayList<StorageVolume> mVolumes = new ArrayList<StorageVolume>();
+ private StorageVolume mPrimaryVolume;
private final HashMap<String, String> mVolumeStates = new HashMap<String, String>();
private String mExternalStoragePath;
private PackageManagerService mPms;
@@ -1071,6 +1084,74 @@
}
}
+ // Storage list XML tags
+ private static final String TAG_STORAGE_LIST = "StorageList";
+ private static final String TAG_STORAGE = "storage";
+
+ private void readStorageList(Resources resources) {
+ int id = com.android.internal.R.xml.storage_list;
+ XmlResourceParser parser = resources.getXml(id);
+ AttributeSet attrs = Xml.asAttributeSet(parser);
+
+ try {
+ XmlUtils.beginDocument(parser, TAG_STORAGE_LIST);
+ while (true) {
+ XmlUtils.nextElement(parser);
+
+ String element = parser.getName();
+ if (element == null) break;
+
+ if (TAG_STORAGE.equals(element)) {
+ TypedArray a = resources.obtainAttributes(attrs,
+ com.android.internal.R.styleable.Storage);
+
+ CharSequence path = a.getText(
+ com.android.internal.R.styleable.Storage_mountPoint);
+ CharSequence description = a.getText(
+ com.android.internal.R.styleable.Storage_storageDescription);
+ boolean primary = a.getBoolean(
+ com.android.internal.R.styleable.Storage_primary, false);
+ boolean removable = a.getBoolean(
+ com.android.internal.R.styleable.Storage_removable, false);
+ boolean emulated = a.getBoolean(
+ com.android.internal.R.styleable.Storage_emulated, false);
+ int mtpReserve = a.getInt(
+ com.android.internal.R.styleable.Storage_mtpReserve, 0);
+
+ Slog.d(TAG, "got storage path: " + path + " description: " + description +
+ " primary: " + primary + " removable: " + removable +
+ " emulated: " + emulated + " mtpReserve: " + mtpReserve);
+ if (path == null || description == null) {
+ Slog.e(TAG, "path or description is null in readStorageList");
+ } else {
+ StorageVolume volume = new StorageVolume(path.toString(),
+ description.toString(), removable, emulated, mtpReserve);
+ if (primary) {
+ if (mPrimaryVolume == null) {
+ mPrimaryVolume = volume;
+ } else {
+ Slog.e(TAG, "multiple primary volumes in storage list");
+ }
+ }
+ if (mPrimaryVolume == volume) {
+ // primay volume must be first
+ mVolumes.add(0, volume);
+ } else {
+ mVolumes.add(volume);
+ }
+ }
+ a.recycle();
+ }
+ }
+ } catch (XmlPullParserException e) {
+ throw new RuntimeException(e);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ } finally {
+ parser.close();
+ }
+ }
+
/**
* Constructs a new MountService instance
*
@@ -1078,13 +1159,16 @@
*/
public MountService(Context context) {
mContext = context;
+ Resources resources = context.getResources();
+ readStorageList(resources);
- mExternalStoragePath = Environment.getExternalStorageDirectory().getPath();
- mEmulateExternalStorage = context.getResources().getBoolean(
- com.android.internal.R.bool.config_emulateExternalStorage);
- if (mEmulateExternalStorage) {
- Slog.d(TAG, "using emulated external storage");
- mVolumeStates.put(mExternalStoragePath, Environment.MEDIA_MOUNTED);
+ if (mPrimaryVolume != null) {
+ mExternalStoragePath = mPrimaryVolume.getPath();
+ mEmulateExternalStorage = mPrimaryVolume.isEmulated();
+ if (mEmulateExternalStorage) {
+ Slog.d(TAG, "using emulated external storage");
+ mVolumeStates.put(mExternalStoragePath, Environment.MEDIA_MOUNTED);
+ }
}
// XXX: This will go away soon in favor of IMountServiceObserver
@@ -1756,13 +1840,12 @@
}
}
- public String[] getVolumeList() {
- synchronized(mVolumeStates) {
- Set<String> volumes = mVolumeStates.keySet();
- String[] result = new String[volumes.size()];
- int i = 0;
- for (String volume : volumes) {
- result[i++] = volume;
+ public Parcelable[] getVolumeList() {
+ synchronized(mVolumes) {
+ int size = mVolumes.size();
+ Parcelable[] result = new Parcelable[size];
+ for (int i = 0; i < size; i++) {
+ result[i] = mVolumes.get(i);
}
return result;
}
diff --git a/services/java/com/android/server/TelephonyRegistry.java b/services/java/com/android/server/TelephonyRegistry.java
index 948118f..dd54c16 100644
--- a/services/java/com/android/server/TelephonyRegistry.java
+++ b/services/java/com/android/server/TelephonyRegistry.java
@@ -545,7 +545,6 @@
}
Intent intent = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
- intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
Bundle data = new Bundle();
state.fillInNotifierBundle(data);
intent.putExtras(data);
@@ -585,7 +584,6 @@
}
Intent intent = new Intent(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
- intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
intent.putExtra(Phone.STATE_KEY, DefaultPhoneNotifier.convertCallState(state).toString());
if (!TextUtils.isEmpty(incomingNumber)) {
intent.putExtra(TelephonyManager.EXTRA_INCOMING_NUMBER, incomingNumber);
@@ -601,7 +599,6 @@
// status bar takes care of that after taking into account all of the
// required info.
Intent intent = new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
- intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
intent.putExtra(Phone.STATE_KEY, DefaultPhoneNotifier.convertDataState(state).toString());
if (!isDataConnectivityPossible) {
intent.putExtra(Phone.NETWORK_UNAVAILABLE_KEY, true);
@@ -626,7 +623,6 @@
private void broadcastDataConnectionFailed(String reason, String apnType) {
Intent intent = new Intent(TelephonyIntents.ACTION_DATA_CONNECTION_FAILED);
- intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
intent.putExtra(Phone.FAILURE_REASON_KEY, reason);
intent.putExtra(Phone.DATA_APN_TYPE_KEY, apnType);
mContext.sendStickyBroadcast(intent);
diff --git a/telephony/java/com/android/internal/telephony/CommandsInterface.java b/telephony/java/com/android/internal/telephony/CommandsInterface.java
index bd549ea..b68cbe9 100644
--- a/telephony/java/com/android/internal/telephony/CommandsInterface.java
+++ b/telephony/java/com/android/internal/telephony/CommandsInterface.java
@@ -234,6 +234,9 @@
void registerForSIMLockedOrAbsent(Handler h, int what, Object obj);
void unregisterForSIMLockedOrAbsent(Handler h);
+ void registerForIccStatusChanged(Handler h, int what, Object obj);
+ void unregisterForIccStatusChanged(Handler h);
+
void registerForCallStateChanged(Handler h, int what, Object obj);
void unregisterForCallStateChanged(Handler h);
void registerForVoiceNetworkStateChanged(Handler h, int what, Object obj);
diff --git a/telephony/java/com/android/internal/telephony/IccCard.java b/telephony/java/com/android/internal/telephony/IccCard.java
index 9956ae8..1b49d2d 100644
--- a/telephony/java/com/android/internal/telephony/IccCard.java
+++ b/telephony/java/com/android/internal/telephony/IccCard.java
@@ -87,6 +87,7 @@
private static final int EVENT_CHANGE_ICC_PASSWORD_DONE = 9;
private static final int EVENT_QUERY_FACILITY_FDN_DONE = 10;
private static final int EVENT_CHANGE_FACILITY_FDN_DONE = 11;
+ private static final int EVENT_ICC_STATUS_CHANGED = 12;
/*
UNKNOWN is a transient state, for example, after uesr inputs ICC pin under
@@ -140,11 +141,14 @@
public IccCard(PhoneBase phone, String logTag, Boolean dbg) {
mPhone = phone;
+ mPhone.mCM.registerForIccStatusChanged(mHandler, EVENT_ICC_STATUS_CHANGED, null);
mLogTag = logTag;
mDbg = dbg;
}
- abstract public void dispose();
+ public void dispose() {
+ mPhone.mCM.unregisterForIccStatusChanged(mHandler);
+ }
protected void finalize() {
if(mDbg) Log.d(mLogTag, "IccCard finalized");
@@ -601,6 +605,10 @@
= ar.exception;
((Message)ar.userObj).sendToTarget();
break;
+ case EVENT_ICC_STATUS_CHANGED:
+ Log.d(mLogTag, "Received Event EVENT_ICC_STATUS_CHANGED");
+ mPhone.mCM.getIccCardStatus(obtainMessage(EVENT_GET_ICC_STATUS_DONE));
+ break;
default:
Log.e(mLogTag, "[IccCard] Unknown Event " + msg.what);
}
diff --git a/telephony/java/com/android/internal/telephony/cdma/RuimCard.java b/telephony/java/com/android/internal/telephony/cdma/RuimCard.java
index cfe7df7..11f44d4 100644
--- a/telephony/java/com/android/internal/telephony/cdma/RuimCard.java
+++ b/telephony/java/com/android/internal/telephony/cdma/RuimCard.java
@@ -35,6 +35,7 @@
@Override
public void dispose() {
+ super.dispose();
//Unregister for all events
mPhone.mCM.unregisterForRUIMLockedOrAbsent(mHandler);
mPhone.mCM.unregisterForOffOrNotAvailable(mHandler);
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
index 84b2932..91b150a 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
@@ -101,6 +101,10 @@
// call reRegisterNetwork, or pingTest succeeds.
private int mPdpResetCount = 0;
+ // Recovery action taken in case of data stall
+ enum RecoveryAction {REREGISTER, RADIO_RESTART, RADIO_RESET};
+ private RecoveryAction mRecoveryAction = RecoveryAction.REREGISTER;
+
//***** Constants
@@ -513,8 +517,8 @@
@Override
protected boolean isApnTypeAvailable(String type) {
- if (type.equals(Phone.APN_TYPE_DUN)) {
- return (fetchDunApn() != null);
+ if (type.equals(Phone.APN_TYPE_DUN) && fetchDunApn() != null) {
+ return true;
}
if (mAllApns != null) {
@@ -1132,12 +1136,40 @@
cleanUpAllConnections(true, Phone.REASON_PDP_RESET);
} else {
mPdpResetCount = 0;
- EventLog.writeEvent(EventLogTags.PDP_REREGISTER_NETWORK, mSentSinceLastRecv);
- if (DBG) log("doRecovery() re-register getting preferred network type");
- mPhone.getServiceStateTracker().reRegisterNetwork(null);
+ switch (mRecoveryAction) {
+ case REREGISTER:
+ EventLog.writeEvent(EventLogTags.PDP_REREGISTER_NETWORK, mSentSinceLastRecv);
+ if (DBG) log("doRecovery() re-register getting preferred network type");
+ mPhone.getServiceStateTracker().reRegisterNetwork(null);
+ mRecoveryAction = RecoveryAction.RADIO_RESTART;
+ break;
+ case RADIO_RESTART:
+ EventLog.writeEvent(EventLogTags.PDP_RADIO_RESET, mSentSinceLastRecv);
+ if (DBG) log("restarting radio");
+ mRecoveryAction = RecoveryAction.RADIO_RESET;
+ restartRadio();
+ break;
+ case RADIO_RESET:
+ // This is in case radio restart has not recovered the data.
+ // It will set an additional "gsm.radioreset" property to tell
+ // RIL or system to take further action.
+ // The implementation of hard reset recovery action is up to OEM product.
+ // Once gsm.radioreset property is consumed, it is expected to set back
+ // to false by RIL.
+ EventLog.writeEvent(EventLogTags.PDP_RADIO_RESET, -1);
+ if (DBG) log("restarting radio with reset indication");
+ SystemProperties.set("gsm.radioreset", "true");
+ // give 1 sec so property change can be notified.
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {}
+ restartRadio();
+ break;
+ default:
+ throw new RuntimeException("doRecovery: Invalid mRecoveryAction " +
+ mRecoveryAction);
+ }
}
- // TODO: Add increasingly drastic recovery steps, eg,
- // reset the radio, reset the device.
} else {
if (DBG) log("doRecovery(): ignore, we're not connected");
}
@@ -1202,6 +1234,7 @@
mSentSinceLastRecv = 0;
newActivity = Activity.DATAINANDOUT;
mPdpResetCount = 0;
+ mRecoveryAction = RecoveryAction.REREGISTER;
} else if (sent > 0 && received == 0) {
if (mPhone.getState() == Phone.State.IDLE) {
mSentSinceLastRecv += sent;
@@ -1213,6 +1246,7 @@
mSentSinceLastRecv = 0;
newActivity = Activity.DATAIN;
mPdpResetCount = 0;
+ mRecoveryAction = RecoveryAction.REREGISTER;
} else if (sent == 0 && received == 0) {
newActivity = Activity.NONE;
} else {
@@ -1255,7 +1289,7 @@
} else {
if (DBG) log("Polling: Sent " + String.valueOf(mSentSinceLastRecv) +
" pkts since last received start recovery process");
- stopNetStatPoll();
+ mNoRecvPollCount = 0;
sendMessage(obtainMessage(EVENT_START_RECOVERY));
}
} else {
@@ -1855,9 +1889,11 @@
if (requestedApnType.equals(Phone.APN_TYPE_DUN)) {
ApnSetting dun = fetchDunApn();
- if (dun != null) apnList.add(dun);
- if (DBG) log("buildWaitingApns: X added APN_TYPE_DUN apnList=" + apnList);
- return apnList;
+ if (dun != null) {
+ apnList.add(dun);
+ if (DBG) log("buildWaitingApns: X added APN_TYPE_DUN apnList=" + apnList);
+ return apnList;
+ }
}
String operator = mPhone.mIccRecords.getOperatorNumeric();
diff --git a/telephony/java/com/android/internal/telephony/gsm/SimCard.java b/telephony/java/com/android/internal/telephony/gsm/SimCard.java
index b63c1d7..b7b0af3 100644
--- a/telephony/java/com/android/internal/telephony/gsm/SimCard.java
+++ b/telephony/java/com/android/internal/telephony/gsm/SimCard.java
@@ -55,6 +55,7 @@
@Override
public void dispose() {
+ super.dispose();
//Unregister for all events
mPhone.mCM.unregisterForSIMLockedOrAbsent(mHandler);
mPhone.mCM.unregisterForOffOrNotAvailable(mHandler);
diff --git a/tests/BrowserTestPlugin/jni/Android.mk b/tests/BrowserTestPlugin/jni/Android.mk
index 2956c61..d641dad 100644
--- a/tests/BrowserTestPlugin/jni/Android.mk
+++ b/tests/BrowserTestPlugin/jni/Android.mk
@@ -40,7 +40,7 @@
$(WEBCORE_PATH)/bridge \
$(WEBCORE_PATH)/plugins \
$(WEBCORE_PATH)/platform/android/JavaVM \
- external/webkit/WebKit/android/plugins
+ external/webkit/Source/WebKit/android/plugins
LOCAL_CFLAGS += -fvisibility=hidden
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
index d3018e8..fa82070 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
@@ -101,6 +101,7 @@
}
public void requestWebKitData() {
+ setDumpTimeout(DUMP_TIMEOUT_MS);
Message callback = mHandler.obtainMessage(MSG_WEBKIT_DATA);
if (mRequestedWebKitData)
@@ -112,12 +113,10 @@
case DUMP_AS_TEXT:
callback.arg1 = mDumpTopFrameAsText ? 1 : 0;
callback.arg2 = mDumpChildFramesAsText ? 1 : 0;
- setDumpTimeout(DUMP_TIMEOUT_MS);
mWebView.documentAsText(callback);
break;
case EXT_REPR:
mWebView.externalRepresentation(callback);
- setDumpTimeout(DUMP_TIMEOUT_MS);
break;
default:
finished();
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
index e6e9647..3c0c9a4 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
@@ -25,6 +25,7 @@
import com.android.ide.common.rendering.api.RenderSession;
import com.android.ide.common.rendering.api.Result;
import com.android.ide.common.rendering.api.SessionParams;
+import com.android.ide.common.rendering.api.Result.Status;
import com.android.layoutlib.bridge.android.BridgeAssetManager;
import com.android.layoutlib.bridge.impl.FontLoader;
import com.android.layoutlib.bridge.impl.RenderDrawable;
@@ -39,6 +40,9 @@
import android.graphics.Typeface;
import android.graphics.Typeface_Delegate;
import android.os.Looper;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewParent;
import java.io.File;
import java.lang.ref.SoftReference;
@@ -196,7 +200,8 @@
Capability.EMBEDDED_LAYOUT,
Capability.VIEW_MANIPULATION,
Capability.PLAY_ANIMATION,
- Capability.ANIMATED_VIEW_MANIPULATION);
+ Capability.ANIMATED_VIEW_MANIPULATION,
+ Capability.ADAPTER_BINDING);
BridgeAssetManager.initSystem();
@@ -369,6 +374,40 @@
}
}
+ @Override
+ public Result getViewParent(Object viewObject) {
+ if (viewObject instanceof View) {
+ return Status.SUCCESS.createResult(((View)viewObject).getParent());
+ }
+
+ throw new IllegalArgumentException("viewObject is not a View");
+ }
+
+ @Override
+ public Result getViewIndex(Object viewObject) {
+ if (viewObject instanceof View) {
+ View view = (View) viewObject;
+ ViewParent parentView = view.getParent();
+
+ if (parentView instanceof ViewGroup) {
+ Status.SUCCESS.createResult(((ViewGroup) parentView).indexOfChild(view));
+ }
+
+ return Status.SUCCESS.createResult();
+ }
+
+ throw new IllegalArgumentException("viewObject is not a View");
+ }
+
+ @Override
+ public int getViewBaseline(Object viewObject) {
+ if (viewObject instanceof View) {
+ return ((View) viewObject).getBaseline();
+ }
+
+ throw new IllegalArgumentException("viewObject is not a View");
+ }
+
/**
* Returns the lock for the bridge
*/
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java
index 765fd99..529be97 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java
@@ -22,12 +22,10 @@
import com.android.ide.common.rendering.api.RenderSession;
import com.android.ide.common.rendering.api.Result;
import com.android.ide.common.rendering.api.ViewInfo;
-import com.android.ide.common.rendering.api.Result.Status;
import com.android.layoutlib.bridge.impl.RenderSessionImpl;
import android.view.View;
import android.view.ViewGroup;
-import android.view.ViewParent;
import java.awt.image.BufferedImage;
import java.util.List;
@@ -83,31 +81,6 @@
}
@Override
- public Result getViewParent(Object viewObject) {
- if (viewObject instanceof View) {
- return Status.SUCCESS.createResult(((View)viewObject).getParent());
- }
-
- throw new IllegalArgumentException("viewObject is not a View");
- }
-
- @Override
- public Result getViewIndex(Object viewObject) {
- if (viewObject instanceof View) {
- View view = (View) viewObject;
- ViewParent parentView = view.getParent();
-
- if (parentView instanceof ViewGroup) {
- Status.SUCCESS.createResult(((ViewGroup) parentView).indexOfChild(view));
- }
-
- return Status.SUCCESS.createResult();
- }
-
- throw new IllegalArgumentException("viewObject is not a View");
- }
-
- @Override
public Result render(long timeout) {
try {
Bridge.prepareThread();
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
index 7d794bd..e536028 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
@@ -16,9 +16,11 @@
package com.android.layoutlib.bridge.android;
+import com.android.ide.common.rendering.api.ILayoutPullParser;
import com.android.ide.common.rendering.api.IProjectCallback;
import com.android.ide.common.rendering.api.LayoutLog;
import com.android.ide.common.rendering.api.RenderResources;
+import com.android.ide.common.rendering.api.ResourceReference;
import com.android.ide.common.rendering.api.ResourceValue;
import com.android.ide.common.rendering.api.StyleResourceValue;
import com.android.layoutlib.bridge.Bridge;
@@ -27,6 +29,10 @@
import com.android.resources.ResourceType;
import com.android.util.Pair;
+import org.kxml2.io.KXmlParser;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
import android.app.Activity;
import android.app.Fragment;
import android.content.BroadcastReceiver;
@@ -59,11 +65,13 @@
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
+import android.view.ViewGroup;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
+import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
@@ -270,6 +278,107 @@
}
+ public ResourceReference resolveId(int id) {
+ // first get the String related to this id in the framework
+ Pair<ResourceType, String> resourceInfo = Bridge.resolveResourceId(id);
+
+ if (resourceInfo != null) {
+ return new ResourceReference(resourceInfo.getSecond(), true);
+ }
+
+ // didn't find a match in the framework? look in the project.
+ if (mProjectCallback != null) {
+ resourceInfo = mProjectCallback.resolveResourceId(id);
+
+ if (resourceInfo != null) {
+ return new ResourceReference(resourceInfo.getSecond(), false);
+ }
+ }
+
+ return null;
+ }
+
+ public Pair<View, Boolean> inflateView(ResourceReference resource, ViewGroup parent,
+ boolean attachToRoot, boolean skipCallbackParser) {
+ String layoutName = resource.getName();
+ boolean isPlatformLayout = resource.isFramework();
+
+ if (isPlatformLayout == false && skipCallbackParser == false) {
+ // check if the project callback can provide us with a custom parser.
+ ILayoutPullParser parser = mProjectCallback.getParser(layoutName);
+ if (parser != null) {
+ BridgeXmlBlockParser blockParser = new BridgeXmlBlockParser(parser,
+ this, resource.isFramework());
+ try {
+ pushParser(blockParser);
+ return Pair.of(
+ mBridgeInflater.inflate(blockParser, parent, attachToRoot),
+ true);
+ } finally {
+ popParser();
+ }
+ }
+ }
+
+ ResourceValue resValue;
+ if (resource instanceof ResourceValue) {
+ resValue = (ResourceValue) resource;
+ } else {
+ if (isPlatformLayout) {
+ resValue = mRenderResources.getFrameworkResource(ResourceType.LAYOUT,
+ resource.getName());
+ } else {
+ resValue = mRenderResources.getProjectResource(ResourceType.LAYOUT,
+ resource.getName());
+ }
+ }
+
+ if (resValue != null) {
+
+ File xml = new File(resValue.getValue());
+ if (xml.isFile()) {
+ // we need to create a pull parser around the layout XML file, and then
+ // give that to our XmlBlockParser
+ try {
+ KXmlParser parser = new KXmlParser();
+ parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
+ parser.setInput(new FileReader(xml));
+
+ // set the resource ref to have correct view cookies
+ mBridgeInflater.setResourceReference(resource);
+
+ BridgeXmlBlockParser blockParser = new BridgeXmlBlockParser(parser,
+ this, resource.isFramework());
+ try {
+ pushParser(blockParser);
+ return Pair.of(
+ mBridgeInflater.inflate(blockParser, parent, attachToRoot),
+ false);
+ } finally {
+ popParser();
+ }
+ } catch (XmlPullParserException e) {
+ Bridge.getLog().error(LayoutLog.TAG_BROKEN,
+ "Failed to configure parser for " + xml, e, null /*data*/);
+ // we'll return null below.
+ } catch (FileNotFoundException e) {
+ // this shouldn't happen since we check above.
+ } finally {
+ mBridgeInflater.setResourceReference(null);
+ }
+ } else {
+ Bridge.getLog().error(LayoutLog.TAG_BROKEN,
+ String.format("File %s is missing!", xml), null);
+ }
+ } else {
+ Bridge.getLog().error(LayoutLog.TAG_BROKEN,
+ String.format("Layout %s%s does not exist.", isPlatformLayout ? "android:" : "",
+ layoutName), null);
+ }
+
+ return Pair.of(null, false);
+ }
+
// ------------- Activity Methods
@Override
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java
index 5740e8b..d6bbebd 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java
@@ -19,6 +19,7 @@
import com.android.ide.common.rendering.api.IProjectCallback;
import com.android.ide.common.rendering.api.LayoutLog;
import com.android.ide.common.rendering.api.MergeCookie;
+import com.android.ide.common.rendering.api.ResourceReference;
import com.android.ide.common.rendering.api.ResourceValue;
import com.android.layoutlib.bridge.Bridge;
import com.android.resources.ResourceType;
@@ -44,6 +45,7 @@
private final IProjectCallback mProjectCallback;
private boolean mIsInMerge = false;
+ private ResourceReference mResourceReference;
/**
* List of class prefixes which are tried first by default.
@@ -223,23 +225,33 @@
// get the view key
Object viewKey = parser.getViewCookie();
- // if there's no view key and the depth is 1 (ie this is the first tag), or 2
- // (this is first item in included merge layout)
- // look for a previous parser in the context, and check if this one has a viewkey.
- int testDepth = mIsInMerge ? 2 : 1;
- if (viewKey == null && parser.getDepth() == testDepth) {
+ if (viewKey == null) {
+ int currentDepth = parser.getDepth();
+
+ // test whether we are in an included file or in a adapter binding view.
BridgeXmlBlockParser previousParser = bc.getPreviousParser();
if (previousParser != null) {
- viewKey = previousParser.getViewCookie();
+ // looks like we inside an embedded layout.
+ // only apply the cookie of the calling node (<include>) if we are at the
+ // top level of the embedded layout. If there is a merge tag, then
+ // skip it and look for the 2nd level
+ int testDepth = mIsInMerge ? 2 : 1;
+ if (currentDepth == testDepth) {
+ viewKey = previousParser.getViewCookie();
+ // if we are in a merge, wrap the cookie in a MergeCookie.
+ if (viewKey != null && mIsInMerge) {
+ viewKey = new MergeCookie(viewKey);
+ }
+ }
+ } else if (mResourceReference != null && currentDepth == 1) {
+ // else if there's a resource reference, this means we are in an adapter
+ // binding case. Set the resource ref as the view cookie only for the top
+ // level view.
+ viewKey = mResourceReference;
}
}
if (viewKey != null) {
- if (testDepth == 2) {
- // include-merge case
- viewKey = new MergeCookie(viewKey);
- }
-
bc.addViewKey(view, viewKey);
}
}
@@ -250,6 +262,10 @@
mIsInMerge = isInMerge;
}
+ public void setResourceReference(ResourceReference reference) {
+ mResourceReference = reference;
+ }
+
@Override
public LayoutInflater cloneInContext(Context newContext) {
return new BridgeInflater(this, newContext);
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java
index 5e5aeb1..273e493 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java
@@ -232,9 +232,8 @@
try {
// check if the current parser can provide us with a custom parser.
- BridgeXmlBlockParser currentParser = mContext.getCurrentParser();
- if (currentParser != null) {
- parser = currentParser.getParser(value.getName());
+ if (mPlatformResourceFlag[0] == false) {
+ parser = mProjectCallback.getParser(value.getName());
}
// create a new one manually if needed.
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParser.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParser.java
index 2f54ae6..70dbaa4 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParser.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParser.java
@@ -69,14 +69,6 @@
return mPlatformFile;
}
- public ILayoutPullParser getParser(String layoutName) {
- if (mParser instanceof ILayoutPullParser) {
- return ((ILayoutPullParser)mParser).getParser(layoutName);
- }
-
- return null;
- }
-
public Object getViewCookie() {
if (mParser instanceof ILayoutPullParser) {
return ((ILayoutPullParser)mParser).getViewCookie();
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
index c5eaef9..c53cb23 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
@@ -23,12 +23,14 @@
import static com.android.ide.common.rendering.api.Result.Status.ERROR_VIEWGROUP_NO_CHILDREN;
import static com.android.ide.common.rendering.api.Result.Status.SUCCESS;
+import com.android.ide.common.rendering.api.AdapterBinding;
import com.android.ide.common.rendering.api.IAnimationListener;
import com.android.ide.common.rendering.api.ILayoutPullParser;
import com.android.ide.common.rendering.api.IProjectCallback;
import com.android.ide.common.rendering.api.RenderParams;
import com.android.ide.common.rendering.api.RenderResources;
import com.android.ide.common.rendering.api.RenderSession;
+import com.android.ide.common.rendering.api.ResourceReference;
import com.android.ide.common.rendering.api.ResourceValue;
import com.android.ide.common.rendering.api.Result;
import com.android.ide.common.rendering.api.SessionParams;
@@ -47,6 +49,8 @@
import com.android.layoutlib.bridge.bars.PhoneSystemBar;
import com.android.layoutlib.bridge.bars.TabletSystemBar;
import com.android.layoutlib.bridge.bars.TitleBar;
+import com.android.layoutlib.bridge.impl.binding.FakeAdapter;
+import com.android.layoutlib.bridge.impl.binding.FakeExpandableAdapter;
import com.android.resources.ResourceType;
import com.android.resources.ScreenSize;
import com.android.util.Pair;
@@ -70,8 +74,13 @@
import android.view.View.AttachInfo;
import android.view.View.MeasureSpec;
import android.view.ViewGroup.LayoutParams;
+import android.widget.AbsListView;
+import android.widget.AbsSpinner;
+import android.widget.AdapterView;
+import android.widget.ExpandableListView;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
+import android.widget.ListView;
import android.widget.QuickContactBadge;
import android.widget.TabHost;
import android.widget.TabWidget;
@@ -283,7 +292,6 @@
}
}
-
// content frame
mContentRoot = new FrameLayout(context);
layoutParams = new LinearLayout.LayoutParams(
@@ -314,6 +322,9 @@
View view = mInflater.inflate(mBlockParser, mContentRoot);
+ // done with the parser, pop it.
+ context.popParser();
+
Fragment_Delegate.setProjectCallback(null);
// set the AttachInfo on the root view.
@@ -1091,6 +1102,75 @@
} else if (view instanceof QuickContactBadge) {
QuickContactBadge badge = (QuickContactBadge) view;
badge.setImageToDefault();
+ } else if (view instanceof AdapterView<?>) {
+ // get the view ID.
+ int id = view.getId();
+
+ BridgeContext context = getContext();
+
+ // get a ResourceReference from the integer ID.
+ ResourceReference listRef = context.resolveId(id);
+
+ if (listRef != null) {
+ SessionParams params = getParams();
+ AdapterBinding binding = params.getAdapterBindings().get(listRef);
+
+ // if there was no adapter binding, trying to get it from the call back.
+ if (binding == null) {
+ binding = params.getProjectCallback().getAdapterBinding(listRef,
+ context.getViewKey(view), view);
+ }
+
+ if (binding != null) {
+
+ if (view instanceof AbsListView) {
+ if ((binding.getFooterCount() > 0 || binding.getHeaderCount() > 0) &&
+ view instanceof ListView) {
+ ListView list = (ListView) view;
+
+ boolean skipCallbackParser = false;
+
+ int count = binding.getHeaderCount();
+ for (int i = 0 ; i < count ; i++) {
+ Pair<View, Boolean> pair = context.inflateView(
+ binding.getHeaderAt(i),
+ list, false /*attachToRoot*/, skipCallbackParser);
+ if (pair.getFirst() != null) {
+ list.addHeaderView(pair.getFirst());
+ }
+
+ skipCallbackParser |= pair.getSecond();
+ }
+
+ count = binding.getFooterCount();
+ for (int i = 0 ; i < count ; i++) {
+ Pair<View, Boolean> pair = context.inflateView(
+ binding.getFooterAt(i),
+ list, false /*attachToRoot*/, skipCallbackParser);
+ if (pair.getFirst() != null) {
+ list.addFooterView(pair.getFirst());
+ }
+
+ skipCallbackParser |= pair.getSecond();
+ }
+ }
+
+ if (view instanceof ExpandableListView) {
+ ((ExpandableListView) view).setAdapter(
+ new FakeExpandableAdapter(
+ listRef, binding, params.getProjectCallback()));
+ } else {
+ ((AbsListView) view).setAdapter(
+ new FakeAdapter(
+ listRef, binding, params.getProjectCallback()));
+ }
+ } else if (view instanceof AbsSpinner) {
+ ((AbsSpinner) view).setAdapter(
+ new FakeAdapter(
+ listRef, binding, params.getProjectCallback()));
+ }
+ }
+ }
} else if (view instanceof ViewGroup) {
ViewGroup group = (ViewGroup)view;
final int count = group.getChildCount();
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
index 649160e..96ab30f 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
@@ -115,7 +115,7 @@
public static ColorStateList getColorStateList(ResourceValue resValue, BridgeContext context) {
String value = resValue.getValue();
- if (value != null) {
+ if (value != null && RenderResources.REFERENCE_NULL.equals(value) == false) {
// first check if the value is a file (xml most likely)
File f = new File(value);
if (f.isFile()) {
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/binding/BaseAdapter.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/binding/BaseAdapter.java
new file mode 100644
index 0000000..e0414fe
--- /dev/null
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/binding/BaseAdapter.java
@@ -0,0 +1,247 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+package com.android.layoutlib.bridge.impl.binding;
+
+import com.android.ide.common.rendering.api.AdapterBinding;
+import com.android.ide.common.rendering.api.DataBindingItem;
+import com.android.ide.common.rendering.api.IProjectCallback;
+import com.android.ide.common.rendering.api.LayoutLog;
+import com.android.ide.common.rendering.api.ResourceReference;
+import com.android.ide.common.rendering.api.IProjectCallback.ViewAttribute;
+import com.android.layoutlib.bridge.Bridge;
+import com.android.layoutlib.bridge.android.BridgeContext;
+import com.android.layoutlib.bridge.impl.RenderAction;
+import com.android.util.Pair;
+
+import android.database.DataSetObserver;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.Checkable;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Base adapter to do fake data binding in {@link AdapterView} objects.
+ */
+public class BaseAdapter {
+
+ /**
+ * This is the items provided by the adapter. They are dynamically generated.
+ */
+ protected final static class AdapterItem {
+ private final DataBindingItem mItem;
+ private final int mType;
+ private final int mFullPosition;
+ private final int mPositionPerType;
+ private List<AdapterItem> mChildren;
+
+ protected AdapterItem(DataBindingItem item, int type, int fullPosition,
+ int positionPerType) {
+ mItem = item;
+ mType = type;
+ mFullPosition = fullPosition;
+ mPositionPerType = positionPerType;
+ }
+
+ void addChild(AdapterItem child) {
+ if (mChildren == null) {
+ mChildren = new ArrayList<AdapterItem>();
+ }
+
+ mChildren.add(child);
+ }
+
+ List<AdapterItem> getChildren() {
+ if (mChildren != null) {
+ return mChildren;
+ }
+
+ return Collections.emptyList();
+ }
+
+ int getType() {
+ return mType;
+ }
+
+ int getFullPosition() {
+ return mFullPosition;
+ }
+
+ int getPositionPerType() {
+ return mPositionPerType;
+ }
+
+ DataBindingItem getDataBindingItem() {
+ return mItem;
+ }
+ }
+
+ private final AdapterBinding mBinding;
+ private final IProjectCallback mCallback;
+ private final ResourceReference mAdapterRef;
+ private boolean mSkipCallbackParser = false;
+
+ protected final List<AdapterItem> mItems = new ArrayList<AdapterItem>();
+
+ protected BaseAdapter(ResourceReference adapterRef, AdapterBinding binding,
+ IProjectCallback callback) {
+ mAdapterRef = adapterRef;
+ mBinding = binding;
+ mCallback = callback;
+ }
+
+ // ------- Some Adapter method used by all children classes.
+
+ public boolean areAllItemsEnabled() {
+ return true;
+ }
+
+ public boolean hasStableIds() {
+ return true;
+ }
+
+ public boolean isEmpty() {
+ return mItems.size() == 0;
+ }
+
+ public void registerDataSetObserver(DataSetObserver observer) {
+ // pass
+ }
+
+ public void unregisterDataSetObserver(DataSetObserver observer) {
+ // pass
+ }
+
+ // -------
+
+
+ protected AdapterBinding getBinding() {
+ return mBinding;
+ }
+
+ protected View getView(AdapterItem item, AdapterItem parentItem, View convertView,
+ ViewGroup parent) {
+ // we don't care about recycling here because we never scroll.
+ DataBindingItem dataBindingItem = item.getDataBindingItem();
+
+ BridgeContext context = RenderAction.getCurrentContext();
+
+ Pair<View, Boolean> pair = context.inflateView(dataBindingItem.getViewReference(),
+ parent, false /*attachToRoot*/, mSkipCallbackParser);
+
+ View view = pair.getFirst();
+ mSkipCallbackParser |= pair.getSecond();
+
+ if (view != null) {
+ fillView(context, view, item, parentItem);
+ } else {
+ // create a text view to display an error.
+ TextView tv = new TextView(context);
+ tv.setText("Unable to find layout: " + dataBindingItem.getViewReference().getName());
+ view = tv;
+ }
+
+ return view;
+ }
+
+ private void fillView(BridgeContext context, View view, AdapterItem item,
+ AdapterItem parentItem) {
+ if (view instanceof ViewGroup) {
+ ViewGroup group = (ViewGroup) view;
+ final int count = group.getChildCount();
+ for (int i = 0 ; i < count ; i++) {
+ fillView(context, group.getChildAt(i), item, parentItem);
+ }
+ } else {
+ int id = view.getId();
+ if (id != 0) {
+ ResourceReference resolvedRef = context.resolveId(id);
+ if (resolvedRef != null) {
+ int fullPosition = item.getFullPosition();
+ int positionPerType = item.getPositionPerType();
+ int fullParentPosition = parentItem != null ? parentItem.getFullPosition() : 0;
+ int parentPositionPerType = parentItem != null ?
+ parentItem.getPositionPerType() : 0;
+
+ if (view instanceof TextView) {
+ TextView tv = (TextView) view;
+ Object value = mCallback.getAdapterItemValue(
+ mAdapterRef, context.getViewKey(view),
+ item.getDataBindingItem().getViewReference(),
+ fullPosition, positionPerType,
+ fullParentPosition, parentPositionPerType,
+ resolvedRef, ViewAttribute.TEXT, tv.getText().toString());
+ if (value != null) {
+ if (value.getClass() != ViewAttribute.TEXT.getAttributeClass()) {
+ Bridge.getLog().error(LayoutLog.TAG_BROKEN, String.format(
+ "Wrong Adapter Item value class for TEXT. Expected String, got %s",
+ value.getClass().getName()), null);
+ } else {
+ tv.setText((String) value);
+ }
+ }
+ }
+
+ if (view instanceof Checkable) {
+ Checkable cb = (Checkable) view;
+
+ Object value = mCallback.getAdapterItemValue(
+ mAdapterRef, context.getViewKey(view),
+ item.getDataBindingItem().getViewReference(),
+ fullPosition, positionPerType,
+ fullParentPosition, parentPositionPerType,
+ resolvedRef, ViewAttribute.IS_CHECKED, cb.isChecked());
+ if (value != null) {
+ if (value.getClass() != ViewAttribute.IS_CHECKED.getAttributeClass()) {
+ Bridge.getLog().error(LayoutLog.TAG_BROKEN, String.format(
+ "Wrong Adapter Item value class for TEXT. Expected Boolean, got %s",
+ value.getClass().getName()), null);
+ } else {
+ cb.setChecked((Boolean) value);
+ }
+ }
+ }
+
+ if (view instanceof ImageView) {
+ ImageView iv = (ImageView) view;
+
+ Object value = mCallback.getAdapterItemValue(
+ mAdapterRef, context.getViewKey(view),
+ item.getDataBindingItem().getViewReference(),
+ fullPosition, positionPerType,
+ fullParentPosition, parentPositionPerType,
+ resolvedRef, ViewAttribute.SRC, iv.getDrawable());
+ if (value != null) {
+ if (value.getClass() != ViewAttribute.SRC.getAttributeClass()) {
+ Bridge.getLog().error(LayoutLog.TAG_BROKEN, String.format(
+ "Wrong Adapter Item value class for TEXT. Expected Boolean, got %s",
+ value.getClass().getName()), null);
+ } else {
+ // FIXME
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/binding/FakeAdapter.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/binding/FakeAdapter.java
new file mode 100644
index 0000000..c9bb424
--- /dev/null
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/binding/FakeAdapter.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+package com.android.layoutlib.bridge.impl.binding;
+
+import com.android.ide.common.rendering.api.AdapterBinding;
+import com.android.ide.common.rendering.api.DataBindingItem;
+import com.android.ide.common.rendering.api.IProjectCallback;
+import com.android.ide.common.rendering.api.ResourceReference;
+
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ListAdapter;
+import android.widget.SpinnerAdapter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Fake adapter to do fake data binding in {@link AdapterView} objects for {@link ListAdapter}
+ * and {@link SpinnerAdapter}.
+ *
+ */
+public class FakeAdapter extends BaseAdapter implements ListAdapter, SpinnerAdapter {
+
+ // don't use a set because the order is important.
+ private final List<ResourceReference> mTypes = new ArrayList<ResourceReference>();
+
+ public FakeAdapter(ResourceReference adapterRef, AdapterBinding binding,
+ IProjectCallback callback) {
+ super(adapterRef, binding, callback);
+
+ final int repeatCount = getBinding().getRepeatCount();
+ final int itemCount = getBinding().getItemCount();
+
+ // Need an array to count for each type.
+ // This is likely too big, but is the max it can be.
+ int[] typeCount = new int[itemCount];
+
+ // We put several repeating sets.
+ for (int r = 0 ; r < repeatCount ; r++) {
+ // loop on the type of list items, and add however many for each type.
+ for (DataBindingItem dataBindingItem : getBinding()) {
+ ResourceReference viewRef = dataBindingItem.getViewReference();
+ int typeIndex = mTypes.indexOf(viewRef);
+ if (typeIndex == -1) {
+ typeIndex = mTypes.size();
+ mTypes.add(viewRef);
+ }
+
+ int count = dataBindingItem.getCount();
+
+ int index = typeCount[typeIndex];
+ typeCount[typeIndex] += count;
+
+ for (int k = 0 ; k < count ; k++) {
+ mItems.add(new AdapterItem(dataBindingItem, typeIndex, mItems.size(), index++));
+ }
+ }
+ }
+ }
+
+ public boolean isEnabled(int position) {
+ return true;
+ }
+
+ public int getCount() {
+ return mItems.size();
+ }
+
+ public Object getItem(int position) {
+ return mItems.get(position);
+ }
+
+ public long getItemId(int position) {
+ return position;
+ }
+
+ public int getItemViewType(int position) {
+ return mItems.get(position).getType();
+ }
+
+ public View getView(int position, View convertView, ViewGroup parent) {
+ // we don't care about recycling here because we never scroll.
+ AdapterItem item = mItems.get(position);
+ return getView(item, null /*parentGroup*/, convertView, parent);
+ }
+
+ public int getViewTypeCount() {
+ return mTypes.size();
+ }
+
+ // ---- SpinnerAdapter
+
+ public View getDropDownView(int position, View convertView, ViewGroup parent) {
+ // pass
+ return null;
+ }
+}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/binding/FakeExpandableAdapter.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/binding/FakeExpandableAdapter.java
new file mode 100644
index 0000000..2c492e3
--- /dev/null
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/binding/FakeExpandableAdapter.java
@@ -0,0 +1,179 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+package com.android.layoutlib.bridge.impl.binding;
+
+import com.android.ide.common.rendering.api.AdapterBinding;
+import com.android.ide.common.rendering.api.DataBindingItem;
+import com.android.ide.common.rendering.api.IProjectCallback;
+import com.android.ide.common.rendering.api.ResourceReference;
+
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ExpandableListAdapter;
+import android.widget.HeterogeneousExpandableList;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class FakeExpandableAdapter extends BaseAdapter implements ExpandableListAdapter,
+ HeterogeneousExpandableList {
+
+ // don't use a set because the order is important.
+ private final List<ResourceReference> mGroupTypes = new ArrayList<ResourceReference>();
+ private final List<ResourceReference> mChildrenTypes = new ArrayList<ResourceReference>();
+
+ public FakeExpandableAdapter(ResourceReference adapterRef, AdapterBinding binding,
+ IProjectCallback callback) {
+ super(adapterRef, binding, callback);
+
+ createItems(binding, binding.getItemCount(), binding.getRepeatCount(), mGroupTypes, 1);
+ }
+
+ private void createItems(Iterable<DataBindingItem> iterable, final int itemCount,
+ final int repeatCount, List<ResourceReference> types, int depth) {
+ // Need an array to count for each type.
+ // This is likely too big, but is the max it can be.
+ int[] typeCount = new int[itemCount];
+
+ // we put several repeating sets.
+ for (int r = 0 ; r < repeatCount ; r++) {
+ // loop on the type of list items, and add however many for each type.
+ for (DataBindingItem dataBindingItem : iterable) {
+ ResourceReference viewRef = dataBindingItem.getViewReference();
+ int typeIndex = types.indexOf(viewRef);
+ if (typeIndex == -1) {
+ typeIndex = types.size();
+ types.add(viewRef);
+ }
+
+ List<DataBindingItem> children = dataBindingItem.getChildren();
+ int count = dataBindingItem.getCount();
+
+ // if there are children, we use the count as a repeat count for the children.
+ if (children.size() > 0) {
+ count = 1;
+ }
+
+ int index = typeCount[typeIndex];
+ typeCount[typeIndex] += count;
+
+ for (int k = 0 ; k < count ; k++) {
+ AdapterItem item = new AdapterItem(dataBindingItem, typeIndex, mItems.size(),
+ index++);
+ mItems.add(item);
+
+ if (children.size() > 0) {
+ createItems(dataBindingItem, depth + 1);
+ }
+ }
+ }
+ }
+ }
+
+ private void createItems(DataBindingItem item, int depth) {
+ if (depth == 2) {
+ createItems(item, item.getChildren().size(), item.getCount(), mChildrenTypes, depth);
+ }
+ }
+
+ private AdapterItem getChildItem(int groupPosition, int childPosition) {
+ AdapterItem item = mItems.get(groupPosition);
+
+ List<AdapterItem> children = item.getChildren();
+ return children.get(childPosition);
+ }
+
+ // ---- ExpandableListAdapter
+
+ public int getGroupCount() {
+ return mItems.size();
+ }
+
+ public int getChildrenCount(int groupPosition) {
+ AdapterItem item = mItems.get(groupPosition);
+ return item.getChildren().size();
+ }
+
+ public Object getGroup(int groupPosition) {
+ return mItems.get(groupPosition);
+ }
+
+ public Object getChild(int groupPosition, int childPosition) {
+ return getChildItem(groupPosition, childPosition);
+ }
+
+ public View getGroupView(int groupPosition, boolean isExpanded, View convertView,
+ ViewGroup parent) {
+ // we don't care about recycling here because we never scroll.
+ AdapterItem item = mItems.get(groupPosition);
+ return getView(item, null /*parentItem*/, convertView, parent);
+ }
+
+ public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
+ View convertView, ViewGroup parent) {
+ // we don't care about recycling here because we never scroll.
+ AdapterItem parentItem = mItems.get(groupPosition);
+ AdapterItem item = getChildItem(groupPosition, childPosition);
+ return getView(item, parentItem, convertView, parent);
+ }
+
+ public long getGroupId(int groupPosition) {
+ return groupPosition;
+ }
+
+ public long getChildId(int groupPosition, int childPosition) {
+ return childPosition;
+ }
+
+ public long getCombinedGroupId(long groupId) {
+ return groupId << 16 | 0x0000FFFF;
+ }
+
+ public long getCombinedChildId(long groupId, long childId) {
+ return groupId << 16 | childId;
+ }
+
+ public boolean isChildSelectable(int groupPosition, int childPosition) {
+ return true;
+ }
+
+ public void onGroupCollapsed(int groupPosition) {
+ // pass
+ }
+
+ public void onGroupExpanded(int groupPosition) {
+ // pass
+ }
+
+ // ---- HeterogeneousExpandableList
+
+ public int getChildType(int groupPosition, int childPosition) {
+ return getChildItem(groupPosition, childPosition).getType();
+ }
+
+ public int getChildTypeCount() {
+ return mChildrenTypes.size();
+ }
+
+ public int getGroupType(int groupPosition) {
+ return mItems.get(groupPosition).getType();
+ }
+
+ public int getGroupTypeCount() {
+ return mGroupTypes.size();
+ }
+}