diff options
56 files changed, 384 insertions, 110 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index f08d88d..378a8bd 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -645,11 +645,13 @@ public class Activity extends ContextThemeWrapper Activity mParent; boolean mCalled; boolean mCheckedForLoaderManager; - boolean mStarted; + boolean mLoadersStarted; private boolean mResumed; private boolean mStopped; boolean mFinished; boolean mStartedActivity; + /** true if the activity is going through a transient pause */ + /*package*/ boolean mTemporaryPause = false; /** true if the activity is being destroyed in order to recreate it with a new configuration */ /*package*/ boolean mChangingConfigurations = false; /*package*/ int mConfigChangeFlags; @@ -768,7 +770,7 @@ public class Activity extends ContextThemeWrapper return mLoaderManager; } mCheckedForLoaderManager = true; - mLoaderManager = getLoaderManager(-1, mStarted, true); + mLoaderManager = getLoaderManager(-1, mLoadersStarted, true); return mLoaderManager; } @@ -777,9 +779,13 @@ public class Activity extends ContextThemeWrapper mAllLoaderManagers = new SparseArray<LoaderManagerImpl>(); } LoaderManagerImpl lm = mAllLoaderManagers.get(index); - if (lm == null && create) { - lm = new LoaderManagerImpl(started); - mAllLoaderManagers.put(index, lm); + if (lm == null) { + if (create) { + lm = new LoaderManagerImpl(this, started); + mAllLoaderManagers.put(index, lm); + } + } else { + lm.updateActivity(this); } return lm; } @@ -979,13 +985,16 @@ public class Activity extends ContextThemeWrapper */ protected void onStart() { mCalled = true; - mStarted = true; - if (mLoaderManager != null) { - mLoaderManager.doStart(); - } else if (!mCheckedForLoaderManager) { - mLoaderManager = getLoaderManager(-1, mStarted, false); + + if (!mLoadersStarted) { + mLoadersStarted = true; + if (mLoaderManager != null) { + mLoaderManager.doStart(); + } else if (!mCheckedForLoaderManager) { + mLoaderManager = getLoaderManager(-1, mLoadersStarted, false); + } + mCheckedForLoaderManager = true; } - mCheckedForLoaderManager = true; } /** @@ -4249,7 +4258,7 @@ public class Activity extends ContextThemeWrapper } final void performStart() { - mFragments.mStateSaved = false; + mFragments.noteStateNotSaved(); mCalled = false; mFragments.execPendingActions(); mInstrumentation.callActivityOnStart(this); @@ -4267,7 +4276,7 @@ public class Activity extends ContextThemeWrapper } final void performRestart() { - mFragments.mStateSaved = false; + mFragments.noteStateNotSaved(); synchronized (mManagedCursors) { final int N = mManagedCursors.size(); @@ -4347,8 +4356,8 @@ public class Activity extends ContextThemeWrapper } final void performStop() { - if (mStarted) { - mStarted = false; + if (mLoadersStarted) { + mLoadersStarted = false; if (mLoaderManager != null) { if (!mChangingConfigurations) { mLoaderManager.doStop(); @@ -4407,7 +4416,7 @@ public class Activity extends ContextThemeWrapper if (Config.LOGV) Log.v( TAG, "Dispatching result: who=" + who + ", reqCode=" + requestCode + ", resCode=" + resultCode + ", data=" + data); - mFragments.mStateSaved = false; + mFragments.noteStateNotSaved(); if (who == null) { onActivityResult(requestCode, resultCode, data); } else { diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index f3f7ee7..2abe822 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -1757,6 +1757,7 @@ public final class ActivityThread { for (int i=0; i<N; i++) { Intent intent = intents.get(i); intent.setExtrasClassLoader(r.activity.getClassLoader()); + r.activity.mFragments.noteStateNotSaved(); mInstrumentation.callActivityOnNewIntent(r.activity, intent); } } @@ -1767,11 +1768,13 @@ public final class ActivityThread { if (r != null) { final boolean resumed = !r.paused; if (resumed) { + r.activity.mTemporaryPause = true; mInstrumentation.callActivityOnPause(r.activity); } deliverNewIntents(r, intents); if (resumed) { mInstrumentation.callActivityOnResume(r.activity); + r.activity.mTemporaryPause = false; } } } @@ -2594,6 +2597,7 @@ public final class ActivityThread { try { // Now we are idle. r.activity.mCalled = false; + r.activity.mTemporaryPause = true; mInstrumentation.callActivityOnPause(r.activity); if (!r.activity.mCalled) { throw new SuperNotCalledException( @@ -2614,6 +2618,7 @@ public final class ActivityThread { deliverResults(r, res.results); if (resumed) { mInstrumentation.callActivityOnResume(r.activity); + r.activity.mTemporaryPause = false; } } } diff --git a/core/java/android/app/Fragment.java b/core/java/android/app/Fragment.java index 12bf7e5..3ec0912 100644 --- a/core/java/android/app/Fragment.java +++ b/core/java/android/app/Fragment.java @@ -403,7 +403,7 @@ public class Fragment implements ComponentCallbacks, OnCreateContextMenuListener View mView; LoaderManagerImpl mLoaderManager; - boolean mStarted; + boolean mLoadersStarted; boolean mCheckedForLoaderManager; /** @@ -728,7 +728,7 @@ public class Fragment implements ComponentCallbacks, OnCreateContextMenuListener return mLoaderManager; } mCheckedForLoaderManager = true; - mLoaderManager = mActivity.getLoaderManager(mIndex, mStarted, true); + mLoaderManager = mActivity.getLoaderManager(mIndex, mLoadersStarted, true); return mLoaderManager; } @@ -880,13 +880,16 @@ public class Fragment implements ComponentCallbacks, OnCreateContextMenuListener */ public void onStart() { mCalled = true; - mStarted = true; - if (!mCheckedForLoaderManager) { - mCheckedForLoaderManager = true; - mLoaderManager = mActivity.getLoaderManager(mIndex, mStarted, false); - } - if (mLoaderManager != null) { - mLoaderManager.doStart(); + + if (!mLoadersStarted) { + mLoadersStarted = true; + if (!mCheckedForLoaderManager) { + mCheckedForLoaderManager = true; + mLoaderManager = mActivity.getLoaderManager(mIndex, mLoadersStarted, false); + } + if (mLoaderManager != null) { + mLoaderManager.doStart(); + } } } @@ -971,7 +974,7 @@ public class Fragment implements ComponentCallbacks, OnCreateContextMenuListener // + " mLoaderManager=" + mLoaderManager); if (!mCheckedForLoaderManager) { mCheckedForLoaderManager = true; - mLoaderManager = mActivity.getLoaderManager(mIndex, mStarted, false); + mLoaderManager = mActivity.getLoaderManager(mIndex, mLoadersStarted, false); } if (mLoaderManager != null) { mLoaderManager.doDestroy(); @@ -1182,7 +1185,7 @@ public class Fragment implements ComponentCallbacks, OnCreateContextMenuListener } if (mLoaderManager != null) { writer.print(prefix); writer.print("mLoaderManager="); writer.print(mLoaderManager); - writer.print(" mStarted="); writer.print(mStarted); + writer.print(" mLoadersStarted="); writer.print(mLoadersStarted); writer.print(" mCheckedForLoaderManager="); writer.println(mCheckedForLoaderManager); } @@ -1190,11 +1193,12 @@ public class Fragment implements ComponentCallbacks, OnCreateContextMenuListener void performStop() { onStop(); - if (mStarted) { - mStarted = false; + + if (mLoadersStarted) { + mLoadersStarted = false; if (!mCheckedForLoaderManager) { mCheckedForLoaderManager = true; - mLoaderManager = mActivity.getLoaderManager(mIndex, mStarted, false); + mLoaderManager = mActivity.getLoaderManager(mIndex, mLoadersStarted, false); } if (mLoaderManager != null) { if (mActivity == null || !mActivity.mChangingConfigurations) { diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java index 37e7253..d9a6171 100644 --- a/core/java/android/app/FragmentManager.java +++ b/core/java/android/app/FragmentManager.java @@ -86,6 +86,15 @@ public interface FragmentManager { /** * Start a series of edit operations on the Fragments associated with * this FragmentManager. + * + * <p>Note: A fragment transaction can only be created/committed prior + * to an activity saving its state. If you try to commit a transaction + * after {@link Activity#onSaveInstanceState Activity.onSaveInstanceState()} + * (and prior to a following {@link Activity#onStart Activity.onStart} + * or {@link Activity#onResume Activity.onResume()}, you will get an error. + * This is because the framework takes care of saving your current fragments + * in the state, and if changes are made after the state is saved then they + * will be lost.</p> */ public FragmentTransaction openTransaction(); @@ -271,6 +280,7 @@ final class FragmentManagerImpl implements FragmentManager { boolean mNeedMenuInvalidate; boolean mStateSaved; + String mNoTransactionsBecause; // Temporary vars for state save and restore. Bundle mStateBundle = null; @@ -843,6 +853,10 @@ final class FragmentManagerImpl implements FragmentManager { throw new IllegalStateException( "Can not perform this action after onSaveInstanceState"); } + if (mNoTransactionsBecause != null) { + throw new IllegalStateException( + "Can not perform this action inside of " + mNoTransactionsBecause); + } synchronized (this) { if (mPendingActions == null) { mPendingActions = new ArrayList<Runnable>(); @@ -1271,6 +1285,10 @@ final class FragmentManagerImpl implements FragmentManager { mActivity = activity; } + public void noteStateNotSaved() { + mStateSaved = false; + } + public void dispatchCreate() { mStateSaved = false; moveToState(Fragment.CREATED, false); diff --git a/core/java/android/app/LoaderManager.java b/core/java/android/app/LoaderManager.java index 28abcaa..4d4ea9a 100644 --- a/core/java/android/app/LoaderManager.java +++ b/core/java/android/app/LoaderManager.java @@ -40,7 +40,12 @@ public interface LoaderManager { public Loader<D> onCreateLoader(int id, Bundle args); /** - * Called when a previously created loader has finished its load. + * Called when a previously created loader has finished its load. Note + * that normally an application is <em>not</em> allowed to commit fragment + * transactions while in this call, since it can happen after an + * activity's state is saved. See {@link FragmentManager#openTransaction() + * FragmentManager.openTransaction()} for further discussion on this. + * * @param loader The Loader that has finished. * @param data The data generated by the Loader. */ @@ -102,6 +107,7 @@ class LoaderManagerImpl implements LoaderManager { // previously run loader until the new loader's data is available. final SparseArray<LoaderInfo> mInactiveLoaders = new SparseArray<LoaderInfo>(); + Activity mActivity; boolean mStarted; boolean mRetaining; boolean mRetainingStarted; @@ -172,12 +178,12 @@ class LoaderManagerImpl implements LoaderManager { stop(); } } - if (mStarted && mData != null && mCallbacks != null) { + if (mStarted && mData != null) { // This loader was retained, and now at the point of // finishing the retain we find we remain started, have // our data, and the owner has a new callback... so // let's deliver the data now. - mCallbacks.onLoadFinished(mLoader, mData); + callOnLoadFinished(mLoader, mData); } } } @@ -219,9 +225,7 @@ class LoaderManagerImpl implements LoaderManager { // Notify of the new data so the app can switch out the old data before // we try to destroy it. mData = data; - if (mCallbacks != null) { - mCallbacks.onLoadFinished(loader, data); - } + callOnLoadFinished(loader, data); if (DEBUG) Log.v(TAG, "onLoadFinished returned: " + this); @@ -236,6 +240,23 @@ class LoaderManagerImpl implements LoaderManager { } } + void callOnLoadFinished(Loader<Object> loader, Object data) { + if (mCallbacks != null) { + String lastBecause = null; + if (mActivity != null) { + lastBecause = mActivity.mFragments.mNoTransactionsBecause; + mActivity.mFragments.mNoTransactionsBecause = "onLoadFinished"; + } + try { + mCallbacks.onLoadFinished(loader, data); + } finally { + if (mActivity != null) { + mActivity.mFragments.mNoTransactionsBecause = lastBecause; + } + } + } + } + @Override public String toString() { StringBuilder sb = new StringBuilder(64); @@ -252,10 +273,15 @@ class LoaderManagerImpl implements LoaderManager { } } - LoaderManagerImpl(boolean started) { + LoaderManagerImpl(Activity activity, boolean started) { + mActivity = activity; mStarted = started; } + void updateActivity(Activity activity) { + mActivity = activity; + } + private LoaderInfo createLoader(int id, Bundle args, LoaderManager.LoaderCallbacks<Object> callback) { LoaderInfo info = new LoaderInfo(id, args, (LoaderManager.LoaderCallbacks<Object>)callback); @@ -286,7 +312,7 @@ class LoaderManagerImpl implements LoaderManager { if (info.mData != null && mStarted) { // If the loader has already generated its data, report it now. - info.mCallbacks.onLoadFinished(info.mLoader, info.mData); + info.callOnLoadFinished(info.mLoader, info.mData); } return (Loader<D>)info.mLoader; @@ -348,7 +374,13 @@ class LoaderManagerImpl implements LoaderManager { void doStart() { if (DEBUG) Log.v(TAG, "Starting: " + this); - + if (mStarted) { + RuntimeException e = new RuntimeException("here"); + e.fillInStackTrace(); + Log.w(TAG, "Called doStart when already started: " + this, e); + return; + } + // Call out to sub classes so they can start their loaders // Let the existing loaders know that we want to be notified when a load is complete for (int i = mLoaders.size()-1; i >= 0; i--) { @@ -359,6 +391,12 @@ class LoaderManagerImpl implements LoaderManager { void doStop() { if (DEBUG) Log.v(TAG, "Stopping: " + this); + if (!mStarted) { + RuntimeException e = new RuntimeException("here"); + e.fillInStackTrace(); + Log.w(TAG, "Called doStop when not started: " + this, e); + return; + } for (int i = mLoaders.size()-1; i >= 0; i--) { mLoaders.valueAt(i).stop(); @@ -368,6 +406,12 @@ class LoaderManagerImpl implements LoaderManager { void doRetain() { if (DEBUG) Log.v(TAG, "Retaining: " + this); + if (!mStarted) { + RuntimeException e = new RuntimeException("here"); + e.fillInStackTrace(); + Log.w(TAG, "Called doRetain when not started: " + this, e); + return; + } mRetaining = true; mStarted = false; diff --git a/core/java/android/widget/TabHost.java b/core/java/android/widget/TabHost.java index ff31dec..2949208 100644 --- a/core/java/android/widget/TabHost.java +++ b/core/java/android/widget/TabHost.java @@ -21,6 +21,7 @@ import com.android.internal.R; import android.app.LocalActivityManager; import android.content.Context; import android.content.Intent; +import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.os.Build; import android.util.AttributeSet; @@ -63,6 +64,8 @@ public class TabHost extends FrameLayout implements ViewTreeObserver.OnTouchMode private OnTabChangeListener mOnTabChangeListener; private OnKeyListener mTabKeyListener; + private int mTabLayoutId; + public TabHost(Context context) { super(context); initTabHost(); @@ -70,6 +73,18 @@ public class TabHost extends FrameLayout implements ViewTreeObserver.OnTouchMode public TabHost(Context context, AttributeSet attrs) { super(context, attrs); + + TypedArray a = context.obtainStyledAttributes(attrs, + com.android.internal.R.styleable.TabWidget, + com.android.internal.R.attr.tabWidgetStyle, 0); + + mTabLayoutId = a.getResourceId(R.styleable.TabWidget_tabLayout, 0); + if (mTabLayoutId == 0) { + throw new IllegalArgumentException("Invalid TabWidget tabLayout id"); + } + + a.recycle(); + initTabHost(); } @@ -214,6 +229,7 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1"); if (tabSpec.mIndicatorStrategy instanceof ViewIndicatorStrategy) { mTabWidget.setStripEnabled(false); } + mTabWidget.addView(tabIndicator); mTabSpecs.add(tabSpec); @@ -513,7 +529,7 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1"); final Context context = getContext(); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View tabIndicator = inflater.inflate(R.layout.tab_indicator, + View tabIndicator = inflater.inflate(mTabLayoutId, mTabWidget, // tab widget is the parent false); // no inflate params @@ -525,7 +541,7 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1"); tabIndicator.setBackgroundResource(R.drawable.tab_indicator_v4); tv.setTextColor(context.getResources().getColorStateList(R.color.tab_indicator_text_v4)); } - + return tabIndicator; } } @@ -547,7 +563,7 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1"); final Context context = getContext(); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View tabIndicator = inflater.inflate(R.layout.tab_indicator, + View tabIndicator = inflater.inflate(mTabLayoutId, mTabWidget, // tab widget is the parent false); // no inflate params @@ -555,14 +571,17 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1"); tv.setText(mLabel); final ImageView iconView = (ImageView) tabIndicator.findViewById(R.id.icon); - iconView.setImageDrawable(mIcon); + if (mIcon != null) { + iconView.setImageDrawable(mIcon); + iconView.setVisibility(VISIBLE); + } if (context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.DONUT) { // Donut apps get old color scheme tabIndicator.setBackgroundResource(R.drawable.tab_indicator_v4); tv.setTextColor(context.getResources().getColorStateList(R.color.tab_indicator_text_v4)); } - + return tabIndicator; } } diff --git a/core/java/android/widget/TabWidget.java b/core/java/android/widget/TabWidget.java index 0469e7b..36adacd 100644 --- a/core/java/android/widget/TabWidget.java +++ b/core/java/android/widget/TabWidget.java @@ -120,7 +120,9 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener { final Context context = mContext; final Resources resources = context.getResources(); - + + // Tests the target Sdk version, as set in the Manifest. Could not be set using styles.xml + // in a values-v? directory which targets the current platform Sdk version instead. if (context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.DONUT) { // Donut apps get old color scheme if (mLeftStrip == null) { @@ -131,16 +133,6 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener { mRightStrip = resources.getDrawable( com.android.internal.R.drawable.tab_bottom_right_v4); } - } else { - // Use modern color scheme for Eclair and beyond - if (mLeftStrip == null) { - mLeftStrip = resources.getDrawable( - com.android.internal.R.drawable.tab_bottom_left); - } - if (mRightStrip == null) { - mRightStrip = resources.getDrawable( - com.android.internal.R.drawable.tab_bottom_right); - } } // Deal with focus, as we don't want the focus to go by default diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 09563fc..6897537 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -7142,6 +7142,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener case Gravity.RIGHT: return 0.0f; case Gravity.CENTER_HORIZONTAL: + case Gravity.FILL_HORIZONTAL: return (mLayout.getLineWidth(0) - ((mRight - mLeft) - getCompoundPaddingLeft() - getCompoundPaddingRight())) / getHorizontalFadingEdgeLength(); diff --git a/core/jni/android_net_wifi_Wifi.cpp b/core/jni/android_net_wifi_Wifi.cpp index defd0a0..27d4b9e 100644 --- a/core/jni/android_net_wifi_Wifi.cpp +++ b/core/jni/android_net_wifi_Wifi.cpp @@ -25,6 +25,7 @@ #include "wifi.h" #define WIFI_PKG_NAME "android/net/wifi/WifiNative" +#define BUF_SIZE 256 namespace android { @@ -67,7 +68,7 @@ static int doCommand(const char *cmd, char *replybuf, int replybuflen) static jint doIntCommand(const char *cmd) { - char reply[256]; + char reply[BUF_SIZE]; if (doCommand(cmd, reply, sizeof(reply)) != 0) { return (jint)-1; @@ -78,7 +79,7 @@ static jint doIntCommand(const char *cmd) static jboolean doBooleanCommand(const char *cmd, const char *expect) { - char reply[256]; + char reply[BUF_SIZE]; if (doCommand(cmd, reply, sizeof(reply)) != 0) { return (jboolean)JNI_FALSE; @@ -137,7 +138,7 @@ static void android_net_wifi_closeSupplicantConnection(JNIEnv* env, jobject claz static jstring android_net_wifi_waitForEvent(JNIEnv* env, jobject clazz) { - char buf[256]; + char buf[BUF_SIZE]; int nread = ::wifi_wait_for_event(buf, sizeof buf); if (nread > 0) { @@ -159,7 +160,7 @@ static jint android_net_wifi_addNetworkCommand(JNIEnv* env, jobject clazz) static jboolean android_net_wifi_wpsPbcCommand(JNIEnv* env, jobject clazz, jstring bssid) { - char cmdstr[50]; + char cmdstr[BUF_SIZE]; jboolean isCopy; const char *bssidStr = env->GetStringUTFChars(bssid, &isCopy); @@ -172,9 +173,9 @@ static jboolean android_net_wifi_wpsPbcCommand(JNIEnv* env, jobject clazz, jstri return doBooleanCommand(cmdstr, "OK"); } -static jboolean android_net_wifi_wpsPinCommand(JNIEnv* env, jobject clazz, jstring bssid, int apPin) +static jboolean android_net_wifi_wpsPinFromAccessPointCommand(JNIEnv* env, jobject clazz, jstring bssid, int apPin) { - char cmdstr[50]; + char cmdstr[BUF_SIZE]; jboolean isCopy; const char *bssidStr = env->GetStringUTFChars(bssid, &isCopy); @@ -187,13 +188,29 @@ static jboolean android_net_wifi_wpsPinCommand(JNIEnv* env, jobject clazz, jstri return doBooleanCommand(cmdstr, "OK"); } +static jint android_net_wifi_wpsPinFromDeviceCommand(JNIEnv* env, jobject clazz, jstring bssid) +{ + char cmdstr[BUF_SIZE]; + jboolean isCopy; + + const char *bssidStr = env->GetStringUTFChars(bssid, &isCopy); + int numWritten = snprintf(cmdstr, sizeof(cmdstr), "WPS_PIN %s", bssidStr); + env->ReleaseStringUTFChars(bssid, bssidStr); + + if ((numWritten == -1) || (numWritten >= (int)sizeof(cmdstr))) { + return false; + } + return doIntCommand(cmdstr); +} + + static jboolean android_net_wifi_setNetworkVariableCommand(JNIEnv* env, jobject clazz, jint netId, jstring name, jstring value) { - char cmdstr[256]; + char cmdstr[BUF_SIZE]; jboolean isCopy; const char *nameStr = env->GetStringUTFChars(name, &isCopy); @@ -216,7 +233,7 @@ static jstring android_net_wifi_getNetworkVariableCommand(JNIEnv* env, jint netId, jstring name) { - char cmdstr[256]; + char cmdstr[BUF_SIZE]; jboolean isCopy; const char *nameStr = env->GetStringUTFChars(name, &isCopy); @@ -234,7 +251,7 @@ static jstring android_net_wifi_getNetworkVariableCommand(JNIEnv* env, static jboolean android_net_wifi_removeNetworkCommand(JNIEnv* env, jobject clazz, jint netId) { - char cmdstr[256]; + char cmdstr[BUF_SIZE]; int numWritten = snprintf(cmdstr, sizeof(cmdstr), "REMOVE_NETWORK %d", netId); int cmdTooLong = numWritten >= (int)sizeof(cmdstr); @@ -247,7 +264,7 @@ static jboolean android_net_wifi_enableNetworkCommand(JNIEnv* env, jint netId, jboolean disableOthers) { - char cmdstr[256]; + char cmdstr[BUF_SIZE]; const char *cmd = disableOthers ? "SELECT_NETWORK" : "ENABLE_NETWORK"; int numWritten = snprintf(cmdstr, sizeof(cmdstr), "%s %d", cmd, netId); @@ -258,7 +275,7 @@ static jboolean android_net_wifi_enableNetworkCommand(JNIEnv* env, static jboolean android_net_wifi_disableNetworkCommand(JNIEnv* env, jobject clazz, jint netId) { - char cmdstr[256]; + char cmdstr[BUF_SIZE]; int numWritten = snprintf(cmdstr, sizeof(cmdstr), "DISABLE_NETWORK %d", netId); int cmdTooLong = numWritten >= (int)sizeof(cmdstr); @@ -352,7 +369,7 @@ static jboolean android_net_wifi_stopPacketFiltering(JNIEnv* env, jobject clazz) static jint android_net_wifi_getRssiHelper(const char *cmd) { - char reply[256]; + char reply[BUF_SIZE]; int rssi = -200; if (doCommand(cmd, reply, sizeof(reply)) != 0) { @@ -391,7 +408,7 @@ static jint android_net_wifi_getRssiApproxCommand(JNIEnv* env, jobject clazz) static jint android_net_wifi_getLinkSpeedCommand(JNIEnv* env, jobject clazz) { - char reply[256]; + char reply[BUF_SIZE]; int linkspeed; if (doCommand("DRIVER LINKSPEED", reply, sizeof(reply)) != 0) { @@ -405,8 +422,8 @@ static jint android_net_wifi_getLinkSpeedCommand(JNIEnv* env, jobject clazz) static jstring android_net_wifi_getMacAddressCommand(JNIEnv* env, jobject clazz) { - char reply[256]; - char buf[256]; + char reply[BUF_SIZE]; + char buf[BUF_SIZE]; if (doCommand("DRIVER MACADDR", reply, sizeof(reply)) != 0) { return env->NewStringUTF(NULL); @@ -421,7 +438,7 @@ static jstring android_net_wifi_getMacAddressCommand(JNIEnv* env, jobject clazz) static jboolean android_net_wifi_setPowerModeCommand(JNIEnv* env, jobject clazz, jint mode) { - char cmdstr[256]; + char cmdstr[BUF_SIZE]; int numWritten = snprintf(cmdstr, sizeof(cmdstr), "DRIVER POWERMODE %d", mode); int cmdTooLong = numWritten >= (int)sizeof(cmdstr); @@ -431,7 +448,7 @@ static jboolean android_net_wifi_setPowerModeCommand(JNIEnv* env, jobject clazz, static jint android_net_wifi_getPowerModeCommand(JNIEnv* env, jobject clazz) { - char reply[256]; + char reply[BUF_SIZE]; int power; if (doCommand("DRIVER GETPOWER", reply, sizeof(reply)) != 0) { @@ -469,7 +486,7 @@ static jint android_net_wifi_getBandCommand(JNIEnv* env, jobject clazz) static jboolean android_net_wifi_setNumAllowedChannelsCommand(JNIEnv* env, jobject clazz, jint numChannels) { - char cmdstr[256]; + char cmdstr[BUF_SIZE]; int numWritten = snprintf(cmdstr, sizeof(cmdstr), "DRIVER SCAN-CHANNELS %u", numChannels); int cmdTooLong = numWritten >= (int)sizeof(cmdstr); @@ -479,7 +496,7 @@ static jboolean android_net_wifi_setNumAllowedChannelsCommand(JNIEnv* env, jobje static jint android_net_wifi_getNumAllowedChannelsCommand(JNIEnv* env, jobject clazz) { - char reply[256]; + char reply[BUF_SIZE]; int numChannels; if (doCommand("DRIVER SCAN-CHANNELS", reply, sizeof(reply)) != 0) { @@ -495,7 +512,7 @@ static jint android_net_wifi_getNumAllowedChannelsCommand(JNIEnv* env, jobject c static jboolean android_net_wifi_setBluetoothCoexistenceModeCommand(JNIEnv* env, jobject clazz, jint mode) { - char cmdstr[256]; + char cmdstr[BUF_SIZE]; int numWritten = snprintf(cmdstr, sizeof(cmdstr), "DRIVER BTCOEXMODE %d", mode); int cmdTooLong = numWritten >= (int)sizeof(cmdstr); @@ -505,7 +522,7 @@ static jboolean android_net_wifi_setBluetoothCoexistenceModeCommand(JNIEnv* env, static jboolean android_net_wifi_setBluetoothCoexistenceScanModeCommand(JNIEnv* env, jobject clazz, jboolean setCoexScanMode) { - char cmdstr[256]; + char cmdstr[BUF_SIZE]; int numWritten = snprintf(cmdstr, sizeof(cmdstr), "DRIVER BTCOEXSCAN-%s", setCoexScanMode ? "START" : "STOP"); int cmdTooLong = numWritten >= (int)sizeof(cmdstr); @@ -527,7 +544,7 @@ static jboolean android_net_wifi_reloadConfigCommand(JNIEnv* env, jobject clazz) static jboolean android_net_wifi_setScanResultHandlingCommand(JNIEnv* env, jobject clazz, jint mode) { - char cmdstr[256]; + char cmdstr[BUF_SIZE]; int numWritten = snprintf(cmdstr, sizeof(cmdstr), "AP_SCAN %d", mode); int cmdTooLong = numWritten >= (int)sizeof(cmdstr); @@ -537,7 +554,7 @@ static jboolean android_net_wifi_setScanResultHandlingCommand(JNIEnv* env, jobje static jboolean android_net_wifi_addToBlacklistCommand(JNIEnv* env, jobject clazz, jstring bssid) { - char cmdstr[256]; + char cmdstr[BUF_SIZE]; jboolean isCopy; const char *bssidStr = env->GetStringUTFChars(bssid, &isCopy); @@ -636,7 +653,10 @@ static JNINativeMethod gWifiMethods[] = { { "addToBlacklistCommand", "(Ljava/lang/String;)Z", (void*) android_net_wifi_addToBlacklistCommand }, { "clearBlacklistCommand", "()Z", (void*) android_net_wifi_clearBlacklistCommand }, { "startWpsPbcCommand", "(Ljava/lang/String;)Z", (void*) android_net_wifi_wpsPbcCommand }, - { "startWpsPinCommand", "(Ljava/lang/String;I)Z", (void*) android_net_wifi_wpsPinCommand }, + { "startWpsWithPinFromAccessPointCommand", "(Ljava/lang/String;I)Z", + (void*) android_net_wifi_wpsPinFromAccessPointCommand }, + { "startWpsWithPinFromDeviceCommand", "(Ljava/lang/String;)I", + (void*) android_net_wifi_wpsPinFromDeviceCommand }, { "doDhcpRequest", "(Landroid/net/DhcpInfo;)Z", (void*) android_net_wifi_doDhcpRequest }, { "getDhcpError", "()Ljava/lang/String;", (void*) android_net_wifi_getDhcpError }, }; diff --git a/core/res/res/drawable-hdpi/tab_arrow_left_holo_dark.png b/core/res/res/drawable-hdpi/tab_arrow_left_holo_dark.png Binary files differdeleted file mode 100644 index cfd6f78..0000000 --- a/core/res/res/drawable-hdpi/tab_arrow_left_holo_dark.png +++ /dev/null diff --git a/core/res/res/drawable-hdpi/tab_arrow_left_holo_light.png b/core/res/res/drawable-hdpi/tab_arrow_left_holo_light.png Binary files differdeleted file mode 100644 index 036aa8c..0000000 --- a/core/res/res/drawable-hdpi/tab_arrow_left_holo_light.png +++ /dev/null diff --git a/core/res/res/drawable-hdpi/tab_arrow_right_holo_dark.png b/core/res/res/drawable-hdpi/tab_arrow_right_holo_dark.png Binary files differdeleted file mode 100644 index b226038..0000000 --- a/core/res/res/drawable-hdpi/tab_arrow_right_holo_dark.png +++ /dev/null diff --git a/core/res/res/drawable-hdpi/tab_arrow_right_holo_light.png b/core/res/res/drawable-hdpi/tab_arrow_right_holo_light.png Binary files differdeleted file mode 100644 index 0e5fbe6..0000000 --- a/core/res/res/drawable-hdpi/tab_arrow_right_holo_light.png +++ /dev/null diff --git a/core/res/res/drawable-hdpi/tab_bottom_holo.9.png b/core/res/res/drawable-hdpi/tab_bottom_holo.9.png Binary files differnew file mode 100644 index 0000000..ec9fa8d --- /dev/null +++ b/core/res/res/drawable-hdpi/tab_bottom_holo.9.png diff --git a/core/res/res/drawable-hdpi/tab_divider_holo_dark.png b/core/res/res/drawable-hdpi/tab_divider_holo_dark.png Binary files differdeleted file mode 100644 index 112cb04..0000000 --- a/core/res/res/drawable-hdpi/tab_divider_holo_dark.png +++ /dev/null diff --git a/core/res/res/drawable-hdpi/tab_divider_holo_light.png b/core/res/res/drawable-hdpi/tab_divider_holo_light.png Binary files differdeleted file mode 100644 index 1bf4d38..0000000 --- a/core/res/res/drawable-hdpi/tab_divider_holo_light.png +++ /dev/null diff --git a/core/res/res/drawable-hdpi/tab_selected_focused_holo.9.png b/core/res/res/drawable-hdpi/tab_selected_focused_holo.9.png Binary files differnew file mode 100644 index 0000000..1ba35d5 --- /dev/null +++ b/core/res/res/drawable-hdpi/tab_selected_focused_holo.9.png diff --git a/core/res/res/drawable-hdpi/tab_selected_holo.9.png b/core/res/res/drawable-hdpi/tab_selected_holo.9.png Binary files differnew file mode 100644 index 0000000..ef913cc --- /dev/null +++ b/core/res/res/drawable-hdpi/tab_selected_holo.9.png diff --git a/core/res/res/drawable-hdpi/tab_selected_pressed_focused_holo.9.png b/core/res/res/drawable-hdpi/tab_selected_pressed_focused_holo.9.png Binary files differnew file mode 100644 index 0000000..d7e9688 --- /dev/null +++ b/core/res/res/drawable-hdpi/tab_selected_pressed_focused_holo.9.png diff --git a/core/res/res/drawable-hdpi/tab_selected_pressed_holo.9.png b/core/res/res/drawable-hdpi/tab_selected_pressed_holo.9.png Binary files differnew file mode 100644 index 0000000..b8b1fcf --- /dev/null +++ b/core/res/res/drawable-hdpi/tab_selected_pressed_holo.9.png diff --git a/core/res/res/drawable-hdpi/tab_selector_holo_dark.9.png b/core/res/res/drawable-hdpi/tab_selector_holo_dark.9.png Binary files differdeleted file mode 100644 index f01b9bc..0000000 --- a/core/res/res/drawable-hdpi/tab_selector_holo_dark.9.png +++ /dev/null diff --git a/core/res/res/drawable-hdpi/tab_strip_holo.9.png b/core/res/res/drawable-hdpi/tab_strip_holo.9.png Binary files differdeleted file mode 100644 index d937f6b..0000000 --- a/core/res/res/drawable-hdpi/tab_strip_holo.9.png +++ /dev/null diff --git a/core/res/res/drawable-hdpi/tab_unselected_focused_holo.9.png b/core/res/res/drawable-hdpi/tab_unselected_focused_holo.9.png Binary files differnew file mode 100644 index 0000000..256e8e7 --- /dev/null +++ b/core/res/res/drawable-hdpi/tab_unselected_focused_holo.9.png diff --git a/core/res/res/drawable-hdpi/tab_unselected_holo.9.png b/core/res/res/drawable-hdpi/tab_unselected_holo.9.png Binary files differnew file mode 100644 index 0000000..eaa306a --- /dev/null +++ b/core/res/res/drawable-hdpi/tab_unselected_holo.9.png diff --git a/core/res/res/drawable-hdpi/tab_unselected_pressed_focused_holo.9.png b/core/res/res/drawable-hdpi/tab_unselected_pressed_focused_holo.9.png Binary files differnew file mode 100644 index 0000000..d17b820 --- /dev/null +++ b/core/res/res/drawable-hdpi/tab_unselected_pressed_focused_holo.9.png diff --git a/core/res/res/drawable-hdpi/tab_unselected_pressed_holo.9.png b/core/res/res/drawable-hdpi/tab_unselected_pressed_holo.9.png Binary files differnew file mode 100644 index 0000000..a344994 --- /dev/null +++ b/core/res/res/drawable-hdpi/tab_unselected_pressed_holo.9.png diff --git a/core/res/res/drawable-mdpi/tab_arrow_left_holo_dark.png b/core/res/res/drawable-mdpi/tab_arrow_left_holo_dark.png Binary files differdeleted file mode 100644 index 4f8bafe..0000000 --- a/core/res/res/drawable-mdpi/tab_arrow_left_holo_dark.png +++ /dev/null diff --git a/core/res/res/drawable-mdpi/tab_arrow_left_holo_light.png b/core/res/res/drawable-mdpi/tab_arrow_left_holo_light.png Binary files differdeleted file mode 100644 index 8e225fc..0000000 --- a/core/res/res/drawable-mdpi/tab_arrow_left_holo_light.png +++ /dev/null diff --git a/core/res/res/drawable-mdpi/tab_arrow_right_holo_dark.png b/core/res/res/drawable-mdpi/tab_arrow_right_holo_dark.png Binary files differdeleted file mode 100644 index 0a8006d..0000000 --- a/core/res/res/drawable-mdpi/tab_arrow_right_holo_dark.png +++ /dev/null diff --git a/core/res/res/drawable-mdpi/tab_arrow_right_holo_light.png b/core/res/res/drawable-mdpi/tab_arrow_right_holo_light.png Binary files differdeleted file mode 100644 index 85aae47..0000000 --- a/core/res/res/drawable-mdpi/tab_arrow_right_holo_light.png +++ /dev/null diff --git a/core/res/res/drawable-mdpi/tab_bottom_holo.9.png b/core/res/res/drawable-mdpi/tab_bottom_holo.9.png Binary files differnew file mode 100644 index 0000000..1e40b9c --- /dev/null +++ b/core/res/res/drawable-mdpi/tab_bottom_holo.9.png diff --git a/core/res/res/drawable-mdpi/tab_divider_holo_dark.png b/core/res/res/drawable-mdpi/tab_divider_holo_dark.png Binary files differdeleted file mode 100644 index 89d7b8b..0000000 --- a/core/res/res/drawable-mdpi/tab_divider_holo_dark.png +++ /dev/null diff --git a/core/res/res/drawable-mdpi/tab_divider_holo_light.png b/core/res/res/drawable-mdpi/tab_divider_holo_light.png Binary files differdeleted file mode 100644 index 878b2b4..0000000 --- a/core/res/res/drawable-mdpi/tab_divider_holo_light.png +++ /dev/null diff --git a/core/res/res/drawable-mdpi/tab_focused_holo.9.png b/core/res/res/drawable-mdpi/tab_focused_holo.9.png Binary files differnew file mode 100644 index 0000000..187d8c5 --- /dev/null +++ b/core/res/res/drawable-mdpi/tab_focused_holo.9.png diff --git a/core/res/res/drawable-mdpi/tab_pressed_holo.9.png b/core/res/res/drawable-mdpi/tab_pressed_holo.9.png Binary files differnew file mode 100644 index 0000000..a76fbae --- /dev/null +++ b/core/res/res/drawable-mdpi/tab_pressed_holo.9.png diff --git a/core/res/res/drawable-mdpi/tab_selected_focused_holo.9.png b/core/res/res/drawable-mdpi/tab_selected_focused_holo.9.png Binary files differnew file mode 100644 index 0000000..9a33cd2 --- /dev/null +++ b/core/res/res/drawable-mdpi/tab_selected_focused_holo.9.png diff --git a/core/res/res/drawable-mdpi/tab_selected_holo.9.png b/core/res/res/drawable-mdpi/tab_selected_holo.9.png Binary files differnew file mode 100644 index 0000000..e029e57 --- /dev/null +++ b/core/res/res/drawable-mdpi/tab_selected_holo.9.png diff --git a/core/res/res/drawable-mdpi/tab_selected_pressed_focused_holo.9.png b/core/res/res/drawable-mdpi/tab_selected_pressed_focused_holo.9.png Binary files differnew file mode 100644 index 0000000..285116e --- /dev/null +++ b/core/res/res/drawable-mdpi/tab_selected_pressed_focused_holo.9.png diff --git a/core/res/res/drawable-mdpi/tab_selected_pressed_holo.9.png b/core/res/res/drawable-mdpi/tab_selected_pressed_holo.9.png Binary files differnew file mode 100644 index 0000000..dadefa7 --- /dev/null +++ b/core/res/res/drawable-mdpi/tab_selected_pressed_holo.9.png diff --git a/core/res/res/drawable-mdpi/tab_selector_holo_dark.9.png b/core/res/res/drawable-mdpi/tab_selector_holo_dark.9.png Binary files differdeleted file mode 100644 index 30d30df..0000000 --- a/core/res/res/drawable-mdpi/tab_selector_holo_dark.9.png +++ /dev/null diff --git a/core/res/res/drawable-mdpi/tab_unselected_focused_holo.9.png b/core/res/res/drawable-mdpi/tab_unselected_focused_holo.9.png Binary files differnew file mode 100644 index 0000000..032a992 --- /dev/null +++ b/core/res/res/drawable-mdpi/tab_unselected_focused_holo.9.png diff --git a/core/res/res/drawable-mdpi/tab_unselected_holo.9.png b/core/res/res/drawable-mdpi/tab_unselected_holo.9.png Binary files differnew file mode 100644 index 0000000..848f3f1 --- /dev/null +++ b/core/res/res/drawable-mdpi/tab_unselected_holo.9.png diff --git a/core/res/res/drawable-mdpi/tab_unselected_pressed_focused_holo.9.png b/core/res/res/drawable-mdpi/tab_unselected_pressed_focused_holo.9.png Binary files differnew file mode 100644 index 0000000..3845135 --- /dev/null +++ b/core/res/res/drawable-mdpi/tab_unselected_pressed_focused_holo.9.png diff --git a/core/res/res/drawable-mdpi/tab_unselected_pressed_holo.9.png b/core/res/res/drawable-mdpi/tab_unselected_pressed_holo.9.png Binary files differnew file mode 100644 index 0000000..23fd8c9 --- /dev/null +++ b/core/res/res/drawable-mdpi/tab_unselected_pressed_holo.9.png diff --git a/core/res/res/drawable/tab_bottom_right.xml b/core/res/res/drawable/tab_bottom_right.xml index f7f5c2f..450c461 100644 --- a/core/res/res/drawable/tab_bottom_right.xml +++ b/core/res/res/drawable/tab_bottom_right.xml @@ -16,6 +16,6 @@ <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/tab_press_bar_right"/> - <item android:state_focused="false" android:state_pressed="false" android:drawable="@drawable/tab_selected_bar_right"/> - <item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/tab_focus_bar_right"/> + <item android:state_focused="false" android:drawable="@drawable/tab_selected_bar_right"/> + <item android:state_focused="true" android:drawable="@drawable/tab_focus_bar_right"/> </selector> diff --git a/core/res/res/drawable/tab_indicator_holo.xml b/core/res/res/drawable/tab_indicator_holo.xml new file mode 100644 index 0000000..0d46e0c --- /dev/null +++ b/core/res/res/drawable/tab_indicator_holo.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2008 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. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <!-- Non focused states --> + <item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_unselected_holo" /> + <item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected_holo" /> + + <!-- Focused states --> + <item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_unselected_focused_holo" /> + <item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected_focused_holo" /> + + <!-- Pressed --> + <!-- Non focused states --> + <item android:state_focused="false" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/tab_unselected_pressed_holo" /> + <item android:state_focused="false" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/tab_selected_pressed_holo" /> + + <!-- Focused states --> + <item android:state_focused="true" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/tab_unselected_pressed_focused_holo" /> + <item android:state_focused="true" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/tab_selected_pressed_focused_holo" /> +</selector> diff --git a/core/res/res/layout/tab_indicator.xml b/core/res/res/layout/tab_indicator.xml index 71e4001..bc657c3 100644 --- a/core/res/res/layout/tab_indicator.xml +++ b/core/res/res/layout/tab_indicator.xml @@ -20,7 +20,6 @@ android:layout_weight="1" android:layout_marginLeft="-3dip" android:layout_marginRight="-3dip" - android:orientation="vertical" android:background="@android:drawable/tab_indicator"> <ImageView android:id="@+id/icon" diff --git a/core/res/res/layout/tab_indicator_holo.xml b/core/res/res/layout/tab_indicator_holo.xml new file mode 100644 index 0000000..d37476b --- /dev/null +++ b/core/res/res/layout/tab_indicator_holo.xml @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2008 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. +--> + +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="wrap_content" + android:layout_height="56dip" + android:layout_weight="0" + android:layout_marginLeft="0dip" + android:layout_marginRight="0dip" + android:background="@android:drawable/tab_indicator_holo"> + + <View android:id="@+id/tab_indicator_left_spacer" + android:layout_width="16dip" + android:layout_height="0dip" /> + + <ImageView android:id="@+id/icon" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerVertical="true" + android:visibility="gone" + android:layout_toRightOf="@id/tab_indicator_left_spacer" + android:paddingRight="8dip" /> + + <TextView android:id="@+id/title" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerVertical="true" + android:layout_toRightOf="@id/icon" + android:paddingLeft="0dip" + android:paddingRight="16dip" + style="?android:attr/tabWidgetStyle" /> + +</RelativeLayout> diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index d5f1610..dab627c 100755 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -2137,6 +2137,8 @@ <attr name="tabStripLeft" format="reference" /> <!-- Drawable used to draw the right part of the strip underneath the tabs. --> <attr name="tabStripRight" format="reference" /> + <!-- Layout used to organize each tab's content. --> + <attr name="tabLayout" format="reference" /> </declare-styleable> <declare-styleable name="TextAppearance"> <!-- Text color. --> diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml index c441f5a..76a3c34 100644 --- a/core/res/res/values/styles.xml +++ b/core/res/res/values/styles.xml @@ -560,6 +560,12 @@ <item name="android:textAppearance">@style/TextAppearance.Widget.TabWidget</item> <item name="ellipsize">marquee</item> <item name="singleLine">true</item> + <item name="android:tabStripLeft">@android:drawable/tab_bottom_left</item> + <item name="android:tabStripRight">@android:drawable/tab_bottom_right</item> + <item name="android:tabStripEnabled">true</item> + <item name="android:divider">@null</item> + <item name="android:gravity">fill_horizontal|center_vertical</item> + <item name="android:tabLayout">@android:layout/tab_indicator</item> </style> <style name="Widget.Gallery"> @@ -1070,7 +1076,7 @@ </style> <style name="TextAppearance.Holo.Widget.TabWidget"> - <item name="android:textSize">14sp</item> + <item name="android:textSize">18sp</item> <item name="android:textStyle">normal</item> <item name="android:textColor">@android:color/tab_indicator_text</item> </style> @@ -1421,6 +1427,13 @@ </style> <style name="Widget.Holo.TabWidget" parent="Widget.TabWidget"> + <item name="android:textAppearance">@style/TextAppearance.Holo.Widget.TabWidget</item> + <item name="android:tabStripLeft">@null</item> + <item name="android:tabStripRight">@null</item> + <item name="android:tabStripEnabled">false</item> + <item name="android:divider">@null</item> + <item name="android:gravity">left|center_vertical</item> + <item name="android:tabLayout">@android:layout/tab_indicator_holo</item> </style> <style name="Widget.Holo.WebTextView" parent="Widget.WebTextView"> @@ -1693,7 +1706,7 @@ <style name="Widget.Holo.Light.CompoundButton.Star" parent="Widget.CompoundButton.Star"> </style> - <style name="Widget.Holo.Light.TabWidget" parent="Widget.TabWidget"> + <style name="Widget.Holo.Light.TabWidget" parent="Widget.Holo.TabWidget"> </style> <style name="Widget.Holo.Light.WebTextView" parent="Widget.WebTextView"> diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java index 4f75366..92588fc 100644 --- a/services/java/com/android/server/WifiService.java +++ b/services/java/com/android/server/WifiService.java @@ -872,9 +872,19 @@ public class WifiService extends IWifiManager.Stub { mWifiStateMachine.startWpsPbc(bssid); } - public void startWpsPin(String bssid, int apPin) { + public void startWpsWithPinFromAccessPoint(String bssid, int apPin) { enforceChangePermission(); - mWifiStateMachine.startWpsPin(bssid, apPin); + mWifiStateMachine.startWpsWithPinFromAccessPoint(bssid, apPin); + } + + public int startWpsWithPinFromDevice(String bssid) { + enforceChangePermission(); + if (mChannel != null) { + return mWifiStateMachine.syncStartWpsWithPinFromDevice(mChannel, bssid); + } else { + Slog.e(TAG, "mChannel is not initialized"); + return -1; + } } private final BroadcastReceiver mReceiver = new BroadcastReceiver() { diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl index f760d27..720f6ac 100644 --- a/wifi/java/android/net/wifi/IWifiManager.aidl +++ b/wifi/java/android/net/wifi/IWifiManager.aidl @@ -108,6 +108,8 @@ interface IWifiManager void startWpsPbc(String bssid); - void startWpsPin(String bssid, int apPin); + void startWpsWithPinFromAccessPoint(String bssid, int apPin); + + int startWpsWithPinFromDevice(String bssid); } diff --git a/wifi/java/android/net/wifi/WifiConfigStore.java b/wifi/java/android/net/wifi/WifiConfigStore.java index be5fab4..04b3891 100644 --- a/wifi/java/android/net/wifi/WifiConfigStore.java +++ b/wifi/java/android/net/wifi/WifiConfigStore.java @@ -361,10 +361,11 @@ class WifiConfigStore { } /** - * Start WPS pin method configuration + * Start WPS pin method configuration with pin obtained + * from the access point */ - static boolean startWpsPin(String bssid, int apPin) { - if (WifiNative.startWpsPinCommand(bssid, apPin)) { + static boolean startWpsWithPinFromAccessPoint(String bssid, int apPin) { + if (WifiNative.startWpsWithPinFromAccessPointCommand(bssid, apPin)) { /* WPS leaves all networks disabled */ markAllNetworksDisabled(); return true; @@ -374,6 +375,21 @@ class WifiConfigStore { } /** + * Start WPS pin method configuration with pin obtained + * from the device + */ + static int startWpsWithPinFromDevice(String bssid) { + int pin = WifiNative.startWpsWithPinFromDeviceCommand(bssid); + /* WPS leaves all networks disabled */ + if (pin != -1) { + markAllNetworksDisabled(); + } else { + Log.e(TAG, "Failed to start WPS pin method configuration"); + } + return pin; + } + + /** * Start WPS push button configuration */ static boolean startWpsPbc(String bssid) { diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java index 0b3a782..84d615c 100644 --- a/wifi/java/android/net/wifi/WifiManager.java +++ b/wifi/java/android/net/wifi/WifiManager.java @@ -1050,19 +1050,36 @@ public class WifiManager { /** * Start Wi-fi Protected Setup pin method configuration + * with pin obtained from the access point * * @param bssid BSSID of the access point * @param apPin PIN issued by the access point * * @hide */ - public void startWpsPin(String bssid, int apPin) { + public void startWpsWithPinFromAccessPoint(String bssid, int apPin) { try { - mService.startWpsPin(bssid, apPin); + mService.startWpsWithPinFromAccessPoint(bssid, apPin); } catch (RemoteException e) { } } /** + * Start Wi-fi Protected Setup pin method configuration + * with pin obtained from the device + * + * @param bssid BSSID of the access point + * @return pin generated by device + * @hide + */ + public int startWpsWithPinFromDevice(String bssid) { + try { + return mService.startWpsWithPinFromDevice(bssid); + } catch (RemoteException e) { + return -1; + } + } + + /** * Allows an application to keep the Wi-Fi radio awake. * Normally the Wi-Fi radio may turn off when the user has not used the device in a while. * Acquiring a WifiLock will keep the radio on until the lock is released. Multiple diff --git a/wifi/java/android/net/wifi/WifiNative.java b/wifi/java/android/net/wifi/WifiNative.java index 1251a25..313ae0b 100644 --- a/wifi/java/android/net/wifi/WifiNative.java +++ b/wifi/java/android/net/wifi/WifiNative.java @@ -153,7 +153,9 @@ public class WifiNative { public native static boolean startWpsPbcCommand(String bssid); - public native static boolean startWpsPinCommand(String bssid, int apPin); + public native static boolean startWpsWithPinFromAccessPointCommand(String bssid, int apPin); + + public native static int startWpsWithPinFromDeviceCommand(String bssid); public native static boolean doDhcpRequest(DhcpInfo results); diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index e3deeb3..faafb7a 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -301,9 +301,10 @@ public class WifiStateMachine extends HierarchicalStateMachine { * supplicant config. */ private static final int CMD_FORGET_NETWORK = 92; - /* Start Wi-Fi protected setup */ - private static final int CMD_START_WPS = 93; - + /* Start Wi-Fi protected setup push button configuration */ + private static final int CMD_START_WPS_PBC = 93; + /* Start Wi-Fi protected setup pin method configuration */ + private static final int CMD_START_WPS_PIN = 94; /** * Interval in milliseconds between polling for connection * status items that are not sent via asynchronous events. @@ -787,11 +788,18 @@ public class WifiStateMachine extends HierarchicalStateMachine { } public void startWpsPbc(String bssid) { - sendMessage(obtainMessage(CMD_START_WPS, bssid)); + sendMessage(obtainMessage(CMD_START_WPS_PBC, bssid)); + } + + public void startWpsWithPinFromAccessPoint(String bssid, int apPin) { + sendMessage(obtainMessage(CMD_START_WPS_PIN, apPin, 0, bssid)); } - public void startWpsPin(String bssid, int apPin) { - sendMessage(obtainMessage(CMD_START_WPS, apPin, 0, bssid)); + public int syncStartWpsWithPinFromDevice(AsyncChannel channel, String bssid) { + Message resultMsg = channel.sendMessageSynchronously(CMD_START_WPS_PIN, bssid); + int result = resultMsg.arg1; + resultMsg.recycle(); + return result; } public void enableRssiPolling(boolean enabled) { @@ -1654,7 +1662,8 @@ public class WifiStateMachine extends HierarchicalStateMachine { case CMD_CONNECT_NETWORK: case CMD_SAVE_NETWORK: case CMD_FORGET_NETWORK: - case CMD_START_WPS: + case CMD_START_WPS_PBC: + case CMD_START_WPS_PIN: break; default: Log.e(TAG, "Error! unhandled message" + message); @@ -2395,17 +2404,11 @@ public class WifiStateMachine extends HierarchicalStateMachine { /* Expect a disconnection from the old connection */ transitionTo(mDisconnectingState); break; - case CMD_START_WPS: + case CMD_START_WPS_PBC: String bssid = (String) message.obj; - int apPin = message.arg1; - boolean success; - if (apPin != 0) { - /* WPS pin method configuration */ - success = WifiConfigStore.startWpsPin(bssid, apPin); - } else { - /* WPS push button configuration */ - success = WifiConfigStore.startWpsPbc(bssid); - } + /* WPS push button configuration */ + boolean success = WifiConfigStore.startWpsPbc(bssid); + /* During WPS setup, all other networks are disabled. After * a successful connect a new config is created in the supplicant. * @@ -2422,6 +2425,24 @@ public class WifiStateMachine extends HierarchicalStateMachine { transitionTo(mDisconnectingState); } break; + case CMD_START_WPS_PIN: + bssid = (String) message.obj; + int apPin = message.arg1; + int pin; + if (apPin != 0) { + /* WPS pin from access point */ + success = WifiConfigStore.startWpsWithPinFromAccessPoint(bssid, apPin); + } else { + pin = WifiConfigStore.startWpsWithPinFromDevice(bssid); + success = (pin != -1); + mReplyChannel.replyToMessage(message, CMD_START_WPS_PIN, pin); + } + if (success) { + mWpsStarted = true; + /* Expect a disconnection from the old connection */ + transitionTo(mDisconnectingState); + } + break; case SCAN_RESULTS_EVENT: /* Set the scan setting back to "connect" mode */ WifiNative.setScanResultHandlingCommand(CONNECT_MODE); |
