English 中文(简体)
给予申请根本特权
原标题:Grant the root privilege to the application

I have an application which consists of the native part and higher layer.

Therefore, it needs to be granted the root privilege to run some native functions.

As the article I post before, I added a piece of code taken from Bluez Utils(hidd.c).

if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
    close(sk);
    return -1;
   }

该法典是由国家科索沃统计局制定的。

Unfortunately, It keeps returning -1 and errno is 13 which means Permission Denied.

Some experienced developers(Thank you here) mentioned about that the error happens because this application doesnt have enough permission.

“SHOULD NOT”就是这样的东西。

工艺过程 = 运行时间。

I think this means you possess a system permission but your application doesnt. (Let me know if I am wrong)

是否有办法给予谁以根本特权?

Any reply/clue/hint will be highly appreciated.

关于

Sam

最佳回答

我认为,我可以帮助你这样做。

这里,我们 go......

void gainRoot()
{
    Process chperm;
    try {
        chperm=Runtime.getRuntime().exec("su");
          DataOutputStream os = 
              new DataOutputStream(chperm.getOutputStream());
            os.writeBytes("chmod 777 /dev/video0
");
            os.flush();

            os.writeBytes("exit
");
            os.flush();

            chperm.waitFor();

    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

这是一项职能,通常用于改变对基本档案的许可。

当你起诉时,将产生一个具有根本特权的新进程。 因此,利用这一进程,你可以开展任何根本行动。 有一些具体的分类需要遵循。 以上的例子就说明了这一点。

你可以做的一件事情是,将《刑法》的约束部分作为单独的可执行部分,并将其置于系统/宾内,或放在通常可起诉的地点。 保留可执行的名称是123,而不是123

            os.writeBytes("chmod 777 /dev/video0
");
            os.flush();

改为

            os.writeBytes("bind123
");
            os.flush();

上述法典。

这应当行之有效。 或许一旦这项工作完成,我们便可尝试将其与申请结合起来,而不依赖可起诉者。 我希望我不会混淆你。 如果完全需要澄清,请让我知道......。

问题回答

You don t need root to bind to port >=1024. You only need INTERNET permission in your ApplicationManifest.xml file.





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签