I can't load kext on macOS Sierra - macos-sierra

I'm trying load kext on macOS Sierra. but error occur.
Please, someone help me.
1.
csrutil disable && reboot
disable SIP.
2.
nvram boot-"debug=0x146 kext-dev-mode=1" && reboot
kext developer mode.
3.
kext build with xcode.
4.
cp -rf /Users//Library/Developer/Xcode/DerivedData//Build/Products/Debug /System/Library/Extensions
5.
kextload /System/Library/Extensions/test.kext
/System/Library/Extensions/test.kext failed to load - (libkern/kext) validation failure (plist/executable); check the system/kernel logs for errors or try kextutil(8).
6.
kextutil /System/Library/Extensions/test.kext
...
Code Signing Failure: code signature is invalid

If you are starting out with kext dev, don't put your kext in the Library/Extensions folder since this may cause a disaster if something goes wrong in your kext and prevent your OS from booting. You can load it from anywhere other than Library/Extensions.
The kext should load unless there's an obvious mistake of having csrutils being enabled. Just like someone from the comments said, check whether you have SIP turned on by using csrutil status. If not, I'm guessing you have a faulty plist in your project. Please post your plist so that I can take a look.
Referring to your 2. Starting from sierra nvram will not work unless you're in recovery mode.
If you have your csrutil disabled, you'll see
kext signature failure override allowing invalid signature -67050 0xFFFFFFFFFFFEFA16 for kext
after your Code signing failure prompt and then load your kext successfully.

Regarding step #2, according to Apple,
As of macOS El Capitan, the kext-dev-mode boot-arg is now obsolete.
$ sudo nvram boot-args="kext-dev-mode=1" # Has No Effect

You can simply add Oracle editor in this authorization list.
Restart your mac in Recovery mode (cmd + R)
Then open a Terminal and enter :
spctl kext-consent add VB5E2TV963
Restart your mac.
Ok for me with Mojave and Virtual Box 6.

Related

Back button not working on android emulator

I try to start an android sdk emulator, but when I press the back button this error appears:
INFO | Critical: Failed to load https://maps.googleapis.com/maps/api/mapsjs/gen_204?csp_test=true: The 'Access-Control-Allow-Origin' header has a value 'qrc://' that is not equal to the supplied origin. Origin 'qrc://' is therefore not allowed access. (qrc:/html/js/common.js:0, (null))
INFO | Critical: Failed to load https://maps.googleapis.com/maps/api/mapsjs/gen_204?csp_test=true: The 'Access-Control-Allow-Origin' header has a value 'qrc://' that is not equal to the supplied origin. Origin 'qrc://' is therefore not allowed access. (qrc:/html/js/common.js:0, (null))
I use Ubuntu and try to start the emulator through terminal, I use the avdmanager of the google cmdline-tools (latest version) and this is the AVD that I try to use:
Name: my_avd_29ii
Path: /home/user/.android/avd/my_avd_29ii.avd
Target: Google APIs (Google Inc.)
Based on: Android 10.0 (Q) Tag/ABI: google_apis/x86
Sdcard: 512 MB
The best option would (Needs to be done for every emulator you install)
Windows
%USERPROFILE%\.adnroid\avd\<Emulator Name>.avd
Edit config.ini
Change hw.keyboard=no to hw.keyboard=yes
Mac
~/.adnroid/avd/<Emulator Name>.avd
Edit config.ini
Change hw.keyboard=no to hw.keyboard=yes
The answer is based on this article
After looking around I found that there were two ways to push hardware events to the emulator:
First method
This method uses telnet, like so:
telnet 127.0.0.1 5554
auth <auth-key>
event send EV_KEY:KEY_BACK:0
event send EV_KEY:KEY_BACK:1
This is going to simulate the pressing down (0) the releasing (1) of a button.
Second method
This method uses adb, like so:
adb shell input keyevent KEYCODE_BACK
Ok so what?
After trying both, I realized that telnet didn't work but adb did work. I also checked the source code of emulator and saw that telnet relies on the same set of functions that are used by the tool-window. So it's probably a bug, and we can wait for the update to fix it, or...
In the meantime
I downloaded the source code, wrote a janky workaround, and built it. Basically instead of using the keypress method, I use the adb method. If you want here it is. It's quite voluminous so be patient. I included a small script to automatically replace the emulator, just run:
$ chmod +x replace
# ./reaplace path-to-android-sdk
This adds a new flag -use-adb-toolwindow to emulator. When you activate it it will use adb (successfully) for most of keyboard inputs, and home, back, apps and power buttons. Like I said it's a quick fix, but for me it works fine.
Note:
I have no clue where the bug is, so I didn't do any report, hopefuly as more people get this issue it will become clearer.

Enable VncServer 6.2.1 ARMv6 experimental capture mode by command line

I'm not able to enable the Raspberry Pi's VNC capture mode from the command line.
ExperimentalRaspiCapture mode allows you to remotely view videos running.
If not enabled, you cannot watch videos. As my application has disabled the raspbian graphical mode, I only have operations from the command line and I do not have access to the internet on them, only local network.
I did tests on an alternative raspberry and in graphical mode I enabled this option according to the tutorial on page vncserver experimental direct capture mode missing and it worked for me, but I have several raspberries and enabling it by command line is my best option at the moment, but I can't enable it.
I already tried the tutorial on the page:
How do I get VNC access to Kano OS working correctly?
But it did not work.
Any idea? Has anyone managed to do this?
Thanks.
Use vnc version: VNC (R) Server 6.2.1 (r32538) ARMv6
I use the raspberry:
*Linux raspberrypi 4.14.34-v7 *
I found the problem. I wasn't doing it right. I have to change the file in the root user and then restart the serviced. ;)
Edit the config file '/root/.vnc/config.d/vncserver-x11'
adding the following:
CaptureTech=raspi
ExperimentalRaspiCapture=1
ServerPreferredEncoding=JPEG
and then restarted:
sudo systemctl restart vncserver-x11-serviced

opening an hiddevice failes

I have a device to program which uses hidapi. I had problems in opening a device when running my program in eclipse. My first guess was that it is a permission problem.
So I added the following udev rule in a text file, with vendor and product id of my device:
SUBSYSTEM=="usb", ATTRS{idVendor}=="06cb", ATTRS{idProduct}=="009a", MODE="0666"
in the /etc/udev/rules.d
I rebooted the system and plugged in the device again.
Now when I try
sudo udevadm test /dev/usb/hiddev3
(which is the path to my device), I can see in the list that it reads the rule I added. But still I get this message at the end:
unable to open device '/sys/dev/usb/hiddev3'
So my question is:
Is it really a permission issue that hinders access to the device? If not, what are other problems that can block opening a hid device?
If it is a permission issue, how can I solve it? Is there any other udev rule to add?
I am on ubuntu 18.04.
Thank you very much

Error "System UI isn't responding" while running AOSP build on emulator

I am trying to run AOSP(oreo 8.1) build on emulator.
I used following commands to build AOSP.
source build/envsetup.sh
lunch aosp_arm-eng
make -j4
my build was successful. Now i'm trying to run on emulator using following command.
emulator
emulator is started with following warning message.
Could not automatically detect an ADB binary. Some emulator functionality will not work until a custom path to ADB is added in the extended settings page.
After successful boot "System UI isn't responding" message is displaying on the emulator, also emulator is running real slow.
Any help in resolving this issue is greatly appreciated.
emulator screenshot: system ui isn't responding
emulator: WARNING: system partition size adjusted to match image file (2050 MB > 200 MB)
emulator: WARNING: encryption is off
main-loop: WARNING: I/O thread spun for 1000 iterations
It often occurs - especially on slow machines running CPU-consuming emulations, that an emulator would initially load into a state where a System UI isn't responding alert shows. It does not necessarily mean the device isn't working; Often enough, the alert can be dismissed and the device will be completely functional from that point on.
I'm not sure what the exact issue to solve here is. Nevertheless, assuming you're running on CI and - besides the emulator's sluggishness, wish to overcome the System UI isn't responding alert appearing upon boot completion (as suggested by the title) -- may I suggest this bash script (gist):
#!/bin/bash
echo ""
echo "[Waiting for launcher to start]"
LAUNCHER_READY=
while [[ -z ${LAUNCHER_READY} ]]; do
UI_FOCUS=`adb shell dumpsys window windows 2>/dev/null | grep -i mCurrentFocus`
echo "(DEBUG) Current focus: ${UI_FOCUS}"
case $UI_FOCUS in
*"Launcher"*)
LAUNCHER_READY=true
;;
"")
echo "Waiting for window service..."
sleep 3
;;
*"Not Responding"*)
echo "Detected an ANR! Dismissing..."
adb shell input keyevent KEYCODE_DPAD_DOWN
adb shell input keyevent KEYCODE_DPAD_DOWN
adb shell input keyevent KEYCODE_ENTER
;;
*)
echo "Waiting for launcher..."
sleep 3
;;
esac
done
echo "Launcher is ready :-)"
The script awaits for the launcher to become ready and in-focus, and automatically dismisses system responsiveness alerts, coming its way.
It in no way addresses the emulator's sluggishness, however.
See this answer from another question to fix the ADB error. However, this will likely not fix the responsiveness of your emulator.
The emulator tends to function extremely slowly if you are compiling aosp for a different architecture than your host machine. If you are building on an x86 machine an x86 build will result in a significantly faster emulator that won't eat up all of your machine's resources.
May be this answer could be helpful for someone who have made a mistake like me and could save his time.
I faced this issue on my physical device as i used an app icon of very large size (2100x2100). I resolved it by using an app icon of low size(512x512).

iPhone Simulator - Simulate a slow connection?

Is there a way to slow down the internet connection to the iPhone Simulator, so as to mimic how the App might react when you are in a slow spot on the cellular network?
How to install Apple’s Network Link Conditioner
These instructions current as of October 2019.
Warning: If you just upgraded to new version of macOS, make sure you install the very latest Network Conditioner (in Additional Tools for Xcode) or it may silently fail; that is, you will turn it on but it won’t throttle anything or drop any packets.
Update: As of Xcode 11, there may be an even simpler way to simulate network conditions on tethered devices; see this blog post. For how to affect simulated devices, continue below, as before.
Install Xcode if you don’t have it.
Open Xcode and go to Xcode › Open Developer Tool › More Developer Tools…
Download Additional Tools for Xcode (matching your current Xcode version)
Open the downloaded disk image and double-click the Network Link Conditioner .prefpane under “Hardware” to install it.
There we go!
Be sure to turn it on. You need to select a profile and enable the network conditioner.
Caveat
This won't affect localhost, so be sure to use a staging server or co-worker's computer to simulate slow network connections to an API you’re running yourself. You may find https://ngrok.com/ helpful in this regard.
"There's an app for that!" ;) Apple provides "Network Link Conditioner" preference pane that does the job quite well.
for Xcode versions prior to 4.3, the pane installer can be found in your Developer folder, e.g. "/Developer/Applications/Utilities/Network Link Conditioner", after installation, if daemon fails to start and you don't want to reboot your machine, just use sudo launchctl load /system/library/launchdaemons/com.apple.networklinkconditioner.plist
if you are already done with Developer folder, you can install the pane as a part of "Hardware IO Tools for Xcode" package available via Mac Dev Center additional downloads section.
Link to download page (you must log in with your Apple ID): https://developer.apple.com/downloads/index.action
(credits to #nverinaud)
An app called SpeedLimit
https://github.com/mschrag/speedlimit
Works great.
chris.
It also worth mentioning that Xcode also has a built in way for devices, not simulator.
Just go 'Devices and Simulator' (cmmd+shift+2)
Select your device
Scroll down til you find 'Device Conditions'
Set your desired profile
Hit Start
To have this working you need to install 'Network Link Conditioner' on your Mac. See steps mention in Alan's answer
I would argue that a slow connection isn't enough to simulate real-work mobile data network behaviour - since there is also much more packet loss, higher latencies and more dropped connections too.
Here is a handy script I found to configure the firewall to emulate these parameters:
http://pmilosev-notes.blogspot.com/2011/02/ios-simulator-testing-over-different.html
#!/bin/sh
if [ "$#" -ne "3" ]
then
echo "Usage:\n$0 <bandwidth in kpbs> <delay in ms> <packet loss ratio>";
exit 1
fi
BW=$1
DELAY=$2
PLR=$3
sudo ipfw pipe 1 config bw ${BW}Kbit/s delay $DELAY plr $PLR
sudo ipfw add 1 pipe 1 all from me to not me
sudo ipfw add 2 pipe 1 all from not me to me
echo "RETURN to stop connection noise"
read
sudo ipfw delete 1
sudo ipfw delete 2
exit 0
Some suggested values you can use:
Scenario
Bw (Kbit)
delay (ms)
pr (ratio)
2.5G mobile
(GPRS)
50
200
3G mobile
1000
200
0.2
VSAT
5000
500
0.2
Busy LAN on VSAT
300
500
0.4
There isn't a direct way to emulate a slow connection, unlike, say, the nice network connection emulator that blackberry developers enjoy. However, since your simulator's connection goes through your computer - you can simply focus on slowing down your computer's connection.
You'll want to achieve two things (depending upon your circumstances):
throttle your bandwidth
increase your latency
Maybe this will point you in right direction:
http://www.macosxhints.com/article.php?story=20080119112509736
There are some good open source solutions, too, but I so can't remember their names.
This question might help: How to throttle network traffic for environment simulation?
You can do it in really device through Xcode(14) settings
Debug -> Induce Device conditions -> Network Link -> select the Network you want