auto import from //branches/cupcake/...@137873
diff --git a/tests/appwidgets/AppWidgetProviderTest/Android.mk b/tests/appwidgets/AppWidgetProviderTest/Android.mk
new file mode 100644
index 0000000..c87a0f2
--- /dev/null
+++ b/tests/appwidgets/AppWidgetProviderTest/Android.mk
@@ -0,0 +1,11 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := user
+
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+
+LOCAL_PACKAGE_NAME := AppWidgetProvider
+LOCAL_CERTIFICATE := platform
+
+include $(BUILD_PACKAGE)
diff --git a/tests/appwidgets/AppWidgetProviderTest/AndroidManifest.xml b/tests/appwidgets/AppWidgetProviderTest/AndroidManifest.xml
new file mode 100644
index 0000000..ec4d583
--- /dev/null
+++ b/tests/appwidgets/AppWidgetProviderTest/AndroidManifest.xml
@@ -0,0 +1,13 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+        package="com.android.tests.appwidgetprovider">
+    <uses-permission android:name="android.permission.VIBRATE" />
+
+    <application>
+        <receiver android:name="TestAppWidgetProvider">
+            <intent-filter>
+                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
+            </intent-filter>
+            <meta-data android:name="android.appwidget.provider" android:resource="@xml/appwidget_info" />
+        </receiver>
+    </application>
+</manifest>
diff --git a/tests/appwidgets/AppWidgetProviderTest/res/layout/test_appwidget.xml b/tests/appwidgets/AppWidgetProviderTest/res/layout/test_appwidget.xml
new file mode 100644
index 0000000..e0a416e
--- /dev/null
+++ b/tests/appwidgets/AppWidgetProviderTest/res/layout/test_appwidget.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2006 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.
+-->
+
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/oh_hai_text"
+    android:layout_width="150dp"
+    android:layout_height="150dp"
+    android:text="@string/oh_hai"
+    android:background="#8fff"
+    android:textColor="#000"
+    android:textStyle="bold"
+/>
+
diff --git a/tests/appwidgets/AppWidgetProviderTest/res/values/strings.xml b/tests/appwidgets/AppWidgetProviderTest/res/values/strings.xml
new file mode 100644
index 0000000..e51299b
--- /dev/null
+++ b/tests/appwidgets/AppWidgetProviderTest/res/values/strings.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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.
+-->
+
+<resources>
+    <string name="appwidget_view_title">Widget Test</string>
+    <string name="add_appwidget">Add Widget</string>
+    <string name="oh_hai">Oh hai.</string>
+    <string name="delete_appwidget">Delete</string>
+</resources>
+
diff --git a/tests/appwidgets/AppWidgetProviderTest/res/xml/appwidget_info.xml b/tests/appwidgets/AppWidgetProviderTest/res/xml/appwidget_info.xml
new file mode 100644
index 0000000..c133743
--- /dev/null
+++ b/tests/appwidgets/AppWidgetProviderTest/res/xml/appwidget_info.xml
@@ -0,0 +1,7 @@
+<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
+    android:minWidth="150dp"
+    android:minHeight="150dp"
+    android:updatePeriodMillis="2000"
+    android:initialLayout="@layout/test_appwidget"
+    >
+</appwidget-provider>
diff --git a/tests/appwidgets/AppWidgetProviderTest/src/com/android/tests/appwidgetprovider/TestAppWidgetProvider.java b/tests/appwidgets/AppWidgetProviderTest/src/com/android/tests/appwidgetprovider/TestAppWidgetProvider.java
new file mode 100644
index 0000000..418be65
--- /dev/null
+++ b/tests/appwidgets/AppWidgetProviderTest/src/com/android/tests/appwidgetprovider/TestAppWidgetProvider.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.tests.appwidgetprovider;
+
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.appwidget.AppWidgetManager;
+import android.os.Bundle;
+import android.os.SystemClock;
+import android.util.Log;
+import android.widget.RemoteViews;
+
+public class TestAppWidgetProvider extends BroadcastReceiver {
+
+    static final String TAG = "TestAppWidgetProvider";
+
+    public void onReceive(Context context, Intent intent) {
+        String action = intent.getAction();
+        Log.d(TAG, "intent=" + intent);
+
+        if (AppWidgetManager.ACTION_APPWIDGET_ENABLED.equals(action)) {
+            Log.d(TAG, "ENABLED");
+        }
+        else if (AppWidgetManager.ACTION_APPWIDGET_DISABLED.equals(action)) {
+            Log.d(TAG, "DISABLED");
+        }
+        else if (AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals(action)) {
+            Log.d(TAG, "UPDATE");
+            Bundle extras = intent.getExtras();
+            int[] appWidgetIds = extras.getIntArray(AppWidgetManager.EXTRA_APPWIDGET_IDS);
+
+            AppWidgetManager gm = AppWidgetManager.getInstance(context);
+            RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.test_appwidget);
+            views.setTextViewText(R.id.oh_hai_text, "hai: " + SystemClock.elapsedRealtime());
+            if (false) {
+                gm.updateAppWidget(appWidgetIds, views);
+            } else {
+                gm.updateAppWidget(new ComponentName("com.android.tests.appwidgetprovider",
+                            "com.android.tests.appwidgetprovider.TestAppWidgetProvider"), views);
+            }
+        }
+    }
+}
+