Hi folks!
I'm currently trying to develop an Application for displaying a so-called "HomeZone-Icon" that indicates lower telephony-rates in special geographic areas.
The centers of that spots and the radius of the area is stored into the SIM-card by our provider O2.
Now I need to get this information out of this card.
I know where to search (File ID 28512), know what command (Binary read) and have given Parameters (don't know for what they are 0,0,123)
When I use my common (non Windows Mobile) mobile from Siemens for extracting these informations via the at-command AT+CRSM everything goes right and I'm able to locate my areas by just converting the hexadez. notation into dez. notation. The result is a GK-Code.
But by using the RIL-API i can notice that it is the right file (because other file ids cause responding with less filelength - perhaps online steering signals of the file system) but the given data doesn't seem to be the same. And even after many nights I'm still unable to find any system behind this response that relates it to what it should be.
The transcript of the terminal session with my Siemens S45 above the result of the RIL API
Code:
at
OK
at&f
OK
AT+CRSM=176,28512,0,0,123
+CRSM: 144,0,
1107919471060040340C84947106000100
01 000516E7 0008B3D2 00007D29 01686F6D65FFFFFFFFFFFFFFFF
02 00000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF
03 00000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF
04 00051674 0008B497 00093040 036369747
Smartphone-API-resonse:
000000107800001033F011003F2231005F
12000050009F22800090105F2294400000
50009F2280005F12900050108F22C0100A
C800009CFFDF22A3408000000090000000
5000
The API was called with:
Code:
#include "ril.h"
HRESULT stkExec()
{
//AT+CRSM=176,28512,0,0,123
RILSIMCMDPARAMETERS sTKparams;
sTKparams.dwParams = RIL_PARAM_SCP_ALL;
sTKparams.dwFileID = 28512;
sTKparams.dwParameter1 = 0;
sTKparams.dwParameter2 = 0;
sTKparams.dwParameter3 = 123;
sTKparams.cbSize=sizeof(RILSIMCMDPARAMETERS);
return RIL_SendRestrictedSimCmd(m_hRil,RIL_SIMCMD_READBINARY, &sTKparams, NULL, 0);
}
Thank you in advance for your help!
This forum is awesome, noticed it at developing my navigation-program. (http://gknavigation.de)
Florian
hi,
the getICCID method returns, in theory, the simcard identifier.
the simcard identifier was printed at the simcard, and is a 17-18 digits number.
but, the getICCID method returns a 10 bytes number. what's the method to convert the getICCID result (internal stored simcard id) into the printed simcard id ????
thank you very much!!
bart
hi,
is there any way to set the sim pin by my applikation?
we don't want our customers to know the sim pin, so our applikation will know it (encrypted config file). if the device needs the sim pin, it shouldn't prompt the user for a sim pin. my application should set it for the user.
Maybe the following code would be helpful for you:
Code:
TelephonyManager tm =
(TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
Class clazz = Class.forName(tm.getClass().getName());
Method m = clazz.getDeclaredMethod("getITelephony");
m.setAccessible(true);
ITelephony it = (ITelephony) m.invoke(tm);
it.supplyPin("1111");
Please keep in mind that you also need ITelephony.aidl from Android sources.
rwxer said:
Maybe the following code would be helpful for you:
Code:
TelephonyManager tm =
(TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
Class clazz = Class.forName(tm.getClass().getName());
Method m = clazz.getDeclaredMethod("getITelephony");
m.setAccessible(true);
ITelephony it = (ITelephony) m.invoke(tm);
it.supplyPin("1111");
Please keep in mind that you also need ITelephony.aidl from Android sources.
Click to expand...
Click to collapse
thank you very much.
can you please tell me, where to get the right ITelephony.aidl? i tried searching in my sdk folder, but didn't found anything. google found a couple of different versions. what should i do exactly with the aidl file?
bassmaster said:
thank you very much.
can you please tell me, where to get the right ITelephony.aidl? i tried searching in my sdk folder, but didn't found anything. google found a couple of different versions.
Click to expand...
Click to collapse
I used aidl from source repository http://android.git.kernel.org/ , version 2.2. You can try the one you found.
bassmaster said:
what should i do exactly with the aidl file?
Click to expand...
Click to collapse
Did you try to google?
http://developer.android.com/guide/developing/tools/aidl.html
Place ITelephony.aidl in package com.android.internal.telephony in your source dir. After that java classes should be generated from .aidl files and compiled if you're using standard build script.
I added “ITelephony.aidl” and the code to my app. It all works fine. Thank you.
But now I have the following problem:
My App starts within the device. While booting, the sim pin dialog request appears. This screen is blocking everything - including the start of my app.
How can I avoid that?
The only workaround known to me is to do the following:
I enabled the flight mode before I shut down the device. After reboot my app starts, disables the flight mode and sets the pin.
But I don't know an efficient way that always starts the device in flight mode.
Can you help me please?
You can try to handle android.intent.action.BOOT_COMPLETED intent (see example http://www.androidcompetencycenter.com/2009/06/start-service-at-boot/) and provide sim pin code just after boot. Don't forget to add permission android.permission.RECEIVE_BOOT_COMPLETED
An app I installed on Nook Touch doesn't even start. I checked the logcat file and realised there is a NullPointer Expection regarding GetDeviceID. I believe Nook Touch just provides a string without the needed 16 characters, which I believe is used by this app to register the device with it's server.
So the question is, is it possible to modify the device id of Nook Simple Touch. I tried this app called Android ID Changer. It does change the id but goes back to the original once the device restarts. I tried manually modifying settings.db in /data/data/com.android.provider.settings but again it reverted to original id on startup.
So is it possible to modify this device id?
Invisman said:
[...] I tried manually modifying settings.db in /data/data/com.android.provider.settings but again it reverted to original id on startup.
Click to expand...
Click to collapse
Renate has done a write up on modifying the init.rc. You could try re-inserting the value for /data/data/com.android.provider.settings in settings.db during the init process. Unfortunately, I don't know enough about the NST boot process to tell you how to guarantee that your entry occurs after whatever clears it each time, but it might be worth a shot.
Everybody's init.rc are all the same.
All the device specific stuff is in the:
Code:
Partition Type Start End Size (bytes) Mount
--------- ---- ----- --- ------------- --------
mmcblk0p2 vfat 39 46 16,777,216 /rom
Um, there's IDs and there are IDs.
Which getDeviceId() was blowing up?
I'd guess that you were using the TelephonyManager getDeviceId()
Since the Nook is not a telephone, it probably returned null.
Thanks guys
Not sure which DeviceID was causing the error but since the log says NullPointer Exception, I guess it is the Telephony one. Anyway to make it return some 16 character string when the TelephonyManager DeviceID request comes in?
Invisman said:
Thanks guys
Not sure which DeviceID was causing the error but since the log says NullPointer Exception, I guess it is the Telephony one. Anyway to make it return some 16 character string when the TelephonyManager DeviceID request comes in?
Click to expand...
Click to collapse
Telephony ID will be IMEI.
The only problem with nook, it does return random IMEI on every call - random, but not null.
Lot's other stuff won't work if IMEI returns null, I guess...
I need a way to search in StorageFiles with dynamically pattern, which comes from a TextBox. The directive "Windows.Storage.Search" doesnt exist in windows phone 8.1 runtime, as i saw. Now my question is, how can i do this in alternative way?
The only way to do it with WP 8.1 since Microsoft ALWAYS fails to implement the important things are to query using LINQ.
Ex:
Code:
var result = (await Windows.Storage.ApplicationData.Current.LocalFolder.GetFilesAsync(Windows.Storage.Search.CommonFileQuery.OrderByName)).
Where(x => x.Name.
Contains(x => txtBox.Text));
That's about all you can do pretty much. (Thanks Microsoft).
Thank you for the example. But it wont work for me, it shows me the following error(s):
Code:
A local variable named 'x' cannot be declared in this scope because it would give a different meaning to 'x', which is already used in a 'parent or current' scope to denote something else
and
Code:
Cannot convert lambda expression to type 'string' because it is not a delegate type
Thats really odd from Microsoft, that they havent implementet the search function like in WinRT (Windows Store App).
The first error is pretty simple. You already have the variable named "x" and it would be very bad if compiler didn't give you that error.
Change the name of the variable to something else that you don't use in that scope and it will work.
And for second problem, try this one:
Code:
private List<string> Result()
{
var result = ((List<Windows.Storage.Search.CommonFileQuery>)Windows.Storage.ApplicationData.Current.LocalFolder.GetFilesAsync(Windows.Storage.Search.CommonFileQuery.OrderByName)).Where(x => x.ToString().Contains(txtBox.Text));
return result as List<string>;
}
private async Task<List<string>> ResultAsync()
{
return await Task.Run(() => Result()).ConfigureAwait(continueOnCapturedContext: false);
}
You should call ResultAsync method and get the result in this way:
Code:
List<string> myList = ResultAsync().Result;
That's not going to work. You can't cast a StorageFile as a string.
To fix my code (simple lambda typo)
Code:
var result = (await Windows.Storage.ApplicationData.Current.LocalFolder.GetFilesAsync(Windows.Storage.Search.CommonFileQuery.OrderByName)).
Where(x => x.Name.
Contains(txtBox.Text));
if(result.Any())
{
// Do shtuff
}
Also, you should never access the .Result of an async task because you never know if it completed yet.
Ok, first error is done, but the second error is still here
Code:
Cannot convert lambda expression to type 'string' because it is not a delegate type
You are missing the point of the TAP (Task Async Pattern).
Both main thread and async method will be in execution in the same time. When the async method finish his work, main thread will stop and catch the result trough the Result property.
TAP is the recommended way of asynchronous programming in C#. The only thing with TAP is to use ConfigureAwait method in non-console type of apps to avoid deadlock.
Sooner or later you will get the result from TAP method. Nothing will get in the conflict with the main thread.
Oh wait, @andy123456 I updated my response. I forgot String.Contains ISNT a lambda .
@Tonchi91, I know all about the TAP. I've been using it since it was CTP. I've seen the awkward situations with threading in WP .
Now... if he did
Code:
List<string> myList;
ResultAsync().ContinueWith(t=> { myList = t.Result; });
I wouldn't be worried .
Ok the errors are gone, but the debugger show me the following exception:
Code:
Value does not fall within the expected range
Is this search method case-sensitive? I tried with an exact input in the TextBox.
Hmmm. Let's see your full code.
its actually only for testing, so i added your code to a button (asnyc) and will show the output in a textBlock.
Code:
private async void buttonTest_Click(object sender, RoutedEventArgs e)
{
//Result();
var result = (await Windows.Storage.KnownFolders.CameraRoll.GetFilesAsync(Windows.Storage.Search.CommonFileQuery.OrderByName)).
Where(x => x.Name.
Contains(textBox_test.Text));
if (result.Any())
{
// Do shtuff
textBlock_test.Text = result.ToString();
}
}
The error is coming from here
Code:
var result = (await Windows.Storage.KnownFolders.CameraRoll.GetFilesAsync(Windows.Storage.Search.CommonFileQuery.OrderByName))
andy123456 said:
its actually only for testing, so i added your code to a button (asnyc) and will show the output in a textBlock.
Code:
private async void buttonTest_Click(object sender, RoutedEventArgs e)
{
//Result();
var result = (await Windows.Storage.KnownFolders.CameraRoll.GetFilesAsync(Windows.Storage.Search.CommonFileQuery.OrderByName)).
Where(x => x.Name.
Contains(textBox_test.Text));
if (result.Any())
{
// Do shtuff
textBlock_test.Text = result.ToString();
}
}
The error is coming from here
Code:
var result = (await Windows.Storage.KnownFolders.CameraRoll.GetFilesAsync(Windows.Storage.Search.CommonFileQuery.OrderByName))
Click to expand...
Click to collapse
Oh Camera Roll.. You MIGHT need to have the capability to view the camera roll enabled. I forget what it's called, but you need a specific cap in order to view from there. Also, I would try to see if you can use a generic folder instead.
I would try Windows.Storage.ApplicationData.Current.LocalFolder.GetFilesAsync() as your method after the await just to test whether you can read correctly.
Yes but in wp8.1 runtime app, there arent caps anymore. The capability for access to the pictures is simply calles pictures library and is enabled. I have tested it as you said, but it gives me the same exception.
A quick tip: another way to do this is to use the Win32 C runtime API. You can, for example, use the FindFirst/NextFile functions (http://msdn.microsoft.com/en-us/library/windows/desktop/aa364418(v=vs.85).aspx) which support searches using wildcards (* and ? characters in the first parameter). These functions are wrapped in my NativeLibraries classes, but are also just publicly available for third0party developers to call from their own C++ DLLs.
Alternatively, you can use the .NET System.IO.Directory class, which has functions like EnumerateFiles(String path, String searchPattern). This is probably the better way to do it, actually.
Of course, if you want these operations to not block the current thread, you'll need to explicitly put them in their own thread or async function.
EDIT: This also assumes you have read access to the relevant directories. You application data directory works fine, for example (you can get its path from the relevant StorageFolder object). Other directories that can be accessed via WinRT functions may go through a broker function instead of being directly readable.
The point is, that i have an array with filenames. Now i need the StorageFile files which contains these filenames. My idea was to search for these files and return the files as StorageFile, so i can work with these. Or is there a simpler / another way?
http://msicc.net/?p=4182 <-- try this
Thank you, i have already done this and its working. But how can i compare the Files to read, with already read files and take only the not yet read files?