Merge "Verify AppWidget ownership during update." into ics-mr1
diff --git a/api/current.txt b/api/current.txt
index b180f7d..808cb6f 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -18637,6 +18637,7 @@
method public android.os.Bundle getBundle();
method public java.lang.String getLocale();
method public void onCancel();
+ method public void onClose();
method public abstract void onCreate();
method public abstract android.view.textservice.SuggestionsInfo onGetSuggestions(android.view.textservice.TextInfo, int);
method public android.view.textservice.SuggestionsInfo[] onGetSuggestionsMultiple(android.view.textservice.TextInfo[], int, boolean);
diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java
index 85aec4c..c4ba778 100644
--- a/core/java/android/app/FragmentManager.java
+++ b/core/java/android/app/FragmentManager.java
@@ -725,8 +725,9 @@
// While removing a fragment, we can't change it to a higher state.
newState = f.mState;
}
- // Defer start if requested; don't allow it to move to STARTED or higher.
- if (f.mDeferStart && newState > Fragment.STOPPED) {
+ // Defer start if requested; don't allow it to move to STARTED or higher
+ // if it's not already started.
+ if (f.mDeferStart && f.mState < Fragment.STARTED && newState > Fragment.STOPPED) {
newState = Fragment.STOPPED;
}
if (f.mState < newState) {
diff --git a/core/java/android/inputmethodservice/KeyboardView.java b/core/java/android/inputmethodservice/KeyboardView.java
index 5343e2a..5143f7f 100644
--- a/core/java/android/inputmethodservice/KeyboardView.java
+++ b/core/java/android/inputmethodservice/KeyboardView.java
@@ -1145,44 +1145,29 @@
@Override
public boolean onHoverEvent(MotionEvent event) {
- // If touch exploring is enabled we ignore touch events and transform
- // the stream of hover events as touch events. This allows one consistent
- // event stream to drive the keyboard since during touch exploring the
- // first touch generates only hover events and tapping on the same
- // location generates hover and touch events.
if (mAccessibilityManager.isTouchExplorationEnabled() && event.getPointerCount() == 1) {
final int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_HOVER_ENTER:
- event.setAction(MotionEvent.ACTION_DOWN);
- break;
case MotionEvent.ACTION_HOVER_MOVE:
- event.setAction(MotionEvent.ACTION_MOVE);
+ final int touchX = (int) event.getX() - mPaddingLeft;
+ int touchY = (int) event.getY() - mPaddingTop;
+ if (touchY >= -mVerticalCorrection) {
+ touchY += mVerticalCorrection;
+ }
+ final int keyIndex = getKeyIndices(touchX, touchY, null);
+ showPreview(keyIndex);
break;
case MotionEvent.ACTION_HOVER_EXIT:
- event.setAction(MotionEvent.ACTION_UP);
+ showPreview(NOT_A_KEY);
break;
}
- onTouchEventInternal(event);
- event.setAction(action);
}
- return super.onHoverEvent(event);
+ return true;
}
@Override
- public boolean onTouchEvent(MotionEvent event) {
- // If touch exploring is enabled we ignore touch events and transform
- // the stream of hover events as touch events. This allows one consistent
- // event stream to drive the keyboard since during touch exploring the
- // first touch generates only hover events and tapping on the same
- // location generates hover and touch events.
- if (mAccessibilityManager.isTouchExplorationEnabled()) {
- return true;
- }
- return onTouchEventInternal(event);
- }
-
- private boolean onTouchEventInternal(MotionEvent me) {
+ public boolean onTouchEvent(MotionEvent me) {
// Convert multi-pointer up/down events to single up/down events to
// deal with the typical multi-pointer behavior of two-thumb typing
final int pointerCount = me.getPointerCount();
diff --git a/core/java/android/service/textservice/SpellCheckerService.java b/core/java/android/service/textservice/SpellCheckerService.java
index 2ecf307..28251a6 100644
--- a/core/java/android/service/textservice/SpellCheckerService.java
+++ b/core/java/android/service/textservice/SpellCheckerService.java
@@ -146,6 +146,14 @@
public void onCancel() {}
/**
+ * Request to close this session.
+ * This function will run on the incoming IPC thread.
+ * So, this is not called on the main thread,
+ * but will be called in series on another thread.
+ */
+ public void onClose() {}
+
+ /**
* @return Locale for this session
*/
public String getLocale() {
@@ -162,7 +170,7 @@
// Preventing from exposing ISpellCheckerSession.aidl, create an internal class.
private static class InternalISpellCheckerSession extends ISpellCheckerSession.Stub {
- private final ISpellCheckerSessionListener mListener;
+ private ISpellCheckerSessionListener mListener;
private final Session mSession;
private final String mLocale;
private final Bundle mBundle;
@@ -192,6 +200,12 @@
mSession.onCancel();
}
+ @Override
+ public void onClose() {
+ mSession.onClose();
+ mListener = null;
+ }
+
public String getLocale() {
return mLocale;
}
diff --git a/core/java/android/view/textservice/SpellCheckerSession.java b/core/java/android/view/textservice/SpellCheckerSession.java
index 5c3f089..01b114c 100644
--- a/core/java/android/view/textservice/SpellCheckerSession.java
+++ b/core/java/android/view/textservice/SpellCheckerSession.java
@@ -152,6 +152,7 @@
public void close() {
mIsUsed = false;
try {
+ mSpellCheckerSessionListenerImpl.close();
mTextServicesManager.finishSpellCheckerService(mSpellCheckerSessionListenerImpl);
} catch (RemoteException e) {
// do nothing
@@ -190,6 +191,7 @@
private static class SpellCheckerSessionListenerImpl extends ISpellCheckerSessionListener.Stub {
private static final int TASK_CANCEL = 1;
private static final int TASK_GET_SUGGESTIONS_MULTIPLE = 2;
+ private static final int TASK_CLOSE = 3;
private final Queue<SpellCheckerParams> mPendingTasks =
new LinkedList<SpellCheckerParams>();
private final Handler mHandler;
@@ -224,6 +226,9 @@
case TASK_GET_SUGGESTIONS_MULTIPLE:
processGetSuggestionsMultiple(scp);
break;
+ case TASK_CLOSE:
+ processClose();
+ break;
}
}
@@ -247,6 +252,13 @@
suggestionsLimit, sequentialWords));
}
+ public void close() {
+ if (DBG) {
+ Log.w(TAG, "close");
+ }
+ processOrEnqueueTask(new SpellCheckerParams(TASK_CLOSE, null, 0, false));
+ }
+
public boolean isDisconnected() {
return mOpened && mISpellCheckerSession == null;
}
@@ -284,6 +296,21 @@
}
}
+ private void processClose() {
+ if (!checkOpenConnection()) {
+ return;
+ }
+ if (DBG) {
+ Log.w(TAG, "Close spell checker tasks.");
+ }
+ try {
+ mISpellCheckerSession.onClose();
+ mISpellCheckerSession = null;
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to close " + e);
+ }
+ }
+
private void processGetSuggestionsMultiple(SpellCheckerParams scp) {
if (!checkOpenConnection()) {
return;
diff --git a/core/java/android/webkit/HTML5VideoInline.java b/core/java/android/webkit/HTML5VideoInline.java
index 42581c2..fe5908e 100644
--- a/core/java/android/webkit/HTML5VideoInline.java
+++ b/core/java/android/webkit/HTML5VideoInline.java
@@ -74,11 +74,13 @@
public SurfaceTexture getSurfaceTexture(int videoLayerId) {
// Create the surface texture.
if (videoLayerId != mVideoLayerUsingSurfaceTexture
- || mSurfaceTexture == null) {
- if (mTextureNames == null) {
- mTextureNames = new int[1];
- GLES20.glGenTextures(1, mTextureNames, 0);
+ || mSurfaceTexture == null
+ || mTextureNames == null) {
+ if (mTextureNames != null) {
+ GLES20.glDeleteTextures(1, mTextureNames, 0);
}
+ mTextureNames = new int[1];
+ GLES20.glGenTextures(1, mTextureNames, 0);
mSurfaceTexture = new SurfaceTexture(mTextureNames[0]);
}
mVideoLayerUsingSurfaceTexture = videoLayerId;
diff --git a/core/java/android/widget/SearchView.java b/core/java/android/widget/SearchView.java
index 6df80e4..399d217 100644
--- a/core/java/android/widget/SearchView.java
+++ b/core/java/android/widget/SearchView.java
@@ -1187,6 +1187,8 @@
*/
@Override
public void onActionViewExpanded() {
+ if (mExpandedInActionView) return;
+
mExpandedInActionView = true;
mCollapsedImeOptions = mQueryTextView.getImeOptions();
mQueryTextView.setImeOptions(mCollapsedImeOptions | EditorInfo.IME_FLAG_NO_FULLSCREEN);
diff --git a/core/java/com/android/internal/textservice/ISpellCheckerSession.aidl b/core/java/com/android/internal/textservice/ISpellCheckerSession.aidl
index 5a00603..3c61968 100644
--- a/core/java/com/android/internal/textservice/ISpellCheckerSession.aidl
+++ b/core/java/com/android/internal/textservice/ISpellCheckerSession.aidl
@@ -25,4 +25,5 @@
void onGetSuggestionsMultiple(
in TextInfo[] textInfos, int suggestionsLimit, boolean multipleWords);
void onCancel();
+ void onClose();
}
diff --git a/core/res/res/drawable/ic_lockscreen_outerring.xml b/core/res/res/drawable/ic_lockscreen_outerring.xml
index 490f370..3bdd6f6 100644
--- a/core/res/res/drawable/ic_lockscreen_outerring.xml
+++ b/core/res/res/drawable/ic_lockscreen_outerring.xml
@@ -17,7 +17,7 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
>
- <size android:height="270dp" android:width="270dp" />
+ <size android:height="@dimen/keyguard_lockscreen_outerring_diameter" android:width="@dimen/keyguard_lockscreen_outerring_diameter" />
<solid android:color="#00000000" />
<stroke android:color="#1affffff" android:width="2dp" />
-</shape>
+</shape>
\ No newline at end of file
diff --git a/core/res/res/values-sw600dp/dimens.xml b/core/res/res/values-sw600dp/dimens.xml
index db94884..551c1d8 100644
--- a/core/res/res/values-sw600dp/dimens.xml
+++ b/core/res/res/values-sw600dp/dimens.xml
@@ -45,6 +45,12 @@
<!-- Size of clock font in LockScreen. -->
<dimen name="keyguard_pattern_unlock_clock_font_size">98sp</dimen>
+ <!-- Size of lockscreen outerring on unsecure unlock LockScreen -->
+ <dimen name="keyguard_lockscreen_outerring_diameter">364dp</dimen>
+
+ <!-- target placement radius for MultiWaveView -->
+ <dimen name="multiwaveview_target_placement_radius">182dip</dimen>
+
<!-- Size of status line font in LockScreen. -->
<dimen name="keyguard_pattern_unlock_status_line_font_size">14sp</dimen>
diff --git a/core/res/res/values/arrays.xml b/core/res/res/values/arrays.xml
index ce6bbc2..f9e1f5b 100644
--- a/core/res/res/values/arrays.xml
+++ b/core/res/res/values/arrays.xml
@@ -343,8 +343,6 @@
<item>@drawable/list_divider_holo_dark</item>
<item>@drawable/list_divider_holo_light</item>
<item>@drawable/list_divider_holo_light</item>
- <item>@drawable/ic_lockscreen_handle</item>
- <item>@drawable/ic_lockscreen_outerring</item>
<item>@drawable/ic_lockscreen_chevron_left</item>
<item>@drawable/ic_lockscreen_chevron_right</item>
<item>@drawable/ab_transparent_dark_holo</item>
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index 3edd5ce..fa18648 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -66,6 +66,9 @@
<!-- Default vertical gap between keys in the password keyboard (used by keyguard) -->
<dimen name="password_keyboard_verticalGap">9dip</dimen>
+ <!-- Size of lockscreen outerring on unsecure unlock LockScreen -->
+ <dimen name="keyguard_lockscreen_outerring_diameter">270dp</dimen>
+
<!-- Default target placement radius for MultiWaveView -->
<dimen name="multiwaveview_target_placement_radius">135dip</dimen>
diff --git a/docs/html/guide/developing/device.jd b/docs/html/guide/developing/device.jd
index 9ce3649..deb7a2d 100644
--- a/docs/html/guide/developing/device.jd
+++ b/docs/html/guide/developing/device.jd
@@ -58,14 +58,17 @@
element.</p>
</li>
<li>Set up your device to allow installation of non-Market applications. <p>On
-the device, go to <strong>Settings > Applications</strong> and enable
+the device, go to <strong>Settings > Applications</strong> and enable
-<strong>Unknown sources</strong>.</p>
+<strong>Unknown sources</strong> (on an Android 4.0 device, the setting is
+located in <strong>Settings > Security</strong>).</p>
</li>
<li>Turn on "USB Debugging" on your device.
- <p>On the device, go to <strong>Settings > Applications > Development</strong>
- and enable <strong>USB debugging</strong>.</p>
+ <p>On the device, go to <strong>Settings > Applications > Development</strong>
+ and enable <strong>USB debugging</strong>
+ (on an Android 4.0 device, the setting is
+located in <strong>Settings > Developer options</strong>).</p>
</li>
<li>Set up your system to detect your device.
<ul>
diff --git a/docs/html/sdk/android-4.0.jd b/docs/html/sdk/android-4.0.jd
index 2ccc927..e886bdf 100644
--- a/docs/html/sdk/android-4.0.jd
+++ b/docs/html/sdk/android-4.0.jd
@@ -518,7 +518,7 @@
<p>To specify the focus or metering areas to use, simply call {@link
android.hardware.Camera.Parameters#setFocusAreas setFocusAreas()} or {@link
-android.hardware.Camera.Parameters#setFocusAreas setMeteringAreas()}. Each take a {@link
+android.hardware.Camera.Parameters#setMeteringAreas setMeteringAreas()}. Each take a {@link
java.util.List} of {@link android.hardware.Camera.Area} objects that indicate the areas to consider
for focus or metering. For example, you might implement a feature that allows the user to set the
focus area by touching an area of the preview, which you then translate to an {@link
@@ -1028,7 +1028,7 @@
<p>Android 4.0 gives users precise visibility of how much network data their applications are using.
The Settings app provides controls that allow users to manage set limits for network data usage and
even disable the use of background data for individual apps. In order to avoid users disabling your
-app’s access to data from the background, you should develop strategies to use use the data
+app’s access to data from the background, you should develop strategies to use the data
connection efficiently and adjust your usage depending on the type of connection available.</p>
<p>If your application performs a lot of network transactions, you should provide user settings that
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
index 7cdb76c..70208f8 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
@@ -282,7 +282,7 @@
if (err == -EWOULDBLOCK) {
if (mSource->feedMoreTSData() == OK) {
- msg->post();
+ msg->post(10000ll);
}
}
} else if (what == ACodec::kWhatEOS) {
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/audio/MediaBassBoostTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/audio/MediaBassBoostTest.java
index e3aa8cf..1fa5c0d 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/audio/MediaBassBoostTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/audio/MediaBassBoostTest.java
@@ -44,13 +44,7 @@
*/
public class MediaBassBoostTest extends ActivityInstrumentationTestCase2<MediaFrameworkTest> {
private String TAG = "MediaBassBoostTest";
- private final static int MIN_ENERGY_RATIO_2 = 3;
private final static short TEST_STRENGTH = 500;
- private final static int TEST_VOLUME = 4;
- // Implementor UUID for volume controller effect defined in
- // frameworks/base/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
- private final static UUID VOLUME_EFFECT_UUID =
- UUID.fromString("119341a0-8469-11df-81f9-0002a5d5c51b");
private BassBoost mBassBoost = null;
private int mSession = -1;
@@ -184,85 +178,6 @@
}
//-----------------------------------------------------------------
- // 2 - Effect action
- //----------------------------------
-
- //Test case 2.0: test actual bass boost influence on sound
- @LargeTest
- public void test2_0SoundModification() throws Exception {
- boolean result = false;
- String msg = "test2_0SoundModification()";
- EnergyProbe probe = null;
- AudioEffect vc = null;
- MediaPlayer mp = null;
- AudioManager am = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE);
- int volume = am.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
- am.setStreamVolume(AudioManager.STREAM_MUSIC,
- TEST_VOLUME,
- 0);
-
- try {
- probe = new EnergyProbe(0);
- // creating a volume controller on output mix ensures that ro.audio.silent mutes
- // audio after the effects and not before
- vc = new AudioEffect(
- AudioEffect.EFFECT_TYPE_NULL,
- VOLUME_EFFECT_UUID,
- 0,
- 0);
- vc.setEnabled(true);
-
- mp = new MediaPlayer();
- mp.setDataSource(MediaNames.SINE_200_1000);
- mp.setLooping(true);
- mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
- getBassBoost(mp.getAudioSessionId());
- mp.prepare();
- mp.start();
- Thread.sleep(200);
- // measure reference energy around 1kHz
- int refEnergy200 = probe.capture(200);
- int refEnergy1000 = probe.capture(1000);
- mBassBoost.setStrength((short)1000);
- mBassBoost.setEnabled(true);
- Thread.sleep(4000);
- // measure energy around 1kHz with band level at min
- int energy200 = probe.capture(200);
- int energy1000 = probe.capture(1000);
- // verify that the energy ration between low and high frequencies is at least
- // MIN_ENERGY_RATIO_2 times higher with bassboost on.
- assertTrue(msg + ": bass boost has no effect",
- ((float)energy200/(float)energy1000) >
- (MIN_ENERGY_RATIO_2 * ((float)refEnergy200/(float)refEnergy1000)));
- result = true;
- } catch (IllegalArgumentException e) {
- msg = msg.concat(": Bad parameter value");
- loge(msg, "Bad parameter value");
- } catch (UnsupportedOperationException e) {
- msg = msg.concat(": get parameter() rejected");
- loge(msg, "get parameter() rejected");
- } catch (IllegalStateException e) {
- msg = msg.concat("get parameter() called in wrong state");
- loge(msg, "get parameter() called in wrong state");
- } catch (InterruptedException e) {
- loge(msg, "sleep() interrupted");
- }
- finally {
- releaseBassBoost();
- if (mp != null) {
- mp.release();
- }
- if (vc != null) {
- vc.release();
- }
- if (probe != null) {
- probe.release();
- }
- am.setStreamVolume(AudioManager.STREAM_MUSIC, volume, 0);
- }
- assertTrue(msg, result);
- }
- //-----------------------------------------------------------------
// private methods
//----------------------------------
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/audio/MediaEqualizerTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/audio/MediaEqualizerTest.java
index ee91bbb..da9089d 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/audio/MediaEqualizerTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/audio/MediaEqualizerTest.java
@@ -49,11 +49,6 @@
private final static int MAX_BAND_LEVEL = 1500;
private final static int TEST_FREQUENCY_MILLIHERTZ = 1000000;
private final static int MIN_NUMBER_OF_PRESETS = 4;
- private final static int TEST_VOLUME = 4;
- // Implementor UUID for volume controller effect defined in
- // frameworks/base/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
- private final static UUID VOLUME_EFFECT_UUID =
- UUID.fromString("119341a0-8469-11df-81f9-0002a5d5c51b");
private Equalizer mEqualizer = null;
private int mSession = -1;
@@ -252,80 +247,6 @@
}
//-----------------------------------------------------------------
- // 2 - Effect action
- //----------------------------------
-
- //Test case 2.0: test that the equalizer actually alters the sound
- @LargeTest
- public void test2_0SoundModification() throws Exception {
- boolean result = false;
- String msg = "test2_0SoundModification()";
- EnergyProbe probe = null;
- AudioEffect vc = null;
- MediaPlayer mp = null;
- AudioManager am = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE);
- int volume = am.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
- am.setStreamVolume(AudioManager.STREAM_MUSIC,
- TEST_VOLUME,
- 0);
- try {
- probe = new EnergyProbe(0);
- // creating a volume controller on output mix ensures that ro.audio.silent mutes
- // audio after the effects and not before
- vc = new AudioEffect(
- AudioEffect.EFFECT_TYPE_NULL,
- VOLUME_EFFECT_UUID,
- 0,
- 0);
- vc.setEnabled(true);
-
- mp = new MediaPlayer();
- mp.setDataSource(MediaNames.SINE_200_1000);
- mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
- getEqualizer(mp.getAudioSessionId());
- mp.prepare();
- mp.start();
- Thread.sleep(500);
- // measure reference energy around 1kHz
- int refEnergy = probe.capture(1000);
- short band = mEqualizer.getBand(1000000);
- short[] levelRange = mEqualizer.getBandLevelRange();
- mEqualizer.setBandLevel(band, levelRange[0]);
- mEqualizer.setEnabled(true);
- Thread.sleep(500);
- // measure energy around 1kHz with band level at min
- int energy = probe.capture(1000);
- assertTrue(msg + ": equalizer has no effect at 1kHz", energy < refEnergy/4);
- result = true;
- } catch (IllegalArgumentException e) {
- msg = msg.concat(": Bad parameter value");
- loge(msg, "Bad parameter value");
- } catch (UnsupportedOperationException e) {
- msg = msg.concat(": get parameter() rejected");
- loge(msg, "get parameter() rejected");
- } catch (IllegalStateException e) {
- msg = msg.concat("get parameter() called in wrong state");
- loge(msg, "get parameter() called in wrong state");
- } catch (InterruptedException e) {
- loge(msg, "sleep() interrupted");
- }
- finally {
- releaseEqualizer();
- if (mp != null) {
- mp.release();
- }
- if (vc != null) {
- vc.release();
- }
- if (probe != null) {
- probe.release();
- }
- am.setStreamVolume(AudioManager.STREAM_MUSIC, volume, 0);
- }
- assertTrue(msg, result);
- }
-
- //-----------------------------------------------------------------
// private methods
//----------------------------------
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/audio/MediaVirtualizerTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/audio/MediaVirtualizerTest.java
index b74e525..122545f 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/audio/MediaVirtualizerTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/audio/MediaVirtualizerTest.java
@@ -44,13 +44,7 @@
*/
public class MediaVirtualizerTest extends ActivityInstrumentationTestCase2<MediaFrameworkTest> {
private String TAG = "MediaVirtualizerTest";
- private final static int MIN_ENERGY_RATIO_2 = 2;
private final static short TEST_STRENGTH = 500;
- private final static int TEST_VOLUME = 4;
- // Implementor UUID for volume controller effect defined in
- // frameworks/base/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
- private final static UUID VOLUME_EFFECT_UUID =
- UUID.fromString("119341a0-8469-11df-81f9-0002a5d5c51b");
private Virtualizer mVirtualizer = null;
private int mSession = -1;
@@ -185,89 +179,6 @@
}
//-----------------------------------------------------------------
- // 2 - Effect action
- //----------------------------------
-
- //Test case 2.0: test actual virtualizer influence on sound
- @LargeTest
- public void test2_0SoundModification() throws Exception {
- boolean result = false;
- String msg = "test2_0SoundModification()";
- EnergyProbe probe = null;
- AudioEffect vc = null;
- MediaPlayer mp = null;
- AudioManager am = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE);
- int volume = am.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
- am.setStreamVolume(AudioManager.STREAM_MUSIC,
- TEST_VOLUME,
- 0);
-
- try {
- probe = new EnergyProbe(0);
- // creating a volume controller on output mix ensures that ro.audio.silent mutes
- // audio after the effects and not before
- vc = new AudioEffect(
- AudioEffect.EFFECT_TYPE_NULL,
- VOLUME_EFFECT_UUID,
- 0,
- 0);
- vc.setEnabled(true);
-
- mp = new MediaPlayer();
- mp.setDataSource(MediaNames.SINE_200_1000);
- mp.setLooping(true);
- mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
- getVirtualizer(mp.getAudioSessionId());
- mp.prepare();
- mp.start();
- Thread.sleep(200);
- // measure reference energy around 1kHz
- int refEnergy200 = probe.capture(200);
- int refEnergy1000 = probe.capture(1000);
- mVirtualizer.setStrength((short)1000);
- mVirtualizer.setEnabled(true);
- Thread.sleep(4000);
- // measure energy around 1kHz with band level at min
- int energy200 = probe.capture(200);
- int energy1000 = probe.capture(1000);
- // verify that the energy ration between low and high frequencies is at least
- // MIN_ENERGY_RATIO_2 times higher with virtualizer on.
- // NOTE: this is what is observed with current virtualizer implementation and the test
- // audio file but is not the primary effect of the virtualizer. A better way would
- // be to have a stereo PCM capture and check that a strongly paned input is centered
- // when output. However, we cannot capture stereo with the visualizer.
- assertTrue(msg + ": virtualizer has no effect",
- ((float)energy200/(float)energy1000) >
- (MIN_ENERGY_RATIO_2 * ((float)refEnergy200/(float)refEnergy1000)));
- result = true;
- } catch (IllegalArgumentException e) {
- msg = msg.concat(": Bad parameter value");
- loge(msg, "Bad parameter value");
- } catch (UnsupportedOperationException e) {
- msg = msg.concat(": get parameter() rejected");
- loge(msg, "get parameter() rejected");
- } catch (IllegalStateException e) {
- msg = msg.concat("get parameter() called in wrong state");
- loge(msg, "get parameter() called in wrong state");
- } catch (InterruptedException e) {
- loge(msg, "sleep() interrupted");
- }
- finally {
- releaseVirtualizer();
- if (mp != null) {
- mp.release();
- }
- if (vc != null) {
- vc.release();
- }
- if (probe != null) {
- probe.release();
- }
- am.setStreamVolume(AudioManager.STREAM_MUSIC, volume, 0);
- }
- assertTrue(msg, result);
- }
- //-----------------------------------------------------------------
// private methods
//----------------------------------
diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml
index ce390a0..ff67a7e 100644
--- a/packages/SystemUI/res/values/colors.xml
+++ b/packages/SystemUI/res/values/colors.xml
@@ -26,7 +26,7 @@
<drawable name="status_bar_recents_app_thumbnail_background">#88000000</drawable>
<color name="status_bar_recents_app_label_color">#ffffffff</color>
<drawable name="status_bar_notification_row_background_color">#ff090909</drawable>
- <drawable name="notification_header_bg">#d8000000</drawable>
+ <drawable name="notification_header_bg">#FF000000</drawable>
<drawable name="notification_tracking_bg">#d8000000</drawable>
<color name="notification_list_shadow_top">#80000000</color>
<drawable name="recents_callout_line">#99ffffff</drawable>
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 0a77654..7d97246 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -389,8 +389,8 @@
boolean mLockScreenTimerActive;
// visual screen saver support
- int mScreenSaverTimeout;
- boolean mScreenSaverEnabled = false;
+ int mScreenSaverTimeout = 0;
+ boolean mScreenSaverEnabled = true;
// Behavior of ENDCALL Button. (See Settings.System.END_BUTTON_BEHAVIOR.)
int mEndcallBehavior;
@@ -454,7 +454,7 @@
Settings.Secure.DEFAULT_INPUT_METHOD), false, this);
resolver.registerContentObserver(Settings.System.getUriFor(
"fancy_rotation_anim"), false, this);
- resolver.registerContentObserver(Settings.System.getUriFor(
+ resolver.registerContentObserver(Settings.Secure.getUriFor(
Settings.Secure.DREAM_TIMEOUT), false, this);
updateSettings();
}
@@ -909,9 +909,8 @@
updateRotation = true;
}
- mScreenSaverTimeout = Settings.System.getInt(resolver,
+ mScreenSaverTimeout = Settings.Secure.getInt(resolver,
Settings.Secure.DREAM_TIMEOUT, 0);
- mScreenSaverEnabled = true;
updateScreenSaverTimeoutLocked();
}
if (updateRotation) {
@@ -3417,70 +3416,59 @@
}
}
- // Turn this off for now, screen savers not currently enabled.
- if (false) {
- synchronized (mLock) {
- updateScreenSaverTimeoutLocked();
- }
+ synchronized (mLock) {
+ // Only posts messages; holds no additional locks.
+ updateScreenSaverTimeoutLocked();
}
}
- Runnable mScreenSaverActivator = null;
- /*new Runnable() {
+ Runnable mScreenSaverActivator = new Runnable() {
public void run() {
- synchronized (this) {
- if (!(mScreenSaverEnabled && mScreenOn)) {
- Log.w(TAG, "mScreenSaverActivator ran, but the screensaver should not be showing. Who's driving this thing?");
- return;
- }
+ if (!(mScreenSaverEnabled && mScreenOnEarly)) {
+ Log.w(TAG, "mScreenSaverActivator ran, but the screensaver should not be showing. Who's driving this thing?");
+ return;
+ }
- if (localLOGV) Log.v(TAG, "mScreenSaverActivator entering dreamland");
- try {
- String component = Settings.System.getString(
- mContext.getContentResolver(), Settings.Secure.DREAM_COMPONENT);
- if (component != null) {
- ComponentName cn = ComponentName.unflattenFromString(component);
- Intent intent = new Intent(Intent.ACTION_MAIN)
- .setComponent(cn)
- .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
- | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
- | Intent.FLAG_ACTIVITY_NO_USER_ACTION
- | Intent.FLAG_ACTIVITY_SINGLE_TOP);
- mContext.startActivity(intent);
- } else {
- Log.e(TAG, "Couldn't start screen saver: none selected");
- }
- } catch (android.content.ActivityNotFoundException exc) {
- // no screensaver? give up
- Log.e(TAG, "Couldn't start screen saver: none installed");
+ if (localLOGV) Log.v(TAG, "mScreenSaverActivator entering dreamland");
+ try {
+ String component = Settings.Secure.getString(
+ mContext.getContentResolver(), Settings.Secure.DREAM_COMPONENT);
+ if (component != null) {
+ ComponentName cn = ComponentName.unflattenFromString(component);
+ Intent intent = new Intent(Intent.ACTION_MAIN)
+ .setComponent(cn)
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
+ | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
+ | Intent.FLAG_ACTIVITY_NO_USER_ACTION
+ );
+ mContext.startActivity(intent);
+ } else {
+ Log.e(TAG, "Couldn't start screen saver: none selected");
}
+ } catch (android.content.ActivityNotFoundException exc) {
+ // no screensaver? give up
+ Log.e(TAG, "Couldn't start screen saver: none installed");
}
}
};
- */
// Must call while holding mLock
private void updateScreenSaverTimeoutLocked() {
if (mScreenSaverActivator == null) return;
- // GAH... acquiring a lock within a lock? Please let's fix this.
- // (Also note this is called from userActivity, with the power manager
- // lock held. Not good.)
- synchronized (mScreenSaverActivator) {
- mHandler.removeCallbacks(mScreenSaverActivator);
- if (mScreenSaverEnabled && mScreenOnEarly && mScreenSaverTimeout > 0) {
- if (localLOGV)
- Log.v(TAG, "scheduling screensaver for " + mScreenSaverTimeout + "ms from now");
- mHandler.postDelayed(mScreenSaverActivator, mScreenSaverTimeout);
- } else {
- if (localLOGV) {
- if (mScreenSaverTimeout == 0)
- Log.v(TAG, "screen saver disabled by user");
- else if (!mScreenOnEarly)
- Log.v(TAG, "screen saver disabled while screen off");
- else
- Log.v(TAG, "screen saver disabled by wakelock");
- }
+ mHandler.removeCallbacks(mScreenSaverActivator);
+ if (mScreenSaverEnabled && mScreenOnEarly && mScreenSaverTimeout > 0) {
+ if (localLOGV)
+ Log.v(TAG, "scheduling screensaver for " + mScreenSaverTimeout + "ms from now");
+ mHandler.postDelayed(mScreenSaverActivator, mScreenSaverTimeout);
+ } else {
+ if (localLOGV) {
+ if (mScreenSaverTimeout == 0)
+ Log.v(TAG, "screen saver disabled by user");
+ else if (!mScreenOnEarly)
+ Log.v(TAG, "screen saver disabled while screen off");
+ else
+ Log.v(TAG, "screen saver disabled by wakelock");
}
}
}
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 310ace0..0c42926 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -293,7 +293,7 @@
/**
* Historical data of past broadcasts, for debugging.
*/
- static final int MAX_BROADCAST_HISTORY = 100;
+ static final int MAX_BROADCAST_HISTORY = 25;
final BroadcastRecord[] mBroadcastHistory
= new BroadcastRecord[MAX_BROADCAST_HISTORY];
@@ -13898,7 +13898,7 @@
if (curLevel >= ComponentCallbacks2.TRIM_MEMORY_COMPLETE) {
// For these apps we will also finish their activities
// to help them free memory.
- mMainStack.destroyActivitiesLocked(app, false);
+ mMainStack.destroyActivitiesLocked(app, false, "trim");
}
}
app.trimMemoryLevel = curLevel;
@@ -13962,7 +13962,7 @@
}
if (mAlwaysFinishActivities) {
- mMainStack.destroyActivitiesLocked(null, false);
+ mMainStack.destroyActivitiesLocked(null, false, "always-finish");
}
}
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index a47502e..8435eaa 100644
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -947,7 +947,7 @@
r.state = ActivityState.STOPPED;
if (!r.finishing) {
if (r.configDestroy) {
- destroyActivityLocked(r, true, false);
+ destroyActivityLocked(r, true, false, "stop-config");
resumeTopActivityLocked(null);
}
}
@@ -976,7 +976,7 @@
// instance right now, we need to first completely stop
// the current instance before starting the new one.
if (DEBUG_PAUSE) Slog.v(TAG, "Destroying after pause: " + prev);
- destroyActivityLocked(prev, true, false);
+ destroyActivityLocked(prev, true, false, "pause-config");
} else {
mStoppingActivities.add(prev);
if (mStoppingActivities.size() > 3) {
@@ -1364,7 +1364,8 @@
}
}
- if (!prev.finishing && prev.app != null && prev.app != next.app) {
+ if (!prev.finishing && prev.app != null && prev.app != next.app
+ && prev.app != mService.mHomeProcess) {
// We are switching to a new activity that is in a different
// process than the previous one. Note the previous process,
// so we can try to keep it around.
@@ -3113,7 +3114,7 @@
if (DEBUG_STATES) Slog.v(TAG, "Stop failed; moving to STOPPED: " + r);
r.state = ActivityState.STOPPED;
if (r.configDestroy) {
- destroyActivityLocked(r, true, false);
+ destroyActivityLocked(r, true, false, "stop-except");
}
}
}
@@ -3288,7 +3289,7 @@
for (i=0; i<NF; i++) {
ActivityRecord r = (ActivityRecord)finishes.get(i);
synchronized (mService) {
- destroyActivityLocked(r, true, false);
+ destroyActivityLocked(r, true, false, "finish-idle");
}
}
@@ -3487,7 +3488,7 @@
|| prevState == ActivityState.INITIALIZING) {
// If this activity is already stopped, we can just finish
// it right now.
- return destroyActivityLocked(r, true, true) ? null : r;
+ return destroyActivityLocked(r, true, true, "finish-imm") ? null : r;
} else {
// Need to go through the full pause cycle to get this
// activity into the stopped state and then finish it.
@@ -3593,7 +3594,7 @@
}
}
- final void destroyActivitiesLocked(ProcessRecord owner, boolean oomAdj) {
+ final void destroyActivitiesLocked(ProcessRecord owner, boolean oomAdj, String reason) {
for (int i=mHistory.size()-1; i>=0; i--) {
ActivityRecord r = mHistory.get(i);
if (owner != null && r.app != owner) {
@@ -3604,7 +3605,7 @@
if (r.app != null && r.haveState && !r.visible && r.stopped && !r.finishing
&& r.state != ActivityState.DESTROYING
&& r.state != ActivityState.DESTROYED) {
- destroyActivityLocked(r, true, oomAdj);
+ destroyActivityLocked(r, true, oomAdj, "trim");
}
}
}
@@ -3616,13 +3617,13 @@
* but then create a new client-side object for this same HistoryRecord.
*/
final boolean destroyActivityLocked(ActivityRecord r,
- boolean removeFromApp, boolean oomAdj) {
+ boolean removeFromApp, boolean oomAdj, String reason) {
if (DEBUG_SWITCH) Slog.v(
TAG, "Removing activity: token=" + r
+ ", app=" + (r.app != null ? r.app.processName : "(null)"));
EventLog.writeEvent(EventLogTags.AM_DESTROY_ACTIVITY,
System.identityHashCode(r),
- r.task.taskId, r.shortComponentName);
+ r.task.taskId, r.shortComponentName, reason);
boolean removedFromHistory = false;
@@ -4109,7 +4110,7 @@
if (r.app == null || r.app.thread == null) {
if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG,
"Switch is destroying non-running " + r);
- destroyActivityLocked(r, true, false);
+ destroyActivityLocked(r, true, false, "config");
} else if (r.state == ActivityState.PAUSING) {
// A little annoying: we are waiting for this activity to
// finish pausing. Let's not do anything now, but just
diff --git a/services/java/com/android/server/am/EventLogTags.logtags b/services/java/com/android/server/am/EventLogTags.logtags
index aadd37d..a579f44 100644
--- a/services/java/com/android/server/am/EventLogTags.logtags
+++ b/services/java/com/android/server/am/EventLogTags.logtags
@@ -48,7 +48,7 @@
# Reporting to applications that memory is low
30017 am_low_memory (Num Processes|1|1)
# An activity is being destroyed:
-30018 am_destroy_activity (Token|1|5),(Task ID|1|5),(Component Name|3)
+30018 am_destroy_activity (Token|1|5),(Task ID|1|5),(Component Name|3),(Reason|3)
# An activity has been relaunched, resumed, and is now in the foreground:
30019 am_relaunch_resume_activity (Token|1|5),(Task ID|1|5),(Component Name|3)
# An activity has been relaunched:
diff --git a/services/java/com/android/server/connectivity/Tethering.java b/services/java/com/android/server/connectivity/Tethering.java
index 1107fe9..7bd29d9 100644
--- a/services/java/com/android/server/connectivity/Tethering.java
+++ b/services/java/com/android/server/connectivity/Tethering.java
@@ -73,7 +73,7 @@
private Context mContext;
private final static String TAG = "Tethering";
private final static boolean DBG = true;
- private final static boolean VDBG = false;
+ private final static boolean VDBG = true;
// TODO - remove both of these - should be part of interface inspection/selection stuff
private String[] mTetherableUsbRegexs;
@@ -920,6 +920,29 @@
setTethered(true);
sendTetherStateChangedBroadcast();
}
+
+ void cleanupUpstream() {
+ if (mMyUpstreamIfaceName != null) {
+ // note that we don't care about errors here.
+ // sometimes interfaces are gone before we get
+ // to remove their rules, which generates errors.
+ // just do the best we can.
+ try {
+ // about to tear down NAT; gather remaining statistics
+ mStatsService.forceUpdate();
+ } catch (Exception e) {
+ if (VDBG) Log.e(TAG, "Exception in forceUpdate: " + e.toString());
+ }
+ try {
+ mNMService.disableNat(mIfaceName, mMyUpstreamIfaceName);
+ } catch (Exception e) {
+ if (VDBG) Log.e(TAG, "Exception in disableNat: " + e.toString());
+ }
+ mMyUpstreamIfaceName = null;
+ }
+ return;
+ }
+
@Override
public boolean processMessage(Message message) {
if (VDBG) Log.d(TAG, "TetheredState.processMessage what=" + message.what);
@@ -928,23 +951,7 @@
switch (message.what) {
case CMD_TETHER_UNREQUESTED:
case CMD_INTERFACE_DOWN:
- if (mMyUpstreamIfaceName != null) {
- try {
- // about to tear down NAT; gather remaining statistics
- mStatsService.forceUpdate();
-
- mNMService.disableNat(mIfaceName, mMyUpstreamIfaceName);
- mMyUpstreamIfaceName = null;
- } catch (Exception e) {
- try {
- mNMService.untetherInterface(mIfaceName);
- } catch (Exception ee) {}
-
- setLastErrorAndTransitionToInitialState(
- ConnectivityManager.TETHER_ERROR_DISABLE_NAT_ERROR);
- break;
- }
- }
+ cleanupUpstream();
try {
mNMService.untetherInterface(mIfaceName);
} catch (Exception e) {
@@ -975,23 +982,7 @@
if (VDBG) Log.d(TAG, "Connection changed noop - dropping");
break;
}
- if (mMyUpstreamIfaceName != null) {
- try {
- // about to tear down NAT; gather remaining statistics
- mStatsService.forceUpdate();
-
- mNMService.disableNat(mIfaceName, mMyUpstreamIfaceName);
- mMyUpstreamIfaceName = null;
- } catch (Exception e) {
- try {
- mNMService.untetherInterface(mIfaceName);
- } catch (Exception ee) {}
-
- setLastErrorAndTransitionToInitialState(
- ConnectivityManager.TETHER_ERROR_DISABLE_NAT_ERROR);
- break;
- }
- }
+ cleanupUpstream();
if (newUpstreamIfaceName != null) {
try {
mNMService.enableNat(mIfaceName, newUpstreamIfaceName);
@@ -1016,23 +1007,7 @@
error = true;
// fall through
case CMD_TETHER_MODE_DEAD:
- if (mMyUpstreamIfaceName != null) {
- try {
- // about to tear down NAT; gather remaining statistics
- mStatsService.forceUpdate();
-
- mNMService.disableNat(mIfaceName, mMyUpstreamIfaceName);
- mMyUpstreamIfaceName = null;
- } catch (Exception e) {
- try {
- mNMService.untetherInterface(mIfaceName);
- } catch (Exception ee) {}
-
- setLastErrorAndTransitionToInitialState(
- ConnectivityManager.TETHER_ERROR_DISABLE_NAT_ERROR);
- break;
- }
- }
+ cleanupUpstream();
try {
mNMService.untetherInterface(mIfaceName);
} catch (Exception e) {
diff --git a/tests/FrameworkPerf/res/layout/button_layout.xml b/tests/FrameworkPerf/res/layout/button_layout.xml
new file mode 100644
index 0000000..7786a25
--- /dev/null
+++ b/tests/FrameworkPerf/res/layout/button_layout.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:text="FooBarYou" />
+</LinearLayout>
diff --git a/tests/FrameworkPerf/res/layout/image_button_layout.xml b/tests/FrameworkPerf/res/layout/image_button_layout.xml
new file mode 100644
index 0000000..65b12b3
--- /dev/null
+++ b/tests/FrameworkPerf/res/layout/image_button_layout.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+ <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:src="@drawable/stat_happy"/>
+</LinearLayout>
diff --git a/tests/FrameworkPerf/res/layout/large_layout.xml b/tests/FrameworkPerf/res/layout/large_layout.xml
index b6ac88c..39bbe34 100644
--- a/tests/FrameworkPerf/res/layout/large_layout.xml
+++ b/tests/FrameworkPerf/res/layout/large_layout.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
+<!-- Copyright (C) 2011 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/tests/FrameworkPerf/res/layout/small_layout.xml b/tests/FrameworkPerf/res/layout/small_layout.xml
index 9fcbb26..e78a176 100644
--- a/tests/FrameworkPerf/res/layout/small_layout.xml
+++ b/tests/FrameworkPerf/res/layout/small_layout.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2009 The Android Open Source Project
+<!-- Copyright (C) 2011 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/tests/FrameworkPerf/res/layout/view_layout.xml b/tests/FrameworkPerf/res/layout/view_layout.xml
new file mode 100644
index 0000000..0171eef
--- /dev/null
+++ b/tests/FrameworkPerf/res/layout/view_layout.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+ <View android:layout_width="wrap_content" android:layout_height="wrap_content" />
+</LinearLayout>
diff --git a/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java b/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java
index 5e15224..3979902 100644
--- a/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java
+++ b/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java
@@ -20,6 +20,8 @@
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
+import android.content.res.TypedArray;
+import android.content.res.XmlResourceParser;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
@@ -29,13 +31,16 @@
import android.os.PowerManager;
import android.os.Process;
import android.os.SystemClock;
+import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
+import android.util.Xml;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
+import android.widget.Button;
import android.widget.Spinner;
import android.widget.TextView;
@@ -46,6 +51,9 @@
import java.io.RandomAccessFile;
import java.util.ArrayList;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
/**
* So you thought sync used up your battery life.
*/
@@ -57,8 +65,10 @@
Spinner mFgSpinner;
Spinner mBgSpinner;
- TextView mLog;
TextView mTestTime;
+ Button mStartButton;
+ Button mStopButton;
+ TextView mLog;
PowerManager.WakeLock mPartialWakeLock;
long mMaxRunTime = 5000;
@@ -100,12 +110,21 @@
new WriteFileOp(), new ReadFileOp(),
new ReadFileOp(), new WriteFileOp(),
new ReadFileOp(), new ReadFileOp(),
+ new OpenXmlResOp(), new NoOp(),
+ new ReadXmlAttrsOp(), new NoOp(),
new ParseXmlResOp(), new NoOp(),
new ParseLargeXmlResOp(), new NoOp(),
new LayoutInflaterOp(), new NoOp(),
new LayoutInflaterLargeOp(), new NoOp(),
+ new LayoutInflaterViewOp(), new NoOp(),
+ new LayoutInflaterButtonOp(), new NoOp(),
+ new LayoutInflaterImageButtonOp(), new NoOp(),
+ new CreateBitmapOp(), new NoOp(),
+ new CreateRecycleBitmapOp(), new NoOp(),
new LoadSmallBitmapOp(), new NoOp(),
+ new LoadRecycleSmallBitmapOp(), new NoOp(),
new LoadLargeBitmapOp(), new NoOp(),
+ new LoadRecycleLargeBitmapOp(), new NoOp(),
new LoadSmallScaledBitmapOp(), new NoOp(),
new LoadLargeScaledBitmapOp(), new NoOp(),
};
@@ -122,12 +141,21 @@
new CreateWriteSyncFileOp(),
new WriteFileOp(),
new ReadFileOp(),
+ new OpenXmlResOp(),
+ new ReadXmlAttrsOp(),
new ParseXmlResOp(),
new ParseLargeXmlResOp(),
new LayoutInflaterOp(),
new LayoutInflaterLargeOp(),
+ new LayoutInflaterViewOp(),
+ new LayoutInflaterButtonOp(),
+ new LayoutInflaterImageButtonOp(),
+ new CreateBitmapOp(),
+ new CreateRecycleBitmapOp(),
new LoadSmallBitmapOp(),
+ new LoadRecycleSmallBitmapOp(),
new LoadLargeBitmapOp(),
+ new LoadRecycleLargeBitmapOp(),
new LoadSmallScaledBitmapOp(),
new LoadLargeScaledBitmapOp(),
};
@@ -208,17 +236,22 @@
mBgSpinner.setAdapter(adapter);
mBgSpinner.setOnItemSelectedListener(this);
- findViewById(R.id.start).setOnClickListener(new View.OnClickListener() {
+ mTestTime = (TextView)findViewById(R.id.testtime);
+
+ mStartButton = (Button)findViewById(R.id.start);
+ mStartButton.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
startRunning();
}
});
- findViewById(R.id.stop).setOnClickListener(new View.OnClickListener() {
+ mStopButton = (Button)findViewById(R.id.stop);
+ mStopButton.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
stopRunning();
}
});
- mTestTime = (TextView)findViewById(R.id.testtime);
+ mStopButton.setEnabled(false);
+
mLog = (TextView)findViewById(R.id.log);
PowerManager pm = (PowerManager)getSystemService(POWER_SERVICE);
@@ -267,9 +300,17 @@
fgOp = mFgTest;
bgOp = mBgTest;
} else if (mFgTest != null) {
+ // Skip null test.
+ if (mCurOpIndex == 0) {
+ mCurOpIndex = 1;
+ }
fgOp = mFgTest;
bgOp = mAvailOps[mCurOpIndex];
} else {
+ // Skip null test.
+ if (mCurOpIndex == 0) {
+ mCurOpIndex = 1;
+ }
fgOp = mAvailOps[mCurOpIndex];
bgOp = mBgTest;
}
@@ -297,12 +338,13 @@
stopRunning();
return;
}
- }
- mCurOpIndex++;
- if (mCurOpIndex >= mAvailOps.length) {
- log("Finished");
- stopRunning();
- return;
+ } else {
+ mCurOpIndex++;
+ if (mCurOpIndex >= mAvailOps.length) {
+ log("Finished");
+ stopRunning();
+ return;
+ }
}
startCurOp();
}
@@ -313,6 +355,11 @@
if (!mStarted) {
log("Start");
mStarted = true;
+ mStartButton.setEnabled(false);
+ mStopButton.setEnabled(true);
+ mTestTime.setEnabled(false);
+ mFgSpinner.setEnabled(false);
+ mBgSpinner.setEnabled(false);
updateWakeLock();
startService(new Intent(this, SchedulerService.class));
mCurOpIndex = 0;
@@ -325,6 +372,11 @@
void stopRunning() {
if (mStarted) {
mStarted = false;
+ mStartButton.setEnabled(true);
+ mStopButton.setEnabled(false);
+ mTestTime.setEnabled(true);
+ mFgSpinner.setEnabled(true);
+ mBgSpinner.setEnabled(true);
updateWakeLock();
stopService(new Intent(this, SchedulerService.class));
for (int i=0; i<mResults.size(); i++) {
@@ -333,7 +385,7 @@
float bgMsPerOp = result.getBgMsPerOp();
String fgMsPerOpStr = fgMsPerOp != 0 ? Float.toString(fgMsPerOp) : "";
String bgMsPerOpStr = bgMsPerOp != 0 ? Float.toString(bgMsPerOp) : "";
- Log.i(TAG, "\t" + result.name + "\t" + result.fgOps
+ Log.i("PerfRes", "\t" + result.name + "\t" + result.fgOps
+ "\t" + result.getFgMsPerOp() + "\t" + result.fgTime
+ "\t" + result.fgLongName + "\t" + result.bgOps
+ "\t" + result.getBgMsPerOp() + "\t" + result.bgTime
@@ -662,6 +714,71 @@
}
}
+ static class OpenXmlResOp extends Op {
+ Context mContext;
+
+ OpenXmlResOp() {
+ super("OpenXmlRes", "Open (and close) an XML resource");
+ }
+
+ void onInit(Context context, boolean foreground) {
+ mContext = context;
+ }
+
+ boolean onRun() {
+ XmlResourceParser parser = mContext.getResources().getLayout(R.xml.simple);
+ parser.close();
+ return true;
+ }
+ }
+
+ static class ReadXmlAttrsOp extends Op {
+ Context mContext;
+ XmlResourceParser mParser;
+ AttributeSet mAttrs;
+
+ ReadXmlAttrsOp() {
+ super("ReadXmlAttrs", "Read attributes from an XML tag");
+ }
+
+ void onInit(Context context, boolean foreground) {
+ mContext = context;
+ mParser = mContext.getResources().getLayout(R.xml.simple);
+ mAttrs = Xml.asAttributeSet(mParser);
+
+ int eventType;
+ try {
+ // Find the first <item> tag.
+ eventType = mParser.getEventType();
+ String tagName;
+ do {
+ if (eventType == XmlPullParser.START_TAG) {
+ tagName = mParser.getName();
+ if (tagName.equals("item")) {
+ break;
+ }
+ }
+ eventType = mParser.next();
+ } while (eventType != XmlPullParser.END_DOCUMENT);
+ } catch (XmlPullParserException e) {
+ throw new RuntimeException("I died", e);
+ } catch (IOException e) {
+ throw new RuntimeException("I died", e);
+ }
+ }
+
+ void onTerm(Context context) {
+ mParser.close();
+ }
+
+ boolean onRun() {
+ TypedArray a = mContext.obtainStyledAttributes(mAttrs,
+ com.android.internal.R.styleable.MenuItem);
+ a.recycle();
+ return true;
+ }
+ }
+
static class ParseXmlResOp extends Op {
Context mContext;
@@ -702,7 +819,7 @@
Context mContext;
LayoutInflaterOp() {
- super("LayoutInflaterOp", "Inflate layout resource");
+ super("LayoutInflater", "Inflate layout resource");
}
void onInit(Context context, boolean foreground) {
@@ -724,7 +841,7 @@
Context mContext;
LayoutInflaterLargeOp() {
- super("LayoutInflaterLargeOp", "Inflate large layout resource");
+ super("LayoutInflaterLarge", "Inflate large layout resource");
}
void onInit(Context context, boolean foreground) {
@@ -742,6 +859,111 @@
}
}
+ static class LayoutInflaterViewOp extends Op {
+ Context mContext;
+
+ LayoutInflaterViewOp() {
+ super("LayoutInflaterView", "Inflate layout with 50 View objects");
+ }
+
+ void onInit(Context context, boolean foreground) {
+ mContext = context;
+ }
+
+ boolean onRun() {
+ if (Looper.myLooper() == null) {
+ Looper.prepare();
+ }
+ LayoutInflater inf = (LayoutInflater)mContext.getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE);
+ inf.inflate(R.layout.view_layout, null);
+ return true;
+ }
+ }
+
+ static class LayoutInflaterButtonOp extends Op {
+ Context mContext;
+
+ LayoutInflaterButtonOp() {
+ super("LayoutInflaterButton", "Inflate layout with 50 Button objects");
+ }
+
+ void onInit(Context context, boolean foreground) {
+ mContext = context;
+ }
+
+ boolean onRun() {
+ if (Looper.myLooper() == null) {
+ Looper.prepare();
+ }
+ LayoutInflater inf = (LayoutInflater)mContext.getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE);
+ inf.inflate(R.layout.button_layout, null);
+ return true;
+ }
+ }
+
+ static class LayoutInflaterImageButtonOp extends Op {
+ Context mContext;
+
+ LayoutInflaterImageButtonOp() {
+ super("LayoutInflaterImageButton", "Inflate layout with 50 ImageButton objects");
+ }
+
+ void onInit(Context context, boolean foreground) {
+ mContext = context;
+ }
+
+ boolean onRun() {
+ if (Looper.myLooper() == null) {
+ Looper.prepare();
+ }
+ LayoutInflater inf = (LayoutInflater)mContext.getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE);
+ inf.inflate(R.layout.image_button_layout, null);
+ return true;
+ }
+ }
+
+ static class CreateBitmapOp extends Op {
+ Context mContext;
+
+ CreateBitmapOp() {
+ super("CreateBitmap", "Create a Bitmap");
+ }
+
+ void onInit(Context context, boolean foreground) {
+ mContext = context;
+ }
+
+ boolean onRun() {
+ BitmapFactory.Options opts = new BitmapFactory.Options();
+ opts.inScreenDensity = DisplayMetrics.DENSITY_DEVICE;
+ Bitmap bm = Bitmap.createBitmap(16, 16, Bitmap.Config.ARGB_8888);
+ return true;
+ }
+ }
+
+ static class CreateRecycleBitmapOp extends Op {
+ Context mContext;
+
+ CreateRecycleBitmapOp() {
+ super("CreateRecycleBitmap", "Create and recycle a Bitmap");
+ }
+
+ void onInit(Context context, boolean foreground) {
+ mContext = context;
+ }
+
+ boolean onRun() {
+ BitmapFactory.Options opts = new BitmapFactory.Options();
+ opts.inScreenDensity = DisplayMetrics.DENSITY_DEVICE;
+ Bitmap bm = Bitmap.createBitmap(16, 16, Bitmap.Config.ARGB_8888);
+ bm.recycle();
+ return true;
+ }
+ }
+
static class LoadSmallBitmapOp extends Op {
Context mContext;
@@ -758,6 +980,26 @@
opts.inScreenDensity = DisplayMetrics.DENSITY_DEVICE;
Bitmap bm = BitmapFactory.decodeResource(mContext.getResources(),
R.drawable.stat_sample, opts);
+ return true;
+ }
+ }
+
+ static class LoadRecycleSmallBitmapOp extends Op {
+ Context mContext;
+
+ LoadRecycleSmallBitmapOp() {
+ super("LoadRecycleSmallBitmap", "Load and recycle small raw bitmap");
+ }
+
+ void onInit(Context context, boolean foreground) {
+ mContext = context;
+ }
+
+ boolean onRun() {
+ BitmapFactory.Options opts = new BitmapFactory.Options();
+ opts.inScreenDensity = DisplayMetrics.DENSITY_DEVICE;
+ Bitmap bm = BitmapFactory.decodeResource(mContext.getResources(),
+ R.drawable.stat_sample, opts);
bm.recycle();
return true;
}
@@ -779,6 +1021,26 @@
opts.inScreenDensity = DisplayMetrics.DENSITY_DEVICE;
Bitmap bm = BitmapFactory.decodeResource(mContext.getResources(),
R.drawable.wallpaper_goldengate, opts);
+ return true;
+ }
+ }
+
+ static class LoadRecycleLargeBitmapOp extends Op {
+ Context mContext;
+
+ LoadRecycleLargeBitmapOp() {
+ super("LoadRecycleLargeBitmap", "Load and recycle large raw bitmap");
+ }
+
+ void onInit(Context context, boolean foreground) {
+ mContext = context;
+ }
+
+ boolean onRun() {
+ BitmapFactory.Options opts = new BitmapFactory.Options();
+ opts.inScreenDensity = DisplayMetrics.DENSITY_DEVICE;
+ Bitmap bm = BitmapFactory.decodeResource(mContext.getResources(),
+ R.drawable.wallpaper_goldengate, opts);
bm.recycle();
return true;
}
@@ -800,7 +1062,6 @@
opts.inScreenDensity = DisplayMetrics.DENSITY_DEVICE;
Bitmap bm = BitmapFactory.decodeResource(mContext.getResources(),
R.drawable.stat_sample_scale, opts);
- bm.recycle();
return true;
}
}
@@ -821,7 +1082,6 @@
opts.inScreenDensity = DisplayMetrics.DENSITY_DEVICE;
Bitmap bm = BitmapFactory.decodeResource(mContext.getResources(),
R.drawable.wallpaper_goldengate_scale, opts);
- bm.recycle();
return true;
}
}
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pService.java b/wifi/java/android/net/wifi/p2p/WifiP2pService.java
index 1b02774..6bb22a4 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pService.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pService.java
@@ -81,7 +81,7 @@
*/
public class WifiP2pService extends IWifiP2pManager.Stub {
private static final String TAG = "WifiP2pService";
- private static final boolean DBG = true;
+ private static final boolean DBG = false;
private static final String NETWORKTYPE = "WIFI_P2P";
private Context mContext;
@@ -131,12 +131,22 @@
/* User rejected to disable Wi-Fi in order to enable p2p */
private static final int WIFI_DISABLE_USER_REJECT = BASE + 5;
+ /* User accepted a group negotiation request */
+ private static final int GROUP_NEGOTIATION_USER_ACCEPT = BASE + 6;
+ /* User rejected a group negotiation request */
+ private static final int GROUP_NEGOTIATION_USER_REJECT = BASE + 7;
+
+ /* User accepted a group invitation request */
+ private static final int GROUP_INVITATION_USER_ACCEPT = BASE + 8;
+ /* User rejected a group invitation request */
+ private static final int GROUP_INVITATION_USER_REJECT = BASE + 9;
+
/* Airplane mode changed */
- private static final int AIRPLANE_MODE_CHANGED = BASE + 6;
+ private static final int AIRPLANE_MODE_CHANGED = BASE + 10;
/* Emergency callback mode */
- private static final int EMERGENCY_CALLBACK_MODE = BASE + 7;
- private static final int WPS_PBC = BASE + 8;
- private static final int WPS_PIN = BASE + 9;
+ private static final int EMERGENCY_CALLBACK_MODE = BASE + 11;
+ private static final int WPS_PBC = BASE + 12;
+ private static final int WPS_PIN = BASE + 13;
private final boolean mP2pSupported;
@@ -260,6 +270,10 @@
private P2pEnabledState mP2pEnabledState = new P2pEnabledState();
// Inactive is when p2p is enabled with no connectivity
private InactiveState mInactiveState = new InactiveState();
+ private UserAuthorizingGroupNegotiationState mUserAuthorizingGroupNegotiationState
+ = new UserAuthorizingGroupNegotiationState();
+ private UserAuthorizingGroupInvitationState mUserAuthorizingGroupInvitationState
+ = new UserAuthorizingGroupInvitationState();
private GroupNegotiationState mGroupNegotiationState = new GroupNegotiationState();
private GroupCreatedState mGroupCreatedState = new GroupCreatedState();
@@ -290,6 +304,8 @@
addState(mP2pEnablingState, mDefaultState);
addState(mP2pEnabledState, mDefaultState);
addState(mInactiveState, mP2pEnabledState);
+ addState(mUserAuthorizingGroupNegotiationState, mInactiveState);
+ addState(mUserAuthorizingGroupInvitationState, mInactiveState);
addState(mGroupNegotiationState, mP2pEnabledState);
addState(mGroupCreatedState, mP2pEnabledState);
@@ -379,6 +395,10 @@
// Ignore
case WIFI_DISABLE_USER_ACCEPT:
case WIFI_DISABLE_USER_REJECT:
+ case GROUP_NEGOTIATION_USER_ACCEPT:
+ case GROUP_NEGOTIATION_USER_REJECT:
+ case GROUP_INVITATION_USER_ACCEPT:
+ case GROUP_INVITATION_USER_REJECT:
case GROUP_NEGOTIATION_TIMED_OUT:
break;
default:
@@ -747,6 +767,7 @@
case WifiMonitor.P2P_GO_NEGOTIATION_REQUEST_EVENT:
mSavedGoNegotiationConfig = (WifiP2pConfig) message.obj;
notifyP2pGoNegotationRequest(mSavedGoNegotiationConfig);
+ transitionTo(mUserAuthorizingGroupNegotiationState);
break;
case WifiP2pManager.CREATE_GROUP:
mPersistGroup = true;
@@ -761,6 +782,7 @@
case WifiMonitor.P2P_INVITATION_RECEIVED_EVENT:
WifiP2pGroup group = (WifiP2pGroup) message.obj;
notifyP2pInvitationReceived(group);
+ transitionTo(mUserAuthorizingGroupInvitationState);
break;
default:
return NOT_HANDLED;
@@ -769,6 +791,70 @@
}
}
+ class UserAuthorizingGroupNegotiationState extends State {
+ @Override
+ public void enter() {
+ if (DBG) logd(getName());
+ }
+
+ @Override
+ public boolean processMessage(Message message) {
+ if (DBG) logd(getName() + message.toString());
+ switch (message.what) {
+ case WifiMonitor.P2P_GO_NEGOTIATION_REQUEST_EVENT:
+ case WifiMonitor.P2P_INVITATION_RECEIVED_EVENT:
+ //Ignore additional connection requests
+ break;
+ case GROUP_NEGOTIATION_USER_ACCEPT:
+ sendMessage(WifiP2pManager.CONNECT, mSavedGoNegotiationConfig);
+ mSavedGoNegotiationConfig = null;
+ break;
+ case GROUP_NEGOTIATION_USER_REJECT:
+ if (DBG) logd("User rejected incoming negotiation request");
+ mSavedGoNegotiationConfig = null;
+ transitionTo(mInactiveState);
+ break;
+ default:
+ return NOT_HANDLED;
+ }
+ return HANDLED;
+ }
+ }
+
+ class UserAuthorizingGroupInvitationState extends State {
+ @Override
+ public void enter() {
+ if (DBG) logd(getName());
+ }
+
+ @Override
+ public boolean processMessage(Message message) {
+ if (DBG) logd(getName() + message.toString());
+ switch (message.what) {
+ case WifiMonitor.P2P_GO_NEGOTIATION_REQUEST_EVENT:
+ case WifiMonitor.P2P_INVITATION_RECEIVED_EVENT:
+ //Ignore additional connection requests
+ break;
+ case GROUP_INVITATION_USER_ACCEPT:
+ if (DBG) logd(getName() + " connect to invited group");
+ WifiP2pConfig config = new WifiP2pConfig();
+ config.deviceAddress = mSavedP2pGroup.getOwner().deviceAddress;
+ sendMessage(WifiP2pManager.CONNECT, config);
+ mSavedP2pGroup = null;
+ break;
+ case GROUP_INVITATION_USER_REJECT:
+ if (DBG) logd("User rejected incoming invitation request");
+ mSavedP2pGroup = null;
+ transitionTo(mInactiveState);
+ break;
+ default:
+ return NOT_HANDLED;
+ }
+ return HANDLED;
+ }
+ }
+
+
class GroupNegotiationState extends State {
@Override
public void enter() {
@@ -1091,15 +1177,14 @@
mSavedGoNegotiationConfig.wps.setup = WpsInfo.KEYPAD;
mSavedGoNegotiationConfig.wps.pin = pin.getText().toString();
}
- sendMessage(WifiP2pManager.CONNECT, mSavedGoNegotiationConfig);
- mSavedGoNegotiationConfig = null;
+ sendMessage(GROUP_NEGOTIATION_USER_ACCEPT);
}
})
.setNegativeButton(r.getString(R.string.cancel), new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (DBG) logd(getName() + " ignore connect");
- mSavedGoNegotiationConfig = null;
+ sendMessage(GROUP_NEGOTIATION_USER_REJECT);
}
})
.create();
@@ -1180,14 +1265,16 @@
.setView(textEntryView)
.setPositiveButton(r.getString(R.string.ok), new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
- WifiP2pConfig config = new WifiP2pConfig();
- config.deviceAddress = mSavedP2pGroup.getOwner().deviceAddress;
- if (DBG) logd(getName() + " connect to invited group");
- sendMessage(WifiP2pManager.CONNECT, config);
- mSavedP2pGroup = null;
+ sendMessage(GROUP_INVITATION_USER_ACCEPT);
}
})
- .setNegativeButton(r.getString(R.string.cancel), null)
+ .setNegativeButton(r.getString(R.string.cancel), new OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ if (DBG) logd(getName() + " ignore invite");
+ sendMessage(GROUP_INVITATION_USER_REJECT);
+ }
+ })
.create();
pin.setVisibility(View.GONE);