Fixed
Status Update
Comments
me...@thomaskeller.biz <me...@thomaskeller.biz> #2
I've found this code fragment in the newest API 23 SDK's source code
WifiServiceImpl.java Line964
if (!canReadPeerMacAddresses && !isActiveNetworkScorer && !isLocationEnabled()) {
return new ArrayList<ScanResult>();
}
It could explain this issue.The method "isLocationEnabled" read Location settings then returns false at this condition, and getScanResults returns null.
WifiServiceImpl.java Line964
if (!canReadPeerMacAddresses && !isActiveNetworkScorer && !isLocationEnabled()) {
return new ArrayList<ScanResult>();
}
It could explain this issue.The method "isLocationEnabled" read Location settings then returns false at this condition, and getScanResults returns null.
bl...@gmail.com <bl...@gmail.com> #3
Thank you for your comment.
getScanResults() returns current results on Lollipop and older even if GPS is disabled.
Scan results should have no relation to GPS.
getScanResults() returns current results on Lollipop and older even if GPS is disabled.
Scan results should have no relation to GPS.
ne...@gmail.com <ne...@gmail.com> #4
I had confirmed the same with Nexus 5 Preview 3 (build num.: MPA44G).
[Deleted User] <[Deleted User]> #5
This is affecting App which need scanned wifi networks but not necessarily want GPS enabled. And by enabling GPS it is gonna drain the battery faster. Which may result in inefficient user experience..
Why location service is mandated now. Is google collecting geo location along with wifi networks for other project?
Why location service is mandated now. Is google collecting geo location along with wifi networks for other project?
sl...@google.com <sl...@google.com>
ka...@gmail.com <ka...@gmail.com> #6
I also asked this problem on M-preview issue tracker.
On MRA58K, we still have to enable GPS to get ScanResults.
https://code.google.com/p/android-developer-preview/issues/detail?id=3163
For typical android users, it is may be quite difficult to find relation between Wi-Fi scanning and location settings.
ScanResults should be available if location permission is granted.
On MRA58K, we still have to enable GPS to get ScanResults.
For typical android users, it is may be quite difficult to find relation between Wi-Fi scanning and location settings.
ScanResults should be available if location permission is granted.
sl...@google.com <sl...@google.com> #7
Thanks for the suggestion. Our development team has looked into this bug and decided that it is working as per the design.
WifiManager#getScanResults() returns an empty list if location is turned off for the device.
WifiManager#getScanResults() returns an empty list if location is turned off for the device.
Description
Devices/Android versions reproduced on: any
I use the IntentsTestRule in my JUnit test to start my activity and capture intents that it issues. If the activity fails to launch for any reason, "Intents.release()" is called. In this method, "defaultInstance.internalRelease()" is called uncondtionally, i.e. also when "defaultInstance" is still null, which leads to an NPE.
Full stack trace:
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.test.espresso.intent.Intents.internalRelease()' on a null object reference
at android.support.test.espresso.intent.Intents.release(Intents.java:140)
at android.support.test.espresso.intent.rule.IntentsTestRule.afterActivityFinished(IntentsTestRule.java:68)
at android.support.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:260)
at my.package.MockServerRule$1.evaluate(MockServerRule.java:29)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:54)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:240)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1976)
Source code of MockServerRule:
public class MockServerRule implements TestRule {
@Override
public Statement apply(final Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
startServer();
try {
base.evaluate();
} finally {
stopServer();
}
}
};
}
...
}
My test class:
@RunWith(AndroidJUnit4.class)
public class LoginActivityTest {
@Rule
public final IntentsTestRule<LoginActivitySingle> mActivityTestRule = new IntentsTestRule<>(LoginActivitySingle.class, true, false);
@Rule
public final MockServerRule mMockServerRule = new MockServerRule();
@Test
public void someTest() {
Activity activity = mActivityTestRule.getActivity();
...
}
}