Merge "Add libinput native tests."
diff --git a/build/sdk.atree b/build/sdk.atree
index 1391476..cceec19 100644
--- a/build/sdk.atree
+++ b/build/sdk.atree
@@ -60,7 +60,7 @@
sdk/sdk-build.prop platforms/${PLATFORM_NAME}/build.prop
# the uper-jar file that apps link against. This is the public API
-out/target/common/obj/PACKAGING/android_jar_intermediates/android.jar platforms/${PLATFORM_NAME}/android.jar
+${OUT_DIR}/target/common/obj/PACKAGING/android_jar_intermediates/android.jar platforms/${PLATFORM_NAME}/android.jar
# the aidl precompiled include
obj/framework.aidl platforms/${PLATFORM_NAME}/framework.aidl
diff --git a/ndk/platforms/android-3/arch-arm/include/asm/byteorder.h b/ndk/platforms/android-3/arch-arm/include/asm/byteorder.h
index 4da37bf..b869695 100644
--- a/ndk/platforms/android-3/arch-arm/include/asm/byteorder.h
+++ b/ndk/platforms/android-3/arch-arm/include/asm/byteorder.h
@@ -22,7 +22,7 @@
#ifndef __thumb__
if (!__builtin_constant_p(x)) {
- asm ("eor\t%0, %1, %1, ror #16" : "=r" (t) : "r" (x));
+ __asm__ ("eor\t%0, %1, %1, ror #16" : "=r" (t) : "r" (x));
} else
#endif
t = x ^ ((x << 16) | (x >> 16));
diff --git a/samples/ApiDemos/AndroidManifest.xml b/samples/ApiDemos/AndroidManifest.xml
index 21a85e0..d73fa39 100644
--- a/samples/ApiDemos/AndroidManifest.xml
+++ b/samples/ApiDemos/AndroidManifest.xml
@@ -174,7 +174,8 @@
</intent-filter>
</activity>
- <activity android:name=".app.SendResult">
+ <activity android:name=".app.SendResult"
+ android:theme="@android:style/Theme.Holo.DialogWhenLarge">
</activity>
<activity android:name=".app.Forwarding" android:label="@string/activity_forwarding">
@@ -250,8 +251,9 @@
</intent-filter>
</activity>
- <activity android:name=".app.FragmentAnim"
- android:label="@string/fragment_anim">
+ <activity android:name=".app.FragmentHideShow"
+ android:label="@string/fragment_hide_show"
+ android:windowSoftInputMode="stateUnchanged">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
diff --git a/samples/ApiDemos/res/layout-land/fragment_layout.xml b/samples/ApiDemos/res/layout-land/fragment_layout.xml
index 5c512f0..c1ef203 100644
--- a/samples/ApiDemos/res/layout-land/fragment_layout.xml
+++ b/samples/ApiDemos/res/layout-land/fragment_layout.xml
@@ -26,9 +26,9 @@
android:id="@+id/titles" android:layout_weight="1"
android:layout_width="0px" android:layout_height="match_parent" />
- <fragment class="com.example.android.apis.app.FragmentLayout$DetailsFragment"
- android:id="@+id/details" android:layout_weight="1"
- android:layout_width="0px" android:layout_height="match_parent" />
+ <FrameLayout android:id="@+id/details" android:layout_weight="1"
+ android:layout_width="0px" android:layout_height="match_parent"
+ android:background="?android:attr/detailsElementBackground" />
</LinearLayout>
<!-- END_INCLUDE(layout) -->
diff --git a/samples/ApiDemos/res/layout/fragment_context_menu.xml b/samples/ApiDemos/res/layout/fragment_context_menu.xml
index 8f2c044..b5dac8e 100644
--- a/samples/ApiDemos/res/layout/fragment_context_menu.xml
+++ b/samples/ApiDemos/res/layout/fragment_context_menu.xml
@@ -24,6 +24,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
+ android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/fragment_context_menu_msg" />
<Button android:id="@+id/long_press"
diff --git a/samples/ApiDemos/res/layout/fragment_dialog.xml b/samples/ApiDemos/res/layout/fragment_dialog.xml
index e03f64f..f9dec59 100644
--- a/samples/ApiDemos/res/layout/fragment_dialog.xml
+++ b/samples/ApiDemos/res/layout/fragment_dialog.xml
@@ -27,6 +27,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical|center_horizontal"
+ android:textAppearance="?android:attr/textAppearanceMedium"
android:gravity="top|center_horizontal" />
<Button android:id="@+id/show"
diff --git a/samples/ApiDemos/res/layout/fragment_dialog_or_activity.xml b/samples/ApiDemos/res/layout/fragment_dialog_or_activity.xml
index eb95e14..295f017 100644
--- a/samples/ApiDemos/res/layout/fragment_dialog_or_activity.xml
+++ b/samples/ApiDemos/res/layout/fragment_dialog_or_activity.xml
@@ -28,6 +28,7 @@
android:layout_weight="0"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="top|center_horizontal"
+ android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/fragment_dialog_or_activity_msg" />
<Button android:id="@+id/show_dialog"
@@ -47,6 +48,7 @@
android:layout_height="wrap_content"
android:layout_weight="0"
android:layout_gravity="center_vertical|center_horizontal"
+ android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/fragment_dialog_or_activity_inline" />
<FrameLayout
diff --git a/samples/ApiDemos/res/layout/fragment_anim.xml b/samples/ApiDemos/res/layout/fragment_hide_show.xml
similarity index 78%
rename from samples/ApiDemos/res/layout/fragment_anim.xml
rename to samples/ApiDemos/res/layout/fragment_hide_show.xml
index 8bec894..9f13295 100644
--- a/samples/ApiDemos/res/layout/fragment_anim.xml
+++ b/samples/ApiDemos/res/layout/fragment_hide_show.xml
@@ -4,9 +4,9 @@
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.
@@ -21,34 +21,37 @@
android:gravity="center_horizontal"
android:layout_width="match_parent" android:layout_height="match_parent">
+ <TextView android:layout_width="match_parent" android:layout_height="wrap_content"
+ android:gravity="center_vertical|center_horizontal"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:text="Demonstration of hiding and showing fragments." />
+
<LinearLayout android:orientation="horizontal" android:padding="4dip"
android:gravity="center_vertical" android:layout_weight="1"
- android:layout_width="wrap_content" android:layout_height="wrap_content">
-
- <fragment android:name="com.example.android.apis.app.FragmentAnim$FirstFragment"
- android:id="@+id/fragment1" android:layout_weight="1"
- android:layout_width="0px" android:layout_height="wrap_content" />
+ android:layout_width="match_parent" android:layout_height="wrap_content">
<Button android:id="@+id/frag1hide"
android:layout_width="wrap_content" android:layout_height="wrap_content"
- android:text="Hide">
- </Button>
-
+ android:text="Hide" />
+
+ <fragment android:name="com.example.android.apis.app.FragmentHideShow$FirstFragment"
+ android:id="@+id/fragment1" android:layout_weight="1"
+ android:layout_width="0px" android:layout_height="wrap_content" />
+
</LinearLayout>
-
+
<LinearLayout android:orientation="horizontal" android:padding="4dip"
android:gravity="center_vertical" android:layout_weight="1"
- android:layout_width="wrap_content" android:layout_height="wrap_content">
-
- <fragment android:name="com.example.android.apis.app.FragmentAnim$SecondFragment"
- android:id="@+id/fragment2" android:layout_weight="1"
- android:layout_width="0px" android:layout_height="wrap_content" />
+ android:layout_width="match_parent" android:layout_height="wrap_content">
<Button android:id="@+id/frag2hide"
android:layout_width="wrap_content" android:layout_height="wrap_content"
- android:text="Hide">
- </Button>
-
+ android:text="Hide" />
+
+ <fragment android:name="com.example.android.apis.app.FragmentHideShow$SecondFragment"
+ android:id="@+id/fragment2" android:layout_weight="1"
+ android:layout_width="0px" android:layout_height="wrap_content" />
+
</LinearLayout>
-
+
</LinearLayout>
diff --git a/samples/ApiDemos/res/layout/fragment_menu.xml b/samples/ApiDemos/res/layout/fragment_menu.xml
index b2d3c52..7f0278c 100644
--- a/samples/ApiDemos/res/layout/fragment_menu.xml
+++ b/samples/ApiDemos/res/layout/fragment_menu.xml
@@ -24,6 +24,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
+ android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/fragment_menu_msg" />
<CheckBox android:id="@+id/menu1"
diff --git a/samples/ApiDemos/res/layout/fragment_retain_instance.xml b/samples/ApiDemos/res/layout/fragment_retain_instance.xml
index e9a9a43..0dc3985 100644
--- a/samples/ApiDemos/res/layout/fragment_retain_instance.xml
+++ b/samples/ApiDemos/res/layout/fragment_retain_instance.xml
@@ -24,6 +24,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
+ android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/fragment_retain_instance_msg" />
<ProgressBar android:id="@+id/progress_horizontal"
diff --git a/samples/ApiDemos/res/layout/hello_world.xml b/samples/ApiDemos/res/layout/hello_world.xml
index 0282076..3d90a33 100644
--- a/samples/ApiDemos/res/layout/hello_world.xml
+++ b/samples/ApiDemos/res/layout/hello_world.xml
@@ -22,4 +22,5 @@
<TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/text"
android:layout_width="match_parent" android:layout_height="match_parent"
android:gravity="center_vertical|center_horizontal"
+ android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/hello_world"/>
diff --git a/samples/ApiDemos/res/layout/receive_result.xml b/samples/ApiDemos/res/layout/receive_result.xml
index a894612..5deb2ac 100644
--- a/samples/ApiDemos/res/layout/receive_result.xml
+++ b/samples/ApiDemos/res/layout/receive_result.xml
@@ -27,12 +27,15 @@
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_weight="0"
android:paddingBottom="4dip"
+ android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/receive_result_instructions"/>
<TextView android:id="@+id/results"
android:layout_width="match_parent" android:layout_height="10dip"
android:layout_weight="1"
android:paddingBottom="4dip"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="#000"
android:background="@drawable/green">
</TextView>
diff --git a/samples/ApiDemos/res/values/strings.xml b/samples/ApiDemos/res/values/strings.xml
index 766830d..ae041a6 100644
--- a/samples/ApiDemos/res/values/strings.xml
+++ b/samples/ApiDemos/res/values/strings.xml
@@ -108,7 +108,7 @@
<string name="fragment_alert_dialog">App/Fragment/Alert Dialog</string>
- <string name="fragment_anim">App/Fragment/Anim</string>
+ <string name="fragment_hide_show">App/Fragment/Hide and Show</string>
<string name="fragment_context_menu">App/Fragment/Context Menu</string>
<string name="fragment_context_menu_msg">Fragment populating a context
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/Animation.java b/samples/ApiDemos/src/com/example/android/apis/app/Animation.java
index 5ba41c4..bd2bd89 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/Animation.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/Animation.java
@@ -30,10 +30,7 @@
/**
- * <p>Example of explicitly starting and stopping the {@link LocalService}.
- * This demonstrates the implementation of a service that runs in the same
- * process as the rest of the application, which is explicitly started and stopped
- * as desired.</p>
+ * <p>Example of using a custom animation when transitioning between activities.</p>
*/
public class Animation extends Activity {
@Override
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/ForegroundService.java b/samples/ApiDemos/src/com/example/android/apis/app/ForegroundService.java
index f1513ac..9f84be1 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/ForegroundService.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/ForegroundService.java
@@ -49,17 +49,33 @@
static final String ACTION_BACKGROUND = "com.example.android.apis.BACKGROUND";
// BEGIN_INCLUDE(foreground_compatibility)
+ private static final Class<?>[] mSetForegroundSignature = new Class[] {
+ boolean.class};
private static final Class<?>[] mStartForegroundSignature = new Class[] {
int.class, Notification.class};
private static final Class<?>[] mStopForegroundSignature = new Class[] {
boolean.class};
private NotificationManager mNM;
+ private Method mSetForeground;
private Method mStartForeground;
private Method mStopForeground;
+ private Object[] mSetForegroundArgs = new Object[1];
private Object[] mStartForegroundArgs = new Object[2];
private Object[] mStopForegroundArgs = new Object[1];
+ void invokeMethod(Method method, Object[] args) {
+ try {
+ mStartForeground.invoke(this, mStartForegroundArgs);
+ } catch (InvocationTargetException e) {
+ // Should not happen.
+ Log.w("ApiDemos", "Unable to invoke method", e);
+ } catch (IllegalAccessException e) {
+ // Should not happen.
+ Log.w("ApiDemos", "Unable to invoke method", e);
+ }
+ }
+
/**
* This is a wrapper around the new startForeground method, using the older
* APIs if it is not available.
@@ -69,20 +85,13 @@
if (mStartForeground != null) {
mStartForegroundArgs[0] = Integer.valueOf(id);
mStartForegroundArgs[1] = notification;
- try {
- mStartForeground.invoke(this, mStartForegroundArgs);
- } catch (InvocationTargetException e) {
- // Should not happen.
- Log.w("ApiDemos", "Unable to invoke startForeground", e);
- } catch (IllegalAccessException e) {
- // Should not happen.
- Log.w("ApiDemos", "Unable to invoke startForeground", e);
- }
+ invokeMethod(mStartForeground, mStartForegroundArgs);
return;
}
// Fall back on the old API.
- //setForeground(true);
+ mSetForegroundArgs[0] = Boolean.TRUE;
+ invokeMethod(mSetForeground, mSetForegroundArgs);
mNM.notify(id, notification);
}
@@ -109,7 +118,8 @@
// Fall back on the old API. Note to cancel BEFORE changing the
// foreground state, since we could be killed at that point.
mNM.cancel(id);
- //setForeground(false);
+ mSetForegroundArgs[0] = Boolean.FALSE;
+ invokeMethod(mSetForeground, mSetForegroundArgs);
}
@Override
@@ -123,6 +133,14 @@
} catch (NoSuchMethodException e) {
// Running on an older platform.
mStartForeground = mStopForeground = null;
+ return;
+ }
+ try {
+ mSetForeground = getClass().getMethod("setForeground",
+ mSetForegroundSignature);
+ } catch (NoSuchMethodException e) {
+ throw new IllegalStateException(
+ "OS doesn't have Service.startForeground OR Service.setForeground!");
}
}
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/FragmentAlertDialog.java b/samples/ApiDemos/src/com/example/android/apis/app/FragmentAlertDialog.java
index abf9731..56ddc6b 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/FragmentAlertDialog.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/FragmentAlertDialog.java
@@ -30,6 +30,9 @@
import android.widget.Button;
import android.widget.TextView;
+/**
+ * Demonstrates how to show an AlertDialog that is managed by a Fragment.
+ */
public class FragmentAlertDialog extends Activity {
@Override
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/FragmentAnim.java b/samples/ApiDemos/src/com/example/android/apis/app/FragmentHideShow.java
similarity index 82%
rename from samples/ApiDemos/src/com/example/android/apis/app/FragmentAnim.java
rename to samples/ApiDemos/src/com/example/android/apis/app/FragmentHideShow.java
index 42345a0..9e9661a 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/FragmentAnim.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/FragmentHideShow.java
@@ -20,45 +20,46 @@
import android.app.Activity;
import android.app.Fragment;
+import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
-import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.TextView;
/**
- * Demonstration of animations when changing fragment states.
+ * Demonstration of hiding and showing fragments.
*/
-public class FragmentAnim extends Activity {
+public class FragmentHideShow extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.fragment_anim);
+ setContentView(R.layout.fragment_hide_show);
- addShowHideListener(R.id.frag1hide, findFragmentById(R.id.fragment1));
- addShowHideListener(R.id.frag2hide, findFragmentById(R.id.fragment2));
+ // The content view embeds two fragments; now retrieve them and attach
+ // their "hide" button.
+ FragmentManager fm = getFragmentManager();
+ addShowHideListener(R.id.frag1hide, fm.findFragmentById(R.id.fragment1));
+ addShowHideListener(R.id.frag2hide, fm.findFragmentById(R.id.fragment2));
}
void addShowHideListener(int buttonId, final Fragment fragment) {
final Button button = (Button)findViewById(buttonId);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
- FragmentTransaction ft = openFragmentTransaction();
+ FragmentTransaction ft = getFragmentManager().openTransaction();
ft.setCustomAnimations(android.R.anim.animator_fade_in,
android.R.anim.animator_fade_out);
if (fragment.isHidden()) {
- button.setAnimation(AnimationUtils.loadAnimation(
- FragmentAnim.this, android.R.anim.slide_in_left));
ft.show(fragment);
+ button.setText("Hide");
} else {
- button.setAnimation(AnimationUtils.loadAnimation(
- FragmentAnim.this, android.R.anim.slide_out_right));
ft.hide(fragment);
+ button.setText("Show");
}
ft.commit();
}
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/FragmentLayout.java b/samples/ApiDemos/src/com/example/android/apis/app/FragmentLayout.java
index a63685e..f959d00 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/FragmentLayout.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/FragmentLayout.java
@@ -21,11 +21,11 @@
import android.app.Activity;
import android.app.Fragment;
+import android.app.FragmentTransaction;
import android.app.ListFragment;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
-import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
@@ -73,17 +73,23 @@
if (savedInstanceState == null) {
// During initial setup, plug in the details fragment.
DetailsFragment details = new DetailsFragment();
+ details.setArguments(getIntent().getExtras());
getFragmentManager().openTransaction().add(android.R.id.content, details).commit();
- details.setText(getIntent().getIntExtra("text", -1));
}
}
}
//END_INCLUDE(details_activity)
+ /**
+ * This is the "top-level" fragment, showing a list of items that the
+ * user can pick. Upon picking an item, it takes care of displaying the
+ * data to the user as appropriate based on the currrent UI layout.
+ */
//BEGIN_INCLUDE(titles)
public static class TitlesFragment extends ListFragment {
- DetailsFragment mDetails;
+ boolean mDualPane;
int mCurCheckPosition = 0;
+ int mShownCheckPosition = -1;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
@@ -93,17 +99,22 @@
setListAdapter(new ArrayAdapter<String>(getActivity(),
android.R.layout.simple_list_item_activated_1, Shakespeare.TITLES));
- // Restore last state for checked position.
+ // Check to see if we have a frame in which to embed the details
+ // fragment directly in the containing UI.
+ View detailsFrame = getActivity().findViewById(R.id.details);
+ mDualPane = detailsFrame != null && detailsFrame.getVisibility() == View.VISIBLE;
+
if (savedInstanceState != null) {
+ // Restore last state for checked position.
mCurCheckPosition = savedInstanceState.getInt("curChoice", 0);
+ mShownCheckPosition = savedInstanceState.getInt("shownChoice", -1);
}
- // If we are showing details in the screen, set up the list to highlight.
- mDetails = (DetailsFragment)getFragmentManager().findFragmentById(R.id.details);
- if (mDetails != null && mDetails.isInLayout()) {
+ if (mDualPane) {
+ // In dual-pane mode, the list view highlights the selected item.
getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
- getListView().setItemChecked(mCurCheckPosition, true);
- mDetails.setText(mCurCheckPosition);
+ // Make sure our UI is in the correct state.
+ showDetails(mCurCheckPosition);
}
}
@@ -111,67 +122,97 @@
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt("curChoice", mCurCheckPosition);
+ outState.putInt("shownChoice", mShownCheckPosition);
}
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
- mCurCheckPosition = position;
+ showDetails(position);
+ }
- if (mDetails != null && mDetails.isVisible()) {
- // If the activity has a fragment to display the dialog,
- // point it to what the user has selected.
- mDetails.setText(position);
- getListView().setItemChecked(position, true);
+ /**
+ * Helper function to show the details of a selected item, either by
+ * displaying a fragment in-place in the current UI, or starting a
+ * whole new activity in which it is displayed.
+ */
+ void showDetails(int index) {
+ mCurCheckPosition = index;
+
+ if (mDualPane) {
+ // We can display everything in-place with fragments, so update
+ // the list to highlight the selected item and show the data.
+ getListView().setItemChecked(index, true);
+
+ if (mShownCheckPosition != mCurCheckPosition) {
+ // If we are not currently showing a fragment for the new
+ // position, we need to create and install a new one.
+ DetailsFragment df = DetailsFragment.newInstance(index);
+
+ // Execute a transaction, replacing any existing fragment
+ // with this one inside the frame.
+ FragmentTransaction ft = getFragmentManager().openTransaction();
+ ft.replace(R.id.details, df);
+ ft.setTransition(index > mCurCheckPosition
+ ? FragmentTransaction.TRANSIT_FRAGMENT_NEXT
+ : FragmentTransaction.TRANSIT_FRAGMENT_PREV);
+ ft.commit();
+ mShownCheckPosition = index;
+ }
+
} else {
// Otherwise we need to launch a new activity to display
// the dialog fragment with selected text.
Intent intent = new Intent();
intent.setClass(getActivity(), DetailsActivity.class);
- intent.putExtra("text", position);
+ intent.putExtra("index", index);
startActivity(intent);
}
}
}
//END_INCLUDE(titles)
+ /**
+ * This is the secondary fragment, displaying the details of a particular
+ * item.
+ */
//BEGIN_INCLUDE(details)
public static class DetailsFragment extends Fragment {
- int mDisplayedText = -1;
- TextView mText;
+ /**
+ * Create a new instance of DetailsFragment, initialized to
+ * show the text at 'index'.
+ */
+ public static DetailsFragment newInstance(int index) {
+ DetailsFragment f = new DetailsFragment();
- public void setText(int id) {
- mDisplayedText = id;
- if (mText != null && id >= 0) {
- mText.setText(Shakespeare.DIALOGUE[id]);
- }
- }
+ // Supply index input as an argument.
+ Bundle args = new Bundle();
+ args.putInt("index", index);
+ f.setArguments(args);
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- if (savedInstanceState != null) {
- mDisplayedText = savedInstanceState.getInt("text", -1);
- }
- }
-
- @Override
- public void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- outState.putInt("text", mDisplayedText);
+ return f;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
+ if (container == null) {
+ // We have different layouts, and in one of them this
+ // fragment's containing frame doesn't exist. The fragment
+ // may still be created from its saved state, but there is
+ // no reason to try to create its view hierarchy because it
+ // won't be displayed. Note this is not needed -- we could
+ // just run the code below, where we would create and return
+ // the view hierarchy; it would just never be used.
+ return null;
+ }
+
ScrollView scroller = new ScrollView(getActivity());
- mText = new TextView(getActivity());
+ TextView text = new TextView(getActivity());
int padding = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
4, getActivity().getResources().getDisplayMetrics());
- mText.setPadding(padding, padding, padding, padding);
- scroller.addView(mText);
- if (mDisplayedText >= 0) {
- mText.setText(Shakespeare.DIALOGUE[mDisplayedText]);
- }
+ text.setPadding(padding, padding, padding, padding);
+ scroller.addView(text);
+ text.setText(Shakespeare.DIALOGUE[getArguments().getInt("index", 0)]);
return scroller;
}
}
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/FragmentStack.java b/samples/ApiDemos/src/com/example/android/apis/app/FragmentStack.java
index 2aa9a12..6710a2d 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/FragmentStack.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/FragmentStack.java
@@ -116,6 +116,7 @@
View v = inflater.inflate(R.layout.hello_world, container, false);
View tv = v.findViewById(R.id.text);
((TextView)tv).setText("Fragment #" + mNum);
+ tv.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.gallery_thumb));
return v;
}
}
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/_index.html b/samples/ApiDemos/src/com/example/android/apis/app/_index.html
index fff5ce2..6fe2d4c 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/_index.html
+++ b/samples/ApiDemos/src/com/example/android/apis/app/_index.html
@@ -37,47 +37,131 @@
<dt><a href="TranslucentBlurActivity.html">TranslucentBlur</a></dt>
<dd>Demonstrates how to make an activity with a transparent background with
a special effect (blur). </dd>
+
+ <dt><a href="DialogActivity.html">Dialog Activity</a></dt>
+ <dd>An Activity that sets its theme to android:style/Theme.Dialog so that
+ it looks like a Dialog.</dd>
+
+ <dt><a href="CustomTitle.html">Custom Title</a></dt>
+ <dd>An Activity that places a custom UI in its title.</dd>
+
+ <dt><a href="Animation.html">Animation</a></dt>
+ <dd>Demonstrates how to use custom animations when moving between activities. </dd>
+
+ <dt><a href="ActivityRecreate.html">Activity Recreate</a></dt>
+ <dd>Demonstrates how an Activity can cause itself to be recreated.</dd>
+
+ <dt><a href="ScreenOrientation.html">Screen Orientation</a></dt>
+ <dd>Demonstrates the different screen orientations an Activity can request.</dd>
+
+ <dt><a href="SoftInputModes.html">Soft Input Modes</a></dt>
+ <dd>Demonstrates how different soft input modes set in an Activity's
+ window impacts how it adjusts to accommodate an IME.</dd>
+
+ <dt><a href="IntentActivityFlags.html">Intent Activity Flags</a></dt>
+ <dd>Demonstrates various uses of Intent flags to modify an application
+ task's activity stack in common ways.</dd>
+
+ <dt><a href="ReorderOnLaunch.html">Reorder on Launch</a></dt>
+ <dd>Demonstrates how the activities in a task can be reordered. UI flow
+ goes through the activities <a href="ReorderOnLaunch.html">ReorderOnLaunch</a>,
+ <a href="ReorderTwo.html">ReorderTwo</a>, <a href="ReorderThree.html">ReorderThree</a>,
+ and <a href="ReorderFour.html">ReorderFour</a>.</dd>
+
+ <dt><a href="WallpaperActivity.html">Wallpaper Activity</a></dt>
+ <dd>An Activity that uses android:style/Theme.Wallpaper to be displayed
+ on top of the system wallpaper.</dd>
+</dl>
+
+<h3>Fragment</h3>
+<dl>
+ <dt><a href="FragmentAlertDialog.html">Fragment Alert Dialog</a></dt>
+ <dd>Demonstrates how to use a DialogFragment to show and manage an
+ AlertDialog.</dd>
+
+ <dt><a href="FragmentContextMenu.html">Fragment Context Menu</a></dt>
+ <dd>Demonstrates how to display and respond to a context menu that is
+ display from a fragment's view hierarchy.</dd>
+
+ <dt><a href="FragmentDialog.html">Fragment Dialog</a></dt>
+ <dd>Demonstrates use of DialogFragment to show various types of dialogs.</dd>
+
+ <dt><a href="FragmentDialogOrActivity.html">Fragment Dialog or Activity</a></dt>
+ <dd>Demonstrates how the same Fragment implementation can be used to provide the UI
+ for either an Activity or Dialog.</dd>
+
+ <dt><a href="FragmentHideShow.html">Fragment Hide Show</a></dt>
+ <dd>Demonstrates hiding and showing fragments.</dd>
+
+ <dt><a href="FragmentLayout.html">Fragment Layout</a></dt>
+ <dd>Demonstrates use of the <fragment> tag to embed a Fragment in
+ an Activity's content view layout, and making the layout change based on
+ configuration to achieve different UI flows.</dd>
+
+ <dt><a href="FragmentListArray.html">Fragment List Array</a></dt>
+ <dd>Demonstrates use of ListFragment to show the contents of a simple ArrayAdapter.</dd>
+
+ <dt><a href="FragmentCursorLoader.html">Fragment List Cursor Loader</a></dt>
+ <dd>Demonstrates use of LoaderManager to perform a query for a Cursor that
+ populates a ListFragment.</dd>
+
+ <dt><a href="FragmentMenu.html">Fragment Menu</a></dt>
+ <dd>Demonstrates populating custom menu items from a Fragment.</dd>
+
+ <dt><a href="FragmentReceiveResult.html">Fragment Receive Result</a></dt>
+ <dd>Demonstrates starting a new Activity from a Fragment, and receiving
+ a result back from it.</dd>
+
+ <dt><a href="FragmentRetainInstance.html">Fragment Retain Instance</a></dt>
+ <dd>Demonstrates a Fragment can be used to easily retain active state across
+ an Activity's configuration change.</dd>
+
+ <dt><a href="FragmentStack.html">Fragment Stack</a></dt>
+ <dd>Demonstrates creating a stack of Fragment instances similar to the
+ traditional stack of activities.</dd>
+
</dl>
<h3>Service</h3>
<dl>
- <dt><a href="LocalService.html">Local Service Controller and
- Local Service Binding</a></dt>
+ <dt><a href="LocalService.html">Local Service</a></dt>
<dd>Demonstrate the implementation of a service that runs in the same
process as its client(s). Shows how those clients can either start/stop it
- with {@link android.content.Context#startService
- Context.startService} and {@link android.content.Context#stopService
- Context.stopService}, or bind and call it with
- {@link android.content.Context#bindService Context.bindService} and
- {@link android.content.Context#unbindService Context.unindService}.
+ with Context.startService and Context.stopService, or bind and call it with
+ Context.bindService and Context.unindService.
This also shows how you can simplify working
- with a service when you know it will only run in your own process.</dd>
+ with a service when you know it will only run in your own process. The client
+ code for interacting with the service is in
+ <a href="LocalServiceActivities.html">Local Service Activities</a>.</dd>
+
+ <dt><a href="MessengerService.html">Messenger Service</a></dt>
+ <dd>Demonstrates binding to a Service whose interface is implemented with
+ the Messenger class. This is often an easier way to do remote communication
+ with a Service than using a raw AIDL interface. The client
+ code for interacting with the service is in
+ <a href="MessengerServiceActivities.html">Messenger Service Activities</a>.</dd>
<dt><a href="RemoteService.html">Remote Service Controller and
Remove Service Binding</a></dt>
<dd>Demonstrates starting a service in a separate process, by assigning
<code>android:process=":remote"</code> to the service in the
AndroidManifest.xml file. Shows how those clients can either start/stop it
- with {@link android.content.Context#startService
- Context.startService} and {@link android.content.Context#stopService
- Context.stopService}, or bind and call it with
- {@link android.content.Context#bindService Context.bindService} and
- {@link android.content.Context#unbindService Context.unindService}.
+ with Context.startService and Context.stopService, or bind and call it with
+ Context.bindService and Context.unindService.
Binding is similar to the local service sample,
but illustrates the additional work (defining aidl
interfaces) needed to interact with a service in another process. Also
shows how a service can publish multiple interfaces and implement
callbacks to its clients.</dd>
- <dt><a href="ServiceStartArguments.html">Service Start Arguments Controller</a></dt>
+ <dt><a href="ServiceStartArguments.html">Service Start Arguments</a></dt>
<dd>Demonstrates how you can use a Service as a job queue, where you
- submit jobs to it with {@link android.content.Context#startService
- Context.startService} instead of binding to the service. Such a service
+ submit jobs to it with Context.startService instead of binding to the service. Such a service
automatically stops itself once all jobs have been processed. This can be
a very convenient way to interact with a service when you do not need
a result back from it.</dd>
- <dt><a href="ForegroundService.html">Foreground Service Controller</a></dt>
+ <dt><a href="ForegroundService.html">Foreground Service</a></dt>
<dd>Shows how you
can write a Service that runs in the foreground and works on both pre-2.0
and post-2.0 versions of the platform. This example will selectively use
@@ -126,6 +210,10 @@
<dt><a href="IncomingMessage.html">IncomingMessage</a></dt>
<dd> Demonstrates sending persistent and transient notifications, with a View object in the notification. It also demonstrated inflating a View object from an XML layout resource. </dd>
+
+ <dt><a href="StatusBarNotifications.html">Status Bar Notifications</a></dt>
+ <dd> Demonstrates a variety of different notifications that can be posted in
+ the status bar, and a standard way for handling them.</dd>
</dl>
<h3>Search</h3>
@@ -141,3 +229,12 @@
</dl>
+<h3>Misc</h3>
+<dl>
+ <dt><a href="AlertDialogSamples.html">Alert Dialog Samples</a></dt>
+ <dd>Demonstrates various styles of alert dialogs.</dd>
+
+ <dt><a href="DeviceAdminSample.html">Device Admin Sample</a></dt>
+ <dd>Demonstration of the implementation of a simple device administrator
+ and its use of the DevicePolicyManager.</dd>
+</dl>
diff --git a/samples/BrowserPlugin/jni/Android.mk b/samples/BrowserPlugin/jni/Android.mk
index d444bb0..b153e37 100644
--- a/samples/BrowserPlugin/jni/Android.mk
+++ b/samples/BrowserPlugin/jni/Android.mk
@@ -30,7 +30,9 @@
LOCAL_SRC_FILES := \
main.cpp \
PluginObject.cpp \
+ RenderingThread.cpp \
animation/AnimationPlugin.cpp \
+ animation/AnimationThread.cpp \
audio/AudioPlugin.cpp \
background/BackgroundPlugin.cpp \
form/FormPlugin.cpp \
@@ -52,10 +54,16 @@
external/webkit/WebCore/bridge \
external/webkit/WebCore/plugins \
external/webkit/WebCore/platform/android/JavaVM \
- external/webkit/WebKit/android/plugins
+ external/webkit/WebKit/android/plugins \
+ external/skia/include/core
LOCAL_SHARED_LIBRARIES := \
- libnativehelper
+ libnativehelper \
+ libutils \
+ libcutils \
+ libEGL \
+ libGLESv2 \
+ libskia
LOCAL_CFLAGS += -fvisibility=hidden
LOCAL_PRELINK_MODULE:=false
diff --git a/samples/BrowserPlugin/jni/PluginObject.cpp b/samples/BrowserPlugin/jni/PluginObject.cpp
index dd0fbac..16925c8 100644
--- a/samples/BrowserPlugin/jni/PluginObject.cpp
+++ b/samples/BrowserPlugin/jni/PluginObject.cpp
@@ -45,6 +45,10 @@
return obj->window->height;
}
+SurfaceSubPlugin::~SurfaceSubPlugin() {
+ setContext(NULL);
+}
+
bool SurfaceSubPlugin::supportsDrawingModel(ANPDrawingModel model) {
return (model == kSurface_ANPDrawingModel);
}
diff --git a/samples/BrowserPlugin/jni/PluginObject.h b/samples/BrowserPlugin/jni/PluginObject.h
index 296749a..e0f4424 100644
--- a/samples/BrowserPlugin/jni/PluginObject.h
+++ b/samples/BrowserPlugin/jni/PluginObject.h
@@ -63,7 +63,7 @@
class SurfaceSubPlugin : public SubPlugin {
public:
SurfaceSubPlugin(NPP inst) : SubPlugin(inst) { m_context = NULL; }
- virtual ~SurfaceSubPlugin() {}
+ virtual ~SurfaceSubPlugin();
virtual jobject getSurface() = 0;
virtual bool supportsDrawingModel(ANPDrawingModel);
diff --git a/samples/BrowserPlugin/jni/RenderingThread.cpp b/samples/BrowserPlugin/jni/RenderingThread.cpp
new file mode 100644
index 0000000..7f267ed
--- /dev/null
+++ b/samples/BrowserPlugin/jni/RenderingThread.cpp
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2010, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "RenderingThread.h"
+
+#include "ANPOpenGL_npapi.h"
+
+extern ANPLogInterfaceV0 gLogI;
+extern ANPOpenGLInterfaceV0 gOpenGLI;
+
+RenderingThread::RenderingThread(NPP npp) : android::Thread() {
+ m_npp = npp;
+ m_width = -1;
+ m_height = -1;
+ gLogI.log(kError_ANPLogType, "Created Rendering Thread");
+}
+
+android::status_t RenderingThread::readyToRun() {
+
+ gLogI.log(kError_ANPLogType, "in ready to run");
+
+ EGLContext context = gOpenGLI.acquireContext(m_npp);
+
+ gLogI.log(kError_ANPLogType, "context: %p", context);
+
+ if (context == EGL_NO_CONTEXT) {
+ gLogI.log(kError_ANPLogType, "Unable to create EGLContext for a TextureProducer thread");
+ return android::UNKNOWN_ERROR;
+ }
+ return android::NO_ERROR;
+}
+
+void RenderingThread::setDimensions(int width, int height) {
+ android::Mutex::Autolock lock(m_sync);
+ m_width = width;
+ m_height = height;
+}
+
+void RenderingThread::getDimensions(int& width, int& height) {
+ android::Mutex::Autolock lock(m_sync);
+ width = m_width;
+ height = m_height;
+}
+
+void RenderingThread::printGLString(const char *name, GLenum s) {
+ const char *v = (const char *) glGetString(s);
+ gLogI.log(kError_ANPLogType, "GL %s = %s\n", name, v);
+}
+
+void RenderingThread::checkGlError(const char* op) {
+ for (GLint error = glGetError(); error; error
+ = glGetError()) {
+ gLogI.log(kError_ANPLogType, "after %s() glError (0x%x)\n", op, error);
+ }
+}
+
+GLenum RenderingThread::getInternalFormat(SkBitmap::Config config)
+{
+ switch(config) {
+ case SkBitmap::kA8_Config:
+ return GL_ALPHA;
+ case SkBitmap::kARGB_4444_Config:
+ return GL_RGBA;
+ case SkBitmap::kARGB_8888_Config:
+ return GL_RGBA;
+ case SkBitmap::kRGB_565_Config:
+ return GL_RGB;
+ default:
+ return -1;
+ }
+}
+
+GLenum RenderingThread::getType(SkBitmap::Config config)
+{
+ switch(config) {
+ case SkBitmap::kA8_Config:
+ return GL_UNSIGNED_BYTE;
+ case SkBitmap::kARGB_4444_Config:
+ return GL_UNSIGNED_SHORT_4_4_4_4;
+ case SkBitmap::kARGB_8888_Config:
+ return GL_UNSIGNED_BYTE;
+ case SkBitmap::kIndex8_Config:
+ return -1; // No type for compressed data.
+ case SkBitmap::kRGB_565_Config:
+ return GL_UNSIGNED_SHORT_5_6_5;
+ default:
+ return -1;
+ }
+}
+
+void RenderingThread::createTextureWithBitmap(GLuint texture, SkBitmap& bitmap) {
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glBindTexture(GL_TEXTURE_2D, texture);
+ checkGlError("glBindTexture");
+ SkBitmap::Config config = bitmap.getConfig();
+ int internalformat = getInternalFormat(config);
+ int type = getType(config);
+ bitmap.lockPixels();
+ glTexImage2D(GL_TEXTURE_2D, 0, internalformat, bitmap.width(), bitmap.height(),
+ 0, internalformat, type, bitmap.getPixels());
+ bitmap.unlockPixels();
+ checkGlError("glTexImage2D");
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+}
+
+void RenderingThread::updateTextureWithBitmap(GLuint texture, SkBitmap& bitmap) {
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glBindTexture(GL_TEXTURE_2D, texture);
+ checkGlError("glBindTexture");
+ SkBitmap::Config config = bitmap.getConfig();
+ int internalformat = getInternalFormat(config);
+ int type = getType(config);
+ bitmap.lockPixels();
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, bitmap.width(), bitmap.height(),
+ internalformat, type, bitmap.getPixels());
+ bitmap.unlockPixels();
+ checkGlError("glTexSubImage2D");
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+}
diff --git a/samples/BrowserPlugin/jni/RenderingThread.h b/samples/BrowserPlugin/jni/RenderingThread.h
new file mode 100644
index 0000000..41f0ce8
--- /dev/null
+++ b/samples/BrowserPlugin/jni/RenderingThread.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2010, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "android_npapi.h"
+#include "SkCanvas.h"
+#include "SkBitmap.h"
+
+#include <EGL/egl.h>
+#include <GLES2/gl2.h>
+
+#ifndef RenderingThread__DEFINED
+#define RenderingThread__DEFINED
+
+
+class RenderingThread : public android::Thread {
+public:
+ RenderingThread(NPP npp);
+ virtual ~RenderingThread() {};
+ virtual android::status_t readyToRun();
+
+ void setDimensions(int width, int height);
+ void getDimensions(int& width, int& height);
+
+protected:
+ NPP m_npp;
+
+ static void printGLString(const char *name, GLenum s);
+ static void checkGlError(const char* op);
+ static GLenum getInternalFormat(SkBitmap::Config config);
+ static GLenum getType(SkBitmap::Config config);
+ static void createTextureWithBitmap(GLuint texture, SkBitmap& bitmap);
+ static void updateTextureWithBitmap(GLuint texture, SkBitmap& bitmap);
+
+private:
+ virtual bool threadLoop() = 0;
+
+ android::Mutex m_sync;
+ int m_width;
+ int m_height;
+};
+
+
+
+
+#endif // RenderingThread__DEFINED
diff --git a/samples/BrowserPlugin/jni/animation/AnimationPlugin.cpp b/samples/BrowserPlugin/jni/animation/AnimationPlugin.cpp
index 6e93fb6..58999ad 100644
--- a/samples/BrowserPlugin/jni/animation/AnimationPlugin.cpp
+++ b/samples/BrowserPlugin/jni/animation/AnimationPlugin.cpp
@@ -33,6 +33,7 @@
extern ANPCanvasInterfaceV0 gCanvasI;
extern ANPPaintInterfaceV0 gPaintI;
extern ANPPathInterfaceV0 gPathI;
+extern ANPSystemInterfaceV0 gSystemI;
extern ANPWindowInterfaceV0 gWindowI;
static uint16_t rnd16(float x, int inset) {
@@ -43,118 +44,74 @@
return static_cast<uint16_t>(ix);
}
-static void inval(NPP instance, const ANPRectF& r, bool doAA) {
- const int inset = doAA ? -1 : 0;
-
- NPRect inval;
- inval.left = rnd16(r.left, inset);
- inval.top = rnd16(r.top, inset);
- inval.right = rnd16(r.right, -inset);
- inval.bottom = rnd16(r.bottom, -inset);
- browser->invalidaterect(instance, &inval);
-}
-
-static void bounce(float* x, float* dx, const float max) {
- *x += *dx;
- if (*x < 0) {
- *x = 0;
- if (*dx < 0) {
- *dx = -*dx;
- }
- } else if (*x > max) {
- *x = max;
- if (*dx > 0) {
- *dx = -*dx;
- }
- }
-}
///////////////////////////////////////////////////////////////////////////////
-BallAnimation::BallAnimation(NPP inst) : SubPlugin(inst) {
- m_x = m_y = 0;
- m_dx = 7 * SCALE;
- m_dy = 5 * SCALE;
-
- memset(&m_oval, 0, sizeof(m_oval));
-
- m_paint = gPaintI.newPaint();
- gPaintI.setFlags(m_paint, gPaintI.getFlags(m_paint) | kAntiAlias_ANPPaintFlag);
- gPaintI.setColor(m_paint, 0xFFFF0000);
-
+BallAnimation::BallAnimation(NPP inst) : SurfaceSubPlugin(inst) {
//register for touch events
ANPEventFlags flags = kTouch_ANPEventFlag;
NPError err = browser->setvalue(inst, kAcceptEvents_ANPSetValue, &flags);
if (err != NPERR_NO_ERROR) {
gLogI.log(kError_ANPLogType, "Error selecting input events.");
}
+
+ gLogI.log(kError_ANPLogType, "Starting Rendering Thread");
+
+ //start a thread and do your drawing there
+ m_renderingThread = new AnimationThread(inst);
+ m_renderingThread->incStrong(inst);
+ m_renderingThread->run("AnimationThread");
}
BallAnimation::~BallAnimation() {
- gPaintI.deletePaint(m_paint);
+ m_renderingThread->requestExitAndWait();
+ destroySurface();
}
bool BallAnimation::supportsDrawingModel(ANPDrawingModel model) {
- return (model == kBitmap_ANPDrawingModel);
+ return (model == kOpenGL_ANPDrawingModel);
}
-void BallAnimation::drawPlugin(const ANPBitmap& bitmap, const ANPRectI& clip) {
+jobject BallAnimation::getSurface() {
- // create a canvas
- ANPCanvas* canvas = gCanvasI.newCanvas(&bitmap);
-
- // clip the canvas
- ANPRectF clipR;
- clipR.left = clip.left;
- clipR.top = clip.top;
- clipR.right = clip.right;
- clipR.bottom = clip.bottom;
- gCanvasI.clipRect(canvas, &clipR);
-
- // setup variables
- PluginObject *obj = (PluginObject*) inst()->pdata;
- const float OW = 20;
- const float OH = 20;
- const int W = obj->window->width;
- const int H = obj->window->height;
-
- // paint the canvas (using the path API)
- gCanvasI.drawColor(canvas, 0xFFFFFFFF);
- {
- ANPPath* path = gPathI.newPath();
-
- float cx = W * 0.5f;
- float cy = H * 0.5f;
- gPathI.moveTo(path, 0, 0);
- gPathI.quadTo(path, cx, cy, W, 0);
- gPathI.quadTo(path, cx, cy, W, H);
- gPathI.quadTo(path, cx, cy, 0, H);
- gPathI.quadTo(path, cx, cy, 0, 0);
-
- gPaintI.setColor(m_paint, 0xFF0000FF);
- gCanvasI.drawPath(canvas, path, m_paint);
-
- ANPRectF bounds;
- memset(&bounds, 0, sizeof(bounds));
- gPathI.getBounds(path, &bounds);
- gPathI.deletePath(path);
+ if (m_surface) {
+ return m_surface;
}
- // draw the oval
- inval(inst(), m_oval, true); // inval the old
- m_oval.left = m_x;
- m_oval.top = m_y;
- m_oval.right = m_x + OW;
- m_oval.bottom = m_y + OH;
- inval(inst(), m_oval, true); // inval the new
- gPaintI.setColor(m_paint, 0xFFFF0000);
- gCanvasI.drawOval(canvas, &m_oval, m_paint);
+ // load the appropriate java class and instantiate it
+ JNIEnv* env = NULL;
+ if (gVM->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
+ gLogI.log(kError_ANPLogType, " ---- getSurface: failed to get env");
+ return NULL;
+ }
- // update the coordinates of the oval
- bounce(&m_x, &m_dx, obj->window->width - OW);
- bounce(&m_y, &m_dy, obj->window->height - OH);
+ const char* className = "com.android.sampleplugin.AnimationSurface";
+ jclass fullScreenClass = gSystemI.loadJavaClass(inst(), className);
- // delete the canvas
- gCanvasI.deleteCanvas(canvas);
+ if(!fullScreenClass) {
+ gLogI.log(kError_ANPLogType, " ---- getSurface: failed to load class");
+ return NULL;
+ }
+
+ jmethodID constructor = env->GetMethodID(fullScreenClass, "<init>", "(Landroid/content/Context;)V");
+ jobject fullScreenSurface = env->NewObject(fullScreenClass, constructor, m_context);
+
+ if(!fullScreenSurface) {
+ gLogI.log(kError_ANPLogType, " ---- getSurface: failed to construct object");
+ return NULL;
+ }
+
+ gLogI.log(kError_ANPLogType, " ---- object %p", fullScreenSurface);
+
+ m_surface = env->NewGlobalRef(fullScreenSurface);
+ return m_surface;
+}
+
+void BallAnimation::destroySurface() {
+ JNIEnv* env = NULL;
+ if (m_surface && gVM->GetEnv((void**) &env, JNI_VERSION_1_4) == JNI_OK) {
+ env->DeleteGlobalRef(m_surface);
+ m_surface = NULL;
+ }
}
void BallAnimation::showEntirePluginOnScreen() {
@@ -179,17 +136,26 @@
switch (evt->eventType) {
case kDraw_ANPEventType:
switch (evt->data.draw.model) {
- case kBitmap_ANPDrawingModel:
- drawPlugin(evt->data.draw.data.bitmap, evt->data.draw.clip);
+ case kOpenGL_ANPDrawingModel: {
+ //send the width and height to the rendering thread
+ int width = evt->data.draw.data.surface.width;
+ int height = evt->data.draw.data.surface.height;
+ gLogI.log(kError_ANPLogType, "New Dimensions (%d,%d)", width, height);
+ m_renderingThread->setDimensions(width, height);
return 1;
+ }
default:
- break; // unknown drawing model
+ return 0; // unknown drawing model
}
case kTouch_ANPEventType:
if (kDown_ANPTouchAction == evt->data.touch.action) {
showEntirePluginOnScreen();
}
- return 1;
+ else if (kDoubleTap_ANPTouchAction == evt->data.touch.action) {
+ browser->geturl(inst(), "javascript:alert('Detected double tap event.')", 0);
+ gWindowI.requestFullScreen(inst());
+ }
+ return 1;
default:
break;
}
diff --git a/samples/BrowserPlugin/jni/animation/AnimationPlugin.h b/samples/BrowserPlugin/jni/animation/AnimationPlugin.h
index 4a5b4e8..870b67c 100644
--- a/samples/BrowserPlugin/jni/animation/AnimationPlugin.h
+++ b/samples/BrowserPlugin/jni/animation/AnimationPlugin.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2008, The Android Open Source Project
+ * Copyright 2010, The Android Open Source Project
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -24,29 +24,25 @@
*/
#include "PluginObject.h"
+#include "AnimationThread.h"
#ifndef pluginGraphics__DEFINED
#define pluginGraphics__DEFINED
-class BallAnimation : public SubPlugin {
+class BallAnimation : public SurfaceSubPlugin {
public:
BallAnimation(NPP inst);
virtual ~BallAnimation();
virtual bool supportsDrawingModel(ANPDrawingModel);
virtual int16_t handleEvent(const ANPEvent* evt);
+
+ virtual jobject getSurface();
private:
- void drawPlugin(const ANPBitmap& bitmap, const ANPRectI& clip);
void showEntirePluginOnScreen();
+ void destroySurface();
- float m_x;
- float m_y;
- float m_dx;
- float m_dy;
-
- ANPRectF m_oval;
- ANPPaint* m_paint;
-
- static const float SCALE = 0.1;
+ jobject m_surface;
+ AnimationThread* m_renderingThread;
};
#endif // pluginGraphics__DEFINED
diff --git a/samples/BrowserPlugin/jni/animation/AnimationThread.cpp b/samples/BrowserPlugin/jni/animation/AnimationThread.cpp
new file mode 100644
index 0000000..9e6342d
--- /dev/null
+++ b/samples/BrowserPlugin/jni/animation/AnimationThread.cpp
@@ -0,0 +1,164 @@
+/*
+ * Copyright 2010, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "AnimationThread.h"
+#include "ANPOpenGL_npapi.h"
+
+#include <EGL/egl.h>
+#include <GLES2/gl2.h>
+#include <utils/SystemClock.h>
+
+extern ANPLogInterfaceV0 gLogI;
+extern ANPOpenGLInterfaceV0 gOpenGLI;
+
+AnimationThread::AnimationThread(NPP npp) : RenderingThread(npp) {
+ m_counter = 0;
+ m_lastPrintTime = android::uptimeMillis();
+ m_executionTime = 0;
+ m_idleTime = 0;
+
+ m_x = m_y = 0;
+ m_dx = 0;
+ m_dy = 0;
+
+ memset(&m_oval, 0, sizeof(m_oval));
+
+ m_paint = new SkPaint;
+ m_paint->setAntiAlias(true);
+
+ m_bitmap = constructBitmap(DEFAULT_WIDTH, DEFAULT_HEIGHT);
+ m_canvas = new SkCanvas(*m_bitmap);
+
+ m_startExecutionTime = 0;
+ m_startTime = android::uptimeMillis();
+}
+
+AnimationThread::~AnimationThread() {
+ delete m_paint;
+ delete m_canvas;
+ delete m_bitmap;
+}
+
+SkBitmap* AnimationThread::constructBitmap(int width, int height) {
+ SkBitmap* bitmap = new SkBitmap;
+ bitmap->setConfig(SkBitmap::kARGB_8888_Config, width, height);
+ bitmap->allocPixels();
+ bitmap->eraseColor(0x00000000);
+ return bitmap;
+}
+
+static void bounce(float* x, float* dx, const float max) {
+ *x += *dx;
+ if (*x < 0) {
+ *x = 0;
+ if (*dx < 0) {
+ *dx = -*dx;
+ }
+ } else if (*x > max) {
+ *x = max;
+ if (*dx > 0) {
+ *dx = -*dx;
+ }
+ }
+}
+
+bool AnimationThread::threadLoop() {
+
+ m_startIdleTime = android::uptimeMillis();
+
+ ANPTextureInfo textureInfo = gOpenGLI.lockTexture(m_npp);
+ GLuint textureId = textureInfo.textureId;
+
+ m_idleTime += android::uptimeMillis() - m_startIdleTime;
+ m_startExecutionTime = android::uptimeMillis();
+
+ int width, height;
+ getDimensions(width, height);
+
+ if (width <= 0)
+ width = DEFAULT_WIDTH;
+ if (height <= 0)
+ height = DEFAULT_HEIGHT;
+
+ if (m_bitmap->width() != width || m_bitmap->height() != height) {
+ delete m_canvas;
+ delete m_bitmap;
+ m_bitmap = constructBitmap(width, height);
+ m_canvas = new SkCanvas(*m_bitmap);
+
+ // change the ball's speed to match the size
+ m_dx = width * .005f;
+ m_dy = height * .007f;
+ }
+
+ // setup variables
+ const float OW = width * .125f;
+ const float OH = height * .125f;
+
+ // clear the old oval
+ m_bitmap->eraseColor(0x880000FF);
+
+ // update the coordinates of the oval
+ bounce(&m_x, &m_dx, width - OW);
+ bounce(&m_y, &m_dy, height - OH);
+
+ // draw the new oval
+ m_oval.fLeft = m_x;
+ m_oval.fTop = m_y;
+ m_oval.fRight = m_x + OW;
+ m_oval.fBottom = m_y + OH;
+ m_paint->setColor(0xAAFF0000);
+ m_canvas->drawOval(m_oval, *m_paint);
+
+ if (textureInfo.width == width && textureInfo.height == height) {
+ updateTextureWithBitmap(textureId, *m_bitmap);
+ } else {
+ createTextureWithBitmap(textureId, *m_bitmap);
+ textureInfo.width = width;
+ textureInfo.height = height;
+ textureInfo.internalFormat = GL_RGBA;
+ }
+
+ m_executionTime += android::uptimeMillis() - m_startExecutionTime;
+ m_counter++;
+
+ gOpenGLI.releaseTexture(m_npp, &textureInfo);
+
+ if (android::uptimeMillis() - m_lastPrintTime > 5000) {
+ float fps = m_counter / ((android::uptimeMillis() - m_startTime) / 1000);
+ float spf = ((android::uptimeMillis() - m_startTime)) / m_counter;
+ float lpf = (m_idleTime) / m_counter;
+ float exe = (m_executionTime) / m_counter;
+ gLogI.log(kError_ANPLogType, "TEXT: counter(%d) fps(%f) spf(%f) lock(%f) execution(%f)\n", (int)m_counter, fps, spf, lpf, exe);
+ m_lastPrintTime = android::uptimeMillis();
+
+ m_counter = 0;
+ m_executionTime = 0;
+ m_idleTime = 0;
+ m_startExecutionTime = 0;
+ m_startTime = android::uptimeMillis();
+ }
+
+ return true;
+}
diff --git a/samples/BrowserPlugin/jni/animation/AnimationThread.h b/samples/BrowserPlugin/jni/animation/AnimationThread.h
new file mode 100644
index 0000000..4f74e94
--- /dev/null
+++ b/samples/BrowserPlugin/jni/animation/AnimationThread.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2010, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "RenderingThread.h"
+#include "SkCanvas.h"
+#include "SkBitmap.h"
+#include "SkRect.h"
+#include "SkPaint.h"
+
+#ifndef AnimationThread__DEFINED
+#define AnimationThread__DEFINED
+
+class AnimationThread : public RenderingThread {
+public:
+ AnimationThread(NPP npp);
+ virtual ~AnimationThread();
+
+private:
+ virtual bool threadLoop();
+ SkBitmap* constructBitmap(int width, int height);
+
+ float m_counter;
+
+ int64_t m_lastPrintTime;
+ int64_t m_executionTime;
+ int64_t m_idleTime;
+ int64_t m_startTime;
+ int64_t m_startExecutionTime;
+ int64_t m_startIdleTime;
+
+ float m_x;
+ float m_y;
+ float m_dx;
+ float m_dy;
+
+ SkRect m_oval;
+ SkPaint* m_paint;
+ SkBitmap* m_bitmap;
+ SkCanvas* m_canvas;
+
+ static const unsigned int DEFAULT_WIDTH = 400;
+ static const unsigned int DEFAULT_HEIGHT = 400;
+};
+
+
+
+#endif // AnimationThread__DEFINED
diff --git a/samples/BrowserPlugin/jni/main.cpp b/samples/BrowserPlugin/jni/main.cpp
index 07bae66..a2dd667 100644
--- a/samples/BrowserPlugin/jni/main.cpp
+++ b/samples/BrowserPlugin/jni/main.cpp
@@ -77,6 +77,7 @@
ANPSystemInterfaceV0 gSystemI;
ANPTypefaceInterfaceV0 gTypefaceI;
ANPWindowInterfaceV0 gWindowI;
+ANPOpenGLInterfaceV0 gOpenGLI;
#define ARRAY_COUNT(array) (sizeof(array) / sizeof(array[0]))
#define DEBUG_PLUGIN_EVENTS 0
@@ -125,6 +126,7 @@
{ kSystemInterfaceV0_ANPGetValue, sizeof(gSystemI), &gSystemI },
{ kTypefaceInterfaceV0_ANPGetValue, sizeof(gTypefaceI), &gTypefaceI },
{ kWindowInterfaceV0_ANPGetValue, sizeof(gWindowI), &gWindowI },
+ { kOpenGLInterfaceV0_ANPGetValue, sizeof(gOpenGLI), &gOpenGLI },
};
for (size_t i = 0; i < ARRAY_COUNT(gPairs); i++) {
gPairs[i].i->inSize = gPairs[i].size;
@@ -162,6 +164,7 @@
if (browser->version >= 14) {
instance->pdata = browser->createobject (instance, getPluginClass());
obj = static_cast<PluginObject*>(instance->pdata);
+ obj->pluginType = 0;
}
/* END: STANDARD PLUGIN FRAMEWORK */
@@ -176,6 +179,9 @@
else if (!strcmp(argv[i], "Surface")) {
model = kSurface_ANPDrawingModel;
}
+ else if (!strcmp(argv[i], "OpenGL")) {
+ model = kOpenGL_ANPDrawingModel;
+ }
gLogI.log(kDebug_ANPLogType, "------ %p DrawingModel is %d", instance, model);
break;
}
@@ -228,7 +234,6 @@
obj->pluginType = kVideo_PluginType;
obj->activePlugin = new VideoPlugin(instance);
}
- gLogI.log(kDebug_ANPLogType, "------ %p PluginType is %d", instance, obj->pluginType);
break;
}
}
@@ -240,6 +245,8 @@
obj->activePlugin = new BallAnimation(instance);
}
+ gLogI.log(kDebug_ANPLogType, "------ %p PluginType is %d", instance, obj->pluginType);
+
// check to ensure the pluginType supports the model
if (!obj->activePlugin->supportsDrawingModel(model)) {
gLogI.log(kError_ANPLogType, "------ %p Unsupported DrawingModel (%d)", instance, model);
@@ -247,7 +254,7 @@
}
// if the plugin uses the surface drawing model then set the java context
- if (model == kSurface_ANPDrawingModel) {
+ if (model == kSurface_ANPDrawingModel || model == kOpenGL_ANPDrawingModel) {
SurfaceSubPlugin* surfacePlugin = static_cast<SurfaceSubPlugin*>(obj->activePlugin);
jobject context;
@@ -434,7 +441,8 @@
PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
if (obj && obj->activePlugin) {
- if(obj->activePlugin->supportsDrawingModel(kSurface_ANPDrawingModel)) {
+ if(obj->activePlugin->supportsDrawingModel(kSurface_ANPDrawingModel)
+ || obj->activePlugin->supportsDrawingModel(kOpenGL_ANPDrawingModel)) {
SurfaceSubPlugin* plugin = static_cast<SurfaceSubPlugin*>(obj->activePlugin);
jobject* surface = static_cast<jobject*>(value);
*surface = plugin->getSurface();
diff --git a/samples/BrowserPlugin/jni/main.h b/samples/BrowserPlugin/jni/main.h
index 66629e6..ebfb4b2 100644
--- a/samples/BrowserPlugin/jni/main.h
+++ b/samples/BrowserPlugin/jni/main.h
@@ -27,6 +27,7 @@
#include <npfunctions.h>
#include <npruntime.h>
#include "android_npapi.h"
+#include "ANPOpenGL_npapi.h"
#include "ANPSurface_npapi.h"
#include "ANPSystem_npapi.h"
diff --git a/samples/BrowserPlugin/src/com/android/sampleplugin/AnimationSurface.java b/samples/BrowserPlugin/src/com/android/sampleplugin/AnimationSurface.java
new file mode 100644
index 0000000..e3afab6
--- /dev/null
+++ b/samples/BrowserPlugin/src/com/android/sampleplugin/AnimationSurface.java
@@ -0,0 +1,22 @@
+package com.android.sampleplugin;
+
+import android.content.Context;
+import android.graphics.Color;
+import android.util.Log;
+import android.widget.TextView;
+
+public class AnimationSurface extends TextView {
+
+ public AnimationSurface(Context context) {
+ super(context);
+
+ Log.e("AnimSurface", "IN ANIMATION SURFACE");
+
+ this.setBackgroundColor(Color.GRAY);
+ this.setTextColor(Color.WHITE);
+ this.setText("This is a full-screen plugin");
+
+ // ensure that the view system is aware that we will be drawing
+ this.setWillNotDraw(false);
+ }
+}
diff --git a/samples/XmlAdapters/Android.mk b/samples/XmlAdapters/Android.mk
index 24a3327..3224bbe 100644
--- a/samples/XmlAdapters/Android.mk
+++ b/samples/XmlAdapters/Android.mk
@@ -10,7 +10,8 @@
LOCAL_PROGUARD_ENABLED := disabled
-include $(BUILD_PACKAGE)
+# XXX These APIs are not yet available in the platform.
+#include $(BUILD_PACKAGE)
# Use the following include to make our test apk.
-include $(call all-makefiles-under,$(LOCAL_PATH))
+#include $(call all-makefiles-under,$(LOCAL_PATH))