Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get push messages to work in work profile/shelter? #764

Open
rugk opened this issue Apr 19, 2019 · 32 comments
Open

How to get push messages to work in work profile/shelter? #764

rugk opened this issue Apr 19, 2019 · 32 comments

Comments

@rugk
Copy link

rugk commented Apr 19, 2019

I've tried setting this up in shelter, but the GCM messaging not work. "push notification tester" cannot register for listening to push notifications. (When I enable the request to be manually approved, the usual question is not even shown.)

The logcat shows the push notification tester is trying "check token availability" again and again…

I am using https://lineage.microg.org/.

Is there any special setup I need?

Which apps, do I need to clone into the shelter? Do I need to also clone "Services Framework Proxy"?


More details/also reported at https://git.angry.im/PeterCxy/Shelter/issues/26 and bbindreiter/PushNotificationTester_App#7 (as the test app actually crashes.)

Also related to #747.

@rugk rugk changed the title How to get it to work in work profile/shelter? How to get push messages to work in work profile/shelter? Apr 19, 2019
@miquecg
Copy link

miquecg commented Apr 21, 2019

Testing app for push notifications also fails for me in the work profile. Device registration seems not possible at some point.

E FirebaseInstanceId: Token retrieval failed: SERVICE_NOT_AVAILABLE
...
E PushNotificationTester: Registering for Push Notifications failed

@rugk
Copy link
Author

rugk commented Apr 21, 2019

Yeah, BTW, also discovered you get exactly the same behaviour/failure if you setup a new user on Android and do everything there. (Likely, because Android's implements for both features is generalized.)

@rugk
Copy link
Author

rugk commented Apr 21, 2019

Actually, discovered #660, which should be about the same issue. The user also mentions a workaround there…

@MrDodojo
Copy link

Youtube has a push notification issue too

@marlid91
Copy link

Did you copy microg over?

@rugk
Copy link
Author

rugk commented Apr 27, 2019

It is automatically copied.
But I've also copied gfs and fakestore and so on. (see the linked shelter issue in the OP)

@jamorford
Copy link
Contributor

This does already work on my device after setting up microG again in the work profile. I used Island to provision the work profile. This sound more like an installation or ROM specific issue. My setup is a Pixel 3, using the stock ROM + FakeGapps Xposed module, with microG (NanoDroid build) installed in priv-app.

@miquecg
Copy link

miquecg commented May 17, 2019

Correct me if I'm wrong but because microG Core Services is a system app, on Shelter there's no such option as uninstall from the work profile. I've checked it out and the only way would be to clone it again from the main profile. Though not sure if this action will make it work.

@jamorford
Copy link
Contributor

You have the option to disable it, just like in the main profile @miquecg

@miquecg
Copy link

miquecg commented May 17, 2019

I can "freeze" microG (it's the same as disabling) but not uninstall it. You mean cloning over after freezing it?

@jamorford
Copy link
Contributor

@miquecg I'm confused as to what you are trying to accomplish. You can fully disable the app or clear its data from the phone's Settings app. Just look for the app with the work profile (suitcase) icon in the installed apps section. On Android Pie, it is Settings > Apps & notifications > See all (number) apps > microg Services Core (with the suitcase icon)

@miquecg
Copy link

miquecg commented May 17, 2019

@miquecg I'm confused as to what you are trying to accomplish. You can fully disable the app or clear its data from the phone's Settings app. Just look for the app with the work profile (suitcase) icon in the installed apps section. On Android Pie, it is Settings > Apps & notifications > See all (number) apps > microg Services Core (with the suitcase icon)

That's another way to do it hehe. On Shelter you can "freeze" apps and it's exactly the same as disabling AFAIK. I was meaning to freeze (disable) microG in Work profile.

What should I do next? Clone microG from Main to Work profile? Is this going to work having already one clone (disabled) in the Work profile? I don't assume it's going to overwrite it. To me uninstall and disable are different things.

Anyway, I should try your suggestion. Thanks!

@jamorford
Copy link
Contributor

@miquecg you just need to Enable/Install microG in the work profile and set it up again as if it is a new phone. The data between the main profile and the work profile is completely separate, so you have to add your account a second time. The key to get all the features working is to turn on device registration and cloud messaging on before you sign into your Google account in the work profile -- this allows microG to do a check-in right at sign-in (bypassing issue #660). Push messages work fine in my work profile after setting it up in this order.

@rugk
Copy link
Author

rugk commented May 17, 2019

With microG you actually do not need to sign-in to your Google account at all. That's actually a good thing, so the only setup is indeed enabling device registration etc. As I've already described, I've done all that, it still did not work…
And yes, maybe #660 is to blame here.

@miquecg
Copy link

miquecg commented May 17, 2019

I don't use any Google account. That's an important difference between your setup and mine. In fact it could be the reason that it's working for you and not for us.

@prt576
Copy link

prt576 commented May 24, 2019

I have the same problem as a few others seem to be.
I can't get GCM registered within the work profile of Shelter no matter what I try.
I've tried as many different options I can find through Google from reinstalling different apps through to sending checkins via ADB shell broadcasts as the "work profile" user.
I'm using latest LOS 15.1 on Samsung S9 with the latest versions of all relevant software.
My chief test tool has been "Push Notification Tester" app.
As an aside I also seem to be getting the same issue with a Samsung S5 on same versions of OS. Although haven't tested this as thoroughly

@ale5000-git
Copy link
Member

Please all of you try the new version released today to see if the problem still persist.

@rugk
Copy link
Author

rugk commented Jun 2, 2019

The microG F-Droid repo only offers me 0.2.6.13280 (2018-09-27) as the latest version only…

@Vavun
Copy link
Contributor

Vavun commented Jun 2, 2019

@rugk just refresh f-droid repos or download new apk here
https://github.com/microg/android_packages_apps_GmsCore/releases

@ale5000-git
Copy link
Member

ale5000-git commented Jun 2, 2019

There is also the official download page: https://microg.org/download.html

@rugk
Copy link
Author

rugk commented Jun 2, 2019

I uninstalled whole Shelter and set it up again, activated device registration in microG and cloned the push notification tester into the work profile.
However, the test app still fails with "register for push notifications".

(AFAIK I don't need to sign-in to a Google account in microG for push notifications.)

@miquecg
Copy link

miquecg commented Jun 2, 2019

I've done the microG update. After that I've tried to get GCM connected status in the work profile in several ways:

  • Disabel GCM > Allow device registration > Enable GCM
  • Dialing the code again

Notification tester app still cannot register for push notifications.

@05nelsonm
Copy link

05nelsonm commented Jun 11, 2019

I found that you have to proc the registration... what I do (because I have to uninstall shelter every LineageOS4microG update), has been to:

  1. Clone DroidGuard Helper to the Work Profile
  2. Open microG Settings for the Work Profile and:
    -Enable UnifiedNlp Settings
    -Enable Google device registration
    -Enable Google Cloud Messaging
    .....+Click the 3 dots menu (top right) and select Advanced
    .....+Enable Confirm new apps
    -Enable SafetyNet
    .....+Click the 3 dots menu (top right) and select Use official server
  3. Go back to Shelter's Main profile and clone a program that is registered for Cloud Messaging on your non-work profile
    • Bitwarden works for me
  4. Open the app you just cloned to your Work Profile and a popup should come up to register it to Cloud Messaging. Accept it.
  5. Close the app then open microG Settings for the Work Profile and:
    -Disable the Google Cloud Messaging Advanced option to confirm new apps
  6. Clone over other apps and they should automatically register

@duxovni
Copy link

duxovni commented Jul 21, 2019

I've found a fix that works for me (bullhead, Shelter, no Google account):
I enabled ADB root access (not sure whether that's actually needed, I was following other guides that suggested doing so), and then ran

$ adb shell pm list users
Users:
        UserInfo{0:Owner:13} running
        UserInfo{12:Work profile:30} running
$ adb shell am broadcast --user 12 -a android.provider.Telephony.SECRET_CODE -d android_secret_code://2432546 --receiver-include-background 

The important part is getting the user ID for the work profile, and then running the secret code broadcast as that user using the --user flag. After doing this, the push notification tester in Shelter is working, and other apps in Shelter seem to be registering for push notifications.

@miquecg
Copy link

miquecg commented Jul 22, 2019

Hi @duxovni, I appreciate your help but this is not working for me. Maybe there's something slightly different between our setups. Let's try to find out.

I've followed this sequence of steps:

  1. Plug device to USB port and attach to it adb shell
  2. List currently running users
$ pm list users
Users:
	UserInfo{0:Propietario:13} running
	UserInfo{10:Perfil de trabajo:30} running
  1. Regular shell user doesn't have enough privileges to run the command
$ am broadcast --user 10 -a android.provider.Telephony.SECRET_CODE -d android_secret_code://2432546 --receiver-include-background
Broadcasting: Intent { act=android.provider.Telephony.SECRET_CODE dat=android_secret_code://2432546 flg=0x1400000 }
Security exception: Permission Denial: not allowed to send broadcast android.provider.Telephony.SECRET_CODE from pid=15317, uid=2000
  1. To run the command successfully it was enough to become root on the shell
# am broadcast --user 10 -a android.provider.Telephony.SECRET_CODE -d android_secret_code://2432546 --receiver-include-background
Broadcasting: Intent { act=android.provider.Telephony.SECRET_CODE dat=android_secret_code://2432546 flg=0x1400000 }
Broadcast completed: result=0

But this didn't make any difference for the notifications tester app. Also miroG stills reflects device status as disconnected under GCM settings.

@duxovni
Copy link

duxovni commented Jul 22, 2019

Huh, interesting. Did you try enabling ADB root access in the phone's developer settings and running adb root? Maybe that's a necessary part, and the broadcast is failing silently somehow without that.

@miquecg
Copy link

miquecg commented Jul 22, 2019

I don't find anything about 'adb root' on developer settings. There's something related on Security > Trust > Superuser access, that it's about applications on the phone, not adb connection.

Trying adb root on shell results on this message: adbd cannot run as root in production builds.

Possible explanation:

In some developer-friendly ROMs you could just enable Root Access in Settings > Developer option > Root access. After that adb root becomes available. Unfortunately it does not work for most stock ROMs on the market.

https://stackoverflow.com/a/27426909

@duxovni
Copy link

duxovni commented Jul 22, 2019

What ROM are you using? I'm using microG's version of Lineage OS.

@prt576
Copy link

prt576 commented Jul 23, 2019

This is weird. I tried this exact approach a bit over two months ago and it didn't work. I thought I'd give it another go and now it works. FYI I'm using the last version of MicroG LOS for Samsung S9 before it became unsupported. I have however installed the latest MicroG from F-Droid (0.2.8.17785-mapbox). Maybe unrelated but installing the latest version of MicroG this way appears to have messed with Location Services :-(

@miquecg
Copy link

miquecg commented Jul 23, 2019

Finally my problem is solved although in a way I wasn't expecting... I've decided to give it another go but this time I've enabled 'device registration' option. After two tries nothing had changed so I've unchecked the option for 'device registration' and all of the sudden it changed GCM status to 'connected' and I could register apps with no problems.

@est61
Copy link

est61 commented Oct 12, 2019

Is anyone still having an issue with this? Am willing to help.

@geeky-neo
Copy link

geeky-neo commented May 23, 2020

yes. microG under sheltern GCM's Current State : Disconnected.
OS : /e/ OS, LineageOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests