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

Commit 5c6e6b45 authored by Philip P. Moltmann's avatar Philip P. Moltmann Committed by android-build-merger
Browse files

Merge "Enable multi-cast while resolving nsd services" into pi-dev

am: da80202b

Change-Id: I6b44a933f9633d70ffb57034a8e8a6d23f8b028e
parents 8acacb70 da80202b
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -18,12 +18,13 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.printservice.recommendation"
    android:versionCode="2"
    android:versionName="1.1.0">
    android:versionCode="3"
    android:versionName="1.2.0">

    <uses-sdk android:minSdkVersion="24"
        android:targetSdkVersion="25" />

    <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />

    <application
+17 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.printservice.recommendation;

import android.content.res.Configuration;
import android.net.wifi.WifiManager;
import android.printservice.PrintService;
import android.printservice.recommendation.RecommendationInfo;
import android.printservice.recommendation.RecommendationService;
@@ -47,8 +48,20 @@ public class RecommendationServiceImpl extends RecommendationService
    /** All registered plugins */
    private ArrayList<RemotePrintServicePlugin> mPlugins;

    /** Lock to keep multi-cast enabled */
    private WifiManager.MulticastLock mMultiCastLock;

    @Override
    public void onConnected() {
        WifiManager wifiManager = getSystemService(WifiManager.class);
        if (wifiManager != null) {
            if (mMultiCastLock == null) {
                mMultiCastLock = wifiManager.createMulticastLock(LOG_TAG);
            }

            mMultiCastLock.acquire();
        }

        mPlugins = new ArrayList<>();

        try {
@@ -125,6 +138,10 @@ public class RecommendationServiceImpl extends RecommendationService
                Log.e(LOG_TAG, "Could not stop plugin", e);
            }
        }

        if (mMultiCastLock != null) {
            mMultiCastLock.release();
        }
    }

    @Override