Merge "Enable multi-cast while resolving nsd services" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
da80202bae
@@ -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,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
|
||||
|
||||
Reference in New Issue
Block a user