title: How do Android check permission?
body: <p>Im trying Android CTS.
  I facing problem during android.permission.</p>
  
  <pre><code>02-05 15:57:27 I/192.168.90.48:5555:         
  android.permission.cts.NoNetworkStatePermissionTest#testSecurityExceptionFromDns FAIL 
  junit.framework.AssertionFailedError
  at android.permission.cts.NoNetworkStatePermissionTest.testSecurityExceptionFromDns
  (NoNetworkStatePermissionTest.java:174)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:190)
  at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:175)
  at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
  at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1661)
  </code></pre>
  
  <p>In my guess, this test check permission. Program tries like below:</p>
  
  <pre><code>public void testSecurityExceptionFromDns() throws Exception {
      try {
          InetAddress.getByName("www.google.com");
          fail();
      } catch (SecurityException expected) {
      }   
  }   
  </code></pre>
  
  <p>expected behavior is that program throws Security-exception because this Application have not
  <code>android.permission.INTERNET</code> </p>
  
  <p>but it can get InetAdress even though it has no permission.</p>
  
  <p>How can I fix this situation? </p>
  
  <p>I already check permissions such as /dev/socket</p>
  
  <p>Can somebody tell me what is happening ?</p>
  
  <p>Thanks.</p>