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

Commit 5be9e7e2 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 96121f81
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -4706,6 +4706,12 @@ public final class Settings {
         */
        public static final String ADB_NOTIFY = "adb_notify";

        /**
         * 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
+6 −1
Original line number Diff line number Diff line
@@ -629,13 +629,18 @@ public class ConnectivityService extends IConnectivityManager.Stub
        mTrackerHandler = new NetworkStateTrackerHandler(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