Android: extracting wifi capabilities with contains - android

I'm trying to know the type security of the scanned networks, and i'm getting result like this :
[WPA-PSK-TKIP+CCMP][WPA2-PSK-TKIP+CCMP][ESS]
[WPA2-PSK-CCMP][WPS][ESS]
And i used this code :
// Constants used for different security types
public static final String WPA = "WPA";
public static final String WEP = "WEP";
public static final String WPA2 = "WPA2";
public static final String OPEN = "Open";
final String cap = results.get(position).capabilities;
final String[] securityModes = { WEP, WPA, WPA2 };
for (int i = securityModes.length - 1; i >= 0; i--) {
if (cap.toLowerCase().contains(securityModes[i].toLowerCase())) {
textView5.setText(securityModes[i] );
}
else
textView5.setText(OPEN );
}
But i'm just obtaining in textViex :OPEN or WEP , i don't get WPA or WPA2, what could be the problem ?

Try this function :
public String security(String cap){
if (cap.toLowerCase().contains(WEP.toLowerCase()))
{return WEP ;}
else if (cap.toLowerCase().contains(WPA2.toLowerCase()))
{return WPA2;}
else if (cap.toLowerCase().contains(WPA.toLowerCase()))
{return WPA;}
else
return OPEN;
}

Related

How to get WiFi security (NONE, WEP, WPA, WPA2) from Android WifiConfiguration entry?

I need to get security type from WifiConfiguration entry. Is it possible?
String getSecurityType(WifiConfiguration conf) {
}
returning values "NONE", "WEP", "WPA", "WPA2"
For those who think it's a duplicate question: I want to get information from WiFiConfiguration object and not from ScanResult object. It's not the same!
I can do it, simply:
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiConfiguration.AuthAlgorithm;
import android.net.wifi.WifiConfiguration.KeyMgmt;
public static final int SECURITY_NONE = 0;
public static final int SECURITY_WEP = 1;
public static final int SECURITY_PSK = 2;
public static final int SECURITY_EAP = 3;
public static int getSecurity(WifiConfiguration config) {
if (config.allowedKeyManagement.get(KeyMgmt.WPA_PSK))
return SECURITY_PSK;
if (config.allowedKeyManagement.get(KeyMgmt.WPA_EAP) || config.allowedKeyManagement.get(KeyMgmt.IEEE8021X))
return SECURITY_EAP;
return (config.wepKeys[0] != null) ? SECURITY_WEP : SECURITY_NONE;
}
so...
public static String getSecurityType(WifiConfiguration config) {
switch (getSecurity(config)) {
case SECURITY_WEP:
return "WEP";
case SECURITY_PSK:
if (wifiConfiguration.allowedProtocols.get(WifiConfiguration.Protocol.RSN))
return "WPA2";
else
return "WPA";
default:
return "NONE";
}
}

How To Get Network Security Mode OPEN+WEP+WPA2 PSK By SSID programatically

I am using this code to get the list of wifi SSID
WifiManager wifimanager = (WifiManager)getActivity().getSystemService(Context.WIFI_SERVICE);
List<ScanResult> mScanResults = wifimanager.getScanResults();
ArrayList<String> statut = new ArrayList<String>() ;
for(ScanResult results : mScanResults){
Log.e("result",results.SSID);
statut.add(results.SSID);}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),android.R.layout.simple_spinner_item,statut);
spinner = (Spinner) rootView.findViewById(R.id.spinner);
spinner.setAdapter(adapter);
Now I want to extract the WIFI security name (WPA/WPA2/PSK) for each SSID.
Any help will be appreciated.
you can try below code:
private String getScanResultSecurity(ScanResult scanResult){
String capabilities = scanResult.capabilities;
String securityModes[] = { Constants.WEP, Constants.PSK, Constants.EAP};
for(int i = 0; i < securityModes.length; i++){
if(capabilities.contains(securityModes[i])){
return securityModes[i];
}
}
return Constants.OPEN;
}
public class Constants {
// Constants used for different security types
public static final String PSK = "PSK";
public static final String WEP = "WEP";
public static final String EAP = "EAP";
public static final String OPEN = "Open";
}

Android read contacts(and details) seems very slow

I use the following code to read each contacts along with their details.
private static final String[] PROJECTION =
{
Data._ID,
Data.MIMETYPE,
Data.DATA1,
Data.DATA2,
Data.DATA3,
Data.DATA4,
Data.DATA5,
Data.DATA6,
Data.DATA7,
Data.DATA8,
Data.DATA9,
Data.DATA10,
Data.DATA11,
Data.DATA12,
Data.DATA13,
Data.DATA14,
Data.DATA15
};
private static final String SELECTION = Data.LOOKUP_KEY + " = ?";
private String[] mSelectionArgs = { "" };
private static final String SORT_ORDER = Data.MIMETYPE;
private static final int MIME_TYPE_INDEX = 1;
private static final int DISPLAY_NAME_INDEX = 3;//data2
private static final int GIVEN_NAME_INDEX = 3;//data2
private static final int FAMILY_NAME_INDEX = 4;//data3
private static final int MIDDLE_NAME_INDEX = 6;//data5
private static final int ORGANIZATION_INDEX = 2;//data2
private static final int PHONE_TYPE_INDEX = 3;//data2
private static final int PHONE_LABEL_INDEX = 4;//data3
private static final int PHONE_NUMBER_INDEX = 2;//data1
private static final int EMAIL_TYPE_INDEX = 3;//data2
private static final int EMAIL_LABEL_INDEX = 4;//data1
private static final int EMAIL_INDEX = 2;//data1
private byte[] createJsonData(ArrayList<String> selected) throws JSONException, IOException{
Log.d("SynchContactActivity", "Time 1: " + java.text.DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime()));
int current = 0;
final String messagePrep = getResources().getString(R.string.progress_message_prep);
final String messageCompress = getResources().getString(R.string.progress_message_compress);
final String messageUpload = getResources().getString(R.string.progress_message_upload);
if(selected == null ){
selected = getContacts();
}
final int count = selected.size();
mHandler.post(new Runnable() {
#Override
public void run() {
if(mProgressDialog != null){
mProgressDialog.setMax(count);
mProgressDialog.setMessage(messagePrep);
}
}
});
updateProgress(current);
JSONObject root = new JSONObject();
JSONArray contactsArray = new JSONArray();
JSONObject contactJSON, phoneJSON, emailJSON;
JSONArray phonesArray,emailsArray;
String name, lastName, middleName,organization;
for (String key : selected) {
contactJSON = new JSONObject();
phonesArray = new JSONArray();
emailsArray = new JSONArray();
mSelectionArgs[0] = key;
//Cursor details = managedQuery(Data.CONTENT_URI, PROJECTION, SELECTION, mSelectionArgs, SORT_ORDER);
Cursor details = getApplicationContext().getContentResolver().query(Data.CONTENT_URI, PROJECTION, SELECTION, mSelectionArgs, SORT_ORDER);
//initialize null variables
name = null;
lastName = null;
middleName = null;
organization = null;
while(details.moveToNext()){
String mimeType = details.getString(MIME_TYPE_INDEX);
if(mimeType.equals(ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE)){
name = details.getString(GIVEN_NAME_INDEX);
lastName = details.getString(FAMILY_NAME_INDEX);
middleName = details.getString(MIDDLE_NAME_INDEX);
}
else if(mimeType.equals(ContactsContract.CommonDataKinds.Organization.CONTENT_ITEM_TYPE)){
organization = details.getString(ORGANIZATION_INDEX);
}
else if(mimeType.equals(ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE)){
phoneJSON = new JSONObject();
String phoneNumber = details.getString(PHONE_NUMBER_INDEX);
int type = details.getInt(PHONE_TYPE_INDEX);
String typeLabel = phoneTypeMap.get(String.valueOf(type));
if (typeLabel == null) {
typeLabel = details.getString(PHONE_LABEL_INDEX);
}
phoneJSON.put("ptype", typeLabel);
phoneJSON.put("number", phoneNumber);
phonesArray.put(phoneJSON);
}
else if(mimeType.equals(ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE)){
emailJSON = new JSONObject();
String email = details.getString(EMAIL_INDEX);
int type = details.getInt(EMAIL_TYPE_INDEX);
String typeLabel = emailTypeMap.get(String.valueOf(type));
if (typeLabel == null) {
typeLabel = details.getString(EMAIL_LABEL_INDEX);
}
emailJSON.put("etype", typeLabel);
emailJSON.put("address",email);
emailsArray.put(emailJSON);
}
}
contactJSON.put("firstname", name==null?"null":name);
contactJSON.put("middlename", middleName==null?"null":middleName);
contactJSON.put("lastname", lastName==null?"null":lastName);
contactJSON.put("organization", organization==null?"null":organization);
contactJSON.put("phones", phonesArray);
contactJSON.put("emails", emailsArray);
contactsArray.put(contactJSON);
details.close();
++current;
updateProgress(current);
}
root.put("contacts", contactsArray);
Log.d("SynchContactActivity", "Time 1: " + java.text.DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime()));
mHandler.post(new Runnable() {
#Override
public void run() {
if(mProgressDialog != null){
mProgressDialog.setMessage(messageCompress);
}
}
});
// to compress
String json_doc = root.toString();
byte[] compressed = compress(json_doc);
mHandler.post(new Runnable() {
#Override
public void run() {
if(mProgressDialog != null){
mProgressDialog.setMessage(messageUpload);
}
}
});
return compressed;
}
This code is too slow - that reads 3-4 contacts per second on average. Is this normal or can be optimized?
I think projection might be a good candidate to be optimized but I'm not sure.
Thanks in advance.
It's hard for me to tell exactly what you're trying to do, but it looks like you're trying to read data from the Contacts Provider and send it to a server using JSON. I suggest you look at the ContactsContract.RawContacts.Entity table, which contains all the data you're probably looking for without the mess of trying to figure out the MIME type of the DATA row you've just retrieved. You're certainly slowing down your app by getting the entire contents of the DATA row.
In addition, you should use a SyncAdapter to do this work. See Transferring Data Using Sync Adapters
Reading contacts can be made in 2-5 seconds. See the example app here
Source code attached

Bluetooth not sending file to other device

It is already asked but i didn't find any solution. For bluetooth application i am using the bluetoothShare.class .
My source code for sending the file to the target device
MainActvity.class:
Set<BluetoothDevice> devices = btAdapter
.getBondedDevices();
final String btDeviceName = selected_deviceName;
BluetoothDevice device = null;
for (BluetoothDevice itDevice : devices) {
if (btDeviceName.equals(itDevice.getName())) {
device = itDevice;
}
}
if (device != null) {
ContentValues values = new ContentValues();
values.put(BluetoothShare.URI, uri.toString());
values.put(BluetoothShare.MIMETYPE, "image/jpeg");
values.put(BluetoothShare.DESTINATION,
device.getAddress());
values.put(BluetoothShare.DIRECTION,
BluetoothShare.DIRECTION_OUTBOUND);
Long ts = System.currentTimeMillis();
values.put(BluetoothShare.TIMESTAMP, ts);
final Uri contentUri = getApplicationContext()
.getContentResolver().insert(
BluetoothShare.CONTENT_URI, values);
Log.v(TAG, "Insert contentUri: " + contentUri
+ " to device: " + device.getName());
Toast.makeText(getApplicationContext(), "Success",
Toast.LENGTH_LONG).show();
} else {
textStatus
.setText("Bluetooth remote device not found");
}
} else {
textStatus.setText("Bluetooth not activated");
}
}
else {
Toast.makeText(getApplicationContext(), "No devices found",
Toast.LENGTH_LONG).show();
}
and the blueToothShare.class:
package process.bluetooth.sendfile.opp;
import android.net.Uri;
import android.provider.BaseColumns;
public final class BluetoothShare implements BaseColumns {
private BluetoothShare() {
}
public static final String PERMISSION_ACCESS = "android.permission.ACCESS_BLUETOOTH_SHARE";
public static final Uri CONTENT_URI = Uri
.parse("content://com.android.bluetooth.opp/btopp");
public static final String TRANSFER_COMPLETED_ACTION = "android.btopp.intent.action.TRANSFER_COMPLETE";
public static final String INCOMING_FILE_CONFIRMATION_REQUEST_ACTION = "android.btopp.intent.action.INCOMING_FILE_NOTIFICATION";
public static final String USER_CONFIRMATION_TIMEOUT_ACTION = "android.btopp.intent.action.USER_CONFIRMATION_TIMEOUT";
public static final String URI = "uri";
public static final String FILENAME_HINT = "hint";
public static final String _DATA = "_data";
public static final String MIMETYPE = "mimetype";
public static final String DIRECTION = "direction";
public static final String DESTINATION = "destination";
public static final String VISIBILITY = "visibility";
public static final String USER_CONFIRMATION = "confirm";
public static final String STATUS = "status";
public static final String TOTAL_BYTES = "total_bytes";
public static final String CURRENT_BYTES = "current_bytes";
public static final String TIMESTAMP = "timestamp";
public static final int DIRECTION_OUTBOUND = 0;
public static final int DIRECTION_INBOUND = 1;
public static final int USER_CONFIRMATION_PENDING = 0;
public static final int USER_CONFIRMATION_CONFIRMED = 1;
public static final int USER_CONFIRMATION_AUTO_CONFIRMED = 2;
public static final int USER_CONFIRMATION_DENIED = 3;
public static final int USER_CONFIRMATION_TIMEOUT = 4;
public static final int VISIBILITY_VISIBLE = 0;
public static final int VISIBILITY_HIDDEN = 1;
public static boolean isStatusInformational(int status) {
return (status >= 100 && status < 200);
}
public static boolean isStatusSuspended(int status) {
return (status == STATUS_PENDING);
}
public static boolean isStatusSuccess(int status) {
return (status >= 200 && status < 300);
}
public static boolean isStatusError(int status) {
return (status >= 400 && status < 600);
}
public static boolean isStatusClientError(int status) {
return (status >= 400 && status < 500);
}
public static boolean isStatusServerError(int status) {
return (status >= 500 && status < 600);
}
public static boolean isStatusCompleted(int status) {
return (status >= 200 && status < 300)
|| (status >= 400 && status < 600);
}
public static final int STATUS_PENDING = 190;
public static final int STATUS_RUNNING = 192;
public static final int STATUS_SUCCESS = 200;
public static final int STATUS_BAD_REQUEST = 400;
public static final int STATUS_FORBIDDEN = 403;
public static final int STATUS_NOT_ACCEPTABLE = 406;
public static final int STATUS_LENGTH_REQUIRED = 411;
public static final int STATUS_PRECONDITION_FAILED = 412;
public static final int STATUS_CANCELED = 490;
public static final int STATUS_UNKNOWN_ERROR = 491;
public static final int STATUS_FILE_ERROR = 492;
public static final int STATUS_ERROR_NO_SDCARD = 493;
public static final int STATUS_ERROR_SDCARD_FULL = 494;
public static final int STATUS_UNHANDLED_OBEX_CODE = 495;
public static final int STATUS_OBEX_DATA_ERROR = 496;
public static final int STATUS_CONNECTION_ERROR = 497;
}
BluetoothShare class not supported android 4.1 and above. you can use the following intent coding to send file in android version 4.1 and above
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setComponent(new ComponentName(
"com.android.bluetooth",
"com.android.bluetooth.opp.BluetoothOppLauncherActivity"));
intent.setType("image/jpeg");
file = new File(filepath);
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
startActivity(intent);
and also some devices in Android v 2.2/2.3 not send the file via bluetoothShare class.
Maybe you can try another solution with BufferedWriter and BufferedReader.
Here is a snipped code:
BluetoothDevice mmDevice;
Set<BluetoothDevice> mBluetoothAdapter;
BluetoothAdapter bAdapter = BluetoothAdapter
.getDefaultAdapter();
mBluetoothAdapter = bAdapter.getBondedDevices();
for (BluetoothDevice bc : mBluetoothAdapter) {
if (bc.getName().indexOf("name_of_bluetoothdevide") != -1) {
UUID uuid = UUID
.fromString("00001101-0000-1000-8000-00805F9B34FB"); // Standard
// SerialPortService
// ID
mmDevice = bc;
BluetoothSocket mmSocket = mmDevice
.createInsecureRfcommSocketToServiceRecord(uuid);
bAdapter.cancelDiscovery();
mmSocket.connect();
BufferedWriter Writer = new BufferedWriter(
new OutputStreamWriter(
mmSocket.getOutputStream()));
Writer.write("Bluetooth connected!");
Writer.flush();
app.setmSocket(mmSocket);
break;
}
}
And for reading:
BufferedReader Reader = new BufferedReader(
new InputStreamReader(mmSocket.getInputStream()));
receivedMsg = Reader.readLine();
Hope it can help you.
This code works with firmware from MediaTek. Tested on Android 4.0.4. Sends the file, without asking anything from the user
public boolean SendFileViaBluetoothOPP(String file_path, String destinationMAC){
BluetoothAdapter btadapter = BluetoothAdapter.getDefaultAdapter();
if(btadapter == null)
return false;
BluetoothDevice btdev = btadapter.getRemoteDevice(destinationMAC);
if(btdev == null)
return false;
Uri uri = Uri.fromFile(new File(file_path));
Intent shareIntent = new Intent(Intent.ACTION_SEND)
.putExtra(Intent.EXTRA_STREAM, uri)
.setType("application/zip");
List<ResolveInfo> resolvedActivities = getPackageManager().queryIntentActivities(shareIntent, 0);
boolean found = false;
for(ResolveInfo actInfo: resolvedActivities){
if(actInfo.activityInfo.packageName.equals("com.mediatek.bluetooth"))
{
shareIntent.setComponent( new ComponentName(actInfo.activityInfo.packageName, actInfo.activityInfo.name ) );
shareIntent.putExtra("com.mediatek.bluetooth.sharegateway.extra.DEVICE_ADDRESS", btdev);
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
found = true;
break;
}
}
if(found){
startActivity(shareIntent);
return true;
}
return false;
}
On older phone from MediaTek with Android 2.2.1 this code launches BluetoothDevicePicker to complete the operation.
Maybe this could help you in some way…
private void sendData(String message) {
byte[] msgBuffer = message.getBytes();
Log.d(TAG, "...Sending data: " + message + "...");
try {
outStream.write(msgBuffer);
} catch (IOException e) {
String msg = "In onResume() and an exception occurred during write: " + e.getMessage();
if (address.equals("00:00:00:00:00:00"))
msg = msg + ".\n\nUpdate your server address from 00:00:00:00:00:00 to the correct address on java code";
msg = msg + ".\n\nCheck that the SPP UUID: " + MY_UUID.toString() + " exists on server.\n\n";
errorExit("Fatal Error", msg);
}
}

Checking miracast compatible devices using android app

How can I search for Miracast compatible devices (may be using WiFi Direct) in android?
I just got to know that DisplayManager and Presentation class in Android 4.2 help in presentation & miracast. But is there any way I can check if the other device is Miracast compatible / search Miracast sink?
Thanks
Smitha
android framework source codes shows how to search miracast sink devices.
basically using WiFi Direct devices search API,
discoverPeers -> requestPeers -> isWifiDisplay & isPrimarySinkDeviceType
private static boolean isWifiDisplay(WifiP2pDevice device) {
return device.wfdInfo != null
&& device.wfdInfo.isWfdEnabled()
&& isPrimarySinkDeviceType(device.wfdInfo.getDeviceType());
}
private static boolean isPrimarySinkDeviceType(int deviceType) {
return deviceType == WifiP2pWfdInfo.PRIMARY_SINK
|| deviceType == WifiP2pWfdInfo.SOURCE_OR_PRIMARY_SINK;
}
https://github.com/kensuke/How-to-Miracast-on-AOSP/wiki/wfd_scan
WifiP2pWfdInfo defined four device types,
public static final int WFD_SOURCE = 0;
public static final int PRIMARY_SINK = 1;
public static final int SECONDARY_SINK = 2;
public static final int SOURCE_OR_PRIMARY_SINK = 3;
http s://android.googlesource.com/platform/frameworks/base/+/master/wifi/java/android/net/wifi/p2p/WifiP2pWfdInfo.java
if you don't familiar with wifi direct, maybe my app is useful for using wifi direct api.
http s://github.com/kensuke/WiFiDirectTestApp
ADD: 2014/02/24 - parse toString output String for recognize Miracast devices Source or Sink
Wi-Fi Direct API requestPeers() callback to onPeersAvailable(), this method's parameter WifiP2pDeviceList has near by P2p devices that is a list of WifiP2pDevice instances, WifiP2pDevice has one device Wi-fi Direct information including Miracast information(wfd..) and device into can get uses WifiP2pDevice.toString() method.
Search "WFD DeviceInfo: XXX" String, XXX is a numerical value, masked "0x03" (see WifiP2pWfdInfo.java), after masked we get 0-3. That value defined SOURCE or SINK, see WifiP2pWfdInfo.java constants).
private static final int WFD_SOURCE = 0;
private static final int PRIMARY_SINK = 1;
private static final int SECONDARY_SINK = 2;
private static final int SOURCE_OR_PRIMARY_SINK = 3;
This very duty way can using on non rooted device, general app.
Sample of WifiP2pDevice.toString() returned value
"Device: ZTS1145
deviceAddress: 7a:e8:b6:f6:4d:74
primary type: 10-0050F204-5
secondary type: null
wps: 392
grpcapab: 0
devcapab: 33
status: 3
wfdInfo: WFD enabled: trueWFD DeviceInfo: 273
WFD CtrlPort: 7236
WFD MaxThroughput: 10"
// callback method of requestPeers();
public void onPeersAvailable(WifiP2pDeviceList peers) {
List<WifiP2pDevice> devs = new ArrayList<WifiP2pDevice>(peers.getDeviceList());
for (int i = 0; i < devs.size(); i++) {
WifiP2pDevice dev = devs.get(i);
boolean src = isWifiDisplaySource(dev);
boolean sink = isWifiDisplaySink(dev);
Log.d(TAG, dev.deviceName + " isSource[" + src + "] isSink[" + sink + "]");
}
}
private static final int WFD_DISABLED = -1;
private static final int WFD_SOURCE = 0;
private static final int PRIMARY_SINK = 1;
private static final int SECONDARY_SINK = 2;
private static final int SOURCE_OR_PRIMARY_SINK = 3;
private static final int DEVICE_TYPE = 0x3;
private int getWFDDeviceInfoFromString(String devStr) {
if (devStr == null) {
return WFD_DISABLED;
}
boolean wfd = false;
for (String line : devStr.split("\n")) {
// start self parsing...
// TODO: sprintf parse is more easy
// search "WFD enabled: [true|false]"
if (!line.matches(".*WFD enabled:.*")) {
continue;
}
String[] tokens = line.split(":");
int toks = tokens.length;
for (int i = 0; i < toks - 1; i++) {
if (!tokens[i].contains("WFD enabled")) {
continue;
}
String tok = tokens[i + 1].replaceAll("\\s", ""); // delete white space
if (tok.startsWith("true")) {
wfd = true;
break;
}
// why didn't use .equals() instead of .contains() and .startsWith() ? because
// 1) "wfdInfo: WFD enabled: trueWFD DeviceInfo: 273" // inputed string
// 2) "(wfdInfo):( WFD enabled):( trueWFD DeviceInfo):( 273)" // : splited string
// 3) "( trueWFD DeviceInfo)" => "trueWFD DeviceInfo" // white space deleted
}
}
if (!wfd) {
return WFD_DISABLED;
}
for (String line : devStr.split("\n")) {
// search "WFD DeviceInfo: \d+"
if (!line.matches(".*WFD DeviceInfo:.*")) {
continue;
}
String[] tokens = line.split(":");
int toks = tokens.length;
for (int i = 0; i < toks - 1; i++) {
if (!tokens[i].contains("WFD DeviceInfo")) {
continue;
}
String tok = tokens[i + 1].replaceAll("\\s", "");
int deviceInfo = Integer.parseInt(tok);
Log.d(TAG, "line[" + line + "] DeviceInfo[" + deviceInfo + "] masked[" + (deviceInfo & DEVICE_TYPE) + "]");
return deviceInfo;
}
}
return WFD_DISABLED;
}
private boolean isWifiDisplaySource(WifiP2pDevice dev) {
if (dev == null) {
return false;
}
int deviceInfo = getWFDDeviceInfoFromString(dev.toString());
if (deviceInfo == WFD_DISABLED) {
return false;
}
int deviceType = deviceInfo & DEVICE_TYPE; // masked
return deviceType == WFD_SOURCE || deviceType == SOURCE_OR_PRIMARY_SINK;
}
private boolean isWifiDisplaySink(WifiP2pDevice dev) {
if (dev == null) {
return false;
}
int deviceInfo = getWFDDeviceInfoFromString(dev.toString());
if (deviceInfo == WFD_DISABLED) {
return false;
}
int deviceType = deviceInfo & DEVICE_TYPE; // masked
return deviceType == PRIMARY_SINK || deviceType == SOURCE_OR_PRIMARY_SINK;
}

Categories

Resources