Changing policy name on device didn't remove old policy apps from the device - android-management-api

When I change the policy name firstpolicy to secondpolicy on the device, the patch API response is 200 ok and it removes apps of first policy to apps of second policy from the play store app, but it did not remove them from the device. It still shows apps of the first policy.
I am using an update mask.
Testing fully managed device
Any help appreciated.

The stack overflow thread at Android Device Policy sync does not work until done manually mentions a reboot will force apply a policy, which isn't ideal but it does at least ensure a policy is updated. I'm also testing a fully managed device.
https://developers.google.com/android/management/reference/rest/v1/enterprises.devices/issueCommand details the standard for sending a command to a device. You can test it against live data with the API explorer on that page, so navigate towards the bottom of the page where it says 'Request Parameters' -> 'Name', and put in your enterprise & device ids of the form 'enterprises/your-enterprise-id/devices/your-device-id'. Then go to 'Request Body' and use the '+' sign to add 'type' : 'REBOOT' as a parameter. Press the execute button, in which you will be prompted to choose an account for OAuth2.0. After this, you will see the results, and if successful (returns a 200 code), it will issue the reboot command, with the policy being updated after rebooting.
To reiterate, I know this isn't ideal, but it at least does do an update, so just providing that info.
Good luck and let me know if everything worked out.

It may take a while for the policy to sync and apply any changes, including removal of apps. You can force sync by opening the Android Device Policy app and touching the sync button. The other way is to issue a reboot command to the device to make sure that the new policy is applied. You can check the issueCommand method for more information.

Related

Custom google home action should always reconnect to get it working

i have a custom google home action implemented as described in the documentation (Oauth2 setup, sync, execute, etc... setup) and all works as expected on my Google home app and my google home physical devices.
Now, every now and then i need to reconnect the app in the Google Home App because it seems the app cannot reach my devices after some time. I checked my Oauth server if the refresh tokens are working ok and they do. Also my access token expires after 20 minutes and me reconnecting to the app should be done after some hours so the refreshing works in my opinion.
Now, are there any restrictions in using the TEST of the google home action?
The case i wrote is specific for personal use (intergration with personal server and domotica system) so i am actually not planning on releasing it, I just want to use it for myself. Is this allowed? Can i just leave my action in 'test' forever for such purposes?
EDIT: 18/05/2022: custom actions still working flawlessly after 6 months in test :-)
EDIT: 02/02/2023: custom actions still working flawlessly in test :-)
Additional question:
If i have to submit the app for release, i cannot meet the expectation in implementing state report as i have no control over the usage of buttons pressed at my home domotica. Is State Reporting also accepted when i report the state of my devices over time (let's say, every hour?)
tnx
EDIT:
So it seems there is something wrong with my refreshing of the tokens but i don't know what. When i try through postman, all works as expected, in stackdriver logs i see this :
jsonPayload: {
#type: "type.googleapis.com/google.identity.accountlinking.type.AccountLinkingError"
errorReason: "Failed to get response from 3P. 3P returned malformed response like invalid response code or un-inflatble body."
request: {
body: "grant_type=refresh_token&refresh_token=REDACTED_VALUE&client_id=qbusauth&client_secret=REDACTED_VALUE"
method: "POST"
uri: "https://******.azurewebsites.net/token"
}
sessionId: -1039956344
step: "REFRESH_ACCESS_TOKEN"
If you don't plan to submit your Action for release, you'll just need to occasionally re-enable device testing through the console.
To minimize the number of query intents to your fulfillment, you should implement Report State and proactively send device states to update HomeGraph. You would have to implement this if you decide to release your Action.

Local receipt doesn't get updated after (automatically) renewing a subscription

I have an app that uses in-app purchases (IAP), specifically auto-renewable subscriptions.
Occasionally it seems that, when a subscription automatically get renewed, the local receipt doesn't get updated automatically. As a result, checking locally if an active subscription is available results false. Performing the same validation remotely (using Apple servers) returns true.
How and when is the local stored receipt updated or is this something that can only be triggered manually? If so, does this need to happen using SKReceiptRefreshRequest or SKPaymentQueue's restoreCompletedTransactions? Based on Apple's documentation the former seems to be the way to go:
A request to refresh the receipt, which represents the user's transactions with your app.
Unfortunately, this fails, perhaps because it thinks there's noting to update? However there is: as the local receipt is outdated as it doesn't contain the renewed subscription status.
I want to ensure I'm doing things correctly and this behavior (that again happens occasionally) is not something on Apple's end.
Thanks for any feedback.

How does one github tab knows when I logged out on another

To replicate:
Open two github tabs on which you're both logged in
Log out of one tab.
At the top of the 2nd tab you almost immediately get notification that you logged out on another tab
I've been trying to figure out how this works. Since the notification is almost immediate I considered 3 possibilities:
Each tab makes XHR/AJAX requests on a schedule to check session validity with the server (or uses long polling)
Each tab registers an event listener to Server Sent Events, and receives notification from the server upon logout.
Each tab has a websocket connection to the server, and receives a similar notification.
For reference, these technologies are discussed here. I am stumped though because when I open the web browser's (Firefox 48 beta) network requests dev tool, I see no communication on the tab that shows the notification between the time I log out of the other tab, and the time the notification appears.
By the way, the notification works in the opposite direction as well. If you have two tabs logged out, and you log into one of them, a notification immediately pops up on the other tab that you logged in. What's going on?
Github uses Local Storage for this trick. It uses entry with key 'logged-in'. This key is either true or false and is set each time user logs in/out. Each tab constantly check (as I know there is no event on Local Storage modification) Local Storage.

How to get the device token of a mac?

I am using the PushWoosh solution to present and send the notifications from my webpage to the mac users.
I would like to set my computer also as a test device where I could check and test my notifications.
To do this, the PushWoosh wants from me the device token of my mac. How and where can I get it?
Here you can see the screen of PushWoosh:
This paragraph in the "Notification Programming Guide for Websites" documentation seems potentially useful:
To check the permission level a user has set for your website, call
window.safari.pushNotification.permission() with your Website Push
ID as an argument. This synchronous call returns a permission object
for the given identifier by looking in the user’s preferences. This
function does not contact your server.
One of the items passed back in the permission object structure is deviceToken, which appears to be what you are looking for.

In-App Billing subscription issues

With the release of the new subscription option from In-App Billing API we started a proof of concept of the service and we found a few issues. Has anyone else tried it and would have some answers for us? Here's the issues we have been facing so far:
1 – While testing the unsubscribe functionality, the Google Play interface displays a white page with an “Item not found” message and a retry button. Is it due to the fact the app is not yet published? If yes, how can we test this flow without publishing it first?
2 – Inter device synchronization. When making a subscription on one device, other devices tied to the same account did not receive a OnPurchaseStateChange event. Is it again due to the fact the app is not published? Or are subscriptions tied to a particular device and not to an account?
3 – On our Google merchant page, when we cancel a purchase, the device does not receive a notification telling the subscription has been cancelled. Is this a bug? As a workaround we are manually checking the current time and comparing with the expiration date to force a restore transactions call. At this point, we are able to see the subscription is no longer valid. Do you think this is an acceptable solution?
4 – When a subscription is made, two transactions show up on the Google Merchant page: a FAILED transaction with a value of $0 and a valid one with the value we charged. Is this the expected behavior? What’s the purpose of the $0 FAILED transaction?
If anyone has faced similar issues we would like to know. Maybe these could be bugs on Google's end or maybe we did not understand 100% how it is supposed to work.
Thanks in advance.
1.I had the same issue and after I published (and later unpublished) my app I could see the app page in the market,so you can publish and than unpublish.
2.I didn't check it with subscriptions ,but for managed item i didn't get purchaseStateChange on two different devices as expected.
3.I do get subscription expired after canceling one,but only after a while.
I didn't understood how you can get the expiration date ?
you only can get it with access to play developer api.
the restore transactions will give you same purchaseStateChange as you got when purchase the item.
*in the developer guide it is recommanded to use restore transactions only in first app use.
4.I have same issue,and i heard at least about 10 people with same 0$ charge.

Resources