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

Commit fe9b529c authored by Chad Brubaker's avatar Chad Brubaker Committed by Steve Kondik
Browse files

Add the calling package name to requestRouteToHost

The calling package name will be used to check if an application is a
system application when deciding if a route should be exempt from VPN
routing rules...

Bug: 12937545
Change-Id: I2c09c875fe9bb9685871a0a801ddcbb32fc17405
parent ea76a734
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -368,10 +368,11 @@ class ContextImpl extends Context {
                            ctx.mMainThread.getHandler());
                }});

        registerService(CONNECTIVITY_SERVICE, new StaticServiceFetcher() {
                public Object createStaticService() {
        registerService(CONNECTIVITY_SERVICE, new ServiceFetcher() {
                public Object createService(ContextImpl ctx) {
                    IBinder b = ServiceManager.getService(CONNECTIVITY_SERVICE);
                    return new ConnectivityManager(IConnectivityManager.Stub.asInterface(b));
                    return new ConnectivityManager(IConnectivityManager.Stub.asInterface(b),
                        ctx.getPackageName());
                }});

        registerService(COUNTRY_DETECTOR, new StaticServiceFetcher() {
+5 −2
Original line number Diff line number Diff line
@@ -396,6 +396,8 @@ public class ConnectivityManager {

    private final IConnectivityManager mService;

    private final String mPackageName;

    /**
     * Tests if a given integer represents a valid network type.
     * @param networkType the type to be tested
@@ -803,7 +805,7 @@ public class ConnectivityManager {
    public boolean requestRouteToHostAddress(int networkType, InetAddress hostAddress) {
        byte[] address = hostAddress.getAddress();
        try {
            return mService.requestRouteToHostAddress(networkType, address);
            return mService.requestRouteToHostAddress(networkType, address, mPackageName);
        } catch (RemoteException e) {
            return false;
        }
@@ -899,8 +901,9 @@ public class ConnectivityManager {
    /**
     * {@hide}
     */
    public ConnectivityManager(IConnectivityManager service) {
    public ConnectivityManager(IConnectivityManager service, String packageName) {
        mService = checkNotNull(service, "missing IConnectivityManager");
        mPackageName = checkNotNull(packageName, "missing package name");
    }

    /** {@hide} */
+2 −2
Original line number Diff line number Diff line
@@ -71,9 +71,9 @@ interface IConnectivityManager

    int stopUsingNetworkFeature(int networkType, in String feature);

    boolean requestRouteToHost(int networkType, int hostAddress);
    boolean requestRouteToHost(int networkType, int hostAddress, String packageName);

    boolean requestRouteToHostAddress(int networkType, in byte[] hostAddress);
    boolean requestRouteToHostAddress(int networkType, in byte[] hostAddress, String packageName);

    boolean getMobileDataEnabled();
    void setMobileDataEnabled(String callingPackage, boolean enabled);
+5 −4
Original line number Diff line number Diff line
@@ -1541,14 +1541,14 @@ public class ConnectivityService extends IConnectivityManager.Stub {
     * desired
     * @return {@code true} on success, {@code false} on failure
     */
    public boolean requestRouteToHost(int networkType, int hostAddress) {
    public boolean requestRouteToHost(int networkType, int hostAddress, String packageName) {
        InetAddress inetAddress = NetworkUtils.intToInetAddress(hostAddress);

        if (inetAddress == null) {
            return false;
        }

        return requestRouteToHostAddress(networkType, inetAddress.getAddress());
        return requestRouteToHostAddress(networkType, inetAddress.getAddress(), packageName);
    }

    /**
@@ -1560,7 +1560,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
     * desired
     * @return {@code true} on success, {@code false} on failure
     */
    public boolean requestRouteToHostAddress(int networkType, byte[] hostAddress) {
    public boolean requestRouteToHostAddress(int networkType, byte[] hostAddress,
            String packageName) {
        enforceChangePermission();
        if (mProtectedNetworks.contains(networkType)) {
            enforceConnectivityInternalPermission();
@@ -4379,7 +4380,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {

                            // Make a route to host so we check the specific interface.
                            if (mCs.requestRouteToHostAddress(ConnectivityManager.TYPE_MOBILE_HIPRI,
                                    hostAddr.getAddress())) {
                                    hostAddr.getAddress(), null)) {
                                // Wait a short time to be sure the route is established ??
                                log("isMobileOk:"
                                        + " wait to establish route to hostAddr=" + hostAddr);