ISETool.exe bug - Windows Phone 7 Software Development

Today I found very annoying and strange bug (or, may be, MS call it "feature" ). Seems like directories on isf can hold 1024 files only...
Try code below:
Code:
Random rnd = new Random();
using (var isf = IsolatedStorageFile.GetUserStoreForApplication())
{
byte[] data = new byte[1024];
isf.CreateDirectory("test");
for (int i=0; i<1025; i++)
{
string fileName = "test\\" + i.ToString("D4") + ".bin";
using (IsolatedStorageFileStream fs = new IsolatedStorageFileStream(fileName, FileMode.Create, isf))
{
rnd.NextBytes(data);
fs.Write(data, 0, data.Length);
}
}
}
After loop completed, resulting directory "test" will be empty! But change i<1024 and you'll get all yours 1024 files...
Tested on emulator and HTC Surround, same results. Can't find any documentation about this limitation... Shame on you, MS!
Update: another strange behavior ('cause of this bug) - if you already have 1024 files and try to add one more, the whole directory content is "magically" disappear But exception isn't thrown...

Interesting, I'll try it as well. This would be lame to have to work around.

Dbeattie said:
Interesting, I'll try it as well.
Click to expand...
Click to collapse
Yes, please, confirm...

I can't test this at the moment but I know I write well over 1000 files to /shared/media so I'm curious to tet this.

sensboston said:
Yes, please, confirm...
Click to expand...
Click to collapse
Hey just tried it out, wrote 2k items to a folder called "Data".
While it didn't show up in the Windows Phone Power tools, the file does exist in the folder itself.
bool success = storage.FileExists(Path.Combine("data", "1999"));
So it's either a problem with the WPConnect api or with the power tools, haven't tried the command line tool.

Yep, fortunately you are right, it's a ISETool.exe (or drivers) bug, not a WP7 ISF.

sensboston said:
Yep, fortunately you are right, it's a ISETool.exe (or drivers) bug, not a WP7 ISF.
Click to expand...
Click to collapse
Could you therefore edit the title of the thread please?
Thanks.

Related

Open ZIP file in Silverlight

Hi,
I'm working on my first application for Windows Phone. I got a ZIP file which contains a huge amount of XML files and which has to be
updated through the app. So I declared the 'Build Action' of the file to 'Content'. Now I'm stuck opening the file for reading and extracting
a stream for a specific XML file.
I tried File.OpenRead but Visual Studio Express crashes when trying to debug this.
Do I need to use Application.GetResourceStream? If yes, can someone post a working example with a content ZIP file (not resource).
Can anyone help me?
Thank you,
toolsche
Try http://senssoft.com/ZipTest.zip
I've created that example project for Freda's developer.
Hi,
Unfortunately that doesn't help me.
1) U did set the file as "Resource" => it will not be updateable because it's within the assembly. If I'm wrong, please tell me...
2) U used an external library (SharpZipLib) which I hope it wouldn't be necessary.
1) I've used an embedded file (actually, epub == zip) to simplify the solution. It's just an example. U may copy the resource file to IsolatedStorageFile / download it from web/ whatever you want. I can't teach you how to use Silverlight for WP7 - buy some good book...
2) SharpZipLib IS NECESSARY! Other "zippers" looks like not a 100% compatible with WinZip/linux zippers (see Freda corresponding topic). SharpZipLib did the job very well.
Of course it up to you: what you want to use. But I gave you a 100% working and tested solution.
Hi,
I'm not in doubt that your solution is working and I thank you for your suggestion.
Maybe I'm on the wrong path, but what I think I need is a solution for opening
a zip file that is NOT part of the assembly (which I think it is if you declare it as
embedded resource).
My intention is to load one or more zip files from a server which the application
should be able parse/remove/replace if outdated. I tried to find a solution but had
no luck so far. MSDN has an example but I couldn't get it to work because I don't
know where the zip file should be located:
http://msdn.microsoft.com/en-us/library/cc190632(v=VS.95).aspx
Try to use IsolatedStorageFile and WebClient, something like this:
Code:
IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
WebClient downloader = new WebClient();
downloader.OpenReadCompleted += delegate(object sender, OpenReadCompletedEventArgs e)
{
if (e.Error == null)
{
using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream("myfile.zip", FileMode.Create, isf))
{
Byte[] buffer = new Byte[e.Result.Length];
e.Result.Read(buffer, 0, buffer.Length);
stream.Write(buffer, 0, buffer.Length);
}
DoSomethingWithZip("myfile.zip");
}
};
downloader.OpenReadAsync(new Uri("http://mysite.com/archive.zip", null));
Thank you for the quick answer. I will try it as soon as possible and post the results.
EDIT: Thanks, it's working as suggested.

[Q][SOLVED] PhotoChooserTask Mango Exception

A simple photochooser task application throws a Nullrefference exception(Invalid pointer) and pixel height and width is 0 on mango, on nodo it worked alright.
Am I missing a cast? or this is a bug in mango, and will be fixed?
Here's the code:
Code:
private PhotoChooserTask photo;
// Constructor
public MainPage()
{
InitializeComponent();
photo = new PhotoChooserTask();
photo.Completed += new EventHandler<PhotoResult>(photo_Completed);
}
void photo_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
BitmapImage bi = new BitmapImage();
bi.SetSource(e.ChosenPhoto);
//////////////////////////////////////////////////////////////////////////////////////
var wb = new WriteableBitmap(bi);//Exception here
/////////////////////////////////////////////////////////////////////////////////////
// bi.PixelHeight and bi.PixelWidth == 0;
}
}
private void button1_Click(object sender, RoutedEventArgs e)
{
photo.Show();
}
}
Hope someone can help.
Thanks in advance
This is because you need to set the CreateOptions property of the BitmapImage before you use it to construct the WriteableBitmap.
The default 'create' option on WP7 is DelayCreation (it may be BackgroundCreation in some of the 7.1 betas, but the mango RTM I think is DelayCreation) but either way the problem you're having is that your image has not been initialised yet at the point you use it in the WriteableBitmap's constructor (hence the null reference exception).
The options (depending what you set) let images be only initialised when needed, and downloaded on separate threads / asynchronously, which can help performance (or at least stop the phone blocking other things happening whilst images are loaded). Users also have the ability with the photo chooser to pick images from online ablums, so as you can imagine you also have to handle perhaps a second or two waiting for a download to complete, and of course downloads can also fail when connections drop etc. which you can handle too.
So in answer to your question (off the top of my head, not confirmed it with code) set the createoptions to none, and use the Bitmap's ImageOpened event to construct the WritableBitmap (you may also want to handle the Bitmap's ImageFailed event). Make sure you set up the ImageOpened event before you set the source, i.e.
BitmapImage bi = new BitmapImage();
bi.CreateOptions = BitmapCreateOptions.None;
bi.ImageOpened += new (some event name)
bi.ImageFailed += new (some event name)
bi.SetSource(e.ChosenPhoto);
Hope that helps,
Ian
Thank you very much
Problem solved
otherworld said:
This is because you need to set the CreateOptions property of the BitmapImage before you use it to construct the WriteableBitmap.
The default 'create' option on WP7 is DelayCreation (it may be BackgroundCreation in some of the 7.1 betas, but the mango RTM I think is DelayCreation) but either way the problem you're having is that your image has not been initialised yet at the point you use it in the WriteableBitmap's constructor (hence the null reference exception).
The options (depending what you set) let images be only initialised when needed, and downloaded on separate threads / asynchronously, which can help performance (or at least stop the phone blocking other things happening whilst images are loaded). Users also have the ability with the photo chooser to pick images from online ablums, so as you can imagine you also have to handle perhaps a second or two waiting for a download to complete, and of course downloads can also fail when connections drop etc. which you can handle too.
So in answer to your question (off the top of my head, not confirmed it with code) set the createoptions to none, and use the Bitmap's ImageOpened event to construct the WritableBitmap (you may also want to handle the Bitmap's ImageFailed event). Make sure you set up the ImageOpened event before you set the source, i.e.
BitmapImage bi = new BitmapImage();
bi.CreateOptions = BitmapCreateOptions.None;
bi.ImageOpened += new (some event name)
bi.ImageFailed += new (some event name)
bi.SetSource(e.ChosenPhoto);
Hope that helps,
Ian
Click to expand...
Click to collapse
Hello, I have the same problem (NullReferenceException) and have read you response, which from what I see it is the solution, but I have a problem; not where I have to go to do I change them that you propose. I would be so kind of explaining to me that I have to continue steps. It English me is very bad and I am using a translator.
I have HTC Trophy the v.th 7740.16 with chevrom and U2M7740 of Ansar.
Thank you in advance and greetings.
Hi,
If you upload your code / project I will take a look and see where the error is.
Si me muestras su código / proyecto, puedo ver por qué recibiras una excepción NullReference
Ian
otherworld said:
Hi,
If you upload your code / project I will take a look and see where the error is.
Si me muestras su código / proyecto, puedo ver por qué recibiras una excepción NullReference
Ian
Click to expand...
Click to collapse
Hello,
The question is that it is not any project, applications do not develop (although I would like). This type of errorr (nullreferenceexception) happens to me since I updated to Mango, so much in v.7720.68 as in v.7740.16 and happens in apps as Morfo, Fantasy Painter, and at the time of choosing fund in Touchxperience. Not if these apps are not conditioned to Mango or if, perhaps, from the record it might change some type of configuration or entering the Xaml of the app to be able to change some fact, end not...
For the little that, an error of the photochooser seems to be, the question is if it is possible to gain access to him and as doing it.
Anyhow thank you very much and a cordial greeting.
Hi,
If it is not a code issue then I do not know what it could be. Are you using a custom rom?
Good luck with it.
Ian
otherworld said:
Hi,
If it is not a code issue then I do not know what it could be. Are you using a custom rom?
Good luck with it.
Ian
Click to expand...
Click to collapse
Hello. Not, I am with official Mango the v.th 7740.16. I have already restored to factory and it continues the error. I believe that it is a question of the update, it must have a mistake in the pitcher of photos or some error with the librerie, do not know...
Thank you anyhow and greetings.
Hello, otherworld.
I continue with the same problem, 'nullreferenceexception' related with 'chooserphoto' in some application. The curious thing is that someone of them me work correctly, I gain access to me librery and it takes the photos, and in others not, as for example Morfo. I do not know if the problem is in the code source of these applications or phone is in me. Is this the code source of Morfo, is it possible to correct so that this does not happen?
Thank you in advance and greetings.

[DEV][08/May/2013]HD2 off-mode Alarm Clock(cLK)[WIP]

This is an experiment - project. It is about adding off-mode alarm clock to the HD2.
(If you don't have cLK installed (at least v1.5.1.4), then this is not applicable for you)
kokotas said:
Is it even possible to include something like auto-power-on in cLK, for alarm clock purposes?
Click to expand...
Click to collapse
After ~10 months, zicoxx asked more or less the same thing:
zicoxx said:
i want to suggest a feature for clk and our hd2..offline alarms
Click to expand...
Click to collapse
So lets see what we have so far...
This project depends on 3 factors, (1)Kernel, (2)Android application, (3)Bootloader.
Kernel
The kernel has a function in arch\arm\mach-msm\pm.c which handles the reboot reason:
Code:
static int msm_reboot_call(struct notifier_block *this, unsigned long code, void *_cmd)
{
if((code == SYS_RESTART) && _cmd) {
char *cmd = _cmd;
if (!strcmp(cmd, "bootloader")) {
restart_reason = 0x77665500;
} else if (!strcmp(cmd, "recovery")) {
restart_reason = 0x77665502;
} else if (!strcmp(cmd, "eraseflash")) {
restart_reason = 0x776655EF;
} else if (!strncmp(cmd, "oem-", 4)) {
unsigned code = simple_strtoul(cmd + 4, 0, 16) & 0xff;
restart_reason = 0x6f656d00 | code;
[COLOR="YellowGreen"]
//This is the proposed patch to our kernel
//(thanks Rick_1995 for suggesting it to bypass the time limit of 255 min)
} else if (!strncmp(cmd, "S", 1)) {
unsigned code = simple_strtoul(cmd + 1, 0, 16) & 0x00ffffff;
restart_reason = 0x53000000 | code;
[/COLOR]
} else if (!strcmp(cmd, "force-hard")) {
restart_reason = 0x776655AA;
} else {
restart_reason = 0x77665501;
}
}
return NOTIFY_DONE;
}
Not being able to compile a new kernel with a change like the green text in the above function, I just used the "oem-" prefix in the reboot reason passed from the application. The downside of this is that we can't set an alarm for more than 255 min from the current time.
Application
The application is able to:
reboot the device using the PowerManager class since it is signed and placed in /system/app:
Code:
//MinutesToSuspend is set using a TimePicker
mPowerManager.reboot("oem-" + MinutesToSuspend);
[COLOR="YellowGreen"]
//In case we have a kernel with the above patch included
mPowerManager.reboot("S" + MinutesToSuspend);[/COLOR]
play the alarm when the device has booted usind the BroadcastReceiver class that will get the BOOT_COMPLETED action.
Bootloader
The bootloader (in this case cLK):
detects the boot reason and decodes the MinutesToSuspend from it and enters a sort of suspend mode with a timeout equal to MinutesToSuspend converted to msec
Code:
if(target_check_reboot_mode() == (target_check_reboot_mode() | 0x6f656d00)) {
char str[16];
char *endptr;
unsigned MinutesToSuspend;
unsigned msecToSuspend = 0;
// Decode the MinutesToSuspend from the reboot_mode
sprintf(str, "%i", (target_check_reboot_mode() ^ 0x6f656d00));
MinutesToSuspend = strtol(str, &endptr, 16);
if (MinutesToSuspend < 3)
msecToSuspend = (MinutesToSuspend * 60000);
else
msecToSuspend = (MinutesToSuspend * 60000) - (120000);
suspend_time = msecToSuspend;
show_multi_boot_screen = 0;
boot_into_recovery = 0;
}
[COLOR="YellowGreen"]
//In case we have a kernel with the above patch included
#define MARK_ALARM_TAG 0x53000000
if(target_check_reboot_mode() & 0xFF000000 == MARK_ALARM_TAG) {
uint32_t MinutesToSuspend;
// Decode the MinutesToSuspend from the reboot_mode
MinutesToSuspend = target_check_reboot_mode() ^ MARK_ALARM_TAG;
if (MinutesToSuspend > 3)
MinutesToSuspend -= 2;
suspend_time = MinutesToSuspend * 60000;
show_multi_boot_screen = 0;
boot_into_recovery = 0;
}
[/COLOR]
if(suspend_time) {
msm_acpu_clock_init(1); // 384MHz (acpu_freq_tbl[0])
//Could try setting cpu clock at 245...
//msm_acpu_clock_init(0); // 245MHz (acpu_freq_tbl[0])
htcleo_suspend(suspend_time);
}
the suspend mode is implemented using this function
Code:
#define DS2746_SAFE_CHG_VOLTAGE 4200 // mV
void htcleo_suspend(unsigned timeout)
{
uint32_t voltage;
//int16_t current;
bool usb_cable_connected;
time_t start_time;
start_time = current_time();
if (timeout)
htcleo_panel_bkl_pwr(0);
do {
//current = ds2746_current(DS2746_I2C_SLAVE_ADDR, 1200);
voltage = ds2746_voltage(DS2746_I2C_SLAVE_ADDR);
usb_cable_connected = htcleo_usb_online();
if (usb_cable_connected) {
if (voltage < DS2746_SAFE_CHG_VOLTAGE) {
// If battery needs charging, set new charger state
if (htcleo_ac_online()) {
if (htcleo_charger_state() != CHG_AC ) {
writel(0x00080000, USB_USBCMD);
ulpi_write(0x48, 0x04);
htcleo_set_charger(CHG_AC);
}
} else {
if (htcleo_charger_state() != CHG_USB_LOW ) {
writel(0x00080001, USB_USBCMD);
mdelay(10);
htcleo_set_charger(CHG_USB_LOW);
}
}
// Led = solid amber
if (htcleo_notif_led_mode != 2)
thread_resume(thread_create("htcleo_notif_led_set_mode_2",
&htcleo_notif_led_set_mode,
(void *)2,
HIGH_PRIORITY,
DEFAULT_STACK_SIZE));
} else {
// Battery is full
if(timeout) {
// Set charger state to CHG_OFF_FULL_BAT
if (htcleo_charger_state() != CHG_OFF_FULL_BAT ) {
writel(0x00080001, USB_USBCMD);
mdelay(10);
htcleo_set_charger(CHG_OFF_FULL_BAT);
}
// and turn led solid green
if (htcleo_usb_online() && (htcleo_notif_led_mode != 1))
thread_resume(thread_create("htcleo_notif_led_set_mode_1",
&htcleo_notif_led_set_mode,
(void *)1,
HIGH_PRIORITY,
DEFAULT_STACK_SIZE));
} else {
// exit while if we don't have a timeout
break;
}
}
} else {
// Set charger state to CHG_OFF
if (htcleo_charger_state() != CHG_OFF ) {
writel(0x00080001, USB_USBCMD);
mdelay(10);
htcleo_set_charger(CHG_OFF);
}
// and turn off led
if (htcleo_notif_led_mode != 0)
thread_resume(thread_create("htcleo_notif_led_set_off",
&htcleo_notif_led_set_mode,
(void *)0,
HIGH_PRIORITY,
DEFAULT_STACK_SIZE));
}
// While in loop keep tracking if POWER button is pressed
// in order to (re)boot the device
for (int i=0; i<6; i++) {
if(keys_get_state(KEY_POWER)!=0) {
target_reboot(0);
return;//:)
}
mdelay(96);//total delay ~500ms per loop
}
// And check if timeout exceeded in order to reboot
if (timeout && (current_time() - start_time >= timeout))
target_reboot(0);
} while ( (usb_cable_connected) /* && current >= 0) */
||(timeout) ); // If we have a timeout this while-loop never breaks if we don't reboot.
// Double check voltage
mdelay(10);
voltage = ds2746_voltage(DS2746_I2C_SLAVE_ADDR);
if (voltage < DS2746_SAFE_CHG_VOLTAGE) {
// If battery is not full then
// EITHER the cable is unplugged
// OR the double check of voltage gave us
// a value less than the safe voltage.
// Set charger state to CHG_OFF
writel(0x00080001, USB_USBCMD);
mdelay(10);
htcleo_set_charger(CHG_OFF);
} else {
// If battery is full
// set charger state to CHG_OFF_FULL_BAT
writel(0x00080001, USB_USBCMD);
mdelay(10);
htcleo_set_charger(CHG_OFF_FULL_BAT);
// and turn led solid green
if (htcleo_usb_online() && (htcleo_notif_led_mode != 1))
thread_resume(thread_create("htcleo_notif_led_set_mode_1",
&htcleo_notif_led_set_mode,
(void *)1,
HIGH_PRIORITY,
DEFAULT_STACK_SIZE));
// While usb cable is connected
// keep tracking if POWER button is pressed OR timeout exceeded
// in order to (re)boot the device
while (htcleo_usb_online()) {
if(keys_get_state(KEY_POWER)!=0)
target_reboot(0);
/* if (timeout && (current_time() - start_time >= timeout))
break; */
}
}
// If we've set a timeout and reached it, reboot the device
/* if (timeout && (current_time() - start_time >= timeout))
target_reboot(0); */
// Shutdown the device
enter_critical_section();
platform_exit();
msm_proc_comm(PCOM_POWER_DOWN, 0, 0);
for (;;) ;
}
Any suggestions or observations are welcomed!
This is open for everyone to use or contribute. Source is available at https://github.com/n0d3/HD2_Alarm_Clock
If you have to ask for an apk to test, then you may download this example's apk from here.But don't consider this as an application release thread.
Bazinga
Should I say first or something? Anyway, testing with ~.7 clk now
Thank you!
THANKS KOKOTAS to make it possible also if it is an experiment..
almost you try if it's possible to use it in our beloved hd2
now i try it,and test this version..
however there is an app for samsung phone developer from chainfire team nomoarpowah that use offline charging mode for alarm..
maybe you can check that app to see if can use something
i hope that OUR WONDERFUL DEVELOPER can do another miracle..
I think since Android is between us, make a wake up alarm is really hard to do. Because we need a sub level software such as a boot loader, that listen the internal clock to turn on the device when established. I hope that you will win this challenge bro
All the best !
Although I think this Will be difficult...
zicoxx said:
THANKS KOKOTAS to make it possible also if it is an experiment..
almost you try if it's possible to use it in our beloved hd2
now i try it,and test this version..
however there is an app for samsung phone developer from chainfire team nomoarpowah that use offline charging mode for alarm..
maybe you can check that app to see if can use something
i hope that OUR WONDERFUL DEVELOPER can do another miracle..
Click to expand...
Click to collapse
Chainfire use the charging deamon to include his project. Because we doesnt see source which are availible for the HD2 we couldnt build something like this. Another point would be that the device comes original by windows Mobile so the process completly differs like bootloader/ init by spl/ availible functions !
If you Test chainfire app and read the thread you readout that most of them completly new written coded.
Alarm is integrated into new charging deamon so it doesnt fire device to boot up normal android ...
See it like another very small System work completly alone if device is off (charging)
Sent from my GT-I9300 using xda app-developers app
tb-killa said:
Chainfire use the charging deamon to include his project. Because we doesnt see source which are availible for the HD2 we couldnt build something like this. Another point would be that the device comes original by windows Mobile so the process completly differs like bootloader/ init by spl/ availible functions !
If you Test chainfire app and read the thread you readout that most of them completly new written coded.
Alarm is integrated into new charging deamon so it doesnt fire device to boot up normal android ...
See it like another very small System work completly alone if device is off (charging)
Sent from my GT-I9300 using xda app-developers app
Click to expand...
Click to collapse
If you look closely, It should work already and NOT require any of chainfire's work. cLK is open source, Linux is open source, Android is open source (atleast the part related to this). The only issue you might think of is that the core will be in wfi state instead of pc, unless kokotas has fixed pc in clk.
kokotas said:
Code:
unsigned code = simple_strtoul(cmd + 1, 0, 16) & 0xff000000;
Click to expand...
Click to collapse
Don't you think it should be
Code:
unsigned code = simple_strtoul(cmd + 1, 0, 16) & 0x00FFFFFF;
That's a good point.
I think booting into android to have a ring might be an issue in some cases
(bootloop, long time to boot android itself)
Using a recovery mode to quickly boot into and initiate an alarm that would be more reliable.
... at least I think
nerveless, good job and keep up the good work
Very nice work, seems like more and more people are learning to dev.
Rick_1995 said:
If you look closely, It should work already and NOT require any of chainfire's work. cLK is open source, Linux is open source, Android is open source (atleast the part related to this). The only issue you might think of is that the core will be in wfi state instead of pc, unless kokotas has fixed pc in clk.
Click to expand...
Click to collapse
I think we doesnt have sources of charging deamon for the HD2 right?
If we checked different threads we could read that htc doesnt public sources for Desire, others!
I agree that C(LK) could also do the Same job!
Sent from my GT-I9300 using xda app-developers app
tb-killa said:
I think we doesnt have sources of charging deamon for the HD2 right?
If we checked different threads we could read that htc doesnt public sources for Desire, others!
I agree that C(LK) could also do the Same job!
Sent from my GT-I9300 using xda app-developers app
Click to expand...
Click to collapse
code for charging daemon is not needed....
@kokotas, Why aren't you entering WFI state ?
You should do something like this:
Create a suspend thread and ensure there is no other thread with a higher (or the same) priority.
Inside the thread handle, there should be an infinite loop with something like this:
Code:
int suspend_task(void *args) {
int timeout_ms = (uint32_t) args;
htcleo_panel_bkl_pwr(0);
while( ! (key_pressed(KEY_POWER) && (timeout_ms <= 0)) ) {
if(usb_is_connected())
charge_device();
else
arch_idle(); // WFI
timeout_ms -= 10;
}
reboot();
return 0;
}
#define MARK_ALARM_TAG 0x53000000
void board_init(void) {
.........
uint32_t MinutesToSuspend = target_check_reboot_mode();
if((MinutesToSuspend & 0xFF000000) == MARK_ALARM_TAG) {
MinutesToSuspend &= 0x00FFFFFF;
if (MinutesToSuspend > 3)
MinutesToSuspend -= 2;
thread_create("suspend", suspend_task, (void *) (MinutesToSuspend * 60000) , HIGHEST_PRIORITY, DEFAULT_STACK_SIZE)
}
.........
}
Rick_1995 said:
@kokotas, Why aren't you entering WFI state ?
Click to expand...
Click to collapse
Honestly, never thought of Wait For Interrupt state
I'll rewrite the code based on your example and I'm thinking of creating a new branch in git in order to upload the complete source of latest cLK.
Regards!
kokotas said:
Honestly, never thought of Wait For Interrupt state
I'll rewrite the code based on your example and I'm thinking of creating a new branch in git in order to upload the complete source of latest cLK.
Regards!
Click to expand...
Click to collapse
Thanks, was wanting to update too. Just remember to create a new branch instead of an entirely new repository.
Regards
FYI.
Kernel patch arch\arm\mach-msm\pm.c in the first post has already added into my git.
It was included in my latest ICS kernel r3.6.
https://github.com/tytung/android_k...mmit/23357b2a9d64a076f1b9ac664dae209748fd5ece
tytung said:
FYI.
Kernel patch arch\arm\mach-msm\pm.c in the first post has already added into my git.
It was included in my latest ICS kernel r3.6.
https://github.com/tytung/android_k...mmit/23357b2a9d64a076f1b9ac664dae209748fd5ece
Click to expand...
Click to collapse
Thank you tytung:good:
I changed the relevant source in the application (also updated git repo) and tested successfully.
This also gave me the chance to try something else. Since it makes "oem-" prefix available to be used for other purposes, I've written another application which uses that prefix in reboot_reason for rebooting directly to any extra boot partition, with no need to press any buttons during boot-up.
Will post more info in a separate thread.
EDIT1:
Link
EDIT2:
Rick_1995 said:
Thanks, was wanting to update too. Just remember to create a new branch instead of an entirely new repository.
Regards
Click to expand...
Click to collapse
Just created new branch here.
Regards!
Thank you for your great work.I am trying to make offmode alarm work in clk 1.5.1.5 and nand rom nexushd2 v2.8
After i press set alarm device reboots but then it gives message "error:boot selection not found.an irrecoverable error found" and it boot in clk menu and stays there.I have boot,sboot partition and i select from default kernel the boot partition
clio94 said:
Thank you for your great work.I am trying to make offmode alarm work in clk 1.5.1.5 and nand rom nexushd2 v2.8
After i press set alarm device reboots but then it gives message "error:boot selection not found.an irrecoverable error found" and it boot in clk menu and stays there.I have boot,sboot partition and i select from default kernel the boot partition
Click to expand...
Click to collapse
Hi clio94,
Did you download the SysAlarm2.apk or you're still using the first one (SysAlarm.apk)?
Now that I think of it, I should remove the first one cause it will not work as expected with the last cLK.
Regards!
I tried the first version.The second version work ok.Thank you
clio94 said:
I tried the first version.The second version work ok.Thank you
Click to expand...
Click to collapse
Have you try in nand rom or nativesd ROM?
Thanks!!
Inviato dal mio multiboot HD2

WP7 Shell, Console, Batch files interpreter

Hi Friends.
Standard Cmd.exe seems not working on WP7 probably by any restrictions, then we need own solution. There is a simple WP7 console (paied!!!), but this is childer game only, not a real working tool (some connection features from it are so usable).
There is one BIG problem on CE based systems - Shell context absention, especially Current Directory concept miss. Rainer Keuchel's CELib and Console solves it by ENVIRONMENT registry key, common for every console instance. Desktop Windows / POSIX systems concept of many unique shell contexts is very hard implementable here.There is not problem to make new context in registry - this can be unique key, contain all included processes IDs, environment structure and especially current directory path. But, somebody must release this context, when all processes finish. It can not be user applications dependent, any kernel "garbage collector" must be implemented for it. And, how to refer context to launched process? What do you mean about it - is better simple one context shell then nothing, or long work on multicontext solution?
Another problem is popen and pipes absention on WP7 system. I finished very simple solution last weak, based on stdout to file redirecting, which Microsoft forgets in WP7 API from WM6 one. Then we can make simply dedicated applications (dir.exe, set.exe, copy.exe, delete.exe etc.) in \Windows directory, callable by standard ShellExecuteEx, enrolling ouptut do stdout by printf etc. But, is it good solution? Have you got anybody real pipes working on WP7?
Working console appplication with bath files interpreter give us big possibilities for on-device attempts and programming, simple installators/deinstallators building, WP7 Perl, HaRET, Linux, WM, WinRT, WP8 wrappers working etc. It is not problem now to runs anything in kernel mode on WP7. Are you somebody able to cooperate include native coding? We can make real operating system from Microsoft fart bag named WP7.
Martin7Pro said:
Hi Friends.
Standard Cmd.exe seems not working on WP7 probably by any restrictions, then we need own solution. There is a simple WP7 console (paied!!!), but this is childer game only, not a real working tool (some connection features from it are so usable).
There is one BIG problem on CE based systems - Shell context absention, especially Current Directory concept miss. Rainer Keuchel's CELib and Console solves it by ENVIRONMENT registry key, common for every console instance. Desktop Windows / POSIX systems concept of many unique shell contexts is very hard implementable here.There is not problem to make new context in registry - this can be unique key, contain all included processes IDs, environment structure and especially current directory path. But, somebody must release this context, when all processes finish. It can not be user applications dependent, any kernel "garbage collector" must be implemented for it. And, how to refer context to launched process? What do you mean about it - is better simple one context shell then nothing, or long work on multicontext solution?
Another problem is popen and pipes absention on WP7 system. I finished very simple solution last weak, based on stdout to file redirecting, which Microsoft forgets in WP7 API from WM6 one. Then we can make simply dedicated applications (dir.exe, set.exe, copy.exe, delete.exe etc.) in \Windows directory, callable by standard ShellExecuteEx, enrolling ouptut do stdout by printf etc. But, is it good solution? Have you got anybody real pipes working on WP7?
Working console appplication with bath files interpreter give us big possibilities for on-device attempts and programming, simple installators/deinstallators building, WP7 Perl, HaRET, Linux, WM, WinRT, WP8 wrappers working etc. It is not problem now to runs anything in kernel mode on WP7. Are you somebody able to cooperate include native coding? We can make real operating system from Microsoft fart bag named WP7.
Click to expand...
Click to collapse
Pocket CMD from CE7 ARMv7 works fine via telnet. Tested on my Samsung Omnia 7 and Jaxbot's Samsung Focus. You can see it in action in this screenshot: http://windowsphonehacker.com/articles/all_in_a_days_work-03-03-13
Do I have to rename the zip tp xap and install normally?
No. If you don't know how to install it you probably don't need it as it creates a huge security risk on your phone.
Hmm... , interesting. The same exe in other configuratin I tested on my phones in the past with result : "Too much console ones work immediatelly, close any and try again".
Do you know (or is possible to code) telnet WP7 client, functioning on the same IP as server? Especially with hardware keyboard support?
Martin7Pro said:
Hmm... , interesting. The same exe in other configuratin I tested on my phones in the past with result : "Too much console ones work immediatelly, close any and try again".
Do you know (or is possible to code) telnet WP7 client, functioning on the same IP as server? Especially with hardware keyboard support?
Click to expand...
Click to collapse
Silverlight apps can not connect to localhost, it has been blocked.
Simple batch line interpreter
I tried cmd.exe batch and arguments calling, but it seems does not working for me. Then I will try own attempt.
Single batch line interpreter (*.bat files interpreting precursor):
SHLine.cpp
PHP:
// SHLine.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
//#include <atlstr.h>
/*CString*/
#ifdef _DEBUG
#pragma comment (lib, "libcmtd.lib")
#else
#pragma comment (lib, "libcmt.lib")
#endif
/*CString*/
#include <list>
using namespace std;
typedef list<CString> StringList;
#define SEE_MASK_NOASYNC (0x00000100)
CString ErrorString(DWORD err)
{
CString Error;
try
{
LPTSTR s;
if (::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL, err, 0, (LPTSTR)&s, 0, NULL) == 0)
{
Error.AppendFormat(TEXT("Error code : %X"), err);
} /* failed */
else
{ /* success */
LPTSTR p = _tcschr(s, _T('\r'));
if(p != NULL)
{ /* lose CRLF */
*p = _T('\0');
} /* lose CRLF */
Error = s;
::LocalFree(s);
} /* success */
return Error;
}
catch (...)
{
Error.AppendFormat(TEXT("Error code : %X"), err);
return Error;
}
}
HRESULT ShellExecuteWait(const wchar_t * file, const wchar_t * args, long lTimeout)
{
TRACE(L"ShellExecuteWait file=%s, args=%s, long lTimeout=%X\n", file, args, lTimeout);
try
{
SHELLEXECUTEINFO lpExecInfo;
memset(&lpExecInfo, 0, sizeof(SHELLEXECUTEINFO));
lpExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
lpExecInfo.lpFile = file;
lpExecInfo.lpParameters = args;
lpExecInfo.lpDirectory = _T("");
lpExecInfo.lpVerb = _T("open");
lpExecInfo.nShow = SW_MINIMIZE;
lpExecInfo.fMask = 0;
lpExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NOASYNC;// | SEE_MASK_FLAG_DDEWAIT;//0; lpExecInfo.hwnd = NULL;
lpExecInfo.hInstApp = NULL;//AfxGetInstanceHandle();
if(!ShellExecuteEx(&lpExecInfo))
{
DWORD err = GetLastError();
TRACE(L"ShellExecuteEx Error %d %s\n", err, ErrorString(err));
/// Sleep(100);
return (HRESULT)err;//ERROR_SUCCESS;
}
if (lpExecInfo.hProcess > 0)
{
TRACE(L"ShellExecuteEx WaitForSingleObject hProcess=%X\n", lpExecInfo.hProcess);
DWORD res = ::WaitForSingleObject(lpExecInfo.hProcess, lTimeout/*INFINITE*/);//5000);
TRACE(L"WaitForSingleObject lTimeout=%X, res=%X\n", lTimeout, res);
/// Sleep(100);
if (lTimeout != INFINITE && res != WAIT_OBJECT_0)
{
TerminateProcess(lpExecInfo.hProcess, 0);
TRACE(L"TerminateProcess;\n");
}
CloseHandle(lpExecInfo.hProcess);
}
TRACE(L"return ERROR_SUCCESS;\n");
return ERROR_SUCCESS;
}
catch (...)
{
DWORD err = 0x80070000 | GetLastError();
MessageBox(NULL, ErrorString(err), _T("ShellExecuteWait Error"), MB_OK);
return ERROR_SUCCESS;//(HRESULT)err;
}
}
StringList GetPathList(StringList & slPathList)
{
slPathList.clear();
slPathList.push_front(L"Program Files"); // Only for testing. HKCU\Environment PATH value will splitted instead;
slPathList.push_front(L"My Documents");
return slPathList;
}
CString GetCurrentDirectory(CString & csCurDir)
{
csCurDir = L"Program Files\\SHLine"; // Only for testing. HKCU\Environment CurrentDirectory value will readed instead;
return csCurDir;
}
bool FileExists(const wchar_t * file)
{
WIN32_FIND_DATA FindFileData;
HANDLE hFile = ::FindFirstFile(file, &FindFileData) ;
bool bFound = (hFile && (hFile != INVALID_HANDLE_VALUE));
if(bFound)
{
::FindClose(hFile);
}
return bFound;
}
int _tmain(int argc, _TCHAR* argv[])
{
TRACE(L"_tmain(int argc=%d);\n", argc);
if (argc > 1 && argv[1])
{
CString csRunPath = argv[1];
CString csRunArgs = L"";
if (argc > 2 && argv[2])
{
csRunArgs = argv[2];
for (int i = 3; i <= argc; i++)
{
if (argv[i])
{
csRunArgs = csRunArgs + L" " + argv[i];
}
}
}
CString csCurDir;
GetCurrentDirectory(csCurDir);
HRESULT hRes = ERROR_FILE_NOT_FOUND;
CString csFN = L"\\"+csCurDir+L"\\"+csRunPath/*.GetString()*/;
if (FileExists(csFN))
{
hRes = ShellExecuteWait(csFN, csRunArgs/*.GetString()*/, 60000);
}
if (hRes == ERROR_FILE_NOT_FOUND)
{
csFN = L"\\"+csRunPath;
CString csWin = L"\\Windows\\"+csRunPath;
if (FileExists(csFN) || FileExists(csWin))
{
hRes = ShellExecuteWait(csFN, csRunArgs, 60000); // Full path specified or file is known for CE Shell (included to \\Windows\ directory)
}
if (hRes == ERROR_FILE_NOT_FOUND)
{
StringList slPathList;
GetPathList(slPathList);
DWORD dwPath = 0;
for (StringList::iterator itPath = slPathList.begin(); itPath != slPathList.end(); ++itPath)
{
csFN = L"\\"+*itPath+L"\\"+csRunPath;
if (FileExists(csFN))
{
hRes = ShellExecuteWait(csFN, csRunArgs, 60000);
}
}
}
}
TRACE(L"_tmain returns 0x%X;\n", hRes);
return hRes;
}
TRACE(L"_tmain returns E_INVALIDARG;\n");
return E_INVALIDARG;
}
This interpret will be uploaded to \Windows directory to be used by any appplication. One can be batch files interpreter (call this shell with all lines as paramters), or do any controlling (lines can contain controlling directives as cycles etc.). The .bat extension registering is soluted by CE standard way on unlocked phones.
CD.exe, DIR.exe, ..., etc programs will add standard shell functionality. Output (directories listing etc.) will soluted by stdout file forwarding.
In this way one only shell interpreting application (one current directory only) will allowed immeditelly. Better something then nothing.
EDIT:
I have got batch interpreter working. But, very strange behaviour occures:
1. AygShell does not add exe extension automatically. Then I copied "copy.exe" to "\Windows\copy" etc. It works well. But, it does not work for "start" directive! Start is necessary for Iexplore and other "uncloseable" applications launching to prevent interpreter hanging up. It is interesting too "start.exe" (or "start") everytime renames automatically to "Start" with upcased first letter. Probably "\Windows\Start.html" causes this system behaviour.
2. std::list iterating for multi batch lines interpreting crashes everytime, when lauchched application contains any messagebox. Iterating replacing by numerous cyclus soles it. Unbelievable...
I will publish XAP as soon as. Any filemanager can be used for batch lauching after instllation. I recommend Phone Commander, which is able not only launch, but also edit *.bat files.
Non XAP preliminary beta for testers
1. Copy included files to \Windows directory.
2. Apply registry changes by Batch.reg (can be did automatically from Phone Commander etc.).
3. Try tap to Example.bat from any filemanager (Phone Commander, WP7 Root Tools, wPhoExplorer etc.).
4. Make your own scripts (you can use also automatical shell creating function from Phone Commander menu, rename *.sh file to *.bat and edit it's content by Phone Commander "View" edit function by pencil icon).
"start" and "copy" directives only are implemented still. "copy" is implemented with source and destionation parameters only (copies everytime), switches will added in future versions.
start "filename" [params] = nonblocking shell starting
"filename" [params] (without "start") = blocking shell starting, it waits to application closing (danger for iexplore and any other "uncloseable" applications, use "start" instead). It blocks NonDDE shell directives, DDE (pword.exe, other Office applications, etc.) are nonblocking everytime by principle.
"copy" directive + *.reg files interpreter can be used for simple installator creating for your native applications.
The same principle will used for universal scheduler (for example "switch on wifi every monday morning, switch off ringing and wifi tethering every friday evening" etc.).
"SHLine" part is offered for all console application creators (it interprets one batch line). Use stdout file redirect and ShellExecuteEx(...,L"SHLine.exe",User console input line,...);
jessenic said:
Pocket CMD from CE7 ARMv7 works fine via telnet. Tested on my Samsung Omnia 7 and Jaxbot's Samsung Focus. You can see it in action in this screenshot: http://windowsphonehacker.com/articles/all_in_a_days_work-03-03-13
Click to expand...
Click to collapse
Thanks for a tip. There is working on device Telnet xap screenshot:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Xap release will published, when I solute HaRET and Pocket CMD listing switch.
XAP is released.
Download from HaRET WP7 thread.
Console Big Update - try Ping, IPConfig, NetStat, WLanUtils etc.
New Console7 version can offer to you many usable utilities, as cgacutil, etcha, ipconfig, ipconfig6, ipv6, kbdtest, msmqadm, ndisconfig, net, netlogctl, netstat, ping, rnaapp, route, services, shell, tracert, upnpreg and wlantool. With simply user interface you can write commands (or batch or Mort scripts) with big possibilities as on desktop Windows.
Console7 is not so dangerous as HaRET, but you still keep in mind that it can also destroy your operating system and possibly device ...
1. Install XAP.
2. Enable it by Root Manager.
3. Tap to Upeer screen part, tap to Menu button, slide menu left and select "Install pocketcmd shell etc."
4. Wait to reboot.
5. Wait to automatical Console7 start.
6. Type commands in bottom textbox and send it by Enter key. HELP command is available.
7. Try standard commands. Use help , help cmd commands to see full list.
8. Try additional features. Use help, for example:
ipconfig /?
Also copy, delete, etcha. ipconfig, ipconfig6, ipv6, kbdtest, launchuri, md, messagebox, msmqadm, ndisconfig, net, netlogctl, netstat, ping, reboot, regimport, rnaapp, route, services, shell, start, startback, tracert, upnpreg, wlantool directives are offered, some with help by /?.
9. Try Batch and Mort script making by PhoneCommander editor. Batch files (*.bat) are registered authomatically by Console7 installing. MortScripts installator will available as soon as.
10. When you want to risc device Hard Reset, try also "install haret and kernel driver".
11. Try HaRET/Shell switching by yellow buttons.
Remember: PocketCMD using is relatively safe (when you will not delete any system files or directories), but HaRET may be very danger still! Use both on your own risc.

[dev] hook into PhoneStatusBarPolicy

Hello alltogether,
I digged into the Lollipop code to look for a solution to restore the old Kitkat silent mode in Lollipop with Xposed.
I got a working prototype now but would like to add the silentmode icon back to the statusbar.
Unfortunately it got removed in Lollipop so I have to port it forward from an older ROM.
To do that I need to hook into the PhoneStatusBarPolicy class, which for some reason fails.
This is my code:
Code:
private static final String CLASS_PHONE_STATUSBAR_POLICY = "com.android.systemui.statusbar.phone.PhoneStatusBarPolicy$1";
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
if (lpparam.packageName != "android")
return;
final Class<?> classStatusbarPolicy = XposedHelpers.findClass(CLASS_PHONE_STATUSBAR_POLICY, lpparam.classLoader);
XposedHelpers.findAndHookMethod(classStatusbarPolicy, "updateVolumeZen",
new XC_MethodReplacement() {
...
});
}
}
But for some reason it fails:
Code:
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.android.systemui.statusbar.phone.PhoneStatusBarPolicy" on path: DexPathList[[zip file "/system/framework/services.jar", zip file "/system/framework/ethernet-service.jar", zip file "/system/framework/wifi-service.jar"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
Does anyone have an idea?
Thanks!
You should change lpparam.packageName != "android"
to
lpparam.packageName.equals("android")
Why android? This class is within com.android.systemui package.
C3C076 said:
Why android? This class is within com.android.systemui package.
Click to expand...
Click to collapse
Ah I guess I misread rovos post about the new API with the dummy android package.
In detail, this means: If you want to hook a system service like PackageManagerService, you can no longer do that in initZygote(). Instead, move your code to handleLoadPackage() and check for dummy package "android". Make sure you use lpparam.classLoaders when looking for classes and hooking methods. This way has worked in older Android versions as well, so you don't lose backwards-compatiblity.
Click to expand...
Click to collapse
After reading it again this just applies to system services. And based on some code I saw at your Gravitybox repo it doesn't even seem to apply to all system services as you are still hooking a couple during initZygote
Xposed is new to me, but it's an amazing toolset!
So hooking works fine now, unfortunately it just got a bit ugly as the StatusBarManager which I'd like to use for the icons can't get imported. I guess I'll have to use some reflection to get into the class hehe.

Categories

Resources