summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/Development/AndroidManifest.xml3
-rw-r--r--apps/Development/res/layout/connectivity.xml68
-rw-r--r--apps/Development/res/layout/media_scanner_activity.xml49
-rw-r--r--apps/Development/res/values/strings.xml13
-rw-r--r--apps/Development/src/com/android/development/Connectivity.java414
-rw-r--r--apps/Development/src/com/android/development/MediaScannerActivity.java215
-rw-r--r--apps/GraphicsLab/Android.mk10
-rw-r--r--apps/GraphicsLab/AndroidManifest.xml11
-rw-r--r--apps/GraphicsLab/MODULE_LICENSE_APACHE20
-rw-r--r--apps/GraphicsLab/NOTICE190
-rw-r--r--apps/GraphicsLab/res/drawable/beach.jpgbin47700 -> 0 bytes
-rw-r--r--apps/GraphicsLab/res/drawable/news_img.jpgbin489231 -> 0 bytes
-rw-r--r--apps/GraphicsLab/res/layout/graphics_lab.xml25
-rw-r--r--apps/GraphicsLab/src/com/android/graphicslab/GraphicsLab.java299
14 files changed, 623 insertions, 674 deletions
diff --git a/apps/Development/AndroidManifest.xml b/apps/Development/AndroidManifest.xml
index c8095542c..827b57a7c 100644
--- a/apps/Development/AndroidManifest.xml
+++ b/apps/Development/AndroidManifest.xml
@@ -18,6 +18,7 @@
package="com.android.development"
android:versionCode="1" android:versionName="1.0">
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.DEVICE_POWER" />
@@ -117,7 +118,7 @@
</intent-filter>
</activity>
- <activity android:name="MediaScannerActivity" android:label="Media Scanner">
+ <activity android:name="MediaScannerActivity" android:label="Media Provider">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.TEST" />
diff --git a/apps/Development/res/layout/connectivity.xml b/apps/Development/res/layout/connectivity.xml
index 612304fa7..ff0c6ea6b 100644
--- a/apps/Development/res/layout/connectivity.xml
+++ b/apps/Development/res/layout/connectivity.xml
@@ -17,12 +17,14 @@
** limitations under the License.
*/
-->
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <LinearLayout
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
@@ -202,5 +204,59 @@
android:layout_height="wrap_content"
android:text="@string/crash" />
</LinearLayout>
-</LinearLayout>
+
+ <LinearLayout
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <Button android:id="@+id/add_default_route"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/add_default_route" />
+ <Button android:id="@+id/remove_default_route"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/remove_default_route" />
+ </LinearLayout>
+ <LinearLayout
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <Button android:id="@+id/default_request"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/default_request" />
+ <Button android:id="@+id/default_socket"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/default_socket" />
+ </LinearLayout>
+ <LinearLayout
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <Button android:id="@+id/bound_http_request"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/bound_http_request" />
+ <Button android:id="@+id/bound_socket_request"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/bound_socket_request" />
+ </LinearLayout>
+ <LinearLayout
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <Button android:id="@+id/routed_http_request"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/routed_http_request" />
+ <Button android:id="@+id/routed_socket_request"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/routed_socket_request" />
+ </LinearLayout>
+ </LinearLayout>
+</ScrollView>
diff --git a/apps/Development/res/layout/media_scanner_activity.xml b/apps/Development/res/layout/media_scanner_activity.xml
index 974f68378..480684355 100644
--- a/apps/Development/res/layout/media_scanner_activity.xml
+++ b/apps/Development/res/layout/media_scanner_activity.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.
@@ -14,12 +14,45 @@
limitations under the License.
-->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="horizontal">
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/title"
+ android:textSize="16sp"
+ android:textStyle="bold"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <Button
+ android:layout_width="160dip"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:text="@string/scancard"
+ android:onClick="startScan" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="horizontal"
+ android:layout_marginTop="30dip">
+
+ <EditText
+ android:id="@+id/numsongs"
+ android:layout_width="150dip"
+ android:layout_height="wrap_content"
+ android:hint="@string/numsongs"
+ android:numeric="integer"
+ />
+
+ <Button
+ android:id="@+id/insertbutton"
+ android:layout_width="150dip"
+ android:layout_height="wrap_content"
+ android:onClick="insertItems" />
- <TextView android:id="@+id/title" android:textSize="16sp" android:textStyle="bold"
- android:layout_width="match_parent" android:layout_height="wrap_content" />
+ </LinearLayout>
</LinearLayout>
diff --git a/apps/Development/res/values/strings.xml b/apps/Development/res/values/strings.xml
index 181c4fa7d..422bd7f59 100644
--- a/apps/Development/res/values/strings.xml
+++ b/apps/Development/res/values/strings.xml
@@ -36,6 +36,14 @@
<string name="start_hipri">Start HiPri</string>
<string name="stop_hipri">Stop HiPri</string>
<string name="crash">CRASH</string>
+ <string name="add_default_route">Add Default Route</string>
+ <string name="remove_default_route">Remove Default Route</string>
+ <string name="default_request">Make a http request</string>
+ <string name="default_socket">Make a raw request</string>
+ <string name="bound_http_request">Make bound http request</string>
+ <string name="bound_socket_request">Make bound socket request</string>
+ <string name="routed_http_request">Make routed http request</string>
+ <string name="routed_socket_request">Make routed socket request</string>
<string name="device_info_default">unknown</string>
@@ -208,4 +216,9 @@
<string name="bad_behavior_anr_service_label">ANR starting a Service</string>
<string name="bad_behavior_anr_system_label">System ANR (in ActivityManager)</string>
<string name="bad_behavior_wedge_system_label">Wedge system (5 minute system ANR)</string>
+
+ <!-- MediaScannerActivity -->
+ <string name="scancard">Scan SD card</string>
+ <string name="numsongs"># of albums</string>
+ <string name="insertbutton">Insert %1s albums</string>
</resources>
diff --git a/apps/Development/src/com/android/development/Connectivity.java b/apps/Development/src/com/android/development/Connectivity.java
index 59157bfb6..c7029ecc7 100644
--- a/apps/Development/src/com/android/development/Connectivity.java
+++ b/apps/Development/src/com/android/development/Connectivity.java
@@ -28,6 +28,7 @@ import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.ConnectivityManager;
+import android.net.NetworkUtils;
import android.net.wifi.WifiManager;
import android.os.RemoteException;
import android.os.Handler;
@@ -58,19 +59,27 @@ import com.android.internal.telephony.Phone;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.io.PrintWriter;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.Socket;
+import java.util.Enumeration;
import java.util.Map;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.conn.params.ConnRouteParams;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpParams;
+import org.apache.http.HttpResponse;
+import org.apache.http.impl.client.DefaultHttpClient;
+
public class Connectivity extends Activity {
- private static final String TAG = "Connectivity";
+ private static final String TAG = "DevTools - Connectivity";
private static final int EVENT_TOGGLE_WIFI = 1;
private static final int EVENT_TOGGLE_SCREEN = 2;
- private Button mEnableWifiButton;
- private Button mDisableWifiButton;
-
- private Button mStartDelayedCycleButton;
- private Button mStopDelayedCycleButton;
private EditText mDCOnDurationEdit;
private EditText mDCOffDurationEdit;
private TextView mDCCycleCountView;
@@ -78,8 +87,6 @@ public class Connectivity extends Activity {
private long mDCOffDuration = 120000;
private int mDCCycleCount = 0;
- private Button mStartScreenCycleButton;
- private Button mStopScreenCycleButton;
private EditText mSCOnDurationEdit;
private EditText mSCOffDurationEdit;
private TextView mSCCycleCountView;
@@ -87,12 +94,6 @@ public class Connectivity extends Activity {
private long mSCOffDuration = 12000;
private int mSCCycleCount = 0;
- private Button mStartMmsButton;
- private Button mStopMmsButton;
- private Button mStartHiPriButton;
- private Button mStopHiPriButton;
- private Button mCrashButton;
-
private boolean mDelayedCycleStarted = false;
private WifiManager mWm;
@@ -191,15 +192,11 @@ public class Connectivity extends Activity {
mPm = (PowerManager)getSystemService(Context.POWER_SERVICE);
mCm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
- mEnableWifiButton = (Button)findViewById(R.id.enableWifi);
- mEnableWifiButton.setOnClickListener(mEnableWifiClicked);
- mDisableWifiButton = (Button)findViewById(R.id.disableWifi);
- mDisableWifiButton.setOnClickListener(mDisableWifiClicked);
+ findViewById(R.id.enableWifi).setOnClickListener(mClickListener);
+ findViewById(R.id.disableWifi).setOnClickListener(mClickListener);
- mStartDelayedCycleButton = (Button)findViewById(R.id.startDelayedCycle);
- mStartDelayedCycleButton.setOnClickListener(mStartDelayedCycleClicked);
- mStopDelayedCycleButton = (Button)findViewById(R.id.stopDelayedCycle);
- mStopDelayedCycleButton.setOnClickListener(mStopDelayedCycleClicked);
+ findViewById(R.id.startDelayedCycle).setOnClickListener(mClickListener);
+ findViewById(R.id.stopDelayedCycle).setOnClickListener(mClickListener);
mDCOnDurationEdit = (EditText)findViewById(R.id.dc_wifi_on_duration);
mDCOnDurationEdit.setText(Long.toString(mDCOnDuration));
mDCOffDurationEdit = (EditText)findViewById(R.id.dc_wifi_off_duration);
@@ -207,10 +204,8 @@ public class Connectivity extends Activity {
mDCCycleCountView = (TextView)findViewById(R.id.dc_wifi_cycles_done);
mDCCycleCountView.setText(Integer.toString(mDCCycleCount));
- mStartScreenCycleButton = (Button)findViewById(R.id.startScreenCycle);
- mStartScreenCycleButton.setOnClickListener(mStartScreenCycleClicked);
- mStopScreenCycleButton = (Button)findViewById(R.id.stopScreenCycle);
- mStopScreenCycleButton.setOnClickListener(mStopScreenCycleClicked);
+ findViewById(R.id.startScreenCycle).setOnClickListener(mClickListener);
+ findViewById(R.id.stopScreenCycle).setOnClickListener(mClickListener);
mSCOnDurationEdit = (EditText)findViewById(R.id.sc_wifi_on_duration);
mSCOnDurationEdit.setText(Long.toString(mSCOnDuration));
mSCOffDurationEdit = (EditText)findViewById(R.id.sc_wifi_off_duration);
@@ -218,16 +213,20 @@ public class Connectivity extends Activity {
mSCCycleCountView = (TextView)findViewById(R.id.sc_wifi_cycles_done);
mSCCycleCountView.setText(Integer.toString(mSCCycleCount));
- mStartMmsButton = (Button)findViewById(R.id.start_mms);
- mStartMmsButton.setOnClickListener(mStartMmsClicked);
- mStopMmsButton = (Button)findViewById(R.id.stop_mms);
- mStopMmsButton.setOnClickListener(mStopMmsClicked);
- mStartHiPriButton = (Button)findViewById(R.id.start_hipri);
- mStartHiPriButton.setOnClickListener(mStartHiPriClicked);
- mStopHiPriButton = (Button)findViewById(R.id.stop_hipri);
- mStopHiPriButton.setOnClickListener(mStopHiPriClicked);
- mCrashButton = (Button)findViewById(R.id.crash);
- mCrashButton.setOnClickListener(mCrashClicked);
+ findViewById(R.id.start_mms).setOnClickListener(mClickListener);
+ findViewById(R.id.stop_mms).setOnClickListener(mClickListener);
+ findViewById(R.id.start_hipri).setOnClickListener(mClickListener);
+ findViewById(R.id.stop_hipri).setOnClickListener(mClickListener);
+ findViewById(R.id.crash).setOnClickListener(mClickListener);
+
+ findViewById(R.id.add_default_route).setOnClickListener(mClickListener);
+ findViewById(R.id.remove_default_route).setOnClickListener(mClickListener);
+ findViewById(R.id.bound_http_request).setOnClickListener(mClickListener);
+ findViewById(R.id.bound_socket_request).setOnClickListener(mClickListener);
+ findViewById(R.id.routed_http_request).setOnClickListener(mClickListener);
+ findViewById(R.id.routed_socket_request).setOnClickListener(mClickListener);
+ findViewById(R.id.default_request).setOnClickListener(mClickListener);
+ findViewById(R.id.default_socket).setOnClickListener(mClickListener);
registerReceiver(mReceiver, new IntentFilter(CONNECTIVITY_TEST_ALARM));
}
@@ -239,62 +238,114 @@ public class Connectivity extends Activity {
super.onResume();
}
- private View.OnClickListener mStartDelayedCycleClicked = new View.OnClickListener() {
- public void onClick(View v) {
- if (!mDelayedCycleStarted) {
- mDelayedCycleStarted = true;
- try {
- mDCOnDuration = Long.parseLong(mDCOnDurationEdit.getText().toString());
- mDCOffDuration = Long.parseLong(mDCOffDurationEdit.getText().toString());
- } catch (Exception e) { };
- mDCCycleCount = 0;
-
- mWakeLock = mPm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "ConnectivityTest");
- mWakeLock.acquire();
- mHandler2.sendMessage(mHandler2.obtainMessage(EVENT_TOGGLE_WIFI));
- }
- }
- };
- private View.OnClickListener mStopDelayedCycleClicked = new View.OnClickListener() {
+ private View.OnClickListener mClickListener = new View.OnClickListener() {
public void onClick(View v) {
- if (mDelayedCycleStarted) {
- mDelayedCycleStarted = false;
- mWakeLock.release();
- mWakeLock = null;
- if(mHandler2.hasMessages(EVENT_TOGGLE_WIFI)) {
- mHandler2.removeMessages(EVENT_TOGGLE_WIFI);
- }
+ switch (v.getId()) {
+ case R.id.enableWifi:
+ mWm.setWifiEnabled(true);
+ break;
+ case R.id.disableWifi:
+ mWm.setWifiEnabled(false);
+ break;
+ case R.id.startDelayedCycle:
+ onStartDelayedCycle();
+ break;
+ case R.id.stopDelayedCycle:
+ onStopDelayedCycle();
+ break;
+ case R.id.startScreenCycle:
+ onStartScreenCycle();
+ break;
+ case R.id.stopScreenCycle:
+ onStopScreenCycle();
+ break;
+ case R.id.start_mms:
+ mCm.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,
+ Phone.FEATURE_ENABLE_MMS);
+ break;
+ case R.id.stop_mms:
+ mCm.stopUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,
+ Phone.FEATURE_ENABLE_MMS);
+ break;
+ case R.id.default_socket:
+ onDefaultSocket();
+ break;
+ case R.id.default_request:
+ onDefaultRequest();
+ break;
+ case R.id.routed_socket_request:
+ onRoutedSocketRequest();
+ break;
+ case R.id.routed_http_request:
+ onRoutedHttpRequest();
+ break;
+ case R.id.bound_socket_request:
+ onBoundSocketRequest();
+ break;
+ case R.id.bound_http_request:
+ onBoundHttpRequest();
+ break;
+ case R.id.remove_default_route:
+ onRemoveDefaultRoute();
+ break;
+ case R.id.add_default_route:
+ onAddDefaultRoute();
+ break;
+ case R.id.crash:
+ onCrash();
+ break;
+ case R.id.start_hipri:
+ mCm.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,
+ Phone.FEATURE_ENABLE_HIPRI);
+ break;
+ case R.id.stop_hipri:
+ mCm.stopUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,
+ Phone.FEATURE_ENABLE_HIPRI);
+ break;
}
}
};
- private View.OnClickListener mEnableWifiClicked = new View.OnClickListener() {
- public void onClick(View v) {
- mWm.setWifiEnabled(true);
- }
- };
- private View.OnClickListener mDisableWifiClicked = new View.OnClickListener() {
- public void onClick(View v) {
- mWm.setWifiEnabled(false);
- }
- };
-
- private View.OnClickListener mStartScreenCycleClicked = new View.OnClickListener() {
- public void onClick(View v) {
+ private void onStartDelayedCycle() {
+ if (!mDelayedCycleStarted) {
+ mDelayedCycleStarted = true;
try {
- mSCOnDuration = Long.parseLong(mSCOnDurationEdit.getText().toString());
- mSCOffDuration = Long.parseLong(mSCOffDurationEdit.getText().toString());
+ mDCOnDuration = Long.parseLong(mDCOnDurationEdit.getText().toString());
+ mDCOffDuration = Long.parseLong(mDCOffDurationEdit.getText().toString());
} catch (Exception e) { };
- mSCCycleCount = 0;
+ mDCCycleCount = 0;
- mScreenonWakeLock = mPm.newWakeLock(PowerManager.FULL_WAKE_LOCK,
- "ConnectivityTest");
- mScreenonWakeLock.acquire();
+ mWakeLock = mPm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "ConnectivityTest");
+ mWakeLock.acquire();
+ mHandler2.sendMessage(mHandler2.obtainMessage(EVENT_TOGGLE_WIFI));
+ }
+ }
- scheduleAlarm(10, SCREEN_OFF);
+ private void onStopDelayedCycle() {
+ if (mDelayedCycleStarted) {
+ mDelayedCycleStarted = false;
+ mWakeLock.release();
+ mWakeLock = null;
+ if(mHandler2.hasMessages(EVENT_TOGGLE_WIFI)) {
+ mHandler2.removeMessages(EVENT_TOGGLE_WIFI);
+ }
}
- };
+ }
+
+ private void onStartScreenCycle() {
+ try {
+ mSCOnDuration = Long.parseLong(mSCOnDurationEdit.getText().toString());
+ mSCOffDuration = Long.parseLong(mSCOffDurationEdit.getText().toString());
+ } catch (Exception e) { };
+ mSCCycleCount = 0;
+
+ mScreenonWakeLock = mPm.newWakeLock(PowerManager.FULL_WAKE_LOCK,
+ "ConnectivityTest");
+ mScreenonWakeLock.acquire();
+
+ scheduleAlarm(10, SCREEN_OFF);
+ }
private void scheduleAlarm(long delayMs, String eventType) {
AlarmManager am = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
@@ -310,42 +361,189 @@ public class Connectivity extends Activity {
am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + delayMs, p);
}
- private View.OnClickListener mStopScreenCycleClicked = new View.OnClickListener() {
- public void onClick(View v) {
+ private void onStopScreenCycle() {
+ }
+
+ private void onCrash() {
+ ConnectivityManager foo = null;
+ foo.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,
+ Phone.FEATURE_ENABLE_MMS);
+ }
+
+ private void onAddDefaultRoute() {
+ try {
+ NetworkUtils.addRoute("eth0", "0.0.0.0", 0, "8.8.8.8");
+ } catch (Exception e) { }
+ }
+
+ private void onRemoveDefaultRoute() {
+ Log.e(TAG, "removeDefaultRoute returned "+NetworkUtils.removeDefaultRoute("eth0"));
+ }
+
+ private void onRoutedHttpRequest() {
+ onRoutedRequest(HTTP);
+ }
+
+ private void onRoutedSocketRequest() {
+ onRoutedRequest(SOCKET);
+ }
+
+ private final static int SOCKET = 1;
+ private final static int HTTP = 2;
+
+ private void onRoutedRequest(int type) {
+ String url = "www.google.com";
+
+ InetAddress inetAddress = null;
+ try {
+ inetAddress = InetAddress.getByName(url);
+ } catch (Exception e) {
+ Log.e(TAG, "error fetching address for " + url);
+ return;
}
- };
- private View.OnClickListener mStartMmsClicked = new View.OnClickListener() {
- public void onClick(View v) {
- mCm.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE, Phone.FEATURE_ENABLE_MMS);
+ mCm.requestRouteToHostAddress(ConnectivityManager.TYPE_MOBILE_HIPRI, inetAddress);
+
+ switch (type) {
+ case SOCKET:
+ onBoundSocketRequest();
+ break;
+ case HTTP:
+ HttpGet get = new HttpGet("http://" + url);
+ HttpClient client = new DefaultHttpClient();
+ try {
+ HttpResponse httpResponse = client.execute(get);
+ Log.d(TAG, "routed http request gives " + httpResponse.getStatusLine());
+ } catch (Exception e) {
+ Log.e(TAG, "routed http request exception = " + e);
+ }
}
- };
- private View.OnClickListener mStopMmsClicked = new View.OnClickListener() {
- public void onClick(View v) {
- mCm.stopUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE, Phone.FEATURE_ENABLE_MMS);
+ }
+
+ private void onBoundHttpRequest() {
+ NetworkInterface networkInterface = null;
+ try {
+ networkInterface = NetworkInterface.getByName("rmnet0");
+ Log.d(TAG, "networkInterface is " + networkInterface);
+ } catch (Exception e) {
+ Log.e(TAG, " exception getByName: " + e);
+ return;
+ }
+ if (networkInterface != null) {
+ Enumeration inetAddressess = networkInterface.getInetAddresses();
+ while(inetAddressess.hasMoreElements()) {
+ Log.d(TAG, " inetAddress:" + ((InetAddress)inetAddressess.nextElement()));
+ }
}
- };
- private View.OnClickListener mStartHiPriClicked = new View.OnClickListener() {
- public void onClick(View v) {
- mCm.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,
- Phone.FEATURE_ENABLE_HIPRI);
+ HttpParams httpParams = new BasicHttpParams();
+ if (networkInterface != null) {
+ ConnRouteParams.setLocalAddress(httpParams,
+ networkInterface.getInetAddresses().nextElement());
}
- };
+ HttpGet get = new HttpGet("http://www.bbc.com");
+ HttpClient client = new DefaultHttpClient(httpParams);
+ try {
+ HttpResponse response = client.execute(get);
+ Log.d(TAG, "response code = " + response.getStatusLine());
+ } catch (Exception e) {
+ Log.e(TAG, "Exception = "+ e );
+ }
+ }
- private View.OnClickListener mStopHiPriClicked = new View.OnClickListener() {
- public void onClick(View v) {
- mCm.stopUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,
- Phone.FEATURE_ENABLE_HIPRI);
+ private void onBoundSocketRequest() {
+ NetworkInterface networkInterface = null;
+ try {
+ networkInterface = NetworkInterface.getByName("rmnet0");
+ } catch (Exception e) {
+ Log.e(TAG, "exception getByName: " + e);
+ return;
}
- };
+ if (networkInterface == null) {
+ try {
+ Log.d(TAG, "getting any networkInterface");
+ networkInterface = NetworkInterface.getNetworkInterfaces().nextElement();
+ } catch (Exception e) {
+ Log.e(TAG, "exception getting any networkInterface: " + e);
+ return;
+ }
+ }
+ if (networkInterface == null) {
+ Log.e(TAG, "couldn't find a local interface");
+ return;
+ }
+ Enumeration inetAddressess = networkInterface.getInetAddresses();
+ while(inetAddressess.hasMoreElements()) {
+ Log.d(TAG, " addr:" + ((InetAddress)inetAddressess.nextElement()));
+ }
+ InetAddress local = null;
+ InetAddress remote = null;
+ try {
+ local = networkInterface.getInetAddresses().nextElement();
+ } catch (Exception e) {
+ Log.e(TAG, "exception getting local InetAddress: " + e);
+ return;
+ }
+ try {
+ remote = InetAddress.getByName("www.flickr.com");
+ } catch (Exception e) {
+ Log.e(TAG, "exception getting remote InetAddress: " + e);
+ return;
+ }
+ Log.d(TAG, "remote addr ="+remote);
+ Log.d(TAG, "local addr ="+local);
+ Socket socket = null;
+ try {
+ socket = new Socket(remote, 80, local, 6000);
+ } catch (Exception e) {
+ Log.e(TAG, "Exception creating socket: " + e);
+ return;
+ }
+ try {
+ PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
+ out.println("Hi flickr");
+ } catch (Exception e) {
+ Log.e(TAG, "Exception writing to socket: " + e);
+ return;
+ }
+ }
- private View.OnClickListener mCrashClicked = new View.OnClickListener() {
- public void onClick(View v) {
- ConnectivityManager foo = null;
- foo.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,
- Phone.FEATURE_ENABLE_MMS);
+ private void onDefaultRequest() {
+ HttpParams params = new BasicHttpParams();
+ HttpGet get = new HttpGet("http://www.cnn.com");
+ HttpClient client = new DefaultHttpClient(params);
+ try {
+ HttpResponse response = client.execute(get);
+ Log.e(TAG, "response code = " + response.getStatusLine());
+ } catch (Exception e) {
+ Log.e(TAG, "Exception = " + e);
}
- };
+ }
+
+ private void onDefaultSocket() {
+ InetAddress remote = null;
+ try {
+ remote = InetAddress.getByName("www.flickr.com");
+ } catch (Exception e) {
+ Log.e(TAG, "exception getting remote InetAddress: " + e);
+ return;
+ }
+ Log.e(TAG, "remote addr =" + remote);
+ Socket socket = null;
+ try {
+ socket = new Socket(remote, 80);
+ } catch (Exception e) {
+ Log.e(TAG, "Exception creating socket: " + e);
+ return;
+ }
+ try {
+ PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
+ out.println("Hi flickr");
+ Log.e(TAG, "written");
+ } catch (Exception e) {
+ Log.e(TAG, "Exception writing to socket: " + e);
+ return;
+ }
+ }
}
diff --git a/apps/Development/src/com/android/development/MediaScannerActivity.java b/apps/Development/src/com/android/development/MediaScannerActivity.java
index f78910ac4..04f641422 100644
--- a/apps/Development/src/com/android/development/MediaScannerActivity.java
+++ b/apps/Development/src/com/android/development/MediaScannerActivity.java
@@ -17,56 +17,239 @@
package com.android.development;
import android.app.Activity;
+import android.content.ContentResolver;
+import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.BroadcastReceiver;
+import android.database.sqlite.SQLiteConstraintException;
import android.net.Uri;
+import android.os.Bundle;
import android.os.Environment;
+import android.os.Handler;
+import android.os.Message;
+import android.provider.MediaStore;
+import android.provider.MediaStore.Audio;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.util.Log;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
import android.widget.TextView;
+import java.util.Random;
+
public class MediaScannerActivity extends Activity
{
+ private TextView mTitle;
+ private int mNumToInsert = 20;
+ private int mArtists;
+ private int mAlbums;
+ private int mSongs;
+ private ContentResolver mResolver;
+ private Uri mAudioUri;
+ ContentValues mValues[] = new ContentValues[10];
+ Random mRandom = new Random();
+ StringBuilder mBuilder = new StringBuilder();
+
public MediaScannerActivity() {
}
-
+
/** Called when the activity is first created or resumed. */
@Override
- public void onResume() {
- super.onResume();
-
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+
setContentView(R.layout.media_scanner_activity);
-
+
IntentFilter intentFilter = new IntentFilter(Intent.ACTION_MEDIA_SCANNER_STARTED);
intentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED);
intentFilter.addDataScheme("file");
registerReceiver(mReceiver, intentFilter);
-
- sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"
- + Environment.getExternalStorageDirectory())));
-
+
+ EditText t = (EditText) findViewById(R.id.numsongs);
+ t.addTextChangedListener(new TextWatcher() {
+
+ public void afterTextChanged(Editable s) {
+ String text = s.toString();
+ try {
+ mNumToInsert = Integer.valueOf(text);
+ } catch (NumberFormatException ex) {
+ mNumToInsert = 20;
+ }
+ setInsertButtonText();
+ }
+
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ }
+
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ }
+
+ });
mTitle = (TextView) findViewById(R.id.title);
- mTitle.setText("Sent ACTION_MEDIA_MOUNTED to trigger the Media Scanner.");
+ mResolver = getContentResolver();
+ mAudioUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
+
+ for (int i = 0; i < 10; i++) {
+ mValues[i] = new ContentValues();
+ }
+ setInsertButtonText();
}
/** Called when the activity going into the background or being destroyed. */
@Override
- public void onPause() {
- super.onPause();
+ public void onDestroy() {
unregisterReceiver(mReceiver);
+ mInsertHandler.removeMessages(0);
+ super.onDestroy();
}
-
+
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_MEDIA_SCANNER_STARTED)) {
- mTitle.setText("Media Scanner started scanning " + intent.getData().getPath());
+ mTitle.setText("Media Scanner started scanning " + intent.getData().getPath());
}
else if (intent.getAction().equals(Intent.ACTION_MEDIA_SCANNER_FINISHED)) {
- mTitle.setText("Media Scanner finished scanning " + intent.getData().getPath());
+ mTitle.setText("Media Scanner finished scanning " + intent.getData().getPath());
}
}
};
- private TextView mTitle;
+ public void startScan(View v) {
+ sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"
+ + Environment.getExternalStorageDirectory())));
+
+ mTitle.setText("Sent ACTION_MEDIA_MOUNTED to trigger the Media Scanner.");
+ }
+
+ private void setInsertButtonText() {
+ String label = getString(R.string.insertbutton, Integer.valueOf(mNumToInsert));
+ Button b = (Button) findViewById(R.id.insertbutton);
+ b.setText(label);
+ }
+
+
+ public void insertItems(View v) {
+ if (mInsertHandler.hasMessages(0)) {
+ mInsertHandler.removeMessages(0);
+ setInsertButtonText();
+ } else {
+ mInsertHandler.sendEmptyMessage(0);
+ }
+ }
+
+ Handler mInsertHandler = new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+
+ if (mNumToInsert-- > 0) {
+ addAlbum();
+ runOnUiThread(mDisplayUpdater);
+
+ if (!isFinishing()) {
+ sendEmptyMessage(0);
+ }
+ }
+ }
+ };
+
+ Runnable mDisplayUpdater = new Runnable() {
+ public void run() {
+ mTitle.setText("Added " + mArtists + " artists, " + mAlbums + " albums, "
+ + mSongs + " songs.");
+ }
+ };
+
+ // Add one more album (with 10 songs) to the database. This will be a compilation album,
+ // with one album artist for the album, and a separate artist for each song.
+ private void addAlbum() {
+ try {
+ String albumArtist = "Various Artists";
+ String albumName = getRandomWord(3);
+ int baseYear = 1969 + mRandom.nextInt(30);
+ for (int i = 0; i < 10; i++) {
+ mValues[i].clear();
+ String artist = getRandomName();
+ final ContentValues map = mValues[i];
+ map.put(MediaStore.MediaColumns.DATA,
+ "http://bogus/" + albumName + "/" + artist + "_" + i);
+ map.put(MediaStore.MediaColumns.TITLE,
+ getRandomWord(4) + " " + getRandomWord(2) + " " + (i + 1));
+ map.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3");
+
+ map.put(Audio.Media.ARTIST, artist);
+ map.put("album_artist", albumArtist);
+ map.put(Audio.Media.ALBUM, albumName);
+ map.put(Audio.Media.TRACK, i + 1);
+ map.put(Audio.Media.DURATION, 4*60*1000);
+ map.put(Audio.Media.IS_MUSIC, 1);
+ map.put(Audio.Media.YEAR, baseYear + mRandom.nextInt(10));
+ }
+ mResolver.bulkInsert(mAudioUri, mValues);
+ mSongs += 10;
+ mAlbums++;
+ mArtists += 11;
+ } catch (SQLiteConstraintException ex) {
+ Log.d("@@@@", "insert failed", ex);
+ }
+ }
+
+ /**
+ * Some code to generate random names. This just strings together random
+ * syllables, and randomly inserts a modifier between the first
+ * and last name.
+ */
+ private String[] elements = new String[] {
+ "ab", "am",
+ "bra", "bri",
+ "ci", "co",
+ "de", "di", "do",
+ "fa", "fi",
+ "ki",
+ "la", "li",
+ "ma", "me", "mi", "mo",
+ "na", "ni",
+ "pa",
+ "ta", "ti",
+ "vi", "vo"
+ };
+
+ private String getRandomWord(int len) {
+ int max = elements.length;
+ mBuilder.setLength(0);
+ for (int i = 0; i < len; i++) {
+ mBuilder.append(elements[mRandom.nextInt(max)]);
+ }
+ char c = mBuilder.charAt(0);
+ c = Character.toUpperCase(c);
+ mBuilder.setCharAt(0, c);
+ return mBuilder.toString();
+ }
+
+ private String getRandomName() {
+ boolean longfirst = mRandom.nextInt(5) < 3;
+ String first = getRandomWord(longfirst ? 3 : 2);
+ String last = getRandomWord(3);
+ switch (mRandom.nextInt(6)) {
+ case 1:
+ if (!last.startsWith("Di")) {
+ last = "di " + last;
+ }
+ break;
+ case 2:
+ last = "van " + last;
+ break;
+ case 3:
+ last = "de " + last;
+ break;
+ }
+ return first + " " + last;
+ }
+
+
+
}
diff --git a/apps/GraphicsLab/Android.mk b/apps/GraphicsLab/Android.mk
deleted file mode 100644
index e8dd114d7..000000000
--- a/apps/GraphicsLab/Android.mk
+++ /dev/null
@@ -1,10 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := GraphicsLab
-
-include $(BUILD_PACKAGE)
diff --git a/apps/GraphicsLab/AndroidManifest.xml b/apps/GraphicsLab/AndroidManifest.xml
deleted file mode 100644
index a91c4fad3..000000000
--- a/apps/GraphicsLab/AndroidManifest.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.graphicslab">
- <application android:label="Graphics Lab">
- <activity android:name="GraphicsLab">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.DEFAULT" />
- <category android:name="android.intent.category.TEST" />
- </intent-filter>
- </activity>
- </application>
-</manifest>
diff --git a/apps/GraphicsLab/MODULE_LICENSE_APACHE2 b/apps/GraphicsLab/MODULE_LICENSE_APACHE2
deleted file mode 100644
index e69de29bb..000000000
--- a/apps/GraphicsLab/MODULE_LICENSE_APACHE2
+++ /dev/null
diff --git a/apps/GraphicsLab/NOTICE b/apps/GraphicsLab/NOTICE
deleted file mode 100644
index c5b1efa7a..000000000
--- a/apps/GraphicsLab/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2005-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.
-
- 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.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/apps/GraphicsLab/res/drawable/beach.jpg b/apps/GraphicsLab/res/drawable/beach.jpg
deleted file mode 100644
index ae9794fc0..000000000
--- a/apps/GraphicsLab/res/drawable/beach.jpg
+++ /dev/null
Binary files differ
diff --git a/apps/GraphicsLab/res/drawable/news_img.jpg b/apps/GraphicsLab/res/drawable/news_img.jpg
deleted file mode 100644
index 16a5ecb94..000000000
--- a/apps/GraphicsLab/res/drawable/news_img.jpg
+++ /dev/null
Binary files differ
diff --git a/apps/GraphicsLab/res/layout/graphics_lab.xml b/apps/GraphicsLab/res/layout/graphics_lab.xml
deleted file mode 100644
index 7c0e5d9f6..000000000
--- a/apps/GraphicsLab/res/layout/graphics_lab.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2009 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:id="@+id/content"
- android:layout_width="match_parent" android:layout_height="match_parent"
- android:orientation="vertical"
- android:paddingLeft="4dip" android:paddingRight="4dip"
- android:paddingTop="4dip" android:paddingBottom="4dip">
-</LinearLayout>
-
-
diff --git a/apps/GraphicsLab/src/com/android/graphicslab/GraphicsLab.java b/apps/GraphicsLab/src/com/android/graphicslab/GraphicsLab.java
deleted file mode 100644
index dd5ac5bc4..000000000
--- a/apps/GraphicsLab/src/com/android/graphicslab/GraphicsLab.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.graphicslab;
-
-import java.util.Map;
-
-import android.app.Activity;
-import android.content.Context;
-import android.graphics.*;
-import android.graphics.utils.*;
-import android.os.Bundle;
-import android.os.SystemClock;
-import android.view.*;
-
-public class GraphicsLab extends Activity {
- public GraphicsLab() {}
-
- private int mCurrView = 1;
-
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- setContentView(new SampleView(this));
-// setTitle("Graphics Lab");
- }
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- switch(keyCode) {
- case KeyEvent.KEYCODE_DPAD_CENTER:
- if (mCurrView == 1) {
- setContentView(new SampleView2(this));
- mCurrView = 2;
- } else {
- setContentView(new SampleView(this));
- mCurrView = 1;
- }
- }
- return super.onKeyDown(keyCode, event);
- }
-
- private static class SampleView2 extends View {
- private static final int ROWS = 16;
- private static final int COLS = 16;
- private static final int UNSTRETCH_MSEC = 250;
-
- private Interpolator mInterp;
- private BoundaryPatch mPatch;
- private float[] mCubics;
- private float[] mOrig = new float[24];
- private Paint mPaint0;
- private Paint mPaint1;
- private int mCurrIndex = -1;
- private float mPrevX;
- private float mPrevY;
-
- public SampleView2(Context context) {
- super(context);
- setFocusable(true);
-
- Bitmap bm = BitmapFactory.decodeResource(getResources(),
- R.drawable.news_img);
-
- mPatch = new BoundaryPatch();
- mPatch.setTexture(bm);
-
- float unit = 90;
- mCubics = new float[] {
- 0, 0, 1, 0, 2, 0,
- 3, 0, 3, 1, 3, 2,
- 3, 3, 2, 3, 1, 3,
- 0, 3, 0, 2, 0, 1
- };
- for (int i = 0; i < 24; i++) {
- mCubics[i] *= 90;
- mCubics[i] += 20;
- }
- rebuildPatch();
-
- mPaint0 = new Paint();
- mPaint0.setAntiAlias(true);
- mPaint0.setStrokeWidth(12);
- mPaint0.setStrokeCap(Paint.Cap.ROUND);
- mPaint1 = new Paint(mPaint0);
- mPaint1.setColor(0xFFFFFFFF);
- mPaint1.setStrokeWidth(10);
- }
-
- @Override
- protected void onSizeChanged(int nw, int nh, int ow, int oh) {
- float[] pts = mCubics;
- float x1 = nw*0.3333f;
- float y1 = nh*0.3333f;
- float x2 = nw*0.6667f;
- float y2 = nh*0.6667f;
- pts[0*2+0] = 0; pts[0*2+1] = 0;
- pts[1*2+0] = x1; pts[1*2+1] = 0;
- pts[2*2+0] = x2; pts[2*2+1] = 0;
-
- pts[3*2+0] = nw; pts[3*2+1] = 0;
- pts[4*2+0] = nw; pts[4*2+1] = y1;
- pts[5*2+0] = nw; pts[5*2+1] = y2;
-
- pts[6*2+0] = nw; pts[6*2+1] = nh;
- pts[7*2+0] = x2; pts[7*2+1] = nh;
- pts[8*2+0] = x1; pts[8*2+1] = nh;
-
- pts[9*2+0] = 0; pts[9*2+1] = nh;
- pts[10*2+0] = 0; pts[10*2+1] = y2;
- pts[11*2+0] = 0; pts[11*2+1] = y1;
-
- System.arraycopy(pts, 0, mOrig, 0, 24);
- rebuildPatch();
- }
-
- @Override protected void onDraw(Canvas canvas) {
- if (mInterp != null) {
- int now = (int)SystemClock.uptimeMillis();
- Interpolator.Result result = mInterp.timeToValues(now, mCubics);
- if (result != Interpolator.Result.NORMAL) {
- mInterp = null;
- } else {
- invalidate();
- }
- rebuildPatch();
- }
- mPatch.draw(canvas);
- }
-
- private void rebuildPatch() {
- mPatch.setCubicBoundary(mCubics, 0, ROWS, COLS);
- }
-
- @Override public boolean onTouchEvent(MotionEvent event) {
- float x = event.getX();
- float y = event.getY();
- switch (event.getAction()) {
- case MotionEvent.ACTION_DOWN:
- System.arraycopy(mOrig, 0, mCubics, 0, 24);
- mPrevX = x;
- mPrevY = y;
- break;
- case MotionEvent.ACTION_MOVE: {
- float scale = 1.5f;
- float dx = (x - mPrevX) * scale;
- float dy = (y - mPrevY) * scale;
- int index;
-
- if (dx < 0) {
- index = 10;
- } else {
- index = 4;
- }
- mCubics[index*2 + 0] = mOrig[index*2 + 0] + dx;
- mCubics[index*2 + 2] = mOrig[index*2 + 2] + dx;
-
- if (dy < 0) {
- index = 1;
- } else {
- index = 7;
- }
- mCubics[index*2 + 1] = mOrig[index*2 + 1] + dy;
- mCubics[index*2 + 3] = mOrig[index*2 + 3] + dy;
-
- rebuildPatch();
- invalidate();
- } break;
- case MotionEvent.ACTION_UP:
- case MotionEvent.ACTION_CANCEL: {
- int start = (int)SystemClock.uptimeMillis();
- mInterp = new Interpolator(24);
- mInterp.setKeyFrame(0, start, mCubics,
- new float[] { 0, 0.5f, 0.5f, 1 });
- mInterp.setKeyFrame(1, start + UNSTRETCH_MSEC, mOrig
- );
- invalidate();
- } break;
- }
- return true;
- }
- }
-
- private static class SampleView extends View {
- private static final int ROWS = 16;
- private static final int COLS = 16;
-
- private BoundaryPatch mPatch;
- private float[] mCubics;
- private float[] mOrig = new float[24];
- private Paint mPaint0;
- private Paint mPaint1;
- private int mCurrIndex = -1;
- private float mPrevX;
- private float mPrevY;
-
- public SampleView(Context context) {
- super(context);
- setFocusable(true);
-
- Bitmap bm = BitmapFactory.decodeResource(getResources(),
- R.drawable.beach);
-
- mPatch = new BoundaryPatch();
- mPatch.setTexture(bm);
-
- float unit = 90;
- mCubics = new float[] {
- 0, 0, 1, 0, 2, 0,
- 3, 0, 3, 1, 3, 2,
- 3, 3, 2, 3, 1, 3,
- 0, 3, 0, 2, 0, 1
- };
- for (int i = 0; i < 24; i++) {
- mCubics[i] *= 90;
- mCubics[i] += 20;
- }
- rebuildPatch();
-
- mPaint0 = new Paint();
- mPaint0.setAntiAlias(true);
- mPaint0.setStrokeWidth(12);
- mPaint0.setStrokeCap(Paint.Cap.ROUND);
- mPaint1 = new Paint(mPaint0);
- mPaint1.setColor(0xFFFFFFFF);
- mPaint1.setStrokeWidth(10);
- }
-
- @Override protected void onDraw(Canvas canvas) {
- canvas.drawColor(0xFFCCCCCC);
- mPatch.draw(canvas);
- canvas.drawPoints(mCubics, mPaint0);
- canvas.drawPoints(mCubics, mPaint1);
- }
-
- private void rebuildPatch() {
- mPatch.setCubicBoundary(mCubics, 0, ROWS, COLS);
- }
-
- private int findPtIndex(float x, float y) {
- final float tolerance = 25;
- final float[] pts = mCubics;
- for (int i = 0; i < (pts.length >> 1); i++) {
- if (Math.abs(pts[i*2 + 0] - x) <= tolerance &&
- Math.abs(pts[i*2 + 1] - y) <= tolerance) {
- return i*2;
- }
- }
- return -1;
- }
-
- private void offsetPts(float dx, float dy) {
- final float[] pts = mCubics;
- for (int i = 0; i < (pts.length >> 1); i++) {
- pts[i*2 + 0] += dx;
- pts[i*2 + 1] += dy;
- }
- rebuildPatch();
- }
-
- @Override public boolean onTouchEvent(MotionEvent event) {
- float x = event.getX();
- float y = event.getY();
- switch (event.getAction()) {
- case MotionEvent.ACTION_DOWN:
- mCurrIndex = findPtIndex(x, y);
- mPrevX = x;
- mPrevY = y;
- break;
- case MotionEvent.ACTION_MOVE:
- if (mCurrIndex >= 0) {
- mCubics[mCurrIndex + 0] = x;
- mCubics[mCurrIndex + 1] = y;
- mPatch.setCubicBoundary(mCubics, 0, ROWS, COLS);
- } else {
- offsetPts(x - mPrevX, y - mPrevY);
- mPrevX = x;
- mPrevY = y;
- }
- invalidate();
- break;
- }
- return true;
- }
-}
-}
-