text:
Read the URL of currently open tab in a browser, every time it changes
I use Logitech media server (LMS) to play my music on a DLNA device. The server also has a youtube plugin and can play the sound of youtube videos if a specific url, which contains the youtube video id, is opened. For example http://myLMS:9000/status.html?p0=playlist&p1=play&p2=youtube://wS1drVzZPmw&player=myPlayer.
But it only plays back a single video this way. And I'd like them to autoplay, the way they do when youtube is accessed with a browser.
One way to do this, would be to open a browser and read the youtube url every time it changes, somehow, extract the video id from the url, and then forward it to LMS by generating a link, similar to the one I posted above, but containing the id of the video, that was extracted from the youtube url.
The generating and opening of the custom link for the LMS should not be too difficult, by using tasker, I think. But I suspect getting the url from the browser and constantly checking if it changed, would be more difficult.
So - is it possible to read the URL of currently open tab in a browser, every time it changes, and store it as text somewhere?
Or maybe the youtube app on android stores the id of the video it is currently playing somewhere. That might work also, if we could read it somehow. I think the youtube app also autoplays the videos.

I am a bit confused here. This logitech software seems to be supported on Windows, Linux and Mac, so I assume you are running it on a non-Android device. Your DLNA client is probably an Android device though where you listen the music. So, you want to keep sending a YouTube URL from that client on your Android to that server. Did I get this correctly? Which DLNA client are you using?

Yes, the server is running on a NAS device, and I would like to send the server custom links, that would be generated on an android device. I'm not sure what exactly is a "DLNA client", but the music is streamed from the server to a Yamaha device, which then outputs analog signal. I can use any device that is connected to LAN and has a browser, to control the server.

Apps on Android can't access data of other apps. Therefore you can't just read the current URL of a web browser like chrome.
If this would be possible every app with advertisements would do so and report all the URLs you are visiting in the web browser back to some ad network. As you can see such an interface would be a privacy nightmare.
Hence the only chance to get what you want to do it inside of a browser-plugin.
However I don't think that there is any browser-plugin for Chrome, Firefox or another web browser on Android that would do what you want. Hence you would have to develop your own web browser plugin (please note that development topics are off-topic on this site).

I thought that by having root we could access the intents of other apps, or something, and maybe the info about URLs could be stored in these intents, but I don't have enough knowledge yet to try to find them myself. And of course I would not like 3rd party apps analyzing my browsing history, it's enough that google does that already. And software development is over my head, but I think I had googled something about a firefox plugin that can copy the urls of open tabs, and I think android was mentioned also, so will have to try that for myself.


text:
Google Play does not install applications through OpenVPN connect
Google Play works fine as application browser, but fails to install any app when OpenVPN is active. The same problem repeats on 3 phones from different vendors.
How to investigate?

Where is the OpenVNP server located (on network level). Is the Internet freely accessible from the OpenVPN server (e.g. any deep-inspection man-in-the-middle proxies active in this network)?

Aruba.it VPS in CZ domain. I know nothing about any DPI and MITM but I have never (during 2 years) met any problems with access to any service using this server.

To answer the "How to investigate?":

Enable ADB (Android debugging) on your phone.

Go to settings -> about this phone (or similar naming) and press the "Build number" 7 times. Congratulations, you are now a developer!
Go to settings -> Developer Options. Enable "Android debugging"

Connect your phone to a PC and install adb on there.

On debian based Linux: apt-get install adb
On arch based Linux: pacman -S adb
Please see Google "How to install adb on YOUR_OS" for other Operating Systems

Open a terminal on your PC (On Windows, make sure you are in the same directory as the adb binary. You might need to replace the adb below with ./adb or ./adb.exe on Windows.)
Run adb devices to make sure your phone shows up. Confirmation on phone might be required.
Run adb shell to get a shell into your phone.
Within that shell, run logcat *:W (without the *:W for more verbosity).

You will now get a lot of log entries, the *:W shows only warnings and "worse". Without disconnecting USB or closing the shell, try to get something from the Play Store now. Watch the log window on your PC. Try to look for anything related in there.
My guess is that Google simply blocks downloads from your VPN (logcat should show this clearly), so have this workaround aswell:
Install F-Droid
F-Droid is an alternative App Store that has a lot of really nice open source applications.
But I want an app that isn't on F-Droid
Check out Yalp Store on F-droid!
I personally do not use Google services and removed everything Google from my phone. Nor do I have a Google account. Whenever I do need an application that's only on the Play Store though, I use Yalp. You don't need an account, you can browse apps just like in the Play Store and they install just as easily. It's kinda like a proxy to the Play Store. APKs are being downloaded from Google, not some fishy weird websites, so it's safe to use.
Depending on how Yalp works exactly, it might try to access the APK from Google's servers using your IP, which means it might still get blocked. But it's most certainly worth a try and might very well work!

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Root - patch/change installed application's smali code
I want to modify an existing android application, but I want to have it keep its original signature, or at least its capabilities of auto updating and using Google Play services.
I am aware of Lucky Patcher being able to be used to patch the system to disable signature verification, however, there must be another way. Lucky Patcher itself is also capable of patching installed application's code, without invalidating any checks in any way. How is this achieved?
I have also thought of a custom apk installer, ran as root, that just forces the apk install by bypassing the package manager, but I can't find the low-level install process to execute this.
Is there any good solution to modifying an installed Android application and have it still have access to Google Play Services and the like, without patching the Android system?

not possible, thats what the signature is designed for. installing apk and receiving updates from Google Play are two different things. you can install ANY apk to device (with loosened security settings, no root required)

@alecxs But Lucky Patcher does it? Do you know what causes Google Play Services to work or not work for an application then?

Google Play Store (not related to Google Play Services) identifies apps by it's signatures. the signing requires certificate (only author have it) and can therefore not be spoofed. I don't think that Lucky Patcher does recompile apks with it's original signature, i believe this is not possible per design. https://android.stackexchange.com/a/218161 Google Play Services is a core component providing all kind of APIs to give apps availbility to interact with android. if it does not work for an application, the app is outdated and needs maintenance from developer

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
8-digit password prompt only when SIM is in device (it's not the PUK)
My HTC A9 phone is asking me for an 8-digits password only when a SIM is in the device. I already tried it with the PUK of the SIM what does not work. If there is no SIM in the device, there is no password prompt and I can use the phone normally. With no SIM in the device, I did a factory reset of the phone, but nothing changed.
The password prompt says: "Network locked". Is this a SIM-locked phone?
What is going on here?

Since the PUK does not work (which usually would only be asked if the PIN has been entered wrong three times) and the prompt says "Network locked" this is most likely a SIM-Lock of the phone by the carrier.
Using a SIM from the carrier the phone is branded with you should not get this prompt and it should simply work, to use a SIM card from another carrier you will need the unlock code.
You can get this code from the carrier, most carriers charge only a very small amount or nothing at all after some period of time.

Let me explain you PUK is different thing and network locked phone is different thing.
When you enter wrong password many time your sim card is locked and it need PUK code. You can get PUK code from your sim provider. Call to customer care number and they will provide code.
But when mobile is locked then you need unlock code. When you purchase mobile on monthly installment plan. Then those mobile are network locked. For that you need to provide 1)imei number of mobile,
2) Name of sim provider and
3)Location country of phone locked. After that you will get code at your register email address. you will get detail process at my below blog.
https://mobile-cellphones.blogspot.com/2020/08/sim-unlock.html .
Now insert any sim card and start mobile. It will ask to enter code enter code you get at your email.


text:
Bluetooth headphones occasionally disconnect and immediately reconnect
I use a Huawei MediaPad X2 (GEM-701L with Android 4.3) and a couple of different Bluetooth headphones (the latest are Sony WF-1000XM3). I listen to music through the headphones and they occasionally disconnect and reconnect (maybe once every 15 minutes on average, but I cannot detect any regularity). Sometimes they go silent for a few seconds, then they say "BT disconnected", then immediately "BT connected", and the music is back; the whole episode takes maybe 10-15 seconds. Sometimes they disconnect while playing and immediately reconnect with a pause in the music of perhaps only 2-3 seconds. I read whatever I could find on the web about power settings, etc. but I believe this has nothing to do with that--again, it is completely irregular, not after a specific time. Somehow the problem must be on the Android side, for it manifests very similarly with both sets of headphones. I believe it is not a wireless signal issue, for it happens in very different settings, including sitting at the desk with less than a meter between the devices involved.
I know nothing to Bluetooth, but I tried to capture Bluetoot HCI packets in btsnoop_hci.log, waited for one such event, and I inspected the log with Wireshark. Here is, I believe, the relevant part of the log:

I believe the event in questionstarts at 1104.784603 and ends at 1104.895574, for the rest before and after looks a perfectly regular transmission. It is odd, though, because the event looks a tad too short and I do not see any sign of connection reestablished at the end of the event.
Anyway, alas, I understand nothing of the protocol. Does anyone have an idea of what might be going on or how to investigate further?
p.s.: I could not find problem descriptions on the web truly matching the problem I have. Except perhaps this one, fairly old and never answered: Bluetooth earpiece spontaneously disconnects and reconnects while talking.

I get this happening also. I get it alot between the car and the house, and house to yard. I'm attributing this to my WiFi attempts of the phone to re/dis-connect to its known node. Since I also leave on Bluetooth scanning, I believe even in a closely passing vehicle, some handshaking occurs enough to cause disruption. It's the world we live in, and I've come to accept it as a minor distraction at worst.

I am not sure what is the potential connection to WiFi, but (looking to the Bluetooth log) it does not seem to me that there is any evidence of any handshaking with any other device (and it would be surprising when I am simply sitting at home).

Nothing on a device happens "simultaneously". Every action is an interruption to all other actions. Small, unobtrusive interruptions make the device feel to the user like a lot of things happen simultaneously; all should cooperate to make a seamless experience. Depending on privilege and scope, that interruption can be small and unfelt or longer and noticeable to the user. In my case, communication interruptions are the most felt, especially background communications interrupting foreground ones.


text:
how to get battery percentage back in status bar, Android 7.1.1
I have a Samsung Galaxy J2 Pro running Android 7.1.1, and Samsung Experience version 8.5.
How do I get the battery percentage into the status bar? I am sure it was there until yesterday (unless I am going crazy) and now it has disappeared. Yes I have tried turning it off and on :)

OK, I found it myself when I had time to read through all the Settings in the manual:

tap "Settings"
tap "Display"
tap "Status Bar"
turn on "Show battery percentage"

Step 1: Tap on the Settings from the Home Screen.
Step 2: Select Smart manager
Step 3: Select Battery
Step 4: Now, you should see the option that can help you show the battery percentage.
Step 4: Turn Battery Percentage on.
Source:
https://phoneradar.com/samsung-galaxy-j2-pro-tips-tricks-faqs-options/#f

Thanks, but there is no Battery icon under Settings. Battery does appear under Settings -> Device Maintenance, but that has no "Show Battery Percentage" option.

Haha...funny how even the same android versions have different locations. Try the edited version. It should be in smart manager.

Thank you again, but I had no "Smart Manager" selection either. It was under "Display" then "Status Bar" (see my answer).


text:
Annoying overlay add
This specific add keeps popping up as overlay at random.
It's always the same Facebook Maket thing.
I'd appreciate any hint on how to get rid of it.

While that ad on screen, run adb shell dumpsys window | grep mFocused on PC. You will get the app showing that ad. Uninstall it. Report it. Blacklist it. Or whatever else you find appropriate.

@IrfanLatif mFocusedWindow=Window{ffea4e u0 com.facebook.orca/com.facebook.orca.auth.StartScreenActivity}     mFocusedApp=Token{a6af053 ActivityRecord{5bb9e8d u0 com.facebook.orca/.auth.StartScreenActivity t13163}}   mFocusedApp=AppWindowToken{7f3cd90 token=Token{a6af053 ActivityRecord{5bb9e8d u0 com.facebook.orca/.auth.StartScreenActivity t13163}}}

Hello ElmoVanKielmo. Let me know if the answers to the duplicate questions do not work for you. I hope they do and solve the issue. :-)

Thanks @Firelord - I'll check.

Yes, the issue is resolved @Firelord - it turns out it was enough to revoke unnecessary permission to show alert popup on top of other apps. And it can be done via native app manager on my Android phone as it simply lists apps with this permission enabled.

@ElmoVanKielmo Good to know. :)

First, see @Ifran Latif's comment. This is a good action for finding malicious apps.
If it's simply an ad that you want to not see anymore, there are several ad blocker apps available that can help:
AdAway
AdBlock Plus
AdGuard

So far I can say that your answer is useful, yet adb didn't show the offending app - like the overlay ad was really smart. I'm checking ad blockers provided.


text:
Re: Internal storage space
I had a LOT (100+) apps installed on an LG Stylo 3+.  Never had any problems as far as storage space (no error messages about space running out, low memory, anything like that.)  Recently I upgraded to an LG Stylo 5.  In the course of setting that one up, I installed EXACTLY the same apps, EXACTLY the same # of apps, as I had had on the 3+.  The next thing I know, the 5 is refusing to download  email and popping up messages about "not enough storage space". Both phones are supposed to have the same amount of internal storage space, so why is what worked on the 3+ too much for the 5?

Hello, and welcome to Android StackExchange! It does seem like you have a perplexing issue, but more information may be needed to help figure out what's wrong. Have you started taking more photos or downloading more music or podcasts? Could you provide info or screenshots about the storage on each device and maybe the largest apps?

Is it possible you had an SD card in the old phone...?

The new device might use more storage for preinstalled stuff (and the newer Android version possibly). You could compare the output of adb shell dumpsys diskstats of both devices (see our adb tag wiki if you don't know what ADB is and how to use it).

As Izzy has already surmised, via comment, the new device likely comes with a lot more space taken by the pre-installed apps and system data. That is what I believe is the problem. If you want to save space by stopping the default apps from updating, you can try to disable them in the apps portion of your android configuration menu, or, if that doesn't work, then this guide explains how to force disable apps using adb from a computer, though to get rid of the pre-installed versions' files, you need root.
https://www.xda-developers.com/disable-system-app-bloatware-android/


text:
How to flash custom or stock ROM with Odin mode working? (from a bad flashed Galaxy A20, see image)
The current state of the device is shown bellow.
I prefer using heimdall to flash each partition directly from command line if possible. Unless it is mandatory to put all images inside a tar and flash them at the same time.
Top left corner of the Download mode screen:

More details of the previous (and solved) problem here: question

Flashing the correct img solved the problem:
heimdall flash --RECOVERY TWRP-3.3.1.0_A20_V1.2_by_Agrim720\[Black-themed\].img.img

File was found here: XDA-forum
Device: A205GUBU4ASK2
Previously rooted with boot.img patched by magisk and vbmeta flashed:
heimdall flash --BOOT magisk_patched.img
heimdall flash --VBMETA vbmeta.img

I highly recommend to avoid Samsung devices. Motorola ones, e.g. are better for custom ROMs.
If device complains about "official binaries", bypassing KG state is needed.

However TWRP worked only the first time. After I formatted Data and restarted, the device started with puritanism about "official binaries".

I needed to bypass KG state. answer updated. thanks.

For Heimdal:
I refer to the Developers read me file for linux command line instructions:
Flashing Firmware from Command Line:
1. Fully charge your phone (use the wall charger as it's faster).

2. Download a decrypted device ROM or a Heimdall Firmware Package
   and extract everything to the one directory.

3. If the ROM is not a Heimdall Firmware Package it may instead be provided
   as multiple archives (nested or otherwise), extract them all to the same
   location.

   NOTE: If you want to use the CSC then extract it last.

4. Put your Galaxy S device into download mode and plug it in..

5. Open a terminal and navigate to the directory where you extracted
   the ROM/firmware files.

6. Type the following to list all the functionality Heimdall supports:

        heimdall help

7. Before flashing, you must first know the names of the partitions you
   wish to flash. These can be obtained by executing:

        heimdall print-pit --no-reboot

   The inclusion of --no-reboot ensures the phone will not reboot after PIT
   file has been downloaded and displayed. After executing a command with
   the --no-reboot argument, the next command should include the --resume
   argument.

   NOTE: You can still safely reboot your phone manually (with the power
         button) after executing --no-reboot commands.

8. Use the help and print-pit output to construct a command with all the
   files you want to flash.

   Here is an example that does a full flash and repartition on a GT-I9000:

        heimdall flash --repartition --resume --pit s1_odin_20100512.pit --FACTORYFS factoryfs.rfs --CACHE cache.rfs --DBDATA dbdata.rfs --IBL+PBL boot.bin --SBL Sbl.bin --PARAM param.lfs --KERNEL zImage --MODEM modem.bin

9. Heimdall will display the progress as it flashes so that you know things
   are working as they should.

How to Create a Heimdall Firmware Package:
Firstly, Heimdall's firmware package format is just a regular TAR archive
compressed with gzip. The only two real requirements are that a valid
firmware.xml must be included (refer to Appendix A) and you can only
include files (no directories, links etc.) As such if you'd like there is
nothing preventing you from creating Heimdall packages manually. Of course
Heimdall Frontend provides a simple user interface that takes care of all
the hard work for you.

There are two ways in which you can create a firmware package. You can
create a package from scratch, or you can load an existing package, apply
modifications and then save the package. Creating a package from scratch
is the preferred approach, by taking this approach you're far less likely
to run into file name length limitations.

Before you can access Heimdall Frontend's firmware creation functionality
(available from the "Create Package" tab) you must first specify which
files will be included in your package, as well as a few flashing options
i.e. Whether or not users should repartition when flashing. This
information must be filled out from the "Flash" tab in exactly the same
fashion you would provide information to flash your device (see "Performing
a Custom Flash with Heimdall Frontend"). As mentioned above, it's not the
preferred means, but you're able to load an existing package as a starting
point for this information.

Once you've specified the files/partitions you wish to include in your
firmware package the "Create Package" tab will become available. Clicking
this tab will display additional information that you can include in your
package. In order to continue you must fill out all sections except for the
URLs section, which is optional. The following is a break-down of what all
these options mean.

For Odin:
Depending on what Odin version you are using it can be slightly different. A newer Odin version it is pretty simple:
Make sure your bootloader is current with the devices firmware or updated. Check the u# within the firmware zip/tar name.
1) unpack the .zip of the official firmware.
2)  Start Odin.
3) connect your device through USB. Once connected a device should show up within the com box.
4) select AP,  within the selection go to your unpacked firmware and select the tar.md file or tar file.
Make sure you do not select/enable anything with the pit option.
5) Once loaded push the start button and let it so it's thing.
It should take a bit or got to twenty minutes or more to boot. Once booted you should be good to go with the firmware.
If you have more than just a single tar or tar.md5 file then:
1) unpack the .zip of the official firmware.
2) the zip might include a variety of things (files) such as AP,  BL, CP, CSC.
3) start Odin.
4) connect your device through USB. Once connected a device should show up within the com box.
5) select each of the different boxes and within the selection put the associated files in the correct box. The AP (system), BL (Bootloader), CP (Modem), CSC (Device Variant).
Make sure you do not select/enable anything with thepit option.
6) Once loaded push the start button and let it so it's thing.

link to heimdall support thread https://forum.xda-developers.com/showthread.php?t=755265


text:
Shortcut to change value of the developer option
My case: during day to day phone (Samsung Galaxy S7) usage I have monochromatic color space turned on from developer options in 'Simulate color space'. But sometimes I would like to turn back to normal color space. Is there possibility to create shortcut to change that option directly from main screen or at least open Developer Options on certain position?

https://play.google.com/store/apps/details?id=com.sika524.android.quickshortcut

You can open a settings page from your home screen by adding a shortcut.
Open the Widgets/Shortcuts on your launcher (I can do so by long-pressing an empty space on my home screen) and scroll down to Settings. Then tap the Settings shortcut and select the settings page you want that shortcut to open to. You will want to select Developer Options.

Also, some accessibility options are available in your Quick Settings (settings above your notifications). You may be able to edit your Quick Settings tiles to include color space (I have a Quick Setting tile named Greyscale which comes from Google's Digital Wellbeing app.


text:
What is com.coloros.safecenter?
I am using Oppo F11 Pro mobile phone. When managing my Google account, under my activities I see "Used com.coloros.safecenter".
What is that?

it's a power management taskmanager or something https://dontkillmyapp.com/oppo

This is the security center of your Oppo phone. It's a pre-installed app where you can hide your apps and photos and do much more.


text:
How to format SD card that has been formatted as internal storage for Android?
I have tried clean all command in Diskpart and it took an hour to be completed but at the end nothing has changed. I think the SD card is locked and when I try to format or re-partition the disk, either it will show a successful result or it will return "Windows was unable to complete the format" error. I have tried to format it in Linux (this answer) and Android as well but no luck. Is there a way to reuse my SD card as a portable storage?
UPDATE: GParted details when I delete the partition
GParted 0.30.0 --enable-libparted-dmraid --enable-online-resize

Libparted 3.2

Delete /dev/mmcblk0p2 (unknown, 59.46 GiB) from /dev/mmcblk0  00:00:08    ( SUCCESS )

calibrate /dev/mmcblk0p2  00:00:00    ( SUCCESS )

path: /dev/mmcblk0p2 (partition)
start: 34816
end: 124735454
size: 124700639 (59.46 GiB)
delete partition  00:00:08    ( SUCCESS )
libparted messages    ( INFO )

Input/output error during write on /dev/mmcblk0
========================================

Delete /dev/mmcblk0p1 (unknown, 16.00 MiB) from /dev/mmcblk0  00:00:01    ( SUCCESS )

calibrate /dev/mmcblk0p1  00:00:00    ( SUCCESS )

path: /dev/mmcblk0p1 (partition)
start: 2048
end: 34815
size: 32768 (16.00 MiB)
delete partition  00:00:01    ( SUCCESS )
========================================

GParted details when I try to format:
GParted 0.30.0 --enable-libparted-dmraid --enable-online-resize

Libparted 3.2

Format /dev/mmcblk0p1 as fat16  00:00:01    ( ERROR )

calibrate /dev/mmcblk0p1  00:00:00    ( SUCCESS )

path: /dev/mmcblk0p1 (partition)
start: 2048
end: 34815
size: 32768 (16.00 MiB)
clear old file system signatures in /dev/mmcblk0p1  00:00:00    ( SUCCESS )

write 512.00 KiB of zeros at byte offset 0  00:00:00    ( SUCCESS )
write 512.00 KiB of zeros at byte offset 16252928  00:00:00    ( SUCCESS )
write 4.00 KiB of zeros at byte offset 16711680  00:00:00    ( SUCCESS )
write 8.00 KiB of zeros at byte offset 16769024  00:00:00    ( SUCCESS )
flush operating system cache of /dev/mmcblk0  00:00:00    ( SUCCESS )
set partition type on /dev/mmcblk0p1  00:00:01    ( SUCCESS )

new partition type: fat16
create new fat16 file system  00:00:00    ( ERROR )

mkfs.fat -F16 -v -I '/dev/mmcblk0p1'    ( EXECUTING )

Failed to execute child process “mkfs.fat” (Input/output error)    ( ERROR )
========================================

Format /dev/mmcblk0p2 as fat32

Results for zeroing:
sudo dd if=/dev/zero of=/dev/mmcblk0 bs=8192

dd: error writing `dev/mmcblk0`: No space left on device

7795969+0 records in
7795968+0 records out
63864569856 bytes (64 GB, 59 CAB) copied, 3824.26 s, 16.7 MB/s

Results for amd64-stdtool status:
[+] Found RCA for /dev/mmcblk0: E624.
[+] Card CSD: 400E005A7B590001DED48F700R808006.
[+] Write protection state: Off.

You forgot to describe the actual problem, only that nothing has changed. Usually if you repartition and reformat the card you can simply use it.

Maybe SDCard is corrupt

@KirandeepMaan It's not corrupted. Android locks SD cards when they are formatted as internal storage.

Oh i get it, as i said if window say unable to format then there are two possibilities one is corrupt and other as you mention  locked which doesn't give permission to access its format operation and as alecxs said send some screenshots for reference to solve your matter.

windows does not allow multiple partitions on sdcard. use linux gparted (again, as you stated you already tried)

16.00 MiB is a bit small for partition, you should create new partition table and format fat32. the Input/output error may indicate physical dead (wear-out) but can also caused by linux incompatible card reader or wrong drivers

@alecxs I have not created the 16MB partition and it cannot be changed. it's ridiculous that Android is doing this to SD cards without providing any solution to recovering the SD Card. I tried this on a second SD card and the same problem occurred. So this case is not a hardware problem.

you can not delete/create partition table?

No, even after deleting the partitions the same partitions will appear again.

try sm set-force-adoptable false sm list-disks sm partition disk:123,45 public sm list-volumes all from adb shell

just linked for reference more or less relevant
problems 1, 2, 3
partitioning 4, 5, 6

@alecxs Your information is outdated. Windows 10 supports multiple partitions on SD-cards and USB sticks since AFAIK Win 10 1903.

This was possible even before Win10 with a little hack: http://www.etcwiki.org/wiki/Cfadisk_usb_driver

You may go to Settings > Storage. Then go to the more button at the top right corner. There should be an option "Format as portable". Would that work?

Thx for your answer. however, the question is about I/O errors on (new) MicroSD cards (even after zero-ing whole mmcblk0)

@alecxs most probably the card is dead. You can try using mmc-utils to get low level details e.g. Life Time Estimation and pre-EOL information. But mostly SD cards and USB thumb drives have dumb FTLs. Also many IOCTLs and CMDs don't pass through USB interface and card readers. So the symptoms determine that the card is dead.

@IrfanLatif it's not my question, but he tried this on a second SD card and the same problem occurred. there are similar unanswered questions - it sounds naiv/stupid but maybe it's true that android lock sd cards in some however way? on the other hand i aggree the best way is to get low level details and base answer on solid facts instead of speculation

i feel remembered the first day i ever heard about selinux

I think the problem is write protection.
I am currently experiencing this problem..
I initially used the sdcard as internal storage so I believe Android will put write protection in the sdcard.
To me the solution is to use Android command line or shell and run Linux command on the sdcard and remove the write protection knowing fully well that only device that encrypte the sdcard can decrypt it.


text:
Is there a way to install a imei on a samsung galaxy s9
I have a samsung Galaxy S9 that has no Imei Installed I was wondering if there is any way of boot loading or forcing a imei on to the system it is a retail phone

As far as I remember Samsung usually stores the IMEI info in some special partition called EFS. There are some tutorials online how to recover/repair such a EFS partition. Normally in all custom ROM tutorials there is a big warning that you have to backup this partition first.


text:
How to embed an Android app's data together with the app into a new apk file?
I found this Windows program to embed an Android app's data into a new apk together with the app.
https://github.com/And42/SaveToGame/releases
But it seems it uses old smali, baksmali, apktool files.
I tried with new files but it didn't make a difference.
To change the language to English, just change the first menu option and select the language as English.
If someone can test the program and see if they can get it to work, please let me know.
I tried it with a couple of apps like Kodi, but after installing the modded apk, it seems just like a regular install and doesn't restore any data or user settings. Some other apps also can't be repacked probably because of old jar files, apktool it still uses.
To use it
1) You make a backup of your app with Titanium Backup
2) Load the apk with the first button in the program
3) Load the tar.gz app data backup made with Titanium backup with the second button in the program
4) The third button creates the modded app that includes the app data.
This would be great to use to install an app with it's data on non rooted Android devices.

When installing an app with data the better way is to use adb backup and adb restore. Modifying the APK is IMHO not a good idea.


text:
Cannot connect to xfinitywifi on Google Pixel 3a
I just bought a Google Pixel 3a phone, I cannot connect to xfinitywifi. I have no problem with many other Wi-Fi.
What happened is like this:

When I tap xfinitywifi at the Wi-Fi list, I can see that it comes to the phase of acquiring an IP address.
Then it shows I need to log in to the Wi-Fi.

At this point, I encountered several different problems:

I am led to a sign-in page, wifilogin.comcast.com, but before I can finish typing user name, I am led back to the Wi-Fi list interface and it shows either "not connected" or "connected but no internet"
I am led to that sign-in page, but before I even have a chance to type, it goes back to the Wi-Fi list interface
It does not leave from the Wi-Fi list interface at all. I can see some notification at the top saying login is needed, but it does not change to that login page

At the first start of the phone, it asked me whether I want to transfer everything from my old LG phone to this phone, I did that. The LG phone connected to xfinitywifi automatically.
I tried the following:

Open the browser and go to wifilogin.comcast.com, it only gives me a blank page
Click Forget the wifi and re-connect
Power down and on
Go to setting and delete all the user credentials.

None of these works.
Any suggestion?

Did you tried to connect in safe mode?

As a work-around you could try force the login-page to appear by surfing to a HTTP only site such as http://neverssl.com.

If you go to Settings - About phone - Android version, what security patch level are you on (this should be a date)? This was a known issue with the 3A and 3A XL with wifi networks that used a separate login page, until about the December security patch. You should be on "February 5, 2020" patch level.

Using http://neverssl.com/ only works if you have a data connection.  Maybe the problem is that Private DNS is enabled?

It is an obvious Pixel bug.  I can't connect my Pixel 3XL to xfinitywifi hotspots either.  I am totally gobsmacked that Google allows such bugs to exist in perpetuity.  It is totally unbelievable that in some ways Google's stuff is trash and they don't care.
It should be noted that my provider is Google Fi.  There own stuff does work together... Unbelievable.


text:
How can my 3GB SD Card have 76GB files
What are these files in SD Card /Android/data/com.android.chrome/
And these are only in SD Card. They were never there before today. And they total above 76GB, in the attached picture only one screenshot is shown. Thanks in advance.
!

try to repair with adb shell fsck_msdos -y /dev/block/mmcblk1p1 or make backup and format. the folder can be deleted

As alecxs already mentioned the size, the defect names and the strange dates indicates a defect file system.

Thanks for you guys help. I got injured so could not thank in time. I found out that the sd card was physically damaged, so I had to buy a new one anyway. But I will definitely try to repair file system, using the commands above. Thanks once again for helping.


text:
How to hide installed app from other app?
If app has storage access, how to hide other installed app from it? App consists of files in different locations. Maybe somehow I can make them unaccessible for other app? If I didn't give root right for detecting app, the only location should be in "Android" folder?

scroll down to APPS SPACE USAGE every line with  may exist for your app, so every app with root access can look at this locations

Ok, thanks. Now I'm interested in way, how can I hide app from other app which doesn't have root access.

If app has storage access, how to hide other installed app from it?

Without root access and without any permission (including Storage), any app can getInstalledApplications for current user/profile. You need a mod like XPrivacyLua to hide apps from other apps. Or isolate apps in user profiles (see Are multiple-users protected from each other differently than apps?).

App consists of files in different locations. Maybe somehow I can make them inaccessible for other app? If I didn't give root right for detecting app, the only location should be in "Android" folder?

If I understand correctly you mean that apps private files are already inaccessible to other apps. With Storage permission granted apps can only see files created by other apps in shared storage (/sdcard and physically external SD card). So if an app creates it's private directory in /sdcard/Android/, it does indicate its presence on device. But hiding the private directory won't be helpful as explained earlier. You have to stop the app from using getInstalledApplications first.
After that, if you have to grant Storage permission because the app refuses to start otherwise, you can disable Storage access using appops:
~$ appops set <pkg> READ_EXTERNAL_STORAGE ignore
~$ appops set <pkg> WRITE_EXTERNAL_STORAGE ignore

If that doesn't work you have to go for a root solution like XPrivacyLua's BlockGuardOs.open hook or Storage Redirect (it's paid app). I've no affiliation with either. Also Scoped Storage on Android 10+ provides better storage isolation.


text:
Why I cannot grant "Allow all the time" location permission to WhatsApp?
I have a Pixel 4 and Android 10 stock. I want to share my location for a few hours with a friend using WhatsApp, but the system only offers me these options for location permission:

Allow only while the app is in use
Deny

But there is no "Allow all the time". I'm afraid that it won't work without that permission.
I guess Google removed that option for that particular application, other apps have it enabled. Is that right?
PS: I'm aware of who owns WhatsApp and their issues.

Open adb shell and execute: appops set com.whatsapp COARSE_LOCATION allow; appops set com.whatsapp FINE_LOCATION allow; appops set com.whatsapp GPS allow; pm grant com.whatsapp android.permission.ACCESS_COARSE_LOCATION; pm grant com.whatsapp android.permission.ACCESS_FINE_LOCATION

You can share it , whatsapp has managed about this features even without that permission. I am also using thePixel 2and already checked it. I didn't goes in deep about coding implementation but yes it is working even in background.

WhatsApp has seemingly stopped supporting this function. Use Google Maps instead.

So here is the problem: the latest (non-beta) WhatsApp is set up with a target platform of Android 10, but the developers failed to include a request for ACCESS_BACKGROUND_LOCATION in the manifest.xml file in the APK.
This is a problem because this is a new permission introduced in Android 10, and any app not requesting it which also targets Android 10 is assumed to not want background location access.

Well that figures. I tried @IrfanLatif 's adb shell method which simply set the permission from 'deny' to 'allow only while using the app' (I was hoping there was a background setting hidden from the UI). I contacted whatsapp they gave a number of useless unrelated templated answers, after finally showing them screenshots and asking them specifically and directly to answer my questions they end the conversation with "Unfortunately, we can't provide any comments." Yikes.


text:
OsmAnd+ Voice Navigation Not Working
I am using OsmAnd+ 3.5.5 from F-Droid on my Samsung A3 2016 running LineageOS 16 (Android 9).
It all seems to working fine, but for whatever reason the voice navigation will not work, making me have to constantly look at the directions rather than listen.
What am I missing here? Is there a way of making it speak to me?

I think I have the same problem but on regular android with the free Osmand 3.5.5 from google play. Did you check if voice output works at all under (Android) Settings -> Accessibility -> Text-to-speech output or the LineageOS equivalent?

@user2740 I checked, the output works. Just to be double safe I changed the language from 'System Language' to 'English United Kingdom', and that still worked in settings. But it still didn't work under OsmAnd+ :/

I had the same problem (I think) with the play store Osmand 3.5.5 and android 8.1. Here's what I did:

wait for Osmand 3.6 to be released.
start a new route
go to options -> Navigation settings
tap on "voice prompts" even though it is already "on". Tap on the text not the switch!
You can see a bunch of options now such as "voice guidance" which maybe defaults to "Don't use". Make sure it is set to some language.

It updated the 3.6.3 recently and what you suggested worked. Thank you :)

PicoTTS (the integrated speech synthesis tool) has been removed from LineageOS 16 due to the lack of development.
I’ve looked for an alternative, but sadly couldn’t find anything on par with PicoTTS, so I eventually resorted to installing GoogleTTS, which I must say does a pretty good job.


text:
Android fastboot device-id
I have a smartphone lg g6 i try to root it.
When i put the command adb devices the cmd show me my attached device name.
I test many adb commands all works. Finally i put adb reboot bootloader and my phone was opened in fastboot mode.
All fastboot command works just the fastboot oem commands shows me this error:failed command.
I try also fastboot oem devices-id and show me the same error.
Note: fastboot devices work and show me my device name also fastboot getvar all, fastboot oem unlock all shows me result just fastboot oem device-id didn't work. Any idea please.
Edit: After i unlock my phone all the oem option they didn't work Any idea to relock my phone.

Not on every device bootloaders include fastboot protocol in its entirety. Particularly the fatboot oem commands are very OEMs/vendors specific. Even they vary for different devices from same manufacturer. So you need to find out right commands (if they exist) for your device. Check xda forums.

https://www.xda-developers.com/how-to-discover-hidden-fastboot-commands


text:
How to create a 'Google Drive' file or folder shortcut, within Google Drive, on Android? (see body of question)
On the web application for desktop this is accomplished by navigating to the file, clicking on it, and pressing Shift + Z.
Is there a way to accomplish the same functionality on Android? Either within the Google Drive app or thru some other means?
NOTE: When I go to a file that's in multiple locations on the Google Drive app and go to: Options -> Details, then I can see all the locations the file is in, and also remove locations, but I can't seem to add locations from this menu.

Using Google Drive version 2.20.141.03.34:

Select the file(s)
Click on the 3-dot menu, then select "Add shortcut to Drive"
Select the location where the shortcut(s) should be created.

You can select the file and add to star in google drive, next time when you want to see you can directly click on starred files of folders.

Hi Mansi, this doesn't answer my question. If you read the question it says "(see body of question)". If you then read the body of the question I feel like it pretty clearly states that I'm trying to accomplish the same functionality as the shift + z shortcut on the google drive web app. Which allows me to create a short cut to a file or folder in any folder. Using the star feature doesn't accomplish that.


text:
Unable to Log into Samsung Account on Samsung S5 Neo
Entered correct email and password. Next step.
Entered correct 2-step Verification code. On pressing next, refreshes page and asks for code again. Never actually logs in.
Restart Phone ... NO FIX
Reset Password ... NO FIX

Went on my desktop and logged into samsung accounts from there, 2-step verification worked on their wekapp login portal. Then went into security settings (webapp), disabled 2-step verification, restarted the phone.
Then was able to log into Samsung Account successfully (phone).


text:
Is it possible to open new tabs/links next to current tab in Chrome?
In Chrome (or Chrome Canary), I'd like to be able to open new links/tabs next to the current tab I'm on. If this was on a PC, the equivalent would be tabs/links opened at the top of the tab tree/stack.
The best workaround I've found is selecting any piece of text on the current tab's page, then doing a "web search" from the popup context menu. This opens a tab next to the current tab, then I'll use this tab for what I was wanting to search. This doesn't work for opening links next to the current tab, however. And I'd prefer if this could be done without needing a workaround.


text:
No keyboard after reset!
I don't know how it happened but I did a factory reset on my LG g pad and it came back with no keyboard   Which means I can't pass the setup wizard because I can't type a password.  I can't go anywhere?! I didn't delete the keyboard so I am wondering what happened.  Just need help!!

you should be able to sideload apk from recovery, or connect physical keyboard with OTG


text:
What mitigation can I take for CVE-2020-0022 (aka BlueFrag)?
A vulnerability, CVE-2020-0022, was recently announced in some versions of Android. My phone, a Sony Xperia XA2, does not yet have an update available.
What should I do in the meantime?
The report suggests "Only enable Bluetooth if strictly necessary". Is it sufficient to disable by tapping the button on the "swipe-down" panel or does it require a deeper configuration change?

The report also suggests "Keep your device non-discoverable". Is it perhaps sufficient to leave discoverability switched off until an update is available? If leaving discoverability switched off was not sufficient mitigation, why would the report even mention it?

AFAIR "non-discoverable" just means that the device name ist not sent, but if there is Bluetooth traffic your device is visible to any scanner by it's MAC address. The MAC is everything you need if you want to send data to a device (or attack it).


text:
Unable to root Motorola g7 Power
I have unlocked the bootloader and enabled USB debugging. I can launch TWRP over fastboot and use the interface.
To root the phone, I tried the following:

Push the TWRP zip onto the device adb push ~/Downloads/SuperSU-v2.82-201705271822.zip /tmp
In the TWRP interface do: Install -> Add Zip -> /tmp/SuperSU-v2.82-201705271822.zip > Swipe to continue
Process finishes and Phone reboots
Open Root Checker Basic

"Sorry! Root access in not properly installed on this device. "

My goal is to be able to run su in adb shell.
What have I done wrong here?

try this tutorial just skip lineageos and gapps installation https://forum.xda-developers.com/showthread.php?t=3969341

also please note a su in shell is not really useful on isolated namespaces and selinux enforcing

SuperSU is discontinued and shouldn't work as expected on new versions of Android. You should consider using Magisk.
Flash the zip the same way you did for SuperSU. Then remember to launch magisk app and do the necessary additional installation steps.

I can confirm that Magisk worked for me


text:
How to launch a pdf from a terminal?
I gain precious time by launching pdf from the terminal in Linux
evince ~/mypdf.pdf

What is the exact command that allows me to do that on android?
This post gives the following template:
am start -a android.intent.action.MAIN -n my.domain.myApp/my.domain.myApp.myClass

*How to modify this command to launch a pdf**

I am not sure if you can starting an intent with a relative file name. Better use the absolute file name and use am start to view the file:
am start -a android.intent.action.VIEW -d file:///storage/emulated/0/mypdf.pdf -t application/pdf


text:
How to identify which app is causing the notification LED to flash?
My LG G4's notification LED has started intermittently flashing yellow for unknown reasons.
Normally, I would assume that a notification is causing it, but in this case, no notifications are present and clearing the existing ones doesn't stop the flashing. I have not (knowingly) set an app to flash either.
Is there a way to diagnose which app is causing the flashing?


text:
Is it possible to access speech-to-text audio clips for debugging?
Is there a way to access the audio clip that gets used for Google's speech-to-text transcribing?
I've been getting increasingly inaccurate output using Google's speech-to-text output. After discovering my Samsung phone has more than one microphone, I'm  wondering if perhaps this could have to do with either which microphone is getting used, and/or if there's any audio processing being applied which is affecting accuracy.
If I could debug these waveform/recordings myself, I could at least see whether the input itself is the source of the inaccuracy, or whether it's something else.

Issues relating to programming is off-topic here. You can just run any number of audio recording apps to see what is being recorded to check if there is a device problem.

https://myactivity.google.com/myactivity?restrict=vaa

https://myactivity.google.com/myactivity?restrict=vaa suggested by  alecxs
will let you access audio recordings from Google assistant but Gboard  voice typing:

Tested with  Android 12 with a Google Pixel 6.


text:
Saved WiFi passwords on Android 10
I'm trying to figure out the logic of the WifiConfigStore.xml file on Android 10.
I am rooted. I have a XML file generated by Titanium Backup, which I can import and have several hundreds of saved networks restored.
Each marked with "Saved by Titanium Backup".
If I remove TiB - all saved networks are gone.
Password viewers work, but I'm looking for a way to "mimic" TiB's behavior: export a list, then import it, without a specific app dependency (so passwords won't disappear if I remove the app).
I tried dumping the WifiConfigStore.xml after saving one network, manually adding a saved network, pushing it back and setting the permissions+owner. After a reboot - no saved passwords on my device.
Help would be appreciated

For adding new Wifi configurations Android has an API for ages. See WifiConfiguration/WifiNetworkSpecifier.Builder. Therefore from inside an app it is plain and simple.

I'm not a developer, just a user, with some more-than-average understanding...


text:
Does flashing the stock ROM repartition the device internal memory?
After I have repartitioned my tablet I wonder what would happen if I flashed the stock ROM again.

Not the usual zip files meant to be flashed in recovery mode (it is possible though). But factory firmware flashers which work at bootloader or even lower level can manipulate partitions. Starting with Android 10 even OTA updates from OEMs will be able to resize dynamic partitions inside a super partition.

A full firmware from the manufacturer can do that. You can see the flash sequence has a file similar to gpt_both or anything with GPT in the filename and is flashed to the partition partition. For example: fastboot flash partition gpt_both.bin
If there's no such file you can find, then the flash sequence is most likely not rebuilding the partition structure.


text:
Android device can't boot
I have this device Samsung A5 2016 which has not booted for a while, wanting to repair it, I went into recovery mode however no option seemed to work, recurring error which appeared: "can't find misc/", I tried to make a bootable SD card then to execute it from recovery mode, error "can't find sdcard/".
I also tried to go through Odin mode, however the device does not have USB debugging active it is not in the list of devices connected to adb, so I can do nothing on this side there.
What do you recommend ?

flash tools doesn't rely on usb-debugging, enter download mode with proper key combo and install drivers

@alecxs Can you please expand on what you said?

sorry maybe my english is not the best. Odin3 requires usb drivers installed while phone connected in download mode. but requires no adb/usb-debugging at all. download mode can be activated with combination of power + home + vol down buttons


text:
How to make a file show up in the Downloads App?
I have copied a file to the Downloads folder with the File Manager App. But when I open the Downloads App, the file doesn't show up.
The Downloads folder is definately the right one: I've deleted a file in the Downloads App and could wittness its disappearance in the Downloads folder in the File Manager App.
Does the Downloads app register downloads somehow and only shows files that have come to the Downloads folder the right way by some Downloads App standard?
Update:
I renamed a file in the Downloads folder to a filename, that already showed up in the Downloads App. That did work, I could open the file from the Downloads App.
Seems very strange to me...
My phone is a LANIX Ilium LT500 on Android 5.1.
Update 2:
Even a reboot of the phone could not make the Downloads App show all files in the Downloads folder...

Edit /data/data/com.android.providers.downloads/databases/downloads.db.

nothing strange on this behavior. the downloads app is not related to files. it's just a kind of notifications history, similar to your pc's webbrowser download history


text:
Adb restoration stopped on Zenfone 3
My goal is to backup save data of two games from my older phone, which I succeeded, and to restore them to my new phone where I have Lineage 16.0 installed.
I used the command : adb backup -apk nameoftheapp.com and then adb restore backup.ab
But as soon as I type the second command and enter the backup password on the new telephone a dialog appears with "Restoration ended".
Is there a workaround/a way to troubleshoot the issue?
Thanks a lot!!

leave the password empty on creating and restoring (this will disable backup encryption and reduce possible reasons for the fail). please read other questions in the Related section


text:
Turning on with ADB and SDK tools?
My samsung mobile is switched off with busted power button, and the "Volume down+main button with charger" process is also not working..is there a way I can restart it using adb and sdk tools??

https://android.stackexchange.com/questions/131248

download magisk manager and exact variant of boot.img to any other android device. patch boot.img with advanced - keep force encryption + keep avb/dm-verity
install Odin and drivers. flash magisk_patched.tar in AP slot. set the auto reboot option
unlock device and install magisk manager. you are rooted
edit: now modify your device for auto boot each time charger is plugged in, see Irfan Latif's answer on Automatically power on Android when the charger is connected
now dump your para partition and inspect with hex editor. if you find the off mode charge string you can modify value. flash the modified para partition. this will make your device auto boot each time charger is plugged in
if the changes aren't persistent for some reason, install some start-up script which executes the mod directly

 sed -i '0,/off-mode-charge=1/s/off-mode-charge=1/off-mode-charge=0/' $(find /dev/block -name by-name)/para

This trick should work only on devices where bootloader supports fastboot oem off-mode-charge 0. I don't know if odin provides an equivalent command or not. But many vendors don't implement this command in bootloader.

Universal way: https://android.stackexchange.com/a/221384/218526


text:
Samsung Tab A6 won't leave battery screen or turn on
I'm currently having issues turn my A6 on, in that it simply won't start up.
I have tried: Holding the Power and Volume Down button, Holding the Power button for 30 secs, changing cables, changing adapters, changing wall sockets, and trying all manner of button combinations. Unfortunately the issue still persists.
When I plug the A6 in, the battery charging screen is displayed but doesn't change or do anything. If I unplug it, the battery charging screen stays for about 5 seconds and the switches off, leaving me with a dead tablet again.
Is this something I can fix, or do I need to get a replacement?

https://android.stackexchange.com/q/221365


text:
Phone (Nexus Zenfone 5 !!MODEL ZE620KL!!) only boots into TWRP
So I unlocked my bootloader and flashed twrp, but my data was auto-encrypted so i had to perform a wipe from inside twrp. I did this and now everytime i start my phone it boots into twrp. I tried flashing a custom rom but i dont think my version of twrp has usb support since i couldnt tick the box.
So tbh im not sure if i accidentally deleted my stock version of android or if i just did something else wrong, and its very hard to find information about this since theres another phone by the exact same name (ASUS Zenfone 5) but the one I have has the model number (ZE620KL).
So yeah how do I make my phone boot into android instead of twrp everytime i turn it on.

Does the vol-up/down keys work correctly in TWRP?

they dont do anything, i dont think theyre supposed to do anything since theres a sound setting in the twrp settings

Originally a recovery ROMs were using the volume buttons for up/down navigation. That nowadays TWRP supports to use the touch screen is often a convenience function. Because if one of the volume buttons would be defect and permanently firing "I am pressed" the system may always boot into recovery even if the main OS is present. That would be one possible explanation for your problem.

you probably wiped wrong partition. fastboot boot boot.img will ignore volume keys (in case button stucks)

click on Show all and download proper version, try oldest first

ok but how do i download it only my device? adb via usb doesnt seem to be working

flash with QFIL (or what i would do: python sdat2img.py vendor.transfer.list vendor.new.dat and adb push vendor.img /dev/block/bootdevice/by-name/vendor and same for system.new.dat. adb is working in twrp. boot.img can be flashed from fastboot in download/bootloader mode directly too)

https://www.firmware27.com/2018/03/asus-zenfone-5-5z-firmware.html


text:
Called 112 (emergency) but no record in call log?
Last week I called 112 for an emergency. Later I saw that this call was not logged. In the past these calls were logged. Any ideas why this happens?

guesswork: it only appears in call logs when screen is unlocked and called from regular dialer app


text:
How can I change the default browser on MIUI 10.x?
I've read this question:
How can I change the default browser?
but the instructions there don't fit my Xiaomi phone, which has the MIUI 10 interface. How can I change the default browser there?

In your Settings application, navigate to System Applications Browser.
You get a prompt saying:

Set as default browser?
MIUI Browser is really great blah blah blah
  blah blah blah blah blah blah.
No Thanks | Set

Tap "No Thanks".
Make sure "Set as default browser" is in the off position (grayed dot, not blue dot).
Open some application with web links.
Click a web link.
You will now get the dialog for choosing the app with which to open the link.
Tap "Remember my choice" or some equivalent wording before choosing your new default browser.


text:
How to send all internet traffic to a SOCKS5 proxy server in local network?
I got the inspiration here. It looks like AFWall+ is able to create a NAT forwarding policy to keep all traffic going through a SOCKS5 proxy and fool Google apps into thinking they are not connected via a VPN (Google apps implement additional security measures when connecting via VPNService and if you are in China you will not pass the security check - the security check requests don't go through VPN, so they will EOF because GFW will kill these requests, read more here).
So my question is, if let's say I have a socks5 server running at 192.168.1.1:1088 which tunnels all connections via vmess protocol (aka V2Ray) to remote servers in the US, how do I create my custom script? I have tried:
IP6TABLES=/system/bin/ip6tables
IPTABLES=/system/bin/iptables
ULIMIT=/system/bin/ulimit
PORT=1088
SERVER=192.168.1.1
$ULIMIT -n 4096
$IP6TABLES -F
$IP6TABLES -A INPUT -j DROP
$IP6TABLES -A OUTPUT -j DROP
$IPTABLES -t nat -F OUTPUT
$IPTABLES -t nat -A OUTPUT -o lo -j RETURN
$IPTABLES -t nat -A OUTPUT -d 127.0.0.1 -j RETURN
$IPTABLES -t nat -A OUTPUT -p tcp --dport 53 -j DNAT --to-destination $SERVER:$PORT
$IPTABLES -t nat -A OUTPUT -p udp --dport 53 -j DNAT --to-destination $SERVER:$PORT
$IPTABLES -t nat -A OUTPUT -p tcp -j DNAT --to-destination $SERVER:$PORT
$IPTABLES -t nat -A OUTPUT -p udp -j DNAT --to-destination $SERVER:$PORT

This does not work. So:

Did I create a wrong script? How do I create a script that does what I want to do?
Are there other settings that I should enable first? I didn't tick any app so I assume that means all app go through custom script, right?

The link you have provided is not setting up SOCKS but a transparent proxy i.e. it takes TCP/UDP traffic and SOCKSify it before sending through shadowsocks tunnel. But you need to make your traffic SOCKS-aware before directing towards SOCKS proxy. Either configure individual apps (which have built-in support for SOCKS) or enforce proxy system-wide transparently (what you are trying to do).
LIMITATIONS OF SOCKS PROXY:

It looks like AFWall+ is able to create a NAT forwarding policy

AFWall+ uses iptables at back end and it can execute your script on network changes. Enforcing global proxy is (at least partially) possible with proxifier apps like ProxyDroid (which is iptables-based) and SocksDroid (which is VPN/routing based). I have no affiliation with either.
If manually workig from CLI, you can use a transparent TCP/UDP-to-proxy redirector like redsocks in combination with iptables. shadowsocks provides its own similar tool (ss-redir), so does Tor.

I didn't tick any app so I assume that means all app go through custom script, right?

No. The problem with the iptables approach is that SOCKS5 is a layer 5 protocol in OSI model. So it cannot carry whole traffic from all apps. Most of the traffic generated by apps is TCP which works fine with SOCKS and is easy to setup. But some games, VoIP apps and above all the traditional DNS generate UDP traffic which is not supported by many SOCKS5 proxies. E.g. openssh and tor both don't, shadowsocks however does have UDP associate features. But it doesn't work with simple DNAT or REDIRECT (probably because SO_ORIGINAL_DST is not available for UDP sockets, I don't know the details). You can possibly redirect traffic only towards a fixed socket (IP:PORT) e.g. a DNS server or game server.
TPROXY is the alternative here, but the trouble is that it works only with PREROUTING chain i.e. the traffic coming from outside, not that generated on device. So you have to do extra setup to route your on-device traffic without NATing towards a local proxy server (usually default gateway) where you'll set up TPROXY.
Complicated? That's why VPN is preferred. Even if you need to use a proxy to circumvent firewalls, VPN tunneling through proxy spares you from the traffic redirection complexities. VPN operates at lower level in network stack (L2/L3 in OSI), so it flawlessly carries all IP traffic including ICMP echos (ping) etc. which can no way be sent through SOCKS. Another plus point is that VPN can be tunneled through transparent proxies - like shapeshifter-dispatcher and stunnel - or SOCKS proxies which are meant to forward only single port - like obfs4proxy.
If not forwarding single port (tunneling), SOCKS5 must be an application level proxy i.e. it should be able to forward arbitrary ports from different apps like SSH dynamic port forwarding does.
tun2socks is another SOCKSification method which collects TCP/UDP traffic on a tun interface (same like a VPN, no NAT involved) and forwards it through a SOCKS proxy. It recently added UDP associate support. Previously used UDP Gateway method also worked quite fine but it requires running a separate daemon (udpgw) along with proxy server. tun2socks is a non-root solution because apps - like SocksDroid and many other firewalls, sniffers etc. - using this method rely on Android's VPN facilities.

... and fool Google apps into thinking they are not connected via a VPN (Google apps implement additional security measures when connecting via VPNService ...

With both above methods (VPN through tunnel and Tun-to-SOCKS) it's not necessary to use Android's VPNService API (if that's causing problems for you). On a rooted device you can get a static openvpn or tun2socks binary and run that through CLI. That's far less hassle than setting up proxy through iptables. In former case, though, you need a VPN server obviously.
SOCKSIFY WHOLE DEVICE:
As you don't want to go with VPN/routing based solution, here is the simple iptables-based method.
First get redsocks binary for your device architecture (or try this one for aarch64 or this one for armeabi-v7a).
Create configuration file:
// redsocks.conf

// general configuration
base {
    redirector = iptables;
}

// for TCP
redsocks {
    local_ip = "127.0.0.1"; local_port = "12345";
    ip = "192.168.1.1"; port = "1088"; type = socks5;
}

// for UDP, assuming your SOCKS5 proxy supports UDP associate
redudp {
    local_ip = "127.0.0.1"; local_port = "12345";
    ip = "192.168.1.1"; port = "1088";
    dest_ip = "1.1.1.1"; dest_port = "53";  /* set whatever DNS server */
}

 * See redsocks.conf.example for details and more options.
Run:
#!/system/bin/sh

IPTABLES="/system/bin/iptables -w5 -t nat"

# create new chain
$IPTABLES -N PROXY
$IPTABLES -I OUTPUT -j PROXY

# exclude local traffic, see: http://manpages.org/ss-redir
$IPTABLES -A PROXY -d 127.0.0.0/8 -j RETURN
$IPTABLES -A PROXY -d 192.168.0.0/16 -j RETURN

# socksify whole TCP traffic
$IPTABLES -A PROXY -p tcp -j DNAT --to 127.0.0.1:12345

# socksify only DNS UDP traffic
$IPTABLES -A PROXY -p udp --dport 53 -j DNAT --to 127.0.0.1:12345

echo "Ctrl^C to exit."
trap "$IPTABLES -D OUTPUT -j PROXY; $IPTABLES -F PROXY; $IPTABLES -X PROXY" EXIT

# run socksifier
redsocks -c /path/to/redsocks.conf

You can add custom iptables script to AFWall+. redsocks can be run as init service with non-root UID, dropped capabilities and restricted SELinux context. See How to run an executable on boot?

RELATED:

Why is not all traffic captured from my device when routing through proxy?
How to set up a socks5 with Android CLI?

Your redsocks + iptables solution worked but I had to correct several things to use Dante SOCKS proxy on Anbox. For the first iptables command, I got error unknown option "-w5". Adding a space before the number did not solve the problem. Anbox used Android 7 (x86) with iptables v1.4.20 and the -w parameter did not accept any value. Is this parameter necessary? I did not need to use it. Then I had to comment the iptables command for UDP, otherwise DNS would not work. In redsocks.conf, I also had to comment the redudp block because of the error file parsing error at line 13: unknown section.

@baptx for -w see iptables manpage. // UDP is officially supported by redsocks: https://github.com/darkk/redsocks/blob/master/redsocks.conf.example#L117. It doesn't work for you because your proxy doesn't have UDP associate feature. So you can't send DNS or any other UDP traffic through proxy. That's what I've explained under LIMITATIONS OF SOCKS PROXY. Please go through the answer completely for better understanding. // May be you need an empty line at .conf end: https://github.com/darkk/redsocks/issues/134

I still got the file parsing error on the redudp line, even with an empty line at the end of the config file. It looks like this configuration is not supported by the version of redsocks I am using. I downloaded the x86 build of redsocks from ProxyDroid. With redsocks -v, I can see that they are using an older version, 0.4 instead of latest 0.5.

@baptx UDP is supported since version 0.1: https://github.com/darkk/redsocks/commit/c0d4cede5a43e552017f2696d5b80dc2741e3190#diff-d64baa8264254662e7f0007c0f4fa939. But you may consider building from latest source.

@IrfanLatif how to use TPROXY instead of DNAT? here not all UDP traffic is redirected.

@hldev read the link given in the answer. Or any other TPROXY setup guide on internet.

@IrfanLatif yes, I found TPROXY can be used only from PREROUTING, so I cant route the output like you did, redsocks must run on another machine.


text:
Bypass Samsung Knox factory reset protection
I have an Android device supplied by my government for students and secured by Samsung Knox. However & unfortunately, I forgot the security pattern of the device and I want to hard reset it to access it again. But Knox prevents factory reset by all the ways :/
I have tried entering the pattern in a wrong way 20+ times but it still refuses to achieve a factory reset. I have also tried booting into Android recovery but the factory reset option says MDM disallows factory reset.
Also Google's Find My Device can't even detect the device so I can't reset it using Google's Find My Device.
And developer options are disabled by Knox too so I can't do it using adb
I know that I have made it complex but its the truth and I was wondering if someone knows any way or PC tool to hard reset without USB debugging, or a PC tool that can enable USB debugging.
I don't want to flash ROMs because they will erase Knox which I shouldn't erase :/

you misunderstand what factory reset protection does. even after successful factory reset or flashing (official) rom you won't be able to by-pass factory reset protection. bootloader is locked and device is bonded to samsung account and it's the only (official) way to use Find My Mobile

@alecxs I don't need to hack my device and I want it to continue entering the Knox organization. But I just want to hard reset because I forgot the pattern

you need to remember your samsung account and login to https://findmymobile.samsung.com there you can set temporary screen lock pattern or factory reset


text:
Corrupt weird files in Android Folder of SD Card after data transfer to PC
I had a 32GB microSD card and I transferred a few files to my computer using the SD card reader, but when I inserted it in my Samsung Galaxy Tab 4 SMT230_NU a separate folder named "Drive" was created with all my folders, all files were working fine except that the Android folder, instead of containing the data and obb folders, contained files without any format, the folder is still taking as much space as it took before but I cannot access anything

All my downloads were very important and they were in the Android folder, is there any way to recover my files?

two possible reasons: folder is encrypted, or file system is corrupt. it's not recommended to use this folder anyway. there is a Download folder by default

This has happened to me before in two different scenarios. 1: Cheap µSD cardreader corrupted the card. 2: Virus. Recovery anything you can from the card (See my tutorial here) and completely re-format it (preferably wiping it clean first). Run a few tests to see if it still works properly and if not, replace it. Scenario 1 damaged my card permanently, scenario 2 it was able to recover from.


text:
Suspicious notification from "Find My Mobile"
I just received a notification from Samsungs "Find My Mobile" service, without having triggered anything. The same thing happened to my work mate today morning.

As I almost never use my Samsung account, and never even configured this service, I assume one of the following:

Someone hijacked my Samsung account
Someone hijacked the Samsung system, affecting multiple user accounts
The responsible api call is lacking a permission check
Samsung itself did a test which went wrong

Does anyone know more about this?

I would assume that someone managed to abuse on of the APIs provided by Samsung sending this find my mobile notification to multiple users. For doing so you don't have to hijack a complete system. May be the API of Find my mobile API allows to specify a foreign user id instead of using your id from the login system.

the more interesting why this happen even to devices having Find My Mobile disabled, and would it be possible to erase all Samsung devices "unintentionally" same way?

Yes, it's rather distressing since I don't even have a Samsung account. At least it's not another Hawaiian missle test warning.

Samsung probably wanted to quickly refresh their internal user locations database ;)
https://twitter.com/SamsungHelpUK/status/1230430326687780865

@SamsungHelpUK
Recently, a notification about “Find My Mobile 1” occurred on a limited number of Galaxy devices. This was sent unintentionally during an internal test and there is no effect on your device. We apologize for any inconvenience this may have caused our customers. ^LF

http://www.google.com/search?tbm=nws&q=find+my+mobile
edit: against some news, this notification was not the result of a Samsung data breach.
https://www.sammobile.com/news/samsung-data-leaked-mystery-find-my-mobile-notification

Samsung has clarified that, while a data breach did happen around the same time, it's not related to the “Find my Mobile” notification. this technical error affected only Samsung's UK website and it only affected about 150 users in total.

related : https://www.theverge.com/2020/2/20/21145130/samsung-find-my-mobile-app-1-notification-galaxy

Hmm? By technical error, are they referring to the breach or the accidental notification?  Because my wife and I (both in the US) received the notification..  EDIT: from the article's comments, it looks like I wasn't the only one confused by the UK comment.

@Arctiic the notification was sent to all (newer) samsung devices. the data breach was limited to few users in samsung shop


text:
Recurring "Allow USB debugging?" popup during a test run
Per my work-around here ./gradlew test connectedAndroidTest erases my getFilesDir() folder, I test on two ONN tablets using a Ruby Rakefile that looks a little bit like this:
task default: [ :unit_test_and_install, :espresso_test ]

task :unit_test_and_install do
    sh './gradlew --console=verbose test installDebug installDebugAndroidTest'
end

task :espresso_test do
    devices = `adb devices`
    serial_numbers = devices.split("\n")[1..-1].map{|q| q.split("\t")[0] }

    threads = serial_numbers.map do |sn|
        Thread.new do
            sh "adb -s #{sn} shell am instrument -w -r -e package com.mycorp.myapp -e disableAnalytics true " +
                    "com.mycorp.myapp.test/androidx.test.runner.AndroidJUnitRunner | tee tests_#{sn}.txt"
        end
    end

    threads.each &:join

    serial_numbers.each do |sn|
        grop = `grep "^OK .*tests" tests_#{sn}.txt`

        if grop == ''
            sh "cat tests_#{sn}.txt"
            abort 'FAILURES on ' + sn
        end
    end

end

The problem is the adb -s WHATEVER shell am instrument line. Even though it launches the JUnit tests correctly, sometimes the tablet puts up its "Allow USB debugging?" requester. (The one that says "The computer's RSA key fingerprint is...")
The tests run whether I tap the requester or not, and it usually does not pop up. Test runs and debugging runs from Android Studio or ./gradlew don't trigger the popup. But how do I get rid of it?

does the fingerprint change each time the dialog is shown? Please note that development questions are off-topic here.

this is just initial pop up for each new host, should not happen. adb does generate new keys in .android under certain circumstances in home folder, maybe you did run your tests from different users? in any case you should grep connection state and wait for authorize in your script. if you want to skip this you need to modify devices ro.adb.secure

please stop editing this question. This is not wikipedia, Third parties should only edit a question to fix a typographical error or something


text:
Any OpenSource SOCKS proxy server for Android?
I am looking for a SOCKS proxy server I can run on my Android phone. I could only find some commercial apps, but would prefer a FOSS alternative.
It does not need to be an app: a binary I can run from adb shell would work as well, but I'd prefer it if it does not require root.

What about using ssh and it's -D option? ssh -D 8888 user@phone-ip on your PC, then use 127.0.0.1:8888 as proxy server. Tested on iOS but should work on Android aswell. (An SSH server must be installed on the phone, of course. (A FOSS one is on F-Droid))

My phone does not currently have a SSHD. I found SimpleSSHD, but it does not support SOCKS: https://f-droid.org/en/packages/org.galexander.sshd/

Argh, SimpleSSHD is what I was referring to. I'm not aware of another FOSS SSH server for android (that also supports -D).

Ohh, so you're saying that SimpleSSHD includes a SOCKS proxy server? I did not try, just read that it didn't...
Giving it a try now!

No sorry, I didn't mean to word it like that. I am absolutely unsure whether it does or doesn't have the -D option included, I can't test it right now but if it says it doesn't then that's probably true. Edit: Actually, I can try right now. Give me a second. Edit: Heh. I'll leave a full answer for you to accept. :)

Thanks for checking and for the great news. Not sure where I read it didn't support it, maybe some outdated piece of documentation.

@NanoBabo are you planning to access SOCKS on local WiFi network? Most probably your phone won't be accessible over Mobile Data: https://android.stackexchange.com/a/205807/218526

@IrfanLatif I circumvent this by using a VPN service, port forwarding is done via the VPN (to a non-standard port for security reasons, specified on ssh using -p <port>.

Use SSH!
You can use the FOSS application SimpleSSHD for this! You can get it directly from that link, the Google Play Store or using the F-droid app store on your phone.
Once setup you can connect to your device using either your LAN or WAN IP from your PC like this:
ssh -D 8899 <PHONE-IP> -p <SSD PHONE PORT>

The -D option sets up a local "dynamic" application-level port forwarding, which essentially makes ssh act like a SOCKS5 (SOCKS4 is supported as well) proxy server. SimpleSSHD will show the IP, selected port and password.
After this, you can set your proxy to 127.0.0.1:8899 on your PC. I've tested it with curl:
curl --socks5 127.0.0.1:8899 https://myip.is

And it worked! Note that I did not even need root for this, it worked as the normal android user.
Note that if you want to use your mobile network for this your cell provider might not let you connect to SSHD using the WAN IP. A VPN can circumvent this if necessary.

It performs poor with parallel TCP connections. And doesn't support UDP associate, right? So not useful with games, VoIP etc. Btw Termux does have sshd. A more clean CLI solution.

@IrfanLatif I'm not sure about the underlying techs of it, I used this solution before for rather low-bandwidth applications, but VoIP (with webcam) worked flawlessly.

Awesome! This helped me overcome the tethering blocking of my SIM card.

If you want to get a SOCKS proxy of your mobile Internet, you can connect it over USB.

Go to developer settings, enable USB debugging
Connect USB cable
Install adb. In Debian, this is sudo apt install adb
Forward the port 2222 by doing adb forward tcp:2222 tcp:2222
Start the sshd
Set up proxy by doing ssh -D 8899 127.0.0.1 -p 2222, where 8899 is the desired port of your proxy.


text:
Android stops/pauses execution of my background script?
Short version:
Why is my bash script (running in the background, started via SSHD) not running every ~30 seconds when it should? (NOTE: SSHD and the script are running as root!)

I have a script that I start using nohup bash script.sh & so that it runs in the background.
The script is supposed to check whether a specific app is connected using netstat and if not it automatically reconnects using am start and input keyevent. (This turns out to be irrelevant though).
I've noticed that even though the script should check every 30 seconds (roughly of course), sometimes it takes minutes to check. I couldn't really figure out why and it seemed completely random (note that the phone's screen is off most of the time and everything is running in the background.), so I made a testscript which is what the question should focus on for simplicity:
#!/bin/sh
while : ; do
    echo "$(date +'%Y-%m-%d %H:%M:%S')"
    sleep 30
done

That's it. Started via nohup bash script.sh & using SSHD. The script does nothing but print the current datetime and thanks to nohup writes it to a file. I left this running for a while and then wrote another script to check on the results and print the amount of seconds whenever it's above 30. Result:
134
127
115
127
88
113
116
99
110
116
54
44
70
75
62
82
94
68
429
62
81
126
144
39
467
71
62

This is from the output of a script that ran for only 4:20 hours, so quite a lot of times where execution must have been delayed, the sleep was longer than 30 seconds, or whatever is going on....
Can someone explain this? And is there a solution to this?
I suspect this might have something to do with memory or power management pausing the script but really it shouldn't happen and I would like my script to run in the background and to sleep for exactly 30 seconds and not be paused or delayed. In this testrun, the highest was 467 seconds, but the highest I've seen with the main script so far was a little over 20 minutes. This is rare, but 5-10 minutes of a delay happens a few times a day.

Android turns off some of CPUs and/or don't let apps use them when it's dozing. It's achieved through Linux kernel's Control Groups. One of the cgroups is cpuset that controls which CPU is assigned to which processes. Android creates multiple descendant cgroups in cpuset e.g. background, foreground, system-background, top-apps etc.
Apps are normally in background category which can use least no. of CPUs - usually one or two. Core native services like vold, zygote (and system_server), telephony services, and apps which run a foreground service (e.g. notification) or those exempted from Battery Optimization or those having privileges like allow-in-power-save are put in foreground group which can use CPUs even when device is in sleep mode.
So you need to add the script to foreground cgroup in order to keep it alive. From within script:
~# echo -n $$ >/dev/cpuset/foreground/tasks

Going even more aggressive, you can hold a wake lock so that device doesn't suspend:
~# echo -n my_script >/sys/power/wake_lock

Don't forget to release it (echo -n my_script >/sys/power/wake_unlock) after stopping the script.
Please note that both of these measures can adversely affect your battery performance, particularly the latter. Android's warning:

Creating and holding wake locks can have a dramatic impact on the host device's battery life

wow, my poor interim was always send input keyevent every 10 seconds. is that the same list used for battery safer in settings?

@alecxs it's partially yes. There are other factors too. Android's power management is complicated. After OEM's contribution it also becomes uncertain and frustrating. I've been thinking about explaining this topic in detail but I think that would become too much detailed. And I'm not aware of many OEM-specific things.

I was thinking about disabling the "battery optimization" in settings aswell, but I wasn't sure whether I'd have to do it for shell or SimpleSSHD, and I felt like that would have an effect on more than just my script so potentially reduce battery life too much. The first solution in your answer seems to work flawlessly with not a single >31s step so far. I'll have to watch this a bit longer but so far the battery usage seems to be pretty much the same (probably different for more complex/battery hungry scripts of course).

+1: I learned something beyond simple wakelocks today. Very nice answer.

@DeathMaskSalesman I'm honored.

I wish I could upvote an answer twice. Been running smoothly since weeks now, saving me a lot of headaches. Thanks again, and after having it running like this for weeks now I can clearly say that the battery consumption is nearly the same. I don't notice worse performance at all (again using only the first trick).


text:
How to know which App architecture is installed on my device? 32bit and 64bit
I've researched a lot about this,
found how to know if the APK is 32bit or 64bit
https://stackoverflow.com/questions/30348216/how-to-find-if-apk-is-32-bit-or-64-bit
I tried going to the developer area in my phone => process manager and still couldn't see running apps' architecture.
tried installing a couple of task manger apps too, still no luck.
I think Google play automatically detects CPU architecture and installs the correct version
https://developer.android.com/google/play/publishing/multiple-apks
https://developer.android.com/distribute/best-practices/develop/64-bit#test-64-bit-hardware
and apparently since 2019 August, Google play requires all apps to have a 64-bit version.
https://android-developers.googleblog.com/2017/12/improving-app-security-and-performance.html
but when I go to Chrome => chrome://version, it shows 32-bit
so I'm looking for a universal way to find out whether the installed app on my phone is 32bit pr 64bit.
I'm using Android 9

You can look at the output of adb shell dumpsys package and check the primaryCpuAbi – or use e.g. my tool Adebar which creates a device documentation for you, listing the architecture for each app. Unfortunately, this seems not always to be set (for several apps it is just "null" – in which case Adebar cannot show it either).

Java apps are neither 32-bit nor 64-bit: https://android.stackexchange.com/a/208132/218526 Bitness matters only if app includes prebuilt native libraries inside .apk. In this case extract the .apk (in any unzip utility) and check the binaries or .so files using e.g. file command or hexdump etc.


text:
Is it possible to boot a Android smartphone without battery with charging wire on?
Problem
The title of this post seems a funny challenge. But frankly, there are a lot of worthy points involved in this question.
If a Android phone support rapid charging. If its battery is removed, but the charging USB line is connected. Then push the power button. Is it possible to launch it normally?
My experiment
I have a Huawei Honor 9, It is nice condition phone.
I open its back closure and lift the motherboard. Then the bottom of battery exposed. I use credit card to flip the battery against glue. After that, I detach the battery wire from the motherboard.
Then, I put motherboard back and put the back closure on. I connected the charging line.
After push the power button. The boot-flash logo appears. However, this state last for a long time (much longer than normal situation).
When it told me to input password. The thing goes wrong. It indicated that several service (Google service, Huawei Service and UI) is not properly launched. When I input my password. There is only a empty screen with only background wallpaper and a notification bar.
The notification bar show there are 2% of battery. No application is able to launch.
My confusion
Is this result from the protective mechanism of Android system? (Because when battery is beyond some percent, the system will automatically turn off).
How nowadays Android smartphone determine the remaining charge in battery?
As the charging voltage is higher than the voltage in full-charge.
Is it the normal condition that the system cannot launch correctly without battery? Or it is because I might broke some part of circuit when I disassembly this smartphone?

Very related: Using Android phone without battery. Also for battery level reading: How does the Android estimate the battery level without a current sensor?

The best way to answer your last question is to reconnect the battery and see if it works normal again.


text:
I installed some other phones flash file into my phone and my phone is not booting neither detected by pc, help me
Just for experiment I installed some other phones flash file into my phone using sp flash tool, flashing that file succeeded, SP flash tool successfully flashed that file into my device...
But when I started to turn on the phone, phone is not turning on neither even screen starts up.. I do not know what happened to my phone..
My phone model is Rivo RX45 and it is made by Rivo company.. My phone processor is mediatek mt6572. Flash file that I installed was from the following page: http://fixfirmwares.com/gowin-f7-firmware-mt6572/
Now when I tried to format my device from sp flash tool, device is not detected by the pc. Help me please

you probably flashed wrong preloader now your device is hard bricked. btw the linked ROM does not even match your device specifications

what is solution sir?

preloader is required. check if preloader is visible in device manager 1st second when connected, like this. if you remove battery it should loop every 5 seconds. if you can't hear or see it, there is no hope https://youtu.be/O2XWTAYmNUo

http://www.mediafire.com/file/d1s7x6sc1x2w2qk/Rivo_RX45_MIRA.zip


text:
Automatically synchronize files between PCs and Android without Internet
I have two laptops. One has internet access while the other does not. Both laptops are in a remote location (one in the office and the other in the home). I have to download some files on a daily basis (3~7 files having 500MB~2000MB file size) for my office project and need these files in the home as well.

I do not want to re-download these files in the home, so I use the following procedure:

Download file in Office Laptop
Copy in (Android) mobile (via SHAREit App)
Paste in the home Laptop (via SHAREit App)
Delete from Mobile
Delete from Office Laptop

Is it possible to do all these steps automatically?
This means, at the end of the day (before leaving my office) I just run a script that copy (latest) files on my mobile and delete these files from the office PC; when I reached home (from mobile) I run another script, which copies these (latest) files in my home PC and delete from mobile.

Possible in multiple ways. E.g. run rclone on all of the three devices. Or run sshd/sftp server on phone and clients on both PCs. Or even simple run a FTP server on phone temporarily. With all these options you can use a local WiFi network if available. Or phone's hotspot. No internet required.


text:
How to see the boot progress messages (akin to dmesg) when booting LineageOS?
After the last OTA update my phone (OnePlus 3) seems to be stuck for about half an hour on the boot animation.
Since updates usually take ages to install, how do I know that the update process is stuck?
On my desktop I can always see dmesg message during the boot, and it is relatively easy to troubleshoot problems. Is there a tool that allows me to see the diagnostic messages while the phone is booting?

http://play.google.com/store/apps/details?id=eu.chainfire.liveboot

Finally I've managed to do that without any 3rd party addons. The key is to get boot.img, and modify the file default.prop that is living in the root folder inside the img-ramdisk.gz:
You have to do three modifications:

persist.sys.usb.config=none -> persist.sys.usb.config=mtp,adb
ro.secure=1 -> ro.secure=0
ro.adb.secure=1 -> ro.adb.secure=0

You can get the boot.img if you extract the flash image with the OS you are currently using, or by extracting it from the device directly.
After that, the adb logcat will collect the live boot messages when you connect your laptop to the phone when it boots.
With adb secure on '1', it will give you 'unauthorized' message when you attempt to adb.
ro.secure=0 allows adb to have root privileges (see more here https://android.googlesource.com/platform/system/core/+/master/adb/daemon/main.cpp)

All credits go to the IRC users LuK1337 and razorloves from the LineageOS Discord/IRC channel.

Boot progress messages on Linux PC appear on kernel console or first virtual terminal. They start appearing from bootloader stage. But your proposed solution gets the logs on USB (not framebuffer) from a userspace daemon when at least kernel, init, logd and adbd are running. If a panic occurrs before this stage, you won't get any logs. So technically it's not "akin to dmesg". // ro.secure=0 and ro.adb.secure=0 work only on debuggable builds. So this solution won't work on any stock/user ROM. // last_kmsg and pstore are more certain ways to get persistent logs from last reboot


text:
Push Empty Directories with ADB
What do I want?
I want to push some directories from my desktop to my android phone. The directories are empty, but the folder name contains important meta-data. The structure is not changeable.
What is the Issue?
If I try to push via adb, I get the following warning:
adb: warning: skipping empty directory

What have I tried?
As a workaround I could use the MTP protocol. But this protocol is not stable and crashes a lot, especially if you want to copy multiple files. I can't get it work on linux anyways, so adb seems to be the best choice.
My Questions

What is the reasoning to skip empty directories? It seems like an arbitrary (and annoying) design choice for me.
Is there a flag to NOT skip empty directories?
Is there a workaround?

I don't see a way to get around this limitation of adb in the adb source code.  The sad part is that there is already a bug ticket mentioned to change this behavior (the comment was added Nov 2015).
For pushing empty directories I would try to build a TAR archive (e.g. my.tar), and execute tar extraction on-device via adb shell providing the TAR archive via stdin:
adb shell tar xv -C /storage/emulated/0 < my.tar

If the tar files contains empty directories they will be correctly extracted on device.


text:
SSH authentication failure from 4g network
I use JuiceSSH to connect to my server via my Android device. If the device is connected via Wi-Fi, all goes smoothly. But if I connect via 4g network, then I get Authentication failure error. Why? I couldn't find any solution so far. Any help is very welcome.

Run server in debugging mode (sshd -d) and see why authentication fails.

Where is "your server" located from a network perspective? It is in your network or is it just one server on the Internet?

@Robert It's on my home network, the router is forwarding correctly and I have static IP. As I said, if I join via Wifi, whatever wifi, it connects without problem. But via 4g network not.

For example, now I am on holiday, if my android device is connected to the hotel wifi, I can ssh into my server. From 4g no.

Which mobile network provider do you use? Because the only reason for this behavior I can imagine based on your description is that your mobile network provider is blocking/redirecting SSH traffic. I would try to use a non-standard ssh port for your server instead. See if this makes a difference. Also check the ssh server log (of capture the traffic via tshark) if you really had a connection to it.

@Robert Usually, I am on Tele2, from The Netherlands. Now on Italian Vodafone, same story. Thanks for the port suggestion, I will check it up.