servalproject / serval_chat

Other
33 stars 18 forks source link

Android 8 & 9 support #11

Open aboozaid opened 4 years ago

aboozaid commented 4 years ago

I just get into testing this apk in android 8 & 9 with no luck at all. As I know there are many problems regarding network connectivity, GPS and other services for these two versions due to security layers. APK works just fine with versions less than android 8 I just wonder if there is any intent to investigate the problem which is app crashed when you just try to open it (this is happening in android 9 only) on the other side android 8 has problem when opening BL or Hotspot some time crash and sometimes not.

I'm still trying to solve it but I would be happy to have others help.

aboozaid commented 4 years ago

@lakeman what do you think?

lakeman commented 4 years ago

If you can paste a stack trace, I can have a quick look at it.

aboozaid commented 4 years ago

Well, let me first put you in the situation. This is happening in both android 8 & 9, When you open BL from the device itself and then open the app, it will be crashed immediately. The same thing goes when you open wifi except it will be crashed until you connect to someone's wifi network (or via wifi-direct).

This is the error for both situation image

Another problem with hotspot which is not opened or closed at all (which is obviously because of security layers in these versions)

this is the error I got image

All permissions are granted already.

aboozaid commented 4 years ago

For a hotspot error, I think I solved it but I will test it later and let you know.

This is where the error comes from WifiServiceImpl.java

/**
 * see {@link WifiManager#getWifiApConfiguration()}
 * @return soft access point configuration
 * @throws SecurityException if the caller does not have permission to retrieve the softap
 * config
 */
@Override
public WifiConfiguration getWifiApConfiguration() {
    enforceAccessPermission();
    int uid = Binder.getCallingUid();
    // only allow Settings UI to get the saved SoftApConfig
    if (!mWifiPermissionsUtil.checkConfigOverridePermission(uid)) {
        // random apps should not be allowed to read the user specified config
        throw new SecurityException("App not allowed to read or update stored WiFi Ap config "
                + "(uid = " + uid + ")");
    }
    mLog.trace("getWifiApConfiguration uid=%").c(uid).flush();
    return mWifiStateMachine.syncGetWifiApConfiguration();
}

Just add this permission

<permission android:name="android.permission.OVERRIDE_WIFI_CONFIG"
    android:protectionLevel="signature|privileged" />
lakeman commented 4 years ago

Looks like foreground notifications changed in O; https://smartdevicelink.com/en/guides/android/getting-started/integration-basics/

testUserConfig is already trying to catch securityexception. Are you sure that's the cause of the crash? https://github.com/servalproject/serval_chat/blob/08ed786b657fe9dbdc1f6193f6b8b39d2aacc4cd/app/src/main/java/org/servalproject/mid/networking/Hotspot.java#L70

We are using an unsupported api, it was always a bit surprising that it worked at all. Using it was already a problem with some earlier American telco builds of android.

On Thu, 10 Oct 2019 at 06:07, Assem notifications@github.com wrote:

For a hotspot error, I think I solved it but I will test it later and let you know.

This is where the error comes from WifiServiceImpl.java

/**

  • see {@link WifiManager#getWifiApConfiguration()}
  • @return soft access point configuration
  • @throws SecurityException if the caller does not have permission to retrieve the softap
  • config */ @Override public WifiConfiguration getWifiApConfiguration() { enforceAccessPermission(); int uid = Binder.getCallingUid(); // only allow Settings UI to get the saved SoftApConfig if (!mWifiPermissionsUtil.checkConfigOverridePermission(uid)) { // random apps should not be allowed to read the user specified config throw new SecurityException("App not allowed to read or update stored WiFi Ap config "
    • "(uid = " + uid + ")"); } mLog.trace("getWifiApConfiguration uid=%").c(uid).flush(); return mWifiStateMachine.syncGetWifiApConfiguration(); }

Just add this permission

<permission android:name="android.permission.OVERRIDE_WIFI_CONFIG" android:protectionLevel="signature|privileged" />

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/servalproject/serval_chat/issues/11?email_source=notifications&email_token=AAEQHXRCNEDM6AMIVYRM2WLQNYXHLA5CNFSM4I62C5JKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAZCFOA#issuecomment-540156600, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEQHXTTAHCOAX3VOJ6UGDTQNYXHLANCNFSM4I62C5JA .

aboozaid commented 4 years ago

Looks like foreground notifications changed in O; https://smartdevicelink.com/en/guides/android/getting-started/integration-basics/

Yeah, that's true I think we have to catch up with the new API for oreo and pie versions.

testUserConfig is already trying to catch securityexception. Are you sure that's the cause of the crash? https://github.com/servalproject/serval_chat/blob/08ed786b657fe9dbdc1f6193f6b8b39d2aacc4cd/app/src/main/java/org/servalproject/mid/networking/Hotspot.java#L70

I didn't say it causes a crash but it doesn't work at all If you tried to open or close it and that's because you use an unsupported API (or to be clear systemApi now).

Using it was already a problem with some earlier American telco builds of android.

What's their android versions? as far as I know, everything works great with android less than oreo.

aboozaid commented 4 years ago

WifiManager methods have been hidden for only systemApi usage. to create a hotspot now you have to use startLocalOnlyHotspot function from WifiManager which creates an auto-generated SSID and password (It's a bad approach because you have to broadcast the password over a discovery service or BL)

lakeman commented 4 years ago

Yeah, since android is now so focused on user intervention, it seemed pointless to implement. Just giving the user a quick link to the normal hotspot seemed equivalent.

On Thu, 10 Oct 2019 at 16:19, Assem notifications@github.com wrote:

WifiManager methods have been hidden for only systemApi usage. to create a hotspot now you have to use startLocalOnlyHotspot function from WifiManager which creates an auto-generated SSID and password (It's a bad approach because you have to broadcast the password over a discovery service or BL)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/servalproject/serval_chat/issues/11?email_source=notifications&email_token=AAEQHXUYTYZYIOTCCEDNFZ3QN266NA5CNFSM4I62C5JKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEA2ZYHQ#issuecomment-540384286, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEQHXU3V5VW5FXAUA45BCDQN266NANCNFSM4I62C5JA .

aboozaid commented 4 years ago

I don't think so because most of the people now have really great and smart devices which run these versions (according to statistics, Google always recommends their users to update their OS to the last version which is 9), However, I will try to solve them and see if I can make a pull request if you don't mind.

aboozaid commented 4 years ago

Yeah, since android is now so focused on user intervention, it seemed pointless to implement. Just giving the user a quick link to the normal hotspot seemed equivalent. On Thu, 10 Oct 2019 at 16:19, Assem @.***> wrote: WifiManager methods have been hidden for only systemApi usage. to create a hotspot now you have to use startLocalOnlyHotspot function from WifiManager which creates an auto-generated SSID and password (It's a bad approach because you have to broadcast the password over a discovery service or BL) — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#11?email_source=notifications&email_token=AAEQHXUYTYZYIOTCCEDNFZ3QN266NA5CNFSM4I62C5JKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEA2ZYHQ#issuecomment-540384286>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEQHXU3V5VW5FXAUA45BCDQN266NANCNFSM4I62C5JA .

Yeah, it's equivalent except it will give you a crash if you open it from outside and get into the app again due to the changing of foreground services API.

gardners commented 4 years ago

We still need to fix this, so I'll reopen it.