iCar

 
iCar Vám udělá za pomocí levného tabletu či telefonu „chytré auto“ klidně i z 25leté škodovky! :-)

iCar.apk (c) MTs verze 423, Android 6 až 14
iCar-2.apk (c) MTs Android 9+ (i moderní 15+) *
iTargets.apk (c) MTs Android 9+, aplikace na správu oblíbených míst
magisk-cz.mts.iservices17.zip (c) MTs Android 9+, služba pro Wifi/Bluetooth ON/OFF (instaluje se přes Magisk) *
youtube (c) MTs videonávody

 
* Od Androidu 15 už nelze první generaci programu iCar nainstalovat, protože protože necílí (target API) na API36. Jenže od API36 je spousta bezpečnostních omezení a aplikaci už nelze odladit tak, aby uměla ovládat plnohodnotně wifi a bluetooth. Proto jsem udělal ještě verzi 2 a modul (jednoduchá služba - viz. zdroják níže), který se instaluje pomocí Magisk. Pokud Vám nevadí, že wifi a bluetooth neumí iCar zapínat a vypínat, tak tento iservices nemusíte instalovat. Instalace Magisku je snadná, jenže, abyste mohli instalovat moduly, musíte mít telefon odemčený a bootloader upravený právě Magiskem. Na internetu naleznete spoustu návodů jak na to, ale i tak to není úplně trivialná záležitost. Doporučuju tedy pouze pro fajnšmekry, kterým vadí, že iCar neumí vypínat wifi a bluetooth. A ideálně instalovat na separátní telefon určený jen pro auto, protože odemčený telefon nemají rády bankovní aplikace :)


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="cz.mts.iservices">

    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />

    <application>
        <service
            android:name=".myservice"
            android:exported="true">

            <intent-filter>
                <action android:name="cz.mts.iservices.ACTION_WIFI_ON" />
                <action android:name="cz.mts.iservices.ACTION_WIFI_OFF" />
                <action android:name="cz.mts.iservices.ACTION_BT_ON" />
                <action android:name="cz.mts.iservices.ACTION_BT_OFF" />
            </intent-filter>

        </service>
        <receiver
            android:name=".NetworkReceiver"
            android:exported="true">
            <intent-filter>
                <action android:name="cz.mts.iservices.ACTION_WIFI_ON" />
                <action android:name="cz.mts.iservices.ACTION_WIFI_OFF" />
                <action android:name="cz.mts.iservices.ACTION_BT_ON" />
                <action android:name="cz.mts.iservices.ACTION_BT_OFF" />
            </intent-filter>
        </receiver>

    </application>
</manifest>


package cz.mts.iservices;

import android.app.Service;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothManager;
import android.content.Intent;
import android.net.wifi.WifiManager;
import android.os.IBinder;

public class myservice extends Service {

    // Definice action stringů pro klienty
    public static final String ACTION_WIFI_ON  = "cz.mts.iservices.ACTION_WIFI_ON";
    public static final String ACTION_WIFI_OFF = "cz.mts.iservices.ACTION_WIFI_OFF";
    public static final String ACTION_BT_ON    = "cz.mts.iservices.ACTION_BT_ON";
    public static final String ACTION_BT_OFF   = "cz.mts.iservices.ACTION_BT_OFF";

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId)
    {
        if (intent != null) {
            String action = intent.getAction();
            if (ACTION_WIFI_ON.equals(action)) {
                setWifiEnabled(true);
            } else if (ACTION_WIFI_OFF.equals(action)) {
                setWifiEnabled(false);
            } else if (ACTION_BT_ON.equals(action)) {
                setBluetoothEnabled(true);
            } else if (ACTION_BT_OFF.equals(action)) {
                setBluetoothEnabled(false);
            }
        }
        return START_NOT_STICKY;
    }

    private void setWifiEnabled(boolean enable) {
        try {
            WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
            if (wifiManager != null) {
                int state = wifiManager.getWifiState();
                if (enable) {
                    if (state != WifiManager.WIFI_STATE_ENABLED &&
                            state != WifiManager.WIFI_STATE_ENABLING) {
                        wifiManager.setWifiEnabled(true);
                    }
                } else {wifiManager.setWifiEnabled(false);}
            }
        } catch (Exception ignored) {}
    }

    private void setBluetoothEnabled(boolean enable) {
        try {
            BluetoothManager btMgr = (BluetoothManager) getSystemService(BLUETOOTH_SERVICE);
            BluetoothAdapter btAdapter = btMgr != null ? btMgr.getAdapter() : null;

            if (btAdapter != null) {
                int state = btAdapter.getState();
                if (enable) {
                    if (state != BluetoothAdapter.STATE_ON &&
                            state != BluetoothAdapter.STATE_TURNING_ON) {
                        btAdapter.enable();
                    }
                } else {btAdapter.disable();}
            }
        } catch (Exception ignored) {}
    }
}



package cz.mts.iservices;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.wifi.WifiManager;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothManager;

public class NetworkReceiver extends BroadcastReceiver {

    public static final String ACTION_WIFI_ON  = "cz.mts.iservices.ACTION_WIFI_ON";
    public static final String ACTION_WIFI_OFF = "cz.mts.iservices.ACTION_WIFI_OFF";
    public static final String ACTION_BT_ON    = "cz.mts.iservices.ACTION_BT_ON";
    public static final String ACTION_BT_OFF   = "cz.mts.iservices.ACTION_BT_OFF";

    @Override
    public void onReceive(Context context, Intent intent)
    {
        String action = intent.getAction();

        if (ACTION_WIFI_ON.equals(action))
        {setWifiEnabled(context, true);}
        else if (ACTION_WIFI_OFF.equals(action))
        {setWifiEnabled(context, false);}
        else if (ACTION_BT_ON.equals(action))
        {setBluetoothEnabled(context, true);}
        else if (ACTION_BT_OFF.equals(action))
        {setBluetoothEnabled(context, false);}
    }

    private void setWifiEnabled(Context context, boolean enable) {
        try {
            WifiManager wifiManager = (WifiManager) context.getSystemService(context.WIFI_SERVICE);
            if (wifiManager != null) {
                int state = wifiManager.getWifiState();
                if (enable)
                {
                    if (state != WifiManager.WIFI_STATE_ENABLED &&
                            state != WifiManager.WIFI_STATE_ENABLING) {
                        wifiManager.setWifiEnabled(true);
                    }
                } else {wifiManager.setWifiEnabled(false);}
            }
        } catch (Exception ignored) {}
    }

    private void setBluetoothEnabled(Context context, boolean enable) {
        try {
            BluetoothManager btMgr = (BluetoothManager) context.getSystemService(context.BLUETOOTH_SERVICE);
            BluetoothAdapter btAdapter = btMgr != null ? btMgr.getAdapter() : null;

            if (btAdapter != null) {
                int state = btAdapter.getState();
                if (enable) {
                    if (state != BluetoothAdapter.STATE_ON &&
                            state != BluetoothAdapter.STATE_TURNING_ON) {
                        btAdapter.enable();
                    }
                } else {btAdapter.disable();}
            }
        } catch (Exception ignored) {}
    }
}