How do I get root access in Android while building from source? - android

I have built an Android version for Intel x86_64 from the Intel Celadon source code. The generated Android image is running on my machine. However, I do not have root access in the Terminal app in the Android device. I don't want the adb shell. I need the root access (sudo) in the Android Terminal app. How can I get that?
In previous Android builds, it was done by changing the init.rc as described in this StackOverflow link. However, this process does not work anymore because of SELinux update in Android. My guess is that there is some capability specification added. Can anybody give any clue on how to build Android from source to give root or sudo access in a Terminal app?

Related

Is there a way to execute adb commands programatically in C++? This C++ part of code is built using ndk build in android studio. There

I referred to this link - Use CreateProcess to execute ADB command. The approach used in the above link requires Windows.h file which is contained in windows SDk. Since i am executing Android Studio in Mac i will not be able to get the include file. I am not sure whether the above mentioned approach can be performed using Android Studio in Mac.
You can use system or popen methods to start an adb process.

Check android runtime

Since it's now possible to execute an apk file on windows mobile, is there any way to check if the environment is emulated on windows or not? I want to be aware if the app is executed on windows platform.
Users cannot run arbitrary APKs on Windows. As a developer you will choose to package and publish your APK for Windows. It can call Windows Runtime API or compile in custom checks as needed.
For more information check out the Build session “PROJECT ASTORIA“: Build Great Windows Apps with Your Android Code. You can sign up for the for the Windows Bridge for Android (fka Project Astoria) developer preview at https://dev.windows.com/en-us/uwp-bridges/android
I found the way. You just need to read file /proc/cmdline and look for the hyperv string.

Run NodeJs server in Android

Is it possible to run NodeJs server in android device (like linux devices not android apps).
If possible please help me to do it.
And is it possible to start mongo server on Android device?
My devices:
RK3288 TV Box (android 4)
Asus fonepad 7 (android 5 root)
LG Optimus G (android 4 root)
Important!! I want to start a server app in android. because I have an unused android TV-Box and I want to use it in my home server
And I don't want to use it in APK files (to load html files in WebView s). I need nodejs server not javascript client with CommonJs and RequireJs
You might want to install a chrooted-linux on your android-device, as explained here.
In short, do this:
prepare linux-image
do this on any gnu+linux -device.
create a big file (>1 GB)
format it as a filesystem (eg. ext2)
mount it.
copy a distribution inside of it (e.g. with debootstrap)
copy loopdevice to android
mount it (root required)
maybe install busybox
attach some directories from the root-device to the host (usually dev, dev/pts, proc and sys )
chroot
install nodejs inside chroot
note: I have done something similar to my tf301 and it works like a charm. But when I start to use too much memory inside the chroot (e.g. when compiling an android-app), the host will crash. I have not yet experienced those crashes with node and I do not know, if other devices are affected by this.
Install jxcore, as explained here:
Express on Android
The script assumes that Apache Cordova and the Android SDK is installed on your system. If they are not, please refer to individual documentation on how to do this.
Plug an android device into a USB socket (with USB Debugging enabled), unless you want to run the application on the Android Emulator.
Download the script and save it into an empty folder. Run it with a sample folder name as an argument, for example “express sample”:
$ ./install_and_run.sh "express sample"
The Script can be found here.
J2V8 is best solution of your problem. It's run Nodejs application on jvm(java and android).
J2V8 is Java Bindings for V8, But Node.js integration is available in J2V8 (version 4.4.0)
Github : https://github.com/eclipsesource/J2V8
Example : http://eclipsesource.com/blogs/2016/07/20/running-node-js-on-the-jvm/

Node.js On Non-Root Android

As the question title states, can I install node.js on Android without root? I have a couple terminal emulator apps and at least one of them has BusyBox, git, and adp, among other things, though I am severely limited in what I can do with them. For example, I can not just git clone the node.js source code, as "No auth methods c[an] be used". I can download the node.js source code, but it seems to be under the "system_server" user as soon as it's downloaded, which I assume is the root user or very close. I am able to unpack it, but unable to run the configure executable in this directory, I assume because it is owned by root as soon as it is downloaded.
Am I trying the right approach here? I have heard about anode, but its wiki is empty and whatever instructions it has are confusing and do not say whether I need to be root. Everything else I have seen tells me I have to have a rooted Android to install node.js, but I hate to give up after so much effort.
Instead installing node.js on the android device, try jxcore.
You can download an android executable binary from its download page, and execute it from the terminal emulator. Remember to set up exec flags.
EDIT: jxcore seems no longer under development.

accessing android os root files

i have the following doubt:
i have read that android os is based on linux, and i imagine it may have the same structure that ubuntu (in terms of file configurations: /root, /dev, etc).
so, is it possible to run an application written in C in android? just as it is possible to do in ubuntu? if so, how can i do that?
also, how can i get access to the root files through an android application (written in java)? and how to get access to the behavior of the os (in terms of interruptions for example)?
thanks in advance for your answers.
gus
Basic answer: Running a C app on Android isn't supported, except through the Native Development Kit (NDK).
You can't get access to the root files except by rooting a phone.
You can get access to some OS behavior through the API. Basically, if it's not part of the API, you can't access it.
The Android OS is based on Linux, but it's an OS, not a windowing server like X or a desktop environment like Gnome or KDE.
You may run C and C++ code on android using NDK. You may use also QT framework. But code is runing in virtual machine named Davlik. Android have root acount , but it is default not available for user. Therefore, access to directory is dependend for chmod.
If you would like read about access to low level in android:
http://www.phrack.org/issues.html?issue=68&id=6
And about architecture this system:
https://developer.android.com/guide/basics/what-is-android.html
You can run programs using Runtime.exec. As an example, you can see Terminal IDE which runs many different programs including ssh, vim and bash. It's also open source so you can learn from the code. You will probably have to include the executable as a resource or asset and then copy to a local directory, grant execute permissions, then run with Runtime.exec. You still have limited user permissions as your app runs under a restricted account unless the device is rooted and you request root access.
an android smartphone/tablet works with an Arm cpu, not a x85. the architecture is different.
but you CAN run a C application in android if you cross compile it for arm linux. or you can use a c compiler inside android device. people ported c compiler to android. you can try C4DROID and in android market. but you can only run compiled program in system memory because of android permissions about sd card.

Categories

Resources