android.net.IConnectivityManager Java Examples

The following examples show how to use android.net.IConnectivityManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CmdWifiAP.java    From PhoneProfilesPlus with Apache License 2.0 5 votes vote down vote up
static boolean setWifiAP(boolean enable, boolean doNotChangeWifi) {
    //PPApplication.logE("CmdWifiAP.setWifiAP", "START enable="+enable);
    //PPApplication.logE("CmdWifiAP.setWifiAP", "START doNotChangeWifi="+doNotChangeWifi);
    final String packageName = PPApplication.PACKAGE_NAME;
    try {
        IConnectivityManager connectivityAdapter = IConnectivityManager.Stub.asInterface(ServiceManager.getService("connectivity"));  // service list | grep IConnectivityManager
        //PPApplication.logE("CmdWifiAP.setWifiAP", "connectivityAdapter="+connectivityAdapter);
        if (enable) {
            if (!doNotChangeWifi) {
                IWifiManager wifiAdapter = IWifiManager.Stub.asInterface(ServiceManager.getService("wifi"));  // service list | grep IWifiManager
                //PPApplication.logE("CmdWifiAP.setWifiAP", "wifiAdapter="+wifiAdapter);
                int wifiState = wifiAdapter.getWifiEnabledState();
                boolean isWifiEnabled = ((wifiState == WifiManager.WIFI_STATE_ENABLED) || (wifiState == WifiManager.WIFI_STATE_ENABLING));
                //PPApplication.logE("CmdWifiAP.setWifiAP", "isWifiEnabled="+isWifiEnabled);
                if (isWifiEnabled)
                    wifiAdapter.setWifiEnabled(packageName, false);
            }

            ResultReceiver dummyResultReceiver = new ResultReceiver(null);
            connectivityAdapter.startTethering(0, dummyResultReceiver, false, packageName);
        } else {
            connectivityAdapter.stopTethering(0, packageName);
        }

        //PPApplication.logE("CmdWifiAP.setWifiAP", "END=");
        return true;
    } catch (java.lang.SecurityException ee) {
        //Log.e("CmdWifiAP.setWifiAP", Log.getStackTraceString(ee));
        //PPApplication.logToCrashlytics("E/CmdWifiAP.setWifiAP: " + Log.getStackTraceString(ee));
        //PPApplication.recordException(e);
        //PPApplication.logE("CmdWifiAP.setWifiAP", Log.getStackTraceString(e));
        return false;
    } catch (Throwable e) {
        //Log.e("CmdWifiAP.setWifiAP", Log.getStackTraceString(e));
        PPApplication.recordException(e);
        //PPApplication.logE("CmdWifiAP.setWifiAP", Log.getStackTraceString(e));
        return false;
    }
}
 
Example #2
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
public Object createStaticService() {
    IBinder b = ServiceManager.getService(CONNECTIVITY_SERVICE);
    return new ConnectivityManager(IConnectivityManager.Stub.asInterface(b));
}
 
Example #3
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
public Object createStaticService() {
    IBinder b = ServiceManager.getService(CONNECTIVITY_SERVICE);
    return new ConnectivityManager(IConnectivityManager.Stub.asInterface(b));
}
 
Example #4
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
public Object createService(ContextImpl ctx) {
    IBinder b = ServiceManager.getService(CONNECTIVITY_SERVICE);
    return new ConnectivityManager(IConnectivityManager.Stub.asInterface(b));
}
 
Example #5
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
public Object createService(ContextImpl ctx) {
    IBinder b = ServiceManager.getService(CONNECTIVITY_SERVICE);
    return new ConnectivityManager(IConnectivityManager.Stub.asInterface(b));
}
 
Example #6
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
public Object createStaticService() {
    IBinder b = ServiceManager.getService(CONNECTIVITY_SERVICE);
    return new ConnectivityManager(IConnectivityManager.Stub.asInterface(b));
}
 
Example #7
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
public Object createStaticService() {
    IBinder b = ServiceManager.getService(CONNECTIVITY_SERVICE);
    return new ConnectivityManager(IConnectivityManager.Stub.asInterface(b));
}
 
Example #8
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
public Object createStaticService() {
    IBinder b = ServiceManager.getService(CONNECTIVITY_SERVICE);
    return new ConnectivityManager(IConnectivityManager.Stub.asInterface(b));
}
 
Example #9
Source File: SystemServiceRegistry.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
@Override
public ConnectivityManager createService(Context context) throws ServiceNotFoundException {
    IBinder b = ServiceManager.getServiceOrThrow(Context.CONNECTIVITY_SERVICE);
    IConnectivityManager service = IConnectivityManager.Stub.asInterface(b);
    return new ConnectivityManager(context, service);
}