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

Commit 9fc4d4ca 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: Ifb672f1a6310cfd5257bd7989c13759cb62f3afd
parent a12f587d
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -2885,6 +2885,11 @@ public final class Settings {
         */
        public static final String ADB_NOTIFY = "adb_notify";

        /**
         * The host name for this device.
         */
        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
+16 −7
Original line number Diff line number Diff line
@@ -253,12 +253,21 @@ public class ConnectivityService extends IConnectivityManager.Stub {
    private ConnectivityService(Context context) {
        if (DBG) Slog.v(TAG, "ConnectivityService starting up");

        // setup our unique device name
        // try to get our custom device name
        String hostname = Settings.Secure.getString(context.getContentResolver(),
                Settings.Secure.DEVICE_HOSTNAME);
        if (hostname != null && hostname.length() > 0) {
            SystemProperties.set("net.hostname", hostname);
            Slog.i(TAG, "hostname has been set: " + hostname);
        } else {
            // otherwise setup our unique device name
            String id = Settings.Secure.getString(context.getContentResolver(),
                    Settings.Secure.ANDROID_ID);
            if (id != null && id.length() > 0) {
            String name = new String("android_").concat(id);
                String name = new String("android-").concat(id);
                SystemProperties.set("net.hostname", name);
                Slog.i(TAG, "hostname has been set: " + name);
            }
        }

        mContext = context;