Merge "Apparently wxImage::HasAlpha and wxMenuBase::AppendSeparator are not present (anymore?) in the wx2.6 .so, but gcc wants to use the exported functions instead of inlining them. Comment them out for now."
diff --git a/apps/Development/AndroidManifest.xml b/apps/Development/AndroidManifest.xml
index 981d506..827b57a 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" />
diff --git a/apps/Development/res/layout/connectivity.xml b/apps/Development/res/layout/connectivity.xml
index 612304f..ff0c6ea 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/values/strings.xml b/apps/Development/res/values/strings.xml
index d144b8f..422bd7f 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>
diff --git a/apps/Development/src/com/android/development/Connectivity.java b/apps/Development/src/com/android/development/Connectivity.java
index 59157bf..c7029ec 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.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 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
super.onResume();
}
- private View.OnClickListener mStartDelayedCycleClicked = new View.OnClickListener() {
+ private View.OnClickListener mClickListener = 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() {
- 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();
-
- scheduleAlarm(10, SCREEN_OFF);
+ mWakeLock = mPm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "ConnectivityTest");
+ mWakeLock.acquire();
+ mHandler2.sendMessage(mHandler2.obtainMessage(EVENT_TOGGLE_WIFI));
}
- };
+ }
+
+ 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 @@
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 View.OnClickListener mStartMmsClicked = new View.OnClickListener() {
- public void onClick(View v) {
- mCm.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE, Phone.FEATURE_ENABLE_MMS);
- }
- };
+ private void onCrash() {
+ ConnectivityManager foo = null;
+ foo.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,
+ Phone.FEATURE_ENABLE_MMS);
+ }
- private View.OnClickListener mStopMmsClicked = new View.OnClickListener() {
- public void onClick(View v) {
- mCm.stopUsingNetworkFeature(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 View.OnClickListener mStartHiPriClicked = new View.OnClickListener() {
- public void onClick(View v) {
- mCm.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,
- Phone.FEATURE_ENABLE_HIPRI);
- }
- };
+ private void onRemoveDefaultRoute() {
+ Log.e(TAG, "removeDefaultRoute returned "+NetworkUtils.removeDefaultRoute("eth0"));
+ }
- private View.OnClickListener mStopHiPriClicked = new View.OnClickListener() {
- public void onClick(View v) {
- mCm.stopUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,
- Phone.FEATURE_ENABLE_HIPRI);
- }
- };
+ private void onRoutedHttpRequest() {
+ onRoutedRequest(HTTP);
+ }
- 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 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;
}
- };
+
+ 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 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()));
+ }
+ }
+
+ 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 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 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/samples/ApiDemos/AndroidManifest.xml b/samples/ApiDemos/AndroidManifest.xml
index c7e61cb..d0d80eb 100644
--- a/samples/ApiDemos/AndroidManifest.xml
+++ b/samples/ApiDemos/AndroidManifest.xml
@@ -209,6 +209,14 @@
</intent-filter>
</activity>
+ <activity android:name=".app.ScreenOrientation"
+ android:label="@string/activity_screen_orientation">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.SAMPLE_CODE" />
+ </intent-filter>
+ </activity>
+
<!-- Fragment Samples -->
<activity android:name=".app.FragmentAlertDialog"
diff --git a/samples/ApiDemos/res/layout/screen_orientation.xml b/samples/ApiDemos/res/layout/screen_orientation.xml
new file mode 100644
index 0000000..b5943e2
--- /dev/null
+++ b/samples/ApiDemos/res/layout/screen_orientation.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 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.
+-->
+
+<!-- Demonstrates implementation of a DeviceAdmin. -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical" android:padding="4dip"
+ 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:layout_weight="0"
+ android:paddingBottom="4dip"
+ android:text="@string/screen_orientation_summary"/>
+
+ <Spinner android:id="@+id/orientation"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:drawSelectorOnTop="true"
+ android:prompt="@string/screen_orientation">
+ </Spinner>
+</LinearLayout>
+
diff --git a/samples/ApiDemos/res/values/arrays.xml b/samples/ApiDemos/res/values/arrays.xml
index e1ef7e8..aac4f79 100644
--- a/samples/ApiDemos/res/values/arrays.xml
+++ b/samples/ApiDemos/res/values/arrays.xml
@@ -103,6 +103,22 @@
<item>Complex</item>
</string-array>
+ <!-- Used in app/Screen Orientation -->
+ <string-array name="screen_orientations">
+ <item>UNSPECIFIED</item>
+ <item>LANDSCAPE</item>
+ <item>PORTRAIT</item>
+ <item>USER</item>
+ <item>BEHIND</item>
+ <item>SENSOR</item>
+ <item>NOSENSOR</item>
+ <item>SENSOR_LANDSCAPE</item>
+ <item>SENSOR_PORTRAIT</item>
+ <item>REVERSE_LANDSCAPE</item>
+ <item>REVERSE_PORTRAIT</item>
+ <item>FULL_SENSOR</item>
+ </string-array>
+
<!-- Used in view/Secure View examples -->
<string-array name="secure_view_clicked">
<item>*bzzt*\nTransferred $1,000,000 to J. Phisher. Thank you!</item>
diff --git a/samples/ApiDemos/res/values/strings.xml b/samples/ApiDemos/res/values/strings.xml
index 8c351b0..77c634a 100644
--- a/samples/ApiDemos/res/values/strings.xml
+++ b/samples/ApiDemos/res/values/strings.xml
@@ -44,6 +44,12 @@
<string name="set_wallpaper">Set Wallpaper</string>
<string name="randomize">Randomize</string>
+ <string name="activity_screen_orientation">App/Activity/Screen Orientation</string>
+ <string name="screen_orientation_summary">Demonstrates the available screen
+ orientation modes. Often you want to set the desired mode in your manifest
+ instead of programmatically.</string>
+ <string name="screen_orientation">Screen Orientation</string>
+
<string name="activity_translucent">App/Activity/Translucent</string>
<string name="translucent_background">Example of how you can make an
activity have a translucent background, compositing over
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/ScreenOrientation.java b/samples/ApiDemos/src/com/example/android/apis/app/ScreenOrientation.java
new file mode 100644
index 0000000..3946b2a
--- /dev/null
+++ b/samples/ApiDemos/src/com/example/android/apis/app/ScreenOrientation.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2010 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.example.android.apis.app;
+
+import com.example.android.apis.R;
+
+import android.app.Activity;
+import android.app.admin.DevicePolicyManager;
+import android.content.pm.ActivityInfo;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.Spinner;
+import android.widget.AdapterView.OnItemSelectedListener;
+
+public class ScreenOrientation extends Activity {
+ Spinner mOrientation;
+
+ // Orientation spinner choices
+ // This list must match the list found in samples/ApiDemos/res/values/arrays.xml
+ final static int mOrientationValues[] = new int[] {
+ ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED,
+ ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE,
+ ActivityInfo.SCREEN_ORIENTATION_PORTRAIT,
+ ActivityInfo.SCREEN_ORIENTATION_USER,
+ ActivityInfo.SCREEN_ORIENTATION_BEHIND,
+ ActivityInfo.SCREEN_ORIENTATION_SENSOR,
+ ActivityInfo.SCREEN_ORIENTATION_NOSENSOR,
+ ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE,
+ ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT,
+ ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE,
+ ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT,
+ ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR,
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.screen_orientation);
+
+ mOrientation = (Spinner)findViewById(R.id.orientation);
+ ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
+ this, R.array.screen_orientations, android.R.layout.simple_spinner_item);
+ adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ mOrientation.setAdapter(adapter);
+ mOrientation.setOnItemSelectedListener(
+ new OnItemSelectedListener() {
+ public void onItemSelected(
+ AdapterView<?> parent, View view, int position, long id) {
+ setRequestedOrientation(mOrientationValues[position]);
+ }
+
+ public void onNothingSelected(AdapterView<?> parent) {
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
+ }
+ });
+ }
+}
diff --git a/samples/NotePad/AndroidManifest.xml b/samples/NotePad/AndroidManifest.xml
index 7d3ce43..82fcead 100644
--- a/samples/NotePad/AndroidManifest.xml
+++ b/samples/NotePad/AndroidManifest.xml
@@ -27,7 +27,9 @@
>
<provider android:name="NotePadProvider"
android:authorities="com.google.provider.NotePad"
- />
+ android:exported="false">
+ <grant-uri-permission android:pathPattern=".*" />
+ </provider>
<activity android:name="NotesList" android:label="@string/title_notes_list">
<intent-filter>