Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 547b5fb5 authored by Alex Avance's avatar Alex Avance Committed by Steve Kondik
Browse files

Add an option to change the device hostname (1/2).

This adds an option to modify the device hostname used
in ip resolution. This is useful when connecting to the
android device in a dynamic dhcp environment.

Change-Id: I44e4771f4415a32fe66867d4dd90f1ad138341e1
parent 7b5b624b
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -3095,6 +3095,12 @@ public final class Settings {
         */
        public static final String ADB_PORT = "adb_port";

        /**
         * The hostname for this device
         * @hide
         */
        public static final String DEVICE_HOSTNAME = "device_hostname";

        /**
         * Setting to allow mock locations and location provider status to be injected into the
         * LocationManager service for testing purposes during application development.  These
+5 −1
Original line number Diff line number Diff line
@@ -334,13 +334,17 @@ public class ConnectivityService extends IConnectivityManager.Stub {
        mHandler = new MyHandler(handlerThread.getLooper());

        // setup our unique device name
        if (TextUtils.isEmpty(SystemProperties.get("net.hostname"))) {
        String hostname = Settings.Secure.getString(context.getContentResolver(),
                Settings.Secure.DEVICE_HOSTNAME);
        if (TextUtils.isEmpty(hostname) && TextUtils.isEmpty(SystemProperties.get("net.hostname"))) {
            String id = Settings.Secure.getString(context.getContentResolver(),
                    Settings.Secure.ANDROID_ID);
            if (id != null && id.length() > 0) {
                String name = new String("android-").concat(id);
                SystemProperties.set("net.hostname", name);
            }
        } else {
            SystemProperties.set("net.hostname", hostname);
        }

        // read our default dns server ip