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

Commit 774d8669 authored by Makoto Onuki's avatar Makoto Onuki Committed by Android (Google) Code Review
Browse files

Merge "Add DO API to get wifi mac address"

parents d13fb587 a31ebbc4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5776,6 +5776,7 @@ package android.app.admin {
    method public android.app.admin.SystemUpdatePolicy getSystemUpdatePolicy();
    method public java.util.List<android.os.PersistableBundle> getTrustAgentConfiguration(android.content.ComponentName, android.content.ComponentName);
    method public android.os.Bundle getUserRestrictions(android.content.ComponentName);
    method public java.lang.String getWifiMacAddress();
    method public boolean hasCaCertInstalled(android.content.ComponentName, byte[]);
    method public boolean hasGrantedPolicy(android.content.ComponentName, int);
    method public boolean installCaCert(android.content.ComponentName, byte[]);
+1 −0
Original line number Diff line number Diff line
@@ -5906,6 +5906,7 @@ package android.app.admin {
    method public android.app.admin.SystemUpdatePolicy getSystemUpdatePolicy();
    method public java.util.List<android.os.PersistableBundle> getTrustAgentConfiguration(android.content.ComponentName, android.content.ComponentName);
    method public android.os.Bundle getUserRestrictions(android.content.ComponentName);
    method public java.lang.String getWifiMacAddress();
    method public boolean hasCaCertInstalled(android.content.ComponentName, byte[]);
    method public boolean hasGrantedPolicy(android.content.ComponentName, int);
    method public boolean installCaCert(android.content.ComponentName, byte[]);
+17 −0
Original line number Diff line number Diff line
@@ -4649,4 +4649,21 @@ public class DevicePolicyManager {
            return false;
        }
    }

    /**
     * Called by device owner to get the MAC address of the Wi-Fi device.
     *
     * @return the MAC address of the Wi-Fi device, or null when the information is not
     * available. (For example, Wi-Fi hasn't been enabled, or the device doesn't support Wi-Fi.)
     *
     * <p>The address will be in the {@code XX:XX:XX:XX:XX:XX} format.
     */
    public String getWifiMacAddress() {
        try {
            return mService.getWifiMacAddress();
        } catch (RemoteException re) {
            Log.w(TAG, "Failed talking with device policy service", re);
            return null;
        }
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -236,4 +236,5 @@ interface IDevicePolicyManager {
    List<String> getKeepUninstalledPackages(in ComponentName admin);
    boolean isManagedProfile(in ComponentName admin);
    boolean isSystemOnlyUser(in ComponentName admin);
    String getWifiMacAddress();
}
+25 −0
Original line number Diff line number Diff line
@@ -71,6 +71,8 @@ import android.media.IAudioService;
import android.net.ConnectivityManager;
import android.net.ProxyInfo;
import android.net.Uri;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.AsyncTask;
import android.os.Binder;
import android.os.Bundle;
@@ -1121,6 +1123,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
            return Looper.myLooper();
        }

        WifiManager getWifiManager() {
            return mContext.getSystemService(WifiManager.class);
        }

        long binderClearCallingIdentity() {
            return Binder.clearCallingIdentity();
        }
@@ -6871,6 +6877,25 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        return true;
    }

    @Override
    public String getWifiMacAddress() {
        // Make sure caller has DO.
        synchronized (this) {
            getActiveAdminForCallerLocked(null, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
        }

        final long ident = mInjector.binderClearCallingIdentity();
        try {
            final WifiInfo wifiInfo = mInjector.getWifiManager().getConnectionInfo();
            if (wifiInfo == null) {
                return null;
            }
            return wifiInfo.hasRealMacAddress() ? wifiInfo.getMacAddress() : null;
        } finally {
            mInjector.binderRestoreCallingIdentity(ident);
        }
    }

    /**
     * Returns the target sdk version number that the given packageName was built for
     * in the given user.
Loading