text:
Why do Android phones have more cores than computers?
Laptops have usually at most four cores, and dualcores are probably more common. I have recently switched from quadcore to dualcore and I can confirm there is a limited number of usecases for quadcore, even with CPU intensive tasks.
On the other hands, at mobile phones, quadcores, hexacores and octacores seem to be common. Why? What tasks can utilize them?
I understand that big.LITTLE can be a part of the answer. That is, the main benefit of so many cores is not the ability to use all of them simultaneously, but rather using a core with power consumption appropriate for the current workload. However, for example, the Snapdragon 625 has eight Cortex-A53 cores, which does not seem to be a case for big.LITTLE.
Maybe the ARM architecture has a lower point of optimal performance per watt. That is, having a single core tuned for optimal performance per watt results in a lower performance on ARM than on Intel. So, more cores are used in order to deliver the performance. This is just a hypothesis.
But even in this case, I don't see what workload can efficiently use, say, eight cores on a mobile phone. On laptops, I can imagine a few like full (non-incremental) compilation of a project. But on phones?

Games can be performance-hungry, but they usually require GPU performance rather than CPU, don't they?
Theoretically, multiple cores could speed up Android Lollipop/Marshmallow AOT compilation when installing or when upgrading (i.e., the phase “Optimizing apps 3/121”). I am, however, not sure if this can utilize multiple cores. As far as I remember the code, only one app is being compiled at a time, but maybe there is some parallelism within the compilation process itself.
Also Android 7+ could utilize multiple cores when compiling. But since it reportedly compiles when idle and charging, the benefit seems to be rather minimal. At least when one charges the phone overnight – I really don't care if it takes 30minutes or two hours in such a scenario.

As I pointed out in my answer, keep in mind that you seems to be looking at things upside down. Many core/parallel execution is the norm, is not your phone which is an anomaly for having many core, it's the PC CPU which is an anomaly.

Your question is flawed, PCs can have more cores than phones. https://www.intel.com/content/www/us/en/products/processors/core/x-series/i9-7900x.html And that's not even getting into server-class machines, which can have dozens or even hundreds of cores. (And some supercomputers get into the thousands-of-cores range.)

@JAB Sure, but I'm not talking about maximum number of cores, rather about typical number. For laptops, more than quadcores are pretty uncommon, but you could find some exception, maybe with Xeon. For mobile phones, even octacores seem to be relatively common.

"I have recently switched from quadcore to dualcore and I can confirm there is a limited number of usecases for quadcore, even with CPU intensive tasks." - Can you expand and elaborate on how you came to that conclusion?

@Abdul It comes mostly from my observations (seeing system load using htop or a similar tool) and partially from my conclusions. Even some taksk where I would expect parallelization (e.g., rendering using OpenScad) are single-core. Firefox (ESR) usually consumes at most one core. Incremental compilation – I haven't measured it, but intuitively, there is not much opportunities for finding independent tasks. (Full compilation is a different case.)

@Daniel Maybe it is there in newer versions, I have 45 ESR. Anyway, this will allow usage of multiple cores for multiple pages (and maybe pages are grouped in processes by domain, I think), not using multiple cores for one page. But maybe even this will come, as experiments with Servo suggest.

See That eight-core smartphone isn’t as fast as you think it is and the linked paper therein.

As you've already noted, the big.LITTLE combination strategy (technically, HMP, Heterogeneous Multi-Processing clusters) is the primary reason for so many (and sometimes overwhelmingly many) cores. A mobile device often runs into multiple scenarios, both heavy load and light load ones included.
An extreme consumer-class example is MediaTek's Helio X20, which has 2 performance-oriented A72 cores, 4 balanced A53 cores, plus 4 energy-efficient A35 cores. That's very flexible throughout different usage cases. However, I think 8 cores 2 clusters is usually enough.
There's also another desktop-like example, Qualcomm's Snapdragon 800 series (S 800, S 801, and S 805). There are only 4 cores of the same microarchitecture in each SoC, with 2 clocked higher and 2 clocked lower. Qualcomm made these SoCs because they were very confident of their own microarchitecture (Krait 400 and Krait 450).
For games, even if they seemingly demand GPU performance rather than CPU, they still put a heavy load on the CPU. A GPU cannot work alone without something else supplying it with data to be processed, and that's one of the major jobs that the CPU is doing while you're gaming. In most gaming cases, the GPU only renders graphics, while all other jobs like loading data, resources and assets, and calculating in-game mechanics like the system, environment and physics are done by the  CPU. You won't observe a higher frame rate if you upgrade your GPU while sticking to a low-end CPU.
A secondary reason is how Android utilizes CPU resources. Android pretty much makes their own application environment. It uses nothing but codes (and APIs) from Java, but it has its own virtual machine named Dalvik, which was later replaced by ART (API Level 21). APKs have their executable codes in a "neutral" format, much like .class files in Java. Before they're run, the codes get compiled once more into the machine's native instructions[1]. The compilation process is multi-threaded and can utilize multi-cores for a performance boost.
And when an app is running, there are several other processes and mechanics (like the Garbage Collector) that run alongside, or parallel to the app. More cores can let the supportive processes run more efficiently, as well as the main app.
1. If you use a file type identifier, you'll find that "optimized" dex files are in ELF format, while the "neutral" dex files are just in a format of their own.
Another lesser reason is that ARM cores can't work as fast as an Intel x86 chip. The Intel x86 microarchitecture can be dated back to 1976, when the Intel 8086 chip started to be designed, which means that the x86 has developed over a long time. A single modern high-end ARM Cortex-A73 core is only as powerful as an Intel Clarkdale core, taking Core i5-660 as an example (GeekBench, single-core). This is because x86 is a CISC microarchitecture while ARM is a RISC microarchitecture. You surely don't want a phone that becomes laggy with only two or so active apps. More cores will help relieve the pressure. That's why dual-core SoCs are relatively popular only on smart watches. Who needs performance on a smart watch?
Interestingly, more cores will result in less power than a single core at the same load. The relationship between CPU frequency and power consumption is more than linear, so twice the frequency will always result in demanding more than twice, or even 3x or 4x as much power, while delivering less than twice the performance (due to other resource limitations like cache). So 4 cores can easily beat a single core at the same load, providing better performance and simultaneously demanding less power.
Further Reading:

Why 8 and 10 CPU cores in smartphones are a good idea – a lesson from the kitchen
Why some phones have two quad core processors and some have similar clocked octa core. Which is better one in terms of performance?

Comments are not for extended discussion; this conversation has been moved to chat.

I remember reading or watching somewhere that the Linux kernel had originally worked on good multi-core support with a focus in supercomputers, many years ago, and these efforts proved useful "in the future" (now) for smartphones, like a kind of "accident"

This answer does not appear to actually answer the question, despite being accepted. This answer seems to be answering "Why might I want extra cores in my phone?" which is not the question at hand. It does not explain the difference between PC and Phone. The points given about why a phone may want more cores apply also to desktop computers, especially the points about gaming.

I have added the above comment back in after it got swept away with the moved-to-chat comments. My comment was not part of any "extended discussion" and was specifically about the integrity of the (non)answer at hand here. Were it actually answering the question, I would +1, but since it does not actually answer the question, it needs some appropriate content added.

The 1976 claim on x86 CPUs is somewhat misleading. ARM cores can be dated back to the Acorn RISC Machine project in 1983, only 7 years later, and in some ways being newer is an advantage, Acorn learned several things that were wrong with the development of x86 and similar CPU designs and incorporated that into ARM.

The main difference between the two now is that Intel has invested massive amounts in building CPUs that are as fast as possible to the exclusion of all else, whilst ARM focused of CPUs that are far more efficient, both in terms of power consumption per cycle, and cost.

Also RISC vs CISC has nothing to do with it, Intel CPUs run a RISCish core internally (uops). The real difference is out or order vs in order execution.

Video cards have thousands of cores. It's all up to what they are used for.

@user1937198 AFAIK there are both CPU types (in-order and out-of-order) for both ARM and x86/x64.

@Overmind Video cards are a quite different category (CPU cores are independent, the GPU “cores” you are talking about are in fact coupled threads) and designed for a quite different workload.

The x86 thing is quite ... wrong. They're superscalar chips, basic implementations would not do anywhere near as good as the classic RISC pipeline used in most ARM chips. It's also worth noting that linking cores together with super-scalar designs is VERY hard due to out of order execution and the cache hierarchy. No one knew what they were missing so there wasn't really demand for it. If you notice some of Intels newer iterations are not in the high core count chips - they're on Broadwell, this is because they discarded sync stuff - out of space.

Neither the x86 ISA nor JavaScript are intrinsically particularly suited to be fast - actually, in many respects its quite the opposite (e.g. on x86 complex, irregular instructions put pressure on the decoder, all the side effects make it hard to analyze dependencies and exploit instruction-level parallelism, having so few registers force spilling on stack; in JavaScript, having , dynamic typization and attribute lookup force many decisions to be delayed at run time).

Still, they are the fastest in their class for the same reason: some big company hired the best minds in their field and made them work hard on the problem; given enough R&D many design problems can be worked around, and the result can have better performance than designs that would be equivalent or better in their initial design.

The comment about Java is total irrelevant. Most serious compute performant apps don't use Java but native code via NDK: Games, Browser Engines, PDF renderers ... nobody is crazy enough to try this with java. Java on Android was intended what is scripting languages on desktop computers.

I was with you up through "This is because x86 is a CISC microarchitecture while ARM is a RISC microarchitecture", which has nothing to do with it. It's because the x86 throws hardware at identifying dependencies and feeding the instruction stream into multiple chip-specific pipelines as efficiently as possible -- where "as efficiently" means "to get through executing them"—with power saving a selectable secondary concern. The specific way the x86 does it is by decoding the CISC ISA to a RISC µISA and feeding that to a RISC core, then remapping the results to the CISC model on completion.

The reason is as simple as much as complicate.
The short answer is "because the mobile phone market has never been and is not driven by Intel".
The long answer is way too long to resume here, but the basic concept is that Intel has dominated the PC market for years with all means possible, to the point of paying and corrupting (and being fined for this) to have his CPUs be the first and only choice for PC manufacturers.
Having the total control of the market has allowed Intel to inflate the CPU prices while artificially deciding which features and how much processing power the users should have wanted, and if you analyse a bit Intel history you'll notice that its main strength is basically in the increase of CPUs frequency, so it mostly never tried to do something really smart or innovative; and it didn't need it, because it can just say to people "you don't need more cores, but I have this juicy new CPUs which runs 100 MHz faster". At the same time, it could sell multicore CPUs in the server market at absurdly high prices
(because servers have always needed tons of parallel power, to the point that there is a current trend in trying to realize servers that use...guess what? Hundred of your cheap phone CPUs working in parallel)
This, in turn, has reflected into the developers community which has never caught up with the importance of parallel programming, so that many if not most of the them never bothered using more than one thread at time -or, to express it in a non technical way, having their software do more than one task at time. Which, by the way, makes sense when 99% of your customers base has two cores at max. Sadly, this is had led to the legend that parallel algorithms are really difficult to implement and applies only to a small subset of problems.
Instead, finally, the mobile market has never seen Intel success; quite the contrary, actually, as it happens most of the time that Intel tries to do something different from the usual X86 architecture. So, lacking is influence and control of the market, the other CPUs producer have gone in the direction that has been the normality for ages outside the PC market: parallel computing.

Are you sure you're answering the right question?

@iBug Obviously, yes. If someone pick a white sheep and a blu sheep and ask "why the white sheep is not blu like all others shesp?" the problem the OP is facing is thinking that a white sheep is an exception, while the truth it's quite the contrary.

Hmm? I think you need more smarts to make a fast core than to make a slow core then Ctrl-C/Ctrl-V it. I remember reading about a interview where the were discussing lntel's difficulty in speeding up CPUs further and computer scientist said "I don't want more cores, I want faster cores", and the Intel guy said something like "Faster cores is what you want, but more cores is what you will get"

@iBug This answer applies to the OP's question better than the accepted answer. The accepted answer is the one that is not answering the right question.

"inflate the CPU prices artificially" -> If Intel was artificially inflating the prices, why their competition use similar priced hardware and why ARM powered computers suck so hard when compared to Intel hardware? This intel-hating is ridiculous. Making CPU's is hard. The thing that made ARM so popular among mobile devices was the big.LITTLE idea, something they conceived before Intel.

Also, I'm pretty sure it was Intel that started with the multicore thing at budget prices, with the Celeron D line. Your answer makes no sense.

Intel doesn't control the PC chip market and hasn't for many years.  And the reason chip designers shifted from faster clocks to more cores is that faster clocks were hitting some fundamental physical limitations.  More cores was a much harder problem to solve, so they put it off until it was the most cost effective way to keep increasing performance.

This answer is definitely about shesp.

This answer makes no sense. Intel is one of the chip makers in PCs. And the question is why phones have more cores than PCs. Not why phones have more cores than Intel PCs. This answer assumes Intel = PC, which is not the case.

This is more of a rant about evil Intel corporation, which IMO is not well-deserved since ARM screws independent chip makers with licenses just as well.

Intel has made shady deals that were exposed 20 years ago; at the time they had AMD and Cyrix and competitors and were trying to have a quasi monopoly.
They have some of the most advanced fabs you can find and the x86 series have been RISC cpu's internally for a long time with a decoder in front for the CISC instructions. You're giving a totally uneducated and uninformed opinion

I don't understand why this is getting so many positive responses; this doesn't answer the original question and is full of nonsense. Increasing single-thread performance has always been pursued because it easily speeds up everything. All the older single-threaded programs will get the free lunch, and multi-thread ones will benefit as well. We stopped increasing frequency because of physical limits - and even still, you need to be seriously deluded if you think that the only difference between a 486 and a Pentium 4 is the instruction clock - superscalar x86 processors are extremely ...

... complex beasts that manage to execute a legacy IA applying all kind of automagical optimizations (out of order execution/instruction-level parallelism, register renaming, branch prediction, all kind of caches, µops explosion/fusion) in an almost completely transparent manner. You simply cannot achieve this level of performance by just making a higher clocked 486. The claim that "parallel algorithms are really difficult to implement" is a legend is also completely bogus. Besides the so-called "embarrassingly parallel" problems, making parallel versions of algorithms is one of the hardest...

... challenges that we are facing, and in many cases (typically, when you need data from the previous stage of the algorithm to feed the next one) it just cannot be done, unless you have a neverending stream of data to elaborate, so you can pipeline. Besides, efficient and correct parallel programming when you have shared resource to juggle between multiple thread of execution is an extremely hard challenge on its own. Even Linus Torvalds warned against being too smart about inventing synchronization primitives, given that typically almost nobody gets it right.

There are two factors going on, one very practical and the other historical.
The practical reason is the use of mixed architectures in phones. Power consumption is critical for phones and phones spend a lot of time in modes where they require very little performance. It makes sense to have some cores optimized for minimal power consumption when little performance is needed while having some cores optimized to provide maximum performance when it's needed.
The other reason is largely historical. Until 2005 or so, desktop CPUs were all single cores. Improving desktop CPU performance consisted almost exclusively in making a core that can execute as many instructions per second as possible. Even today, so much desktop software cannot take full advantage of multiple cores that many would prefer a CPU with 4 cores over an 8 core CPU with cores 20% slower.
Getting as much performance out of a single core as possible requires huge amounts of CPU real estate. This is real estate that could otherwise be used to provide more cores. This is why Intel's newest Kaby Lake CPUs max out at 4 cores and people buy them because each core is faster than their predecessor's cores. For many, they are an upgrade even from CPUs with a higher core count.
Over time, expect to see much more desktop software fully optimized to support more cores. As that happens, the engineering tradeoffs will start to favor more cores over faster cores on desktops. While cores will almost certainly still get faster, you'll start to see people preferring an 8 core CPU over a 4 core CPU even if each core is 20% slower. Chip designers will follow the market.

It's crucial for a phone to be able to provide computational power in short bursts (we need certain apps to be fast) but to also avoid overheating (heat dissipation is much more difficult for phones than for laptops or PCs). In order to accomplish this, architects design phones to use a single core when the workload is light and provide extra cores to boost performance when it is needed. If phones were to use fewer large cores, overheating would become a problem even when the workload is fairly light.
Source: A graduate-level computer architecture course.

Truth being told, the ability to provide computational power (if that's what you mean by energy) in short bursts is crucial for desktop as well. That's why they have TurboBoost on Intel chips.

Yes, computational power is what I meant. True, all devices that can expect to have a bursty workload at some point in time (including phones and desktops) need to be able to handle it. The main difference is heat dissipation.

I agree with what you said, just wanted to point out that bursty workload is not specific to phones.

First, Java virtual machine can historically benefit from multi-core more than typical desktop software. Even if you write a single-threaded app in Java, it will run faster on a multicore because most of the garbage collector code will run alongside with your app.
Second, a lot of things are going on in the background on your phone: automatic updates, ad downloads, antivirus software, management of GSM module, etc. On a laptop, all these tasks would barely keep one core busy, but ARM cores are much less powerful, so you may want to have at least a couple of those dedicated to background tasks if you want a responsive system.
Finally, there's marketing. Not many users are capable of assessing whether they would benefit from 8 cores, but an 8-core smartphone certainly sounds more expensive than 2 or 4 core one.

I keep seeing statements along the line of "ARM cores are much less powerful" - what does that exactly mean? They have less clockspeed?

@Abdul less operations per second. x86 chips can execute several operations at once, so they outperform ARM even for the same clock speed. Check out this comparison: the top ARM chip (GT-I9100) is about 10 times slower than the top x86 chip (i7-2920XM).

Is "operations per second" synonymous with FLOPS?

@Abdul Not necessarily. In fact, aside from games and physics simulations, floating point is not used that much. Also, many ARM chips achieve decent FLOPS by crippling the precision, so it's not the one true measurement either.

Android apps don't run on Java virtual machine. They run on Dalvik VM

@LưuVĩnhPhúc Still, Davlik code is generated from Java bytecode and thus relies on the GC being there.

Background tasks like sync are IMHO mostly I/O-bound and can have low priority. GC might be an usecase, but a with concurrent GC (i.e., a GC that can keep the app running when collecting), I doubt you will typically see a benefit of more than one extra core unless GC has ti run very often. And when GC has to run very often, there is probably something wrong.

@v6ak True, but wouldn't there be a GC thread for every process? So once there are 2-3 active processes running on the phone, 4-8 cores don't look that unreasonable.

@DmitryGrigoryev Do you consider heavy GC in multiple processes as a common scenario? In fact, many background processes would probably work better with stop-the-world GC than with concurrent GC. The main drawback of stop-the-world GC is sudden hiccup, which usually doesn't matter in background processes (with few exceptions like playing music, but they are mostly handled by a native code or HW acceleration anyway). The concurrent GC has some overhead, reducing the total throughput, so it is not ideal for typical background processes.

The concurrent GC has one advantage, it uses less memory bandwith by using overall more memory. Memory bandwith is one of the real problems with ARM and smartphone technology.

The answers so far explain some facets of the problem leading to this overwhelmingly many number of CPU cores on Android phones. Read that again; Android phones. The iPhone has managed to stuck to just a couple of cores for ages and still performs much smoother than any Android flagship.
The designers of Android made a huge gamble when deciding to chose the Java programming and as a consequence the JVM as the runtime of applications. Java, due to its design principles solves the problem of needing to compile and build code for each CPU architecture before it could be run on it by sacrificing performance. Java introduces a heavyweight and bulky virtual machine usually called the JVM. The JVM actually emulates a CPU at software level to avoid the need to compile code separately for each device. Think of the JVM as a virtual CPU which has the same properties regardless of the device running it so the code need only be compiled once for the JVM and could then be run on every device. This allows manufacturers to throw any hardware they want before needing to worry about application compatibility. This also allows devices them to fill the market with both crappy low-end devices and quality high-end ones and eventually dominate it.
The JVM itself is merely a specification and people are free to develop their own JVM as long as it adheres to this spec. The original android JVM was called Dalvik. Nowadays Google has replaced that with ART.
Now what is the problem with JVM? It is a heavy piece of software which consumes a whole lot of computing resources. Add to this some other properties of the Java language such as Garbage Collection and the JVM's resource consumption simply becomes too much for a device with modest hardware power. Each application and system service open on your device is itself an instance of the ART JVM and by now you could conclude that managing them all requires some really capable hardware. Thing will get even worse when there is the need to draw user interfaces.
Each application runs on a number of Threads. Each CPU core can run only one thread at a time. Each app has one main thread on which it does the stuff related to the user interface. There could be many more threads per application for doing file access, network, etc. There are generally more apps (and system services) open than there are CPU cores and as a result there are usually much more threads than there are CPU cores. So each core has to switch between processing different threads constantly, doing a little of each one and going to next. This switching takes a lot of time for the CPU and in case of the applications being essentially JVMs, this task becomes even more exhaustive. By increasing the number of cores you simple reduce the number of applications (and therefore threads) each core needs to worry about and that increases the general performance.
Based on this explanation one could deduce that android needs powerful hardware to run smoothly. The early generations of Android devices were famous for lagging, crashing and many other unfortunate things. But over the years these problems have been mostly solved by relying on powerful hardware.
On the other hand, iOS application are compiled to native machine code and hence don't need the virtualization. The language used and the operating system are also more efficient and hence allow these devices to remain smooth without the need for some overkill chipset.

This is a nice explanation why mobile phones are much more powerful than desktops. Or aren't they?

“This allows manufacturers to throw any hardware they want before needing to worry about application compatibility.” – good point, but I am not sure if this was the intention for a system intended (originally) for cameras.

“There could be many more threads per application for doing file access, network, etc” – those are rather I/O-bound, not consuming much CPU. Sometimes, I/O is handled just by one thread, because CPU is much faster than I/O devices.

“The early generations of Android devices were famous for lagging, crashing and many other unfortunate things” – I remember running Marshmallow on such phone (Xperia Mini Pro), and I think that there are many other reasons for being slow than CPU. They run on low RAM had slower flash devices like MTD (much slower than microSD cards for some operations), older Androids had a less efficient “JVM” (which is not technically a JVM). Sure, better CPU also helps, but I would be far from such conclusion.

Also, programming style like performing I/O (or other long operations) in UI thread can make apps laggy regardless of CPU performance. AFAIK, this style is quite common in early Android apps. Such apps can be laggy even with modern phones. They will be probably less laggy, but that's more due to faster flash memories than faster CPUs or more cores.

@v6ak RAM is certainly an issue. The JVM is a very resource hungry process and having lots of RAM allows the operating system to keep as much of the application in main memory, reducing the time it takes to switch between them and etc. Also a reason behind why these Android flagships have ridiculously high amount of RAM.

@v6ak You are absolutely right. The problem is that in an Android application, everything (including services and broadcast receivers which are the operating system's messaging facilities) runs on the UI thread by default which can negatively affect performance. This is however becoming less of a problem as Google has introduced efficient threading facilities and later platform versions prohibit doing I/O on the main thread at build time.

Resuming all above, i can say that use cases of PC and phone are quite different. PC most times used in single or couple of apps (of course browser with bunch of tabs require many cpu cores, can lag even on top i-3), phones used to multitask. At least network connection, UI draw, system triggers, notifications. If you open task manager on PC there are many of processes too, but they use less than few % of cpu power even on old Core 2 duo.
4 cores is pretty cheap (MTK 65x2 was cost 1$ at start for OEM) It`s also RISK vs CISC when last lack on performance per core. Energy efficient != powerful, as we can see here. Multi-core is perfect for mobile,because no serious heavy single tread load, and multi-task aimed experience (but we can see that iPhones need less cores and RAM due to good software like in this video or others )

Many of this is often performed on laptop, too. And multitasking doesn't have to be CPU-demanding. Difference in manufacturing costs might cause some differences and might be a reason for fewer cores for lowend CPUs, but I doubt that manufacturing costs is the only reason why not all i7s have at least four cores. I believe that manufacturing costs are just a tiny fraction of price of those CPUs.

@v6ak, problem is that x86 cores is bigger and more complicated,  CPUs from intell (or amd) are just not good enough to be top model. In fact, most of them is  got blocked some parts and become junior i7 or Pentiums. ARM cores looks less tricky so not so many models arrive each year. Still true octa core was Samsung Exynos Octa 7xxx, MTK Helio X10, Latest (X30) even propose little(4).Middle(4).BIG(2) , we can her in ads that it is a 10 core processor, cheap marketing does it thing.

I think one of the main driving factors beyond a 4 or 8 (for big:little configurations) is just marketing at the moment.
One huge problem of the high core count is when you consider the size of the memory. Normally in desktop apps when you want to improve the utilization of multiple cores you need to duplicate structures and use much more memory then in a single threaded application.
This does not happen because RAM is very expensive (especially in the 2017/2018 RAM crisis situation). Marketing wants high numbers but controlling want to cut on component prices. If you see a balance which is less than 1 Gigabyte of RAM per core then you see a failed compromise.


text:
Custom boot image
I have a smartphone (Xiaomi mido) with a corrupted eMMC, but it seems I can load a boot image into it and run it. I would like to experiment with low-level programming in Rust, such as the display and camera. I found the source code for mido, but I don't understand it at all. Tons of code I don't understand. Googling without success. So that the question can be answered objectively, you can answer that what I'm doing is impossible or stupid. Can I at least run Hello World on my smartphone hardware?

Related reading: Bootloader/BIOS, flashing ROM and correlated risks. Why Android devices are more brickable than PCs?, and Why are there not generic phone OS installers?

source: Stack Exchange

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

sort: votes


text:
Can I send start command to my android phone in linux using serial command
I can't use my phone's start button, it's non-functional and in shutdown state.similar problem but can't access battery
Can I send start command using Linux USB serial communication for this?
If it's probable, which port should I use to send that start command.
Here difference in my port list.

Connected
No Connection

bsg
------------------------

cdrom
------------------------

sr0
------------------------

That is hardware specific. The only devices I know that have an active USB port when device is off are those with a Mediatek CPU/SoC.

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


text:
Phone doesn't ring or show a popup for incoming calls
My phone doesn't ring or show the on-screen popup when I receive calls. On incoming calls notification settings, it shows "~1 notification per day," so this may be related.
When I switch the preferred network type from LTE to 2G or vice versa, it rings and shows a popup only for the first call. When I make the second test call, it no longer rings or shows the popup until I change the preferred network type.
What may be the cause of this issue, and how to fix it? Is there any way I can increase the frequency of "~1 notification per day" or even unlimited?
Settings:

Mobile data: On
Do not disturb: Off
Airplane mode: Off
SIM status > Mobile network state: Connected

Incoming calls notifications:

Pop on screen: On
Sound: Chosen
Show notification dot: On

It shows "~1 notification per day"

What I've done:

Reset network settings
Re-inserted the sim card
Restarted the phone

APN settings:

Tried different settings as suggested by my phone provider

Note:

This phone is supported by my phone provider
The same SIM is working fine on another Android phone

Thank you.

Does this happen in safe mode too? If it does then it's a hardware  issue likely//If it doesn't, then an installed app could be the culprit but I don't think it's the case//You can take a backup of your important data and do a factory-reset to see if it helps. If you don't want to do that you can try automation to alert you when you get calls

Before checking in safe mode, try installing a phone app from Play Store to role out issues with phone app being used now

Thank you, beesyhams. Reinstalling the Phone app didn't fix the issue. It still occurs in safe mode, so it's like a hardware issue. But safe mode helped troubleshoot. I turned on notifications on system apps like Phone Services and Call Management. After that, it works when I set the preferred network type to 2G, but it's unstable with LTE though the phone supports LTE. I hope to avoid doing factory reset.

My phone company says the device is locked, while the seller says it's not locked. Does it make any sense that the phone lock may cause this issue? I suspect more of a hardware issue.

To me it looks like hardware issue. If you take it for repair, they will do a factory-reset. So you may as well do that and if it is fixed, you save the cost and time of repair

That makes sense. Suppose I run a factory reset, and the phone works fine. In that case, if I restore all apps and settings, is it possible to reproduce the issue?

If you restore apps one by one and check as you go along, you may be able to identify the culprit


text:
Bug in chrome app with notification slider, starts search on page
So I have this bug, I already reported it to OnePlus but didn't get any feedback.
I have a OnePlus 8T, which has a physical notification slider above the lock button on the side of the phone. This slider will put the phone in silent, vibrate, or sound-on mode. The bug is that whenever I do this when I'm in the google chrome app, it will start a search on page.
Is this a bug that people know about? Is it a feature? Any ideas what it could be?
I provided a screenshot below to show what I mean. Sorry for the dutch, but as you can see it started a "search on page" when on the right you see that it also switched to vibration mode

This appears that Chrome tries to overlay a Search operation via a hardware operation, and then pass the control to the hardware layer for its proper operation, too. Search the Chrome options for shortcuts, gestures, something like that, to switch it off if possible.

According to the Oneplus community post, looks like it's possible to customize the alert slider: "There’s also ways to customize it teeny bit as well. From the settings menu go to (Buttons & Gestures) then tap on (Alert slider) You can adjust each of the 3 triggers there are a few options you can toggle on and off. One thing that persists however through all 3 settings is the alarm." Could you try checking it?


text:
Recover pending WhatsApp messages sent to old phone number
I have WhatsApp on my Android phone. I changed from number A to number B and did not notify contacts. Later, some contacts told me that they had sent me messages on WhatsApp to phone number A, and I did not receive them. They see the messages as having only one tick, which means that they are on WhatsApp's servers. I would like to recover those pending messages, especially from the other contacts who didn't tell me that they had sent messages.
I changed the number on the WhatsApp app back to number A, but still, those messages do not appear on the phone.
Does the encryption key change when I change numbers? If so, those messages are indecipherable, even if the WhatsApp server does send them.
If not, has anyone managed to recover pending messages?
Note: this question is different from Will I receive pending messages after I reactivate my account on new phone? because the action is reversible (I can change phone numbers) and I know that the top answer does not work (I have pending messages that I did not receive).

"I tried changing the number on the phone back to number A" does this mean you have switched SIM card or does this mean you have reconfigured Whatsapp to use the old number?

Thanks @Robert. I reconfigured WhatsApp and I edited the question.


text:
Check what website is my app displaying. It was created with appcreator24
I have an app that is basically a container of a browser opening a website but I am unable to see what website it is so I can open it through a normal browser.
I have tried to trap the network traffic but haven't found a way to do so, and extracting the apk has given me too much files to check. Any ideas?

Could you link the app? Also, if you turn off the internet, does it stop loading?

I can't since it has personal information, but It does not load anything without internet, not even the interface, so I'm 100% positive it's a sanboxed browser

Usually such generated apps have fixed code and load the start URL from a configuration file. Unpack the APK, delete the dex files and make a full text search tool searching for https:// assuming the site you configured is a https site or even longer parts of the URL that should be used. May be you find the URL, then you know the file.


text:
CM12 app install/reboot issue
I've installed CyanogenMod 12.1 (stable branch: cm-12.1-20151117-SNAPSHOT-YOG7DAO1K9) on my phone (MotoX, 1st gen) using Clockwork Recovery, including the version of OpenGApps recommended on CM wiki, and SuperSU.  There are three issues i've noticed - putting them all here in case they're related...

App install from Play Store triggers soft reboot
Android is upgrading, Starting apps message on every boot
Can't copy files to device: The device has either stopped responding or has been disconnected

I've searched around but advice seems pretty thin.
UPDATE: I've checked adb logcat during install, and found that this seems to happen shortly prior to reboot:
F/PackageManager( 5905): java.io.FileNotFoundException: /data/system/users/0/package-restrictions.xml: open failed: ENOENT (No such file or directory)
Having checked for the file I can confirm it's not there. Is there a replacement I can add in order to resolve this? I've noticed that any new users created do have this file, though it doesn't seem possible to copy it across, even with root.
UPDATE2: Somehow i have files located in /data/media/0/0/0/0/0/clockworkmod: .recovery_version and philz-touch_6.sav
When I format in preparation for reinstall these files cannot be removed. I've also tried using root and adb shell to delete with no success. As a result apps seem to persist across OS reinstalls.
I think the best thing to try now is a manual reformat of the data partition...

Thanks.  Yes I used the version recommended on the CM wiki: OpenGApps.
CGApps is also linked, so maybe worth trying that.
Is it ok to just install one over the other, or is there a method to remove it first?

@Izzy The Open GApps FAQ says that only TWRP recovery is officially supported, though I had issues with it when flashing CM, so would prefer to stick with CWM.  I also found this in the details txt file: APK contains a new Google certificate not yet available in the keystore, please contact Open GApps maintainer to get it included - so maybe there's a key i need to install?

Haven't checked myself in a while (no longer using GApps), but as far as I've heard the packages do a removal first. If you want to be on the safe side, wipe and flash CM again before installing a different GApps package. Not sure about the certificate thing, but that might indeed be the cause of a crash (though not of a reboot).

I think it might be related to package-restrictions.xml (updated in question), but I've been unable to create a new one in that directory. If I create a new user everything seems to be in the right place though, so maybe a complete reset is the way to go.

That file missing shouldn't be the cause of a reboot. If it's not found, it should simply be created (see here and here for some background). Though I wonder why it was not created to start with, as it should include details of all packages (whether they're enabled/disabled, default app, etc.). I'd expect it to be created at the first startup automatically. Note that except from package manager, only root can access that file.

I seem to have all these issues resolved now.
Firstly I forced a format of my data partition, by flashing TWRP, switching the filesystem for /data to ext4, and then switching back to f2fs. This means that instead of just deleting files as it tends to do during a wipe it has to recreate the entire filesystem, removing those troublesome files from before in the process.
I then pushed CM12, OpenGApps and SuperSU zip files over adb to the data partition, before re-flashing CWM and installing them.
Boot into CM12 and everything works!
.recovery_version and philz-touch_6.sav have returned, this time to /data/media/0/0/clockworkmod but as I've already formatted by this point, they don't seem to be causing any problems.
Thanks to @Izzy and @Kshitij for their help.

I'm writing this here because I am unable to comment.

You could try a clean install i.e. wipe system, data, cache
partitions and flash ROM & GApps packages.
OpenGApps recommends that you flash OpenGApps package right after you
flash the ROM without any reboots in between
https://github.com/opengapps/opengapps/wiki/Notes-for-Android-6.0 (I
know this is for 6.0 but it might be applicable to previous versions
as well)
You could try posting your logs in the OpenGApps XDA Forum link given on
their FAQ page
https://github.com/opengapps/opengapps/wiki/FAQ#2-im-having-a-problem-with-my-open-gapps-install-what-information-do-you-need-to-help-me

Hi, thanks for the input! I'm actually trying to do that at the moment, but the factory reset won't complete properly (fails to format data) due to the files mentioned in Update2 above.  I'm currently looking into manually formatting the partiton,  but so far have some up with little to nothing...

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


text:
Phone doesn't charge via USB while on
I'm trying to figure out a charging issue with my Nexus 6 (Marshmallow 6.0.1).
While I'm in Windows (10) and the phone is on, it won't charge over USB. If I turn off the phone it charges via USB. If I'm in post or the BIOS of my computer the phone charges via USB while on.
I tried the same with a Nexus 5 and it charges while in Windows as expected.
The mobo is an Asus Z170-A. I didn't see any USB power option in the BIOS.
I've updated to the latest version

@beeshyams The 6P is Type C, this is the 6 it's just a micros USB port. I'm on Marshmallow 6.0.1.

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


text:
Adware keeps installing itself
I have somehow got my phone infected with an adware by the name 'Android Communication Sync' ('com.foreign.provider').
It isn't visible in the apps browser (doesn't have any icon) and causes ads to occassionally display out of nowhere.
I have tried to uninstall it multiple times, but everytime I find it installed on my phone after a few days (it appears in Settings -> Apps -> Downloaded).
My current solution is to disable (freeze) it, so that it atleast doesn't disturb with me ads.
How can I remove it and prevent it from getting installed again?
My phone is a rooted Micromax Unite 2 (Micromax A106) running Android 4.4.2. As far as I remember, I haven't installed any app outside of Google Play Store except Adaway.
Here is its apk I exported using Link2SD.

It could be that some other app you installed might be installing this app as an add-on. So no matter how many times you force remove it, as long as the "mother" app is there, it will still re-download it. That's one theory. Try uninstalling those recent apps that you might've installed one at a time to narrow down on the culprit.

@blueren Is it possible for an app hosted on the Play Store to do such thing? Doesn't Google filter these kinds of malware out?

You never know. Something similar came up here. Not entirely informative though.

Root your device and remove the file
'/system/bin/fotabinder' using root explorer.
Then uninstall the App Android Communication sync. This would break your OTA updates though.
Recommend you to update your firmware or Flash with a new ROM

It is possible for adware, as well as other "viruses" to be installed on the sd card. Thus even doing a factory reset can reinstall the "virus". If you have access to a pc with virus protection on it. You can mount the phone as a USB storage and scan it from there. Besides wiping both the phone and the sd card. There may not be a permanent fix. But if you are able to locate the file and delete it from there. That may fix it.


text:
Very low to no volume after upgrade to 6.0 marshmellow
I recently upgraded to 6.0 and since then I have had very quiet volume on calls and even when listening to music.
I have everything turned up to maximum but still very quiet like it is on low.
Has anyone experienced or heard anything like this or know of some ways on how to fix this and make the volume louder?
I am also running a Droid Turbo 2.

Tried the Windows approach already (reboot the device)? Next steps which cannot hurt, but for crazy reasons sometimes help: Cleared cache from recovery? I had a comparable issue once, and strangely it got fixed by a simple reboot. Worth a try at least :)

Yea, I tried the windows thing. I'll have to look up how to clear cache from recovery. Not sure what that is or does.

Good call @Izzy

Ah, the usual trick when in doubt and finding no other solution :) Glad to read you've fixed it, enjoy! And thanks for self-answering (+1)

I have the same issue on my Samsung Note 4 - after update to 6.0.01 I hardly can hear people. Wiping change doesn't help.

@Shrike it might be a glitched or bad update. I spent a month debugging this issue and eventually called and asked for a free phone replacement. I've also since then keep telling my phone to not update.

I eventually fixed this issue with another phone replacement in the end. Apparently, it was either a glitched update or something. I opted for a free phone replacement and I've not had issues since.

Fixed it.
You do need to go in and delete the cache after an update. Everything sounds correct now.
Get into bootloader

Power off phone
Press and hold Vol down , press power button until you seebootloader
(3 happy androids on skateboards at bottom of page). Release vol
down.

Open Recovery

Select Recovery by using vol down, press Power to select.
Wait. This takes a while.
You will now see a screen with a picture of a phone with a red
exclamation mark on it. Press in power button, keep it pressed, and
press volume up button shortly (do not keep it pressed). Release
power button.
You will now see a menu with yellow text on-top of it.
Select Wipe Cache partition with vol down. Press Power to select.
Now it wipes the cache partition. Done!
It should now have marked Reboot system now. Press Power to select.
Phone will now reboot to normal mode.


text:
I can't disable Parental Control on Google Play Store
Since I transfer my daughter's data from Redmi Note 8T to Samsung A52 4G I noticed that in the Google Play Store the Parental Control has been activated and I cannot disabled it at all.
I already tried all the procedure found in the web (clear Play Store's data, delete Google account and restore it back, perform a factory reset) but no of them seem to work.
Does someone else get the same issue and know how I can solve?
Maybe some settings in the Google account that I forget to check.
(My daughter is 18 year old, so I can't really understand why the Parental Control has been activated)
Here is a short video showing the issue:
https://youtu.be/_5wB4xaAwXc

I found out there is a procedure to verify the age on Google account:
https://myaccount.google.com/age-verification
After verification, the Parental Control switched off automatically!

In my case, I just had to restart the tablet after disabling the parental controls.


text:
Unable to access my data on the same device on which I mistakenly selected SD card to be used as adoptable internal storage
Currently using pixel experience rom based on Android 12, by mistake selected sd card as adoptable internal storage and migrated my data   - Esp Images & videos- to adopted sd card. And then foolishly removed and reinserted my sd card multiple times without selecting 'Eject' or 'Unmount'. Now I am unable to access my photos & videos even on the device in which the sd card was encrypted and used as adopted storage let alone reading the sd card data on computer or any other device. In the same device I can only see the thumbnails of around only 20-30% of photos & videos and when selecting those photos/files individually the photo/file appears blurry & just keeps loading and the rest 70% files/photos, when opened, display the error 'could not open file'. I have not factory reset my device or erased any of internal storage which means the key to decrypt is still inside internal storage but my device is not rooted. Can someone please help me out so that I am able to access my data/ precious memories?? I'd really appreciate any help to solve this problem and get me out of this stressed out situation.

Honestly it sounds to me like you the SD card is corrupt or failing... I would connect your phone to a PC via USB and copy the data off the card as soon as possible. These issues have a tendency to escalate until the entire thing is inaccessible. The likelihood of being able to recover these photos/videos is slim since this is an encrypted volume. The alternative would be to put the card in a card reader in a Linux PC and use the process of recovery since you have an unlocked/rooted device already and can access the decryption key.

I have copied all data esp Media- photos& videos on my computer but the data was neither readable on the mobile device nor it is readable on the PC. And now I have formatted the MicroSD card to be used as a portable storage but the card is displaying an error of currupt SD card. So I again turned the formatted card as Transportable internal storage because no media was left in the device so nothing shifted into Transportable storage except some system files. My Nokia 6.1+ has an unlocked Bootloader but is not Rooted. Is there any way to make the backed up data on my PC readable by Rooting????

I copied some files/photos from the backed up data on PC to this Transportable internal Storage in the hope that may be it becomes readable but it is still not readable. I have only formatted the Sd card but have not formatted/ not factory reset my Phone internal storage which is hopefully still containing the key to decrypt the data. After Rooting the device, is there a way to make my data readable by using the key??? Do I still have a chance left to access my data?? I don't know how to read the key & use it to decrypt data.Can someone help me out with this situation??

Let me get this straight... You copied the data off, then formatted the card, then formatted it back to adopted storage? If that is correct, you are totally screwed if you didn't get the key off the phone before you formatted the card and readopted it, because a new key is generated every time storage is adopted, the original key would be overwritten and it is gone. That said, the device is telling you the card is bad, THROW IT AWAY AND GET A NEW ONE!

Does this answer your question? Can't access my phone memory suddenly after using SD card as internal memory

I am a noob when it comes to technical matters so pardon me if questions are a bit silly.

If I patch the boot.img using Magisk, would I get access to the decryption key??? As u said that since I formatted the Sd card as portable and adoptable storage multiple times & then repeated the same again on another Sd card multiple times, the Original Key was overwritten on. Can the Final Key Decrypt the Data encrypted the 1 St time??? Can we somehow get the 1st original key using the Final Key ????

I am ready to give remote access.Can I get someone online who can do this process for me? Or atleast give me Instructions in layman terms so that I can 1st Root device and be able to read the Final Key. Then using that Final key keys how to decipher the original key for decryption!

If I manage to find the key / different keys . Then how to use the key to Read the backed up data stored on my PC? Can I make it readable somehow on the PC or have to do it in Android? If on Android, with the help of key  how to do it?

I don't have that corrupt sd card anymore. Have already returned it and got a new one. All I have is the Key/keys stored in my android system internal storage & the backed up data on my PC!

I now have Root access on the device. Can you tell me how to find this /data/misc/vold folder and read the Key/Keys & then make the backed up data on my PC readable??

use current SD Card and follow the linked steps for exercise to get a feeling how things work. all your questions will be answered during this homework (spoiler: it's pointless)


text:
Finding Decryption Key and how to use it to decrypt
Nokia 6.1+ device using pixel experience ROM based on Android 12.

Adopted SD card as internal storage and removed it without 'Eject'.
Afterwards couldn't read the data even on the device itself.
Copied the encrypted data ( mainly images and videos) to my PC.
Tried to make the data readable again, copied and pasted the data to another 2nd SD card by adopting it as internal storage, didn't work.
Adopted it as Portable storage as well. Could not read the data any way.
I Adopted 2nd sd card as Portable and internal storage multiple times but neither formatted nor "Forget" the 1st SD card

1 - Does the device store separate Keys for different sd cards when they're adopted as internal storage?

Can the Original 1st key still be inside the device system files as I didn't format or changed any system files?

If just one latest key is present inside the device, could this key decrypt my data which was 1st encrypted??

Could this last key be used to deduce the 1st key ?

I have Root access on my device and Encrypted data on my PC.
Using CX file manager can access data/misc/vold folder which contains the decryption key
But those KEYS inside are not being read by my android device.

How to access and Read the decryption Key(s)?

Then Can I copy and paste the Vold folder and save the keys on PC?

How to read and then use the decryption key to decrypt the encrypted data stored on my PC?

Thanks

Does this answer your question? How to decrypt Adopted Storage?

Please read What should I do if no one answers my question?. Sorry, I'm going to close all your previous questions as a dupe to this question because asking the same question multiple times is discouraged. Please continue the progress on this question so that the info is centralized to help potential answerers. The fact that no one has answered probably means that they don't know the solution, or it's otherwise a really difficult/impossible task, so please be patient. Thanks for your understanding, I really hope for the best outcome.

This seems like a bug in your custom ROM. File based encryption is static whose keys are within the device at secure place so removing the adoptable storage and putting back in is like powering off your phone and turning it on once again. FBE keys for adoptable storage are tied to its GUID which doesn't change. Can you read data which is on your phone?

No the data (mainly images & videos) is not readable in the device. As I said, I removed the adopted SD card without 'EJECT' and Data/Misc/Vold can be accessed as I hv root access. There are multiple .key folders inside it but they are not being read on Android.

The ROM has corrupted your filesystem. Removing the adopted storage without ejection does not corrupt the data. It works once again after reinserting the storage. Your filesystem cannot be repaired because what data block is causing the ROM to not recognize your filesystem is not known. Once you know the error with experiments, you will be able to fix it. Try analyzing the raw filesystem metadata with some tools.

According to your other questions, what you want is decrypting adoptable storage on FBE file encryption.
Nobody knows and nobody will answer. All the information is outdated, it's all about FDE block device encryption.

Let us continue this discussion in chat.


text:
Duplicate app names in battery optimization list
While troubleshooting a problem with the stock Android Phone app, I was thinking to let the phone app bypass battery optimization and see if that made any difference.  I notice that in the battery optimization list there are two listings for "Phone" with similar blue handset icons in the battery optimization list (as well as one with a green robot icon, and a "Phone Services" and "Phone and Messaging Storage" and "Call Management" all with similar blue handset icons).
Why do I have the apparent duplicate Phone app (with similar, not identical, icons) and how do I find out what the other, phone-related apps do?
I have UNrooted Android 7.0 Nougat on a Motorola Droid Turbo 2.
FWIW, I also see duplicate entries (including identical icons) for "Motorola Settings", "Photos" (with Google Photos icon), and "Setup Wizard".
Thanks,
Rebeccah

If the reboot while ringing happens every time connect the phone to a charger and make it ring. If it does not reboot with a charger connected it is not a software problem but a hardware (battery).

It doesn't reboot while ringing.  After I notice that it doesn't ring when called, if I reboot the phone, AND if I hear the normal music when the phone reboots, then it once again rings when called.  Sometimes when I reboot, it reboots silently, and in that case, the phone won't ring either.
I can try plugging the phone in as soon as I notice it's not ringing and test it, but I have noticed that once it stops ringing, the only way to get it to ring again is reboot (as many times as it takes to get a normal reboot with sound).
Rebeccah

Anyway, I have a different question posted about the ringing failure.  This one is about the duplicate app entries in the Battery Optimization list.  I will update the post to be more clear.


text:
Permission denied on android directories?
Forgive my newness...  I've installed Android Studio/Android SDK in Windows 7, enabled debugging on my Droid Turbo 2 with Android 7.0, system version 25.216.2.kinzie_verizon.verizon.en.US, and successfully attached my device.  I've successfully made a backup (haven't tried restoring it), but of course it's a compressed file.  So now I want to browse my phone's directory structure.  So I opened a shell and tried to navigate around with ls and cd, but I see a lot of directories are giving me Permission denied.
Is there anything I can do about this?
Edited to add:  I was particularly interested in having a non-cloud method of backing up my contacts, sms history, and call history.  Normally, I periodically connect the phone to my PC via USB and just copy everything in Windows Explorer.  But, as I discovered when I moved to another phone yesterday that already had some of my contacts on it, the contacts file is not accessible to this method of backing up.  Verizon made a hodgpodge out of old and new contacts information which is going to take me another hour or two to sort through.  It would have been easier if I could have just restored this file.
I'd rather not root my phone if I don't have to, and from everything I've read, there is no root discovered for the Droid Turbo 2 anyway.

So you are using adb shell right? In Android the adb user has limited permissions therefore you can't access certain directories. Only on rooted devices you can get access to every directory.

Thanks.  So I would have to root my phone, then.  Sigh.

Rooting is the fastest way to access everything. However for some files there are workarounds known. You should explicitly write what you want to access.

You can make use of some apps (like SMS Backup & Restore, Termux etc.) which can backup contacts, messages and call history by getting data through Android API's (instead of directly reading files from filesystem what you are trying to do) in some kind of text format (json, xml etc.). Then you can copy the backed up files wherever you want (also by automating the backup by scheduling tasks). Restoring the data would also be easy this way (e.g. you can merge or append files) as compared to if you backup the contacts / messages / call history in SQLite database file (not accessible without root)

Thanks, Irfan - I'll take a look at those.


text:
How to capture downloading address of downloading file?
I am downloading the file in PC browser so I can easily capture the download link by entering into Downloads Tab & click "copy link address"
In Android, I know by long press on Download button, it gives menu so I can use "copy link address" to capture the address.
but not all sites display download address in Download tab, I mean Link address of download button & downloading file are not same.
so How to capture downloading address in androids OS?
Android OS is 4.2.2
Browser: chrome 30.0.1599.82

@OP You can try some Download Managers like ADM which can capture download links..

Better choice for you is try to install third-party download manager, I recommend Loader Droid https://play.google.com/store/apps/details?id=org.zloy.android.downloader

Loader Droid capture links by Share menu

I installed it, but it is not catching downloads like IDM does?

You should be able to press and hold on the download button, then press "copy link address" or something similar to that.


text:
Open gapps crashing, no GSF id available on LineageOS 15.1
I just installed LineageOS 15.1 on my Galaxy Note 4 (SM910F) via TWRP, everything worked out nicely. Now I wanted to add the Gapps to the system in order to use the playstore. I downloaded the zip file from https://opengapps.org/ (ARM/Android 8.1/pico) and installed it with TWRP. After a reboot I keep getting messages that Google Play services repeatedly crashed, about every 10 seconds or so.
After some searching I found out that Google started blocking uncertified devices from using the service, but that there is a way to whitelist your "custom device" by submitting your Google Service Framework ID to Google. To get this GSF ID, I tried the commands given on the page (www.google.com/android/uncertified):
$ adb root
$ adb shell 'sqlite3 /data/data/com.google.android.gsf/databases/gservices.db "select * from main where name = \"android_id\";"'

But this did not work, no ID was found, neither via adb as above, nor in a local root shell directly on the phone. I then tried to read out the ID by using an app called "Device ID" (as described here), but this app also did not manage to get the GSF ID, the field was blank.
I already wiped the phone and retried the procedure with another gapps package (the "micro" variant), but I ran into the same problem.
Is there something I can do? I would love to use LineageOS, but unfortunately I still do need the Playstore and I really do not want to go back to the stock Android 6.

According to LineageOS Wiki, you have to flash gapps before rebooting into LOS for the first time. Have you done that?


text:
Is it possible to switch to a new phone with all data?
How do I switch to a new phone transferring all data (without root access)?
All data means (at most):

Files and folders (including some hidden files, like browser's cookies)
Apps and their data
Settings and app permissions

Not possible ......

@beeshyams, Is there any chance that any cell phone company (including Google) will add this feature?

I have heard of some Chinese OEMs having this feature but also that they discontinued it.  It's very unlikely that it will be added, given that Google backup service is felt sufficient (for me it's crappy)

@beeshyams, please answer this question with the most complete data switch method (not all data, but most)

OEMs provide D2D transfer apps comment329712

@alecxs, but non-system apps don't have enough access to most of the data I mentioned, right?


text:
I can't select app from from Personal profile
I have installed the Poweramp app

in my Personal profile via Play Store. However, when I try to add a Music folder, I can only select folders from my work profile

the following toast appears: You're using this app on your work profile.

Build number: 939
Android 11
RedMagic OS V4.5

The toast message indicated that it's installed on the work profile. Just to be sure that you installed this app from your personal Play Store, not your work profile's Play Store? Usually, there's a small icon indicating work profile apps

Hi @AndrewT.,  My Personal and Work profile have different Google Accounts. I already tried reinstalling the app in my Personal profile. I have uploaded an image above showing it's not installed in the Work profile.


text:
Using a VPN Server on Android device in order to perform remote vulnerability scan
I am working on an Android Java application that performs a vulnerability scan of the network where the mobile device is. Since I cannot install any type of vulnerability scan tool on Android I would like to send the vulnerability scan packets from a back-end server (running open-vas) to my android device and then make the android device forward them to the destination hosts inside his network. The easiest way to do that would be to create a VPN Server on the android device, but I don't think it's possible with the VpnService APIs. From what I have found it looks like someone managed to forward traffic with VPN Service: Android VpnService - How to forward intercepted internet traffic.
Another idea was to create a sort of packet wrapping: I can wrap the original packet coming from the back-end server inside a standard TCP packet, send it to the android device, unwrap it and forward it to the host inside the device's network. Although I don't know if this would really work in my case for 2 main reasons:

I will probably receive RAW packets from the server (since vulnerability scanners forges specific RAW packets for vulnerability testing) and Java does not have any support for manipulating packets
Even if I am able to unwrap the packet I will still have a RAW
packet to send and from what I have seen Java does not have any
support for RAW sockets for security reasons.

So do you guys have an idea if there is a way to create a VPN Server on Android to do this remote vulnerability scan?
Thanks!
PS Maybe rooting the device will give some more alternatives but I am reserving this as last chance.

Package unwrapping on application layer is equivalent to creating the packages and sending it. If you can't forge arbitrary packets this won't work. And the VPN solution will give you access to the Android device but I don't think that you will be able to access the network the Android device is in (otherwise the VPN would have to run in network bridging mode).

@Robert thank you very much for the answer. I agree with you in both cases...I have to investigate if arbitrary packets forgery is possible in Android but I am pretty sure that it is not.
For now the only solution I see is root the device and install the binary of an OpenVPN server like you would do on a Linux Machine.

I would install Kali Nethunter for Android with root. That should allow arbitrary packet forging as well as sniffing via Wireshark.


text:
Binder from Android to chroot linux
Situation:
Android OS that runs chroot'ed Ubuntu.
As i understand Ubuntu does work on top of android linux kernel,
which have integrated Binder interface, i checked few examples here.
Does it mean that i can compile this 'client' library for ubuntu that will use binder /dev/binder?
And at same time have an android application that will act as 'server'?
The idea is to get IPC working between these two systems.

Yes it will work. But the native binder library isn't available in Ubuntu chroot. You'll have build the library / binary with Android NDK (not with GCC) and copy the shared libraries from /system/lib[64]/ to Ubuntu's /lib/.

thats not gonna work then because i cant use android Bionic from ubuntu

Linking to Android libraries with Ubuntu's GCC or building statically linked libraries is a big challenge. So better go for some other option. Why not simply use socket? If you own the app.


text:
Does disabling stock apps cause problems with phone on Android 6.0
So I disabled all the stock apps and other apps I don't use or need in my phone and I am just curious if that could cause issues with the phone where audio eventually breaks.
I've been on support with verizon and after several resets I've ran my phone without any apps installed and the issue came back and the only thing I've done was use blue tooth with my car and disable stock apps.
I'm trying to convenience them that my Refurbished Droid Turbo 2 is a bad phone and while the issue seems like it would be software I can't explain what is triggering the issue software wise that even makes sense unless it was a bad firmware/software upgrade from 5?
The weird part is even if audio breaks, if you blue tooth up to the car it works just fine.
EDIT:

Can you provide us the list of stock apps you disabled? The command pm list packages -d using [tag:adb] or with a terminal emulator could work.

Sure. Updated with disabled apps.

There are many stock apps which you defenetely shoud'nt disable as it can problems to your stock frimware behaviour. I also once disabled lots of packages as i thought it will save battery and ram but it turns out there are extensions or side apps which are required by other apps to get/run their content. for example there is an sideapp called media storage which scans and stores media changes in your storage locations i.e. if you disable your music players like play music,phonograph,musixmatch,etc.. wont work and will show previous catched files insted of new files or currwent files. same way you may be facing same problem here. Just check which app does your audio player needs to run audio smoothly. re-enable it and restart your phone..this should solve the problem.

Your answer tries to address only the second half of the OP's question. Actually, they asked if disabling stock apps can potentially cause problems or not, as well. The lack of elaboration justifies my downvote.

well i explained how it caused problem in detail...duh bro!


text:
Nexus 5 only emergency calls call are allowed by device owner
I am new to Android and I am not the owner of the current device (LG Nexus 5) I use. I come across this problem: I am not the owner of the device. Instead, I am the second user. When I want to call someone, it prompts an alert box saying that

only emergency calls are allowed by the owner.

Similarly, when I open the Messenger app, another alert box prompted:

this app isn't allowed by the device owner

so I set Hangouts as the default SMS app, but SMS is disabled and not be able to enable.
Other features work fine. The reception is full. Cellular data works. I can even accept calls, just not be able to calling out or sending SMS. Do I have to contact the owner, for them to unlock the calling and texting features?

when your phone is under guest it wont allow you to have access to everything. switch to original owner and your phone will work again!

You may be right but adding a reliable Source to support would enhance value of answer, else it is a comment and would attract downvotes

Ok, log back in as the owner of the device (if you can)
Slide down the menu from the top
Click on the user icon
Click on "More Settings" down the bottom
Click on the settings cog next to the user you want to enable phone and sms for
Click "Turn on phone calls & SMS"
This is working for Android 7, Google nexus 5x
Found in this guide:
http://www.ibtimes.co.uk/android-5-0-lollipop-how-enable-remove-restrict-guest-user-mode-1470690

Here are 2 approaches
http://www.thecellguide.com/ has detailed pictures to go along with the information below, which has been directly quoted.

Go into Settings > Storage and tap on Cached Data and select ok to clear data.
Go into Settings > More > Cellular Networks > Preferred network type.
Select "2G" as your preferred network mode. - Turn your Nexus off completely, wait 10 seconds and then turn it back on again.
Go back into Preferred Network type as shown above and switch it to 3G.
Then select Network Operators > Search Networks - Select your Carrier and you should connect successfully.

https://productforums.google.com/forum/m/#!topic/nexus/tkdAkJEAXmo information below is from Srijith G Nath answer.

A lot of people have been having trouble with their network connections on the Nexus 5. Sometimes it will struggle to connect properly when switching between Wi-Fi and a mobile network; sometimes it seems to run into issues when switching between 3G and 4G. Sometimes it is dropping onto EDGE or GPRS when 3G or 4G is available. For some people it happens when the Nexus 5 sleeps and there are suggestions it might be related to fast dormancy if it’s not supported by your carrier.
Workaround:
Hold down the power button and reboot your Nexus 5 and the connection should return.Try going to Settings > Wireless & networks > More > Mobile networks >Network mode and choosing it manually.
Potential fixes:

There’s an outside chance that your APN settings are wrong. Check with your carrier to find out what they should be and go to Settings > Wireless & networks > More > Mobile networks > Access Point Names to make sure they are set correctly.
Try using your SIM in another phone to make sure it’s not an issue with the SIM card.A few people say the problem is gone after a factory reset or replacement handset, but there are also reports that neither helps, so it’s definitely not a guaranteed fix.

I do not see Cellular Networks under Settings -> More, and switching to 2G or 3G will probably slow down my cellular data speed, since I am using 4G LTE and the connections are fine.

In terms of Cached Data, I have 1.57GB after I cleared them, I am not sure if that is normal. But it does not work.

Switching to 2g forces the phone to locking to base signal.

The only other option I can see is try the SIM card in another device and see if it connects to make a phone call.

unfortunately on my phone I cannot select preferred networks. SIM works, I tried it on another phone.

Contacting the owner is the simplest way to do that -- they'll probably need to have the phone physically in hand, too.

Which setting do they have to modify to enable the features?

No idea; I don't have a Nexus (any version), nor ever tried to change those settings on my Galaxy S4.


text:
MTP not working under Android 6
I am running out of Ideas how to get MTP working again... I am simply not getting the dialog again on my android, asking me wether I want just charging, or MTP or Picture mode...
Until most recently, it was easy: Use a USB cable, concect it to my Ubuntu 16.04 Laptop, get the mentioned choice/approval box... and voilà the Tablet appeared as an MTP device in the Ubuntu ‚file explorer‘ (caja) nicely auto-mounted.

got an Samsung Galaxy S2 tablet
running Android 6.01
it worked until recently in this configuration

I already followed some advice:

I made the developer options visible (by tapping the about device info thrice)
enabled USB debugging (which some sources say, is something to watch out for)
dialed on the phone menu *#0808# → which shows I'am on (o)AP and on MTP + ADB mode just like I should (this radio box btw only holds its state, if USB debugging is enabled)

also...

tried different USB ports
tried different cables
tried with another device (MacBook. Thus I have no reason to believe, I messed something up on the host machine OS side... Ubuntu is very stable anyway)
External Store (4kb) under Settings→Applications→“Show System Apps” is on

well, one last clue:

Settings → Tethering has the USB switch grayed out „USB cable not connected“. Althoug it clearly is. And I can recharge my tablet through it (otherwise I would have certainly noted...)

Device is not rooted. No other glitches.
Are there maybe some log files (now that Dev mode is enabled) to check out what might got wrong?
Not looked/understood ADB yet. So I couldn't tell you, if that works. Anyway, no dialog to choose upon connecting.
I am out of ammo :-( Thank you for any piece of advice...

Revoke the USB debugging authorisation in Developer options? That would disable device recognition and may help in getting back the prompt?

Just double checking - is Select USB Config in developer options set to MTP? Even if it is, try toggling it to some other option , Connect USB and toggle it back to MTP?

Did you try on a Windows machine also?

@beeshyams: Forth and back switching form MTP to Charge to PTP etc... no sucess

@esQmo No Win machine available. But since if worked last week (same host, already under Android 6) and since I don't even see a raw USB device in Ubuntu (i.e. one w/o proper drivers) I think it's unlikely the host is to blame...

So check the USB connector if the port is totally clean of lint or debris.

Try different usb cable. Also try on other machine win/linux than you will know where is problem. Also try finding usb connection setting in settings when and when isn't connected vias usb. And I don't know why but try cleaning cache and data for External storage and Media storage from app manager.

I have same problem, I have fixed it using below app: The answer is:
https://forum.xda-developers.com/android/apps-games/app-mtp-enbaler-t3263467

I already had this kind of trouble with bad cables (good enough to charge but not enough for data). You say you tried with different cables but are sure they worked for data? (charging is not a proof that the cable is good).

Did you try pulling the notification bar down? You should see "Transferring media files via USB", or "Charging via USB, tape for other USB option"
And if after doing all this the problem remains, download Samsung USB drivers from Samsung website.

.
Screenshots from my Galaxy J5 (click images for larger variants)

precisely that Dialogue is no longer coming up. Also not hiding in the drag-down. The USB device is not even visible as a raw USB device (thus it can imho not be an issue on the host...)

Did you mind checking the connector?

authors: Једноруки Крстивоје


text:
Unable to connect to SSH server via Tor
I'm attempting to connect to my SSH server via Tor on my rooted Android.
I couldn't find an SSH client for Android that supports the use of a SOCKS proxy, so I tried to use transparent proxying with Orbot for a number of SSH clients.
So far I've tested JuiceSSH and Serverauditor.
JuiceSSH seemed to have issues with my private key for SSH and Serverauditor just reported that the connection failed.
SSH via Tor works fine on my computer.
edit: I've manged to get the private/public key thing working with JuiceSSH and I've also tried to use ProxyDroid (can't hyperlink due to low reputation) to proxy all system traffic through Tor (SOCKS5, 127.0.0.1:9050).
JuiceSSH now keeps trying to connect but doesn't get much further. Serverauditor still just very briefly tries, then reports that the connection failed.
How can I connect to my SSH server via Tor, using private/public key authentication?


text:
Root Android virtual device with Android 7.1.1
I'm using the official Android SDK with the Android Emulator to create a virtual Android 7.1.1 (x86). I need to test a number of things, amongst others, some applications require root access to the device.
Now I know that I can adb root and I have a root shell, but that doesn't allow the apps I install to have root access.
I've researched this topic now for a while and have seen various approaches. Most answer haven been posted rather long ago.
I think it's quite odd that there's no option to toggle root - this is after all an SDK.
How do I root an Android virtual device, running Android 7.1.1, effectively allowing installed apps root access?
edit: I'd rather not resort to paid emulators like Genymotion if possible.
edit2: This is solely for personal use.
edit3: Genymotion appears to be a viable solution, as an alternative emulator. How come Android SDK/Emulator does not offers such a feature?
edit4: The answer by xavier_fakerat seems to work perfectly fine, however since Android Studio version 3.1 this doesn't seem to be a permanent rooting. Once the AVD is rebooted, root access is gone.

How to root android emulator (Android 7.1.1/ Nougat)
I’m pleased to inform the community of  an easier way to root android emulator (run from standalone Android SDK)
Requirements:

SuperSU app (chainfire) latest version 2.82

Recovery flashable.zip (contains su binary)  (Here is alternative mirror link for flashable zip if the main link is not working : Flashable zip super su 2.82 for all roms)

Note: SuperSU is now deprecated, but this method still works to root the emulator, and more updates will be given for newer rooting methods.
Instructions

Install the SuperSu.apk

Install the SuperSu app firstly, just do drag and drop (if running latest emulator version or sideload through adb i.e adb -e install supersu.apk)

After installing it, when you run it shows a screen as shown below indicating “There is no SU binary installed..”. This error just confirms the device is not yet rooted.

Make emulator’ system partition writable

As it suggests, we need to give the emulator permission to write system files.

Type the following code to accomplish this: emulator.exe -avd {emulator_name} -writable-system

Note: Navigate to the tools folder where Android SDK is installed and open command prompt there by pressing shift and right clicking.

Pushing su binary in system directory

Extract the Recovery flashable.zip (containing the su binaries of different architectures)

Important! Only use the su binary that matches your avd architecture e.g x86, arm etc.., and note the path where you extracted these binaries.

Make sure you are running adb as root and also you need to remount.
Just enter these codes

adb root
adb remount
Now its time to push the su binary:
This is the code I successfully used:  adb -e push C:\%USERPROFILE%\Desktop\rootemu\x86\su.pie /system/bin/su
(nevermind about my specific location of su binary, any location is okay as long there is no white space)
If this fails try this pushing to this directory instead /system/xbin/su. Also for emulators running android 5.1 and below use the su and not su.pie

Change permissions of the su binary

Next let’s do a bit of modification of the permissions of su binary. We have to do this in emulator device through adb:
adb -e shell
su root
cd /system/bin
chmod 06755 su

Important!! Take note of su binary path (mine is /system/bin)

Setting the install directive on su binary and set a daemon

Type the codes:
su --install
and for setting up daemon:
su --daemon&
Important!! Take note of spacing

Setting SELinux to Permissive(i.e turning off SE Linux)

Finally turn off selinux through this code:

setenforce 0
That’s pretty much it!! Open SuperSU app and it may ask to update binaries, you can use Normal method.
Open any app requiring SU permissions just to double check and indeed SuperSU ask if you wish to grant it su permissions.

Remarks
Most content in reference was for older android versions and hence the reason for different commands and paths which I modified.
Special acknowledgements;
Special gratitude to Irvin H, whose tutorial inspired me to create this guide after myself having failed countless times, and also after seeing the need for many users to root their emulators too. I hope this will also benefit a lot
Irvin H: Rooting the android emulator –on Android Studio 2.3((Android 4.4)
#Update
As commented by SaAtomic,

This approach is still viable with Android Studio 3.0.1

After upgrading to emulator version 27.2.9 and above it now makes preserving root much easier through snapshot feature (if copying the system.img method isn't working):
Ideally it is more like hibernating the virtual device with config intact, hence everything is preserved.

Snapshots
You can now save multiple AVD snapshots for a given device
configuration and choose which of the saved snapshots to load when you
start the emulator. Starting a virtual device by loading a snapshot is
much like waking a physical from a sleep state, as opposed to booting
it from a powered-off state.

This implies the only requirement to start the emulator is adding the -writable-system parameter to the normal emulator -avd [avdname] command to start the emulator. (Running the emulator just with emulator -avd [avdname] doesn't launch the rooted version/copy or may lead to some error)
Tested on API level 22

Thank you for the detailed answer. I didn't try it yet, but this seems to be a viable solution!

@SaAtomic, your steps are very useful,
More ever, One can also flash Supersu 2.82/Magisk using a custom recovery, e.g- TWRP , and can easily obtain root....
These works well on any 7.1.1 or 7.1.2 running devices....
Thank You..

I've just tested this with Android SDK 2.3.3 (AVD Manager) and virtual Pixel using Android 7.1.1. Works just as described right away. Thank you!

Update: This approach is still viable with Android Studio 3.0.1

I tried your approach, but get error in the 3rd step.
I used: Android Studio 3.0.1 on Mac, Nexus 5X with Android 7.1, so the emulator name will be Nexus_5X_API_25 for your reference. On executing adb root as stated in 3rd step, I get the below error:
$adb root
adbd cannot run as root in production builds Kindly let me know, if your approach still works at this moment. Thanks.

It is most likely that you're using a wrong emulator image you need to  use the Google APIs Intel x86 Atom System Image rather than Google Play Intel x86 Atom System Image

Update: After the latest update of Android Studio to 3.1 the su binary is in /system/xbin/su for a Pixel AVD with Android 7.1.1 (API 25) and no matter what I try, the rooting is not persistent. After reboots the AVD is not rooted anymore.

$ adb remount                                                                                1
Not running as root. Try "adb root" first.

@SaAtomicyou need to update emulator and use snaptop to boot

First link is dead


text:
Questions on implementation of message/notification light/LED
I hope this collection of questions on Android's "notification light" are not too generic.
Also I hope it's OK to bundle them.
Anyway, here they are:

Is there an API to "replace" a physical notification light by an app, i.e.: make the app "forward" events directed towards the notification light (that is actually absent), also meaning that any other app controlling the notification light would be redirected?
Should a current phone have a notification light (assuming Google makes hardware guidelines for phones)?
My old Huawei Android 7/8 phone had a triple LED (I guess red, green, blue) that could be controlled by apps like signal to light up in different colors (it's also used by the system as well, e.g. to indicate a low battery), but my current Oppo Android 12 AMOLED phone has none any more.
Somehow I miss it.
I noticed that when the camera is in use the display "emulates" a green notification light, so I thought the notification light might be emulated to be used by other applications as well, but seemingly it isn't.
Or is there a setting I need to enable that emulation?
I also noticed that I can "control" the function of the non-present notification light in some apps, but it does not seem to have any effect.

Recent Google Pixel phones have no notification light, I think that says it all...

OK, so it's not required (answering item #2), but the API to control it still exists.


text:
Why was my launcher setup reset after inserting a SIM card?
I have a new phone, and I started to "customize" it while still using my old one.
When I felt the phone is ready for switch-over, I inserted the SIM card from the old phone.
That worked, but after opening the MMS sent by the provider, it caused some app to be installed without my explicit consent.
A moment later I realized that my launcher configuration was reset to default:
All my icons and folders that I had placed and created before were gone!

Is that usual for Android 12 (Oppo's "Color OS" 12.1), or is it unusual?
Is there any chance to get my setup of the launcher back?

I was thinking whether removing the SIM card again would restore my launcher, but then I though:
Better ask here!

That a manufacturer installs additional bloatware apps based on the customer country is nothing new. I wasn't aware that for the country detection the SIM may be used. Unfortunately I don't see any chance that removing the SIM card will revert the changes. Android does not provide a way to save app data in a way that would later allow to go back to that state. All changes are permanent.

So installation of the provider's app did the layout reset? I had uninstalled that apps in the meantime as I don't need them. Also my phone knew the region I live in before inserting the SIM card.

As I found out, the provider's "Welcome" app installed itself as "launcher" without Android asking me for permissions to do so (how did they manage that?).
Also it did not just reset the start screen, but also changed some display options regarding that status bar.


text:
What does compass calibration do and why is it needed more than once?
The"compass" in Android seems to be a projection of the 3D magnetic field measured by a magnetometer:

Having read https://electronics.stackexchange.com/a/22271/282833 I still have three questions:

Assuming the compass has been calibrated while quality testing before shipping, why is it needed to calibrate the compass again?  Or in other words: Assuming that the magnetic sensor is placed the same with high precision on each device of the same series, why can't a "golden sample" be calibrated and the data set to all of the similar devices?

Assuming you calibrated the compass and you use it in more or less the same area (meaning: I know that the compass may need re-calibration when moving a significant distance, like a few hundred km), but same area means less than 50km), what are the reasons you must re-calibrate the sensor after some time?

Is the compass calibration global to all apps, or do individual apps require separate compass calibration? It seems some apps suggest re-calibrating the compass frequently, while others don't.

Background for the question is that even after calibrating the compass, it started to "go mad", meaning north was almost 180° off.

Why is it needed to calibrate the compass again?

Things go out of calibration. If you put a strong magnet next to a camping/orienteering compass for long enough, you will alter the magnetic components of the needle and it will not be able to point to magnetic north correctly. In the same way the magnetometer components in a mobile device are sensitive to magnetic fields.

Why re-calibrate if in the same area?'

The 'same area' needs to specified. Even a smartphone has multiple magnets inside either for the speakers, microphone, or any 'magic' case attachments. A house/home has a variety of magnetic field generators like the electric motors in kitchen appliances, various audio/video equipment, and some lamp fixtures. Vehicles have starter motors and generators in addition to any audio equipment as well as being a large piece of metal. Unless you are in a completely rural community you will be surrounded by power lines, trains, transformers, pipes, buildings all slightly shifting the local magnetic field. In an urban environment it is easy to accidentally get near a strong magnetic field which could require recalibration.

If you are having problems with calibration, make sure that you are using a phone case doesn't have magnets. I would suggest trying in an open field far from any electromagnetic interference like the middle/center location of an outdoor school sports field. If afterwards you are still having problems it may be that the compass is damaged, perhaps due to prolonged exposure to a strong electric motor.

Do individual apps need to calibrate the compass?

In a device there is generally only one magnetometer and its calibration is internal to the chip/driver/subsystem. The Android Open Source Project has a section on Sensor HAL (Hardware Abstraction Layer) where corrections would take place. The 'figure 8 pattern' for calibration is in concert with the accelerometer and gyroscope. All apps should receive any corrected/calibrated values. Its possible that the app may need to be restarted after calibration to get correct values.
Reference to an old answer with a nice video: Compass needle deflected when near off smartphone
Do note that when designing these products the additional magnets are in a known position relative to the internal magnetometer so their influence is minimized.

So wait is it one chip or multiple chips involved in the compass?

The compass/accelerometer/gyroscope are all MEMS devices which allows these features to fit into tiny spaces. For hobbyists, Arduino has a single chip IMU (inertial measurement unit) board and in consumer phones due to all of the magnets the magnetometer appears to be separated from the gyroscope/accelerometer as seen in the Nexus 5 iFixit teardown and the Samsung S7 iFixit teardown. I would not be surprised if in low end phones one of the pair is missing OR the phone is using a single chip for all three.

Occasionally an app will tell me that the compass needs calibration how is that happening?

Most likely you were using a mapping app in directions mode. By itself there isn't any way for a phone to know which way is north, however when walking/biking/driving along a route the mapping app can identify using GPS / WiFi locations that the person is following a route but the compass isn't making sense and will inform the user that recalibration is required. For example moving east on a east-west road but the phone orientation doesn't change (gyroscope & accelerometers) and the compass points the wrong way may trigger a 'recalibrate compass' message.

Somehow I doubt that "its calibration is inside the chip": Don't the "three magnetic dimensions" have to be coordinated with the device position (gyros sensor or orientation sensor)? So unless one chip implements all those, I doubt the calibration will be inside the chop. Do you have references? - And I forgot to ask "How does an app detect that compass re-calibration is needed?"

@U.Windl Your right 'chip' isn't the right word, probably subsystem is more correct.