help proxy settings for android 2.0 - Android Software Development

hello ,
i am looking for a way to set the proxy settings in my nexus one , i found some interesting articles on the net on how to put proxy settings on 1.5 but none for 2.0 , also some one suggested that there is this code in the browser which make it ignores any proxy settings
Code:
//
// start MASF proxy service
//
//Intent proxyServiceIntent = new Intent();
//proxyServiceIntent.setComponent
// (new ComponentName(
// "com.android.masfproxyservice",
// "com.android.masfproxyservice.MasfProxyService"));
//startService(proxyServiceIntent, null);
is there away around it , or we do have to make another browser which doesnt ignore proxy settings?

Related

SMS to Email Address programatically?

I did a search in the forum, and didn't see if this is mentioned, so forgive me if this has been discussed.
I am trying to programatically send an SMS to a normal email address... and I know the phone can do it (AT&T Tilt, AT&T service), as I can do it manually. My first approach (as to not start monkeying around with the MAPI stuff) is to try the SMS API (sms.h and sms.lib). I am trying to use the SmsSendMessage function. My code works great for messages to other phones, but fails with the very informative return code of E_FAIL when sending to a "normal" email address.
Is there a trick or a setting that I am missing?
Here is a code sample of what I am trying to do:
Code:
BOOL CSMSSender::Send( wchar_t *message )
{
if( message == NULL )
{
return FALSE;
}
SMS_HANDLE smsHandle;
SMS_ADDRESS source;
SMS_ADDRESS dest;
TEXT_PROVIDER_SPECIFIC_DATA textData;
SMS_MESSAGE_ID messageId;
HRESULT result = S_OK;
BOOL retVal = TRUE;
result = SmsOpen( SMS_MSGTYPE_TEXT, SMS_MODE_SEND, &smsHandle, NULL );
if( result != S_OK )
{
return FALSE;
}
// Setup source address...
dest.smsatAddressType = SMSAT_UNKNOWN;
_tcsncpy( dest.ptsAddress, GetSmsAddr( ), SMS_MAX_ADDRESS_LENGTH );
// Setup the provider information...
memset( &textData, 0, sizeof( textData ) );
textData.dwMessageOptions = PS_MESSAGE_OPTION_NONE; // No confirmation...
textData.psMessageClass = PS_MESSAGE_CLASS1;
textData.psReplaceOption = PSRO_NONE;
textData.dwHeaderDataSize = 0;
result = SmsSendMessage( smsHandle,
NULL,
&dest,
NULL,
(PBYTE) message,
_tcslen( message ) * sizeof (wchar_t),
(PBYTE) &textData,
sizeof( TEXT_PROVIDER_SPECIFIC_DATA ),
SMSDE_OPTIMAL,
SMS_OPTION_DELIVERY_NONE,
&messageId );
if( result != S_OK )
{
retVal = FALSE;
goto EXIT;
}
EXIT:
result = SmsClose( smsHandle );
if( result != S_OK )
{
retVal = FALSE;
}
return retVal;
}
You can probably guess that GetSmsAddr( ) returns a wchar_t * that is the address I am trying to send it to. When it is a phone number, works swimmingly, when it is a "normal" email address, it fails. This is, of course, a snippet of a much larger system, but the only SMS specific stuff, and the stuff that gives me the problems. So, if you wonder "why did he do it this way", probably stuff missing that would make it more clear.
If the answer is to go swimming in the mess that is MAPI, then so be it... but would like to know if there is an easier answer before I put on my trunks...
Take Care,
Wicked96SS
Found the solution... I feel dumb... It is actually pretty easy. The provider is the one that does the conversion from SMS to "normal" email. And you have to send the SMS to the email gateway. The SMS has to be specially formatted. Here is a non comprehensive list of the formats expected by certain vendors:
Format (Carrier;SMS to Email Gateway Number;Text Format)
AT&T (Formerly Cingular) USA;111 or 121;emailaddress (subject) text
CTI (Argentina);6425;emailaddress (subject) text
Swisscom Mobile AG (only Switzerland);555;<emailaddress> <subject>/<text>
T-Mobile Austria http://t-mobile.at;6761;<emailaddress> <text>
T-Mobile (USA);500;<emailaddress> / <subject> / <text>
Anyhow, still looking for Verizon and some others, but i am sure they are simple.
So, if configured like that, and sent to the correct number, I do get SMS messages to normal email accounts.
Code snippet for AT&T
Code:
result = SmsOpen( SMS_MSGTYPE_TEXT, SMS_MODE_SEND, &smsHandle, NULL );
if( result != S_OK )
{
return SMS_INIT_FAILED;
}
// Setup source address...
dest.smsatAddressType = SMSAT_UNKNOWN;
_tcsncpy( dest.ptsAddress, L"111", SMS_MAX_ADDRESS_LENGTH );
// Setup the provider information...
memset( &textData, 0, sizeof( textData ) );
textData.dwMessageOptions = PS_MESSAGE_OPTION_NONE; // No confirmation...
textData.psMessageClass = PS_MESSAGE_CLASS1;
textData.psReplaceOption = PSRO_NONE;
textData.dwHeaderDataSize = 0;
std::wstring body;
body = L"[email protected](Hi!)Here is the body";
result = SmsSendMessage( smsHandle,
NULL,
&dest,
NULL,
(PBYTE) body.c_str( ),
_tcslen( body.c_str( ) ) * sizeof (wchar_t),
(PBYTE) &textData,
sizeof( TEXT_PROVIDER_SPECIFIC_DATA ),
SMSDE_OPTIMAL,
SMS_OPTION_DELIVERY_NONE,
&messageId );
Question on Normal Emails
I found your posting and it works great for sending sms messages to cell phone emails.
I found this link that shows the other gateways you were looking for.
http://en.wikipedia.org/wiki/SMS_gateways
My question is did you ever get this to work to send emails to network email address like [email protected]
let me know if you have any suggestions.
Thanks in Advance
ColoradoGene
hello ColoradoGene! Sorry for the time it took to respond, but yes, I have been able to send SMS messages to email addresses... the message has to be formatted correctly. The source code in my post (#2) will work for AT&T.
What problems are you actually having?

PPC with Windows Mobile as Server

I have tried for some hours now to catch the problem, nowhere are good resources to read.
I have a server application running on my phone (Windows Mobile 6.1)
Binding the TCP Listener to 127.0.0.1ORT does work, if I type the URL from within the device.
Then I tried to connect via WIFI. At first: All WiFi Settings are correct, I know all IPs and pings are possible ... BUT: When I try to access the server from within the wifi network I don't get through. I've bound the listener for testing purposes to 127.0.0.1 and to the IP of my Wifi card. but nothing helped. Is there a kind of firewall or why can't I use a socket connection from PC to PPC?
This should work. I've create a remote-control program via TCP/IP and there were no issues.
Can you post the code for Bind / Listen?
radhoo said:
Can you post the code for Bind / Listen?
Click to expand...
Click to collapse
Code:
byte[] byteBuffer = new byte[1024];
string stringBuffer = null;
[COLOR="Red"] IPAddress localhost = IPAddress.Parse("0.0.0.0");
// I also tried 127.0.0.1 and the IP of my phone in WiFi
TcpListener httpDaemon = new TcpListener(localhost, 80);
httpDaemon.Start();
[/COLOR]
while (true)
{
TcpClient httpBrowser = httpDaemon.AcceptTcpClient();
NetworkStream commStream = httpBrowser.GetStream();
int i;
// Loop to receive all the data sent by the client.
while ((i = commStream.Read(byteBuffer, 0, byteBuffer.Length)) != 0)
{
stringBuffer = System.Text.Encoding.ASCII.GetString(byteBuffer, 0, i);
}
MessageBox.Show(stringBuffer);
httpBrowser.Close();
Provided your code is good, maybe check if the socket is actually listening, there's netstat tool in dotFred's task manager: http://www.dotfred.net/TaskMgr.htm
Furthermore, you can see if the traffic ever reaches your PPC with hSniffer:
http://winm-soft.atspace.com/
You don't seem to be checking any of the return values.
Have you done that?
You might be facing different conditions than when you bind to the loopback adapter.
theq86 said:
Code:
byte[] byteBuffer = new byte[1024];
string stringBuffer = null;
[COLOR="Red"] IPAddress localhost = IPAddress.Parse("0.0.0.0");
// I also tried 127.0.0.1 and the IP of my phone in WiFi
TcpListener httpDaemon = new TcpListener(localhost, 80);
httpDaemon.Start();
[/COLOR]
while (true)
{
TcpClient httpBrowser = httpDaemon.AcceptTcpClient();
NetworkStream commStream = httpBrowser.GetStream();
int i;
// Loop to receive all the data sent by the client.
while ((i = commStream.Read(byteBuffer, 0, byteBuffer.Length)) != 0)
{
stringBuffer = System.Text.Encoding.ASCII.GetString(byteBuffer, 0, i);
}
MessageBox.Show(stringBuffer);
httpBrowser.Close();
Click to expand...
Click to collapse
try other different port rather than http port = 80
mobile phone not design to be a web server.

[Q] Autodiscovery for Activesync

I recently found out that the autodiscovery process in Android's email application is incomplete. It will only query https://domain.com/autodiscover/autodiscover.xml and https://autodiscover.domain.com/autodiscover/autodiscover.xml
I know this because I checked the source.
I only have a trusted certificate for mail.mydomain.com, so I need to tell the activesync client this. The people at Microsoft thought of a way to do this, but it involves querying an SRV-record in DNS (host -t srv _autodiscover._tcp.domain.com).
This is not done by the email-client in Android.
The full procedure for autodiscovery is described here:
http://technet.microsoft.com/en-us/library/bb332063(EXCHG.80).aspx
This is the code I found on http://android.git.kernel.org
EasSyncService.java
Code:
// There are up to four attempts here; the two URLs that we're supposed to try per the
// specification, and up to one redirect for each (handled in postAutodiscover)
// Note: The expectation is that, of these four attempts, only a single server will
// actually be identified as the autodiscover server. For the identified server,
// we may also try a 2nd connection with a different format (bare name).
// Try the domain first and see if we can get a response
HttpPost post = new HttpPost("https://" + domain + AUTO_DISCOVER_PAGE);
setHeaders(post, false);
post.setHeader("Content-Type", "text/xml");
post.setEntity(new StringEntity(req));
HttpClient client = getHttpClient(COMMAND_TIMEOUT);
HttpResponse resp;
try {
resp = postAutodiscover(client, post, true /*canRetry*/);
} catch (IOException e1) {
userLog("IOException in autodiscover; trying alternate address");
// We catch the IOException here because we have an alternate address to try
post.setURI(URI.create("https://autodiscover." + domain + AUTO_DISCOVER_PAGE));
// If we fail here, we're out of options, so we let the outer try catch the
// IOException and return null
resp = postAutodiscover(client, post, true /*canRetry*/);
}
I already wrote the coder of Android's email application (Marc Blank) an email, but I didn't get a reply.
I am not a java-developer nor do I have write access for Android's source code (obviously). Is there anyone here on this board who can help me to get this full procedure incorporated into Android's code?

APN type IA and broken tethering

After the kitkat update, I see in my APN settings two records.
One like we have used to have to far (APN type default,supl) and one with APN type ia and no APN value.
This has completely broken my tethering using vodafone GR (202 05).
Does anyone know what APN type "ia" is?
+1
georgemv said:
After the kitkat update, I see in my APN settings two records.
One like we have used to have to far (APN type default,supl) and one with APN type ia and no APN value.
This has completely broken my tethering using vodafone GR (202 05).
Does anyone know what APN type "ia" is?
Click to expand...
Click to collapse
+1, what's type ia?
/**
* APN types for data connections. These are usage categories for an APN
* entry. One APN entry may support multiple APN types, eg, a single APN
* may service regular internet traffic ("default") as well as MMS-specific
* connections.<br/>
* APN_TYPE_ALL is a special type to indicate that this APN entry can
* service all data connections.
*/
public static final String APN_TYPE_ALL = "*";
/** APN type for default data traffic */
public static final String APN_TYPE_DEFAULT = "default";
/** APN type for MMS traffic */
public static final String APN_TYPE_MMS = "mms";
/** APN type for SUPL assisted GPS */
public static final String APN_TYPE_SUPL = "supl";
/** APN type for DUN traffic */
public static final String APN_TYPE_DUN = "dun";
/** APN type for HiPri traffic */
public static final String APN_TYPE_HIPRI = "hipri";
/** APN type for FOTA */
public static final String APN_TYPE_FOTA = "fota";
/** APN type for IMS */
public static final String APN_TYPE_IMS = "ims";
/** APN type for CBS */
public static final String APN_TYPE_CBS = "cbs";
/** APN type for IA Initial Attach APN */
public static final String APN_TYPE_IA = "ia";
/** APN type for IA Emergency PDN */
public static final String APN_TYPE_EMERGENCY = "emergency";

Samsung devices not sending IPv6 Multicast datagrams

Hey, sorry if this is in the wrong forum, but I was not exactly sure where to post this.
I'm facing problems sending UDP packets over IPv6 multicast addresses on Galaxy devices.
Particularly, I want to send a Wake-on-LAN Magic Packet over IPv6 to wake up a PC in a different network. That PC is only reachable from outside via IPv6. Since it doesn't have an IP address when it's turned off, I can't send the Magic Packet directly to the computer and need to broadcast it over the network. I'm pretty new to IPv6, so I had to do some research on how to broadcast packets over IPv6 first and I'm not quite sure, if I'm doing everything correctly.
So, let's suppose the network the PC is connected to has the following network prefix:
2a02:123:4567:89ab::/64
According to RFC3306, I can use that prefix to derive a global multicast address, which would be the following:
ff3e:40:2a02:123:4567:89ab:0:0
Packets sent to this address should reach all devices on the network.
I wrote a small method to send a UDP packet to that multicast IP address and checked with Wireshark, if the packets were received or not.
When I run the method in a regular Java application, everything works fine and the packet is received by all devices on the network. When I use the same method in an Android app, I notice a strange behavior. If I send the packet from Non-Samsung devices (e.g. Blackview BV2000s) there are no problems. But from Samsung devices (Galaxy S3, S6 and Note 4 to be precise), the packet is not received by the PC. I think, the devices don't even send out the packet. Strange enough, if I address the PC directly with it's unicast address (e.g. 2a02:123:4567:89ab:cdef:fedc:ba98:7654), the packet is sent and received without any problems. So the problem only occurs on Samsung devices and only when sending to multicast addresses.
I'm using the following method to send the packet:
Java:
public void sendMagicPacket(String host, int port, String macAddress) {
try {
InetAddress address = InetAddress.getByName(host);
String[] macData = macAddress.split("\\:");
byte[] mac = new byte[6];
for (int i = 0; i < 6; i++) {
mac[i] = (byte)Short.parseShort(macData[i], 16);
}
byte[] magic = new byte [102];
for (int i = 0; i < 6; i++) {
magic[i] = (byte)0xff;
}
for (int i = 6; i < 102; i++) {
magic[i] = mac[i%6];
}
DatagramPacket packet = new DatagramPacket(magic, magic.length, address, port);
DatagramSocket socket = new DatagramSocket();
socket.send(packet);
socket.close();
} catch (final Exception e) {}
}
I'm pretty sure there is nothing wrong with the method itself, but am I missing something Android specific? Is sending to IPv6 multicast addresses not supported by Samsung devices or is it a bug? I'm pretty helpless and have no idea how to solve this problem. I hope someone can help me with this. :fingers-crossed:

Categories

Resources