title: Examine android (v30) selinux policy

text:
# Question
Title: Examine android (v30) selinux policy
I'm trying to find what policy is actually enforced by my phone using selinux. You'd think this would be easy. After all, for security it is good to verify that your policy matches expectations. Unfortunately, I've found this shockingly hard to do, because A) android seems to use a forked policy version 30, and B) the policy toolchain seems to have a very low-quality build process (lots of hard-coded paths, etc.).

Here are two things I've tried that have not worked. If I try to use off-the-shelf setools tools (such as come packaged for fedora, or can be installed from AUR with arch linux), then I get the following (after pulling `/sepolicy` from by phone's root directory or factory image):

```
$ sedispol sepolicy
Reading policy...
libsepol.policydb_read: policydb version 30 does not match my version range 15-29
sedispol:  error(s) encountered while parsing configuration
$ sesearch --all sepolicy
ERROR: policydb version 30 does not match my version range 15-29
ERROR: Unable to open policy sepolicy.
ERROR: Success
$

```

Okay, so that suggests I have to build the android version of the selinux libraries. The AOSP source tree comes with precompiled versions of some tools but these depend on old shared libraries that I don't have (like libpcre3). Anyway, it's pretty shocking if the only way to check your security policy is to trust some binary shared library you get off the net.

So here's what I did to build the android selinux libraries. On arch, I had to install `ustr-selinux` from AUR, because ustr uses `inline` where it is now required to use `static inline`. Okay, so far so good. Unfortunately, the build process is really gross, but I was able to get enough of it compiled and installed with the following:

```
git clone https://android.googlesource.com/platform/external/selinux \
    android/external/selinux
export ANDROID_BUILD_TOP=$PWD/android
DESTDIR=$HOME/android_selinux
export LD_LIBRARY_PATH="$DESTDIR/lib:$DESTDIR/usr/lib"
cd android/external/selinux
sed -ie '/^LDLIBS.*(LIBDIR)/s/$/ ..\/lex.yy.o/' checkpolicy/test/Makefile
make install DESTDIR="$DESTDIR" \
     PREFIX='$(DESTDIR)/usr' \
     CFLAGS='-I$(PREFIX)/include' \
     -j20 -k
cp checkpolicy/test/dispol "$DESTDIR/usr/sbin/sedispol"
cp checkpolicy/test/dismod "$DESTDIR/usr/sbin/sedismod"

```

At this point, `sedispol` works an an ordinary SElinux policy (like a version 29 `policy.29` from fedora), but still won't show me what's going on with android:

```
$ ~/android_selinux/usr/sbin/sedispol sepolicy
Reading policy...
libsepol.avtab_read_item: more than one specifier
libsepol.avtab_read: failed on entry 457 of 5582
/home/user/android_selinux/usr/sbin/dispol:  error(s) encountered while parsing configuration
$

```

I also tried compiling the vanilla `setools3` tools against the android libraries. Again, not so easy, but I got it to work with:

```
DESTDIR=$HOME/android_selinux
export LD_LIBRARY_PATH="$DESTDIR/lib:$DESTDIR/usr/lib"
git clone https://github.com/TresysTechnology/setools3.git
cd setools3
./configure --prefix=$DESTDIR/usr --with-sepol-devel=$DESTDIR/usr CPPFLAGS="-I$DESTDIR/usr/include -L$DESTDIR/usr/lib"
make -k -j20

```

This doesn't fully build, but builds enough of the source tree that I can execute `secmds/sesearch`. This sort of works on a vanilla `policy.29` file (I can search `-A` and `-T`, but `--all` gives me `operation not supported`). However, it completely fails with a similar error when trying to examine an android version 30 file:

```
$ ./secmds/sesearch -A sepolicy
ERROR: more than one specifier
ERROR: failed on entry 457 of 5582
ERROR: Unable to open policy sepolicy.
ERROR: Success
$

```

At this point my mind is kind of boggling that the tooling around something so critical as the system security policy is really this hard to build. Surely I must be doing something wrong. Has anyone actually managed to examine an android security policy without relying on externally distributed binary shared libraries?

I should add that I also tried the techniques suggested for rebuilding all prebuilt tools (`ndk/build/tools/download-toolchain-sources.sh` and `ndk/build/tools/rebuild-all-prebuilt.sh`). However the `download-toolchain-sources.sh` script is currently broken. It tries to check out old version directories that are not in the repositories any more, and anyway it doesn't appear to download any selinux related tools, despite that fact that `prebuilts/python` contains selinux-related code. Again, I'm shocked at how crufty these build systems are, and think there has to be an easier way. The question how can I get tools that allow me to check my android selinux policy?

# Answer
First of all, I must admit that I fully agree with your *"I've found this shockingly hard to do"* statement. Google has designed Android mainly from a consumer perspective, and not for power users. The result is that, as soon as you want to do something outside of using the latest Facebook app or playing with Candy Crush, you very quickly find yourself back in realm of early-2000 Linux, when a developer-like knowledge was required to change what should be simple settings. I believe that the situation will fastly evolve as Android system gets more mature, but for now we have to do with what we have got...

As you said, there are two reasons why it is necessary to compile your own SELinux toolset:

* The system provided toolset is usually a version behind. While Android's SELinux relies on policy DB version 30, current Linux boxes usually handle only version up to 29.
* Even if it would be more recent it would not help, in fact building SELinux from upstream code (which is easilly done, at least on Fedora machines following upstream recommendations) effectively allows the system to handle policy DB version 30, however Android's SELinux has been heavilly modified (Google documentation highlights a few modifications) so trying to handle Android's SELinux fails due to syntax and parsing errors.

So, to keep on the Android's SELinux analysis quest, we will have to put our hands in the dirt... in the cleanest possible way:

* First we will setup a sane environment,
* Once this is done we will compile Android's SELinux libraries and first tools,
* On top of them we will build SELinux tools,
* We will finish by adding a few supplementary utilities.

# Setup a proper environment

## Environment properties

The cleanest recommended, an possibly maybe only reliably working way is to dedicate a environment to your Android work:

* A virtual machine is perfectly fine (if not the best option). Prefer to use a VMware one since you will have to connect your phone through USB to the guest system. The free alternative Qemu doesn't seem to handle such task very well. I did not try with other virualization software.
* It will need to be a 64 bits system, otherwise the code will simply not compile due to integers being of the wrong size.
* It is *strongly* recommended, possibly mandatory, to use a Ubuntu system. Feel free to use Xubuntu instead if you prefer XFCE's lighter desktop environment, this does not change the system's core and available package and will have no impact on your Android related work (whatever I say about Ubuntu in this procedure also applies to Xubuntu). You may find in Android's SELinux source tree some ReadMe files recommending the use of Fedora instead, these files are inherited from upstream NSA's SELinux project and their content do not necessarily match Google's Android.
* The exact version of Unbuntu to use depends on the version of Android you want to build. For Android 6.0, Ubuntu 14.04 (Trusty) is recommended. Check Google requirements page for more information.
* You will need plenty of disk space (at least 50GB if you plan only SELinux-related investigation, at least 100GB if you plan for a complete build of Android). CPU and memory are less relevant, they only impact time for a full build and will have no real impact for SELinux related tasks.

Using Ubuntu has two main advantages:

* By using the recommended system, you are working in a well-known and well-tested environment: system libraries, tools and packages are at the version and location expected by the project.
* And more specifically in our current case: Ubuntu itself relies on AppArmor which is a SELinux alternative, it does not use SELinux. The good news is that you will therefore be able to install Android's SELinux tools and binaries system-wide without risking to alter system reliability.

## Environment installation procedure

You can install Ubuntu the traditional way by starting from a full-fledged live-DVD, but a faster alternative is to use a netboot install (textmode install) and select the desktop environment you prefer at the end. Doing so will save you the initial update time by directly installing up-to-date packages version instead of first installing obsolete ones, then asking to apply 389 pending updates on the first boot.

The ISO for Ubuntu/Xubuntu 14.04 (same ISO) netboot installer is available here.

To skip VMware's troublesome "Easy Install" feature, it's a good habit to start by selecting the *"I will install the operating system later"* option.

Be sure to select *Linux*, then *Ubuntu 64 bits* as guest OS.

The VM will need the following ressources:

* Mandatory: disk space must be **at the very least** 40GB (the default 20 GB will **not** be enough, the source code alone takes more space than that), higher is recommended. A full build requires a 100 GB disk minimum, this is the value I usually take. Do not forget that this setting is just a maximum limit: the actual size taken by the VM grows dynamically with guest's requests.
* Facultative: Increase RAM from 1024 to at least 2048 or higher (depends on your host capacity, I use 4096),
* Facultative: Increase the number of processor cores from 1 to 2 or higher (depends on your host capacity, I use 3).
* The CD-Rom must point to the installation ISO file.
* You may want to switch USB from the default 1.1 to 2.0 as the former may give warnings when you connect your device. Depending on your usage, you can also safely uncheck *"Automatically connect new USB devices"* and *"Share Bluetooth devices with the virtual machine"*.
* Depending on your environment, you may also need to tweak display settings (disable 3D, enforce a screen size).

***Attention:***

* If you choosed the netboot install, do not forget to select your desktop environment (*Ubuntu desktop* or *Xubuntu desktop*) when reaching the *Software selection* screen, or you will end-up with a minimal text-only environment!
* Upon first boot, **refuse** to upgrade to the latest release: the whole point here is to stay in 14.04!

Upon first boot, one of the first you may want to do is install Linux guest tools:

```
sudo apt-get install open-vm-tools

```

This packet put boot-time triggers, its installation will therefore be complete only after a guest restart.

# Fetch Android source code

While similar, the procedure details depends on the chosen ROM:

* For CyanogenMod, search for your device (select the vendor first) then click on the *"How to build CyanogenMod"* link to get instruction adapted for your device.
* For AOSP, follow the procedure which starts here.

It can be worth noting that CyanogeMod bundles in its source tree a tool allowing you to unpack `boot.img` files. To say it differently, CyanogenMod provides you a tool which will allow you to access the `sepolicy` file stored in devices and ROM archives. Google's AOSP does not provide such tool, so if you have no other imperative using CyanogenMod's source tree may be the most convenient choice, otherwise you will have to install it appart (which is quick and easy to do, so no worry here).

Here I'm following CyanogenMod 13.0 (Android 6.0) procedure. Explanation on the commands used is available on the pages linked above. Please read them, the typescript below is given only for reference purposes.

***Tip:*** While I use `apt-get` in this post to stick to the lowest common denominator and keep everybody happy, you may prefer to use `aptitude` instead since it will take care of the dependencies in a better way (when removing a package which required the installation of some dependencies, these dependencies will be removed too, leaving your system cleaner). AFAIK the `aptitude` command must be installed in Ubuntu but is available by default on Xubuntu.

```
sudo apt-get install bison build-essential curl flex git gnupg gperf \
libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk2.8-dev libxml2 \
libxml2-utils lzop maven openjdk-7-jdk pngcrush schedtool squashfs-tools \
xsltproc zip zlib1g-dev g++-multilib gcc-multilib lib32ncurses5-dev \
lib32readline-gplv2-dev lib32z1-dev
mkdir -p ~/bin
mkdir -p ~/android/system
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod u+x ~/bin/repo
cd ~/android/system/
git config --global user.name "Your Name"
git config --global user.email "you@example.com
repo init -u https://github.com/CyanogenMod/android.git -b cm-13.0
repo sync
# Coffee time: around 20GB are being downloaded, this may take several hours.
source ./build/envsetup.sh
breakfast

```

Now you have a clean and nearly complete source tree. The proprietary blobs are missing, but you don't need them for SELinux related tasks.

***Tip:*** Fetching the sources is a tedious process, it may be worth to do a snapshot or backup of your VM now.

# Compile and install Android's SELinux toolset and libraries

Now the funny part of the trip begins ;) !

Until now the procedure should have been pretty straightforward. The goal was mainly to ensure that you have the very same environment as me. If you do, the sequel should remain straightforward too.

Under the hood Google's do not hesitate to apply deep changes to Android's source code between versions, therefore the exact compilation steps will be quite certainly version dependent (for instance AOSP master shows that the `sepolicy/` directory will be moved).

I will first share my exact procedure to compile and install Android's SElinux libraries and toolset, but in order to keep the relevance of this post over time I will then add some notes about the generic approach to follow in order to solve most compilation issues.

## Step-by-step procedure

Android's SELinux libraries provide the abstraction layer which will allow upper layer software to deal with Android-specific SELinux policy files. We will therefore need to compule and install them first (which, in itself, actually represents the core if the difficulties here, until you've found your way).

We will then be able to build and install SELinux tools. As we will see, fortunately these do not need to be Android specific, they only need to match the SELinux library version.

This procedure has been tested both using CyanogenMod and AOSP source code trees.

### Compile and install Android SELinux libraries and first tools

First install dependances:

```
sudo apt-get install libapol-dev libaudit-dev libdbus-glib-1-dev libgtk2.0-dev \
libustr-dev python-dev python-networkx swig xmlto

```

In this post the variable `$ANDROID_BUILD_TOP` stores your source location (the directory where you issued the `repo sync` command). Feel free to change its name as you like.

```
ANDROID_BUILD_TOP=~/android/system
cd $ANDROID_BUILD_TOP
source ./build/envsetup.sh

```

By default the policy core utils compilation fails due to `restorecond`'s Makefile being unable to locate some libraries. You have to edit this Makefile in order to use paths dynamically generated by `pkg-config` instead of hardcoded ones (do not confuse backticks with single quotes!):

```
sed -i 's/^CFLAGS ?= -g -Werror -Wall -W$/& `pkg-config --cflags --libs dbus-1 gtk+-2.0`/' \
$ANDROID_BUILD_TOP/external/selinux/policycoreutils/restorecond/Makefile

```

Feel free to open the Makefile with some text editor to ensure that the modification has been correctly taken into account.

And now compile and install:

```
cd $ANDROID_BUILD_TOP/external/bzip2/
make -f Makefile-libbz2_so
sudo make install
cd $ANDROID_BUILD_TOP/external/libcap-ng/libcap-ng-0.7/
./configure
make
sudo make install
cd $ANDROID_BUILD_TOP/external/selinux/
make -C ./libsepol/
sudo make -C /libsepol/ install
EMFLAGS=-fPIC make -C ./libselinux/
sudo make -C ./libselinux/ install
make -C ./libsemanage/
sudo make -C ./libsemanage/ install
make
sudo make install
make swigify
sudo make install-pywrap
sudo cp ./checkpolicy/test/{dispol,dismod} /usr/bin/

```

***Attention:*** Do not miss the `EMFLAGS=-fPIC` environment variable setting when building `libselinux`. It will not generate any error yet, but in the next step you will be unable to build SETools. In case you missed it or did anything else wrong, simply issue a `make clean` and restart your compilation.

### Compile and install SELinux tools

SELinux tools are provided in a prebuilt form which includes:

* Python scripts (and their shell script wrappers) within the `$ANDROID_BUILD_TOP/external/selinux/prebuilts/bin/` directory
* Python packages (including `*.o` compiled files) below `$ANDROID_BUILD_TOP/prebuilts/python/linux-x86/2.7.5/lib/python2.7/site-packages/`.

I would have expected the source code of these tools to be available below `$ANDROID_BUILD_TOP/external`, but it isn't. Actually, I did not find any place where Google shared the exact version of SETools they used (FYI the GPL only mandates to share the code if it has been modified), so we will have to guess and try and do as best as we can.

The tools themselves are Python scripts, this a new evolution from SETools 4 (in SETools 3, commands like `sesearch` were binary executable coded in C). However, the tools themselves still show a version of 3.3.8:

```
$ $ANDROID_BUILD_TOP/external/selinux/prebuilts/bin/sesearch --version
3.3.8

```

So my guess is that Google took some early development snapshot from SETools 4. Until 4.0.0 beta SETools relied on `libsepol` versoin 2.4, with 4.0.0 release they started to rely on the version 2.5 of the library which is not compatible with the version of SELinux bundled in Android 6.0 (you can try to compile this, it will just fail).

So the wisest choice seems to go with SETools 4.0.0 Beta.

Install supplementary dependencies:

```
sudo apt-get install python-setuptools

```

Download and extract the source code:

```
cd ~/android/
wget https://github.com/TresysTechnology/setools/archive/4.0.0-beta.tar.gz
tar xzf 4.0.0-beta.tar.gz
cd ./setools-4.0.0-beta/

```

Due to a bug affecting Flex 2.5, we need to remove `-Wredundant-decls` from compiler's flags:

```
sed -i '/-Wredundant-decls/d' ./setup.py

```

And finally compile and install:

```
python ./setup.py build
sudo python ./setup.py install

```

## Generic procedure (or "How to unstuck yourself")

In case the procedure above did not work in your case, here is a higher level view on how to try to progress.

There is sadly no magic (and no helper :( ) around here: the only way to get this code to compile is the classical yet dreaded cyclic "try-and-see" approach.

Try to compile a first time, it will most likely fail due to some `*.h` file being not found:

1. Search in Android's `external/` directory:

```
find $ANDROID_BUILD_TOP/external -name filename.h

```

If you find the requested file, then this means that a specific version of the corresponding library or tool has been bundled within Android source code. You should therefore not try to install it from Ubuntu's package system, but instead compile and install the version bundled in Android source code.

Be aware that this goes against general advice you may found on forums: *"Your compilation fails because of this library missing? Install this package then it will be fine!"*, by doing this you will most probably just go into worse issue: if a specific version is bundled, it is most probably because a specific version is needed (due to compatibility issues or because this version contains specific changes from Google).

BTW, if you are wondering: of course this library or tool may also have dependencies raising errors due to some `*.h` file being not found, and yes you should apply this very same cyclic "try-and-see" approach.
2. Search systemwide:

```
find / -name filename.h 2>/dev/null

```

If you find "missing" the file to be already present in your system in some standard shared library location, this mean that this dependency is probably already met in your environment but the Makefile who raised the error is too dumb to find it.

If you manually directly call this Makefile, it may be possible for you to set some environment variable fixing this (`LIBDIR=/usr/lib make` for instance), otherwise you may need to modify the Makefile itself (the `pkg-config` command may be of precious help to automatically generate missing build parameters).
3. Search in the packaging system:

```
apt-cache search filename-dev

```

Where `filename-dev` represents the name of the missing file in lowercase with the `.h` extension replaced by the `-dev` suffix (for instance, if `Python.h` is not found, search for `python-dev`). Some tweaking in the exact name may be needed to find the right package.
4. If you remain stuck and that even a quick search on Internet did not provide any clear answer, then `apt-file` will be your best friend. `apt-file` is not installed by default, you need to install it and generate its database:

```
sudo apt-get apt-file
sudo apt-file update

```

`apt-file` allows you to search for packages (even uninstalled ones) providing a particular file. To avoid having too much result, I recommend to associate it with `grep` as below:

```
apt-file search filename.h | grep -w filename.h

```

If there is a package in Ubuntu's repository providing this file, then `apt-file` should be able to find it.

Once you've found the right package, install it using `apt-get install packagename` where `packagename` is your package's name.

***Tip:*** If you screwed something on your system, the command to reinstall a package is this one: `apt-get reinstall pkg_name`. It will work even when a classical remove & install would not be possible due to breaking dependencies (which is most likely for system's libraries).

# Supplementary tools

At this step, you should now have a clean environment allowing you to investigate Android's SELinux rules both in compiled and source formats.

However, most chances are that at the end of your investigation you will want to take some action. In its current shape, your environment will not permit you to modify a device's `sepolicy` file. In fact, this file cannot be easilly replaced: it is part of the device root directory, and the content of the root directory is extracter at boot time from a RAM disk file, which in turn is stored in the device's boot image.

So you still miss two things before your environment is complete:

* A way to access and modify the device's boot image,
* A way to modify its `sepolicy` file.

Fortunately, these are precisely the subject of the two last sections of this post! :)

## Fetch and update device's boot image

Tools to fetch and update devices' boot image can be used for a wide variety of things apart from SELinux rules tampering. I have therefore created a dedicated answer, please refer to it.

## Modify device's SELinux rules

You have two main possibilities here:

* Build a new `sepolicy` file from the rules in your source tree (search for `.te` files to find them: `find $ANDROID_BUILD_TOP -name \*.te`, they are spread into several directories).
* Modify the `sepolicy` file currently used by the device.

Unless you really need to build your rules from scratch, which is more a development-related task and therefore out-of-scope here, the second choice seems by far the safest one as you are sure that the only changes will be the one your explicitely made.

There has been a project to make a tool allowing you to decompile a `sepolicy` file into a recompilable form, allowing to freely edit rules in between. However this project has been abandonned in proof-of-concept state. You will find all information at the end of this blog post, the rest of the article contains enough details to allow anyone else interested to take over.

The currently recommended way to alter `sepolicy` rules goes another route: by directly modifying the `sepolicy` binary file. sepolicy-inject tool allows just that and is actively maintained.

For completeness sake, note that a fork of this tool exist. It adds a few features, some of them being on the original author's to-do list (like the possibility to remove a rule), don't ask me why they choosed to fork instead of contributing...

To compile and install `sepolicy-inject`, simply proceed as follow:

```
cd ~/android/
git clone https://bitbucket.org/joshua_brindle/sepolicy-inject.git
cd ./sepolicy-inject/
LIBDIR=/usr/lib make
sudo cp ./sepolicy-inject /usr/bin/

```

## Use-case example

Let's say for instance you want to add the autorization matching the following error message:

```
avc: denied { read } for pid=128 comm="file-storage"
path="/data/media/0/path/to/some/file"
dev="mmcblk0p28" ino=811035 scontext=u:r:kernel:s0
tcontext=u:object_r:media_rw_data_file:s0 tclass=file permissive=0

```

You will need to fetch device's boot image, then unpack it to get access to it's `sepolicy` file.

A quick check using `sesearch` shows that there is indeed no allow rule (yet!):

```
$ sesearch -A -s kernel -t media_rw_data_file -c file -p read ./sepolicy
$

```

The command has no output.

Then, use the command below to add the required rule (note the similarity between `sesearch` and `sepolicy-inject` parameters):

```
sepolicy-inject -s kernel -t media_rw_data_file -c file -p read -P ./sepolicy

```

Now we can call back our `sesearch` command:

```
$ sesearch -A -s kernel -t media_rw_data_file -c file -p read ./sepolicy
allow kernel media_rw_data_file:file read;
$

```

`sesearch` output shows that the policy has correctly been updated.

You can now repack the device's `boot.img` file and flash it back to the device. Checking the last modification time of the `/sepolicy` file is an easy way to ensure that your device is now running the newly updated `sepolicy` file.

# Conclusion

You should now have a complete environment allowing you to freely inspect and modify Android devices SELinux policies. Enjoy! :)

As a side note, there are also tools allowing to analyze and modify SELinux policy directly from the device.
> 8 votes

# Answer
You should first build an older version of libsepol from the AOSP code (like the one corresponding the 6.0 version), then link sepolicy-inject, dispol, etc against it. This recipe worked for me on debian jessie:

```
cd /to/the/aosp/dir
[repo init, etc]
repo sync external/selinux
cd external/selinux
git checkout android-6.0.0_r1^
cd libsepol
make
libsepol=`pwd`
cd /to/the/selinux-inject-source-dir
make LIBDIR=$libsepol

```

unlike the sepolicy-inject linked against the system's libsepol, this one works fine with the /sepolicy from the 6.0 image included in the android sdk:

```
$ sepolicy-inject -Z shell -P /tmp/sepolicy -o /tmp/sepolicy
libsepol.policydb_read: policydb version 30 does not match my version range 15-29
error(s) encountered while parsing configuration
Could not load policy
$ ./sepolicy-inject -Z shell -P /tmp/sepolicy -o /tmp/sepolicy
libsepol.policydb_index_others: security:  1 users, 2 roles, 525 types, 0 bools
libsepol.policydb_index_others: security: 1 sens, 1024 cats
libsepol.policydb_index_others: security:  87 classes, 4767 rules, 0 cond rules

```

For the tools included in the selinux distribution, the trick is to build them with the same DESTDIR:

```
cd libsepol
make DESTDIR=/some/dir install
cd ../checkpolicy
make DESTDIR=/some/dir
# here you have a working 'dispol' in the 'test' subdir

```
> 2 votes

# Answer
You should try to apply this patch to the sources of libsepol, and then incrementaly rebuild all that stuff. It worked for me in the sam issue

You can try to use libsepol clone with applied patch from this repo https://metizik@bitbucket.org/metizik/selinux\_tools.git I use it to build dispol under Windows, and it works to me fine (still notice that I'm using cygwin for this)
> 1 votes

# Answer
To the people facing the issue with:

```
policydb version 30 does not match my version range 15-29

```

while working with AOSP code.

Assuming, your AOSP code is checked out to **~/android/source** dir:

```
cd ~/android/source
source build/envsetup.sh
export ANDROID_BUILD_TOP=$(pwd)

```

And now you are free to use bundled **audit2allow** utility:

```
./external/selinux/prebuilts/bin/audit2allow

```

**P.S.** Also, I would like to address comment Examine android (v30) selinux policy

> Sesearch dies looking for the include file (from within another policy.h file). Do you know which module contains apol?

Building selinux toolkit from sources https://github.com/SELinuxProject/selinux is not very trivial (unless you are using Fedora). On Ubuntu, you need to install (assuming you've already installed basic dev tools like bison and C compiler) **libglib2.0-dev, libcap-ng-dev, xmlto, libsemanage1-dev, libustr-dev, libaudit-dev, libsepol1-dev**

But at the end I've still failed to compile it because of https://bugs.launchpad.net/ubuntu/+source/glib2.0/+bug/793155 and have no idea how to resolve it
> 1 votes

# Answer
audit2allow, audit2why, and sesearch are all broken with the update AOSP upstream policy to v.30.

You have to apply patches below and rebuild your Android tree to update policy db. These patched already merged to master branch and available starting from Android N.

https://android-review.googlesource.com/187140 https://android-review.googlesource.com/187111
> 0 votes

---
Tags: selinux
---


title: Adoptive Storage on Galaxy S7 edge

text:
# Question
Title: Adoptive Storage on Galaxy S7 edge
I have a S7 edge. When I plug it into my pc it reads 2 separate volumes under phone, 32gb for S7 and 128 for sd. I'm able to freely transfer data between the phone's internal storage and the sd card and the computer. Then I went ahead and turned on the adoptable storage on my device. I then plugged my phone back into the computer but now it only reads 32gb of internal(phone) storage only, not the additional 128gb=160gb. I unplugged my phone from the computer and went into the device storage. It showed that I had 138gb(22gb was already being used by the device). Then the phone asked me if I was ready to migrate data from the internal storage to the sd. I wasn't sure what to do so. I didn't want to migrate data then not be able to access them through my pc or laptop so I canceled then reformatted the sd card as a external storage. I want to turn on adoptable storage but need to know why when I first attempted to do so my pc only saw 32gb instead of 160gb(32gb+128)? Was I suppose to migrate data in order for it to read 160gb? Is it normal for my pc to only see 32gb on the device but will still be able to access ALL of my data through my pc or will it only see the 32gb and whatever the phone decides to store on the sd will only be visible on the phone. One final question...if I'm only able to transfer files from the actual 32gb on the phone will I be able to transfer the other files,data stored on the sd through NFC or Bluetooth?

# Answer
It's because once the sd card is converted to adoptable, the pc will no longer see it. Only the original 32g will be recognized, but you will still have all of the extra space correctly. You'd have to transfer items to the main storage, then move them to the adoptable storage from the phone.
> 0 votes

---
Tags: 6.0-marshmallow, adoptable-storage, samsung-galaxy-s-7-edge
---


# Question
Title: Android Chrome wifi “Sign into Wi-Fi network” how to disable redirect to www.Google.com
When I connect my Android device to wifi that needs login via web page Device has notification that says "Sign into Wi-Fi network".

Clicking on this notification automatically opens default browser (in my case Chrome) and redirects to www.google.com.

However increasingly more login pages do not meet Google's increasingly more stringent security requirements eg no https or certificate not matching domain etc and I can't login to page.

Instead I have to manually redirect browser to another page for example www.cnn.com to get redirected to wifi access point login page.

Is this a browser default that I can change? Is it possible to change default redirect page from www.google.com to say for example www.cnn.com?

# Answer
As I answered here, if you're rooted,

> Just execute `su` then `settings put global captive_portal_server SERVER_YOU_WANT_TO_USE` in a terminal emulator app or ADB shell.

However, not all servers respond properly to HTTP 204 requests, so CNN might not be feasible for example. A possible list of usable ones can be seen in this answer.
> 1 votes

---
Tags: wi-fi, chrome-for-android
---


title: Moto X Pure Edition MetroPCS tethering

text:
# Question
Title: Moto X Pure Edition MetroPCS tethering
Need help w Moto XPure Edition tethering on Metro. The plan I have came with tethering on there Phone but my Unlocked MXPE shows other devices connected but no internet connection. The lady at Metro says that because its not a metro phone but it is unlocked. Everything else worked but the tethering. What should I do? Do I need to root? Is there anyway to extract their Mobile hotspot app from my Metro phone and install on my Moto. I can't find it on the metro phone except on one of the screens and not the apps setting. Thanks Please help. Rawfah

# Answer
http://forum.xda-developers.com/moto-x-style/general/moto-x-pure-mvno-carrier-ting-vs-t3218182

One irritation with Ting was that tethering only worked on 3g. Which required manually setting the phone to 3g, after enabling the hotspot. You

MetroPCS in contrast does not allow tethering unless you purchase a metro branded phone.

I was able to work around the metro pcs tethering restriction by adding a "tether\_dun\_required=0" entry to the sqlite provider.settings file, and now it works perfect on LTE with the stock hotspot software.
> 0 votes

---
Tags: tethering, moto-x
---


title: Microphone issue Samsung GS2

text:
# Question
Title: Microphone issue Samsung GS2
name is Blenderpony

Since half a year now I am stuck with a problem.

My Phones (Samsung GS2) Mic level is ridiculous low. You barely hear anything. Ofc Some would suggest that the mic might be broken or anything. But its not.

If I do a factory reset. The Mic works how its supposed to. Nice loud and clear. No annying background Noise, nothing.

But the moment I turn on wifi or mobile data. And all the updates from the google play store or samsung with it.. My mic just decides to knock the volume level down to 1% out of of possible 100

There isnt really a setting I can use to get it back up.

The Service menu isn't working because Samsung blocked it in the most recent OS updates.

There arent any apps because the Phone is not rooted.

# Answer
> 0 votes
Dude, I had same problem with one of my device few months back. What i did i kept reseting my phone to factory level and it use to get fixed for a while. But later on it use to give me same problem. Then i restarted my phone safe mode and tried testing the mic. It was working fine, then i uninstalled all unnecessary app. That fixed my problem. Please give it a try. If that doesn't work for you. Try reinstalling your phone's OS yourself or go to the service center. That will surely fix your problem.

---
Tags: microphone, application-autoupdate
---


# Question
Title: How to send a variable value to and receive it in a task?
I've a OnePlus One with rooted Cyanogen OS 12 and Tasker v4.8. I've a bash script in PC which when exiting requires a Tasker's task to be executed. I've seen the question Running a tasker task via SSHDroid (or adb shell) and although the accepted answer didn't work on my Android, the solution is very simple. To call a task, do:

```
adb shell su -c am broadcast -a net.dinglisch.android.tasker.ACTION_TASK --es "task_name" "TASK_NAME"

```

However, that's all I can successfully do. During exit, my script needs to pass the exit status to task so that I can continue my processing on device based on script's result.

The official guide for invoking tasks is meant for programmers, so that didn't help me. Per the thread Launch Task via Intent I attempted various ways to pass a variable's value, but to no avail.

When we invoke a task from an another task, we're given the flexibility to pass values using two variables. Those two variables can be received by the invoked task using the name `%par1` and `%par2`. In my demo task, all I'm doing is Alert → Flash → Text → `Show me: %arg1 %par1`.

```
# For demonstration only, I created a task named "lol"

adb shell su -c am broadcast -a net.dinglisch.android.tasker.ACTION_TASK --es "task_name" "lol" --es "varNames" "par1" --es "varValues" "received"
adb shell su -c am broadcast -a net.dinglisch.android.tasker.ACTION_TASK --es "task_name" "lol" --es "varNames" "%par1" --es "varValues" "received"
adb shell su -c am broadcast -a net.dinglisch.android.tasker.ACTION_TASK --es "task_name" "lol" --es "varNames" "Par1" --es "varValues" "received"    # I also changed the variable name par1 to Par1 in task
adb shell su -c am broadcast -a net.dinglisch.android.tasker.ACTION_TASK --es "task_name" "lol" --es "varNames" "%Par1" --es "varValues" "received"

```

All those said commands execute with this output

```
Broadcasting: Intent { act=net.dinglisch.android.tasker.ACTION_TASK (has extras) }
Broadcast completed: result=0

```

Even sending this broadcast works

```
adb shell su -c am broadcast -a net.dinglisch.android.tasker.ACTION_TASK -d "task:lol" --es "arg1" "received"  # I setup a profile to listen to this intent and receive extra from it in a task linked to profile

```

But calling the task directly and then sending the variable value doesn't do anything.

So, where is the fault in my approach and/or how do I send to and receive in a variable value in a task ***only using command-line***?

**Note** that I'm not looking for a workaround. I'm perfectly able to come up with many workarounds to receive exit status from my script on device, but using intent appears to be the most straightforward solution of them and I want to learn this technique too.

## Update

I raised my query at:

I received this reply from Pent, both through email and on forum

> You would have to be able to add a StringArrayList extra to the adb call with -e, don't know if adb can do that.
>
> If so, to see the format you can look TaskerIntent.java http://tasker.dinglisch.net/code/TaskerIntent.java, the function addLocalVariable, if you understand java.

And that is exactly what I later surmised after posting this question.

Per the answer here, I believe a string array can be passed using adb. So I attempted some queries but again met a dead end.

```
adb shell su -c am broadcast -a net.dinglisch.android.tasker.ACTION_TASK --es "task_name" "lol" --es "varNames" '{"arg1"}' --es "varValues" '{"time"}'
adb shell su -c am broadcast -a net.dinglisch.android.tasker.ACTION_TASK --es "task_name" "lol" --es "varNames" '{"par1"}' --es "varValues" '{"time"}'
adb shell su -c am broadcast -a net.dinglisch.android.tasker.ACTION_TASK --es "task_name" "lol" --es "varNames" '{"par1"\,"arg1"}' --es "varValues" '{"received"\,"again"}'

```

I also converted the intent to URI using `am to-intent-uri` and tried sending the intent URI directly, with no success again.

## New update

Based on the readings *viz.* ,  and , I'm absolutely sure that a string array can be passed through `adb shell am` using `--esa` argument. Example:

```
adb shell su -c am broadcast -a net.dinglisch.android.tasker.ACTION_TASK --esa "par" "lol, cat"    # value lol goes in par1 variable and value cat goes in par2 variable

```

That said, this query still fails:

```
adb shell su -c am broadcast -a net.dinglisch.android.tasker.ACTION_TASK --es task_name "lol" --esa varNames "arg1, par1" --esa varValues "lol, cat"

```

## New update #2

You can use stock Android 6.0.1 as a testing ground.

# Answer
> 1 votes
Based on @firelord's findings and `am`'s in-app document (output of `am`, no arg). This worked on my phone running 6.0.1:

```
$ su -c 'am broadcast -a net.dinglisch.android.tasker.ACTION_TASK --es task_name TASK_NAME --esal varNames %VAR_NAME1,%VAR_NAME2 --esal varValues VAR_VALUE1,VAR_VALUE2'

```

---
Tags: tasker, command-line
---


# Question
Title: Nougat downloaded but now not in notifications
I got an over the air nougat update on my Nexus 5x phone. I downloaded it but hadn't installed it yet. Now I don't see the notification on the phone. How can I get it back so I can click to install it? Note I already tried check for updates but no luck there.

# Answer
> 0 votes
If you don't want to sideload it I believe you will get it with the next OTA wave. Also, I remember people were forcing OTA with Google Service Framework disabled back when 5.0 came out, but I havent tried it so I really don't know if that works or not. Here are the steps if you want to give it a try:

1. Find Google Service Framework in the Apps section of your Settings menu
2. Force stop it.
3. Try the System Update option now.

---
Tags: 7.0-nougat
---


# Question
Title: Facebook mobile website tries to open Messenger all the time
On Facebook's mobile website on my sister's phone, when you click the messages tab, it first opens Play Store opened on Messenger app (or, it opens Messenger if it's installed). If you click back, the messages page is properly displayed, but if you click on a conversation the same thing happens -- Play Store pops up, but when you click back, the proper conversation page is loaded in Chrome. Phone: Moto G 3rd gen, Android 6.0.1

On my phone the mobile website in Chrome works just fine -- there's a button that suggests installing Messenger, but I can normally browse and use messages. Phone: OnePlus 2, Android 5.1.1 (OxygenOS 2.2.1)

Is there any way to prevent the facebook website from trying to open the app? I certainly don't want to use any FB app.

---

Details on what I already tried:

* installing and uninstalling messenger
* clearing defaults and clearing data for both chrome and messenger
* if you copy a link to conversation's page and open it in new tab, it opens the page properly (without jumping to Play Store), so is it a malicious script from facebook itself?

# Answer
> 5 votes
Facebook started forcing this change a couple of months ago. There's nothing anyone can do about it. I find it rather annoying myself which is why I switched to a Facebook wrapper app like Swipe It has a workaround for this behavior. I suggest you do the same.

# Answer
> 4 votes
Try using https://mbasic.facebook.com It's not as pretty and you have to click "See Older Messages" and "See Newer Messages" a lot, but it's quite functional and fast.

# Answer
> 2 votes
Just realized I was responding to the duplicate question, but here's another solution: Use Adblock Browser. It's a free browser that disables a lot of ads, and even though some mobile sites might act strange (which is why I still use Chrome), it stops facebook from opening up the Play Store. Hope that helps.

Edit: I've been told that other mobile browsers, namely Dolphin and Lightning, don't have the auto-linking.

# Answer
> 2 votes
If you don't want to install another app, there's a way around it. Although not elegant, you can tell Chrome to "Request desktop site" from the device's menu button. Have to manually change the URL from m.facebook.com to www.facebook.com afterwards, and the site is, as expected, large and unwieldy. But it works.

I've just installed the Adblock Browser as suggested by nguyen\_c and it works a treat. Thank you for that suggestion!

# Answer
> 0 votes
In chrome go to option there click on request desktop site . Play store will not open. This works

# Answer
> 0 votes
I was extremely annoyed by this thing (in Firefox). Then I downloaded a Custom User Agent add-on (which I believe is also available for Chrome), removed "Android" from the UA string, and now I don't get the annoying Play Store poo up.

# Answer
> -1 votes
This happens when you are try to access chatting from Facebook App. Try Facebook using Google Chrome and you can not redirected to download messenger app. You can chat by Chrome mobile.

---
Tags: chrome-for-android, facebook
---


title: Pictures music and videos not showing

text:
# Question
Title: Pictures music and videos not showing
I am having this issue from last 1 month. Whatever pictures I am receiving or videos or music I am downloading is not visible to me in the gallery or the video or music app. But it is visible in the file explorer. My phone does not support SD card. It already posses 16 gb memory.

I don't know what I have done. May be I have deleted some important cache files or something like that. Only the pictures I am capturing is visible in the gallery. I scanned my music app as well but it does not show me the new songs I have added. Same problem with the video app.. Every time I have to visit the file explorer to see these things. Please help me out

# Answer
> 0 votes
Make sure your photos/videos/music are not inside android folder of your phone. Those places are usually skipped by the scanner. Power cycle your phone if possible. If nothing works you might wanna reset your phone from settings-\> backup and reset

# Answer
> 0 votes
You might want to use your file explorer and go to its settings and enable `Show hidden files`.

Now navigate to the folder where you received the images/music and look for a file named `.nomedia`. This file tells the OS to not look for media in that folder. You can delete that file and your media should now show up in the Gallery.

It might take a couple of minutes for your phone to reindex once the `.nomedia` file is deleted.

---
Tags: 4.4-kitkat, internal-storage
---


# Question
Title: How can I find my Samsung Galaxy S5 without internet, or access to Android Device Manager?
I have a Samsung Galaxy S5 that just recently went missing. However, I do not know what email address I made for the Google Account on my phone. I was told I could use Android Device Manager if my phone was connected to the internet & I had to be signed into the Google Account that I had set up on my phone. I do not know the email I used, & I also know for a fact that where my phone is (yes, i'm pretty sure I know who took it) that it isn't connected to the internet. I also have no plan on it right, no minutes, time, no data, no way for it to pick up internet unless it's in Wifi. I was only able to get it to connect to one Wifi near the place where I'm thinking it was stolen. I know it's on, but I'm not sure how much longer my battery is going to last. I really, really need to figure out a way to find my phone. Please any help, or advice is greatly appreciated. Thank you!

# Answer
0 down vote I believe that when you signed up your phone,system email,you must provide an alternative email address for p/w & user name recovery as is common w/Google & most effective email providers. Click on "Gmail"-tab, while on Google Chrome homepage browser,(using a desktop windows pc prefferably) try your best guess at the username, hit enter and under the sign in popup window there should be either "use a different. Account" or "Forgot user name/password"? Click on that and it should tell you something like, "Recovery email,Google will send you an email containing a one time verification code to xxx.....@xxx whatever the alternative email account you used when you set up your phone. If not,then I,might suspect of your true ownership of this phone you speak of. Hope this helps.
> 0 votes

---
Tags: email, samsung-galaxy-s-5, lost-phone
---


# Question
Title: How can I set my bluetooth visibility on all the time with lollipop?
I use my phone as a beacon. When I show up places, other bits of hardware notice my bluetooth presence and do things. As of lollipop apparently this doesn't work anymore because there is no way to have bluetooth visibility on all the time.

Is there a way I can force bluetooth visibility on all the time?

I'd really rather avoid writing yet another app, especially if somebody already has one, but I have had no luck finding anything on the play store.

# Answer
> 0 votes
This app sorta does what I want, but it doesn't start on boot, which means I've have to push some buttons which defeats the purpose. I'm trying to automate the process.

https://play.google.com/store/apps/details?id=com.tcompany.bluetoothdiscovery&hl=en

So the answer will be, I write the app myself. Thanks for the help.

---
Tags: 5.0-lollipop, bluetooth, 5.1-lollipop
---


title: How can i restore an old backup

text:
# Question
Title: How can i restore an old backup
So I uninstalled my WhatsApp application but I didn't restore my old data because of a connection problem when I reinstalled it so I uninstalled it again and now the backup is not the old backup that I want. what can i do to restore the old backup?

# Answer
> 0 votes
I think if your WhatsApp backup on GoogleDrive is not what you want, you can't do anything about this online Backup.

If you have a backup of your sd-card / your previous WhatsApp files you can replace the new WhatsApp files with this backup.

Maybe this helps: https://www.whatsapp.com/faq/en/android/20887921

---
Tags: backup
---


# Question
Title: How to use GPS/Maps without an Internet connection?
I need a way (possibly a third-party application) that allows me to use maps and GPS without an Internet connection.

I don't use it by car, just for walking in cities. It would be nice if I could just copy all data relative to a particular city before going there for tourism.

The Google Maps app does not store maps reliably, so it is risky to rely on it without an Internet connection.

# Answer
> 4 votes
I am now using OsmAnd.

It stores OpenStreetMap maps on the phone's storage.

OsmAnd uses a vectorial format, which means it can store a lot of information without taking too much space, and is visible in all zoom factors.

You can download the maps you want, for instance Italy, Bolivia, or any other country/region.

Free, open source.

# Answer
> 24 votes
ⓘ Many of these applications use map data from a really cool free map project called OSM (OpenStreetMap), which anyone can contribute to. Most of the OSM-based apps won't have traffic information.

**Free:**

* Google Maps
* HERE Maps
    + Unless you specifically want an OSM-based app, this is probably the best free option out there. Has offline maps, turn-by-turn navigation, full street addresses, points of interest, alternate routes, traffic, public transport, and speed limits.
* Organic Maps
    + Open-source fork of Maps.me, uses data from OSM. More user-friendly than OsmAnd. Features offline maps, cycling routes, hiking trails, elevation maps, turn-by-turn navigation, dark mode, and more. No traffic information.
* OsmAnd
    + Open-source, uses data from OSM. Much more advanced than Organic Maps but potentially more complicated to use. No traffic information.
* MapFactor
    + OSM-based offline navigation. Fairly basic but promising. TomTom maps and traffic available as in-app purchases.
* Many others based on OSM here: Android - OpenStreetMap Wiki

**Paid:**

* CoPilot GPS
    + CoPilot Live is a very nice, full-featured app, which will let you download maps ahead of time and use GPS offline. I ended up using it because the US version was so cheap compared to the other paid navigation apps, but I've been very pleased with the quality, features, customer support, and free app and map upgrades. It has all the features I could want in a GPS app, the only downsides being you have to have a paid subscription for traffic data (the paid app includes a free one-year subscription), and you will have to buy new maps if you travel outside your purchased area.
* Other paid apps that I haven't used:

There are detailed reviews of many Android GPS apps here: Android Sat Nav Apps

# Answer
> 14 votes
Google Maps 5.0 now supports offline mode!

# Answer
> 11 votes
I haven't had a chance to try it myself yet, but I've heard good things about Maverick:

Maverick for Google Android - Code Sector

There is both a limited free and pay version.

# Answer
> 3 votes
For England and much of Europe, ViewRanger is great. Supports Ordnance Survey and other official-type maps; also some open street map projects. But it is absolutely what I would use -- and do -- if I am hiking with a phone. For Android - ViewRanger

# Answer
> 3 votes
I regularly use Locus. It doesn't have much in the way of navigation support (although I think this is in the works), but for off-road and off-line use it's fantastic.

It allows downloading of maps for off-line use, supports SQLite and GEMF maps, which allow large map (2GB limit for SQLite, no realistic limit for GEMF) tile sets on your SD card without wasting masses of space. It also supports vector maps as well as bitmap ones (more coverage, less disk space). It has a very good interface and is well supported.

There's a free version with ads which doesn't support in-app map downloading (I think), although you can use your PC to download the maps. The paid version is not expensive.

That all sounds excessively glowing, so I should emphasise that I'm not the developer and have no affiliation; just a very happy user!

# Answer
> 2 votes
Have you tried BackCountry Navigator?

BackCountry Navigator

It has topo maps, open street maps, and aerial photography.

It has a 16 day demo and a paid license.

# Answer
> 0 votes
Maps (-) allows to store maps for offline use from OpenStreetMap, from OpenCycleMap and from Google Maps.

# Answer
> 0 votes
If you are looking for North American maps (and European maps as well I'm told), than I can recommend CoPilot Live. It's not free though.

# Answer
> 0 votes
You might want to use Sygic if you are in India. It comes with free maps.

# Answer
> 0 votes
Mapy.cz is the easiest to use app and now it has all the content of the whole world for download to offline in vectors (which means smaller files).

It is both for cities and tourism. For navigation it currently needs a network, but they claim they'll make it offline as well.

It is free. The world is covered by a great render of OpenStreetMap. The Czech Republic has its own (great) cartographic data.

---
Tags: gps, offline, maps
---


# Question
Title: Consequences of disabling com.android.SystemUI
I have not been able to find the consecuences of disabling the SystemUI app (`com.android.systemui`) on Android Lollipop. The tablet is rooted so to disable it I just have to send the command `pm disable com.android.systemui` on ADB.

So far no app has crashed or have I seen any issues. The soft buttons and the quick settings and notifications bar dissapeared. Does someone know if there are any other consequences?

# Answer
> 4 votes
Is it safe to disable com.android.systemui? from Stack overflow :

> If you completely remove SystemUI.apk from the system, your device will hang on start-up and never fully boot again. Tried it before. ;) Framework-res and the system have some dependencies on SystemUI.

Please also read the comments where OP did what you proposed and is warned that it could result in *soft bricking* the device.

---
Tags: 5.0-lollipop, 5.1-lollipop, system-apps, disable-app
---


title: S-pen SDK Compatibility

text:
# Question
Title: S-pen SDK Compatibility
Has anyone seen the S-pens SDK in the Play Store or galaxy apps store? What exactly is it for and even if I'm not developing any kind of modifications to the S-pen feature of Samsung phones can I download the app to enable an S-pen to be used with my phone? My phone is a Galaxy A5 (2015)

# Answer
> 1 votes
* Your device does not have S Pen feature
* S Pen SDK app on Play Store is for

> This is the downloadable library for the Pen package, which is a part of the Samsung Mobile SDK. With the library installed, your application regarding SPen is able to use the **latest Pen package features.**

( Emphasis supplied)

* So, **no**, you can't download the app and expect to have S pen enabled on your device, since it doesn't have S pen to start with. Quick search on XDA didn't show any mod / custom ROM which has S pen feature
* S pen SDK that can be downloaded from OEM is for *developers* to develop applications using S Pen

---
Tags: google-play-store, samsung-galaxy-tab, s-pen
---


title: How do I root an LG Phoenix 2?

text:
# Question
Title: How do I root an LG Phoenix 2?
I put Kingroot and many other rooting apps on my laptop and phone and all say failed it's a LG Phoenix 2 6.0 marshmallow please help,I did everything to root and still nothing.

# Answer
There is no Root method out A.T.M. Kingroot has gotten 18059 requests (time of 9-11-16 2:34AM) so they might work on it soon
> 0 votes

---
Tags: rooting, lg-phoenix-2
---


# Question
Title: Prevent one particular autocorrect in Google Keyboard
On Google Keyboard, if the app thinks you've mistyped a word it will autocorrect it.

Is there any way to prevent the autocorrect occurring in some particular circumstance? I don't want to totally disable autocorrection all the time and I don't want to add the word to my dictionary. If I let it autocorrect I can do two backspaces to undo it, but that's tedious; is there a way to prevent the autocorrect from occurring at all?

# Answer
> 0 votes
To my knowledge, adding the word to your dictionary *is* the solution for this problem.

---
Tags: auto-correct, gboard
---


# Question
Title: Difference between system app and 3rd party apps?
I was reading about best system optimisation app for android, and this thought came into my mind as what's the difference if you optimise through a 3rd party app or the system app.

So let's say I am using X app (3rd Part) and I clean the space other app are using. It shows me how much memory it was using and shows me available space that I get after performing that action.

Now if use the android system app to the same action, it shows some that there was some space that was realised hence allowing me to optimise . If both do the same whats the difference ?? In using 3rd party app and System app. !!!

Confused

# Answer
> 0 votes
Both do the same job but you can more rely on system app rather than 3rd party app.Because all they have the permissions to do so more efficiently.If your device is rooted then all the permissions you can set to the app as your requirements.

---
Tags: applications, system-apps, optimization
---


# Question
Title: Home screen doesn't use the full screen width
So as of a couple days ago, something is different about my home screen(s). Where once the icons were evenly spread, now they're crammed to the left, leaving a bar of empty space in the right that just shows my wallpaper.

I could deal with this, but I can no longer swipe left from the right edge of the screen to get to my other home screens - it only works if I start the gesture on the part that has icons. How do I get the full width back?

# Answer
> 0 votes
The only thing I can think of is clearing the cache and data for your android launcher. If you go to settings -\> application manager and then to all apps, you should eventually find your launcher. I would recommend taking some screenshots of how your home screen is organised before doing this though; this will end up getting rid of your home screen layout.

---
Tags: 5.1-lollipop, home-screen, moto-x
---


title: Restoring apps from TWRP

text:
# Question
Title: Restoring apps from TWRP
I have a backup of my previous `MIUI` ROM(using TWRP), and presently, I am on custom ROM called `cyonogenmod`. Now, I need to restore my previous user apps(apps that are installed from Play Store) and its data that run on MIUI to new ROM. How can it be done? Is this possible?

# Answer
> 0 votes

---
Tags: cyanogenmod, backup, custom-roms, twrp, miui
---


# Question
Title: Identifying an icon that looks like two persons standing in a line
I found this unknown icon in my status bar. What does it stands for?

Click image(s) for larger version

Device : Coolpad note 3 running Android Marshmallow

# Answer
I figured it out but thanks everyone for there help. This icon is for meeting mode, somehow I enabled it.
> 1 votes

---
Tags: notification-icons
---


# Question
Title: How can I move a system app from one phone to another?
I like the music player on my older samsung phone and want to have it on my new phone. The music player is a system app and I can't simply install it in .apk form normally. Is there a way I can move it to my new phone?

# Answer
There are many apps which can take backup of system app like AndroZip (it can save .apk file of system app in sd card) then you can transfer it to your new phone via bluetooth etc.

Steps To Backup App Using AndroZip.

* Open AndroZip
* Go To **App** tab.
* Check Music Player you want to get apk.
* Click Backup.

apk file will be in app\_backup folder in sdcard.
> 0 votes

---
Tags: samsung
---


title: Nexus 6P Heating Issues

text:
# Question
Title: Nexus 6P Heating Issues
I have a Nexus 6P 64 GB which is just 4 months old. I feel that the phone is getting hot more than normal, mainly the display. When I do browsing say for 10-15 mins or shoot videos (4K) 2-3 mins or take HDR photos 10-15 photos in succession, the phone gets hot from every nook and corner. My local service center is not very high tech. The only solution they suggested is to flash the OS. I do not to what extent this is going to help. I did nt buy the phone from Google Store but from other online partners in India. I sought help of people around here or users of Nexus 6P about their experience.

Thanks.

# Answer
I recently bought a nexus 6p myself and upgraded it to Nougat (Android 7.0). It burns like a stove after playing 10 minutes of any 3D games (in my case, Walking Dead: No man's land), and that's both before and after the system update. I think the following article explains the reason pretty well, it's all about the processor: http://www.androidheadlines.com/2015/10/huawei-nexus-6p-good-bad-ugly.html

I tried wrapping an ice pack with a towel under my phone while using it and it helped a lot. I'm not sure if that's good idea though because people say that it will definitely cause condensation inside the device and void the warranty.
> 0 votes

# Answer
Please ensure that you have a fan with a cool cloth(ice water soaked) draped over it blowing on your 6P. Do not use the phone outdoors for long periods, use mainly in air condition and never leave in your car.
> 0 votes

---
Tags: overheating, nexus-6p
---


# Question
Title: Restore nandroid backup on an other phone
I have a nandroid backup of a huawey y600 and I have to restore it in an other huawei y600.Can I do that?If I do that the imei will change on the phone in wich I do the restore?

# Answer
The guy in this site did this. It might work if you have TWRP because he did this

1. Made a quick backup to generate the proper folder structure and the correct directory name needed for my new phone.
2. Copied the folder that contained the backup I intended to use from my old Hercules S2 to my replacement Hercules S2's TWRP backup directory. 3.Copied the name of the folder of the backup I made in step 1 to the clipboard.
3. deleted the folder I created in step 1.
4. renamed the folder I imported by pasting the name from the clipboard.
5. restored the backup. Done.

The link to the chat discussion http://forum.xda-developers.com/showthread.php?t=1949020.
> 0 votes

---
Tags: adb, backup, stock-android, nandroid
---


# Question
Title: Google Maps blue arrow does not appear on the blue location dot (to show direction)
My Google Maps app shows a blue dot to indicate my current location, but (unlike on all of my friends' Google Maps), the blue dot does *not* show a compass-based arrow to indicate which direction I'm facing.

**How can I fix mine so that I can know which direction I'm facing?**

I've seen online that other people have had similar problems on iOS.

By the way, I've tried clearing cache, force-stopping the app, changing my language and fonts, calibrating my compass, and I've read these tips too.

I want the direction-indicating arrow so that I know which way I'm facing even without entering a destination and switching into Navigation mode.

Also, double-tapping the "blue target" symbol in the bottom right (as suggested here) does not change that symbol into a compass (or do anything different from single-tapping, which centers the map on my current location).

I'm using Android 6.0.1 on a Motorola Moto G4 Plus.

P.S. This question is not relevant because that person *can* see the blue arrow, and my blue dot has no arrow at all.

# Answer
> 2 votes
I thought the Moto G4 Plus had no compass. I own one I like it but I thought it had no NFC or compass in the hardware. Maybe that is causing some of your issues?

---
Tags: google-maps, google-maps-navigation, maps, compass
---


# Question
Title: Audio notes & voice recording stop abruptly in Google Keep
I've recently been trying Google Keep for its speech-to-text feature. The problem I'm having though is that it only records a couple of seconds then stops; usually about 2 to 7 seconds.

I tried it several ways and made sure my fingers aren't on the screen while I'm recording, so I don't think I'm accidentally tapping the screen to stop the recording.

Is the problem likely with my phone, or is there some setting I need to change? I assume I don't need to upgrade $ to make notes that are longer, do I?

# Answer
> 2 votes
After trying the voice recording I've found that the recording stops whenever there is silence for a few seconds. In other words, to make a long recording you'll need to talk continously.

I've so far found no way to increase the length of this silence period in order to stop the recorder from prematurely stop recording. Please comment if you know how to do that.

---
Tags: voice-recognition, google-keep, voice-recording
---


title: Kyocera Hydro doubling in status bar

text:
# Question
Title: Kyocera Hydro doubling in status bar
My Kyocera Hydro has a weird doubling effect on status bar; I would send a screen shot I have if I knew how. I looked at everything in the settings and just can't figure it out.

# Answer
Volume down and power button work for screenshot
> 0 votes

---
Tags: notification-bar
---


# Question
Title: Is charging with a USB-C adapter and a type A charger dangerous?
According to articles on HowToGeek and other sites, it can be dangerous to charge a phone with a USB-C connector by using a non compliant adapter cable and a USB type A charger or laptop outlet. I am wondering whether the same problem (drawing too much power for the cable to handle) occurs when using a micro USB to USB-C adapter like this one together with a generic cable?

My guess is that it is just as dangerous because the reasoning from the article can be applied to the adapter instead of the phone. Can someone shed some light on this? I am about to recommend an adapter like the one linked above to a friend and I don't want her to ruin her charger or worse.

This question is not a duplicate of this one, since I am specifically asking about using an adapter + an older cable instead of an adapter cable.

# Answer
Description of your adapter holds the key :

> Charge & Sync: Uses USB 2.0 protocol for high-speed Micro USB charging and fast data transfer (480 Mbps). **Has a 56K? pull-up resistor for unbeatable safety and reliability**

(Emphasis Added)

This kind of resistor is to specifically cater for **generic** cables - from the section Good and bad cables

> The specification table below shows what values can be used to set a specific Type-C charging mode and underneath, in the small print, we can see that a 56kΩ resistor **should be used with all legacy cable connections. This is to limit the amount of current transferred to Default USB power** or the USB Battery Charging standard (if the cable supports fast charging) when connecting up to older USB type devices.

In the specific adapter of yours, it is catering for legacy cables as a precaution whether the cable has it out not

**tl:dr;** You are good with this adapter
> 1 votes

---
Tags: charging, compatibility
---


title: Resize /system partition of Galaxy S 2

text:
# Question
Title: Resize /system partition of Galaxy S 2
I need to increase the size of my Galaxy S 2's `/system` partition from 503.4MB to... Well, anything possible.

The (main) reason why I want to do this is because I want to install `GApps 20140606`, which is not compatible with devices with small *(under 500MB)* `/system` partitions.

The Galaxy S 2's internal storage is 16GB but I mostly use my SD card, so I don't really care how much of this will be taken to use in the `/system` partition.

I've found a lot of pages explaining different methods to achieve this, like this one from TechoTV, and this one from XDA, but all of them were phone-specific and never gave the information if it would be compatible with other models or not, or they would resize to a specific set size.

There's also this question from Android SE, but the answer weren't satisfactory enough for me, as the author limited himself to only say that it *is possible*, but not saying *how*.

To add a few more information, the phone is rooted and with CyanogenMod 11 (20140806-NIGHTLY), which is Android 4.4.4.

It would be interesting if the information provided works under Linux. I have access to Windows but rather not have to use it.

Aren't there any simple way of resizing the partitions, like GParted (but for Android)?

# Answer
> 22 votes
# Firstly and most important, the credits:

I made this following this great tutorial at XDA-Developers by user `metalgearhathaway`: http://forum.xda-developers.com/galaxy-s2/development-derivatives/mod-partition-internal-memory-app-t2538947

I used `PIT` files (I'll explain what they are, don't worry) made from user `ElGamal` from XDA also, located here (comment number 509).

And a little bit of help from user `CrackDaddy`, also from XDA.

# Second, what you'll need:

* A machine running Windows. I used Windows 7 Ultimate 64-bits;
* Odin 3.07. Careful when installing, it is full of optional AdWares. There's also a Linux and Mac version available called JOdin3, but I didn't try it;
* Flashable ClockWorkMod 6 for Galaxy S II (it is a `.tar` file with a file named `zImage` inside);
* `PIT` file with desired partition table configuration;
* Samsung drivers for Galaxy S2. Usually you can install Samsung Kies but there's also a installer just with drivers available;
* Your original stock unrooted Samsung Jellybean firmware. You can find it at sammobile.com;
* Any ROM of your choice. I highly recommend the last nightly build of Cyanogenmod 11;
* Optionally: GApps 20140606 or newer.

I made most of those available in the following bundle file: https://drive.google.com/open?id=0BxccpydIocBpd21FOE5MaGJiMkU&authuser=0

What is missing is GApps, CyanogenMod, and a stock Samsung JellyBean ROM (as it depends of country and carrier, and might not be legal to provide it here).

# Third, the default warning:

> I am not responsible for anything that might go wrong with your device, neither any of the mentioned users nor anyone here at Stack Overflow or XDA-Developers. This procedure will root your phone if it isn't already and also void your warranty if it isn't already. If anything goes wrong, don't panic, it is most likely fixable by reflashing the stock ROM and starting over again.

# Finally, how to:

## This will only work with the 16GB International version (GT-I9100) of Samsung Galaxy S II

Firstly, copy CyanogenMod 11 `.zip` file (or your desired ROM) and optionally GApps `.zip` file to your external SD card;

Make a backup of everything inside your internal storage, copy it to your computer or somewhere else. It will be completelly erased. Don't worry about your external SD Card, it won't be touched.

Make a NAnd backup of your current ROM, you'll be able to restore it after the repartition. To do it, you must have ClockWorkMod recovery installed, then boot your phone into recovery mode (`Volume UP + Home + Power`), select `backups and restore`, then `backup to /storage/sdcard1`;

When backup finishes, reboot your phone into Download mode (`Volume DOWN + Home + Power`) and connect your phone to the computer. Let Windows install the drivers. If it fails, try to install Samsung Kies or just the drivers provided in the bundle I made available, and try again.

Open Odin3 as Administrator and connect the phone. It should detect your phone and show it under the label `ID:COM`, and also in the `Message`. If it didn't, try to restart your computer, phone, reinstall drivers, check your USB cable, etc., and try again.

Now you'll need to choose a `PIT` file. `PIT` means `Partition Information Table` and it is a Samsung-only thing. In the bundle file, I made available `ElGamal`'s `PIT` file (`I91001GB_6GB.pit`) which also resizes `/system` partition to 1GB, `/data` to 6GB and the rest goes to internal storage. If you wish different sizes, check the thread at XDA-Developers as he made many different versions available. I also included a PIT file for the default configuration (`I9100_2GB-STOCK.pit`) if you wish to go back to as it was later.

When you have chosen your `PIT` file, go to Odin and tick the following checkboxes: `Re-Partition`, `Auto Reboot` and `F. Reset Time`. In the `Re-Partition section`, click on the `PIT` button and select your chosen `PIT` file. In the `Files (Download)` section, click on the `AP` button and select Samsung's stock JellyBean ROM. Double check everything and click `Start`. This can take a while, go grab a coffee.

After everything finishes, your phone will reboot into the stock Samsung JellyBean ROM. Two things can happen now, or it will work normally and if so you can use it and check if everything is as you want. Or it can ask you for a password to access the "encrypted volume", which is nothing but your internal storage that is not formatted. In both ways, unplug your phone (it it's still plugged) and reboot it into Download mode again.

It is interesting to close and reopen Odin3 to reset the settings. Plug your phone again and wait until Odin3 detects it. This time, leave checked just `Auto Reboot` and `F. Reset Time` and make sure `Re-Partition` is **NOT** checked. Click on `AP` button and select the ClockWorkMod Recovery `.tar` file, then click `Start`. This one is faster, but if you feel sleepy, go for another coffee ;)

When it finishes, you should have ClockWorkMod Recovery 6 installed in your phone, so go ahead and reboot into Recovery mode. Go to `mounts and storage`, select `format /storage/sdcard0` and format it as `exfat` (if for some reason you have write problems in your internal storage later, come back here and select another format until it works, but `exfat` should do the trick).

When it finishes, still in Recovery mode, `Wipe data/factory reset`, `Wipe cache` and `Wipe Dalvik cache`. Let's be sure nothing remains from the previous ROMs.

Now, `install zip` -\> `choose zip from /storage/sdcard1` and select the CyanogenMod 11 `.zip` file (or of your desired ROM) and flash it. Optionally also flash GApps afterwards. Reboot your phone and check if everything is right.

If everything is right, reboot your phone into Recovery mode again, do a new `wipe data/factory reset`, `wipe cache` and `wipe Dalvik cache`, and then recover your backed up ROM from the beginning. Reboot your phone.

Check again if everything works right. A few apps might need to be reinstalled (Spotify and Waze are examples) to work correctly again, but that's be only major issue.

Hope everything goes well.

# Answer
> 11 votes
Kudos to @Bruno for a detailed solution and needed files. A **much** quicker method is listed below, which does not require installing any ROM/Gapps or reboot into the ROM in between steps. **You need** an external SD card with enough free space to hold all apps+data+photos+etc that are on your *internal* phone storage.

You can skip steps 1-5 if you already have CWM and also a NAND backup on your **external** SD card already (but make sure you have a NAND backup on your external SD or else you'll lose all data).

**NOTE:** You should backup your data from your internal SD card too in case things go awry, i.e. /storage/sdcard0 (a NAND backup does not back that up).

1. Extract the files provided by @Bruno somewhere on your pc.
2. Reboot phone in download mode (vol down + home + power) then connect it to the pc via USB.
3. Start Odin 3.09. **Un**check Auto-Reboot, put the `CWM-KitKatCompatible-i9100.tar` file in the AP section, then click Start and wait until Odin says "RES OK !!" in the Message log. This should be fairly quick, a few seconds.
4. Now reboot the phone in recovery mode (vol up + home + power)
5. Go to *backup and restore \> backup to /storage/sdcard1* -- note the 1, not 0 (your CWM may say "external sd" instead of /storage/sdcard1; just chose the backup option corresponding to the external SD card, this is **important**, otherwise you'll lose all data). Wait for the backup to finish, this will take a while.
6. Reboot phone into download mode (vol down + home + power)
7. Start Odin 3.09, **Un**check `Auto-Reboot`, **check** `Re-Partition`, put the file `I91001GB_6GB.pit` in the PIT section, put the file `CWM-KitKatCompatible-i9100.tar` in the AP section, then click `Start` and wait until Odin says "RES OK !!" in the Message log. This will take a while.
8. Reboot phone into recovery mode (vol up + home + power)
9. Go to *mounts and storage \> Format /system*, then *Format /cache*, then *Format /data*
10. Go back to *wipe data/factory reset*
11. Go back to *backup and restore \> restore from /storage/sdcard1* and restore the NAND backup made previously
12. Done. Reboot phone normally.

Procedure tested with Cyanogenmod 11 (KitKat 4.4) nightly and snapshot. Should work with any recent ROM. No need to install any custom or stock ROMs or Gapps or even boot into the ROM in between steps.

**DISCLAIMER:** I can't be held responsible if your phone starts singing or dancing Lambada (oh how I hate that song!), calls you names, blows up, loses any of your data etc.

# Answer
> 4 votes
In my case, I needed a cross-platform solution since I use Linux. Here's what worked for me:

1. Back everything up. This will wipe everything on the phone, including the internal SD card.
2. Download:

* A PIT file you want to flash. I used this one, which resizes /system from 512 MB to 1 GB and /data from 2 GB to 6 GB
    * Any compatible recovery. I used this one
    * (Optional) A ROM you want to install. I installed CyanogenMod 13 nightly
3. Download and install Heimdall
4. Boot to download mode

1. Unplug the USB cable
    2. Power off
    3. Press and hold the volume down, home, and power buttons (you can let go once you see the warning screen)
    4. Press the volume up button to continue past the warning screen
5. Connect the USB cable to your phone and PC
6. (Optional) Back up the existing PIT

```
sudo heimdall download-pit --output i9100-stock.pit --no-reboot

```
7. Flash the new PIT and recovery

```
sudo heimdall flash --repartition --pit I91001GB_6GB.pit --KERNEL cwmr6047.img --no-reboot

```
8. Boot to recovery

1. Unplug the USB cable
    2. Power off
    3. Press and hold the volume up, home, and power buttons (you can let go once you see the I9100 screen)
9. Format all partitions, including /system, /data, /cache, and the internal SD card (sdcard0)

* When formatting the internal SD card, if it asks you what filesystem to use pick fat, vfat, or exfat. **If you pick ext4 you will have problems.** (Sources: \[1\] \[2\])
    * For all other partitions pick ext4 if asked
10. Install the ROM or restore your backup

# Answer
> 2 votes
Here's what's probably an even better way: https://github.com/Lanchon/REPIT

It's as easy as flashing a zip and preserves data. Requires TWRP recovery and patience. Worked first time for me on an S2 (i9100) that already had CM13.

---
Tags: cyanogenmod, samsung-galaxy-s-2, partitions
---


title: Resizing /System Partition on Galaxy S2

text:
# Question
Title: Resizing /System Partition on Galaxy S2
I am trying to resize my /system partition on my Galaxy S2 and as soon as I partition /system using various sizes I lose all of the mobile data connectivity & IEMI number is invalid (missing)

However, returning back to stock partition and re-flashing stock ROM returns the IEMI number and mobile data connectivity is fixed.

I need to change my /system partition to 6GB but I can't find any way to stop this partition "bug". I tried hundreds of ways to fix this but none of them worked.

For the mean time I'm just running stock with root (King Root) & I have installed TWRP via the TWRP App.

# Answer
When re-partitioning the internal storage, you are wiping out the `/efs` directory that contains device-specific information, including phone's IMEI, wireless MAC address, etc. This information is encrypted, so you will need to take extra steps to back up this folder, and restore it after partitioning.

You can do this manually by following the steps for backup:

1. On your computer (assuming Windows PC) open Command window and issue the following commands:
    * **`su`** \- accept the prompt on the phone to allow root privileges.
    * **`busybox tar zcvf /sdcard/efsbackup.tar.gz /efs`** \- this compresses the contents of the `/efs` directory and copies the file to your internal SD Card, preserving the Linux file permissions, OR
    * **`cat /dev/block/mmcblk0p1 > /sdcard/efsdevblock-mmcblk0p1.img`** \- this copies the entire partition as an image to your internal SD Card. This is probably a safer method.
2. Copy the file(s) created above (**efsbackup.tar.gz** and/or **efsdevblock-mmcblk0p1.img**) from your internal SD Card to your computer.

To restore you would need to do the reverse:

1. Copy either **efsbackup.tar.gz** or **efsdevblock-mmcblk0p1.img** from your PC to `/sdcard` (the internal SD Card) of your Galaxy S2.
2. On your PC open Command prompt and issue commands to restore the contents of `/efs` folder:
    * **`su`** \- gain root privileges.
    * **`busybox tar zxvf /sdcard/efsbackup.tar.gz -C /`** \- restores only the `/efs` folder, OR
    * **`cat /sdcard/efsdevblock-mmcblk0p1.img > /dev/block/mmcblk0p1`** \- restores the entire partition containing the folder.

Alternatively, dev community members came up with apps (that you must either side-load or run from your PC) that will automate this process for you.

Keep in mind that while this works on many Samsung devices, other manufacturers store device-specific information in other locations of internal memory, so the instructions will be different, and apps may not work.
> 0 votes

# Answer
REPIT from https://github.com/Lanchon/REPIT aims to preserve exiting data.
> 0 votes

---
Tags: rooting, samsung-galaxy-s-2, partitions, system, imei
---


# Question
Title: Does auto-disabling WiFi based on GPS fences save battery life?
I came across an IFTTT recipe that auto-disables WiFi on android when leaving a geographic area. The idea being that it save battery life since it wouldn't try to use WiFi elsewhere.

Does this idea make sense? Or would GPS probing waste more battery life?

# Answer
Your question boils down to battery savings *WiFi Vs GPS* for which I am not aware of a definitive answer

* I am not familiar with IFTTT, but check if location update *rate* is possible to be varied
* Macrodroid another easy to learn automation app allows you to configure update rate, so that you can vary updates to optimise on battery

* Alternatively, if you are using GPS *only* for geo fencing, it would be better to use *cell tower* groups to use as a trigger for switching on/ off Wifi - another feature of Macrodroid
> 1 votes

---
Tags: battery-life, wifi-direct
---


title: Android update and android mod

text:
# Question
Title: Android update and android mod
I want to create a custom boot image for my Android. When I will update the System OTA I will lose my mod?

# Answer
> 0 votes
That very much depends on the OTA and what it includes: it might only replace/add some files, but it could as well replace an entire partition (usually `/boot` and/or `/system`).

So yes, an OTA system update *might* overwrite your "custom boot image" – though not all OTAs will do so.

---
Tags: adb, stock-android, fastboot, ota-update
---


title: Emoji viewing on Android 5.1

text:
# Question
Title: Emoji viewing on Android 5.1
I've seen a number of similar questions, but none have worked for me. A friend keeps sending me emojis, and 99% of the time, it's perfect and I see what I want. However, the other 1% I can't see them. I would like to know a specific one, but I am getting the little box. I've tried copy and pasting it into a browser, etc. and it still does the same thing. Please help.

# Answer
Try Emojisearch.

It displays image of searched emoji so if particular emoji is not supported for your mobile you can still see it.

FAQs on Emoji
> 0 votes

---
Tags: emoticons
---


# Question
Title: I forgot the lock screen PIN on my Moto G second gen XT-1068
I forgot the PIN number of the lock screen.

I'm unable to do anything to get into my device as both data connection and Wi-Fi are off and USB debugging is disabled. Is there any way to enable them?

Otherwise suggest a way to root the device in this state and delete PIN and also to un-root it after the problem is solved.

I don't want to factory reset as I have important data on my phone's internal memory.
My device is un-rooted and runs on Android 4.4.4.

# Answer
> 1 votes
Did you set up and activate either Google's Android Device Manager or Motorola Device Policy (Settings/Security/Device Administrators)? Both allow you to set a new password remotely (which would clear the forgotten PIN), via either https://www.google.com/android/devicemanager or the Moto Support Site respectively.

If so it might be worth giving it a try although if you did manage to Factory Reset the phone that should have removed your Google account. I'm surprised that the PIN survived a Factory Reset.

---
Tags: 4.4-kitkat, rooting, usb-debugging, locked-out, unrooting
---


# Question
Title: The device need to be converted to Unified UserData partition - Cyanogenmod
I'm trying to install latest Cyanogenmod on my Xperia T. But I get the following error:

Click image for larger version

I tried to install it several times.

**NOTE : In my phone the microSD card is not detectable. So i cannot copy the zip and install it from SD card.**

# Answer
You really should've read either the XDA thread or the CM Wiki before doing any of this...

> Migrate to the one big partition for CM-13.0 :
>
> * (Optional) Backup all your data, applications, internal storage, ...
> * (Optional) Empty the internal storage with the old ROM or TWRP 3.0
> * (Optional) If wished, do a full Nandroid backup from Recovery
> * Flash the latest ROM zip of your device to start the unification
> * Read and follow the instructions from the zip if anything goes wrong
> * (Optional) Restore your Nandroid backup if you want to
> * Flash the same ROM zip for CyanogenMod 13.0

So in other words, simply flashing the zip twice back-to-back will do.

Also, ditch CM recovery - it's not required and pathetically weak in function against TWRP. That will also allow you to connect to PC with MTP and put the zip inside the storage before flashing, which saves time if anything goes wrong (you don't need to `adb push` again).
> 2 votes

---
Tags: cyanogenmod, 6.0-marshmallow
---


# Question
Title: How do I simulate menu button on Android 6?
I'm using Samsung Galaxy S7. Long-pressing the recent button does not simulate menu button but activates split screen mode. Long-pressing the back button doesn't work either; it simply closes the app. I'm using an old app that requires the menu button. Any solution to this without rooting the phone?

# Answer
> 10 votes
As per this post, go to Settings → Accessibility → Dexterity and Interaction → turn on the Assistant Menu. This will add a floating button to the screen that you can press to reveal a menu containing the old Menu button.

Samsung also says "In certain applications, you can touch and hold the Recent Apps button to view the Menu options." This is probably limited to newer apps as well which is why it didn't work for you.

# Answer
> 2 votes
I was able to get the long press of the back button on my Galaxy S7 to open the menu on a really old app by forcing the keyboard to open first. My app "eWallet GO!" has a Search field that I was able to click in to open the keyboard. After the keyboard (Swype in my case) opened, I held down on the back button and the app's menu opened. Previously, the whole app had closed when I tried holding down the back button.

Hope this helps.

# Answer
> 2 votes
For the Galaxy S6 (and Galaxy S7 too), you don't need to open a keyboard. Touch and keep touched the back button for at least 2 seconds and the menu appears.

This also works on a brand new Samsung Galaxy J7 running Android 7 (November 2017).

---
Tags: 6.0-marshmallow, menu, samsung-galaxy-s-7-edge
---


# Question
Title: Apps to lock screen asks for password after locking
I have a Moto G4 Plus, with fingerprint scanner fingerprint reader that is able to unlock(physical button) the phone by just giving the fingerprint, no password is required. I'm trying to implement a "double tap homescreen" on my phone, so I used Nova Launcher to enable that feature. It locks the screen, but the problem is that when I try to unlock the phone using fingerprint after locking by this way, it asks for my numerical password, instead of just unlocking directly. I tried other apps to lock the phone with double tap, but it does the same thing. How to lock screen with these app and no being asked for a password after that.

# Answer
> 1 votes
This is a thing to do with the Secure/Smart Lock setup. When using third party apps the system will default to the "primary" method (whatever you set as backup to finger print whether it is PIN, Password, or the draw on the screen gesture lock). The only way I have seen to get around this is to grant root access to your Home Launcher (Nova does allow this in advanced settings), but it is not a guarantee with every device. Here is what I found doing a quick Google search per your question: http://feedback.novalauncher.com/forums/145180-nova-feature-requests/suggestions/12241728-allow-lock-screen-function-to-be-unlocked-by-finge

Which does seem to indicate it is definitely more of an issue in Marshmallow (and probably future releases). Hopefully enabling root MAY get you around this problem.

---
Tags: lock-screens, nova-launcher, fingerprint
---


# Question
Title: What to do when mobile gets wet and the battery is not removable
I got my mobile (HTC One X) wet yesterday and I could not take out the battery since it is not removable.

Currently, everything works fine but I can see a dark blur shadow on the right of the screen and few dark spots all over the screen.

What should I supposed to do ? Do I need to take it to technician right away or I can stay calm ?

# Answer
> 2 votes
It looks like your screen has been effected by the water and needs a new screen.
You can also open it up and dry the screen and digitalizer carefully. Maybe the screen and digitalizer are still wet on the inside. iFixit has said that it's "impossible" to repair it (open it up and being able to close it again), so be warned.
The other option is to turn your phone off and put it in the oven for a short few minutes. The heat will come into the phone and the water will dry up, but it's not guarenteed, since it looks like the screen has already been infected.
It's best to let a technician do it's thing. Take note that waterdamage is probably not a warranty thing, so that they're charging serious money. It's your choice to let it repair or not, because I don't think your phone will suddenly stop functioning. If it does, you can always let your phone being repaired later.

# Answer
> 1 votes
You could always try the trick of sticking the phone in rice along with the things that Tom pointed out. But in the end, since you can already see the damage, it might already be too late. Seeing that you have a newer phone, you might still be under warranty, so I hate to say it but that probably will be your best bet if you want a completely fixed phone. Water damage is the worst to phones!

# Answer
> 0 votes
Depending on your warranty, budget and how much time you've got to invest in the fix...

* **Under Warranty**: If your phone is under warranty, contact the store you bought it from and find out if water damage is covered...If it is, you're golden! Let them fix it for free. Otherwise, read on...
* **Cheap, doesn't void warranty, but takes time**: Start with using a desiccant to try to dry-out the phone. This is the least invasive way to try to fix the problem as you don't have to take the phone apart, but as much water as it seems you've got in your phone...It could takes days to dry it out. If you've got rice around, then find some kind of container/tupperware that you can seal your phone in along with a bunch of rice. Then leave it sealed (important to seal it, so the rice is pulling the moisture from the phone and not the air) like that for several days. The other option, if you want something a little stronger than rice is to stop by an art&craft store and buy some desiccant bags. Do the same thing with sealing your phone in with the desiccant and leave for a couple of days and then check on it.
* **Cheap, but risky and could potentially void warranty**: Check the internet and sites like iFixit for directions on taking apart your phone. Do so and carefully dab dry any pools of wetness you find and then leave all the pieces out in the open air to dry overnight. Put it all back together the next day and the phone should be all better...And you'll have had the experience of taking apart a phone!
* **Safest, doesn't void warranty, but likely expensive**: Bring the phone to an authorized repair store and have them fix it. If the warranty doesn't cover it, it'll likely cost quite a bit but since it's done by an authorized repair shop, you won't lose warranty status in case something else happens.

# Answer
> 0 votes
I dropped my HTC m9+ in the toilet and it was completely drowned. There was water inside the display within seconds.

I tried turning it off asap but it kept turning back on automatically 2 or 3 times because it was getting short circuited internally. After a few tries it turned off.

I took out the sim and sd card and placed the phone in a box of raw rice. After 6 days i plugged it back on into charging (in a wall socket) and the phone turned back on perfectly alhamdulillah. Its been more than a month, there is some problem with the sim tray though. The rest is working perfectly alhamdulillah.

---
Tags: hardware, htc-one-x, water-damage
---


# Question
Title: Is this android vulnerability bug #8219321 fixed?
In 2013, Bluebox Security announced that they had found a bug in Android that could be used to modify the contents of any application package (including ones distributed as part of the system software) without affecting the attached cryptographic signatures; details to be disclosed at Black Hat USA 2013. I don't want to explain in detail as this site explain it well: http://www.computerworld.com/article/2483525/security0/android-flaw-lets-attackers-modify-apps-without-breaking-signatures.html

However there was no news if it has been fixed. I find that there is really an app "Xmodgames" which is exactly doing the same thing.After granting it root permissions It modifies game files without breaking its signature. You can't update that app automatically from play store once its signature get broken right? I assumed the same thing but even if xmodgames applies the mod on a game you can still update that game from play store. It means that it keeps the signature intact. Has it not really been fixed till yet?

# Answer
Yes it was fixed (sourced from MasterKeyDualFix) on Wed Jul 03rd 2013. Generally vulnerabilities like this are reported to Google a long time prior to it being publicly announced. In this case it was reported to Google in Feb 2013 and the fix had already been passed to OEMs to include in their releases. (Note, the date it was committed to AOSP (the first link) is not the date it was available to Google and the OEMs)

As for the second part of your question I believe XMOD works by modifying the files after the app has been installed which bypasses the signature checks. Although I am not that familiar with XMOD I'm pretty sure that it is not using this vulnerability.
> 0 votes

---
Tags: root-access, bugs
---


# Question
Title: Viewing and Transfering files between Nexus 7 (13) and Win 7sp1 x64
Having difficulty with both USB and wifi file transfers. I recently upgraded my desktop from XP to Win7, all was working well with XP.

Over wifi ES file explorer sees the shared Win7 HDDs but will not open them to view contents. Permissions on the HDDs are set to allow all users full access. From the Win7 end the Nexus7 does not show at all on the LAN.

Connecting USB and using ES file explorer I don't know how to make the Win7 PC accessible.
In Win7 explorer the Nexus7 shows up and when Nexus7 USB for file transfers is selected most folders and files are accessible. The exception are uTorrent down loaded files, why are these not accessible?

If anyone can help with file transfers or provide edifying links it will be appreciated.

# Answer
> 0 votes
Follow this answer to access Android Devices' files over a PC. https://android.stackexchange.com/a/42703/21342

You don't have to download any other application to start an FTP Server on your device, simply go to Remote Manager in Tools and press Start.

Make sure that both the phone and PC are on the same network.

---
Tags: nexus-7, file-transfer
---