I have an application that is installed on the STB prefix.

I'm trying in this application with the command: Process pr = Runtime.getRuntime ().exec ("cat /sys/class/net/eth0/address"); get mac address, but this string returns null .

At the same time, if you enter the adb shell "cat /sys/class/net/eth0/address" command adb shell "cat /sys/class/net/eth0/address" through the terminal, then in response, I get a full-fledged mac address.

Permissions of the file -r - r - r--, i.e. absolutely all users can read it.

Please tell me how is this possible?

  • probably because the user on whose behalf your program runs is slightly less privileged than the shell user on whose behalf the commands executed as the adb shell команда are executed on the device. - aleksandr barakin
  • @aleksandrbarakin, yes, I also think about it, but I can’t be 100% sure of it, because there is another STB prefix (another manufacturer, but identical to Android), there the poppy is displayed normally. And the capabilities of users seem to be the same. Maybe you can somehow add the file permissions for everyone to have them? The file itself also has the following permissions: -r - r - r--, i.e. absolutely everyone can read it, but it cannot be read - Dmitry Chubarov
  • Not only the rights to the file are important, but also the rights to all the parent directories (however, on my personal android, the directories have all the necessary rights) - andreymal 4:34 pm
  • goolge: Programmatically getting the MAC of an Android device . not for nothing that the authors of api overlaid this procedure with such difficulties. somewhere a direct appeal to the pseudo-file system sysfs may even “work”, but relying on the presence of such a “hole” in a randomly taken device is hardly justified. - aleksandr barakin
  • @andreymal, yes, I provided it, there is access to all the directories in which this file is located - Dmitry Chubarov

1 answer 1

This console for third-party applications denied access to sysfs. To get the poppy address, I had to take it from the property with the help of ro.boot.ethaddr