How do you test for permissions? - windows-phone-7

Is there a way to simulate whether permission are granted or denied to use services like location on the Windows Phone 7? I want to get the users current location, but I can't seem to find away to make the phone show me the permissions dialog so that I can deny access to it for testing? Anyone else have these kinds of issues? I'm finding it rather hard to really test this stuff without having the actual hardware.

I can't seem to find any built-in support to check if the user will allow the location & push notification services to be used within an application.
I would expect a location-aware Windows Phone 7 app to present a dialog box to the user informing that location services will be used within the app. The dialog box has a "Allow" and a "Deny" option. Based on the selection of the user, the app may or may not use the location of the user. I have used Shawn Wildermuth's Child Window to evaluate the user's choice and use their decision in their application accordingly.
HTH,
indyfromoz

You don't need to check for permissions. When app is certified, AppHub scans application for code requiring permissions and updates WMAppManifest.xml.
When user installs your app, he agrees on all permissions you need. So if it's launched, then you got all you need.

Related

Reading desktop pictures in sandboxed app

I'm having crashes in my sandboxed app related to reading desktops pictures which I can not reproduce on my Mac but I got rejected on the App Store for it crashing and other users have reported crashing.
The desktop pictures are being read from "/Library/Desktop Pictures" or using NSWorkspace's desktopImageURLForScreen method. These work just fine on my Mac but I'm a little confused because I don't know how I'm getting access to "/Library/Desktop Pictures" without the directory being chosen manually in an NSOpenPanel. As for desktopImageURLForScreen I'm not sure if this is sandbox safe depending on where the file is stored on that users screen.
Can anyone verify these 2 methods for getting the desktop picture are safe in all cases or do I need to request the user select the directory where the desktop pictures are stored (even from desktopImageURLForScreen) in a NSOpenPanel?
First, having the sandbox deny access to a URL does not cause a crash - methods will return error indications. So if your app is crashing it is either because you cannot access the URLs, or because you are not testing correctly for failure.
If you wish to quietly access desktop images you can specify the com.apple.security.assets.pictures.read-only entitlement - this will give your app access to common image locations. It does not guarantee that your app can access the URL of the desktop image, just increases the probability. So you must still test for success or failure.
If your program requires access and if silent access fails you can then put up a standard file dialog; with suitably customised prompts, buttons, etc; to request the user grants access to the URL.
HTH

Windows Phone Privacy policy default message when you install a location app?

I am building an app that uses the location service api.
However I am not sure if I have to implement the default Windows Phone Privacy policy message when you install an app? I have already done the permission functionality when a user starts using my app but I am not sure what to do with the installation message? Is it set by default when you set the category of your app via the submission wizard or not?
Microsoft will detect what services your app uses and prompt the user that your app includes these and ask them to confirm that they want to allow the installation to continue. So there's nothing you need to do in that respect.
I'm not sure in what extent you implemented your permission functionality within your app, but just to be sure: you need a Privacy Statement prompt on first launch, an option to turn off location services and a link to access the statement again. I didn't read the guidelines properly, thus dooming the certification of my app.

WP7 Policy Check

I'm trying to upload an application to the Windows Phone Marketplace but it keeps failing due to the location privacy policy. In the application there is only one part that checks your location, and the user has to manually call it. Basically we show a map, and a button to locate the user, when this button is pressed for the first time, we show a small privacy policy, and we ask the user to allow the use of his location. And even with this, the application's certification failed.
I'm wondering if anyone has a good example of how the privacy policy should be, and if it should be displayed when the app is first launched, rather than when the locations services are activated by the user (like we are currently doing it). And any other tips or advice you may have.
This is the only part of the certification the app failed, so once I get some good answers, it'll be ready to go.
Thanks!
Make sure to read the Windows Phone 7 Application Certification Requirements.
Section 2.10 specifically applies to your problem.
Microsoft really wants you to have a permanent link to your privacy policy somewhere in the app. Your privacy policy should explicitly explain that you collect this data, how you use it, how you store it, who you share it with, and what the user can do about it. You also need a setting somewhere for the user to turn use of GeoLocation data off.
In my app I have an About screen with a link to the PrivPol, TOS and Tech Support. I also have a settings page with an ON / OFF switch for GeoLocation data. I made sure our privacy policy explicitly addresses location data. And we got through approval with no issues.
YMMV.
Do you have the specific certification requirement (the reference number) ? Here are a couple of links about it in the Windows Phone 7 developers forum:
http://forums.create.msdn.com/forums/p/72366/441401.aspx#441401
http://forums.create.msdn.com/forums/p/63656/390088.aspx#390088

Drag and drop on Win7 machine to my app

I have a user that is currently running my Winforms app on Win7. My app allows users to select rows from an open Excel spreadsheet and drag-n-drop them onto the app. However, this user cannot do the drag-n-drop. The cursor changes to the "no" cursor (little circle with line through it) and the operation won't complete.
I was researching drag-n-drop and Win7 and everything I found points to UAC and/or UIPI. I was looking for some solutions and am not sure if any of the below would work:
If the user logs in as admin (and as a result runs my app as admin) would that allow drag-n-drop to work?
Does the user need to turn off or change the settings of UAC/UIPI in order to be able to drag-n-drop?
I am not sure what the issue is. My app usually runs from C:/Documents and Settings/... (C:/Users/... on Win7). Does where it is running from matter? Does drag-n-drop not work because the user is not running my app with enough permissions? Are his Excel and my app on different permission levels? If so, what can be done about that? Note that even though my app allows users to just drag the file directly, that doesn't work either.
Also, is there any way I can have the user reproduce this issue with other apps? Are there apps that come with Win7 that he can see the same problem with. For example, can this be reproduced using Notepad?
Thanks.
Explaining this problem away by UIPI is a very long stretch. It doesn't have anything to do with whether or not the user is logged-in as an admin, that doesn't affect UAC and your program will be running with that same account anyway. The only way UIPI could kick in to stop a D+D is when your program is elevated and Excel is not.
To get yourself elevated requires work and doesn't happen by accident. You'd have to include a manifest so that the user gets the UAC prompt, you'd know about that. Or the user would have to change the desktop shortcut and tick the "Run this program as an administrator" option, she's know about that. While UIPI can be bypassed for Windows messages (ChangeWindowMessageFilter), it cannot for Drag and Drop so if any elevation is going on then your stuck. The ultimate test is to simply ask the user to put the UAC slider all the way down.
The much more likely scenario is that your DragEnter event handler simply isn't happy with the data it sees and therefore doesn't assign the e.Effect property. If you can't get a debugger on-site then write a little test program that logs the values of e.Data.GetFormats() plus whatever else you use to check if the drop is acceptable. And don't forget the obvious: the user simply fumbling the drag somehow.

How to use SetWindowsHookEx in Vista and hook Admin apps with UAC?

I'm trying to figure out if there's a way to use SetWindowsHookEx and be able to affect apps that are run with Admin rights on Vista, with UAC enabled. This is an app that will need to add a small button to the caption bar of other windows to enable some multi-monitor-aware handling. I would have thought this couldn't be done, but I've seen one app that appears to do this. As far as I can tell, this other apps is not being run with Admin rights, and yet it can affect all apps in the system, including those with Admin privilege.
It would seem that there's a way to do this, then, but I'm at a loss on how. My app only needs to be able to draw on window title bars and be able to affect their movement and size. I don't need to do anything else.
You can't, as administrative processes are isolated from non-administrative processes running on the same user desktop. You can't even drag and drop between admin and non-admin processes.
This is an in-dept analysis: http://technet.microsoft.com/en-us/magazine/2007.06.uac.aspx
About the application you are referencing, it probably uses some administrative code running in background (usually as a service) so it can interact with administrative processes.

Resources