diff options
10 files changed, 315 insertions, 131 deletions
diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c index 9e6bcc8b1653..6570078f2065 100644 --- a/cmds/dumpstate/dumpstate.c +++ b/cmds/dumpstate/dumpstate.c @@ -109,7 +109,10 @@ static void dumpstate() { run_command("NETWORK INTERFACES", 10, "su", "root", "netcfg", NULL); dump_file("NETWORK ROUTES", "/proc/net/route"); + dump_file("NETWORK ROUTES IPV6", "/proc/net/ipv6_route"); dump_file("ARP CACHE", "/proc/net/arp"); + run_command("IPTABLES", 10, "su", "root", "iptables", "-L", NULL); + run_command("IPTABLE NAT", 10, "su", "root", "iptables", "-t", "nat", "-L", NULL); run_command("WIFI NETWORKS", 20, "su", "root", "wpa_cli", "list_networks", NULL); diff --git a/core/java/android/widget/ProgressBar.java b/core/java/android/widget/ProgressBar.java index cf72ec40f604..6b676b420434 100644 --- a/core/java/android/widget/ProgressBar.java +++ b/core/java/android/widget/ProgressBar.java @@ -64,15 +64,16 @@ import com.android.internal.R; * * <p> * A progress bar can also be made indeterminate. In indeterminate mode, the - * progress bar shows a cyclic animation. This mode is used by applications - * when the length of the task is unknown. + * progress bar shows a cyclic animation without an indication of progress. This mode is used by + * applications when the length of the task is unknown. The indeterminate progress bar can be either + * a spinning wheel or a horizontal bar. * </p> * * <p>The following code example shows how a progress bar can be used from * a worker thread to update the user interface to notify the user of progress: * </p> * - * <pre class="prettyprint"> + * <pre> * public class MyActivity extends Activity { * private static final int PROGRESS = 0x1; * @@ -91,7 +92,7 @@ import com.android.internal.R; * // Start lengthy operation in a background thread * new Thread(new Runnable() { * public void run() { - * while (mProgressStatus < 100) { + * while (mProgressStatus < 100) { * mProgressStatus = doWork(); * * // Update the progress bar @@ -104,8 +105,61 @@ import com.android.internal.R; * } * }).start(); * } - * } - * </pre> + * }</pre> + * + * <p>To add a progress bar to a layout file, you can use the {@code <ProgressBar>} element. + * By default, the progress bar is a spinning wheel (an indeterminate indicator). To change to a + * horizontal progress bar, apply the {@link android.R.style#Widget_ProgressBar_Horizontal + * Widget.ProgressBar.Horizontal} style, like so:</p> + * + * <pre> + * <ProgressBar + * style="@android:style/Widget.ProgressBar.Horizontal" + * ... /></pre> + * + * <p>If you will use the progress bar to show real progress, you must use the horizontal bar. You + * can then increment the progress with {@link #incrementProgressBy incrementProgressBy()} or + * {@link #setProgress setProgress()}. By default, the progress bar is full when it reaches 100. If + * necessary, you can adjust the maximum value (the value for a full bar) using the {@link + * android.R.styleable#ProgressBar_max android:max} attribute. Other attributes available are listed + * below.</p> + * + * <p>Another common style to apply to the progress bar is {@link + * android.R.style#Widget_ProgressBar_Small Widget.ProgressBar.Small}, which shows a smaller + * version of the spinning wheel—useful when waiting for content to load. + * For example, you can insert this kind of progress bar into your default layout for + * a view that will be populated by some content fetched from the Internet—the spinning wheel + * appears immediately and when your application receives the content, it replaces the progress bar + * with the loaded content. For example:</p> + * + * <pre> + * <LinearLayout + * android:orientation="horizontal" + * ... > + * <ProgressBar + * android:layout_width="wrap_content" + * android:layout_height="wrap_content" + * style="@android:style/Widget.ProgressBar.Small" + * android:layout_marginRight="5dp" /> + * <TextView + * android:layout_width="wrap_content" + * android:layout_height="wrap_content" + * android:text="@string/loading" /> + * </LinearLayout></pre> + * + * <p>Other progress bar styles provided by the system include:</p> + * <ul> + * <li>{@link android.R.style#Widget_ProgressBar_Horizontal Widget.ProgressBar.Horizontal}</li> + * <li>{@link android.R.style#Widget_ProgressBar_Small Widget.ProgressBar.Small}</li> + * <li>{@link android.R.style#Widget_ProgressBar_Large Widget.ProgressBar.Large}</li> + * <li>{@link android.R.style#Widget_ProgressBar_Inverse Widget.ProgressBar.Inverse}</li> + * <li>{@link android.R.style#Widget_ProgressBar_Small_Inverse + * Widget.ProgressBar.Small.Inverse}</li> + * <li>{@link android.R.style#Widget_ProgressBar_Large_Inverse + * Widget.ProgressBar.Large.Inverse}</li> + * </ul> + * <p>The "inverse" styles provide an inverse color scheme for the spinner, which may be necessary + * if your application uses a light colored theme (a white background).</p> * * <p><strong>XML attributes</b></strong> * <p> @@ -113,13 +167,21 @@ import com.android.internal.R; * {@link android.R.styleable#View View Attributes} * </p> * - * <p><strong>Styles</b></strong> - * <p> - * @attr ref android.R.styleable#Theme_progressBarStyle - * @attr ref android.R.styleable#Theme_progressBarStyleSmall - * @attr ref android.R.styleable#Theme_progressBarStyleLarge - * @attr ref android.R.styleable#Theme_progressBarStyleHorizontal - * </p> + * @attr ref android.R.styleable#ProgressBar_animationResolution + * @attr ref android.R.styleable#ProgressBar_indeterminate + * @attr ref android.R.styleable#ProgressBar_indeterminateBehavior + * @attr ref android.R.styleable#ProgressBar_indeterminateDrawable + * @attr ref android.R.styleable#ProgressBar_indeterminateDuration + * @attr ref android.R.styleable#ProgressBar_indeterminateOnly + * @attr ref android.R.styleable#ProgressBar_interpolator + * @attr ref android.R.styleable#ProgressBar_max + * @attr ref android.R.styleable#ProgressBar_maxHeight + * @attr ref android.R.styleable#ProgressBar_maxWidth + * @attr ref android.R.styleable#ProgressBar_minHeight + * @attr ref android.R.styleable#ProgressBar_minWidth + * @attr ref android.R.styleable#ProgressBar_progress + * @attr ref android.R.styleable#ProgressBar_progressDrawable + * @attr ref android.R.styleable#ProgressBar_secondaryProgress */ @RemoteView public class ProgressBar extends View { diff --git a/core/java/com/android/internal/util/AsyncChannel.java b/core/java/com/android/internal/util/AsyncChannel.java index 101dd91e1926..39733440f0b6 100644 --- a/core/java/com/android/internal/util/AsyncChannel.java +++ b/core/java/com/android/internal/util/AsyncChannel.java @@ -44,16 +44,16 @@ import java.util.Stack; * In this usage model there is no need for the destination to * use the connect methods. The typical sequence of operations is:</p> *<ol> - * <li>Client calls AsyncChannel#connect</li> - * <li>Client receives CMD_CHANNEL_HALF_CONNECTED from AsyncChannel</li> + * <li>Client calls AsyncChannel#connectSync or Asynchronously:</li> + * <ol>For an asynchronous half connection client calls AsyncChannel#connect.</ol> + * <li>Client receives CMD_CHANNEL_HALF_CONNECTED from AsyncChannel</li> + * </ol> * <li><code>comm-loop:</code></li> - * <li>Client calls AsyncChannel#sendMessage(msgX)</li> - * <li>Server receives and processes msgX</li> - * <li>Server optionally calls AsyncChannel#replyToMessage(msgY) - * and if sent Client receives and processes msgY</li> + * <li>Client calls AsyncChannel#sendMessage</li> + * <li>Server processes messages and optionally replies using AsyncChannel#replyToMessage * <li>Loop to <code>comm-loop</code> until done</li> - * <li>When done Client calls {@link AsyncChannel#disconnect(int)}</li> - * <li>Client receives CMD_CHANNEL_DISCONNECTED from AsyncChannel</li> + * <li>When done Client calls {@link AsyncChannel#disconnect}</li> + * <li>Client/Server receives CMD_CHANNEL_DISCONNECTED from AsyncChannel</li> *</ol> *<br/> * <p>A second usage model is where the server/destination needs to know @@ -62,21 +62,26 @@ import java.util.Stack; * different state for each client. In this model the server will also * use the connect methods. The typical sequence of operation is:</p> *<ol> - * <li>Client calls AsyncChannel#connect</li> - * <li>Client receives CMD_CHANNEL_HALF_CONNECTED from AsyncChannel</li> - * <li>Client calls AsyncChannel#sendMessage(CMD_CHANNEL_FULL_CONNECTION)</li> + * <li>Client calls AsyncChannel#fullyConnectSync or Asynchronously:<li> + * <ol>For an asynchronous full connection it calls AsyncChannel#connect</li> + * <li>Client receives CMD_CHANNEL_HALF_CONNECTED from AsyncChannel</li> + * <li>Client calls AsyncChannel#sendMessage(CMD_CHANNEL_FULL_CONNECTION)</li> + * </ol> * <li>Server receives CMD_CHANNEL_FULL_CONNECTION</li> - * <li>Server calls AsyncChannel#connect</li> - * <li>Server receives CMD_CHANNEL_HALF_CONNECTED from AsyncChannel</li> + * <li>Server calls AsyncChannel#connected</li> * <li>Server sends AsyncChannel#sendMessage(CMD_CHANNEL_FULLY_CONNECTED)</li> * <li>Client receives CMD_CHANNEL_FULLY_CONNECTED</li> * <li><code>comm-loop:</code></li> * <li>Client/Server uses AsyncChannel#sendMessage/replyToMessage * to communicate and perform work</li> * <li>Loop to <code>comm-loop</code> until done</li> - * <li>When done Client/Server calls {@link AsyncChannel#disconnect(int)}</li> + * <li>When done Client/Server calls {@link AsyncChannel#disconnect}</li> * <li>Client/Server receives CMD_CHANNEL_DISCONNECTED from AsyncChannel</li> *</ol> + * + * TODO: Consider simplifying where we have connect and fullyConnect with only one response + * message RSP_CHANNEL_CONNECT instead of two, CMD_CHANNEL_HALF_CONNECTED and + * CMD_CHANNEL_FULLY_CONNECTED. We'd also change CMD_CHANNEL_FULL_CONNECTION to REQ_CHANNEL_CONNECT. */ public class AsyncChannel { /** Log tag */ @@ -85,6 +90,8 @@ public class AsyncChannel { /** Enable to turn on debugging */ private static final boolean DBG = false; + private static final int BASE = Protocol.BASE_SYSTEM_ASYNC_CHANNEL; + /** * Command sent when the channel is half connected. Half connected * means that the channel can be used to send commends to the destination @@ -98,7 +105,7 @@ public class AsyncChannel { * msg.obj == the AsyncChannel * msg.replyTo == dstMessenger if successful */ - public static final int CMD_CHANNEL_HALF_CONNECTED = -1; + public static final int CMD_CHANNEL_HALF_CONNECTED = BASE + 0; /** * Command typically sent when after receiving the CMD_CHANNEL_HALF_CONNECTED. @@ -107,7 +114,7 @@ public class AsyncChannel { * * msg.replyTo = srcMessenger. */ - public static final int CMD_CHANNEL_FULL_CONNECTION = -2; + public static final int CMD_CHANNEL_FULL_CONNECTION = BASE + 1; /** * Command typically sent after the destination receives a CMD_CHANNEL_FULL_CONNECTION. @@ -115,31 +122,33 @@ public class AsyncChannel { * * msg.arg1 == 0 : Accept connection * : All other values signify the destination rejected the connection - * and {@link AsyncChannel#disconnect(int)} would typically be called. + * and {@link AsyncChannel#disconnect} would typically be called. */ - public static final int CMD_CHANNEL_FULLY_CONNECTED = -3; + public static final int CMD_CHANNEL_FULLY_CONNECTED = BASE + 2; /** * Command sent when one side or the other wishes to disconnect. The sender * may or may not be able to receive a reply depending upon the protocol and - * the state of the connection. The receiver should call {@link AsyncChannel#disconnect(int)} + * the state of the connection. The receiver should call {@link AsyncChannel#disconnect} * to close its side of the channel and it will receive a CMD_CHANNEL_DISCONNECTED * when the channel is closed. * * msg.replyTo = messenger that is disconnecting */ - public static final int CMD_CHANNEL_DISCONNECT = -4; + public static final int CMD_CHANNEL_DISCONNECT = BASE + 3; /** * Command sent when the channel becomes disconnected. This is sent when the * channel is forcibly disconnected by the system or as a reply to CMD_CHANNEL_DISCONNECT. * * msg.arg1 == 0 : STATUS_SUCCESSFUL + * 1 : STATUS_BINDING_UNSUCCESSFUL + * 2 : STATUS_SEND_UNSUCCESSFUL * : All other values signify failure and the channel state is indeterminate * msg.obj == the AsyncChannel * msg.replyTo = messenger disconnecting or null if it was never connected. */ - public static final int CMD_CHANNEL_DISCONNECTED = -5; + public static final int CMD_CHANNEL_DISCONNECTED = BASE + 4; /** Successful status always 0, !0 is an unsuccessful status */ public static final int STATUS_SUCCESSFUL = 0; @@ -147,6 +156,12 @@ public class AsyncChannel { /** Error attempting to bind on a connect */ public static final int STATUS_BINDING_UNSUCCESSFUL = 1; + /** Error attempting to send a message */ + public static final int STATUS_SEND_UNSUCCESSFUL = 2; + + /** CMD_FULLY_CONNECTED refused because a connection already exists*/ + public static final int STATUS_FULL_CONNECTION_REFUSED_ALREADY_CONNECTED = 3; + /** Service connection */ private AsyncChannelConnection mConnection; @@ -169,9 +184,7 @@ public class AsyncChannel { } /** - * Connect handler to named package/class. - * - * Sends a CMD_CHANNEL_HALF_CONNECTED message to srcHandler when complete. + * Connect handler to named package/class synchronously. * * @param srcContext is the context of the source * @param srcHandler is the hander to receive CONNECTED & DISCONNECTED @@ -179,8 +192,10 @@ public class AsyncChannel { * @param dstPackageName is the destination package name * @param dstClassName is the fully qualified class name (i.e. contains * package name) + * + * @return STATUS_SUCCESSFUL on success any other value is an error. */ - private void connectSrcHandlerToPackage( + public int connectSrcHandlerToPackageSync( Context srcContext, Handler srcHandler, String dstPackageName, String dstClassName) { if (DBG) log("connect srcHandler to dst Package & class E"); @@ -202,11 +217,61 @@ public class AsyncChannel { Intent intent = new Intent(Intent.ACTION_MAIN); intent.setClassName(dstPackageName, dstClassName); boolean result = srcContext.bindService(intent, mConnection, Context.BIND_AUTO_CREATE); - if (!result) { - replyHalfConnected(STATUS_BINDING_UNSUCCESSFUL); - } - if (DBG) log("connect srcHandler to dst Package & class X result=" + result); + return result ? STATUS_SUCCESSFUL : STATUS_BINDING_UNSUCCESSFUL; + } + + /** + * Connect a handler to Messenger synchronously. + * + * @param srcContext is the context of the source + * @param srcHandler is the hander to receive CONNECTED & DISCONNECTED + * messages + * @param dstMessenger is the hander to send messages to. + * + * @return STATUS_SUCCESSFUL on success any other value is an error. + */ + public int connectSync(Context srcContext, Handler srcHandler, Messenger dstMessenger) { + if (DBG) log("halfConnectSync srcHandler to the dstMessenger E"); + + // We are connected + connected(srcContext, srcHandler, dstMessenger); + + if (DBG) log("halfConnectSync srcHandler to the dstMessenger X"); + return STATUS_SUCCESSFUL; + } + + /** + * connect two local Handlers synchronously. + * + * @param srcContext is the context of the source + * @param srcHandler is the hander to receive CONNECTED & DISCONNECTED + * messages + * @param dstHandler is the hander to send messages to. + * + * @return STATUS_SUCCESSFUL on success any other value is an error. + */ + public int connectSync(Context srcContext, Handler srcHandler, Handler dstHandler) { + return connectSync(srcContext, srcHandler, new Messenger(dstHandler)); + } + + /** + * Fully connect two local Handlers synchronously. + * + * @param srcContext is the context of the source + * @param srcHandler is the hander to receive CONNECTED & DISCONNECTED + * messages + * @param dstHandler is the hander to send messages to. + * + * @return STATUS_SUCCESSFUL on success any other value is an error. + */ + public int fullyConnectSync(Context srcContext, Handler srcHandler, Handler dstHandler) { + int status = connectSync(srcContext, srcHandler, dstHandler); + if (status == STATUS_SUCCESSFUL) { + Message response = sendMessageSynchronously(CMD_CHANNEL_FULL_CONNECTION); + status = response.arg1; + } + return status; } /** @@ -241,8 +306,11 @@ public class AsyncChannel { mDstClassName = dstClassName; } + @Override public void run() { - connectSrcHandlerToPackage(mSrcCtx, mSrcHdlr, mDstPackageName, mDstClassName); + int result = connectSrcHandlerToPackageSync(mSrcCtx, mSrcHdlr, mDstPackageName, + mDstClassName); + replyHalfConnected(result); } } @@ -281,6 +349,28 @@ public class AsyncChannel { public void connect(Context srcContext, Handler srcHandler, Messenger dstMessenger) { if (DBG) log("connect srcHandler to the dstMessenger E"); + // We are connected + connected(srcContext, srcHandler, dstMessenger); + + // Tell source we are half connected + replyHalfConnected(STATUS_SUCCESSFUL); + + if (DBG) log("connect srcHandler to the dstMessenger X"); + } + + /** + * Connect handler to messenger. This method is typically called + * when a server receives a CMD_CHANNEL_FULL_CONNECTION request + * and initializes the internal instance variables to allow communication + * with the dstMessenger. + * + * @param srcContext + * @param srcHandler + * @param dstMessenger + */ + public void connected(Context srcContext, Handler srcHandler, Messenger dstMessenger) { + if (DBG) log("connected srcHandler to the dstMessenger E"); + // Initialize source fields mSrcContext = srcContext; mSrcHandler = srcHandler; @@ -289,21 +379,12 @@ public class AsyncChannel { // Initialize destination fields mDstMessenger = dstMessenger; - if (DBG) log("tell source we are half connected"); - - // Tell source we are half connected - replyHalfConnected(STATUS_SUCCESSFUL); - - if (DBG) log("connect srcHandler to the dstMessenger X"); + if (DBG) log("connected srcHandler to the dstMessenger X"); } /** * Connect two local Handlers. * - * Sends a CMD_CHANNEL_HALF_CONNECTED message to srcHandler when complete. - * msg.arg1 = status - * msg.obj = the AsyncChannel - * * @param srcContext is the context of the source * @param srcHandler is the hander to receive CONNECTED & DISCONNECTED * messages @@ -331,6 +412,7 @@ public class AsyncChannel { * To close the connection call when handler receives CMD_CHANNEL_DISCONNECTED */ public void disconnected() { + mSrcContext = null; mSrcHandler = null; mSrcMessenger = null; mDstMessenger = null; @@ -341,15 +423,11 @@ public class AsyncChannel { * Disconnect */ public void disconnect() { - if (mConnection != null) { + if ((mConnection != null) && (mSrcContext != null)) { mSrcContext.unbindService(mConnection); } if (mSrcHandler != null) { - Message msg = mSrcHandler.obtainMessage(CMD_CHANNEL_DISCONNECTED); - msg.arg1 = STATUS_SUCCESSFUL; - msg.obj = this; - msg.replyTo = mDstMessenger; - mSrcHandler.sendMessage(msg); + replyDisconnected(STATUS_SUCCESSFUL); } } @@ -363,7 +441,7 @@ public class AsyncChannel { try { mDstMessenger.send(msg); } catch (RemoteException e) { - log("TODO: handle sendMessage RemoteException" + e); + replyDisconnected(STATUS_SEND_UNSUCCESSFUL); } } @@ -444,6 +522,7 @@ public class AsyncChannel { */ public void replyToMessage(Message srcMsg, Message dstMsg) { try { + dstMsg.replyTo = mSrcMessenger; srcMsg.replyTo.send(dstMsg); } catch (RemoteException e) { log("TODO: handle replyToMessage RemoteException" + e); @@ -694,10 +773,14 @@ public class AsyncChannel { private static Message sendMessageSynchronously(Messenger dstMessenger, Message msg) { SyncMessenger sm = SyncMessenger.obtain(); try { - msg.replyTo = sm.mMessenger; - dstMessenger.send(msg); - synchronized (sm.mHandler.mLockObject) { - sm.mHandler.mLockObject.wait(); + if (dstMessenger != null && msg != null) { + msg.replyTo = sm.mMessenger; + synchronized (sm.mHandler.mLockObject) { + dstMessenger.send(msg); + sm.mHandler.mLockObject.wait(); + } + } else { + sm.mHandler.mResultMsg = null; } } catch (InterruptedException e) { sm.mHandler.mResultMsg = null; @@ -712,6 +795,7 @@ public class AsyncChannel { /** * Reply to the src handler that we're half connected. + * see: CMD_CHANNEL_HALF_CONNECTED for message contents * * @param status to be stored in msg.arg1 */ @@ -724,23 +808,36 @@ public class AsyncChannel { } /** + * Reply to the src handler that we are disconnected + * see: CMD_CHANNEL_DISCONNECTED for message contents + * + * @param status to be stored in msg.arg1 + */ + private void replyDisconnected(int status) { + Message msg = mSrcHandler.obtainMessage(CMD_CHANNEL_DISCONNECTED); + msg.arg1 = status; + msg.obj = this; + msg.replyTo = mDstMessenger; + mSrcHandler.sendMessage(msg); + } + + + /** * ServiceConnection to receive call backs. */ class AsyncChannelConnection implements ServiceConnection { AsyncChannelConnection() { } + @Override public void onServiceConnected(ComponentName className, IBinder service) { mDstMessenger = new Messenger(service); replyHalfConnected(STATUS_SUCCESSFUL); } + @Override public void onServiceDisconnected(ComponentName className) { - Message msg = mSrcHandler.obtainMessage(CMD_CHANNEL_DISCONNECTED); - msg.arg1 = STATUS_SUCCESSFUL; - msg.obj = AsyncChannel.this; - msg.replyTo = mDstMessenger; - mSrcHandler.sendMessage(msg); + replyDisconnected(STATUS_SUCCESSFUL); } } diff --git a/core/java/com/android/internal/util/Protocol.java b/core/java/com/android/internal/util/Protocol.java index 2689f09c518e..b35f615b240d 100644 --- a/core/java/com/android/internal/util/Protocol.java +++ b/core/java/com/android/internal/util/Protocol.java @@ -29,9 +29,17 @@ package com.android.internal.util; * {@hide} */ public class Protocol { - public static final int MAX_MESSAGE = 0x0000FFFF; + public static final int MAX_MESSAGE = 0x0000FFFF; + + /** Base reserved for system */ + public static final int BASE_SYSTEM_RESERVED = 0x00010000; + public static final int BASE_SYSTEM_ASYNC_CHANNEL = 0x00011000; + + /** Non system protocols */ + public static final int BASE_WIFI = 0x00020000; + public static final int BASE_DHCP = 0x00030000; + public static final int BASE_DATA_CONNECTION = 0x00040000; + public static final int BASE_DATA_CONNECTION_TRACKER = 0x00050000; - public static final int BASE_WIFI = 0x00010000; - public static final int BASE_DHCP = 0x00020000; //TODO: define all used protocols } diff --git a/docs/html/guide/topics/resources/providing-resources.jd b/docs/html/guide/topics/resources/providing-resources.jd index 1da2622f2b8a..7c84bd233348 100644 --- a/docs/html/guide/topics/resources/providing-resources.jd +++ b/docs/html/guide/topics/resources/providing-resources.jd @@ -264,8 +264,8 @@ href="#Compatibility">Providing the Best Device Compatibility with Resources</a> names.</p> <table> <tr> - <th>Qualifier</th> - <th>Values</th> + <th>Configuration</th> + <th>Qualifier Values</th> <th>Description</th> </tr> <tr id="MccQualifier"> diff --git a/media/libstagefright/NuHTTPDataSource.cpp b/media/libstagefright/NuHTTPDataSource.cpp index bee0d5e03092..62fb73256987 100644 --- a/media/libstagefright/NuHTTPDataSource.cpp +++ b/media/libstagefright/NuHTTPDataSource.cpp @@ -100,6 +100,7 @@ NuHTTPDataSource::NuHTTPDataSource(uint32_t flags) mNumBandwidthHistoryItems(0), mTotalTransferTimeUs(0), mTotalTransferBytes(0), + mPrevBandwidthMeasureTimeUs(0), mDecryptHandle(NULL), mDrmManagerClient(NULL) { } @@ -534,6 +535,16 @@ void NuHTTPDataSource::addBandwidthMeasurement_l( mTotalTransferBytes -= entry->mNumBytes; mBandwidthHistory.erase(mBandwidthHistory.begin()); --mNumBandwidthHistoryItems; + int64_t timeNowUs = ALooper::GetNowUs(); + if (timeNowUs - mPrevBandwidthMeasureTimeUs > 2000000LL) { + if (mPrevBandwidthMeasureTimeUs != 0) { + double estimatedBandwidth = + ((double)mTotalTransferBytes * 8E3 / mTotalTransferTimeUs); + LOGI("estimated avg bandwidth is %8.2f kbps in the past %lld us", + estimatedBandwidth, timeNowUs - mPrevBandwidthMeasureTimeUs); + } + mPrevBandwidthMeasureTimeUs = timeNowUs; + } } } diff --git a/media/libstagefright/include/NuHTTPDataSource.h b/media/libstagefright/include/NuHTTPDataSource.h index 25695688c6cf..0d682340515a 100644 --- a/media/libstagefright/include/NuHTTPDataSource.h +++ b/media/libstagefright/include/NuHTTPDataSource.h @@ -97,6 +97,7 @@ private: size_t mNumBandwidthHistoryItems; int64_t mTotalTransferTimeUs; size_t mTotalTransferBytes; + int64_t mPrevBandwidthMeasureTimeUs; DecryptHandle *mDecryptHandle; DrmManagerClient *mDrmManagerClient; diff --git a/telephony/java/com/android/internal/telephony/RIL.java b/telephony/java/com/android/internal/telephony/RIL.java index f347623aa34e..6edd0b6280d9 100644 --- a/telephony/java/com/android/internal/telephony/RIL.java +++ b/telephony/java/com/android/internal/telephony/RIL.java @@ -3025,7 +3025,7 @@ public final class RIL extends BaseCommands implements CommandsInterface { dataCall.active = p.readInt(); dataCall.type = p.readString(); String addresses = p.readString(); - if (TextUtils.isEmpty(addresses)) { + if (!TextUtils.isEmpty(addresses)) { dataCall.addresses = addresses.split(" "); } } else { @@ -3034,7 +3034,8 @@ public final class RIL extends BaseCommands implements CommandsInterface { dataCall.active = p.readInt(); dataCall.type = p.readString(); dataCall.ifname = p.readString(); - if (TextUtils.isEmpty(dataCall.ifname)) { + if ((dataCall.status == DataConnection.FailCause.NONE.getErrorCode()) && + TextUtils.isEmpty(dataCall.ifname)) { throw new RuntimeException("getDataCallState, no ifname"); } String addresses = p.readString(); diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java index f019487aa2bc..32c5d7520eb4 100644 --- a/telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java +++ b/telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java @@ -44,22 +44,14 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker { CDMALTEPhone mCdmaLtePhone; - private int gprsState = ServiceState.STATE_OUT_OF_SERVICE; - - private int newGPRSState = ServiceState.STATE_OUT_OF_SERVICE; + private ServiceState mLteSS; // The last LTE state from Voice Registration public CdmaLteServiceStateTracker(CDMALTEPhone phone) { super(phone); mCdmaLtePhone = phone; - if (DBG) log("CdmaLteServiceStateTracker Constructors"); - } - /** - * @return The current GPRS state. IN_SERVICE is the same as "attached" and - * OUT_OF_SERVICE is the same as detached. - */ - public int getCurrentDataConnectionState() { - return gprsState; + mLteSS = new ServiceState(); + if (DBG) log("CdmaLteServiceStateTracker Constructors"); } @Override @@ -77,11 +69,13 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker { } /** - * The LTE data connection state, only return true here + * Set the cdmaSS for EVENT_POLL_STATE_REGISTRATION_CDMA */ @Override - protected boolean checkAdditionalDataAvaiable() { - return newGPRSState != ServiceState.STATE_IN_SERVICE; + protected void setCdmaTechnology(int radioTechnology) { + // Called on voice registration state response. + // Just record new CDMA radio technology + newSS.setRadioTechnology(radioTechnology); } /** @@ -109,14 +103,10 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker { } } - newGPRSState = regCodeToServiceState(regState); // Not sure if this is needed in CDMALTE phone. // mDataRoaming = regCodeIsRoaming(regState); - if (newGPRSState == ServiceState.STATE_IN_SERVICE) { - this.newCdmaDataConnectionState = newGPRSState; - newNetworkType = type; - newSS.setRadioTechnology(type); - } + mLteSS.setRadioTechnology(type); + mLteSS.setState(regCodeToServiceState(regState)); } else { super.handlePollStateResultMessage(what, ar); } @@ -216,6 +206,21 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker { @Override protected void pollStateDone() { + // determine data NetworkType from both LET and CDMA SS + if (mLteSS.getState() == ServiceState.STATE_IN_SERVICE) { + //in LTE service + newNetworkType = mLteSS.getRadioTechnology(); + mNewDataConnectionState = mLteSS.getState(); + newSS.setRadioTechnology(newNetworkType); + log("pollStateDone LTE/eHRPD STATE_IN_SERVICE newNetworkType = " + newNetworkType); + } else { + // LTE out of service, get CDMA Service State + newNetworkType = newSS.getRadioTechnology(); + mNewDataConnectionState = radioTechnologyToDataServiceState(newNetworkType); + log("pollStateDone CDMA STATE_IN_SERVICE newNetworkType = " + newNetworkType + + " mNewDataConnectionState = " + mNewDataConnectionState); + } + if (DBG) log("pollStateDone: oldSS=[" + ss + "] newSS=[" + newSS + "]"); boolean hasRegistered = ss.getState() != ServiceState.STATE_IN_SERVICE @@ -225,15 +230,15 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker { && newSS.getState() != ServiceState.STATE_IN_SERVICE; boolean hasCdmaDataConnectionAttached = - this.cdmaDataConnectionState != ServiceState.STATE_IN_SERVICE - && this.newCdmaDataConnectionState == ServiceState.STATE_IN_SERVICE; + mDataConnectionState != ServiceState.STATE_IN_SERVICE + && mNewDataConnectionState == ServiceState.STATE_IN_SERVICE; boolean hasCdmaDataConnectionDetached = - this.cdmaDataConnectionState == ServiceState.STATE_IN_SERVICE - && this.newCdmaDataConnectionState != ServiceState.STATE_IN_SERVICE; + mDataConnectionState == ServiceState.STATE_IN_SERVICE + && mNewDataConnectionState != ServiceState.STATE_IN_SERVICE; boolean hasCdmaDataConnectionChanged = - cdmaDataConnectionState != newCdmaDataConnectionState; + mDataConnectionState != mNewDataConnectionState; boolean hasNetworkTypeChanged = networkType != newNetworkType; @@ -272,9 +277,9 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker { } // Add an event log when connection state changes if (ss.getState() != newSS.getState() - || cdmaDataConnectionState != newCdmaDataConnectionState) { + || mDataConnectionState != mNewDataConnectionState) { EventLog.writeEvent(EventLogTags.CDMA_SERVICE_STATE_CHANGE, ss.getState(), - cdmaDataConnectionState, newSS.getState(), newCdmaDataConnectionState); + mDataConnectionState, newSS.getState(), mNewDataConnectionState); } ServiceState tss; @@ -283,6 +288,7 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker { newSS = tss; // clean slate for next time newSS.setStateOutOfService(); + mLteSS.setStateOutOfService(); // TODO: 4G Tech Handoff // if (has4gHandoff) { @@ -309,11 +315,9 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker { cellLoc = newCellLoc; newCellLoc = tcl; - cdmaDataConnectionState = newCdmaDataConnectionState; + mDataConnectionState = mNewDataConnectionState; networkType = newNetworkType; - gprsState = newCdmaDataConnectionState; - newSS.setStateOutOfService(); // clean slate for next time if (hasNetworkTypeChanged) { diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java index ac8352d2cb66..afebebe97688 100755 --- a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java +++ b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java @@ -97,8 +97,8 @@ public class CdmaServiceStateTracker extends ServiceStateTracker { /** * Initially assume no data connection. */ - protected int cdmaDataConnectionState = ServiceState.STATE_OUT_OF_SERVICE; - protected int newCdmaDataConnectionState = ServiceState.STATE_OUT_OF_SERVICE; + protected int mDataConnectionState = ServiceState.STATE_OUT_OF_SERVICE; + protected int mNewDataConnectionState = ServiceState.STATE_OUT_OF_SERVICE; protected int mRegistrationState = -1; protected RegistrantList cdmaForSubscriptionInfoReadyRegistrants = new RegistrantList(); @@ -217,8 +217,8 @@ public class CdmaServiceStateTracker extends ServiceStateTracker { phone.mRuimRecords.unregisterForRecordsLoaded(this); cm.unSetOnSignalStrengthUpdate(this); cm.unSetOnNITZTime(this); - cr.unregisterContentObserver(this.mAutoTimeObserver); - cr.unregisterContentObserver(this.mAutoTimeZoneObserver); + cr.unregisterContentObserver(mAutoTimeObserver); + cr.unregisterContentObserver(mAutoTimeZoneObserver); } @Override @@ -548,10 +548,12 @@ public class CdmaServiceStateTracker extends ServiceStateTracker { } /** - * The LTE data connection state, only return true here + * Determine data network type based on radio technology. */ - protected boolean checkAdditionalDataAvaiable(){ - return true; + protected void setCdmaTechnology(int radioTechnology){ + mNewDataConnectionState = radioTechnologyToDataServiceState(radioTechnology); + newSS.setRadioTechnology(radioTechnology); + newNetworkType = radioTechnology; } /** @@ -639,12 +641,7 @@ public class CdmaServiceStateTracker extends ServiceStateTracker { regCodeIsRoaming(registrationState) && !isRoamIndForHomeSystem(states[10]); newSS.setState (regCodeToServiceState(registrationState)); - if(checkAdditionalDataAvaiable()) { - this.newCdmaDataConnectionState = - radioTechnologyToDataServiceState(radioTechnology); - newSS.setRadioTechnology(radioTechnology); - newNetworkType = radioTechnology; - } + setCdmaTechnology(radioTechnology); newSS.setCssIndicator(cssIndicator); newSS.setSystemAndNetworkId(systemId, networkId); @@ -953,15 +950,15 @@ public class CdmaServiceStateTracker extends ServiceStateTracker { && newSS.getState() != ServiceState.STATE_IN_SERVICE; boolean hasCdmaDataConnectionAttached = - this.cdmaDataConnectionState != ServiceState.STATE_IN_SERVICE - && this.newCdmaDataConnectionState == ServiceState.STATE_IN_SERVICE; + mDataConnectionState != ServiceState.STATE_IN_SERVICE + && mNewDataConnectionState == ServiceState.STATE_IN_SERVICE; boolean hasCdmaDataConnectionDetached = - this.cdmaDataConnectionState == ServiceState.STATE_IN_SERVICE - && this.newCdmaDataConnectionState != ServiceState.STATE_IN_SERVICE; + mDataConnectionState == ServiceState.STATE_IN_SERVICE + && mNewDataConnectionState != ServiceState.STATE_IN_SERVICE; boolean hasCdmaDataConnectionChanged = - cdmaDataConnectionState != newCdmaDataConnectionState; + mDataConnectionState != mNewDataConnectionState; boolean hasNetworkTypeChanged = networkType != newNetworkType; @@ -975,10 +972,10 @@ public class CdmaServiceStateTracker extends ServiceStateTracker { // Add an event log when connection state changes if (ss.getState() != newSS.getState() || - cdmaDataConnectionState != newCdmaDataConnectionState) { + mDataConnectionState != mNewDataConnectionState) { EventLog.writeEvent(EventLogTags.CDMA_SERVICE_STATE_CHANGE, - ss.getState(), cdmaDataConnectionState, - newSS.getState(), newCdmaDataConnectionState); + ss.getState(), mDataConnectionState, + newSS.getState(), mNewDataConnectionState); } ServiceState tss; @@ -992,7 +989,7 @@ public class CdmaServiceStateTracker extends ServiceStateTracker { cellLoc = newCellLoc; newCellLoc = tcl; - cdmaDataConnectionState = newCdmaDataConnectionState; + mDataConnectionState = mNewDataConnectionState; networkType = newNetworkType; // this new state has been applied - forget it until we get a new new state newNetworkType = 0; @@ -1175,7 +1172,7 @@ public class CdmaServiceStateTracker extends ServiceStateTracker { } - private int radioTechnologyToDataServiceState(int code) { + protected int radioTechnologyToDataServiceState(int code) { int retVal = ServiceState.STATE_OUT_OF_SERVICE; switch(code) { case 0: @@ -1226,14 +1223,14 @@ public class CdmaServiceStateTracker extends ServiceStateTracker { * ServiceState.RADIO_TECHNOLOGY_UNKNOWN is the same as detached. */ /*package*/ int getCurrentCdmaDataConnectionState() { - return cdmaDataConnectionState; + return mDataConnectionState; } /** * TODO: In the future, we need remove getCurrentCdmaDataConnectionState */ public int getCurrentDataConnectionState() { - return cdmaDataConnectionState; + return mDataConnectionState; } /** |