fix crash on Android 2.3

Channel wasn't a thing back then. Catch the ClassNotFound exception and
set the same boolean as when permissions aren't available (in manifest),
which means nothing else tries to run.
This commit is contained in:
Eric House 2016-12-29 17:17:27 -08:00
parent 531f30aae8
commit c0784fe8b7

View file

@ -181,18 +181,20 @@ public class WiDirService extends XWService {
public static void init( Context context )
{
DbgUtils.logd( TAG, "init()" );
ChannelListener listener = new ChannelListener() {
@Override
public void onChannelDisconnected() {
DbgUtils.logd( TAG, "onChannelDisconnected()");
}
};
try {
ChannelListener listener = new ChannelListener() {
@Override
public void onChannelDisconnected() {
DbgUtils.logd( TAG, "onChannelDisconnected()");
}
};
sChannel = getMgr().initialize( context, Looper.getMainLooper(),
listener );
s_discoverer = new ServiceDiscoverer( sChannel );
sHavePermission = true;
} catch ( SecurityException se ) {
} catch ( NoClassDefFoundError ndf ) { // old os version
sHavePermission = false;
} catch ( SecurityException se ) { // perm not in manifest
sHavePermission = false;
}
}