ma1co / Sony-PMCA-RE

Reverse Engineering Sony Digital Cameras
MIT License
2.02k stars 224 forks source link

Sony SmartRemote APK - MultiWifi support #64

Open mungewell opened 6 years ago

mungewell commented 6 years ago

I have the official Sony SmartRemote installed on my HX60, when started it will bring down the existing WiFi connection (to my router) to offer a WiFi-Direct connection. Does anyone know how to prevent this?

Looking at the contents of the APK in 'classes.dex' I see the following string IsWifiMultiSupported

But I'm not an Android hacker... is this a reference to a key in the 'Backup.bin' I can set?

mungewell commented 6 years ago

Poking around some more I found an APK decompiler.

"com.sony.imaging.app.srctrl-2_source_from_JADX/com/sony/imaging/app/base/shooting/widget/RotationalSubLcdTextWifiMode.java" contains

public class RotationalSubLcdTextWifiMode extends RotationalSubLcdTextView {
    private static final String KEY_WIFI_MODE_SUPPORTED = "wifi-mode-supported";
...
    private boolean isWifiMultiSupported(Context context) {
        if (!(context instanceof Activity)) {
            return false;
        }
        Activity activity = (Activity) context;
        try {
            ActivityInfo info = activity.getPackageManager().getActivityInfo(activity.getComponentName(), LiveviewCommon.PAYLOAD_HEADER_SIZE);
            if (info.metaData == null) {
                return false;
            }
            String metaData = info.metaData.getString(KEY_WIFI_MODE_SUPPORTED);
            if (metaData == null) {
                return false;
            }
            for (String supportedWifiMode : metaData.split(",")) {
                if (FocusAreaController.MULTI.equals(supportedWifiMode)) {
                    return true;
                }
            }
            return false;
        } catch (NameNotFoundException e) {
            e.printStackTrace();
            return false;
        }
    }

    public boolean isValidValue() {
        if (mIsWifiMultiSupported.booleanValue() && !isAirPlaneModeOn() && ScalarProperties.getInt("wifi.setting") == 2) {
            return true;
        }
        return false;
    }

But still none the wiser about about where "wifi-mode-supported" would be declared.

mungewell commented 6 years ago

I think the above is a bit of misdirection, and only involved in placing an icon on the display.

It seems that the state of the WiFi is passed in messages from the Android core, and monitored in "com/sony/imaging/app/srctrl/SRCtrlRootState.java". In particular this function manages which ESSID to use. Although this references a list I haven't yet found a way to tell the camera to use an already registered accesspoint.

    private void startGroupOwner() {
        this.isGroupCreateActionFiltered = false;
        WifiP2pDeviceInfo dDevice = this.wifiP2pManager.getMyDevice();
        if (dDevice == null) {
            try {
                Log.v(TAG, "Waiting for DirectDevice");
                Thread.sleep(200);
            } catch (InterruptedException e) {
                Log.e(TAG, "InterruptedException");
            }
            dDevice = this.wifiP2pManager.getMyDevice();
        }
        List<WifiP2pConfiguration> confList = this.wifiP2pManager.getConfigurations();
        if (confList.size() > 0) {
            Log.w(TAG, "#### Use device info ####");
            String deviceName = dDevice.getName();
            NetworkRootState.setMyDeviceName(deviceName);
            this.wifiP2pManager.setSsidPostfix(ScalarWifiInfo.getProductCode() + ":" + deviceName);
            this.wifiP2pManager.startGo(((WifiP2pConfiguration) confList.get(confList.size() - 1)).getNetworkId());
            return;
        }

Meanwhile the opening display of the app is handled in "com/sony/imaging/app/srctrl/network/waiting/waiting/NwWaitingState.java".