diff options
27 files changed, 468 insertions, 273 deletions
diff --git a/core/java/android/app/Fragment.java b/core/java/android/app/Fragment.java index 557c8710c26b..cb97c4671bfe 100644 --- a/core/java/android/app/Fragment.java +++ b/core/java/android/app/Fragment.java @@ -367,6 +367,9 @@ public class Fragment implements ComponentCallbacks, OnCreateContextMenuListener // Target fragment. Fragment mTarget; + // For use when retaining a fragment: this is the index of the last mTarget. + int mTargetIndex = -1; + // Target request code. int mTargetRequestCode; diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java index f05e2b3b2c57..285f1c156086 100644 --- a/core/java/android/app/FragmentManager.java +++ b/core/java/android/app/FragmentManager.java @@ -695,6 +695,10 @@ final class FragmentManagerImpl extends FragmentManager { if (!f.mAdded && newState > Fragment.CREATED) { newState = Fragment.CREATED; } + if (f.mRemoving && newState > f.mState) { + // While removing a fragment, we can't change it to a higher state. + newState = f.mState; + } if (f.mState < newState) { // For fragments that are created from a layout, when restoring from @@ -915,6 +919,7 @@ final class FragmentManagerImpl extends FragmentManager { // the fragment now should move to once the animation // is done. f.mStateAfterAnimating = newState; + newState = Fragment.CREATED; } else { if (DEBUG) Log.v(TAG, "movefrom CREATED: " + f); if (!f.mRetaining) { @@ -932,9 +937,13 @@ final class FragmentManagerImpl extends FragmentManager { throw new SuperNotCalledException("Fragment " + f + " did not call through to super.onDetach()"); } - f.mImmediateActivity = null; - f.mActivity = null; - f.mFragmentManager = null; + if (!f.mRetaining) { + makeInactive(f); + } else { + f.mImmediateActivity = null; + f.mActivity = null; + f.mFragmentManager = null; + } } } } @@ -1040,9 +1049,6 @@ final class FragmentManagerImpl extends FragmentManager { fragment.mRemoving = true; moveToState(fragment, inactive ? Fragment.INITIALIZING : Fragment.CREATED, transition, transitionStyle); - if (inactive) { - makeInactive(fragment); - } } } @@ -1397,6 +1403,7 @@ final class FragmentManagerImpl extends FragmentManager { } fragments.add(f); f.mRetaining = true; + f.mTargetIndex = f.mTarget != null ? f.mTarget.mIndex : -1; } } } @@ -1561,6 +1568,7 @@ final class FragmentManagerImpl extends FragmentManager { f.mBackStackNesting = 0; f.mInLayout = false; f.mAdded = false; + f.mTarget = null; if (fs.mSavedFragmentState != null) { fs.mSavedFragmentState.setClassLoader(mActivity.getClassLoader()); f.mSavedViewState = fs.mSavedFragmentState.getSparseParcelableArray( @@ -1600,12 +1608,12 @@ final class FragmentManagerImpl extends FragmentManager { if (nonConfig != null) { for (int i=0; i<nonConfig.size(); i++) { Fragment f = nonConfig.get(i); - if (f.mTarget != null) { - if (f.mTarget.mIndex < mActive.size()) { - f.mTarget = mActive.get(f.mTarget.mIndex); + if (f.mTargetIndex >= 0) { + if (f.mTargetIndex < mActive.size()) { + f.mTarget = mActive.get(f.mTargetIndex); } else { Log.w(TAG, "Re-attaching retained fragment " + f - + " target no longer exists: " + f.mTarget); + + " target no longer exists: " + f.mTargetIndex); f.mTarget = null; } } diff --git a/core/java/android/bluetooth/BluetoothA2dp.java b/core/java/android/bluetooth/BluetoothA2dp.java index 9246a1035087..61d3707f8c64 100644 --- a/core/java/android/bluetooth/BluetoothA2dp.java +++ b/core/java/android/bluetooth/BluetoothA2dp.java @@ -130,7 +130,25 @@ public final class BluetoothA2dp implements BluetoothProfile { } /** - * {@inheritDoc} + * Initiate connection to a profile of the remote bluetooth device. + * + * <p> Currently, the system supports only 1 connection to the + * A2DP profile. The API will automatically disconnect connected + * devices before connecting. + * + * <p> This API returns false in scenarios like the profile on the + * device is already connected or Bluetooth is not turned on. + * When this API returns true, it is guaranteed that + * connection state intent for the profile will be broadcasted with + * the state. Users can get the connection state of the profile + * from this intent. + * + * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} + * permission. + * + * @param device Remote Bluetooth Device + * @return false on immediate error, + * true otherwise * @hide */ public boolean connect(BluetoothDevice device) { @@ -149,7 +167,29 @@ public final class BluetoothA2dp implements BluetoothProfile { } /** - * {@inheritDoc} + * Initiate disconnection from a profile + * + * <p> This API will return false in scenarios like the profile on the + * Bluetooth device is not in connected state etc. When this API returns, + * true, it is guaranteed that the connection state change + * intent will be broadcasted with the state. Users can get the + * disconnection state of the profile from this intent. + * + * <p> If the disconnection is initiated by a remote device, the state + * will transition from {@link #STATE_CONNECTED} to + * {@link #STATE_DISCONNECTED}. If the disconnect is initiated by the + * host (local) device the state will transition from + * {@link #STATE_CONNECTED} to state {@link #STATE_DISCONNECTING} to + * state {@link #STATE_DISCONNECTED}. The transition to + * {@link #STATE_DISCONNECTING} can be used to distinguish between the + * two scenarios. + * + * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} + * permission. + * + * @param device Remote Bluetooth Device + * @return false on immediate error, + * true otherwise * @hide */ public boolean disconnect(BluetoothDevice device) { @@ -220,7 +260,18 @@ public final class BluetoothA2dp implements BluetoothProfile { } /** - * {@inheritDoc} + * Set priority of the profile + * + * <p> The device should already be paired. + * Priority can be one of {@link #PRIORITY_ON} or + * {@link #PRIORITY_OFF}, + * + * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} + * permission. + * + * @param device Paired bluetooth device + * @param priority + * @return true if priority is set, false on error * @hide */ public boolean setPriority(BluetoothDevice device, int priority) { @@ -243,7 +294,16 @@ public final class BluetoothA2dp implements BluetoothProfile { } /** - * {@inheritDoc} + * Get the priority of the profile. + * + * <p> The priority can be any of: + * {@link #PRIORITY_AUTO_CONNECT}, {@link #PRIORITY_OFF}, + * {@link #PRIORITY_ON}, {@link #PRIORITY_UNDEFINED} + * + * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission. + * + * @param device Bluetooth device + * @return priority of the device * @hide */ public int getPriority(BluetoothDevice device) { diff --git a/core/java/android/bluetooth/BluetoothHeadset.java b/core/java/android/bluetooth/BluetoothHeadset.java index 8a9bef05f447..23724f245cab 100644 --- a/core/java/android/bluetooth/BluetoothHeadset.java +++ b/core/java/android/bluetooth/BluetoothHeadset.java @@ -248,7 +248,25 @@ public final class BluetoothHeadset implements BluetoothProfile { } /** - * {@inheritDoc} + * Initiate connection to a profile of the remote bluetooth device. + * + * <p> Currently, the system supports only 1 connection to the + * headset/handsfree profile. The API will automatically disconnect connected + * devices before connecting. + * + * <p> This API returns false in scenarios like the profile on the + * device is already connected or Bluetooth is not turned on. + * When this API returns true, it is guaranteed that + * connection state intent for the profile will be broadcasted with + * the state. Users can get the connection state of the profile + * from this intent. + * + * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} + * permission. + * + * @param device Remote Bluetooth Device + * @return false on immediate error, + * true otherwise * @hide */ public boolean connect(BluetoothDevice device) { @@ -267,7 +285,29 @@ public final class BluetoothHeadset implements BluetoothProfile { } /** - * {@inheritDoc} + * Initiate disconnection from a profile + * + * <p> This API will return false in scenarios like the profile on the + * Bluetooth device is not in connected state etc. When this API returns, + * true, it is guaranteed that the connection state change + * intent will be broadcasted with the state. Users can get the + * disconnection state of the profile from this intent. + * + * <p> If the disconnection is initiated by a remote device, the state + * will transition from {@link #STATE_CONNECTED} to + * {@link #STATE_DISCONNECTED}. If the disconnect is initiated by the + * host (local) device the state will transition from + * {@link #STATE_CONNECTED} to state {@link #STATE_DISCONNECTING} to + * state {@link #STATE_DISCONNECTED}. The transition to + * {@link #STATE_DISCONNECTING} can be used to distinguish between the + * two scenarios. + * + * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} + * permission. + * + * @param device Remote Bluetooth Device + * @return false on immediate error, + * true otherwise * @hide */ public boolean disconnect(BluetoothDevice device) { @@ -338,7 +378,18 @@ public final class BluetoothHeadset implements BluetoothProfile { } /** - * {@inheritDoc} + * Set priority of the profile + * + * <p> The device should already be paired. + * Priority can be one of {@link #PRIORITY_ON} or + * {@link #PRIORITY_OFF}, + * + * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} + * permission. + * + * @param device Paired bluetooth device + * @param priority + * @return true if priority is set, false on error * @hide */ public boolean setPriority(BluetoothDevice device, int priority) { @@ -361,7 +412,16 @@ public final class BluetoothHeadset implements BluetoothProfile { } /** - * {@inheritDoc} + * Get the priority of the profile. + * + * <p> The priority can be any of: + * {@link #PRIORITY_AUTO_CONNECT}, {@link #PRIORITY_OFF}, + * {@link #PRIORITY_ON}, {@link #PRIORITY_UNDEFINED} + * + * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission. + * + * @param device Bluetooth device + * @return priority of the device * @hide */ public int getPriority(BluetoothDevice device) { diff --git a/core/java/android/bluetooth/BluetoothInputDevice.java b/core/java/android/bluetooth/BluetoothInputDevice.java index df212a82d4e6..282b70a42c81 100644 --- a/core/java/android/bluetooth/BluetoothInputDevice.java +++ b/core/java/android/bluetooth/BluetoothInputDevice.java @@ -119,7 +119,23 @@ public final class BluetoothInputDevice implements BluetoothProfile { } /** - * {@inheritDoc} + * Initiate connection to a profile of the remote bluetooth device. + * + * <p> The system supports connection to multiple input devices. + * + * <p> This API returns false in scenarios like the profile on the + * device is already connected or Bluetooth is not turned on. + * When this API returns true, it is guaranteed that + * connection state intent for the profile will be broadcasted with + * the state. Users can get the connection state of the profile + * from this intent. + * + * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} + * permission. + * + * @param device Remote Bluetooth Device + * @return false on immediate error, + * true otherwise * @hide */ public boolean connect(BluetoothDevice device) { @@ -138,7 +154,29 @@ public final class BluetoothInputDevice implements BluetoothProfile { } /** - * {@inheritDoc} + * Initiate disconnection from a profile + * + * <p> This API will return false in scenarios like the profile on the + * Bluetooth device is not in connected state etc. When this API returns, + * true, it is guaranteed that the connection state change + * intent will be broadcasted with the state. Users can get the + * disconnection state of the profile from this intent. + * + * <p> If the disconnection is initiated by a remote device, the state + * will transition from {@link #STATE_CONNECTED} to + * {@link #STATE_DISCONNECTED}. If the disconnect is initiated by the + * host (local) device the state will transition from + * {@link #STATE_CONNECTED} to state {@link #STATE_DISCONNECTING} to + * state {@link #STATE_DISCONNECTED}. The transition to + * {@link #STATE_DISCONNECTING} can be used to distinguish between the + * two scenarios. + * + * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} + * permission. + * + * @param device Remote Bluetooth Device + * @return false on immediate error, + * true otherwise * @hide */ public boolean disconnect(BluetoothDevice device) { @@ -209,7 +247,18 @@ public final class BluetoothInputDevice implements BluetoothProfile { } /** - * {@inheritDoc} + * Set priority of the profile + * + * <p> The device should already be paired. + * Priority can be one of {@link #PRIORITY_ON} or + * {@link #PRIORITY_OFF}, + * + * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} + * permission. + * + * @param device Paired bluetooth device + * @param priority + * @return true if priority is set, false on error * @hide */ public boolean setPriority(BluetoothDevice device, int priority) { @@ -232,7 +281,16 @@ public final class BluetoothInputDevice implements BluetoothProfile { } /** - * {@inheritDoc} + * Get the priority of the profile. + * + * <p> The priority can be any of: + * {@link #PRIORITY_AUTO_CONNECT}, {@link #PRIORITY_OFF}, + * {@link #PRIORITY_ON}, {@link #PRIORITY_UNDEFINED} + * + * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission. + * + * @param device Bluetooth device + * @return priority of the device * @hide */ public int getPriority(BluetoothDevice device) { diff --git a/core/java/android/bluetooth/BluetoothPan.java b/core/java/android/bluetooth/BluetoothPan.java index 9ffed26f4acb..7490f9ee86b4 100644 --- a/core/java/android/bluetooth/BluetoothPan.java +++ b/core/java/android/bluetooth/BluetoothPan.java @@ -140,7 +140,21 @@ public final class BluetoothPan implements BluetoothProfile { } /** - * {@inheritDoc} + * Initiate connection to a profile of the remote bluetooth device. + * + * <p> This API returns false in scenarios like the profile on the + * device is already connected or Bluetooth is not turned on. + * When this API returns true, it is guaranteed that + * connection state intent for the profile will be broadcasted with + * the state. Users can get the connection state of the profile + * from this intent. + * + * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} + * permission. + * + * @param device Remote Bluetooth Device + * @return false on immediate error, + * true otherwise * @hide */ public boolean connect(BluetoothDevice device) { @@ -159,7 +173,29 @@ public final class BluetoothPan implements BluetoothProfile { } /** - * {@inheritDoc} + * Initiate disconnection from a profile + * + * <p> This API will return false in scenarios like the profile on the + * Bluetooth device is not in connected state etc. When this API returns, + * true, it is guaranteed that the connection state change + * intent will be broadcasted with the state. Users can get the + * disconnection state of the profile from this intent. + * + * <p> If the disconnection is initiated by a remote device, the state + * will transition from {@link #STATE_CONNECTED} to + * {@link #STATE_DISCONNECTED}. If the disconnect is initiated by the + * host (local) device the state will transition from + * {@link #STATE_CONNECTED} to state {@link #STATE_DISCONNECTING} to + * state {@link #STATE_DISCONNECTED}. The transition to + * {@link #STATE_DISCONNECTING} can be used to distinguish between the + * two scenarios. + * + * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} + * permission. + * + * @param device Remote Bluetooth Device + * @return false on immediate error, + * true otherwise * @hide */ public boolean disconnect(BluetoothDevice device) { @@ -229,27 +265,6 @@ public final class BluetoothPan implements BluetoothProfile { return BluetoothProfile.STATE_DISCONNECTED; } - /** - * {@inheritDoc} - * @hide - */ - public boolean setPriority(BluetoothDevice device, int priority) { - // Priorities are not supported for PAN devices - since we don't - // auto connect. - return false; - } - - /** - * {@inheritDoc} - * @hide - */ - public int getPriority(BluetoothDevice device) { - if (DBG) log("getPriority(" + device + ")"); - // Priorities are not supported for PAN devices - since we don't - // auto connect. - return BluetoothProfile.PRIORITY_ON; - } - public void setBluetoothTethering(boolean value) { if (DBG) log("setBluetoothTethering(" + value + ")"); try { diff --git a/core/java/android/bluetooth/BluetoothProfile.java b/core/java/android/bluetooth/BluetoothProfile.java index 1ad66f71b938..22555f02d4c5 100644 --- a/core/java/android/bluetooth/BluetoothProfile.java +++ b/core/java/android/bluetooth/BluetoothProfile.java @@ -104,58 +104,6 @@ public interface BluetoothProfile { public static final int PRIORITY_UNDEFINED = -1; /** - * Initiate connection to a profile of the remote bluetooth device. - * - * <p> Currently, the system supports only 1 connection to the - * A2DP and Headset/Handsfree profile. The API will automatically - * disconnect connected devices before connecting. - * - * <p> This API returns false in scenarios like the profile on the - * device is already connected or Bluetooth is not turned on. - * When this API returns true, it is guaranteed that - * connection state intent for the profile will be broadcasted with - * the state. Users can get the connection state of the profile - * from this intent. - * - * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} - * permission. - * - * @param device Remote Bluetooth Device - * @return false on immediate error, - * true otherwise - * @hide - */ - public boolean connect(BluetoothDevice device); - - /** - * Initiate disconnection from a profile - * - * <p> This API will return false in scenarios like the profile on the - * Bluetooth device is not in connected state etc. When this API returns, - * true, it is guaranteed that the connection state change - * intent will be broadcasted with the state. Users can get the - * disconnection state of the profile from this intent. - * - * <p> If the disconnection is initiated by a remote device, the state - * will transition from {@link #STATE_CONNECTED} to - * {@link #STATE_DISCONNECTED}. If the disconnect is initiated by the - * host (local) device the state will transition from - * {@link #STATE_CONNECTED} to state {@link #STATE_DISCONNECTING} to - * state {@link #STATE_DISCONNECTED}. The transition to - * {@link #STATE_DISCONNECTING} can be used to distinguish between the - * two scenarios. - * - * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} - * permission. - * - * @param device Remote Bluetooth Device - * @return false on immediate error, - * true otherwise - * @hide - */ - public boolean disconnect(BluetoothDevice device); - - /** * Get connected devices for this specific profile. * * <p> Return the set of devices which are in state {@link #STATE_CONNECTED} @@ -195,38 +143,6 @@ public interface BluetoothProfile { public int getConnectionState(BluetoothDevice device); /** - * Set priority of the profile - * - * <p> The device should already be paired. - * Priority can be one of {@link #PRIORITY_ON} or - * {@link #PRIORITY_OFF}, - * - * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} - * permission. - * - * @param device Paired bluetooth device - * @param priority - * @return true if priority is set, false on error - * @hide - */ - public boolean setPriority(BluetoothDevice device, int priority); - - /** - * Get the priority of the profile. - * - * <p> The priority can be any of: - * {@link #PRIORITY_AUTO_CONNECT}, {@link #PRIORITY_OFF}, - * {@link #PRIORITY_ON}, {@link #PRIORITY_UNDEFINED} - * - * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission. - * - * @param device Bluetooth device - * @return priority of the device - * @hide - */ - public int getPriority(BluetoothDevice device); - - /** * An interface for notifying BluetoothProfile IPC clients when they have * been connected or disconnected to the service. */ diff --git a/core/java/android/preference/PreferenceFragment.java b/core/java/android/preference/PreferenceFragment.java index 9d46b7a139dc..488919c7c6b3 100644 --- a/core/java/android/preference/PreferenceFragment.java +++ b/core/java/android/preference/PreferenceFragment.java @@ -146,7 +146,6 @@ public abstract class PreferenceFragment extends Fragment implements super.onCreate(savedInstanceState); mPreferenceManager = new PreferenceManager(getActivity(), FIRST_REQUEST_CODE); mPreferenceManager.setFragment(this); - mPreferenceManager.setOnPreferenceTreeClickListener(this); } @Override @@ -179,9 +178,16 @@ public abstract class PreferenceFragment extends Fragment implements } @Override + public void onStart() { + super.onStart(); + mPreferenceManager.setOnPreferenceTreeClickListener(this); + } + + @Override public void onStop() { super.onStop(); mPreferenceManager.dispatchActivityStop(); + mPreferenceManager.setOnPreferenceTreeClickListener(null); } @Override @@ -196,7 +202,6 @@ public abstract class PreferenceFragment extends Fragment implements public void onDestroy() { super.onDestroy(); mPreferenceManager.dispatchActivityDestroy(); - mPreferenceManager.setOnPreferenceTreeClickListener(null); } @Override diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java index 60bee9ab2e1a..62792f469b78 100755 --- a/core/java/android/server/BluetoothService.java +++ b/core/java/android/server/BluetoothService.java @@ -1737,7 +1737,6 @@ public class BluetoothService extends IBluetooth.Stub { pw.println("Number of connected devices:" + deviceList.size()); BluetoothDevice device = deviceList.get(0); pw.println("getConnectedDevices[0] = " + device); - pw.println("Priority of Connected device = " + mPan.getPriority(device)); switch (mPan.getConnectionState(device)) { case BluetoothInputDevice.STATE_CONNECTING: diff --git a/core/java/com/android/internal/statusbar/IStatusBar.aidl b/core/java/com/android/internal/statusbar/IStatusBar.aidl index 7d214896f2b1..2ff04137a1fe 100644 --- a/core/java/com/android/internal/statusbar/IStatusBar.aidl +++ b/core/java/com/android/internal/statusbar/IStatusBar.aidl @@ -31,7 +31,7 @@ oneway interface IStatusBar void animateExpand(); void animateCollapse(); void setLightsOn(boolean on); - void setMenuKeyVisible(boolean visible); + void topAppWindowChanged(boolean menuVisible); void setImeWindowStatus(in IBinder token, int vis, int backDisposition); void setHardKeyboardStatus(boolean available, boolean enabled); void userActivity(); diff --git a/core/java/com/android/internal/statusbar/IStatusBarService.aidl b/core/java/com/android/internal/statusbar/IStatusBarService.aidl index bfc717be3315..3f2b1efab135 100644 --- a/core/java/com/android/internal/statusbar/IStatusBarService.aidl +++ b/core/java/com/android/internal/statusbar/IStatusBarService.aidl @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + package com.android.internal.statusbar; import com.android.internal.statusbar.IStatusBar; @@ -30,7 +30,7 @@ interface IStatusBarService void setIcon(String slot, String iconPackage, int iconId, int iconLevel); void setIconVisibility(String slot, boolean visible); void removeIcon(String slot); - void setMenuKeyVisible(boolean visible); + void topAppWindowChanged(boolean menuVisible); void setImeWindowStatus(in IBinder token, int vis, int backDisposition); // ---- Methods below are for use by the status bar policy services ---- diff --git a/core/tests/bluetoothtests/src/android/bluetooth/BluetoothTestUtils.java b/core/tests/bluetoothtests/src/android/bluetooth/BluetoothTestUtils.java index 047481e56784..42e5cd17f2a7 100644 --- a/core/tests/bluetoothtests/src/android/bluetooth/BluetoothTestUtils.java +++ b/core/tests/bluetoothtests/src/android/bluetooth/BluetoothTestUtils.java @@ -936,7 +936,13 @@ public class BluetoothTestUtils extends Assert { case BluetoothProfile.STATE_DISCONNECTED: case BluetoothProfile.STATE_DISCONNECTING: start = System.currentTimeMillis(); - assertTrue(proxy.connect(device)); + if (profile == BluetoothProfile.A2DP) { + assertTrue(((BluetoothA2dp)proxy).connect(device)); + } else if (profile == BluetoothProfile.HEADSET) { + assertTrue(((BluetoothHeadset)proxy).connect(device)); + } else if (profile == BluetoothProfile.INPUT_DEVICE) { + assertTrue(((BluetoothInputDevice)proxy).connect(device)); + } break; default: removeReceiver(receiver); @@ -1005,7 +1011,13 @@ public class BluetoothTestUtils extends Assert { case BluetoothProfile.STATE_CONNECTED: case BluetoothProfile.STATE_CONNECTING: start = System.currentTimeMillis(); - assertTrue(proxy.disconnect(device)); + if (profile == BluetoothProfile.A2DP) { + assertTrue(((BluetoothA2dp)proxy).disconnect(device)); + } else if (profile == BluetoothProfile.HEADSET) { + assertTrue(((BluetoothHeadset)proxy).disconnect(device)); + } else if (profile == BluetoothProfile.INPUT_DEVICE) { + assertTrue(((BluetoothInputDevice)proxy).disconnect(device)); + } break; case BluetoothProfile.STATE_DISCONNECTED: removeReceiver(receiver); diff --git a/docs/html/guide/topics/usb/adk.jd b/docs/html/guide/topics/usb/adk.jd index 6f23a17460b5..e4e12157468b 100644 --- a/docs/html/guide/topics/usb/adk.jd +++ b/docs/html/guide/topics/usb/adk.jd @@ -24,8 +24,7 @@ page.title=Android Open Accessory Development Kit </li> <li> - <a href="#how">How an Accessory Communicates with an Android-powered Device in Accessory - Mode</a> + <a href="#accessory-protocol">Implementing the Android Accessory Protocol</a> <ol> <li><a href="#wait">Wait for and detect connected devices</a></li> @@ -40,8 +39,7 @@ page.title=Android Open Accessory Development Kit </li> <li> - <a href="#firmware">How the ADK board communicates with an Android-powered Device in - Accessory Mode</a> + <a href="#firmware">How the ADK board implements the Android Accessory Protocol</a> <ol> <li><a href="#wait-adk">Wait for and detect connected devices</a></li> @@ -55,23 +53,19 @@ page.title=Android Open Accessory Development Kit </ol> </li> </ol> - + + + <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://shop.moderndevice.com/products/freeduino-usb-host-board"> - Modern Device</a></li> - - <li><a href="http://www.seeedstudio.com/depot/seeeduino-adk-main-board-p-846.html"> - Seeed Studio</a></li> - <li><a href= "http://www.rt-net.jp/shop/index.php?main_page=product_info&cPath=3_4&products_id=1"> RT Corp</a></li> @@ -83,6 +77,8 @@ page.title=Android Open Accessory Development Kit <li><a href="https://store.diydrones.com/ProductDetails.asp?ProductCode=BR-PhoneDrone"> DIY Drones</a></li> + <li><a href="http://shop.moderndevice.com/products/freeduino-usb-host-board"> + Modern Device</a></li> </ol> </div> </div> @@ -91,7 +87,7 @@ page.title=Android Open Accessory Development Kit support, which allows external USB hardware (an Android USB accessory) to interact with an Android-powered device in a special "accessory" mode. When an Android-powered powered device is in accessory mode, the connected accessory acts as the USB host (powers the bus and enumerates - devices) and the Android-powered device acts as the device. Android USB accessories are + devices) and the Android-powered device acts as the USB device. Android USB accessories are specifically designed to attach to Android-powered devices and adhere to a simple protocol (Android accessory protocol) that allows them to detect Android-powered devices that support accessory mode. Accessories must also provide 500mA at 5V for charging power. Many previously @@ -110,25 +106,15 @@ page.title=Android Open Accessory Development Kit development boards:</p> <ul> - <li><a href="http://shop.moderndevice.com/products/freeduino-usb-host-board">Modern - Device</a> provides an Arduino-compatible board that supports the ADK firmware.</li> - - <li><a href="http://www.seeedstudio.com/depot/seeeduino-adk-main-board-p-846.html"> - Seeed Studio</a> provides an Arduino-compatible board that supports the ADK firmware.</li> - <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> -<<<<<<< HEAD -======= - ->>>>>>> c38ed22... doc change: add link to seeedstudio board + <li><a href="http://shop.moderndevice.com/products/freeduino-usb-host-board">Modern + Device</a> provides an Arduino-compatible board that supports the ADK firmware.</li> </ul> <p>We expect more hardware distributers to create a variety of kits, so please stay tuned for @@ -139,7 +125,7 @@ page.title=Android Open Accessory Development Kit 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 firmware code are contained in the <a href=ctive + 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> @@ -397,14 +383,11 @@ page.title=Android Open Accessory Development Kit accessories communicate with Android-powered devices describe much of what you should be doing in your own accessory.</p> - <h2 id="how">How an Accessory Communicates with an Android-powered Device in Accessory Mode</h2> - - <p>When you connect an accessory to an Android-powered device, the accessory's firmware must - carry out some standard steps to set up communication with the Android-powered device. If you are - building an accessory along with an application, this section goes over some general steps that - your firmware should carry out.</p> + <h2 id="accessory-protocol">Implementing the Android Accessory Protocol</h2> - <p>In general, an accessory should carry out the following steps:</p> + <p>An Android USB accessory must adhere to Android Accessory Protocol, which defines how + an accessory detects and sets up communication with an Android-powered device. In general, an + accessory should carry out the following steps:</p> <ol> <li>Wait for and detect connected devices</li> @@ -416,6 +399,8 @@ page.title=Android Open Accessory Development Kit <li>Establish communication with the device if it supports the Android accessory protocol</li> </ol> + <p>The following sections go into depth about how to implement these steps.</p> + <h3 id="wait">Wait for and detect connected devices</h3> <p>Your accessory should have logic to continuously check @@ -493,12 +478,12 @@ data zero terminated UTF8 string sent from accessory to device <p>The following string IDs are supported, with a maximum size of 256 bytes for each string (must be zero terminated with \0).</p> <pre> -manufacturer name: 1 -model name: 2 -description: 3 -version: 4 -URI: 5 -serial number: 6 +manufacturer name: 0 +model name: 1 +description: 2 +version: 3 +URI: 4 +serial number: 5 </pre> </li> @@ -537,12 +522,11 @@ data: none device's configuration to a value of 1 with a SET_CONFIGURATION (0x09) device request, then communicate using the endpoints.</p> - <h2 id="firmware">How the ADK board communicates with an Android-powered Device in Accessory - Mode</h2> + <h2 id="firmware">How the ADK board implements the Android Accessory protocol</h2> <p>If you have access to the ADK board and shield, the following sections describe the firmware code that you installed onto the ADK board. The firmware demonstrates a practical example of how - to communicate with an Android-powered device. Even if you do not have the ADK board and shield, + to implement the Android Accessory protocol. Even if you do not have the ADK board and shield, reading through how the hardware detects and interacts with devices in accessory mode is still useful if you want to port the code over for your own accessories.</p> @@ -557,8 +541,7 @@ data: none sections.</p> <p>The following sections describe the firmware code in the context of the algorithm described in - <a href="#how">How an Accessory Communicates with an Android-powered Device in Accessory - Mode</a>.</p> + <a href="#accessory-protocol">Implementing the Android Accessory Protocol</a>.</p> <h3 id="wait-adk">Wait for and detect connected devices</h3> @@ -576,13 +559,13 @@ AndroidAccessory acc("Google, Inc.", "1.0", "http://www.android.com", "0000000012345678"); - + ... void loop() { ... - if (acc.isConnected()) { - //communicate with Android application + if (acc.isConnected()) { + //communicate with Android application } else{ //set the accessory to its default state @@ -745,7 +728,7 @@ bool AndroidAccessory::findEndpoints(byte addr, EP_RECORD *inEp, EP_RECORD *outE Serial.print("Can't get config descriptor\n"); return false; } - + ... </pre> @@ -876,13 +859,13 @@ bool AndroidAccessory::configureAndroid(void) changes the state of the accessory, such as lighting up or changing the color of the LED lights.</p> <pre> -int AndroidAccessory::read(void *buff, int len, unsigned int nakLimit) { - return usb.newInTransfer(1, in, len, (char *)buff, nakLimit); } - -int AndroidAccessory::write(void *buff, int len) { - usb.outTransfer(1, out, len, (char *)buff); +int AndroidAccessory::read(void *buff, int len, unsigned int nakLimit) { + return usb.newInTransfer(1, in, len, (char *)buff, nakLimit); } + +int AndroidAccessory::write(void *buff, int len) { + usb.outTransfer(1, out, len, (char *)buff); return len; } - + </pre> <p>See the <code>firmware/demokit/demokit.pde</code> file for information about how the ADK board diff --git a/docs/html/sdk/ndk/index.jd b/docs/html/sdk/ndk/index.jd index bc9ba4be6259..e980ca5261d2 100644 --- a/docs/html/sdk/ndk/index.jd +++ b/docs/html/sdk/ndk/index.jd @@ -1,16 +1,16 @@ ndk=true -ndk.win_download=android-ndk-r5b-windows.zip -ndk.win_bytes=61299831 -ndk.win_checksum=87745ada305ab639399161ab4faf684c +ndk.win_download=android-ndk-r5c-windows.zip +ndk.win_bytes=61627716 +ndk.win_checksum=2c7423842fa0f46871eab118495d4b45 -ndk.mac_download=android-ndk-r5b-darwin-x86.tar.bz2 -ndk.mac_bytes=50210863 -ndk.mac_checksum=019a14622a377b3727ec789af6707037 +ndk.mac_download=android-ndk-r5c-darwin-x86.tar.bz2 +ndk.mac_bytes=50714712 +ndk.mac_checksum=183bfbbd85cf8e4c0bd7531e8803e75d -ndk.linux_download=android-ndk-r5b-linux-x86.tar.bz2 -ndk.linux_bytes=44138539 -ndk.linux_checksum=4c0045ddc2bfd657be9d5177d0e0b7e7 +ndk.linux_download=android-ndk-r5c-linux-x86.tar.bz2 +ndk.linux_bytes=44539890 +ndk.linux_checksum=7659dfdc97026ed1d913e224d0531f61 page.title=Android NDK @jd:body @@ -52,14 +52,97 @@ padding: .25em 1em; text-decoration:underline; } .toggleable.closed .toggleme { - display:none; -} + display:none;} #jd-content .toggle-img { margin:0; } </style> + <div class="toggleable open"> + <a href="#" onclick="return toggleDiv(this)"><img src= + "{@docRoot}assets/images/triangle-opened.png" class="toggle-img" height="9px" width="9px"> + Android NDK, Revision 5c</a> <em>(June 2011)</em> + + <div class="toggleme"> + <p>This release of the NDK does not include any new features compared to r5b. The r5c release + addresses the following problems in the r5b release:</p> + <dl> + <dt>Important bug fixes:</dt> + <dd> + <ul> + <li><code>ndk-build</code>: Fixed a rare bug that appeared when trying to perform parallel + builds of debuggable projects.</li> + + <li>Fixed a typo that prevented <code>LOCAL_WHOLE_STATIC_LIBRARIES</code> to work + correctly with the new toolchain and added documentation for this in + <code>docs/ANDROID-MK.html</code>.</li> + + <li>Fixed a bug where code linked against <code>gnustl_static</code> crashed when run on + platform releases older than API level 8 (Android 2.2).</li> + + <li><code>ndk-gdb</code>: Fixed a bug that caused a segmentation fault when debugging Android 3.0 + or newer devices.</li> + + <li><code><android/input.h></code>: Two functions that were introduced in API level + 9 (Android 2.3) were incorrect and are fixed. While this breaks the source API, the + binary interface to the system is unchanged. The incorrect functions were missing a + <code>history_index</code> parameter, and the correct definitions are shown below: +<pre> +float AMotionEvent_getHistoricalRawX(const AInputEvent* motion_event, + size_t pointer_index, + size_t history_index); + +float AMotionEvent_getHistoricalRawY(const AInputEvent* motion_event, + size_t pointer_index, + size_t history_index); +</pre> + </li> + + <li>Updated the C library ARM binary for API level 9 (Android 2.3) to correctly expose at + link time new functions that were added in that API level (for example, + <code>pthread_rwlock_init</code>).</li> + + </ul> + </dd> + + <dt>Minor improvements and fixes:</dt> + <dd> + <ul> + <li>Object files are now always linked in the order they appear in + <code>LOCAL_SRC_FILES</code>. This was not the case previously because the files were + grouped by source extensions instead.</li> + + <li>When <code>import-module</code> fails, it now prints the list of directories that + were searched. This is useful to check that the <code>NDK_MODULE_PATH</code> definition + used by the build system is correct.</li> + + <li>When <code>import-module</code> succeeds, it now prints the directory where the + module was found to the log (visible with <code>NDK_LOG=1</code>).</li> + + <li>Increased the build speed of debuggable applications when there is a very large number + of include directories in the project.</li> + + <li><code>ndk-gdb</code>: Better detection of <code>adb shell</code> failures and improved + error messages.</li> + + <li><code><pthread.h></code>: Fixed the definition of + <code>PTHREAD_RWLOCK_INITIALIZER</code> for API level 9 (Android 2.3) and higher.</li> + + <li>Fixed an issue where a module could import itself, resulting in an infinite loop in + GNU Make.</li> + + <li>Fixed a bug that caused the build to fail if <code>LOCAL_ARM_NEON</code> was set to + true (typo in <code>build/core/build-binary.mk</code>).</li> + + <li>Fixed a bug that prevented the compilation of </code>.s</code> assembly files + (<code>.S</code> files were okay).</li> + </ul> + </dd> + </div> +</div> + +<div class="toggleable closed"> <a href="#" onclick="return toggleDiv(this)"><img src="{@docRoot}assets/images/triangle-closed.png" class="toggle-img" diff --git a/docs/html/sdk/sdk_toc.cs b/docs/html/sdk/sdk_toc.cs index d02c13d1bc2b..5750c815b1d4 100644 --- a/docs/html/sdk/sdk_toc.cs +++ b/docs/html/sdk/sdk_toc.cs @@ -175,8 +175,7 @@ class="new">new!</span></li> <span style="display:none" class="zh-TW"></span> </h2> <ul> - <li><a href="<?cs var:toroot ?>sdk/ndk/index.html">Android NDK, r5c <span - class="new">new!</span></a> + <li><a href="<?cs var:toroot ?>sdk/ndk/index.html">Android NDK, r5c</a> </li> <li><a href="<?cs var:toroot ?>sdk/ndk/overview.html">What is the NDK?</a></li> </ul> diff --git a/media/libstagefright/chromium_http/support.cpp b/media/libstagefright/chromium_http/support.cpp index 805bd4876cf0..ed6846c4e406 100644 --- a/media/libstagefright/chromium_http/support.cpp +++ b/media/libstagefright/chromium_http/support.cpp @@ -40,7 +40,7 @@ namespace android { static Mutex gNetworkThreadLock; static base::Thread *gNetworkThread = NULL; -static scoped_refptr<URLRequestContext> gReqContext; +static scoped_refptr<net::URLRequestContext> gReqContext; static void InitializeNetworkThreadIfNecessary() { Mutex::Autolock autoLock(gNetworkThreadLock); @@ -214,7 +214,7 @@ void SfDelegate::OnSetCookie( } void SfDelegate::OnResponseStarted(net::URLRequest *request) { - if (request->status().status() != URLRequestStatus::SUCCESS) { + if (request->status().status() != net::URLRequestStatus::SUCCESS) { MY_LOGI(StringPrintf( "Request failed with status %d and os_error %d", request->status().status(), @@ -325,7 +325,7 @@ void SfDelegate::readMore(net::URLRequest *request) { } else { MY_LOGV("readMore pending read"); - if (request->status().status() != URLRequestStatus::IO_PENDING) { + if (request->status().status() != net::URLRequestStatus::IO_PENDING) { MY_LOGI(StringPrintf( "Direct read failed w/ status %d\n", request->status().status()).c_str()); diff --git a/media/libstagefright/chromium_http/support.h b/media/libstagefright/chromium_http/support.h index 4d034937a952..8fe8db1da9e1 100644 --- a/media/libstagefright/chromium_http/support.h +++ b/media/libstagefright/chromium_http/support.h @@ -50,7 +50,7 @@ private: DISALLOW_EVIL_CONSTRUCTORS(SfNetLog); }; -struct SfRequestContext : public URLRequestContext { +struct SfRequestContext : public net::URLRequestContext { SfRequestContext(); virtual const std::string &GetUserAgent(const GURL &url) const; diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 5f0fbef7b6c1..83eaaa824ac4 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -44,6 +44,8 @@ <dimen name="status_bar_recents_fading_edge_length">20dip</dimen> <!-- Margin between recents container and glow on the right --> <dimen name="status_bar_recents_right_glow_margin">100dip</dimen> + <!-- Amount to offset bottom of notification peek window from top of status bar. --> + <dimen name="peek_window_y_offset">-12dp</dimen> <!-- thickness (height) of the navigation bar on phones that require it --> <dimen name="navigation_bar_size">42dp</dimen> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java index da1e1c5e72c5..f81820e5a3f4 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java @@ -56,13 +56,12 @@ public class CommandQueue extends IStatusBar.Stub { private static final int MSG_SET_LIGHTS_ON = 7 << MSG_SHIFT; - private static final int MSG_SHOW_MENU = 8 << MSG_SHIFT; + private static final int MSG_TOP_APP_WINDOW_CHANGED = 8 << MSG_SHIFT; private static final int MSG_SHOW_IME_BUTTON = 9 << MSG_SHIFT; private static final int MSG_SET_HARD_KEYBOARD_STATUS = 10 << MSG_SHIFT; private static final int MSG_USER_ACTIVITY = 11 << MSG_SHIFT; - private StatusBarIconList mList; private Callbacks mCallbacks; private Handler mHandler = new H(); @@ -87,7 +86,7 @@ public class CommandQueue extends IStatusBar.Stub { public void animateExpand(); public void animateCollapse(); public void setLightsOn(boolean on); - public void setMenuKeyVisible(boolean visible); + public void topAppWindowChanged(boolean visible); public void setImeWindowStatus(IBinder token, int vis, int backDisposition); public void setHardKeyboardStatus(boolean available, boolean enabled); public void userActivity(); @@ -166,10 +165,11 @@ public class CommandQueue extends IStatusBar.Stub { } } - public void setMenuKeyVisible(boolean visible) { + public void topAppWindowChanged(boolean menuVisible) { synchronized (mList) { - mHandler.removeMessages(MSG_SHOW_MENU); - mHandler.obtainMessage(MSG_SHOW_MENU, visible ? 1 : 0, 0, null).sendToTarget(); + mHandler.removeMessages(MSG_TOP_APP_WINDOW_CHANGED); + mHandler.obtainMessage(MSG_TOP_APP_WINDOW_CHANGED, menuVisible ? 1 : 0, 0, + null).sendToTarget(); } } @@ -253,8 +253,8 @@ public class CommandQueue extends IStatusBar.Stub { case MSG_SET_LIGHTS_ON: mCallbacks.setLightsOn(msg.arg1 != 0); break; - case MSG_SHOW_MENU: - mCallbacks.setMenuKeyVisible(msg.arg1 != 0); + case MSG_TOP_APP_WINDOW_CHANGED: + mCallbacks.topAppWindowChanged(msg.arg1 != 0); break; case MSG_SHOW_IME_BUTTON: mCallbacks.setImeWindowStatus((IBinder)msg.obj, msg.arg1, msg.arg2); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java index 23ae8230aef4..e567dc7a71b5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java @@ -78,7 +78,7 @@ public abstract class StatusBar extends SystemUI implements CommandQueue.Callbac disable(switches[0]); setLightsOn(switches[1] != 0); - setMenuKeyVisible(switches[2] != 0); + topAppWindowChanged(switches[2] != 0); // StatusBarManagerService has a back up of IME token and it's restored here. setImeWindowStatus(binders.get(0), switches[3], switches[4]); setHardKeyboardStatus(switches[5] != 0, switches[6] != 0); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 687de0750efd..cc8358e8b723 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -1144,7 +1144,7 @@ public class PhoneStatusBar extends StatusBar { } // Not supported - public void setMenuKeyVisible(boolean visible) { } + public void topAppWindowChanged(boolean visible) { } public void setImeWindowStatus(IBinder token, int vis, int backDisposition) { } @Override public void setHardKeyboardStatus(boolean available, boolean enabled) { } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/HeightReceiver.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/HeightReceiver.java index 9924faa0c8de..7f4c9180dd40 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/HeightReceiver.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/HeightReceiver.java @@ -76,7 +76,7 @@ public class HeightReceiver extends BroadcastReceiver { int height = -1; if (plugged) { final DisplayMetrics metrics = new DisplayMetrics(); - mWindowManager.getDefaultDisplay().getMetrics(metrics); + mWindowManager.getDefaultDisplay().getRealMetrics(metrics); //Slog.i(TAG, "setPlugged: display metrics=" + metrics); final int shortSide = Math.min(metrics.widthPixels, metrics.heightPixels); height = shortSide - 720; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java index ffb45ca5abcf..68eade0d6385 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java @@ -246,11 +246,12 @@ public class TabletStatusBar extends StatusBar implements 512, // ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, - WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN + WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, PixelFormat.TRANSLUCENT); lp.gravity = Gravity.BOTTOM | Gravity.RIGHT; + lp.y = res.getDimensionPixelOffset(R.dimen.peek_window_y_offset); lp.setTitle("NotificationPeekWindow"); lp.windowAnimations = com.android.internal.R.style.Animation_Toast; @@ -956,14 +957,14 @@ public class TabletStatusBar extends StatusBar implements mHandler.sendEmptyMessage(on ? MSG_SHOW_CHROME : MSG_HIDE_CHROME); } - public void setMenuKeyVisible(boolean visible) { + public void topAppWindowChanged(boolean windowVisible) { if (DEBUG) { - Slog.d(TAG, (visible?"showing":"hiding") + " the MENU button"); + Slog.d(TAG, (windowVisible?"showing":"hiding") + " the MENU button"); } - mMenuButton.setVisibility(visible ? View.VISIBLE : View.GONE); + mMenuButton.setVisibility(windowVisible ? View.VISIBLE : View.GONE); // See above re: lights-out policy for legacy apps. - if (visible) setLightsOn(true); + if (windowVisible) setLightsOn(true); // XXX: HACK: not sure if this is the best way to catch a new activity that might require a // change in compatibility features, but it's a start. diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 9dd2625db20c..572898977c63 100755 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -330,6 +330,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { static final Rect mTmpVisibleFrame = new Rect(); WindowState mTopFullscreenOpaqueWindowState; + WindowState mTopAppWindowState; + WindowState mLastTopAppWindowState; boolean mTopIsFullscreen; boolean mForceStatusBar; boolean mHideLockScreen; @@ -340,7 +342,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { Intent mDeskDockIntent; int mShortcutKeyPressed = -1; boolean mConsumeShortcutKeyUp; - boolean mShowMenuKey = false; // track FLAG_NEEDS_MENU_KEY on frontmost window // support for activating the lock screen while the screen is on boolean mAllowLockscreenWhenOn; @@ -1957,12 +1958,11 @@ public class PhoneWindowManager implements WindowManagerPolicy { // the status bar. They are protected by the STATUS_BAR_SERVICE // permission, so they have the same privileges as the status // bar itself. - pf.left = df.left = cf.left = vf.left = mUnrestrictedScreenLeft; - pf.top = df.top = cf.top = vf.top = mUnrestrictedScreenTop; - pf.right = df.right = cf.right = vf.right - = mUnrestrictedScreenLeft+mUnrestrictedScreenWidth; - pf.bottom = df.bottom = cf.bottom = vf.bottom - = mUnrestrictedScreenTop+mUnrestrictedScreenHeight; + pf.left = df.left = cf.left = mRestrictedScreenLeft; + pf.top = df.top = cf.top = mRestrictedScreenTop; + pf.right = df.right = cf.right = mRestrictedScreenLeft+mRestrictedScreenWidth; + pf.bottom = df.bottom = cf.bottom + = mRestrictedScreenTop+mRestrictedScreenHeight; } else { pf.left = mContentLeft; pf.top = mContentTop; @@ -2032,6 +2032,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { /** {@inheritDoc} */ public void beginAnimationLw(int displayWidth, int displayHeight) { mTopFullscreenOpaqueWindowState = null; + mTopAppWindowState = null; mForceStatusBar = false; mHideLockScreen = false; @@ -2067,6 +2068,12 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } } + if (mTopAppWindowState == null && win.isVisibleOrBehindKeyguardLw()) { + if (attrs.type >= FIRST_APPLICATION_WINDOW + && attrs.type <= LAST_APPLICATION_WINDOW) { + mTopAppWindowState = win; + } + } } /** {@inheritDoc} */ @@ -2110,22 +2117,13 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } - boolean topNeedsMenu = mShowMenuKey; - if (lp != null) { - topNeedsMenu = (lp.flags & WindowManager.LayoutParams.FLAG_NEEDS_MENU_KEY) != 0; - } - - if (DEBUG_LAYOUT) Log.v(TAG, "Top window " - + (topNeedsMenu ? "needs" : "does not need") - + " the MENU key"); - mTopIsFullscreen = topIsFullscreen; - final boolean changedMenu = (topNeedsMenu != mShowMenuKey); - if (changedMenu) { - final boolean topNeedsMenuF = topNeedsMenu; + if (mTopAppWindowState != null && mTopAppWindowState != mLastTopAppWindowState) { + mLastTopAppWindowState = mTopAppWindowState; - mShowMenuKey = topNeedsMenu; + final boolean topNeedsMenu = (mTopAppWindowState.getAttrs().flags + & WindowManager.LayoutParams.FLAG_NEEDS_MENU_KEY) != 0; mHandler.post(new Runnable() { public void run() { @@ -2140,9 +2138,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { final IStatusBarService sbs = mStatusBarService; if (mStatusBarService != null) { try { - if (changedMenu) { - sbs.setMenuKeyVisible(topNeedsMenuF); - } + sbs.topAppWindowChanged(topNeedsMenu); } catch (RemoteException e) { // This should be impossible because we're in the same process. mStatusBarService = null; diff --git a/services/java/com/android/server/StatusBarManagerService.java b/services/java/com/android/server/StatusBarManagerService.java index 1d2072c2cc27..b1bce50bac97 100644 --- a/services/java/com/android/server/StatusBarManagerService.java +++ b/services/java/com/android/server/StatusBarManagerService.java @@ -16,21 +16,16 @@ package com.android.server; -import android.app.PendingIntent; import android.app.StatusBarManager; import android.content.BroadcastReceiver; -import android.content.ComponentName; import android.content.Context; import android.content.Intent; -import android.content.IntentFilter; import android.content.pm.PackageManager; import android.content.res.Resources; -import android.net.Uri; import android.os.IBinder; import android.os.RemoteException; import android.os.Binder; import android.os.Handler; -import android.os.SystemClock; import android.util.Slog; import android.view.View; @@ -253,25 +248,23 @@ public class StatusBarManagerService extends IStatusBarService.Stub * Hide or show the on-screen Menu key. Only call this from the window manager, typically in * response to a window with FLAG_NEEDS_MENU_KEY set. */ - public void setMenuKeyVisible(final boolean visible) { + public void topAppWindowChanged(final boolean menuVisible) { enforceStatusBar(); - if (SPEW) Slog.d(TAG, (visible?"showing":"hiding") + " MENU key"); + if (SPEW) Slog.d(TAG, (menuVisible?"showing":"hiding") + " MENU key"); synchronized(mLock) { - if (mMenuVisible != visible) { - mMenuVisible = visible; - mHandler.post(new Runnable() { - public void run() { - if (mBar != null) { - try { - mBar.setMenuKeyVisible(visible); - } catch (RemoteException ex) { - } + mMenuVisible = menuVisible; + mHandler.post(new Runnable() { + public void run() { + if (mBar != null) { + try { + mBar.topAppWindowChanged(menuVisible); + } catch (RemoteException ex) { } } - }); - } + } + }); } } diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index 4f0265c6b432..f1098a8b04e7 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -7667,7 +7667,8 @@ public final class ActivityManagerService extends ActivityManagerNative pw.println(" COMP_SPEC may also be a component name (com.foo/.myApp),"); pw.println(" a partial substring in a component name, an"); pw.println(" ActivityRecord hex object identifier, or"); - pw.println(" \"all\" for all objects"); + pw.println(" \"all\" for all objects, or"); + pw.println(" \"top\" for the top activity."); pw.println(" -a: include all available server state."); pw.println(" -c: include client state."); return; @@ -8221,6 +8222,13 @@ public final class ActivityManagerService extends ActivityManagerNative activities.add(r1); } } + } else if ("top".equals(name)) { + synchronized (this) { + final int N = mMainStack.mHistory.size(); + if (N > 0) { + activities.add((ActivityRecord)mMainStack.mHistory.get(N-1)); + } + } } else { ComponentName componentName = ComponentName.unflattenFromString(name); int objectId = 0; diff --git a/services/java/com/android/server/am/CompatModePackages.java b/services/java/com/android/server/am/CompatModePackages.java index 1334bcd7147a..f65648624229 100644 --- a/services/java/com/android/server/am/CompatModePackages.java +++ b/services/java/com/android/server/am/CompatModePackages.java @@ -131,13 +131,7 @@ public class CompatModePackages { final boolean mayCompat = !ci.alwaysSupportsScreen() && !ci.neverSupportsScreen(); - if (!updated) { - // First time -- if the app may run in compat mode, enable that - // by default. - if (mayCompat) { - setPackageScreenCompatModeLocked(ai, ActivityManager.COMPAT_MODE_ENABLED); - } - } else { + if (updated) { // Update -- if the app no longer can run in compat mode, clear // any current settings for it. if (!mayCompat && mPackages.containsKey(packageName)) { |