Android O issues with WiFi Peer Discovery - android-wifi

I am developing an Android Application that employs WiFi (Direct) for service discovery and P2P peer discovery/connection.
My development enviromment is as follows:-
Android Studio 3.0 Beta 4
Build #AI-171.4304935, built on August 29, 2017
JRE: 1.8.0_152-release-915-b01 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.11.6
My Gradle build:-
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.research.wifi_direct"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
buildTypes {
debug {
buildConfigField "String", "INSTANCE_NAME", "\"_vascodagama\""
buildConfigField "String", "SERVICE_TYPE", "\"_presence._tcp\""
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.0.2'
implementation 'com.android.support:recyclerview-v7:26.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.yarolegovich:lovely-dialog:1.0.7'
implementation 'io.realm:android-adapters:2.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', {
exclude group: 'com.android.support', module: 'support-annotations'
})
}
The devices I am testing on include:-
Nexus 7 - Android 6.0.1
Nexus 9 - Android 7.1.1
Samsung Tablet - Android 4.4.1
Pixel - Android 8.0.0
The service discovery works fine on all four devices.
However the P2P Peers List is always empty on the Pixel XL running Android 8.0.0.
The other three devices consistently discover each other as well as other miscellaneous devices
around my office e.g. such as a Samsung TV and my colleagues personal phones etc..
The only thing I can think of is that theres something about Android O that inhibits P2P peers being discovered.
I cannot see anything in the "Whats New In Android O" to identify the culprit
Has anyone seen this behaviour on Android O? What am I doing wrong? What am I missing?
The code I am basing my application on is to be found here
https://developer.android.com/training/connect-devices-wirelessly/wifi-direct.html
https://developer.android.com/training/connect-devices-wirelessly/nsd-wifi-direct.html
Something odd that I noticed was that when I tried to keep the WiFi "stack" awake using an android.net.wifi.WifiManager.WifiLock
my application stopped working altogether. Further more I had to power off all my devices and restart them once I had removed the
associated WiFiLock code. And yes... I did add uses-permission android:name="android.permission.WAKE_LOCK".
UPDATE - 0001
Whats odd is that when I log out the extras available in my Broadcast Receiver for PEER_CHANGED I can see the available peers listed as shown here when the Android O Pixel XL has discovered my Nexus
WiFiDirectBroadcastRcvr: android.net.wifi.p2p.PEERS_CHANGED<<<<<EXTRA DATA :: ------------------------START
WiFiDirectBroadcastRcvr: EXTRA DATA :: wifiP2pDeviceList
Device: Nexus 7
deviceAddress: da:50:e6:7c:56:4e
primary type: 000A0050F2040005
secondary type: null
wps: 392
grpcapab: 0
devcapab: 37
status: 3
wfdInfo: WFD enabled: trueWFD DeviceInfo: 0
WFD CtrlPort: 0
WFD MaxThroughput: 0 (android.net.wifi.p2p.WifiP2pDeviceList)
WiFiDirectBroadcastRcvr: EXTRA DATA :: ------------------------FINISH
However when I then make my subsequent call to requestPeers I always receive an empty WifiP2pDeviceList?
case WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION:
Log.d(TAG, "onReceive: WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION");
mWiFiPeer2PeerCommander.requestPeers(mWifiP2pManager, mWifiP2pManagerChannel);
break;
Am I supposed to use the WifiP2pDeviceList from the passed Extra an not bother to call requestPeers?

I had the same problem. On my nexus 5x now also Android O.
And I also always got an empty WifiP2pDeviceList.
I think it's assign (?) with similar problem on Android 6
SCAN_RESULTS_AVAILABLE_ACTION return empty list in Android 6.0
It works for me...

Set the targetSdkVersion <= 25 can solve this issue,but I don't know why.

I faced the similar issue. I fixed it by adding
Step 1 : Add Location permission in manifest.
Step 2: Request permission dynamically in your activity.
Step 3: Now scan for WIFI peers. It will appear.
Kudos!!!

Related

How does Chrome support webgl on macOS?

I found libGLESv2.dylib libswiftshader_libGLESv2.dylib libvk_swiftshader.dylib in Chrome.app. And in https://webglreport.com/?v=2 it says:
Vendor: WebKit
Renderer: WebKit WebGL
Unmasked Vendor: ATI Technologies Inc.
Unmasked Renderer: AMD Radeon Pro 560X OpenGL Engine
Antialiasing: Available
ANGLE: No
I heard that chrome uses angle on windows. Here angle is not used on macOS. So how does chrome run webgl?
There is no way to detect ANGLE. WebGLReport guesses and its guess are wrong. Here is their code
function getAngle(gl) {
var lineWidthRange = describeRange(gl.getParameter(gl.ALIASED_LINE_WIDTH_RANGE));
// Heuristic: ANGLE is only on Windows, not in IE, and not in Edge, and does not implement line width greater than one.
var angle = ((navigator.platform === 'Win32') || (navigator.platform === 'Win64')) &&
(gl.getParameter(gl.RENDERER) !== 'Internet Explorer') &&
(gl.getParameter(gl.RENDERER) !== 'Microsoft Edge') &&
(lineWidthRange === describeRange([1, 1]));
if (angle) {
// Heuristic: D3D11 backend does not appear to reserve uniforms like the D3D9 backend, e.g.,
// D3D11 may have 1024 uniforms per stage, but D3D9 has 254 and 221.
//
// We could also test for WEBGL_draw_buffers, but many systems do not have it yet
// due to driver bugs, etc.
if (isPowerOfTwo(gl.getParameter(gl.MAX_VERTEX_UNIFORM_VECTORS)) && isPowerOfTwo(gl.getParameter(gl.MAX_FRAGMENT_UNIFORM_VECTORS))) {
return 'Yes, D3D11';
} else {
return 'Yes, D3D9';
}
}
return 'No';
}
It's wrong and years out of date.
The first guess is looking at lineWidthRange which even when they wrote it was only a guess. The spec says it is valid to have only lines of width 1. Back when WebGL shipped it was common that ANGLE supported just lines of size 1 and OpenGL supported others. But, that changed when WebGL2 shipped because WebGL2, when running on top of desktop OpenGL, required using the "Core" profile and the "Core" profile disallows lines other than size 1 period.
From the spec
E.2.1 Deprecated But Still Supported Features
The following features are deprecated, but still present in the core profile. They
may be removed from a future version of OpenGL, and are removed in a forwardcompatible context implementing the core profile.
Wide lines - LineWidth values greater than 1.0 will generate an INVALID_VALUE error
Their second guess is looking at the browser. That's obviously no longer valid. Edge is now based on Chromium and further Safari now uses ANGLE as well.
The last one is one more guess that ANGLE is being used because it assumes ANGLE is running on top of D3D and that certain limits were therefore special but ANGLE is now used on all platforms and can run on top of Desktop OpenGL, D3D, OpenGL ES, Metal, and Vulkan. From the chart on the angle project as of January 2021
Level of OpenGL ES support via backing renderers
Direct3D 9
Direct3D 11
Desktop GL
GL ES
Vulkan
Metal
OpenGL ES 2.0
complete
complete
complete
complete
complete
complete
OpenGL ES 3.0
complete
complete
complete
complete
in progress
OpenGL ES 3.1
incomplete
complete
complete
complete
OpenGL ES 3.2
in progress
in progress
in progress
And here is the list of platforms ANGLE currently supports
Platform support via backing renderers
Direct3D 9
Direct3D 11
Desktop GL
GL ES
Vulkan
Metal
Windows
complete
complete
complete
complete
complete
Linux
complete
complete
Mac OS X
complete
in progress
iOS
planned
Chrome OS
complete
planned
Android
complete
complete
GGP (Stadia)
complete
Fuchsia
in progress
So, you shouldn't believe WebGLReport. Maybe you should go file a bug.
Chrome is able to use desktop OpenGL on MacOS to run WebGL but AFAIK ANGLE is used on all Chrome platforms at this point in time including MacOS. ANGLE was even added to Safari recently to enable Safari's WebGL2 support and to fix a bunch of bugs with their WebGL1 support

Flutter - dart.ui no method 'platformViewRegistry'

Im working on Flutter web and I want to render an html code. Since flutter_webview_plugin doesnt support flutter web yet Im using IFrameElement and HtmlElementView. But I have this problem when using dart.ui, platformViewRegistry method isn't defined.
Error message:
The name 'platformViewRegistry' is being referenced through the prefix 'ui', but it isn't defined in any of the libraries imported using that prefix.
import 'dart:ui' as ui;
......
ui.platformViewRegistry.registerViewFactory(
createdViewId,
(int viewId) => html.IFrameElement()
..width = MediaQuery.of(context).size.width.toString() //'800'
..height = MediaQuery.of(context).size.height.toString() //'400'
..srcdoc = """<!DOCTYPE html><html>
<head><title>Page Title</title></head><body><h1>This is a Heading</h1><p>This is a paragraph.</p></body></html>"""
..style.border = 'none');
Example Code From: https://stackoverflow.com/a/60089273/12789200
I read some solution to solve this problem. But I don't want to downgrade my flutter version. Since in the past month Flutter has a lot of changes
Flutter Doctor
[√] Flutter (Channel beta, 1.22.1, on Microsoft Windows [Version 10.0.19041.508], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[√] Chrome - develop for the web
[√] Android Studio (version 4.0)
[√] VS Code (version 1.49.3)
[√] Connected device (3 available)
Is there any other solution for this problem? Or another example I can used for WebView on Flutter Web.
Up to my knowledge I have tried several solutions and apparently there is a problem in the 'dart:ui' package .
The solutions I've tried are:
Tried using a WebView widget //Failed No web support yet
Tried rendering on HTML instead of CanvasKit //UI will look rubbish
Tried editing on the **analysis_options.yaml**
Tried adding a comment above the code that said //ignore: undefined_prefixed_name
All these solutions referred to other errors, the solution was to use a package called:
universal_ui from the https://pub.dev/packages/universal_ui , which is apparently the same as 'dart:ui' package, but with all methods included.
Hope this works for you !

Codename One Windows Phone Build Fail

I'm experiencing problems while building my Codename One project for Windows Phone.
I've had 3 attempts: 2 failed and 1 was stuck on a build phase for more than an hour and I decided to cancel it.
I've downloaded error logs for both failed attempts (files were more than 60M and I've noticed it too late, so sorry for using your server's bandwidth). Here is the extract (files sizes are more than 60M) from the last error log (2f361a99-589d-4e29-9e6d-14d22b1cacc3-1453240937030-error.txt/Tue Jan 19 2016 23:46:42 GMT+0200 (FLE Standard Time)):
Executing: java -Xmx1024m -jar win_xmlvm.jar --in=C:\Users\Shai\AppData\Local\Temp\build6825805865501307423xxx\classes --resource=C:\Users\Shai\AppData\Local\Temp\build6825805865501307423xxx\ApplicationCN1\ApplicationCN1\res/ --out=C:\Users\Shai\AppData\Local\Temp\build6825805865501307423xxx\ApplicationCN1\ApplicationCN1\src --target=csharp --app-name=ApplicationCN1 [01/19/16 23:47:19.038] ERROR: Couldn't create node for com.codename1.impl.ImplementationFactory
[01/19/16 23:47:19.038] ERROR: Couldn't create node for com.codename1.impl.ImplementationFactory
...classes...
...lots of warnings about hidden inherited members...
"C:\Users\Shai\AppData\Local\Temp\build6825805865501307423xxx\ApplicationCN1\ApplicationCN1.sln" (default target) (1) ->
"C:\Users\Shai\AppData\Local\Temp\build6825805865501307423xxx\ApplicationCN1\ApplicationCN1\ApplicationCN1.csproj" (default target) (2) ->
(CoreCompile target) ->
src\com\yyy\yyy\DialogForm.cs(1133,5): error CS1511: Keyword 'base' is not available in a static method [C:\Users\Shai\AppData\Local\Temp\build6825805865501307423xxx\ApplicationCN1\ApplicationCN1\ApplicationCN1.csproj]
130875 Warning(s)
1 Error(s)
Time Elapsed 00:07:44.77
My configuration:
Windows 7 SP1 x64;
Java SE Development Kit 7 Update 45 (64-bit);
Eclipse IDE for Java Developers, Version: Luna Service Release 2 (4.4.2), Build id: 20150219-0600;
Plugin: CodenameOneFeature 1.0.0.201511241324;
Contents of my codenameone_settings.properties:
#
#Mon Jan 18 16:05:13 EET 2016
codename1.vendor=yyy
codename1.displayName=yyy
codename1.icon=icon.png
codename1.languageLevel=5
codename1.secondaryTitle=yyy
codename1.version=0.4
codename1.mainName=ApplicationCN1
codename1.ios.certificatePassword=
codename1.rim.signtoolDb=
libVersion=97
codename1.ios.certificate=
codename1.arg.j2me.nativeThemeConst=3
codename1.arg.ios.add_libs=CFNetwork.framework
codename1.arg.android.debug=false
codename1.arg.android.release=true
codename1.j2me.nativeTheme=
codename1.rim.signtoolCsk=
codename1.rim.certificatePassword=
codename1.ios.provision=
codename1.packageName=com.yyy.yyy
What am I doing wrong?
You probably have a field or method named base and our old XMLVM based backend isn't smart enough to deal with that (reserved word in C#).
Just rename that for now and also look at the project size.
We are currently working on a rewrite of the Windows Phone VM/port so this and many other issues won't exist when we are done. Since its almost a complete rewrite (we will probably base it in part on the community port) this might take a while to deliver.

iOS 8 - Starling context loss on open camera roll gallery

I am creating an app on iOS in Flash Builder, with as3.
The app uses the Starling plugin: http://wiki.starling-framework.org/start
My app allows users to take photos and customise them. When attempting to access the camera or camera roll on iOS 8, I get the error message "The application lost the device context!".
On Android, I can get around this problem with this line:
Starling.handleLostContext = true;
But I am told that iOS should never lose context (and I haven't seen it lose context on iOS 7 or below).
If I include that line in iOS 8, the application crashes at around the same point, but in this case the app crashes completely, and returns me to the home screen rather than displaying the previous message.
I have heard there are restrictions on iOS 8 with regards to the use of 64 bit/32 bit plugins and extensions, but I am not using any ANEs in this particular app. Are there any other areas where 32-bit could be causing problems or is that strictly related to ANEs?
I don't get this error on iOS 7 or below or Android, unless I set handleLostContext to false.
Adobe Scout provides no error message.
Any help would be appreciated.
UPDATE:
This code calls in the camera functionality:
var cameraRoll:CameraRoll = new CameraRoll();
if(CameraRoll.supportsBrowseForImage) {
trace("camera rolling");
cameraRoll.addEventListener(MediaEvent.SELECT, imageSelected);
cameraRoll.addEventListener(flash.events.Event.CANCEL, browseCanceled);
cameraRoll.addEventListener(flash.events.ErrorEvent.ERROR, galleryMediaError);
cameraRoll.browseForImage();
} else {
var alert:Alert = Alert.show("Image browsing is not supported on this device.", "Error", new ListCollection([{label:"OK"}]));
}
UPDATE 2:
I've switched from AIR SDK 17 to 16, and it is now more stable but has similar issues
There is a known issue with the camera roll in iOS which will cause stage3d to lose context. Your options:
Set Starling.handleLostContext = true, it is possible to lose context in iOS.
Find an ANE (Supposedly these exist) that handles the camera roll without losing context.
More Information:
http://forum.starling-framework.org/topic/starling-and-cameraui#post-77339
I can confirm on ios 8.3 a Context3D is not lost when opening the CameraRoll using AIR 18.
Make sure you are using AIR 18.
Make sure you are using the latest Starling Version.
If the problem persist it's likely Starling is the cause.
Either report the problem and wait for an update.
Do not use Starling when requesting the CameraRoll (turn Starling off and Display normal Bitmaps).
Don't use Starling and use another engine or create your own.

Is Worklight App based on Dojo toolkit 1.9 supported in Windows phone 8?

I am working on a worklight App using it's default 1.9 Dojo Toolkit. My App is working fine in Android emulator and in the web browser simulator. I tried to test the same app in Windows phone 8 Emulator but I am not able to see the whole Home page. I can see only Tabbar Button part used at the button while I am not able to see the list items used in the page. My Question is does Dojo Toolkit 1.9 supports Windows Phone 8?
I have visited dojo 1.9 release link and It says that in dojo 1.9, support for Windows Phone 8 has been included. If this is true, What could be the reason of failure for my app in Windows phone 8 emulator?
I also got below log when I created Windows phone 8 environment in my Worklight Project.
[2013-11-12 22:14:08] Environment 'Windows Phone 8' was created.
[2013-11-12 22:14:13] Starting build process: application 'KaiserTestApp', environment 'windowsphone8'
[2013-11-12 22:14:28] Windows Phone 8 app may not work well with Dojo toolkit included for this Application. Use a different Worklight Project, without Dojo toolkit, for Windows Phone 8 apps.
[2013-11-12 22:14:28] Application 'KaiserTestApp' with environment 'windowsphone8' build finished.
There is a WP8 VM bug that might hurt ListItem and might explain your issue. To check if that you are falling into this just monkey patch the _ItemBase _setSelectedAttr method this way and see if that fixes your issue:
_setSelectedAttr: function(/*Boolean*/selected){
// summary:
// Makes this widget in the selected or unselected state.
// description:
// Subclass should override.
// tags:
// private
if(selected){
var p = this.getParent();
if(p && p.selectOne){
// deselect the currently selected item
var arr = array.filter(p.getChildren(), function(w){
return w.selected;
});
array.forEach(arr, function(c){
this._prevSel = c;
c.set("selected", false);
}, this);
}
}
this.selected = selected;
//this._set("selected", selected);
}
If that is fixing your issue let us know and we will see how to release an updated version of Dojo that workarounds that WP8 WM bug.