Webclient Help - Windows Mobile Software Development

how do i replicate this under windows mobile. The first function works flawlessly however the second version (Which is required to run on windows mobile 6.1-6.5) doesn't.. If anyone has any idea how to fix it i'm willing to try it out.
Thanks
Code:
private static byte[] WebPost(string url, byte[] data)
{
var webClient = new WebClient();
return webClient.UploadData(url, data);
}
This dont.
Code:
private static byte[] WebPost(string url, byte[] data)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Credentials = System.Net.CredentialCache.DefaultCredentials;
request.Timeout = 10000; // 10 secs
request.Method = "POST";
byte[] requestPostBuffer = System.Text.Encoding.GetEncoding(1252).GetBytes(ByteArrayToStr(data));
request.ContentLength = requestPostBuffer.Length;
Stream requestPostData = request.GetRequestStream();
requestPostData.Write(requestPostBuffer, 0, requestPostBuffer.Length);
requestPostData.Close();
// initialize the httpweresponse object
HttpWebResponse webResponse = (HttpWebResponse)request.GetResponse();
// set our encoding
Encoding enc = System.Text.Encoding.GetEncoding(1252);
//initialis the webresponse stream with our encoding
StreamReader webResponseStream = new StreamReader(webResponse.GetResponseStream(),enc);
// create a string to copy it all into.
string streamedData = webResponseStream.ReadToEnd();
webResponse.Close();
webResponseStream.Close();
byte[] convertedResponse = StrToByteArray(streamedData);
convertedResponse = Encoding.Convert(System.Text.Encoding.Default, Encoding.GetEncoding(1252),convertedResponse);
return convertedResponse;
}

Related

Device Power Management in WM

Dear сolleagues and development guru!
I have some stopper in Power Management. I hope somebody will help me to understand.
Technologies: C#, .NET 3.5
The main point of application:
Make beep periodically.
Main problem is:
When PocketPC in active mode application running correct, but when PocketPC went to sleep mode it does not make a beep. As I understood speaker is turned off in sleep mode (like all other devices in PocketPC).
Question:
How can I turn on speaker in sleep mode?
Simply what I need is turn on speaker, make beep and back speaker to previous mode without wake up all device.
I tried code like this:
Code:
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Media;
using System.Threading;
using System.Runtime.InteropServices;
namespace TestProject
{
static class Program
{
public const int POWER_NAME = 0x00000001;
public enum DevicePowerState : int
{
Unspecified = -1,
D0 = 0,
D1,
D2,
D3,
D4,
}
[DllImport("coredll.dll", SetLastError = true)]
public static extern int SetDevicePower(
string pvDevice,
int dwDeviceFlags,
DevicePowerState DeviceState
);
[DllImport("coredll.dll", SetLastError = true)]
public static extern IntPtr SetPowerRequirement(
string device,
DevicePowerState state,
uint deviceFlags,
IntPtr systemState,
ulong stateFlags
);
[DllImport("coredll.dll", SetLastError = true)]
public static extern int ReleasePowerRequirement(IntPtr handle);
[MTAThread]
static void Main()
{
MessageBox.Show("Application is running...", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Asterisk,MessageBoxDefaultButton.Button1);
string deviceName = "WAV1:"; // speaker
for (; ; )
{
// set D0 power value
IntPtr handle = SetPowerRequirement(deviceName, DevicePowerState.D0, 1, IntPtr.Zero, 0);
// make a beep
SystemSounds.Beep.Play();
// set default power value
ReleasePowerRequirement(handle);
Thread.Sleep(10000);
}
}
}
}
And like this:
Code:
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Media;
using System.Threading;
using System.Runtime.InteropServices;
namespace TestProject
{
static class Program
{
public const int POWER_NAME = 0x00000001;
public enum DevicePowerState : int
{
Unspecified = -1,
D0 = 0,
D1,
D2,
D3,
D4,
}
[DllImport("coredll.dll", SetLastError = true)]
public static extern int SetDevicePower(
string pvDevice,
int dwDeviceFlags,
DevicePowerState DeviceState
);
[DllImport("coredll.dll", SetLastError = true)]
public static extern IntPtr SetPowerRequirement(
string device,
DevicePowerState state,
uint deviceFlags,
IntPtr systemState,
ulong stateFlags
);
[DllImport("coredll.dll", SetLastError = true)]
public static extern int ReleasePowerRequirement(IntPtr handle);
[MTAThread]
static void Main()
{
MessageBox.Show("Application is running...", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Asterisk,MessageBoxDefaultButton.Button1);
string deviceName = "WAV1:"; // speaker
int resDevicePowerOn = SetDevicePower(deviceName, POWER_NAME, DevicePowerState.D0);
for (; ; )
{
// make a beep
SystemSounds.Beep.Play();
Thread.Sleep(10000);
}
}
}
}
But any of these codes does not work - there are no beep in sleep mode.
Hi, I just happened to find an article from codeproject.
You may want to take a look at it.
http://www.codeproject.com/KB/mobile/WiMoPower1.aspx
I think what you need is cerunappattime.
It seems you are enabling the audio device to run in low-power mode, but you are not actually telling the CPU to keep running ("unattended mode").
Lookup PowerPolicyNotify, specifically PPN_UNATTENDEDMODE.
You may also need to periodically call SHIdleTimerResetEx and/or SystemIdleTimerReset to keep the device active in unattended mode or it will still truely suspend.
Prevent the system enter sleep mode
The system will stop all activitis when the system enter sleep mode.So you must prevent the system enter sleep mode.
The system sleep mode:
on -> unattended -> suspend
You can run:
on -> unattended -> resuming
my code:time up is system on
ex file:screenblack.rar
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using Microsoft.Win32;
namespace ScreenBlack
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//取得系統狀態 Get system state
[DllImport("Coredll.dll", SetLastError = true)]
public static extern int GetSystemPowerState(StringBuilder PowerState, int length, ref int Flags);
//設定系統電源狀態
[DllImport("Coredll.dll")]
public static extern int SetSystemPowerState(int psState, int StateFlags, int Options);
public const int POWER_STATE_ON = 0x12010000;
public const int NULL = 0;
public const int POWER_FORCE = 0x00001000;
private void Form1_Load(object sender, EventArgs e)
{
//設定 timer1 的設定值 0.5 秒 Set timer1 activie in 0.5 second
timer1.Interval = 500;
//啟動定時器 Start timer1
timer1.Enabled = true;
}
//宣告變數判斷是否有改變 suspend 0:沒有改變 1:有改變
int change = 0;
//宣告變數判斷執行秒數 10
int second = 20;
private void timer1_Tick(object sender, EventArgs e)
{
//設定其標為 0
int flags = 0;
//取得系統狀態名稱 on、suspend、unattended、resuming
StringBuilder stb = new StringBuilder(260);
//取得系統狀態 Get Current system state
GetSystemPowerState(stb, stb.Capacity, ref flags);
//判斷目前系統狀態
if (flags.ToString() == "4194304")
{
//改變 unattended 為 resuming Chang unattended into resuming
RegistryKey reg = Registry.LocalMachine.OpenSubKey(@"System\CurrentControlSet\Control\Power\State\Suspend", true);
reg.SetValue("Flags", "268435456", RegistryValueKind.DWord);
reg.Close();
//設定 reg 有改變
change = 1;
}
else if (flags.ToString() == "268435456")
{
//秒數減一
second--;
//判斷 second 是否等於零
if (second == 0)
{
//************
// your code
//************
//system on
SetSystemPowerState(NULL, POWER_STATE_ON, POWER_FORCE);
//設定秒數
second = 20;
}
}
else
{
//判斷是否有改變
if (change == 1)
{
//改變 unattended 為 resuming Chang unattended into resuming
RegistryKey reg = Registry.LocalMachine.OpenSubKey(@"System\CurrentControlSet\Control\Power\State\Suspend", true);
reg.SetValue("Flags", "2097152", RegistryValueKind.DWord);
reg.Close();
//設定 reg 有改變
change = 0;
//設定秒數
second = 20;
}
}
}
}
}

Turn off GPRS

I'm looking for a way to turn off the data (GRPS)
Search didn't brought me anything usefull, I'm sure there is somwhere the data but can't find it.
I'm especially need it for WM 6.5 (HD2)
Search around for Modaco's NoData program. It's late and I'm too tired to search it up for you right now.
kekkle said:
Search around for Modaco's NoData program. It's late and I'm too tired to search it up for you right now.
Click to expand...
Click to collapse
Thanks for the replay but it’s not what I meant, sorry for not be clarify.
I know the NoData app and actually i just finish writing something similar but more user friendly, hope to release it asap (Now I have problem with the icon )
What I’m looking is a way to turn off programmatically the data connection of the device, what the CommManager in the HTC sense do.
I tried to use the RAS api but it didn't work
look for jmlcomm.exe here at xda and use it in your app.simple command line call.and free to use.
MichelDiamond said:
look for jmlcomm.exe here at xda and use it in your app.simple command line call.and free to use.
Click to expand...
Click to collapse
Thanks for the idea, I'll try it.
But I prefer to do it directly from my app. without calling external tool.
I found a solution!
Its from few posts in the net, don't remember where exactly with some modification of me.
here is the code I use, if someone else will need it:
Code:
using System;
using System.Text;
using System.Runtime.InteropServices;
namespace RasHelper
{
class RasHelper
{
private const int SUCCESS = 0;
private const int ERROR_NOT_ENOUGH_MEMORY = 8;
private const int RASBASE = 600;
private const int ERROR_BUFFER_TOO_SMALL = RASBASE + 3;
private const int ERROR_INVALID_SIZE = RASBASE + 32;
// --- RASCONN data structure definition (refer to ras.h) --
private const int RAS_MaxEntryName = 20;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct RASCONN
{
public int dwSize;
public IntPtr hrasconn;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = RAS_MaxEntryName + 1)]
public string szEntryName;
}
// --------------------------------------------
[DllImport("coredll.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern uint RasEnumConnections(
[In, Out] RASCONN[] rasconn,
[In, Out] ref int cb,
[Out] out int connections);
[DllImport("coredll.dll")]
private static extern uint RasHangUp(IntPtr pRasConn);
/// <summary>
/// Returns all active RAS connections as an array of data structure RASCONN
/// </summary>
/// <returns></returns>
public static RASCONN[] GetAllConnections()
{
RASCONN[] tempConn = new RASCONN[1];
RASCONN[] allConnections = tempConn;
tempConn[0].dwSize = Marshal.SizeOf(typeof(RASCONN));
int lpcb = tempConn[0].dwSize;
int lpcConnections = 0;
uint ret = RasEnumConnections(tempConn, ref lpcb, out lpcConnections);
if (ret == ERROR_INVALID_SIZE)
{
throw new Exception("RAS: RASCONN data structure has invalid format");
}
else if (ret == ERROR_BUFFER_TOO_SMALL && lpcb != 0)
{
// first call returned that there are more than one connections
// and more memory is required
allConnections = new RASCONN[lpcb / Marshal.SizeOf(typeof(RASCONN))];
allConnections[0] = tempConn[0];
ret = RasEnumConnections(allConnections, ref lpcb, out lpcConnections);
}
// Check errors
if (ret != SUCCESS)
{
throw new Exception("RAS returns error: " + ret);
}
if (lpcConnections > allConnections.Length)
{
throw new Exception("RAS: error retrieving correct connection count");
}
else if (lpcConnections == 0)
{
// if there are no connections resize the data structure
allConnections = new RASCONN[0];
}
return allConnections;
}
/// <summary>
/// Closes all active RAS connections
/// </summary>
/// <returns></returns>
public static void CloseAllConnections()
{
RASCONN[] connections = GetAllConnections();
for (int i = 0; i < connections.Length; ++i)
{
//MessageBox.Show(connections[i].ToString());
RasHangUp(connections[i].hrasconn);
}
}
/// <summary>
/// Check if there are open data connections
/// </summary>
/// <returns></returns>
public static bool IsConnectionsOpen()
{
RASCONN[] connections = GetAllConnections();
if (connections.Length > 0)
return true;
else
return false;
}
}
}

[REQUEST] hacking MVNO support into framework.jar

hello! i hope this is the right forum for my request.
i`ve tried to hack some files from JS2, which supports national roaming without data roaming enabled, into the deodexed JVK framework.jar. the result was crashing com.....phone and no working phone function.
here are the outputs of jd-gui after i used dex2jar on services.dex in framework.jar for com/android/internal/telephony/gsm/GsmServiceStateTracker.class with the relevant code:
JS2:
PHP:
private boolean isRoamingBetweenOperators(boolean paramBoolean, ServiceState paramServiceState)
{
String str1 = SystemProperties.get("gsm.sim.operator.alpha", "empty");
String str2 = paramServiceState.getOperatorAlphaLong();
String str3 = paramServiceState.getOperatorAlphaShort();
int i;
if (str2 != null)
{
String str4 = str1;
String str5 = str2;
if (str4.equals(str5))
i = 1;
}
while (true)
{
int j;
label72: String str8;
String str9;
int k;
label141: int m;
int n;
int i1;
if (str3 != null)
{
String str6 = str1;
String str7 = str3;
if (str6.equals(str7))
{
j = 1;
str8 = SystemProperties.get("gsm.sim.operator.numeric", "");
str9 = paramServiceState.getOperatorNumeric();
if ((str8 == null) || (str9 == null))
break label318;
String str10 = str8;
String str11 = "24421";
if (!str10.equals(str11))
break label318;
String str12 = str9;
String str13 = "24405";
if (!str12.equals(str13))
break label318;
k = 1;
m = 1;
n = 0;
i1 = 3;
}
}
try
{
String str14 = str8;
int i2 = n;
int i3 = i1;
String str15 = str14.substring(i2, i3);
String str16 = str9;
int i4 = 0;
int i5 = 3;
String str17 = str16.substring(i4, i5);
int i6 = str15.equals(str17);
m = i6;
label208: String[] arrayOfString1 = this.phone.mSIMRecords.getFakeHomeOn();
int i8;
if (arrayOfString1 != null)
{
String[] arrayOfString2 = arrayOfString1;
int i7 = arrayOfString2.length;
i8 = 0;
label237: if (i8 < i7)
{
String str18 = arrayOfString2[i8];
if (!str18.equals(str9))
{
String str19 = str9;
int i9 = 0;
int i10 = 3;
String str20 = str19.substring(i9, i10);
String str21 = str18;
String str22 = str20;
if (!str21.equals(str22));
}
else
{
n = 0;
}
}
}
while (true)
{
return n;
i = 0;
break;
j = 0;
break label72;
label318: k = 0;
break label141;
i8 += 1;
break label237;
StringBuilder localStringBuilder = new StringBuilder().append("isRoamingBetweenOperators : equalsSaunalahtiElisa=");
int i11 = k;
String str23 = i11;
int i12 = Log.w("GSM", str23);
if (SIMRecords.isNationalRoaming(str8, str9))
{
n = 0;
continue;
}
if ((paramBoolean) && ((m == 0) || ((i == 0) && (j == 0))) && (k == 0))
{
n = 1;
continue;
}
n = 0;
}
}
catch (Exception localException)
{
break label208;
}
}
}
http://pastebin.com/stD1YFPB
JVK:
PHP:
private boolean isRoamingBetweenOperators(boolean paramBoolean, ServiceState paramServiceState)
{
String str1 = SystemProperties.get("gsm.sim.operator.alpha", "empty");
String str2 = paramServiceState.getOperatorAlphaLong();
String str3 = paramServiceState.getOperatorAlphaShort();
int i;
if ((str2 != null) && (str1.equals(str2)))
i = 1;
while (true)
{
int j;
label56: String str4;
String str5;
int k;
int m;
int n;
if ((str3 != null) && (str1.equals(str3)))
{
j = 1;
str4 = SystemProperties.get("gsm.sim.operator.numeric", "");
str5 = paramServiceState.getOperatorNumeric();
k = 1;
m = 0;
n = 3;
}
try
{
String str6 = str4;
int i1 = m;
int i2 = n;
String str7 = str6.substring(i1, i2);
String str8 = str5;
int i3 = 0;
int i4 = 3;
String str9 = str8.substring(i3, i4);
int i5 = str7.equals(str9);
k = i5;
label140: String[] arrayOfString1 = this.phone.mSIMRecords.getFakeHomeOn();
int i7;
if (arrayOfString1 != null)
{
String[] arrayOfString2 = arrayOfString1;
int i6 = arrayOfString2.length;
i7 = 0;
label169: if (i7 < i6)
{
String str10 = arrayOfString2[i7];
if (!str10.equals(str5))
{
String str11 = str5;
int i8 = 0;
int i9 = 3;
String str12 = str11.substring(i8, i9);
String str13 = str10;
String str14 = str12;
if (!str13.equals(str14));
}
else
{
m = 0;
}
}
}
while (true)
{
return m;
i = 0;
break;
j = 0;
break label56;
i7 += 1;
break label169;
if ((paramBoolean) && ((k == 0) || ((i == 0) && (j == 0))))
{
m = 1;
continue;
}
m = 0;
}
}
catch (Exception localException)
{
break label140;
}
}
}
http://pastebin.com/mgNYbWPa
you can see in the code of JS2 there is some code with "isNationalRoaming" which in JVK does not exist. i think this is the reason why national roaming without data roaming enabled is not working in JVK (and also many other sgs roms). i`ve tried to swap the JS2 GsmServiceStateTracker.smali file into the JVK framework, smali it back to .dex and put services.dex back into framework.jar with 7zip. the result was no working com...phone.
i`m no pro, so i think i did something wrong and some of you pro devs maybe have the answer how to do this. many users with virtual network operators like hutchison 3, bob, yesss, and many more would be happy if there will be a way without enabling the risky dataroaming, which could be very expensive when you are geting near a frontier and using data from foreign countries.
push
unwanted data roaming could be really expensive, please help. a lot of users would love you for a working solution! i would donate some beers for a working howto/fix!
to all MVNO users like 3, bob, yesss, .... push this thread with your comments how you would love national roaming without the risk of high costs in the near of frontiers!
I think solution could be easier
Who is your mobile provider?
BOB in austria, MVNO in a1 network.
bob: at 23211
a1: at 23201
Extract this file, paste 'spn-conf.xml' on system/etc/ and reboot
Let me know if it works!
IT WORKS! THANX DUDE!
here are the promised beers: 9J3661079T435484J
Glad tit worked!
Many thanks for your beer!
rafalense said:
Glad tit worked!
Many thanks for your beer!
Click to expand...
Click to collapse
Should this file also work for the Desire (Provider= 3 Austria)
Greetings
r u schnello from braunau?
i think it should work. if u have root, try it.
if it doesn`t work, delete the file again. it won`t harm anything.
edit: the fake_home data for 3 isn`t in the file. i will try to find some more infos about 3 roaming.
paratox said:
r u schnello from braunau?
i think it should work. if u have root, try it.
if it doesn`t work, delete the file again. it won`t harm anything.
Click to expand...
Click to collapse
Thx for the quick reply,
yeah my home town is braunau.
Greetings
Schnello said:
Thx for the quick reply,
yeah my home town is braunau.
Greetings
Click to expand...
Click to collapse
you`ve got a pm!
if we find a solution, we will post it here.
Could this also work on a stock nexus one with gingerbread?

MAPIdotnet and binary message body

Best all,
A while ago I tried to make a simple application which can export all my smses and mmses to my local database server. It runs quite smoothly but I can't manage to get the correct mms body data. It seems that about 5% of the exported body data(for example a sent picture in jpeg format) is different from the original jpeg picture/body data: the exported picture data can't be viewed, it is corrupt.
I suspect the method of exporting the data must be changed from string to binary, but I don't know exactly how to proceed.
I'm using C# 2008 in combination with the MAPIdotnet library, and my target device is a HTC HD Mini with Windows Mobile 6.5 professional.
The part of my code where it's going wrong:
Code:
ASCIIEncoding asen = new ASCIIEncoding();
byte[] ba = asen.GetBytes(s);
bw.Write(ba);
bw.Close();
fs.Close();
if (messages[msgID].Body != null)
{
FileStream fs2 = File.Create("\\Opslagkaart\\Debug\\body_" + Convert.ToString(msgID) + ".dat");
BinaryWriter bw2 = new BinaryWriter(fs2);
System.Text.UnicodeEncoding enc = new System.Text.UnicodeEncoding();
byte[] file = enc.GetBytes(messages[msgID].Body);
//bw2.Write(messages[msgID].Body);
bw2.Write(file);
bw2.Close();
fs2.Close();
}
In combination with MAPIdotnet's code:
Code:
public string Body
{
get
{
IStreamChar s = (IStreamChar)this.msg.OpenProperty(cemapi.PropTags.PR_BODY, 0);
if (s == null)
return "";
IntPtr p = Marshal.AllocHGlobal(4);
char[] b = new char[3];
StringBuilder str = new StringBuilder();
int c, len = b.Length * 2;
do
{
s.Read(b, len, p);
c = Marshal.ReadInt32(p);
str.Append(new string(b, 0, c / 2));
}
while (c >= len);
Marshal.FreeHGlobal(p);
return str.ToString();
}
}
Can somebody give a hint of how to proceed?
Thanks,
I suddenly got some more inspiration and, with help from google, I've managed to correctly retrieve the binary jpeg attachments of two of my mmses.
The code part of my program:
Code:
//if (messages[msgID].BodyBinary.Length>0)
//{
FileStream fs2 = File.Create("\\Opslagkaart\\Debug\\body_" + Convert.ToString(msgID) + ".dat");
BinaryWriter bw2 = new BinaryWriter(fs2);
bw2.Write(messages[msgID].BodyBinary);
bw2.Close();
fs2.Close();
//}
The code part of the customized MAPIdotnet:
Code:
private static IntPtr ReadBuffer;
static int Read(OpenNETCF.Runtime.InteropServices.ComTypes.IStream strm, byte[] buffer)
{
if (ReadBuffer == IntPtr.Zero) ReadBuffer = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(int)));
try
{
strm.Read(buffer, buffer.Length, ReadBuffer);
}
catch (NullReferenceException e)
{
//do nothing
}
return Marshal.ReadInt32(ReadBuffer);
}
public byte[] BodyBinary
{
get
{
int buffsize = 1024*1024*2; /* If mms body is bigger than 2MB we have a problem here */
byte[] buffer = new byte[buffsize];
Read(this.msg.OpenProperty(cemapi.PropTags.PR_BODY, 0), buffer);
byte[] data = buffer;//ms.ToArray();
Marshal.FreeCoTaskMem(ReadBuffer);
return data;
}
}
But now ALL bodies are saved as 2MB files.. including the empty ones from for example a sms. And not all mms bodies are of the max size of 2mb. My carrier/phone supports up to 1MB. Perhaps I need to get some 'dynamic size' buffer instead of the fixed one. Does anyone have an idea on how to determine the size of the
this.msg.OpenProperty(cemapi.PropTags.PR_BODY, 0)
Click to expand...
Click to collapse
stream ?
I've solved all my problems by means of the following code (for mapidotnet):
Code:
private static IntPtr ReadBuffer;
static int Read(OpenNETCF.Runtime.InteropServices.ComTypes.IStream strm, byte[] buffer)
{
int returnvalue = 0;
if (ReadBuffer == IntPtr.Zero) ReadBuffer = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(int)));
try
{
strm.Read(buffer, buffer.Length, ReadBuffer);
returnvalue = Marshal.ReadInt32(ReadBuffer);
}
catch (NullReferenceException e)
{
returnvalue = 0;
}
return returnvalue;
}
public byte[] BodyBinary
{
get
{
int newdatasize = 0;
int buffsize = 1024*1024*3; /* If mms body is bigger than 3MB we have a problem here */
byte[] buffer = new byte[buffsize];
newdatasize = Read(this.msg.OpenProperty(cemapi.PropTags.PR_BODY, 0), buffer);
if (newdatasize < 0) { newdatasize = 0; }
byte[] data = new byte[newdatasize];
Buffer.BlockCopy(buffer, 0, data, 0, newdatasize);
Marshal.FreeCoTaskMem(ReadBuffer);
return data;
}
}
Now all is working fine and the exported files are of their own real size. I'm sure the above code can be optimized but it's working good now.

[Q] How to convert IR Pattern from Android ~4.4.2 to 4.4.3

Is there a way to convert a IR pattern from a Android ~4.4.2 to 4.4.3 compatible pattern.
Here is a example how they look like
Code:
private static final int SAMPLE_FREQ = 38400;
private static final int[] IR_SIGNAL_PULSE_COUNT = {171,171,22,64,22,64,22,64,22,21,22,21,22,21,22,21,22,21,22,64,22,64,22,64,22,21,22,21,22,21,22,21,22,21,22,21,22,21,22,64,22,21,22,21,22,21,22,21,22,21,22,64,22,64,22,21,22,64,22,64,22,64,22,64,22,64,22,876};
private static final int[] IR_SIGNAL_TIME_LENGTH = {4499,4499,578,1683,578,1683,578,1683,578,552,578,552,578,552,578,552,578,552,578,1683,578,1683,578,1683,578,552,578,552,578,552,578,552,578,552,578,552,578,552,578,1683,578,552,578,552,578,552,578,552,578,552,578,1683,578,1683,578,552,578,1683,578,1683,578,1683,578,1683,578,1683,578,23047};
I'm getting a close but not perfect result with this..
Code:
private int[] toCompIR(IrDataCompat data){
int inUs = 1000000/data.getFrequency();
int[] frame = data.getFrame();
int[] arrayOfInt = new int[-1 + frame.length];
for (int j = 1; j < frame.length; j++)
arrayOfInt[(j - 1)] = frame[(j - 1)] * inUs;
return arrayOfInt;
}

Categories

Resources