Bruteforce Verizon Moto Z2 Force - Moto Z2 Force Guides, News, & Discussion

Updated 7.30.20
I have a server up and running and thought it would be perfect to go back to this. I noticed some problems with the original code. After a while, the oem unlock command would hang, so I made it reboot the bootloader ever 1024 keys. I also added an initial oem unlock check because the first time you do the command it asks are you sure. This script should work forever.
I did notice that the screen will get burn in if left on for a long time. I cannot seem to find a way around this, no fastboot command can turn the screen off and keep fastboot running. I figured a $40 screen is worth reviving a $700 phone. This phone has been sitting in a box for years because verizon's anti everyone policies on bootloaders. I will be running this until it cracks the bootloader.
There is an automatic saving/restoring feature in case the computers gets turned off or I need to restart it. I also made the script not repeat characters more than 3 times in a row. I know chances are this won't work, but to me it's worth a try considering I don't have to do anything.
Code:
#!/bin/bash
restore() {
echo "Restoring Previous Session..."
crunch 20 20 ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 -d 3 -s "${file}" | while read line; do
iter=$((iter + 1))
echo "Testing key ${line} - ${iter}"
line2=$((sudo fastboot oem unlock "${line}") 2>&1)
check=$(echo "${line2}" | sed -n 2p)
echo "${check}"
if [ "${check}" != "(bootloader) Code validation failure" ]; then
echo "${line}" >> key
finished
fi
echo "${line}" > current
if [ $iter -eq 1024 ]; then
echo "--------------------"
echo "Rebooting to bootloader"
echo "--------------------"
sudo fastboot reboot bootloader
echo "--------------------"
echo "Sleeping 5 seconds"
echo "--------------------"
sleep 5s
iter=0
echo "--------------------"
echo "Running initial oem unlock"
echo "--------------------"
sudo fastboot oem unlock aaaaaaaaaaaaaaaaaaaa
fi
done
}
new() {
echo "Running New Session..."
crunch 20 20 ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 -d 3 | while read line; do
iter=$((iter + 1))
echo "Testing key ${line} - ${iter}"
line2=$((sudo fastboot oem unlock "${line}") 2>&1)
check=$(echo "${line2}" | sed -n 2p)
echo "${check}"
if [ "${check}" != "(bootloader) Code validation failure" ]; then
echo "${line}" >> key
finished
fi
echo "${line}" > current
if [ $iter -eq 1024 ]; then
echo "--------------------"
echo "Rebooting to bootloader"
echo "--------------------"
sudo fastboot reboot bootloader
echo "--------------------"
echo "Sleeping 5 seconds"
echo "--------------------"
sleep 5s
iter=0
echo "--------------------"
echo "Running initial oem unlock"
echo "--------------------"
sudo fastboot oem unlock aaaaaaaaaaaaaaaaaaaa
fi
done
}
finished() {
echo ""
echo "------------------------------------"
echo ""
echo "A different output was given, probably bootloader key found"
echo "Last checked key was"
echo "${line}"
echo "Key is also stored in a file called key"
echo "${line}" >> key
chmod 555 key
echo ""
echo "------------------------------------"
echo ""
echo "Press enter to close the terminal"
read var
exit 1
}
testresult() {
if [ -f "current" ]; then
file=$(cat current)
if [ "${file}" == "" ]; then
rm current
new
else
restore
fi
else
new
fi
}
testkey() {
if [ -f "key" ]; then
file=$(cat key)
if [ "${file}" == "" ]; then
chmod 775 key
rm key
testresult
else
echo "Key from last run was found, it is"
echo "${file}"
echo "Backing up to key.old"
chmod 775 key
cat key >> key.old
rm key
testresult
fi
else
testresult
fi
}
iter=0
sudo fastboot oem unlock aaaaaaaaaaaaaaaaaaaa
testkey

Knuxyl said:
I wrote a script for linux to bruteforce the bootloader unlock key on the Verizon model Motorola Moto Z2 Force.
Since I do not use my Force I figured I would run a bruteforce on the bootloader to hopefully one day get it unlocked. I am using an ASUS Tinkerboard with Debian 2.0.7 to run this code.
Requirements
Linux (Ubuntu do sudo apt-get install crunch sed, if your using anything else get crunch and sed)
Time
What it does
Generates alpha-numerics keys 20 characters long in order starting at AAAAAAAAAAAAAAAAAAAA.
It creates a file called "current" that will save your spot in case you want to resume later.
It will stop when bootloader response does not says validation failure and save the last used key to a file called "success"
Code (create a .sh file with this, do chmod +x thisfile.sh, then run it with ./thisfile.sh)
Code:
restore() {
crunch 20 20 ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 -s "${file}" | while read line ; do echo "Testing key below ${line}" && line2=$((sudo fastboot oem unlock "${line}") 2>&1) && check=$(echo "${line2}" | sed -n 2p) && echo "${check}" && if [ "${check}" != "(bootloader) Code validation failure" ]; then echo "${line}" >> success && finished ; fi && echo "${line}" > current ; done
}
new() {
crunch 20 20 ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 | while read line ; do echo "Testing key below ${line}" && line2=$((sudo fastboot oem unlock "${line}") 2>&1) && check=$(echo "${line2}" | sed -n 2p) && echo "${check}" && if [ "${check}" != "(bootloader) Code validation failure" ]; then echo "${line}" >> success && finished ; fi && echo "${line}" > current ; done
}
finished() {
clear
echo "A different output was given, probably bootloader key found"
echo "Last checked key was"
echo "${line}"
echo "Key is also stored in a file called success"
echo "${line}" >> success
echo ""
echo "Press enter to close the terminal"
read var
exit 1
}
if [ -f "current" ]; then
file=$(cat current)
if [ "${file}" == "" ]; then
rm current
new
else
restore
fi
else
new
fi
I am running this now, I will post back if I ever get the key. Started 1700 on 23-July-2018.
I am on AAAAAAAAAAAAAAAAAUAA as of 1743 for a time/speed reference.
Click to expand...
Click to collapse
If it works, it might one day, unlock bootloaders for other phones as well. Good luck, first person I found to even try such a thing...

You'd have much better odds winning the lottery than getting a brute force answer in your lifetime. It is really folly. Let's assume you are doing just numeric characters instead of alpha numeric. That gives you 10 to the 20th power number of combinations instead of 36 to the 20th power. So if you wrote really optimized code and could go through 1 billion combinations a second, that would be 10 to the 9th power. I billion seconds later you would have gone through 10 to the 18th power or just one percent of the possible combinations. A billion seconds is a little more than 31 years. So in 3100 years you would have gone though just the strictly numeric solutions. As I've said before, brute force isn't going to get you the answer and shouldn't even be considered a viable answer.

kingstu said:
You'd have much better odds winning the lottery than getting a brute force answer in your lifetime. It is really folly. Let's assume you are doing just numeric characters instead of alpha numeric. That gives you 10 to the 20th power number of combinations instead of 36 to the 20th power. So if you wrote really optimized code and could go through 1 billion combinations a second, that would be 10 to the 9th power. I billion seconds later you would have gone through 10 to the 18th power or just one percent of the possible combinations. A billion seconds is a little more than 31 years. So in 3100 years you would have gone though just the strictly numeric solutions. As I've said before, brute force isn't going to get you the answer and shouldn't even be considered a viable answer.
Click to expand...
Click to collapse
What's your solution? You seem to have all the answers.

Find an exploit.
Try
Code:
fastboot oem unlock nowait
This worked for the Moto 360 on Marshmallow, it MIGHT work.
To find an exploit would be quicker than brute forcing.

doubledragon5 said:
What's your solution? You seem to have all the answers.
Click to expand...
Click to collapse
I don't have all the answers but buying a bootloader unlockable version is what I would recommend. By showing how long it would take I save someone from waiting and waiting for a task that won't complete in his lifetime...

So the phone died like a day later while running the bruteforce. I have the powerpack moto mod so I'm going to have to plug that in to a charger, put it on the phone, and plug usb to phone and pc/tinkerboard... when I get around to it. But I will keep up with this thread.
I tried the nowait fastboot and Code Validation Failure.

Is it even possible for a mobile device to go through 1-billion combinations a second? What if the code was split up over like 10 devices, and the code had each device only working on a smaller section for the unlock code......

azreark1 said:
Is it even possible for a mobile device to go through 1-billion combinations a second? What if the code was split up over like 10 devices, and the code had each device only working on a smaller section for the unlock code......
Click to expand...
Click to collapse
The unlock has to be tested on the specific device so splitting the processing among multiple devices won't solve the problem since each has its own unique code. Just buy a device with an unlockable bootloader since if it was that easy to decode the device wouldn't be very secure and that would have me more worried...

Oh so it's not a generic unlock code, it would still only be device specific?! Yeah thats pretty useless.

The method was initially a failure, why was it laid out here?

08sv80 said:
The method was initially a failure, why was it laid out here?
Click to expand...
Click to collapse
this is really only for people who have a verizon moto z2 force that they do not use and a pc they keep running 24/7. the method is not a failure, it just takes a long time. this is the only solution we have so far, so its better than nothing, but if u dont like it then move on, dont waste time posting useless comments.

for anyone that was interested in this, i must note that while phone is on the bootloader (fastboot) the screen stays on at like max brightness the whole time, so it can easily cause screen burn in. until i find some fastboot command to turn the screen off this is highly not recommended. Mine started burning in so I stopped the process.

you write nonsense and make people believe it? take it easy. your method is initially a failure. Believe on 4PDA, we know all the working methods.

If it hasn't been done, I believe the only way to unlock these bootloaders is exercising some consumer rights through a legal battle, and good luck with that, not worth wasting the time and money. I would be happy to just have temp-root, even if I have to do it every time I boot the phone. That would be more productive to chase, but I believe all exploits have been tried.

Could somebody use IBM's quantum computer
What if somebody could rewrite the script and use IBM's quantum computer. I am not a developer or a script Kitty or anything but that idea crossed my mind. Could it be possible or is it possible. I do know IBM lets people use their old quantum computer so it's just an idea.

Fastlane81 said:
What if somebody could rewrite the script and use IBM's quantum computer. I am not a developer or a script Kitty or anything but that idea crossed my mind. Could it be possible or is it possible. I do know IBM lets people use their old quantum computer so it's just an idea.
Click to expand...
Click to collapse
It's the phone's response and process that takes time, not the computer running the script.

m4f1050 said:
It's the phone's response and process that takes time, not the computer running the script.
Click to expand...
Click to collapse
Ok I figured that there was so many combinations that the normal computer couldn't figure out the combinations that fastso I figured with a quantum computer it can do it in days instead of months or years. That is what I was thinking.

Fastlane81 said:
Ok I figured that there was so many combinations that the normal computer couldn't figure out the combinations that fastso I figured with a quantum computer it can do it in days instead of months or years. That is what I was thinking.
Click to expand...
Click to collapse
Trust me, even an 8-bit Atari can create random numbers fast enough for this task (not saying you can use one, because you need to store the numbers and compare the newly created one with the ones already used, which I would use SQL server for this and not memory.) It's the phone itself the one slowing this down when entering the number and waiting for the phone to respond and starting the process again.

Kindly give instructions.
If someone can kindly give me instructions on how to initiate this code that would be awesome I have Ubuntu 20.04.1 installed on my desktop. And I just need to know how to initiate this script. If you can email me at [email protected] that would be awesome thank you very much

Related

Build script for 'Nightlies'

Hi guys,
just shameless ripped from the jenkins build script from the wiki and adapted it to our build environment, for 1 device:
build.sh
Code:
#!/bin/bash
export USE_CCACHE=1
################# Your device here:
DEVICE=n7100
################################
cd ~/android/omni
. build/envsetup.sh
repo sync -j4
rm -rf out/target
brunch $DEVICE
make it executeable:
Code:
chmod +x build.sh
Pretty simple, but works for my private nightlies - and maybe as a cron job.
TODO / IDEAS:
Checking if build did work (exit codes? checking for if zip exists?)
Moving the flashable ZIP to a safe (public?) place
purging old builds (tmpwatch?)
check for changes before building
notify on finished builds (notify my android?)
check for changes before building
notify on finished builds (notify my android?)
cb5264 said:
Hi guys,
just shameless ripped from the jenkins build script from the wiki and adapted it to our build environment, for 1 device:
build.sh
Code:
#!/bin/bash
export USE_CCACHE=1
Click to expand...
Click to collapse
This is incomplete. It could be good enough for Jerkins™, but for your desktop rig it should be
Code:
export USE_CCACHE=1
prebuilts/misc/linux-x86/ccache/ccache -M 50G <---- whatever you can spare, I use 50Gbs
cb5264 said:
repo sync -j4
Click to expand...
Click to collapse
Also unnecessary, because the default is -j4.
Code:
repo sync
would suffice.
Keep in mind that we don't have nightlies ready yet as none of the devices are ready yet (nightly builds for us are meant to be stable) but we will have some ready soon
Sent from my SM-N900T using XDA Premium 4 mobile app
Regarding ccache, why should we need to set up the ccache size every compile?
It's a set once value...
Gesendet von meinem GT-N7100 mit Tapatalk
You dont need to. You might add a 'ccache -s' afterwards though - to see how useful ccache was for the build.
If you build OmniROM (when its ready), for yourself, you will want to cherry-pick changes from the Gerrit review, or add changes of your own, to make your build different from that on Jenkins. So it might be better not to have 'repo sync' in your script -- that will wipe out all your changes.
HippyTed said:
You dont need to. You might add a 'ccache -s' afterwards though - to see how useful ccache was for the build.
If you build OmniROM (when its ready), for yourself, you will want to cherry-pick changes from the Gerrit review, or add changes of your own, to make your build different from that on Jenkins. So it might be better not to have 'repo sync' in your script -- that will wipe out all your changes.
Click to expand...
Click to collapse
regarding ccache, as far as I know data that needs to be computed more than once but doesn't change is put into a cache so it will be generated once and then read from the cache, in that case if I delete the cache every time i lose the advantage of a cache...
regarding cherry picks, I would put the cherry picks after the repo sync command to have the best of both worlds (updated core and cherry picks)
regards
Steven
NemesisRE said:
regarding ccache, as far as I know data that needs to be computed more than once but doesn't change is put into a cache so it will be generated once and then read from the cache, in that case if I delete the cache every time i lose the advantage of a cache...
Click to expand...
Click to collapse
Check man pages for ccache - '-C' clears it, '-z' zeroes stats, '-s' shows stats.
regarding cherry picks, I would put the cherry picks after the repo sync command to have the best of both worlds (updated core and cherry picks)
Click to expand...
Click to collapse
Ok.
HippyTed said:
Check man pages for ccache - '-C' clears it, '-z' zeroes stats, '-s' shows stats.
Ok.
Click to expand...
Click to collapse
this doesn't disprove my assertion...
NemesisRE said:
this doesn't disprove my assertion...
Click to expand...
Click to collapse
True. Maybe I misunderstood your reason for making the assertion.
HippyTed said:
True. Maybe I misunderstood your reason for making the assertion.
Click to expand...
Click to collapse
I think so ^^ the reason was to say that rebuilding the cache on every run would be dumb
cb5264 said:
Hi guys,
just shameless ripped from the jenkins build script from the wiki and adapted it to our build environment, for 1 device:
build.sh
Code:
rm -rf out/target
brunch $DEVICE
Click to expand...
Click to collapse
for personal use I don't remove the /out folder but maybe once every few weeks. You're essentially doing a make clobber but leaving your out/host folder so that's good but, even so, it isn't necessary to flush out the target folder every time unless your compiling is pooping out. I suppose it depends whether you're making it a cron job in which case I'd do what you're doing.
---------- Post added at 12:16 AM ---------- Previous post was at 12:14 AM ----------
... what I do think would be nice is to set up a delta update mechanism like cyandelta so we could update on mobile data without killing our data plans.
cd omni
rm -rf out
repo sync -j 16
time brunch n7100
that's what I use
Seems I have the most Advances
Code:
#!/bin/bash
cd ~/
clear
export USE_CCACHE=1
export CCACHE_DIR=~/.ccache
prebuilts/misc/linux-x86/ccache/ccache -M 50G
DATE=$(date -u +%Y%m%d)
OMNIBUILDTODEL=`expr $DATE - 5`
DEVICE=$*
. build/envsetup.sh
rm -f out/target/product/$DEVICE/obj/KERNEL_OBJ/.version
rm -f out/target/product/$DEVICE/system/build.prop
rm -f out/target/product/$DEVICE/system/app/*.odex
rm -f out/target/product/$DEVICE/omni*.zip
rm -f out/target/product/$DEVICE/omni*.zip.md5sum
rm -f out/target/product/$DEVICE/system/framework/*.odex
brunch omni_$DEVICE-userdebug -j12
sftp {-p PORT#} {USER-NAME}@xxx.xxx.xxx.xxx << EOF
cd /var/www/mithun46/hammerhead/omni/
put out/target/product/$DEVICE/omni-4.4-$DATE-$DEVICE-HOMEMADE.zip
put out/target/product/$DEVICE/omni-4.4-$DATE-$DEVICE-HOMEMADE.zip.md5sum
rm omni-4.4-$OMNIBUILDTODEL-$DEVICE-HOMEMADE.zip
rm omni-4.4-$OMNIBUILDTODEL-$DEVICE-HOMEMADE.zip.md5sum
EOF
This:
Uses 50 gigs of ccache
Uploads to my personal server [zip+md5]
Deletes 5 days old builds and their md5sum
This is not clean builds [i clean manually] [is kinda clean though]
Is in the smallest form possible
mithun46 said:
#!/bin/{SHELL}
...
sftp {-p PORT#} {USER-NAME}@xxx.xxx.xxx.xxx
cd /var/www/{what/should/possibly/be/an/obscured/path/to}/omni/
Click to expand...
Click to collapse
You also just provided me with:
1) Verification of an operable {SHELL} compatible shell.
2) Your server's IP.
3) A good indicator that your server accepts SSH AND SFTP connections at the port {PORT#}.
4) Verification that your SSH server accepts "{USER-NAME}" logins.
5) Pretty solid evidence of, and possibly even an otherwise inaccessible path on, a web server
Please edit your post. Ive already made my post as vague as possible without failing to make my point, i hope.
Also, please consider SSH's known_hosts or at the least shell aliases/functions so you don't have to hardcode IP addresses and user-names in random shell scripts.
-Mike
* While it's possible that... EDIT: *REDACTED* no problem, Mithun. I said it for myself as much as I did you; nobody likes a botnet. Well, maybe very few like a botnet.
mithun46 said:
Code:
...
sftp {-p PORT#} {USER-NAME}@xxx.xxx.xxx.xxx << EOF
cd /var/www/mithun46/hammerhead/omni/
put out/target/product/$DEVICE/omni-4.4-$DATE-$DEVICE-HOMEMADE.zip
put out/target/product/$DEVICE/omni-4.4-$DATE-$DEVICE-HOMEMADE.zip.md5sum
rm omni-4.4-$OMNIBUILDTODEL-$DEVICE-HOMEMADE.zip
rm omni-4.4-$OMNIBUILDTODEL-$DEVICE-HOMEMADE.zip.md5sum
EOF
[/LIST]
Click to expand...
Click to collapse
That part got a disturbing 'issue' imho - it doesn't check for a build being successful. I'd work that out with an if-clause checking if the file exists...
cb5264 said:
That part got a disturbing 'issue' imho - it doesn't check for a build being successful. I'd work that out with an if-clause checking if the file exists...
Click to expand...
Click to collapse
If no file exists it shows errors while trying to upload the file in sftp
This is my try, it´s not perfect and for the most people too much... but it`s mine ^^
https://gist.github.com/NemesisRE/7518954
EDIT: Will update the gist until i think it is all ok, but the code here will stay as it is
Code:
#!/bin/bash
##################################################
#
# vim: ai ts=4 sw=4 noet sts=4 ft=sh
#
# Copyright 2013, Steven Koeberich ([email protected])
#
# Title: dinner.sh
# Author: Steven "NemesisRE" Koeberich
# Date: 20131117
# Version: 1.1
# Description: Builds Roms automatically
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License at (http://www.gnu.org/licenses/) for
# more details.
#set -e #do not enable otherwise brunch will fail
#set -x
#For compatibility set Language to en_US.UTF8 and timezone to UTC
export LANGUAGE="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
export LANG="en_US.UTF-8"
export TZ="/usr/share/zoneinfo/UTC"
#Make us of CCACHE
export USE_CCACHE=1
# Define global variables
REPO_DIR="${HOME}/android/omni"
MAIL_BIN=$(which mail)
LOG_DIR="${HOME}/logs"
SHOW_VERBOSE="> /dev/null 2>&1"
CONVERT_TO_HTML="| ansi2html" # install package kbtin to use this feature
#Set initial exitcodes
SYNC_REPO_EXIT_CODE="0"
GET_BREAKFAST_VARIABLES_EXIT_CODE="0"
BRUNCH_DEVICE_EXIT_CODE="0"
MOVE_BUILD_EXIT_CODE="0"
RUN_COMMAND_EXIT_CODE="0"
CLEAN_OLD_BUILDS_EXIT_CODE="0"
SEND_MAIL_EXIT_CODE="0"
# This variables can be overwritten by command line parameters
MAIL='' # set this if you want always an email
ADMIN_MAIL='' # set this if you want always an email (with logs)
TARGET_DIR='' # set this if you want always move your build to the given directorie
CLEANUP_OLDER_THEN="" # set this if you want always automatic cleanup
DOWNLOAD_LINK='' # set this if you want always a download link
RUN_COMMAND='' # set this if you want always run a command after a build was successful
BUILD_FOR_DEVICE="" # set this if you want always build for the given device/s
#Source envsetup
. ${REPO_DIR}/build/envsetup.sh > /dev/null 2>&1
######################
#
# function _usage
#
#
function _usage() {
echo $"Usage: ${0} [-n \"[email protected]\"] [-t \'/var/www/awsome-download-dir\'] [-r \'scp \$\{OUTPUT_FILE\} example.com:\' ][-l \"http://example.com/download/omnirom\"] [-c 7] [-v] [-- i9300 mako ]"
cat<<EOF
Options:
-n Send notification to given Mail-Adress
-t Move files into given Directorie
-r Run command on successful build
-l If you choose a target dir you may want put
a download link into the mail message
-c Cleanup builds older then N days
-v Verbose Output
-h See this Message
EOF
}
function _e_notice () {
echo -e "NOTICE: ${1}"
}
function _e_warning () {
echo -e "WARNING:Something went wrong ${1} (${2})"
}
function _e_error () {
echo -e "ERROR: ${1}"
}
function _check_prerequisites () {
if [ ! -x $(which ansi2html) ]; then
CONVERT_TO_HTML=""
fi
if [ ${TARGET_DIR} ]; then
TARGET_DIR=$(echo "${TARGET_DIR}"|sed 's/\/$//g')
fi
if [ ${LOG_DIR} ]; then
LOG_DIR=$(echo "${LOG_DIR}"|sed 's/\/$//g')
fi
if [ -z ${BUILD_FOR_DEVICE} ]; then
echo "ERROR: No Device given! Stopping..."
_usage
exit 1
fi
if [ ! -d ${LOG_DIR} ]; then
mkdir -p ${LOG_DIR}
fi
}
function _sync_repo () {
_e_notice "Running repo sync..."
eval "repo sync ${SHOW_VERBOSE}"
SYNC_REPO_EXIT_CODE=$?
if [ ${SYNC_REPO_EXIT_CODE} != 0 ]; then
_e_warning "while doing repo sync" "${SYNC_REPO_EXIT_CODE}"
fi
}
function _get_breakfast_variables () {
for VARIABLE in `breakfast ${DEVICE} | sed -e 's/^=.*//' -e 's/[ ^I]*$//' -e '/^$/ d'`; do
eval ${VARIABLE}
done
GET_BREAKFAST_VARIABLES_EXIT_CODE=$?
if [ ${GET_BREAKFAST_VARIABLES_EXIT_CODE} != 0 ]; then
_e_warning "while getting breakfast variables" "${GET_BREAKFAST_VARIABLES_EXIT_CODE}"
fi
}
function _brunch_device () {
_e_notice "Running brunch for ${DEVICE} with version ${PLATFORM_VERSION} ..."
eval "brunch ${DEVICE} 2>&1 | tee ${LOG_DIR}/brunch_${DEVICE}.log ${SHOW_VERBOSE}"
BRUNCH_DEVICE_EXIT_CODE=$?
BRUNCH_RUN_TIME=$(tail ${LOG_DIR}/brunch_${DEVICE}.log | grep "real" | awk '{print $2}')
if [ ${BRUNCH_DEVICE_EXIT_CODE} != 0 ]; then
_e_warning "while brunch the ${DEVICE}, see logfile for more information" "${BRUNCH_DEVICE_EXIT_CODE}"
fi
}
function _move_build () {
_e_notice "Moving files to target directory..."
mv ${OUTPUT_FILE}* ${TARGET_DIR}/
MOVE_BUILD_EXIT_CODE=$?
if [ ${MOVE_BUILD_EXIT_CODE} != 0 ]; then
_e_warning "while moving the build" "${MOVE_BUILD_EXIT_CODE}"
fi
}
function _run_command () {
_e_notice "Run command..."
eval ${RUN_COMMAND}
RUN_COMMAND_EXIT_CODE=$?
if [ ${RUN_COMMAND_EXIT_CODE} != 0 ]; then
_e_warning "while running your command" "${RUN_COMMAND_EXIT_CODE}"
fi
}
function _clean_old_builds () {
_e_notice "Running cleanup of old builds..."
if [ ${TARGET_DIR} ]; then
CLEANED_FILES=$(find ${TARGET_DIR}/ -name "omni-${PLATFORM_VERSION}-*-${DEVICE}-HOMEMADE.zip*" -type f -mtime +${CLEANUP_OLDER_THEN}d -delete)
else
CLEANED_FILES=$(find `dirname ${OUTPUT_FILE}` -name "omni-${PLATFORM_VERSION}-*-${DEVICE}-HOMEMADE.zip*" -type f -mtime +${CLEANUP_OLDER_THEN}d -delete)
fi
CLEAN_OLD_BUILDS_EXIT_CODE=$?
if [ ! ${CLEANED_FILES} ]; then
CLEANED_FILES="Nothing to clean up."
fi
_e_notice "${CLEANED_FILES}"
if [ ${CLEAN_OLD_BUILDS_EXIT_CODE} != 0 ]; then
_e_warning "while cleaning builds" "${CLEAN_OLD_BUILDS_EXIT_CODE}"
fi
}
function _send_mail () {
_e_notice "Sending status mail..."
MAIL_MESSAGE="Build Status:\n\n"
ADMIN_MAIL_MESSAGE=""
if ${BUILD_SUCCESSFUL}; then
MAIL_MESSAGE+="Build for ${DEVICE} was successfull finished after ${BRUNCH_RUN_TIME}\n"
if [ ${DOWNLOAD_LINK} ]; then
MAIL_MESSAGE+="You can download your Build at ${DOWNLOAD_LINK}\n\n"
fi
if [ ${CLEANED_FILES} ]; then
ADMIN_MAIL_MESSAGE+="Removed the following files:\n"
ADMIN_MAIL_MESSAGE+=${CLEANED_FILES}
fi
else
MAIL_MESSAGE+="Build was not successfull ran ${BRUNCH_RUN_TIME}.\n\n"
ADMIN_MAIL_MESSAGE+="Logfile:"
ADMIN_MAIL_MESSAGE+=$(cat ${HOME}/brunch_${DEVICE}.log ${CONVERT_TO_HTML})
fi
if [ ${MAIL} ]; then
echo -e "${MAIL_MESSAGE}" | ${MAIL_BIN} -s "Finished dinner." "${MAIL}"
fi
if [ ${ADMIN_MAIL} ]; then
echo -e "${MAIL_MESSAGE}${ADMIN_MAIL_MESSAGE}" | ${MAIL_BIN} -s "Finished dinner." "${ADMIN_MAIL}"
fi
SEND_MAIL_EXIT_CODE=$?
if [ ${SEND_MAIL_EXIT_CODE} != 0 ]; then
_e_warning "while sending E-Mail" "${SEND_MAIL_EXIT_CODE}"
fi
}
function _check_build () {
OUT_FILE_SECONDS_SINCE_CREATION=$(/bin/date -d "now - $( /usr/bin/stat -c "%Y" ${OUTPUT_FILE} ) seconds" +%s)
if [ -f ${OUTPUT_FILE} ] && [ "${OUT_FILE_SECONDS_SINCE_CREATION}" -lt "120" ] ; then
BUILD_SUCCESSFUL=true
else
BUILD_SUCCESSFUL=false
fi
}
######################
#
# function _main
#
#
function _main() {
_check_prerequisites
cd ${REPO_DIR}
_sync_repo
for DEVICE in ${BUILD_FOR_DEVICE}; do
_get_breakfast_variables
_brunch_device
OUTPUT_FILE="${OUT_DIR}/target/product/${DEVICE}/omni-${PLATFORM_VERSION}-$(date +%Y%m%d)-${DEVICE}-HOMEMADE.zip"
_check_build
if ${BUILD_SUCCESSFUL} && [ ${TARGET_DIR} ]; then
eval TARGET_DIR=${TARGET_DIR}
_move_build
fi
if ${BUILD_SUCCESSFUL} && [ ${CLEANUP_OLDER_THEN} ]; then
_clean_old_builds
fi
if [ ${MAIL} ] || [ ${ADMIN_MAIL} ]; then
eval MAIL=${MAIL}
eval ADMIN_MAIL=${ADMIN_MAIL}
_send_mail
fi
done
OVERALL_EXIT_CODE=$((${SYNC_REPO_EXIT_CODE}+${GET_BREAKFAST_VARIABLES_EXIT_CODE}+${BRUNCH_DEVICE_EXIT_CODE}+${MOVE_BUILD_EXIT_CODE}+${CLEAN_OLD_BUILDS_EXIT_CODE}+${SEND_MAIL_EXIT_CODE}))
if ! ${BUILD_SUCCESSFUL} && [ ${OVERALL_EXIT_CODE} -gt 0 ]; then
_e_warning "buildcheck failed and Overall exit code is higher then 0 will exit with 1" "${OVERALL_EXIT_CODE}"
exit 1
elif ${BUILD_SUCCESSFUL} && [ ${OVERALL_EXIT_CODE} -gt 0 ]; then
_e_warning "buildcheck was successful but Overall exit code is higher then 0 will exit with 1" "${OVERALL_EXIT_CODE}"
exit 1
else
_e_notice "All jobs finished successfully."
fi
}
## Parameter handling
while getopts ":n:t:l:c:vh" opt; do
case ${opt} in
"n")
MAIL='${OPTARG}'
;;
"t")
TARGET_DIR='${OPTARG}'
;;
"r")
RUN_COMMAND='${OPTARG}'
;;
"l")
DOWNLOAD_LINK='${OPTARG}'
;;
"c")
CLEANUP_OLDER_THEN="${OPTARG}"
;;
"v")
SHOW_VERBOSE=""
;;
"h")
_usage
exit 0
;;
\?)
echo "Invalid option: -${OPTARG}"
_usage
exit 1
;;
:)
echo "Option -${OPTARG} requires an argument."
_usage
exit 1
;;
esac
done
shift $((${OPTIND}-1))
if [ ${@} ]; then
BUILD_FOR_DEVICE=${@}
fi
_main
exit 0
Cheers
Steven
No more gist
The script is now called Dinner, more information at http://forum.xda-developers.com/showthread.php?t=2690995

Help please

My htc One is going to need to go in for repair, and i have many images that i dont want to lose, but i know that it is very likely that a factory reset is very likely. Can someone tell what is the easiest and most effective way of saving/storing my wallpapers/photos from the phone back to the phone when it comes back from repair?
Any advice would be very much appreciated, as i am a complete novice when it comes to this sort of thing.
dibdin said:
My htc One is going to need to go in for repair, and i have many images that i dont want to lose, but i know that it is very likely that a factory reset is very likely. Can someone tell what is the easiest and most effective way of saving/storing my wallpapers/photos from the phone back to the phone when it comes back from repair?
Any advice would be very much appreciated, as i am a complete novice when it comes to this sort of thing.
Click to expand...
Click to collapse
What's broken that needs repair?
dibdin said:
My htc One is going to need to go in for repair, and i have many images that i dont want to lose, but i know that it is very likely that a factory reset is very likely. Can someone tell what is the easiest and most effective way of saving/storing my wallpapers/photos from the phone back to the phone when it comes back from repair?
Any advice would be very much appreciated, as i am a complete novice when it comes to this sort of thing.
Click to expand...
Click to collapse
Drag and drop to a folder on your computer, then when the phone comes back drag and drop back into the same place.
dibdin said:
My htc One is going to need to go in for repair, and i have many images that i dont want to lose, but i know that it is very likely that a factory reset is very likely. Can someone tell what is the easiest and most effective way of saving/storing my wallpapers/photos from the phone back to the phone when it comes back from repair?
Any advice would be very much appreciated, as i am a complete novice when it comes to this sort of thing.
Click to expand...
Click to collapse
Here is my little tool to save the whole SDCard, it should be able to do the work... simply follow the instructions:
http://ul.to/0skv8966
Source code, if you think it's a virus:
Code:
::===========================================
::This is Version 1.0 of Android SDCard to PC
::===========================================
@echo off
title Android SDCard To PC
:startProcedure
echo ===============================================================================
echo Willkommen bei Android SDCard To PC
echo Instruktionen: -Shut down your phone into recovery
echo -This tool is only tested on CWM and TWRP, but it should work
echo for all recoveries
echo -It's impossible that this tool damages your phone! But I'm not
echo responsible for any kind if **** that happens
echo -NOW, mount the /data partition from your recovery!
echo ===============================================================================
echo\
cd resources
dir
echo\
echo ===============================================================================
echo Now if you want to continue, press: J
echo If you want to leave, press: N
echo ===============================================================================
set /p pfadUserChoice=
if %pfadUserChoice% == J goto fileCopying
if %pfadUserChoice% == N goto beenden
goto beenden
:beenden
echo Closing programme:
pause
goto ende
:fileCopying
echo ===============================================================================
echo Write here your directory where you want to store the backups
echo (z.B. D:\Users\Name\BackUps )
echo ===============================================================================
set /p computerDirectory=
set backUpDirectoryFinal=/data/media/0
echo Data will be copied if you accept the next request:
echo Von: %backUpDirectoryFinal%
echo Zu: %computerDirectory%
pause
adb remount
adb pull %backUpDirectoryFinal% %computerDirectory%
echo If there were no errors, the process should have worked fine
echo Killing!
pause
:ende
LibertyMarine said:
Here is my little tool to save the whole SDCard, it should be able to do the work... simply follow the instructions:
http://ul.to/0skv8966
Source code, if you think it's a virus:
Code:
::===========================================
::This is Version 1.0 of Android SDCard to PC
::===========================================
@echo off
title Android SDCard To PC
:startProcedure
echo ===============================================================================
echo Willkommen bei Android SDCard To PC
echo Instruktionen: -Shut down your phone into recovery
echo -This tool is only tested on CWM and TWRP, but it should work
echo for all recoveries
echo -It's impossible that this tool damages your phone! But I'm not
echo responsible for any kind if **** that happens
echo -NOW, mount the /data partition from your recovery!
echo ===============================================================================
echo\
cd resources
dir
echo\
echo ===============================================================================
echo Now if you want to continue, press: J
echo If you want to leave, press: N
echo ===============================================================================
set /p pfadUserChoice=
if %pfadUserChoice% == J goto fileCopying
if %pfadUserChoice% == N goto beenden
goto beenden
:beenden
echo Closing programme:
pause
goto ende
:fileCopying
echo ===============================================================================
echo Write here your directory where you want to store the backups
echo (z.B. D:\Users\Name\BackUps )
echo ===============================================================================
set /p computerDirectory=
set backUpDirectoryFinal=/data/media/0
echo Data will be copied if you accept the next request:
echo Von: %backUpDirectoryFinal%
echo Zu: %computerDirectory%
pause
adb remount
adb pull %backUpDirectoryFinal% %computerDirectory%
echo If there were no errors, the process should have worked fine
echo Killing!
pause
:ende
Click to expand...
Click to collapse
Nice idea :good:
Just make sure he's on 4.2.2+ ROM, otherwise if it's still 4.1.2 then it will be in /data/media
LibertyMarine said:
Here is my little tool to save the whole SDCard, it should be able to do the work... simply follow the instructions:
http://ul.to/0skv8966
Source code, if you think it's a virus:
Code:
::===========================================
::This is Version 1.0 of Android SDCard to PC
::===========================================
@echo off
title Android SDCard To PC
:startProcedure
echo ===============================================================================
echo Willkommen bei Android SDCard To PC
echo Instruktionen: -Shut down your phone into recovery
echo -This tool is only tested on CWM and TWRP, but it should work
echo for all recoveries
echo -It's impossible that this tool damages your phone! But I'm not
echo responsible for any kind if **** that happens
echo -NOW, mount the /data partition from your recovery!
echo ===============================================================================
echo\
cd resources
dir
echo\
echo ===============================================================================
echo Now if you want to continue, press: J
echo If you want to leave, press: N
echo ===============================================================================
set /p pfadUserChoice=
if %pfadUserChoice% == J goto fileCopying
if %pfadUserChoice% == N goto beenden
goto beenden
:beenden
echo Closing programme:
pause
goto ende
:fileCopying
echo ===============================================================================
echo Write here your directory where you want to store the backups
echo (z.B. D:\Users\Name\BackUps )
echo ===============================================================================
set /p computerDirectory=
set backUpDirectoryFinal=/data/media/0
echo Data will be copied if you accept the next request:
echo Von: %backUpDirectoryFinal%
echo Zu: %computerDirectory%
pause
adb remount
adb pull %backUpDirectoryFinal% %computerDirectory%
echo If there were no errors, the process should have worked fine
echo Killing!
pause
:ende
Click to expand...
Click to collapse
Liberty - I've never heard of this, but it seems to use adb pull which was going to be one of my suggestions.
is it a ui for these commands?
--
ALSO, dibdin, make sure you have Debugging enabled in Dev Options in settings, and definitely mtp enabled and Fastcharge disabled (if your kernel allows it.)
---------- Post added at 11:16 AM ---------- Previous post was at 10:57 AM ----------
dibdin said:
My htc One is going to need to go in for repair, and i have many images that i dont want to lose, but i know that it is very likely that a factory reset is very likely. Can someone tell what is the easiest and most effective way of saving/storing my wallpapers/photos from the phone back to the phone when it comes back from repair?
Any advice would be very much appreciated, as i am a complete novice when it comes to this sort of thing.
Click to expand...
Click to collapse
if its a cracked digitizer/glass but touch still responds and you can see what youre doing, then you can upload any of them to online storage like Google Drive, Box, Drop Box, etc. the list goes on.
in fact g+ has an auto update feature, if you have used it, it may have already backed up your images..
as for backing up apps: if youre rooted then Titanium Backup (should be "duh!" but in case you didn't know) available on the playstore
or if youre not rooted, theres a relatively new app from Clockwork Mod entitled Helium (also on the playstore) that requires a pc, but not root, and worked great for me since I was afraid to root my One (afraid to brick it like I had with my sgs3 and had to send to jtag (a near 100$ learning experience )
both have premium versions, but if youre into dev or flashing different roms, you'll want to look into either one.
nkk71 said:
Nice idea :good:
Just make sure he's on 4.2.2+ ROM, otherwise if it's still 4.1.2 then it will be in /data/media
Click to expand...
Click to collapse
Oh, okay didn't know that.. thanks, i am gonna update the program so that this guy won't have any troubles if he has Android 4.1.. Do you know if it's possible to determine the Android Version by using ADB and making a CMD check, so the input variable is set automatically? I mean that it changes the directory to /data/media
---------- Post added at 10:26 PM ---------- Previous post was at 10:22 PM ----------
DaringDomino3s said:
Liberty - I've never heard of this, but it seems to use adb pull which was going to be one of my suggestions.
is it a ui for these commands?
Click to expand...
Click to collapse
Yeah.. but it might be easier for him to use a tool instead of working with adb commands.. no there isn't a UI, it's simply a guide.. it does all the work for you... But it simply is a stupid tool.. it's so easy.. but it helps and if you make backups more often, you can let this tool do the work
LibertyMarine said:
Oh, okay didn't know that.. thanks, i am gonna update the program so that this guy won't have any troubles if he has Android 4.1.. Do you know if it's possible to determine the Android Version by using ADB and making a CMD check, so the input variable is set automatically? I mean that it changes the directory to /data/media
---------- Post added at 10:26 PM ---------- Previous post was at 10:22 PM ----------
Yeah.. but it might be easier for him to use a tool instead of working with adb commands.. no there isn't a UI, it's simply a guide.. it does all the work for you... But it simply is a stupid tool.. it's so easy.. but it helps and if you make backups more often, you can let this tool do the work
Click to expand...
Click to collapse
How about using /sdcard, shouldnt that symlink to the correct one?
I'm not thinking straight right now so I better get back 2 u tomorrow...
Sent from my HTC One using Tapatalk
Edit: it's not a stupid tool !
nkk71 said:
How about using /sdcard, shouldnt that symlink to the correct one?
I'm not thinking straight right now so I better get back 2 u tomorrow...
Sent from my HTC One using Tapatalk
Click to expand...
Click to collapse
I once had mounting issues on my recovery.. but yeah, I'll try this option once my HTC One is repaired.. *hoping they'll do it on warranty*
Ok, that's very nice

pre_boot.sh

there is a .sh file in the system/etc folder on my Z1 that checks and loads the touch screen firmware - I tried running it through an adb shell (very new to this stuff) and got permission denied - my phone is rooted correctly as far as I can see with su #
can someone help me to run this manually on my rooted Z1 or offer some help in forcing a firmware load of the touchscreen FW
I have a Z1 with a replaced screen all hardware has been replaced except for the main board
surely some of you whiz kids can help me out here
@Geoffxx, u mean pre_hw_config.sh ?
Code:
#!/system/bin/sh
# pre_hw_config.sh.
# Used to set special parameters during early boot.
#KOTO hw boot
if [ -e /system/bin/snfcboot ]; then
/system/bin/snfcboot
fi
#Touch fw update
touch_path="/sys/devices/virtual/input/"
touch_vendor_id=$(/system/bin/ta_param_loader -p -t 4950 -d 0 -f "0x%02x")
if [ "$touch_vendor_id" = "0x01" ]; then
touch_module_id=0x$(/system/bin/ta_param_loader -p -t 4950 -d 3 -c 2 -f "%02x")
/system/bin/clearpad_fwloader default $touch_module_id
elif [ "$touch_vendor_id" = "0x02" ]; then
touch_chip_id=0x$(/system/bin/ta_param_loader -p -t 4950 -d 1 -c 2 -f "%02x")
touch_config_id=0x$(/system/bin/ta_param_loader -p -t 4950 -d 3 -c 2 -f "%02x")
echo 1 $touch_config_id $touch_chip_id > "$touch_path/max1187x/dflt_cfg"
echo default > "$touch_path/max1187x/fw_update"
else
if [ -a "$touch_path/clearpad" ]; then
touch_module_id=$(/system/bin/ta_param_loader -t 60221 -f "0x%02x")
if [ "$touch_module_id" = "0x00" ]; then
touch_module_id=0x$(cat $touch_path/clearpad/fwfamily)
fi
/system/bin/clearpad_fwloader default $touch_module_id
elif [ -a "$touch_path/max1187x" ]; then
touch_chip_id=$(cat $touch_path/max1187x/chip_id)
touch_config_id=$(cat $touch_path/max1187x/config_id)
echo 1 $touch_config_id $touch_chip_id > "$touch_path/max1187x/dflt_cfg"
echo default > "$touch_path/max1187x/fw_update"
fi
log "*** touch: No valid Misc TA 4950"
fi
yes sorry I was doing it from memory, the phone is in bits right now
There are about 15 different variants of touch firmware, I believe the above code checks to see which variant is present then loads the FW for it from the selection
what I don't know is if this routine runs every time or is called from another part of the boot process to run on an error condition
at present all I know is that I have a dead touchscreen and all the hardware has been replace except the motherboard - everything on the phone works 100% except the touch, so I want to make sure that touch firmware has been loaded by doing it manually
the Z1 has the synaptics touch hardware and so must be identified somewhere
So there are two checks I'd like to do
see if the hardware is being identified/read - there must be a manual way to do this through adb shell
and if the hardware is being identified then force load the Firmware for it
there was a problem with the xperia T family and here is a thread that identified a similar solution http://forum.xda-developers.com/showthread.php?t=2220290&highlight=touch+screen+not+working , unfortunately the Z family of phones/tablets are different, I suspect it's because they all use the same main firmware and have to identify hardware between all the devices and load appropriate software to drive them

GUIDE: connect OP3 with MTP on Linux (ubuntu)

I got my OP3 today and my laptop, running ElementaryOS (ubuntu based) didn't recognize the OP3 as MTP,
Here is a guide how to fix this, I based this guide on this guide for the OP2.
steps:
Do NOT connect your OP3 to your pc
run the command "lsusb" from your terminal
Connect your OP3 to your pc with original cable
run the command "lsusb" again
You will see a new device, my OP3 is called " Bus 001 Device 012: ID 05c6:900e Qualcomm, Inc. "
You see that it has an ID, in my case "05c6:900e".
the first value is the vendor-id, the second the product-id, you need those so write them down!
so in my case it's :
vendor id: 05c6
product id: 900e
Install the MTP drivers: "sudo apt-get install libmtp-dev mtpfs"
edit the following file with the command: "sudo gedit /lib/udev/rules.d/69-libmtp.rules"
if you don't have gedit installed use the command: "sudo nano /lib/udev/rules.d/69-libmtp.rules"
Add the following line to the file:
Code:
ATTR{idVendor}=="[COLOR="Blue"]vendor-id[/COLOR]", ATTR{idProduct}=="[COLOR="blue"]product-id[/COLOR]", SYMLINK+="libmtp-%k", MODE="660", GROUP="audio", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1", TAG+="uaccess"
make sure you change the blue values to your own values found in the step above.
safe the file
restart the service: "sudo service udev restart"
If you did it correct you will see a popup on your OP3, select "File Transfers (MTP)", select that and now you can transfer files between your OP3 and linux
I don't know if the vendor-id and/or product-id are always the same, if some people can confirm that then I will edit the post.
Hey, I got the same vendor id and product id as you did.
However, even after following the procedure step-by-step, I am unable to transfer files between my OP3 and my laptop running Ubuntu 12.04 LTS.
The OnePlus drivers folder gets loaded as a CD(though I'm connecting the phone using USB) when I change the "Use USB for" setting to "File Transfer(MTP)," and the file named "adb_config_Linux_OSX.sh" doesn't do anything when run in terminal either.
Could you help me out with this?
I run Ubuntu 16.04 and needed to install any drivers. simply connect op and I was able to access it.
Sent from my ONEPLUS A3003 using XDA-Developers mobile app
krankyvampire25 said:
Hey, I got the same vendor id and product id as you did.
However, even after following the procedure step-by-step, I am unable to transfer files between my OP3 and my laptop running Ubuntu 12.04 LTS.
The OnePlus drivers folder gets loaded as a CD(though I'm connecting the phone using USB) when I change the "Use USB for" setting to "File Transfer(MTP)," and the file named "adb_config_Linux_OSX.sh" doesn't do anything when run in terminal either.
Could you help me out with this?
Click to expand...
Click to collapse
update: In "设置" -"其他设置" - "内部设备和USB" - "USB计算机连接", select -- "File Transfers (MTP)", everything is ok.
14.04 can't transfer file. a folder cant write anything(not cd image folder).
hi....... i have a other problem with the same OS (Ubuntu 16.04)
MTP works
fastboot works
ADB DON'T !!!
do you know why ?????
ADB and fastboot are working at the same device with Win 10
OK, thanks, forget it, i found a file named "adb_config_Linux_OSX.sh" on the phone and run it...... now it works
ty, it worked after two reboots and a system update. btw, i have the OP3 soft gold with ID 2a70:f003
cheers!
washichi said:
I got my OP3 today and my laptop, running ElementaryOS (ubuntu based) didn't recognize the OP3 as MTP,
Here is a guide how to fix this, I based this guide on this guide for the OP2.
steps:
Do NOT connect your OP3 to your pc
run the command "lsusb" from your terminal
Connect your OP3 to your pc with original cable
run the command "lsusb" again
You will see a new device, my OP3 is called " Bus 001 Device 012: ID 05c6:900e Qualcomm, Inc. "
You see that it has an ID, in my case "05c6:900e".
the first value is the vendor-id, the second the product-id, you need those so write them down!
so in my case it's :
vendor id: 05c6
product id: 900e
Install the MTP drivers: "sudo apt-get install libmtp-dev mtpfs"
edit the following file with the command: "sudo gedit /lib/udev/rules.d/69-libmtp.rules"
if you don't have gedit installed use the command: "sudo nano /lib/udev/rules.d/69-libmtp.rules"
Add the following line to the file:
Code:
ATTR{idVendor}=="[COLOR="Blue"]vendor-id[/COLOR]", ATTR{idProduct}=="[COLOR="blue"]product-id[/COLOR]", SYMLINK+="libmtp-%k", MODE="660", GROUP="audio", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1", TAG+="uaccess"
make sure you change the blue values to your own values found in the step above.
safe the file
restart the service: "sudo service udev restart"
If you did it correct you will see a popup on your OP3, select "File Transfers (MTP)", select that and now you can transfer files between your OP3 and linux
I don't know if the vendor-id and/or product-id are always the same, if some people can confirm that then I will edit the post.
Click to expand...
Click to collapse
I just now happened upon this forum because my OP3 wasn't connecting for file transfers over USB. This worked like a charm for me; the vendor and product IDs were different (as I'm sure others have commented already), thank you for putting this out there, I definitely hit that 'thanks' button!!!!!!!
It's also possible to use this script (Vendor & Product id can differ).
Code:
#!/bin/sh
# adb configuration script
PATH=$PATH:/bin:/sbin:/usr/sbin
ANDROID_HOME=~/.android
ANDROID_CONFIG=~/.android/adb_usb.ini
CUST_VID="0x2a70"
if [ -e $ANDROID_HOME ] ; then
echo "android home is exist!"
else
echo "creat android home!"
mkdir $ANDROID_HOME
fi
grep $CUST_VID $ANDROID_CONFIG 2>/dev/null
if [ $? -eq 0 ] ; then
echo VID $CUST_VID is already configured..
echo "adb should be OK!"
exit 0
else
echo config adb ...
echo $CUST_VID >> $ANDROID_CONFIG
fi
adb kill-server
if [ $? -eq 0 ] ; then
echo "OK! You can use adb now!"
exit 0
else
echo "try sudo exec adb.."
sudo adb kill-server
if [ $? -eq 0 ] ; then
echo "OK! You can use adb now!"
exit 0
else
echo "Please do command \"adb kill-server\""
fi
fi
exit 0
Useful link: https://wiki.archlinux.org/index.php/android#Android_Debug_Bridge_.28ADB.29
Thanks a lot washichi It worked liked a charm on my OnePlus3T. Thanks a ton

[WORKAROUND] - Magisk Not Installed - [Module]

I have Magisk v18.1 installed on my OG Pixel running PixelDust ROM and noticed every so often it loses root access. When entering the Magisk Manager app it also shows Magisk Not Installed. I did some investigating and found that magiskd (magisk daemon) gets terminated at some point randomly. Further testing revealed I could restart it manually by issuing "magisk --daemon" via SSH/ADB root shell.
I wrote a simple module to keep the daemon running and haven't noticed the "Magisk Not Found" error since. The module is just a simple bash script executed as service on boot that checks every minute for the daemon and runs the "magisk --daemon" command as root if not running. I am just posting it here to see if it can help anyone else who's root access disappears randomly on v17-19.3.
Please be aware that this is my first module ever. It was also originally started via an init.d script instead of the service hook in magisk, though it should work exactly the same. I have also noticed it is not possible for my module to restart magiskd yet if it was killed manually by the user.
GIt Repo:
https://github.com/Geofferey/mgkdhelper
Magisk Repo Submission:
https://github.com/Magisk-Modules-Repo/submission/issues/404
Release:
UNINSTALL INITIAL v1.0.0 RELEASE BEFORE INSTALL!!!
If you fail to do so you will have the old version and current version running at same time.
Download:
Current Release v2.1.0
Major thanks to @jcmm11 & @char101 whose contributions are now officially included in this module.
I just wanna say God bless you for this module, my man. I was frustratingly having my Magisk daemon getting killed 2-3 times a day On my LG V20. Since installing your module for the past 4 days ive yet to encounter such an issue. I greatly appreciate you coming up w/a solution to a problem that was frustrating me to the max
Geofferey said:
I wrote a simple module to keep the daemon running and haven't noticed the "Magisk Not Found" error since.
Click to expand...
Click to collapse
Thanks for that module. Very good idea and it's working perfectly fine. :good:
Hi,
There is no /data/local/run directory by default on my phone (OP6 Pie). So I suggest that either you create it first or simply uses /data/local/tmp to store the pid. Also creating the directory first might be a good idea. If you add -q to the grep command there is no need to redirect the output.
Code:
#!/system/xbin/bash
PIDFILE=/data/local/tmp/magiskd-helper.pid
LOGFILE=/data/local/tmp/magiskd-helper.log
is_magisk_running() {
ps -a | grep -q [m]agiskd
}
if [ ! -d /data/local/tmp ]; then
mkdir -p /data/local/tmp
fi
if [ -f $PIDFILE ]; then
kill -9 `cat $PIDFILE`
fi
echo $$ > $PIDFILE
RETRIES=0
while true; do
sleep 60
if ! is_magisk_running; then
echo `date` >> $LOGFILE
echo 'Magisk daemon appears to have crashed' >> $LOGFILE
echo 'Restarting magiskd...' >> $LOGFILE
/sbin/magisk --daemon
if is_magisk_running; then
echo 'Success!' >> $LOGFILE
RETRIES=0
else
echo 'Failure!' >> $LOGFILE
((++RETRIES))
if (( $RETRIES > 10 )); then
echo 'Giving up' >> $LOGFILE
break
fi
fi
echo >> $LOGFILE
fi
done
When first run, /system/bin/ps is linked to magisk builtin busybox, which don't have the -u option
Code:
ps: invalid option -- u
BusyBox v1.30.1-topjohnwu (2019-04-30 01:01:15 EDT) multi-call binary.
Usage: ps [-o COL1,COL2=HEADER] [-T]
Show list of processes
-o COL1,COL2=HEADER Select columns for display
-T Show threads
char101 said:
When first run, /system/bin/ps is linked to magisk builtin busybox, which don't have the -u option
Code:
ps: invalid option -- u
BusyBox v1.30.1-topjohnwu (2019-04-30 01:01:15 EDT) multi-call binary.
Usage: ps [-o COL1,COL2=HEADER] [-T]
Show list of processes
-o COL1,COL2=HEADER Select columns for display
-T Show threads
Click to expand...
Click to collapse
Try again after having install the 'Busybox for NDK' Magisk module (from osm0sis), maybe that the -u arg for ps command will works i ddon't remember me having testing it recently so idk if it will works but i think yeah
I have the GNU coreutils module installed so it is not the problem.
Also the original module redirect stderr to /dev/null so unless you modify it you won't see the error like I posted before.
My modifications
service.sh
Code:
#!/system/bin/sh
# Do NOT assume where your module will be located.
# ALWAYS use $MODDIR if you need to know where this script
# and module is placed.
# This will make sure your module will still work
# if Magisk change its mount point in the future
MODDIR=${0%/*}
# This script will be executed in late_start service mode
$MODDIR/common/magisk-monitor > /data/local/tmp/magisk-monitor.log 2>&1 &
magisk-monitor
Code:
#!/system/bin/sh
is_magisk_running() {
ps -A | grep -q [m]agiskd
}
sleep 300
echo `date`
echo 'magisk-monitor running'
echo
RETRIES=0
while true; do
sleep 60
if ! is_magisk_running; then
echo `date`
echo 'Magisk daemon appears to have crashed'
echo 'Restarting magiskd...'
/sbin/magisk --daemon
if is_magisk_running; then
echo 'Success!'
RETRIES=0
else
echo 'Failure!'
((++RETRIES))
if (( $RETRIES > 10 )); then
echo 'Giving up'
break
fi
fi
echo
fi
done
Rom said:
Try again after having install the 'Busybox for NDK' Magisk module (from osm0sis), maybe that the -u arg for ps command will works i ddon't remember me having testing it recently so idk if it will works but i think yeah
Click to expand...
Click to collapse
I doubt it... From busybox.net:
ps
Report process status
Options:
-o col1,col2=header Select columns for display
-T Show threads
Click to expand...
Click to collapse
It is better to just use 'ps -A' which will work on busybox ps and coreutils ps.
Didgeridoohan said:
I doubt it... From busybox.net:
Click to expand...
Click to collapse
I'm agree with u, but it was already happen for me that some other args works too, i had never know why.
I came across your module while looking for the same issue affecting many users on different devices (although it seems to be affecting Pie only). Magisk GitHub is also full of reports by people losing root and solving with a reboot. I don't know how impactful it is on the battery since it checks for Magisk every 60 seconds (I have just installed it) but so far your module is the only blessing we can get to avoid rebooting once/twice per day. I think you should definitely submit your module to the official repository!
P.s i had to create /data/local/run first for the pid
@Geoffrey another quick correction: in my case on MIUI 10 based on Pie, ps -a does not show the same output as ps -A. So I had to replace the -a in your script with an upper case A.
char101 said:
It is better to just use 'ps -A' which will work on busybox ps and coreutils ps.
Click to expand...
Click to collapse
Coreutils doesn't have a ps applet. If you want to use -u just use the full path /system/bin/ps to force the toybox applet.
@Geoffrey
First of all nice workaround. I did some cleanup and a few modifications if you want to post it to the Magisk repository (and I think you should).
Changed over to the current template.
Removed all the PID stuff, it's really not needed.
Replaced ps -a -u with pgrep. That eliminates any busybox vs toybox issues (at least the way it's being used here)
Removed bash. There's nothing here that requires a bash shell as opposed to the default shell.
Moved the script to it's own directory instead of xbin. Not all phones have xbin, and trying to use it on those that don't is problematic. Plus there's no reason the script needs to be in the PATH.
Added nohup to the script startup command in service.sh
Also always create the log file, with a "started on" line in it. That at least gives an indication that the script started.
So what we're left with.
mgkd-helper (in a script directory)
Code:
#!/system/bin/sh
LOGFILE=/data/local/tmp/magiskd-helper.log
rm -f $LOGFILE
echo "Started " $(date) >> $LOGFILE
echo "-----------------------------" >> $LOGFILE
echo >> $LOGFILE
while true; do
sleep 60
if ! pgrep magiskd >/dev/null; then
echo $(date) >> $LOGFILE
echo "Magisk daemon appears to have crashed" >> $LOGFILE
echo "Restarting magiskd..." >> $LOGFILE
if magisk --daemon; then
echo "success!" >> $LOGFILE
else
echo "failure!" >> $LOGFILE
fi
echo >> $LOGFILE
fi
done
service.sh
Code:
#!/system/bin/sh
# Do NOT assume where your module will be located.
# ALWAYS use $MODDIR if you need to know where this script
# and module is placed.
# This will make sure your module will still work
# if Magisk change its mount point in the future
MODDIR=${0%/*}
# This script will be executed in late_start service mode
#Magisk Daemon Helper
# Copyright (C) 2019 Geofferey @ XDA
# License: GPL V3+
nohup $MODDIR/script/mgkd-helper > /dev/null &
If you do decide to place it in the repository you need to do something with README.md
You should also replace META-INF/com/google/android/update-binary with the attached version. The included version is for standalone installs. Repository versions should use the alternate one. (Remove the ".txt")
Last note: tested this and it does work. I killed the running magiskd and a new one was started, with the appropriate log entry created
I wasn't able to start magiskd with "magisk -- daemon" via adb. It always says "No daemon found" instead of starting it. I seem to have lost root with the original script and I had to restart again. Any idea? I just enabled root via adb in Magisk. Not sure if that was the issue that I couldn't restart it.
And it seems like magiskd is killed in OxygenOS 9.0.5 on my OnePlus 6. Not sure if it is due to out of memory reasons but I can't get any logcat as I don't have root. Super annoying.
Will this be added to the magisk module repository? If it is there I couldn't find it. I do know there are links and a revision at the end of the thread by @jcmm11. I don't need the module, just curious if the revision will be put there eventually. I have had others with that problem that I have helped.
Thanks
martyfender said:
Will this be added to the magisk module repository? If it is there I couldn't find it. I do know there are links and a revision at the end of the thread by @jcmm11. I don't need the module, just curious if the revision will be put there eventually. I have had others with that problem that I have helped.
Thanks
Click to expand...
Click to collapse
I think it should be but it's up to @Geoffrey. It's his module. I cleaned it up a bit that's all. Most of the work is done. Biggest thing left to do is modify README.md
jcmm11 said:
@Geoffrey
First of all nice workaround. I did some cleanup and a few modifications if you want to post it to the Magisk repository (and I think you should).
Changed over to the current template.
Removed all the PID stuff, it's really not needed.
Replaced ps -a -u with pgrep. That eliminates any busybox vs toybox issues (at least the way it's being used here)
Removed bash. There's nothing here that requires a bash shell as opposed to the default shell.
Moved the script to it's own directory instead of xbin. Not all phones have xbin, and trying to use it on those that don't is problematic. Plus there's no reason the script needs to be in the PATH.
Added nohup to the script startup command in service.sh
Also always create the log file, with a "started on" line in it. That at least gives an indication that the script started.
So what we're left with.
mgkd-helper (in a script directory)
service.sh
If you do decide to place it in the repository you need to do something with README.md
You should also replace META-INF/com/google/android/update-binary with the attached version. The included version is for standalone installs. Repository versions should use the alternate one. (Remove the ".txt")
Last note: tested this and it does work. I killed the running magiskd and a new one was started, with the appropriate log entry created
Click to expand...
Click to collapse
Should we directly flash zip in twrp recovery
kryshnakishore said:
Should we directly flash zip in twrp recovery
Click to expand...
Click to collapse
You can flash it in recovery or via Magisk Manager, modules section, big + button at bottom of screen.
I've been looking for a solution to this since v17 ... started happening on 17, kept happening on 18, is even worse now on v19 ... :-/

Categories

Resources