title: SimpleSSHD Missing SCP?

text:
# Question
Title: SimpleSSHD Missing SCP?
I successfully got SimpleSSHD running on my OnePlus 7T and I can SSH into the phone fine and I can also connect using WinSCP. However, whenever I try to transfer a file, I get an error 127, which apparently means the scp command wasn't found. I can confirm from the CLI that it thinks scp doesn't exist. But does that not come with SimpleSSHD? Am I missing something with the installation? I should add, I am transferring files to /sdcard/\*

# Answer
After talking with the app author, it sounds like it's an issue that may not get resolved, but he confirmed that he had to do some funny stuff to get scp working and the Android updates have probably broken it. So I ended up using Termux instead and wrote some documentation on it, in case anyone comes across this later.

# Termux Android SSH Server Setup

## SSH Setup

1. Download and install Termux on the phone
2. Enable File Storage permissions for the app (I had to manually do this)
3. Start the app and run these next steps in the app
4. Install dropbear and openssh

```
pkg upgrade
pkg install openssh
# When OpenSSH asks about overwriting your local config file, answer N to keep the local file

```
5. Run the command `passwd` to generate a login pasword
6. Start the SSH server

```
sshd

```

* NOTE To Stop the SSH server, run this `pkill sshd`

Ref: https://www.crisisshelter.org/install-ssh-in-termux-openssh/

## Key-based Auth Setup (Windows)

### Generate Keys

1. Download https://www.puttygen.com/
2. Run puttygen
3. Select:

1. RSA
    2. Bits: (2048 or 4096 for better encryption)
4. Click Generate
5. Wiggle mouse in blank space of program
6. Copy the public key for pasting into OpenSSH authorized\_keys file and save it to a file named `authorized_keys`

* NOTE: Output should look like this

    `ssh-rsa 1231AD_REALLY_LONG_KEY_HERE_FG123= rsa-key-20220806`
7. Save the private key as `id_rsa.ppk`

### Send Public Key to Phone

1. Connect to the phone's IP using WinSCP on port `8022`
2. Enter a blank username and then the password set above
3. Manually change to `$HOME/.ssh/authorized_keys` (Note, the location of the home directory may be different so use what your path shows)
4. Transfer the `authorized_keys` file created above to this folder

### Setup Key in Kitty/Putty

1. Setup the SSH connection as usual, being sure to use port `8022` and the phone IP
2. Go to `Connection->SSH->Auth` and select the `id_rsa.ppk` file saved from puttygen
3. Be sure to go back to `Session` to name and save the connection
4. Click `Open` to connect
5. Hit `enter` to skip the username and it will use the certificate to authenticate

### Setup Key in WinSCP

1. Setup a `New Site` using the option at the top of the connection list
2. Select `SCP` as the file protocol
3. Enter the phone IP and port `8022`
4. Click `Advanced` and navigate to `SSH->Authentication`
5. Select the `id_rsa.ppk` generated from puttygen and click `OK`
6. Click `Save` and name the connection
7. Click `Login`
8. Click `OK` to bypass the username prompt and it will use the certificate to authenticate

## Disable Password Authentication

1. After ensuring you can login using the certificate, log back into the phone using SSH
2. Edit the sshd config file

```
nano $PREFIX/etc/ssh/sshd_config

```
3. Modify the following line to this setting:

```
PasswordAuthentication no

```
4. Save changes and exit with `CTRL+X`
5. For good measure, set the password to some random password

```
passwd
# Enter some RANDOM_STRING

```
6. You can exit the shell session now

## Termux Logs

SSH daemon does logging to Android system log, you can view it by running `logcat -s 'sshd:*'`. You can do that either from Termux or ADB.

Ref: https://wiki.termux.com/wiki/Remote\_Access
> 1 votes

---
Tags: ssh, oneplus
---


title: how to sync phone memory with pc?

text:
# Question
Title: how to sync phone memory with pc?
Before Jelly Bean forced us to use MTP mode (mass transfer protocol) instead of Mass Storage Device, It was dead simple to backup my phone to my pc, because I only needed to plug it in, and sync the contents of the SD card to my PC.

I used an app called "Free File Sync", which basically just syncs any two folders in windows.

The problem now is, that MTP mode doesn't assign drive letters to the phone's memory (internal and SD), which causes that my syncing program simply doesn't recognize the device.

I have the same problem with other programs that I use to manage my phones SD card, namely "TreeSize free", which analyses any folder or drive and gives you an oversight of the space consumed by folders, etc. Again, since the phone is not assigned a drive letter, the program simply ignores it, as if it wasn't there.

So what are my options? Is there a default way of syncing MTP drives with Windows?

I also have tried to enable Mass Storage in my phone, but it doesn't work (the option is simply no longer there in **Jellybean 4.1.2**, or at least in my model)

Note, I don't want apps to make backups of my stuff (apps, pictures, etc), I already have them (Titanium Backup, etc), what I want is to be able to SYNC everything in my phone (backups included) to my pc automatically.

I could simply copy ALL files from Windows Explorer every single time, and then manually syncing it to the destination backup folder, but obviously is not convenient and loses the point of SYNCING.

So what can I do? I just want to once in a while sync everything in my phone to my pc as a backup.

Thanks!

# Answer
I am posting this as an answer to my own question, instead of just a comment, because I've found a solution.

In fact, the solution is to use the very same tool I was using, because they have recently updated it (version 7) enabling syncing of MTP devices.

Free File Sync

It works just as expected, and it's extremely easy to sync. The only downside is that comparing the folders (your local "backup" folder, vs. the devices memory) is slower than if it was a Mass Storage Device, but it is a more straightforward solution than the others.

As a side note, I’ve also used ES File Explorer successfully as a way to sync files (as suggested by gibfahn), but the advantage of FreeFileSync is that it works with just about any MTP device, being Android or not.

And the best of all, it's free!
> 3 votes

# Answer
The easiest way probably is to turn the mechanism around: instead of letting Windows do the sync, let the Android device take care. From there, you should have full access at least to your SDCard (internal as well as external). So all that's needed is a possibility for the Android device to access your Windows PC.

1. On your Windows PC, create a "share" (i.e. share a directory to the network)
2. On your Android device, install an app like e.g. FolderSync
3. in *FolderSync*, setup at least one account (in your case, an SMB account pointing to your Windows machine) <sup>(thanks to arberg for pointing out this missing step!)</sup>
4. In *FolderSync*, configure your "folder pairs": which directory on your Android device should get synchronized with which directory on the Windows share.

You can sync manually, or in time intervals. You even can restrict it to WiFi, so it wouldn't eat your data plan (I'm not sure wether you can restrict it to a specific WiFi network, so it would e.g. only sync at home -- but that's possible to do as well at least with some similar sync app).
> 4 votes

# Answer
The bad news is there's no obvious/direct way to get a drive letter assigned to an MTP device. The MTP protocol operates at the file level rather than the filesystem/FAT cluster level, which is supposed to protect in some ways users from accidentally doing things that could be really destructive to their phone's filesystem (eg: reformat in a different format, corrupt the filesystem, making your phone appear to not work right when the sd card unmounts to remount on the pc, etc)...so you're not going to have the level of detailed info about the filesystem necessary for a program like treesize to accurately display the usage of the drive.

There are a number of different threads I found online about ways to make windows trick a MTP device into being treated as a mass storage device, but most of them appear to be false leads, or something that might (or might not) work on XP but is unlikely to work on a newer os like windows 7. Nothing I could replicate on my own machine. Most of those hack solutions seem to rely on such things as tricking windows into using the mass storage device driver instead of the MTP driver.

There do appear to be programs that attempt to sync over MTP mode as best they can (ie: the apps can compare the files by size, but it can compare by date/location/filename. Here's one for mac: http://www.sync-mac.com/mtp-sync.html and one for PC: http://mobiletechpundit.blogspot.com/2012/02/syncing-mtp-devices-like-android-based.html (PureSync).

Another option is to look into apps that run on your phone that manages the syncing as Izzy suggested.

Additionally, if your phone is an HTC phone, it may come pre-installed with an application called HTC sync which can sync files between the phone and PC.

Another less automated way to get copies of "everything on your phone" onto your PC would be to just use ADB to backup your entire device filesystem regularly. Not quite as nice as a direct sync app since restore using ADB is all or nothing, however, if you have the right apps installed on your PC you can manually extract a specific file of interest from a specific backup archive (presuming you remember your backup password).
> 3 votes

# Answer
The only way I've found to do this is by using the FTP protocol over a shared WiFi network. Apps like ES File Explorer have the ability to run as an FTP client or server on the phone, and then you can use an app like Filezilla as a server on the computer.

This works for folders, and Filezilla does give you some options ("Overwrite if source file newer", or "Overwrite if size differs", or both), so you can get it to sync selectively.

I found this post detailing a quick way to get ftp working on ES File Explorer, then you just run FileZilla, type in the ftp address, press connect, and drag and drop. It'll ask you about overwriting.

I sync my music with this method, and it works pretty well. It's slower than wired syncing, and occasionally it will decide that it needs to overwrite all the files, but in general it works well.
> 1 votes

# Answer
If MTP transfers are unstable, you can try using FTP over a local network (Your home WiFi router, USB tethering)

Possible example. (For security, use this guide only on home networks)

1. Install an FTP app on phone - install Amaze File Viewer (free, lightweight, FTP available with a good file viewer)

-- Connect both mobile and the PC into the same network. (E.g.: below 2 or 3 steps)--

2. Connect the phone to the PC using USB -\> Enable the "USB tethering" option in phone settings. (Usually faster)
3. Connect both phone and PC to the same router using WiFi or cables. (Fast with a good router and a good phone)
4. Open FTP Server from your FTP app on your phone - Open the Amaze app -\> Open the left pane by clicking the menu icon on the top left corner -\> Select "FTP Server"-\>
5. Configure FTP server settings -\> Click the options icon on top right of the FTP server page of Amaze app -\> Disable secure connections, Read only access, etc... -\> Click logins and disable anonymous login -\> fill in some user detail (eg: username="abc", password="bcd")
6. Click start to start the FPS server. -\> It should display an URL address like "URL - ftp://192.168.42.129" and a port (such as port- 21). It should be ftp instead of ftps. Otherwise, disable the "secure connections" option or any other advanced option.

--Use free file sync on PC to sync files. Files can be viewed by Windows Explorer just by typing in the URL in the address bar and pressing enter. Fill out the credentials in the popup that appears next.--

7. Configure Free File Sync (free, open source) to use FTP -\> click the cloud icon placed after the sync address bar and the browse button. -\> Select FTP option from the top toolbar -\> type in the details given in the FTP server app of the phone (Eg - IP = 192.168.42.129 , port=21, Username = "abc", Password = "bcd" )
8. Click browse below the "Directory on server:" field.

If everything went fine, a window will pop up and will let you select the folder you want to sync.

Make sure you recheck the details every time you change the connection. After changing any setting on the Amaze app, try stopping and starting the FTP server again. You can also change the "shared path" of your phone in the Amaze FTP server settings.

This is way more stable than MTP. With a good router, you can even do wireless transfers.
> 1 votes

# Answer
Here two years later, Goodsync has added an option to sync through MTP, and it works like a charm. Its a beta feature in v9 and will probably be in Goodsync 10, and it costs money. Be noted though that Goodsync support is bad in my experience. Goodsync can also sync the dir through wifi.

MTP requires a cable so in not automatic. Using wifi it can be automated, but the goodsync android app would use far too much battery, so if you want it fully automated you need to turn it around is suggested earlier, and use eg FolderSync on the android device.
> 0 votes

---
Tags: 4.1-jelly-bean, sync, mtp
---


# Question
Title: Cannot log in to google account when on data (works on Wifi)
Device: Lenovo A806 with Android 4.4.2

Problem: Cannot log in to google account while on data (**works on wifi**)

Description: Cannot open google play (connection failed, retry) or add a new google account to the android settings (signing in, may take minutes). Also cannot eg log in to PokemonGO with google account while on data, but can log in with non-google account. The game keeps playing if later I go off-wifi. Wifi is required only for sign in. If I disconnect and allow some time to pass then cannot log in again on data.

Tried:

1. Date and time settings are automatic and I verified that the difference to atomic clock is under 1s.
2. Different SIM in different country has the same problem (network operator-independent)
3. Cannot add new google account (account independent, not related to 2-step verification or wrong password etc)
4. Hosts file contains only 127.0.0.1 localhost.
5. Uninstalling/Reinstalling, clearing cache, clearing data, forcing to stop the app and restarting does not seem to help because more than one app have the same problem.
6. Captured the HTTP/S traffic using Drony but didn't manage to understand which is the call to the google account, and see its status.

I know the question may seem a duplicate, but I haven't found any solved question about having this problem ONLY on data (wifi works so that rules out many solutions)

# Answer
Do you have background data restricted? Usually I can't login to my Google account with background data restricted. Try with removing background restriction.
> 3 votes

# Answer
I also faced the same problem in LE 1s, So,I have done system settings--\>dual sim and mobile networks--\>data management--\>connection control--\>select app that you want in mobile data.
> 0 votes

# Answer
\[SOLVED\] by Patroklos A Jul 25 '16 at 15:39

I think it got fixed, it was probably something similar: The mobile data access was available for google services in android settings but there is a built-in lenovo app called 'security' which has a submodule called 'firewall', and this was blocking google services when on data to save on MB usage. Thank you –

go to settings \> security \> apps with usage access \> google play services \> click on 'i' icon \> data usage \> uncheck restrict background data

you can also access it from settings \> apps \> google play services \> data usage \> uncheck restrict background data

Done! Thanks for the clue, Patroklos!
> 0 votes

# Answer
When I installed my phone for the first time, I probably restricted too many apps from using mobile data.

I have system apps called 'msa' and "Browser services". When I turned mobile data for both apps back on, I finally was able to log into my Google account again via a mobile data connection. ':-D
> 0 votes

---
Tags: google-play-store, wi-fi, google-account, mobile-network, wlan
---


# Question
Title: details of quick ring/call/drop flood attack - phone unusable and overheated
A while ago I read about an attack performed with an application that rendered the attacked phone unusable and overheated for the period of the attack. If I remember correctly the attack was based on initiating a call and quickly dropping it so that the attacked phone would not ring or display the number of the attacker but it would endup unusable and overheated. This whole thing might have been limited to a specific network type, eg. LTE, but I'm not sure if I remember this correctly.

However, I cannot find information about this attack or the app that was used to render it.

I don't plan to use it, I just want to inform myself about it and to understand why the network provider is not rate limiting or banning the attacker.

# Answer
I don't have many articles for you, but I can confirm this also was able to happen on iPhones as well. Attackers literally called my coworker over and over as we both watched, meanwhile he got an email alert that his credit card was being used. It was a fraud distraction.

Keywords to search for: fraud distraction, phone denial of service via calling, incoming dos attack (phone model)

1. https://securelogix.com/threats/tdos-attacks/
2. https://www.cisecurity.org/insights/white-papers/cis-primer-telephony-denial-of-service-attacks
3. https://www.cisa.gov/uscert/ncas/tips/ST04-015
4. https://scambusters.org/distraction.html

To summarize how I would personally do this *if I were a crrrrrriminal*? I'd buy a VoIP server subscription or setup a PBX (or a few) and then use multiple providers and a scripted call routine to flood the line. It would be next to impossible to stop, as the phone company has zero interest in stopping potentially billable calls from being connected. It also could be a legitimate thing (like a radio station prize, etc).

***There's a few steps left out of this for obvious reasons. ;)***

Cheers
> 0 votes

---
Tags: hardware
---


# Question
Title: start apk from console -> get process id
I have some logcat outputs saved as txt file. I need to parse them looking only for entries that correspond to my app. However, it always takes me quite some time to find the exact process ID of my in order to filter for it.

Is there a way to get the process ID automatically when starting the apk via adb?

This is the line in my script that starts the app on a device

```
adb -s $device_name  shell am start -S -n $pkg_name/com.unity3d.player.UnityPlayerActivity

```

**Some more context:**
My script installs and starts an apk on an android device. The script is running on a cloudplatform for device testing (Kobiton) which probably uses Appium to run apks in a sandbox on real devices. After running the app for a the Kobiton server sends back the logcat output as a txt file.

This is what such an output looks like:

```
2022-08-04 16:10:28.722 -0400  4197  4500 D SdpManagerService.SDPLog: com.android.server.SdpManagerService$SdpEngineDatabase$EngineListHandler.getEngineListXmlFile(SdpManagerService.java:2635)
2022-08-04 16:10:28.722 -0400  4197  4500 D SdpManagerService.SDPLog: com.android.server.SdpManagerService$SdpEngineDatabase$EngineListHandler.getEngineListXmlFile(SdpManagerService.java:2623)
2022-08-04 16:10:28.722 -0400  4197  4500 D SdpManagerService.SDPLog: com.android.server.SdpManagerService$SdpEngineDatabase$EngineListHandler.getEngineListLocked(SdpManagerService.java:2721)
2022-08-04 16:10:28.722 -0400  4197  4500 D SdpManagerService.SDPLog: com.android.server.SdpManagerService$SdpEngineDatabase$EngineListHandler.access$2300(SdpManagerService.java:2612)
2022-08-04 16:10:28.722 -0400  4197  4500 D SdpManagerService.SDPLog: com.android.server.SdpManagerService$SdpEngineDatabase.getEngineListLocked(SdpManagerService.java:2592)
2022-08-04 16:10:28.722 -0400  4197  4500 D SdpManagerService.SDPLog: com.android.server.SdpManagerService$SdpEngineDatabase.access$1700(SdpManagerService.java:2570)
2022-08-04 16:10:28.722 -0400  4197  4500 D SdpManagerService.SDPLog: com.android.server.SdpManagerService.readEngineList(SdpManagerService.java:2543)
2022-08-04 16:10:28.722 -0400  4197  4500 D SdpManagerService.SDPLog: com.android.server.SdpManagerService.handlePackageRemoved(SdpManagerService.java:4755)
2022-08-04 16:10:28.723 -0400  4197  4500 D SdpManagerService.SDPLog: com.android.server.SdpManagerService.access$6100(SdpManagerService.java:171)
2022-08-04 16:10:28.723 -0400  4197  4500 D SdpManagerService.SDPLog: com.android.server.SdpManagerService$SdpHandler.handleMessage(SdpManagerService.java:6105)
2022-08-04 16:10:28.723 -0400  4197  4500 D SdpManagerService.SDPLog: android.os.Handler.dispatchMessage(Handler.java:106)
2022-08-04 16:10:28.723 -0400  4197  4500 D SdpManagerService.SDPLog: android.os.Looper.loop(Looper.java:214)
2022-08-04 16:10:28.723 -0400  4197  4500 D SdpManagerService.SDPLog: android.os.HandlerThread.run(HandlerThread.java:65)
2022-08-04 16:10:28.723 -0400  4197  4500 E SdpManagerService: read engine - No any engine found
2022-08-04 16:10:28.734 -0400  4197  4197 D ZenModeHelper: Set zen mode for exception case : 0
2022-08-04 16:10:28.745 -0400 20156 20156 I SKBD    : anc isTosAccept false
2022-08-04 16:10:28.749 -0400  4197  4197 D UniversalCredentialManagerService: ****MSG_CLEAN_INFO block started****
2022-08-04 16:10:28.749 -0400  4197  4197 D UniversalCredentialManagerService: uid - 15747, userId-0
2022-08-04 16:10:28.749 -0400  4197  4197 D UniversalCredentialManagerService: notifyChangeToPlugin is called for package uninstalled...
2022-08-04 16:10:28.749 -0400  4197  4197 D UcmService: notifyChangeToPlugin event 12
2022-08-04 16:10:28.749 -0400  4197  4197 D UcmService: checkCallerPermissionFor is called for method-notifyChangeToPlugin
2022-08-04 16:10:28.749 -0400  4197  4197 D UniversalCredentialManagerService: ****MSG_CLEAN_INFO block ended****
2022-08-04 16:10:28.790 -0400 19812 19812 D Notification.Badge: onNotificationRankingUpdate().sIsDnDModeChanged[false]
2022-08-04 16:10:28.790 -0400 19812 19812 D Notification.Badge: [invalid] onNotificationRankingUpdate : sNotificationListenerInstance = com.android.launcher3.framework.device.notification.NotificationListener@d63fa54 sIsConnected[true]
2022-08-04 16:10:28.793 -0400 22587 27587 V SysAbnormalItemManager: updated column : com.MoveBook.MoveBookFarmAdventures / flag : false
2022-08-04 16:10:28.798 -0400 22587 27587 V SysAbnormalItemManager: updated column : 15747 / flag : false
2022-08-04 16:10:28.801 -0400  4197  4223 V MARsDBManager: getManagedPackagesFromDB!
2022-08-04 16:10:28.802 -0400  4197  4197 W Looper  : Drained
2022-08-04 16:10:28.813 -0400 28468 28468 I cr_SplitCompatApp: aunched version=95.0.4638.50 minSdkVersion=24 isBundle=true processName=com.android.chrome isIsolated=false
2022-08-04 16:10:28.816 -0400  4197  4223 V MARsPolicyManager: getPkgInfoFromSMToMARs size = 29
2022-08-04 16:10:28.830 -0400  4197  4223 E EdmStorageProvider: Admin not in database, something went wrong
2022-08-04 16:10:28.844 -0400  5426  5426 D io_stats: !@ 179,0 r 4229839 195915004 w 12884332 278363688 d 857544 165056904 f 2502218 2756314 iot 11859272 12140884 th 51200 0
0 pt 0 inp 2 0 5407919.174
2022-08-04 16:10:28.850 -0400  4197  4223 I chatty  : uid=1000(system) MARsDBThread identical 7 lines
2022-08-04 16:10:28.852 -0400  4197  4223 E EdmStorageProvider: Admin not in database, something went wrong
2022-08-04 16:10:28.859 -0400 11692 11692 I StackScroller: ADJUST STACK.TRANSLATION
2022-08-04 16:10:28.860 -0400  4197  4223 E EdmStorageProvider: Admin not in database, something went wrong
2022-08-04 16:10:28.864 -0400 11692 11692 I StackScroller: ADJUST STACK.TRANSLATION
2022-08-04 16:10:28.864 -0400 11692 11692 I StackScroller: ADJUST STACK.TRANSLATION
2022-08-04 16:10:28.865 -0400  4197  4223 E EdmStorageProvider: Admin not in database, something went wrong

```

As one can see: it has an additional column "-0400" before the process ID and thread ID column

# Answer
> 0 votes
I don't know a direct way to get the process ID of a started app/activity. But if you have a PC connected to the phone via USB one very easy way would be to use frita-ps to get the full list of active apps and the filter it by the known package name to get the process ID of the started app:

```
frida-ps -a -U

```

(list all apps `-a` on the phone connected via USB `-U`) from frida tools. Frida is a Python based reverse-engineering and hooking framework that can be installed via `pip install frida-tools`. frida-ps is just one tool from this collection.

It shows app package name, app display name and process ID and it works on unrooted devices (no frida-server or app-modification required for frida-ps).

Truncated example output from an unrooted Pixel 4a device:

```
D:\>frida-ps -Ua
  PID  Name                   Identifier
-----  ---------------------  ---------------------------------------
24507  Android Auto           com.google.android.projection.gearhead
16334  Chrome                 com.android.chrome
24906  Duo                    com.google.android.apps.tachyon
20700  Einstellungen          com.android.settings
 2292  Gboard                 com.google.android.inputmethod.latin
 1727  Google                 com.google.android.googlequicksearchbox
22699  Google Play Store      com.android.vending
20585  Google Wallet          com.google.android.apps.walletnfcrel
24221  Maps                   com.google.android.apps.maps
19359  Pixel-Tipps            com.google.android.apps.tips
 2806  SIM-Toolkit            com.android.stk

```

---
Tags: adb, logging
---


# Question
Title: Getting permissions for new apps and apps updates on Google Play Store
That's already been discussed on Hacker News, however the question remains:

* How can you learn the permissions required by a new app *without* installing it?
* How can you learn the new permissions required by an app update again *without* installing it?

Google has hidden app permissions both from the Google Play app and the Google Play website in the middle of May 2022 and replaced it with pretty inane "Data Safety". No one has paid attention, I've even approached at least three news outlets including Android Police, 9to5 Google, and Ars Technica - no one cared. It's a crazy serious issue and I'm appalled I'm the only person among **two billion** Android users who've noticed the abrupt change.

If \[an\] APK \[file\] is available on the Internet it is a solved issue, however it's often not the case, especially for paid apps.

# Answer
It is possible that Google has not killed or restricted off-the-record APIs which allowed Play Store to get app permissions info back in the day. This API *might be* what Raccoon and Aurora Store are able to access to still successfully show app permissions for apps without installing them.

### Aurora Store

Install it from F-Droid, setup a pseudo account, search your app, scroll down on the app page, tap *Permission* (worked on v4.1.1).

See example here.

### Raccoon APK Downloader

Raccoon is a desktop-only Java app. You need Java runtime installed to run this app. See its user guide for your OS specific setup.

Once it is setup, search your app, click on the app entry, and in the bottom left click on *Permission* to see Permissions (worked on v4.20.0).
> 4 votes

# Answer
**Since July 21, 2022, Google has added back permission details on the Play Store.**

In a tweet by the official Android Developers account (@AndroidDev),

> Privacy and transparency are core values in the Android community. We heard your feedback that you find the app permissions section in Google Play useful, and we've decided to reinstate it. The app permissions section will be back shortly.

As of September 2022, this has been added back to both web and app versions on the original location:

* Web: About this app - Permissions - View details
* App: About this app - App permissions - See More
> 2 votes

---
Tags: google-play-store, permissions
---


# Question
Title: Run 32-bit ARM ELF executable on 64-bit Android
For various testing reasons, I need to run my own 32-bit ARM ELF executables on various real ARM Android devices (I can't use emulators). Because it is not easy to buy an ARMv7 device nowadays, I'd like to run the executables on 64-bit Android devices. However, all the 64-bit devices from various vendors I have access to refuse to run the executables with this message:

> not executable: 32-bit ELF file

This means that the system can't run 32-bit ELF files, or it can run them but it is configured to refuse them. Is there any trick to make the 64-bit OS running 32-bit executables, just like 64-bit Windows or 64-bit Linux can run 32-bit executables?

I use the following steps to push and execute the file:

```
adb push printf /data/local/tmp/
adb shell chmod 555 /data/local/tmp/printf
adb shell /data/local/tmp/printf

```

This returns:

> /system/bin/sh: /data/local/tmp/printf: not executable: 32-bit ELF file

# Answer
> 1 votes
This question was viewed many times and it deserves an answer:

> ARMv8 processors are backward compatible only with ARMv7. Your binary must be ARM v5/v6. Rebuild it for at least armeabi-v7a.

As correctly answered by Irfan Latif in the comments.

---
Tags: settings, arm-processors
---


# Question
Title: Can android 11 take 2 wired USB controllers
I have an Android 11 box (Android TV Box 11.0, 4GB 64GB Decodificador Android Box, Amlogic S905W2 Smart TV Box"), and am trying Retroarch.

For controller 1, I have a Power A Liquid Metal XBox One controller. Works fine so far.

But no matter what I configure as Input 2, the 2nd controller stills controls player 1.

I tried several controllers for Input 2, and it's always the same thing. I tried a Wired Rock Candy Switch controller, BlueTooth Atgames Legends Mini, and I also tried using a second Power A Liquid metal Xbox One controller.

No matter what I do, it seems to think that both controllers are the same controller. (both control player 1).

What I noticed that's weird is that since it thinks both controllers are the same, and I mapped both Input 1 and Input 2 to it, when I'm in certain menu screens, when I hit down, it registers twice. I'm guessing because it thinks both players hit down.

I tried both SNES9x and Final Burn Neo. The problem seems to be at the Android level (before getting to Retroarch).

Is it normal to have an Android 11 device only accept one controller? Or is it possible that it's a problem with my device specifically?

# Answer
This is the bug \[Android 11 DP/Beta\] Bluetooth Gamepads Aren't Reported as Source of Input Events".

A workaround is described in a reddit post by /u/SuttonX:

https://www.reddit.com/r/AndroidGaming/comments/kb8mzw/accessibility\_services\_block\_controllers\_android/

> If you don't want to get Tasker, you could just manually go in to your phone settings and turn off all your Accessibility Services permanently.
> 1 votes

---
Tags: settings, usb, input-methods, game-controllers
---


# Question
Title: Why is it that I get texts when both wifi and cellular data are turned off?
Just wondering if everything is normal on my cell phone... It's an LG and they stopped updating, but I don't remember this behavior before...

# Answer
> 0 votes
You do not need cellular data to send text messages (SMS). Networks use a different method to send and receive text messages. SMS uses GSM and ISDN networks to send text messages. You are limited to 160 characters of text. The limitation reflects the speed of the network.

# Answer
> 0 votes
There is SMS (Short Messaging Service) and MMS (Multimedia Messaging Service). SMS messages are 160 characters or less, meaning 1120 bits or less (each character is 7 bits). MMS messages (pictures or messages longer than 160 characters), however, require data. So even if you have data turned off, that will not effect SMS messaging. To turn that off you'll have to use airplane mode.

---
Tags: wi-fi, sms, data
---


# Question
Title: Which Android virtual device is based on ARM system image?
Android Studio has a feature where you can emulate an Android device -- tablet, phone, etc. -- but it crashes the virtual machine (Ubuntu) I am using. Depending on which VM platform I am using, it sometimes lets me know what went wrong. Here are the four options:

> **Troubleshoot**
>
> Unfortunately, your computer does not support hardware accelerated virtualization.
> Here are some of your options:
> 1) Use a physical device for testing
> 2) Develop on a Windows/OSX computer with an Intel processor that supports VT-x and NX
> 3) Develop on a Linux computer that supports VT-x or SVM
> 4) Use an Android Virtual Device based on an ARM system image
> (This is 10x slower than hardware accelerated virtualization)

I like the fourth one. So, which Android virtual device is based on ARM system image?

*Original pop-up dialog:*

# Answer
> 2 votes
Although not recommended due to performance issues, the Android SDK manager still provides ARM system images for the Android SDK emulator:

1. Open "Virtual Device Manager"
2. Click the "Create device" button
3. On "Select Hardware", select an existing device or create a new one, then click the "Next" button
4. On "System Image", switch to the "Other Images" tab
5. Download and select an ARM system image (ABI starting with "arm"), then click the "Next" button
6. Click the "Finish" button to create a new virtual device with an ARM system image

It is also possible to download the system images directly from the SDK Manager:

1. Open "SDK Manager" (Appearance & Behavior - System Settings - Android SDK)
2. Switch to the "SDK Platforms" tab (if it's not selected by default)
3. Tick the "Show Package Details" checkbox
4. Under the Android version to be used, expand the details
5. Tick respective ARM system images to download (e.g. "ARM 64 v8a System Image")
6. Click the "OK" button

---
Tags: android-emulator, android-studio, arm-processors
---


# Question
Title: Accessibility: controlling Android and typing via eyes
I have seen a video where a person with amyotrophic lateral sclerosis (ALS) could type on a screen using their eyes (the software used eye tracking software).

But there are also many disabled people who are partially paralyzed or have handicaps where their limbs give away to spasms or have stiff or impaired parts (but can use their eyes).

Wouldn't it be nice, if, all of these, could have some arm attached to their wheelchair or bed or chair or table, with Android on it, and could use their eyes to open up YouTube and key in some search videos, scroll, and watch YouTube or other media?

Why doesn't Android offer this accessibility feature?

Thanks.

# Answer
Android actually does have this feature (I didn't know it either before today). Camera Switches via the Accessibility Suite is widely available since 30 September 2021 as mentioned on this page.

As stated here:

> Camera Switches is a new Android accessibility feature that makes it possible to navigate a smartphone using eye movements and facial gestures. It uses the front camera as a switch to set up one action to scan and another to select an item.
>
> Choose a combination of two facial gestures such as looking in a specific direction, smiling, raising your eyebrows or opening your mouth.

Here is how to set it up

> Once you have the app, you can start setting up facial gestures. Here’s how:
>
> * Go to Settings \> Accessibility \> Switch Access.
> * Turn on Switch Access, then tap Allow to grant it permissions.
> * Go back to Settings and select Camera Switch.
> * Select Two switches (recommended) to set up two gestures.
> * On the next screen, choose your scanning mode. Linear scanning moves through items one at a time. Let’s select that one.
> * Now select two gestures from a list. One to scan and one to select.
> * Go to Settings \> Accessibility \> Switch Access \> Settings to customize your gestures, set up gestures for global actions and more.
> * Now you can use gestures to navigate your phone. An icon at the top of your screen lets you know when Camera Switches are active.

There is also Project Activate. As mentioned here:

> Project Activate, a new Android application, lets people use these same facial gestures to quickly activate customized actions with a single gesture — like speaking a preset phrase, sending a text, making a phone call or playing audio.

But it is not, for now, available worldwide:

> Project Activate is available in the U.S., U.K., Canada, and Australia in English

**Sources:**

How to control your Android phone with just your eyes

Two new tools that make your phone even more accessible

Camera Switches
> 5 votes

---
Tags: camera, accessibility, front-camera, webcam
---


title: Use adb to remove adoptable storage

text:
# Question
Title: Use adb to remove adoptable storage
I followed these steps (in brief, enable debugging and use adb to enable storage and format sd card) to enable adoptable storage on a Samsung A01 to make the phone more usable (device is not rooted). It basically seemed to work and some apps could be moved to the SD-card and freed up space.

It freed up enough space that I then tried to update the OS (to One UI 3.1 / Android 11) and am now stuck. After the install, most software just hung until I removed the sd card. I have since reformatted the card and uninstalled all the apps previously moved to it and tried the same command sequence hoping to re-enable adoptable storage.

The phone basically works now except the SD card isn't working correctly - I assume it's still looking for the now missing adoptable storage. It complains: "SD card missing" / "insert device again".

I'm wondering if there are similar adb commands to undo adoptable storage - even if the adoptable storage partition is missing. Hoping to avoid a factory reset.

Thanks for any tips!

# Answer
I came back to this and found the magic incantation here:

Basically, connect back to the device and redo the earlier partition command replacing the word "private" with "public". In my case:

```
adb shell sm partition disk:179,64 public

```

Having said that - I then tried to redo the process and am discovering the phone may not play well with adoptable storage. Wonder how many phones get landfilled because of this design issue - all of 2yo.

*Perhaps I spoke a bit too soon...* Wasted a couple more hours on this and found another nugget on reddit: buried in Developer Options is "force allow apps on external" With that I was finally able to free some storage and it seems to work - time will tell. Perhaps leaving this here may be of use to someone.
> 2 votes

---
Tags: adb, samsung, adoptable-storage
---


# Question
Title: Connect to emulator from another PC in LAN
I have two PCs. One runs Ubuntu and another runs Windows. Both have `adb` installed. I have an emulator on Ubuntu and I want to connect to it from Windows. I thought I could use `adb forward` but it doesn't work. On Ubuntu, I set up

```
adb forward tcp:8080 tcp:5555

adb tcpip 5555

```

Then, in Windows, I tried to connect:

```
adb connect user@ubuntu-ip-address:8080

```

But it cannot connect.

PS: I can connect through `ssh` from Windows to ubuntu and use `adb` normally.

# Answer
Suppose you have PC1 and PC2. According to the official Android Developer documentation, `adb forward` is not for forwarding a TCP port of the PC1 to another port of the PC2. It's for forwarding a TCP port of PC1 to a TCP port of the Android device.

For your situation, you can use any port forwarding tool like Port Forwarding for Windows.

There is a nice tutorial below copied from hasper.info by Philipp Hasper:

> I often use the Android emulator to check my apps with different display configurations and to stress-test them. But the problem is that it is really slow on my development laptop. So I installed the Android emulator on my desktop PC running Windows and connect to it over my LAN. The major advantage is that you can continue using your development machine while a “server” deals with emulating – one could even emulate several devices at once and still continue programming.
>
> The approach in a nutshell: Forward the emulator’s port so that it is accessible in the local network. Then connect the ADB to it.
>
> On your desktop – the “server”:
>
> 1. Store the executable of Trivial Portforward on the desktop system (e.g. directly in C:\trivial\_portforward.exe).
> 2. Create a virtual device to emulate (HowTo) and name it “EmulatedAndroid”.
> 3. Create a batch file:
>
> ```
> <your-android-sdk-path>\tools\emulator -avd EmulatedAndroid &
> echo 'On the development machine: adb kill-server and then: adb connect <desktop-pc-name>:5585'
> C:\trivial_portforward 5585 127.0.0.1 5555
>
> ```
> 4. If you execute this batch file on your desktop PC, it will open the emulator with the specified virtual device.
>
> Now on your laptop – the “client”:
>
> 5. Now – given that both systems are in the same network – you can connect to the emulator from your laptop by typing in a terminal:
>
> ```
> adb kill-server
> adb connect <desktop-pc-name>:5585
>
> ```
> 6. Now you can upload apps, access the logcat and execute adb commands on your remote emulator like on any other Android device. And all without performance impairments on your workstation.
> 7. If you are experiencing communication losses, increase the emulator timeout in the eclipse settings to maybe 5000 ms (Window → Preferences → Android → DDMS → ADB connection time out (ms)).
> 6 votes

# Answer
I just want to update answer, since approach with trivial\_portforward is not easy, because issuer is not online anymore and you have to compile it. And also this page is first in google results.

Best approach for port forwarding is to use ssh. If you want to install SSH on windows,here are:

**On Host:**

a) nodaemon server:

```
host$ adb kill-server
host$ adb -a nodaemon server

```

b) create ssh server

Just create ssh server on host machine, if it is windows. I did it this way.

**On Client:**

a)

```
adb kill-server
ssh -L 5037:localhost:5037 <host-IP-or-hostname>

```

b)

```
adb kill-server
ssh -L 5585:localhost:5555 serverusername@<host-IP-or-hostname>
adb connect localhost:5585

```

Then authenticate. Also portforwading is possible do on host or client, if both have ssh server.
> 1 votes

---
Tags: adb, remote-control
---


# Question
Title: Force boot to bootloader (device always boots to recovery)
I was trying to flash TWRP onto my Android tablet (Lenovo TB-X306F), but something went wrong and it failed. Now, every time I boot, no matter what I do (sending adb commands or pressing physical buttons), it goes to the (now broken) recovery.

I'd like to know if there's a way to forcibly boot into the bootloader so I can use fastboot and flash the stock recovery (I have the original images for everything).
I tried flashing it using `flash_image recovery /path/to/recovery.img` through `adb shell` (which is accessible within that "zombie" recovery), but it failed with: `failed with error: -1`. I've looked up online and couldn't find the meaning of such error, but I suspect it's related to trying to flash the recovery while being in the recovery?

Thank you in advance.

# Answer
I finally solved this conundrum!

After digging around a bit more, I found this blog post on someone's website (thank you!) and tried it out. In my case, I had `/dev/block/platform/bootdevice/by-name/recovery` but it still worked wonders.

In case that blog ever goes down, what you have to do is check that path and see if it matches. Like the post suggests, you can do `DEV=$(ls /dev/block/platform/*/by-name/recovery); echo $DEV`.
Then, it's a matter of using `dd` to dump the image onto that path, like this: `dd of=$DEV if=/path/to/recovery.img` (I put mine in `/sdcard` with `adb push`).
Finally, just reboot using `adb reboot ...` or using your device's physical buttons.

Hope this helps!
> 2 votes

---
Tags: adb, recovery-mode, fastboot, boot, bootloader
---


# Question
Title: Which engine does the stock Samsung Browser use?
Which engine does the stock Samsung Browser use? Is it based on WebKit, Gecko, or something else?

# Answer
Android default browser uses WebKit. Check out the second paragraph of Wikipedia WebKit description.
> 1 votes

# Answer
After reviewing some user-agent strings, all native Samsung browsers I saw use WebKit.

There are particular idiosyncrasies when working with this family browser amongst devices, and a lot of weird behavior. According to *What browser does the Samsung Galaxy use?* on Stack Overflow, there is some "value-added" by Samsung to the AOSP browser.
> 2 votes

# Answer
It is based on Chromium, it uses Blink (WebKit fork). https://en.wikipedia.org/wiki/Samsung\_Internet
> 0 votes

---
Tags: samsung-internet-browser
---


# Question
Title: Hotspot and Position automatically toggles off
I'm on a POCO phone M4 pro 5G, running MIUI Global 12.5.8 Android 11 RP1A 200720.01

Sometime I face this annoying problem which apparently no-one experencied on the internet. If I'm sharing my connection via WI-FI Hotspot, at a point it may stop working as the button turns off. This may happen once or twice every week randomly (not linked to battery saving mode). Once the hotspot button toggled off, I coudn't get toggle it on again not even by restarting my phone. As soon as I touch it, it toggles off again. This problem may go away by itselfs in a matter of minutes or hours. I've never notice before but tonight this thing happenend and I got an error saying my GPS wasn't on anymore. When checking the position button it was toggled off as the hotspot one. I coundn't get back neither of them. After 30 mins without any restart they started to work again.

What could be the problem... and the solution? Thanks

# Answer
There are several things to try such as:

Enabling and disabling Airplane mode to refresh your connections.

Change your AP Band from 2.4GHz to 5GHz or vice versa.

Do you have an option in your phone to turn off your Hotspot automatically, which may be affecting you if your devices/apps are slow to respond. If so go into Settings,Wi-Fi & Network \> Hotspot & tethering \> Wi-Fi hotspot and then disable "Turn off Hotspot Automatically"

I personally tend to wonder if your problem is related to 5G, do you have access to a 4G sim to test in your device to see if it makes any difference.
> 1 votes

---
Tags: gps, wifi-hotspot, internet, android-11
---


# Question
Title: Is adoptable storage in any new android version (9,10,11) original?
**Question Is adoptable storage in any new android version (9,10,11) original ?**

I am planning to purchase new smart phone mobile for video editing graphic editing game apps. I want to install aprrox 200-400 apps as file in video editing are huge so I want to use app from external micro sd card and save output and files.on high speed v30 u30 160mbps/90mbps micro sd external card

As new mobile within warranty so don't want to root and use link2sd or app2sd apps to.lapse void warranty

In **android 5.1.1 lolipop** there was option to move partly files to sd card by android llolipop native app2sd option settings\>apps\>app info **"Move to sd card"**

In **android 6.0 marshemellow** the option of **adoptable storage** to which formats the external micro sd card as internal memory

In **android 7.1** there is option in settings developer option **"Force app to SD"**

In **android 8,9,10,11 or 9 pie** I don't what alternative option given there in below findings it say it have the option hidden and activated by **SM (storage manager) command** . Is there any way to get adoptable storage
( Formatting external micro sd as internal) or move app to sd (android native app2sd) or developer option (force app to sd)

But as samsung galaxy have removed all adoptable storage option form its galaxy smart phone but planning to start with android pie 9.0

Can any one suggest me which android OS 9 11.0 or android 10.0 or android 12.0 can support adoptable storage without rooting

**Some.findings** https://source.android.com/devices/storage/adoptable

https://www.quora.com/Which-Smartphones-use-adoptable-storage

https://www.sammobile.com/2018/11/13/samsung-android-pie-adoptable-storage-feature

# Answer
> 0 votes
I came across this while searching for a problem dealing with adoptable storage. While not a direct answer about adoptable storage, I know it's typically used to gain space on internal storage and wanted to note the alternative: "Force allow apps on external" still exists under developer options (close to the bottom). At least it exists in Android 11 on a Samsung A01. Once I got adoptable storage cleaned up/removed, I enabled it and was then able to move a few GB of apps/data to the SD card making the phone more usable again.

---
Tags: internal-storage, adoptable-storage
---


# Question
Title: Screen fading and battery icon outlined in red
I've got a new Doogee S40 running Android 9.0. A problem started when the battery level went down to 20%. The battery icon started to be outlined in red and the screen started dimming after around 5 seconds.

I ensured the following:

1. Screen saver was and is 2 minutes
2. Battery Saver is off
3. Battery Manager is off
4. Standby Intelligent Power Saving is off

I have restarted the phone more than 5 times since this began. There has been no change in the red outline or screen fading.

Does anyone have any ideas how this can be corrected?

# Answer
SUCCESS! I went into Safe Mode. I found the app "Power Saving Mode" and sure enough, it was in "Super Mode" so I changed it to "Normal" and the phone righted itself!

Power Saving Mode seems to be an app built in to Android 9.0, maybe by Doogee as part of their package?

Here is the logo:

And here is a link with some info: https://www.techrepublic.com/article/let-power-saving-mode-keep-your-battery-from-draining-too-quickly/
> 1 votes

---
Tags: battery, screen
---


# Question
Title: How to refresh a web page in Chrome (Ctrl+F5 analogue) on a device without menu button?
I have a Nexus 7 Android device with 4.2.2 and Chrome browser.

**How can one perform a deep refresh of a web page - analogue of `Ctrl+F5` hotkey on desktops?**

Please, notice that the device does not have a menu button.

According to the only related question I've found here, the solution is to clear browser cache completely. I'd prefer more convenient and elegant solution.

# Answer
> 1 votes
**Bypassing per site cache:**

This needs a simple javascript code to be run in the address bar for bypassing the cache and fetch contents from the server instead of the browser cache. According to this MDN page on Force reloading the current page from the server,

```
javascript:location.reload(true)

```

Enter the above code in the browser address bar and hit Enter key. This will fetch all the contents from the server instead of picking the elements cached in your browser(thus bypassing the browser cache).

**Bypass Cache data for all websites(Global cache)**

The above javascript work only for a specific website which you have currently opened. To clear all the website cache use the global browser cache data. You find this under,

```
Settings > Privacy > CLEAR BROWSING DATA

```

Select the "Cache" Checkbox (and other options like Browser data, Cookies, Password etc if you want) and select "Clear".

***Note:*** *While `Ctrl`+`F5` will cause the browser to throw out the cache and request new contents from the server, the server may ignore the `no-cache` header and serve a server-side cached page. Thus, even `Ctrl`+`F5` may return an old version of the page if the server ignores the no-cache header.*

**Incognito Mode:**

Browsing through incognito mode disables history and cache. So you can visit any site through incognito mode to request fresh content everytime.

---

For more interesting discussion on the what does `Ctrl`+`F5` or force refresh does,

Read this SO post, What requests do browsers' “F5” and “Ctrl + F5” refreshes generate?

# Answer
> 6 votes
On the left side of the URL, there is an info icon (i) or a lock icon. Click the icon and then \[web site configuration\].

You will find a trash icon to clear the cache of the current site, and alternatively a "restore preferences" button.

Working on Chrome for Android v71.

# Answer
> 4 votes
I did not get any of these solutions to work. However, I have found a working solution.

**First, find out the CSS URL. In my case, it looked like this:**

```
/min/assets/css/style.min.css

```

**Write it in the address field, but also add a GET variable to it:**

```
/min/assets/css/style.min.css?hello

```

Hopefully, the GET variable is accepted. Because it's a new URL, it forces the CSS to reload. Now, go back to the site and the CSS should have been reloaded.

# Answer
> 3 votes
On my Samsung tablet browsing with Chrome, type this in the address bar:

```
javascript:location.reload(true)

```

That should trigger a hard reload using Javascript. Now I do not have to wait for days to observe results of a change of code I made. A new problem then is that typing on a tablet is not my favorite thing to do.

Instead of typing the above command I also tried to change to desktop mode and then back. That did not deep refresh.

# Answer
> 3 votes
I use a **New Incognito Tab**. It works on other devices and browsers, as well. It avoids the local cache normally.

Notice that private sessions can still be considered concurrent, so you may have to close all incognito tabs to clear their cache.

# Answer
> 1 votes
In the menu of the webpage, ask for the desktop version of the website. It will pull data from the server and the page will reload. After that, you can come back for the mobile version once again.

# Answer
> 1 votes
I need a way to clear the current cache or all cache from the same origin domain via JavaScript, so I can make sure the update rollout of my web app arrives without errors.

I also had no success on temporarily changing the cache meta tags in the HTML header.

Only on desktop and not automatable: Ctrl + R. Used to work to force reload to clear the cache. Now you have to press Ctrl + Shift + R or Shift + F5.

I wrote my own workaround `forceReload()` function that works on Windows Chrome, Chrome for Android, and Chromium:

```
window.forceReload = function() {
    if (!window.fetch) return document.location.reload(true);
    var els = document.getElementsByTagName("*");
    for(var i = 0 ; i < els.length ; i++){
        var src = "";
        if (els[i].tagName == "A") continue;
        if (!src && els[i].src) src = els[i].getAttribute("src");
        if (!src && els[i].href) src = els[i].getAttribute("href");
        if (!src) continue;
        fetch(src, {cache: "reload"});
    }
    return document.location.reload(true);
};

```

This function will only reload contents that have been loaded on the current page. You can trigger it once on each of your clients after new updates are on the server, or simply add a working refresh button on your app.

# Answer
> 0 votes
##### Follow this steps to connect your smartphone to your computer:

1. Open the **Developer Options** screen on your Android. See Configure On-Device Developer Options.
2. Select **Enable USB Debugging**.
3. On your computer, open Chrome.
4. Go to `chrome://inspect#devices`.
5. Make sure that the **Discover USB devices** checkbox is enabled.
6. Connect your Android device directly to your development machine using a USB cable. The first time you do this, you usually see that DevTools has detected an offline device. If you see the model name of your Android device, then DevTools has successfully established the connection to your device.
7. If your device is showing up as **Offline**, accept the **Allow USB Debugging** permission prompt on your Android device.

(Copied from here here)

---

##### Now follow this steps to make `Ctrl` \+ `F5` reload:

1. On your smartphone open Chrome and go to your desired web site.
2. In DevTools tab on your computer click on **inspect** below the web site url.
3. In opened windows (where you can see the mobile screen) press `Ctrl` \+ `F5`.

# Answer
> 0 votes
Another option: install a full keyboard app (e.g. https://play.google.com/store/apps/details?id=org.pocketworkstation.pckeyboard ), tap the address bar to open the keyboard, then press shift+F5

# Answer
> 0 votes
I usually use a version parameter in the css/js url loaded, since every revisitor might have some problems.

Found this solution in another discussion, but I don't know the url. It worked fine for me :-)

# Answer
> -1 votes
Pull down on a page to reload it, it comes incorporated to Chrome for smartphones.

# Answer
> -3 votes
To the left of the web address window you are visiting is a nearly circular arrow.

---
Tags: chrome-for-android
---


# Question
Title: Lost open tabs from Samsung S21 Ultra Android
Lost open tabs from Samsung S21 Ultra Android. I has about 98 open tabs I truly need for work and stuff and lost them all after I uninstalled and reinstalled chrome on my S21 Ultra. These tabs appear under my google chrome sync data but I cant seem to get them on any device, therefore I think they might be in some folders in the protected data folder of my device.

However I'm not sure how to access this folder as my phone is not rooted. I tried accessing the folder by doing an adb backup of my device through USB debugging but I cant seem to back up the folder. I am assuming the file are locally on the device on one of these locations: DATA → select com.android.chrome. And some other locations I read about online are:

The first folder to check is app\_tabs, then 0. In this folder there should be a file called tab\_state which contains a list of all your current tabs. There are also other files in this folder called tab3, tab4, etc. that contain info about current tabs. IMO, you need a special "text editor / sql editor" to read the content of some of these files as the encoding is different.

Next place to look is `/data/com.android.chrome/app_chrome/Default/`. In this folder you'll find a file called History. Depending on your situation, you may find a good list of recent site visits here. Finally, navigate to the Sync Data folder.

The question is does anyone know how to access this files and folders? Or do you have any other solution you may think off?

# Answer
> 0 votes
I had this same question as chrome recently closed half my open tabs (1000s) whereby the data chrome reported halved from 8GB to 4GB.

You need root access however root will invariably wipe all your data, so unfortunately there's no means to non-destructively root your phone for the purpose of data recovery. The recovery can only happen if you had a rooted phone to begin with.

---
Tags: chrome-for-android
---


# Question
Title: How can I see what IP address my android phone has?
I would like to know what IP-address my Android phone has. E.g. if I use my phone over WiFi, how can I get the local IP-address that is assigned to my phone?

# Answer
The easy way is to go to your WiFi Settings, and hit `Menu > Advanced`. It'll show up there, or you can set it to a static IP if you want.

The cool way is to dial `*#*#4636#*#*` to open the Testing menu. Then click WiFi information, then WiFi Status.
> 123 votes

# Answer
**`ifconfig` and `ip` Android 7**

```
adb shell ifconfig
adb shell ip address show

```

`ifconfig` was an annoying implementation that did not show all versions by default on earlier versions as explained below, but now it works fine.

**netcfg Android 5.1.1**

This tool was removed in later Android, and `ifconfig` was made more decent and shows all interfaces by default, thus rendering this method useless on newer versions.

```
adb shell netcfg | grep wlan0

```

from your desktop is the best option if you're already developing for Android and have `adb` and an USB connection setup.

Sample output:

```
wlan0 UP 192.168.0.3/24 [...]

```

Confirm with:

```
adb shell ifconfig wlan0

```

`ifconfig` on Android (home-brewed?) is different from the one on desktops (`net-tools` package on Ubuntu 15.10) as it requires the interface to be given.

This is also mentioned at: Is there a command or application similar to ipconfig?

You could also install a terminal emulator like Teriminal Emulator from Jack Palevich, open it and type: `netcfg`. But in that case you'd be better off with some app that shows the IPs, since typing on devices is a pain (unless you've got an external keyboard...).

If all you want it so SSH into the device, `adb shell` is the way to go: https://stackoverflow.com/a/34040560/895245

If you are developing a server app, the most user-friendly thing to do would be to show the device's IPs on some `TextView`, which has a pure-Java method: https://stackoverflow.com/questions/494465 | https://stackoverflow.com/questions/6064510/how-to-get-ip-address-of-the-device

**Router browser management**

If you are at home, you can:

* connect your desktop to the router with an Ethernet cable
* access some magic vendor dependent address, often http://192.168.0.1
* most vendors have a list of device IPs somewhere in there

**nmap**

If your device is running a server, e.g. SSHD on port 2222 as explained at: https://stackoverflow.com/a/34040560/895245, you can portscan it:

```
sudo nmap -sV --open 192.168.0.0/24 -p2222

```
> 13 votes

# Answer
The easiest way is using a tool like e.g. OS Monitor, which shows you (amongst others) also a lot of network details:

OS Monitor showing network interface details (source: Google Play; click image to enlarge)

As the screenshot shows, this app reveals for each network interface:

* interface name¹
* IPv4 IP address assigned (if `0.0.0.0`, this interface is currently unused)
* IPv6 address (if available)
* MAC address
* packet statistics (i.e. transfered data)
* a status

¹ interface names might be handled differently on different devices. But in most cases you can tell from the IP where it belongs to. Furthermore, `rmnet` is mostly used for GPRS (mobile data), while WiFi uses names like `tiwlan` or `eth`.
> 9 votes

# Answer
In any terminal emulator app:

```
~$ ip -o a

```

Applicable both to WiFi and Mobile Data. Doesn't require root.
> 1 votes

# Answer
This is an old question but I think you can try this command:

```
adb shell ip addr show rmnet0  | grep 'inet ' | cut -d ' ' -f 6 | cut -d / -f 1

```

**It will return your IPV4 assigned by the operator**

> 172.22.1.215

## Note:

Usually, your phone has two networks one by your telcom operator and the other from your wireless interface. These are called network interfaces.

`rmnet0` should be replaced with your interface my case was `rmnet0` usually is `eth0`.

If u want to get the list of interfaces use this command:

```
ip link show

```

You will get something like this:

```
1: lo:  mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc mq state UP qlen 1000
    link/ether b8:ac:6f:65:31:e5 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.5/24 brd 192.168.1.255 scope global eth0
    inet6 fe80::baac:6fff:fe65:31e5/64 scope link
       valid_lft forever preferred_lft forever
3: wlan0:  mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 00:21:6a:ca:9b:10 brd ff:ff:ff:ff:ff:ff
4: pan0:  mtu 1500 qdisc noop state DOWN
    link/ether 92:0a:e7:31:e0:83 brd ff:ff:ff:ff:ff:ff
5: vmnet1:  mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
    link/ether 00:50:56:c0:00:01 brd ff:ff:ff:ff:ff:ff
    inet 192.168.121.1/24 brd 192.168.121.255 scope global vmnet1
    inet6 fe80::250:56ff:fec0:1/64 scope link
       valid_lft forever preferred_lft forever
6: vmnet8:  mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
    link/ether 00:50:56:c0:00:08 brd ff:ff:ff:ff:ff:ff
    inet 192.168.179.1/24 brd 192.168.179.255 scope global vmnet8
    inet6 fe80::250:56ff:fec0:8/64 scope link
       valid_lft forever preferred_lft forever

```

Where usually,

* `lo` – Loopback interface.
* `eth0` – Your first Ethernet network interface on Linux.
* `wlan0` – Wireless network interface in Linux.
> 0 votes

---
Tags: networking, internet
---


# Question
Title: F-Droid v1.15.2: archive.newpipe.net/fdroid/repo: Error getting F-Droid index file => null All other repos didn't create errors
I'm trying to add the custom F-Droid repository, and when I do I am getting this error?

> archive.newpipe.net/fdroid/repo: Error getting F-Droid index file =\> null

All other repos didn't create errors.

What am I doing wrong? I've tried a few times always the same thing. Each time I remove the repo. How can I resolve this error?

# Answer
This worked for me,

1. Remove the NewPipe installed by F-Droid.
2. Remove and reinstall repo.

**If this gives you any problem, try separating the Hash from the URL when you add the Repository**

Then I was able to install the new NewPipe. Not sure what happened here. My guess is this was a change with the F-Droid v1.15.2,

> * Stay safe by checking repo index signatures and APK hashes
> 0 votes

---
Tags: f-droid
---


# Question
Title: Keep user settings/cache after updating app without Google Play
I have developed an app for the school where I work. It is hosted on Google Play, but some of the students have Huawei phones without GMS. I would like them to have the option to download the `apk` from the school's website. I can implement the notification logic, but **I would like to know if a manual update keeps all the app's settings and cached data or not.**

So if I notify the users about a new version, direct them to the website, make them download and install the new `apk`, will they get a fresh installation of the app, or have all their user settings from the older version?

I know there are alternative stores, but it would be easier to handle it on my own, than forcing them to install a second app just to update the other one.

# Answer
> 1 votes
Android in general does not care how you install an app or where the app came from. The older Android versions did not even save the information from where the app came from, only recent Android versions record for each app if the app has been installed from PlayStore or not.

The part that Android uses to decide if an app is allowed to install as update for an existing app or not is the APK signature.

As your app is new I assume you were forced to let Google generate and save the app signing key for you, is this correct? So most likely you only are in possession of the upload key but not the app signature key.

In that case you will have to maintain two different versions of your app:

1. The app versions that are published via Google PlayStore are signed with the app signature key that is saved in the Google Cloud (where you can't access it directly).
2. The app signature key you use for locally signing the APK file.

Both versions can't be mixed, that means you can not install a APK file from (2) as update to an app installed originally from PlayStore (1).

I would recommend to specify two flavors in your build script and set a different packageName for the version that is directly distributed. Then it is clear to the users that there are to app versions available that are incompatible to each other.

---
Tags: updates, apk
---


# Question
Title: Why can't I press the Install button when installing applications from unknown sources?
I'm trying to sideload an application, as seen in the picture below.

I have allowed the installation of applications from unknown applied actions in settings, but I can't seem to press the install button. The cancel button works correctly and installing applications via `adb install` works correctly. What's the problem?

EDIT: For those who have this problem, using ChainFire's C.F. Lumen will correct it because the app uses hardware compositing, and Android doesn't notice a "layer" on top of the current screen.

# Answer
> 203 votes
Looking at your screenshot, I think you are using screen filtering apps like Twilight, f.lux, CF.lumen or bluelight filter. Try to force stop/uninstall or disable the screen filtering apps and it will work again.

If you are not using any filtering app, try looking for your installed apps that have overlay capability, apps that can show their contents over another apps, apps with overlay permission (like- Messenger, Musixmatch, Touch Assistant apps that can float on your screen).

If you are not sure, try disable them one by one in your `Settings ⇒ Apps` and find which one is causing the problem. You can also look for "Draw over other apps" menu in your android setting where all the apps with this permission will be listed. If you couldn't locate the menu, search for overlay permission + {android version} + {device manufacturer}.

# Answer
> 0 votes
The following is a community-curated list of some well-known/popular apps that have "Draw over other apps" permission and may cause this issue:

* Twilight
* Pixel Filter
* Facebook Messenger
* Battery Mix
* Samsung S Finder
* DU Recorder
* Lux Lite

---
Tags: installation, side-loading, unknown-sources
---


# Question
Title: Compose key (multi key) on physical keyboard
Is it possible to configure a key, say for example `Right Alt`, to work as the Compose key on a physical (Bluetooth/USB) keyboard?

I'm used to a Compose key on my desktop computer, and having it on Android would be extremely useful.

This question seems to have been asked almost a decade ago here, but I believe a lot has changed since then, so I hope that now there might be a way.

# Answer
Perhaps use an app like Key Mapper to change a specific key' function to make it do what you want.
> 0 votes

---
Tags: keyboard, external-keyboard, input-methods, text-input, keyboard-shortcuts
---


# Question
Title: New method for enabling Developer Options in Android 13?
I'm on a Pixel 6a with an OTA release of Android 13 stable. I had Developer Options with 13a beta 4 before I upgraded to a stable release, but now the menu option is no longer visible.

I tried tapping "build number", but it does not respond to touch interaction (no focus, feedback, etc.). Tapping it 7 times does nothing.

Is there a new way to enable Developer Options in Android 13 stable, or am I experiencing a bug?

# Answer
> 2 votes
It looks like my pixel 6a required a restart, now that I have power cycled it, the "build number" box has focus and responded to touch. 7 taps got me to developer options as expected.

---
Tags: google-pixel, developer-options, android-13
---


# Question
Title: Is it sensible to turn off the phone for charging?
I know that electronic devices, when not in use for a few hours and especially when charging, should be turned off. However, when I turn my phone off and plug it into the charger, it shows the "Unlocked Bootloader" warning before showing the charging status, meaning it turns itself on again somewhat.

Is the wear of that negligible, or would it make more sense to simply leave the phone on in battery saving/flight mode when charging overnight?

# Answer
I would not shut down the phone before charging because of two reasons:

1. Modern phones often have an optimized battery loading algorithm especially when charging over night. The charging speed is reduced and the last percent or charged the hour before you usually disconnect the phone from charger. Such an advanced loading strategy is usually not implemented in "charging OS" (the minimal OS started for charging).
2. Another reason is your power button. Turning the phone on usually requires the power button. Unfortunately this crucial button is often the part that fails first...
> 1 votes

---
Tags: charging, battery-life, battery-saver
---


title: Think im being hacked

text:
# Question
Title: Think im being hacked
Firstly I'm a technophobe,totally useless and accept that hence why I need advice and answers before I lose my mind...

I believe my old friend and of recent girlfriend could be hacking me. I dont check often but happen to browse my activity abd noticed sight or applications I've never heard of let alone used further more they were all similar and close together so I'm sure I would know if searched. So in looking up some of these sites / apps they are legitimate but also could all be used to munipilate me. The sites were.... ..Com.android systemui ..com.samsung accessibility ..com.android settings ..google play store device connected,...I read your article and can confirm I don't or have ever connected or used another device, this activity was at the very same time that I was on my phone looking at a site about claiming company petrol spend,so naturally worries me ..com.samsung.android.messenging ..Com.OSP app sing in Com.samsung.android.vision intelligence ..com.sec.android app camera ..com.samsung.android dialer ..com.android server telecom Com.samsung.android incallui

These were in order of searches which started a 13:42 and ended at 17:39 there was a few searches repeated a couple of times like settings and accessibility.

Like I said I don't ir gave I ever used another device, no tablet, second phone nothing, all I gave done in the past is used smartphone on th TV but nit for some time. Please please help me and help turn thus language into a course of intended actions I can understand...thank u

FOZ

# Answer
> 0 votes
All of these applications are normal for a Samsung phone, as indicated by `com.samsung accessibility`. None of these are hacking applications. It's improbable that access to your settings or accessibility settings alone could give enough access.

As mentioned in the comments on your post, mental health issues are not relavent here. Paranoia can be a sign of psychosis, this will be for your care provider and another stack exchange though. I do not know any, so feel free to comment down if you know!

If she had another account on your phone, taking a quick look into your settings would reveal another account. If you are seriously concerned about your account being hijacked, change all your passwords. There should be good enough guides for each email and account provider (Google, Gmail, Outlook, Microsoft, etc)

---
Tags: google-play-store, settings, data-transfer, active-sync, system-info
---


title: Android device for birds

text:
# Question
Title: Android device for birds
I would like to know if there exist any Android devices for birds. I've seen my little bird born from his or her egg in an incubator approach my companion's touch screen to peck on it after she showed him or her how to eat food by pointing in a pecking motion with the finger on the food, after which the bird ate.

Alas, my Android device did not respond to the bird's beak, pecking on the touch phone's screen.

I wonder whether there are any screens designed for beaks.

And, what would be possible, for a bird's interacting system, on an Android device?

Anyone know?

Thanks.

Note: This post asks about the possibility of bird to smartphone interfaces, as I know of none, and I'm not sure of Who would know. I was not sure if this was more appropriate on Android stack exchange or in biology stack exchange or in hardware recommendations stack exchange, or even on software engineering stack exchange. Or even obmn user experience (UX) stack exchange.

Please, if not appropriate here, migrate my post as appropriate.

# Answer
Mobile device touch screens have been made with resistive or capacitive technology.

Resistive required pressure to indicate location so normally used a pen/stylus. Capacitive uses the fact that the skin conducts and by interacting alters the screen's electric field marking position.

Birds tapping on a screen with a beak made of keratin isn't what the device was tuned for. The interaction by the bird is similar to a person with long fingernails using the tip on the screen. Personally I'm not even sure if pecking can activate a resistive screen as the pressure isn't similar to handwriting/human interaction and a certain amount of threshold is required to avoid false positive. However you can still get resistive screen Android devices which are targeted for industrial/construction environments.

Other than a resistive screen, my guess is that any interaction with birds and a screen would required a speciality device like a infrared grid or other similar setup which could detect the intrusion but to my knowledge is usually for large TV-ish screen sizes, i.e. digital chalkboards and kiosk signage.
> 3 votes

---
Tags: applications, touchscreen, accessibility, user-interface
---


# Question
Title: Cannot use the "Alt-C" app on Android phone and Mac laptop
I bought a Samsung Galaxy A71 recently then I installed an app called Alt-C on my phone and my MacBook air. It works fine, but the app cannot copy text from my own phone to my Mac, and a message appears on my phone, saying:

> Alt-C could not paste text to PC: make sure you copied the text on your device.

and a notification appears on my Mac saying:

> there was no text in the device's clipboard.

Does anyone have a solution for that?

# Answer
Had the same problem and it seems that since Android 10, apps can only access the clipboard if they are in the foreground. So the only way for the copy to work from Phone to Mac is to open the app on your phone after you've copied the text, and then paste on the Mac.
> 6 votes

# Answer
I've found that Alt C works on Android 11 if you've recently opened it on your phone, or if you allow it to keep use battery in the background.

For the latter, the ways to do this vary - here's an example for Pixel phones. I haven't tested this thoroughly with Alt C.
> 0 votes

# Answer
In Android 12, I faced the same issue where I was able to copy text from PC to phone but not able to copy text from phone to PC, it showed "couldn't paste text from realme", but later I found the way to copy text from phone to PC.

Basically, when you copy text from your phone then you have to open the Alt-C app in order to sync with your PC, and when the app is open on your phone, then you try to paste it on your PC, then it will be paste. It worked for me in Android 12.
> 0 votes

---
Tags: macos, copy-paste
---


# Question
Title: Is there a way to lock the Google Translate app to a specific Japanese character set (camera translate)?
I'm using my phone to translate menus etc in a Japanese videogame (PS4/5), and it tells me like 12 different things it could be. It's ridiculous. Isn't there a specific Japanese character set games use? Can I lock the app to that???

# Answer
Unlike Chinese which has traditional and simplified character sets, **there is only 1 Japanese character set.**

However, looks like the translation quality is more unreliable in "Instant" mode. Some possible causes:

* The quality/size of the image, which may affect the optical character recognition (OCR, or simply image-to-text). Blurry/small text will be harder to interpret, and any background near the text may also obstruct the clarity.
* The Japanese word itself, since without more context, some words can have many interpretations, or...
* The algorithm sacrifices quality for speed. In "Instant" mode, the app tries to translate as quickly as possible and will continuously retranslate the image, even for a static image.

For more reliable translation, *it is better to use the "Scan" mode instead of the "Instant" mode* since it also provides the original text so that the user can cross-check with other dictionaries/translation tools.
> 0 votes

---
Tags: google-translate
---


title: SystemUI.apk is not in /system/app

text:
# Question
Title: SystemUI.apk is not in /system/app
I tried to pull SystemUI.apk on my Samsung Android Pie/OneUI and it seems like it's either in some other directory than /system/app or has been renamed. I tried to pull this through adb. Tried different cases for it but didn't work. To anyone curious, I want to modify me status bar icons. Does someone know where it might be located?

# Answer
Since Android 4.4, all privileged system apps including SystemUI have been moved to `/system/priv-app`.
> 3 votes

# Answer
To find its location, you can use this `adb` command:

```
adb shell pm list packages -f | grep systemui

```
> 0 votes

---
Tags: adb, system
---


# Question
Title: How to make SELinux injected rules persistent without unpacking-packing boot.img?
I am working on an application that needs root access and I have a device which is rooted but not with Magisk. This device has only `adb shell` root available. So, I need an alternative to call the required functionality without the use of Magisk or other tools. I did it by placing my executable inside system directory and run it as a daemon. This daemon required access on some location which is restricted by SELinux policies.

I have injected the required policy with following commands:

```
    sepolicy-inject -s init -t su -c process -p transition -l
    sepolicy-inject -s su -t system_file -c file -p entrypoint -l
    sepolicy-inject -s init -t su -c process -p rlimitinh -l
    sepolicy-inject -s init -t su -c process -p siginh -l
    sepolicy-inject -s su -t shell_exec -c file -p read -l
    sepolicy-inject -s su -t shell_exec -c file -p execute -l
    sepolicy-inject -s su -t shell_exec -c file -p getattr  -l
    sepolicy-inject -s su -t vendor_toolbox_exec -c file -p execute_no_trans -l
    sepolicy-inject -s init -t su -c process -p noatsecure -l
    sepolicy-inject -s su -t toolbox_exec -c file -p getattr -l
    sepolicy-inject -s su -t toolbox_exec -c file -p execute -l
    sepolicy-inject -s su -t system_file -c file -p execute_no_trans -l
    sepolicy-inject -s su -t storage_file -c dir -p search -l
    sepolicy-inject -s su -t storage_file -c lnk_file -p read -l
    sepolicy-inject -s su -t tmpfs -c dir -p search -l
    sepolicy-inject -s su -t mnt_user_file -c dir -p search -l
    sepolicy-inject -s su -t mnt_user_file -c lnk_file -p read -l
    sepolicy-inject -s su -t sdcardfs -c dir -p search -l
    sepolicy-inject -s su -t sdcardfs -c file -p append -l
    sepolicy-inject -s su -t toolbox_exec -c file -p read -l
    sepolicy-inject -s su -t toolbox_exec -c file -p open -l
    sepolicy-inject -s su -t sdcardfs -c file -p read -l
    sepolicy-inject -s su -t sdcardfs -c file -p write -l
    sepolicy-inject -s su -t sdcardfs -c file -p open -l
    sepolicy-inject -s su -t media_rw_data_file -c file -p read -l
    sepolicy-inject -s su -t media_rw_data_file -c file -p write -l
    sepolicy-inject -s su -t media_rw_data_file -c file -p open -l
    sepolicy-inject -s su -t media_rw_data_file -c file -p append -l

```

The problem is that they are not persistent after reboot. I know I can extract boot.img and ramdisk, replace /sepolicy with new policy file copied from /sys/fs/selinux/policy, repack boot.img and flash back.

I want to do it without reflashing `boot.img`. Is there any way with which I can execute above commands after Android finishes with generating SELinux files?

I have tried following rc files:

```
#/etc/init/custom.rc

# define service, use executable here if script not needed
service custom /system/bin/custom.sh

    # don't start unless explicitly asked to
    disabled

    # Use `seclabel u:r:magisk:s0` to run with unrestricted SELinux context to avoid avc denials
    # can also use "u:r:su:s0" on userdebug / eng builds if no Magisk
    # it's required if SELinux is enforcing and service needs access
    # to some system resources not allowed by default sepolicy
    seclabel u:r:su:s0

# start the service when boot is completed
on property:sys.boot_completed=1
    sepolicy-inject -s init -t su -c process -p transition -l
    sepolicy-inject -s su -t system_file -c file -p entrypoint -l
    sepolicy-inject -s init -t su -c process -p rlimitinh -l
    sepolicy-inject -s init -t su -c process -p siginh -l
    sepolicy-inject -s su -t shell_exec -c file -p read -l
    sepolicy-inject -s su -t shell_exec -c file -p execute -l
    sepolicy-inject -s su -t shell_exec -c file -p getattr  -l
    sepolicy-inject -s su -t vendor_toolbox_exec -c file -p execute_no_trans -l
    sepolicy-inject -s init -t su -c process -p noatsecure -l
    sepolicy-inject -s su -t toolbox_exec -c file -p getattr -l
    sepolicy-inject -s su -t toolbox_exec -c file -p execute -l
    sepolicy-inject -s su -t system_file -c file -p execute_no_trans -l
    sepolicy-inject -s su -t storage_file -c dir -p search -l
    sepolicy-inject -s su -t storage_file -c lnk_file -p read -l
    sepolicy-inject -s su -t tmpfs -c dir -p search -l
    sepolicy-inject -s su -t mnt_user_file -c dir -p search -l
    sepolicy-inject -s su -t mnt_user_file -c lnk_file -p read -l
    sepolicy-inject -s su -t sdcardfs -c dir -p search -l
    sepolicy-inject -s su -t sdcardfs -c file -p append -l
    sepolicy-inject -s su -t toolbox_exec -c file -p read -l
    sepolicy-inject -s su -t toolbox_exec -c file -p open -l
    sepolicy-inject -s su -t sdcardfs -c file -p read -l
    sepolicy-inject -s su -t sdcardfs -c file -p write -l
    sepolicy-inject -s su -t sdcardfs -c file -p open -l
    sepolicy-inject -s su -t media_rw_data_file -c file -p read -l
    sepolicy-inject -s su -t media_rw_data_file -c file -p write -l
    sepolicy-inject -s su -t media_rw_data_file -c file -p open -l
    sepolicy-inject -s su -t media_rw_data_file -c file -p append -l
    start custom

```

but it is not working because I think Android generates SELinux files after my custom service has been triggered.

Also tried above commands on `onrestart` option of init service but failed.

Any suggestion?

# Answer
> 4 votes
The `init` service you have defined won't inject SELinux policy rules because of two reasons:

* The syntax of `sepolicy-inject` commands is incomplete; `.rc` files aren't shell scripts. The correct syntax would be:

```
#/etc/init/custom.rc

...

on property:sys.boot_completed=1
    exec - -- /system/bin/sepolicy-inject -s init -t su -c process -p transition -l

...

```
* This will execute the statement with context `u:r:init.s0`. But modifying SELinux policy requires permission `load_policy` i.e. you need to inject rule `sepolicy-inject -s init -t kernel -c security -p load_policy -l` which again won't be allowed to `init`. Read What sepolicy context will allow any other context to access it? to know how SELinux is enforced on Android.

So you are in the same *chicken or the egg* situation as you were at the start of your previous question. SELinux policy can only be modified with context `u:r:su:s0` which is available only through `adb shell` on `userdebug` builds of ROMs. Or root the device e.g. with Magisk, or replace `/sepolicy` file in `boot.img`.

**NOTE:** You don't need to define rules like `sepolicy-inject -s su ...` as `u:r:su:s0` is already set permissive in policy.

**`sepolicy` File Locations:**

On pre-Treble Android releases, there are two possible locations defined for `sepolicy` file:

```
/sepolicy
/data/security/current/sepolicy

```

As stated here:

> The Android initialisation / reload process will first check for this file at: `/data/security/current/sepolicy`. If not present then check root directory: `/sepolicy`.

However `sepolicy` is loaded by `init` at very early boot process when `/data` is not mounted. As stated here:

> Since only the root filesystem is mounted, it chooses `/sepolicy` at this time. The other path is for dynamic runtime reloads of policy.

So initially `/sepolicy` is loaded for sure. But you can put modified `sepolicy` at other locations to see if the previous policy is (or could possibly be) overwritten at some later boot stage. You might need to copy other files as well; this post could be helpful. I never tried this.

On Oreo+ a monolithic policy is loaded from `/sepolicy` if the device is not a Treble device (or if Magisk patched `init` to force load `/sepolicy`). On Treble devices `/system`, `/vendor` and `/odm` are mounted by kernel before starting `init`, as configured in DTB. Here a pre-compiled split policy is loaded from `/vendor/etc/selinux/precompiled_sepolicy` if it matches with `/system`, or the policy is built from `.cil` files in `/system/etc/selinux` and `/vendor/etc/selinux` before loading. See details here.

In both situations things are far more complicated to try than simply replacing `/sepolicy` file in `boot.img`, which is not a big deal in my opinion. You can `dd` out a backup of your original `boot.img` to `/sdcard` which can be restored in a few seconds anytime. However bootloader needs to be unlocked to boot a modified `boot.img`.
Please note that on devices with system-as-root (`A/B` or others) `ramdisk` is moved to `system.img`. So all files which were previously part of `boot.img` (except kernel and DTB) are now part of `system` partition.

# Answer
> 2 votes
I know the question was asked quite some time ago, but since I tried doing something similar recently and this post was one of the top hits on Google, I want to share my recent experience to help others.

*Note that this answer will focus solely on Android 9 to 13 and Treble devices.*

If we want to know how to modify the SELinux policies, I believe it is good to first understand how the policies are loaded in the first place.

**SELinux in the boot process**

At an early stage of the Android boot process and after mounting most of the partitions, `init` will attempt to load the SELinux policies from a monolithic sepolicy file found at either `/odm/etc/selinux/precompiled_sepolicy` or `/vendor/etc/selinux/precompiled_sepolicy`. If `init` notices that the device is updated out of sync, `init` will instead recompile the SELinux policies based on `.cil` files that can be found on several locations.

You can find all the details in the comments of the init/selinux.cpp source file and by looking at the implementation, but here is a summary of the exact steps taken by `init`:

1. Find the sepolicy file to use:
    * if `/odm/etc/selinux/precompiled_sepolicy` exists, use it as the sepolicy file to use
    * else, if `/vendor/etc/selinux/precompiled_sepolicy` exists, use it as the sepolicy file to use
    * else if neither of the above exists, stop here, recompile the policies based on the `.cil` files and load the newly compiled sepolicy file.
2. Check if device was updated out of sync:
    * Compare `/(odm|vendor)/etc/selinux/precompiled_sepolicy.plat_sepolicy_and_mapping.sha256` and `/system/etc/selinux/plat_sepolicy_and_mapping.sha256`
    * Compare `/(odm|vendor)/etc/selinux/precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256` and `/system_ext/etc/selinux/system_ext_sepolicy_and_mapping.sha256`
    * Compare `/(odm|vendor)/etc/selinux/precompiled_sepolicy.product_sepolicy_and_mapping.sha256` and `/product/etc/selinux/product_sepolicy_and_mapping.sha256`
    * (On Android 13) Compare `/(odm|vendor)/etc/selinux/precompiled_sepolicy.apex_sepolicy.sha256` and `/dev/selinux/apex_sepolicy.sha256`
    * if any of the above pair of files do not match, stop here, recompile the policies based on the `.cil` files and load the newly compiled sepolicy file.
3. If everything is ok, load the precompiled sepolicy file (`/odm/etc/selinux/precompiled_sepolicy` or `/vendor/etc/selinux/precompiled_sepolicy`)

The compilation of the policies based on the `.cil` files is as follows:

1. Get the latest version of the policies that are compatible with the `vendor` version (`/vendor/etc/selinux/plat_sepolicy_vers.txt`, note that `init` does not look at the file in the `/odm` partition)
2. Gather the `.cil` files to compile:
    * `/system/etc/selinux/mapping/{vendor_version}.cil`
    * `/system/etc/selinux/mapping/{vendor_version}.compat.cil`
    * `/system_ext/etc/selinux/system_ext_sepolicy.cil`
    * `/system_ext/etc/selinux/mapping/{vendor_version}.cil`
    * `/product/etc/selinux/product_sepolicy.cil`
    * `/product/etc/selinux/mapping/{vendor_version}.cil`
    * `/vendor/etc/selinux/plat_pub_versioned.cil`
    * `/vendor/etc/selinux/vendor_sepolicy.cil` or if it does not exist: `/vendor/etc/selinux/nonplat_sepolicy.cil`
    * `/odm/etc/selinux/odm_sepolicy.cil`
3. Compile the above files with `secilc` to `/dev/sepolicy.XXXXXX`
4. Load policies from `/dev/sepolicy.XXXXXX`

**Modifying SELinux policies permantently**

Now that we understand how `init` loads the policies, it is easy to see how one could permanently add new policies to the system:

* Directly add the policies to `/odm/etc/selinux/precompiled_sepolicy` or `/vendor/etc/selinux/precompiled_sepolicy` with `sepolicy-inject`:
```
sepolicy-inject -s su -t system_file -c file -p entrypoint -P /vendor/etc/selinux/precompiled_sepolicy -o /vendor/etc/selinux/precompiled_sepolicy

```
* Make `init` thinks the device is updated out of sync (By modifying one of the above `.sha256` files, or deleting the precompiled sepolicy files) and modify one of the above `.cil` files

Note that in both cases, you will need to have a read-write access to the partition you want to modify (`/vendor`, `/odm`, and/or `/system`). These partitions are normally mounted as read-only, so you will have to either:

* Remount them as read-write if you have root access (either because your device is rooted, or using `adb root` on a `userdebug` Android build)
* Boot in recovery mode, mount the partitions as read-write and modify them in recovery

If you do not want to have to remount the partitions every time you want to change the SELinux policies, you can add some SELinux rules to allow `init` to load new policies, thereby resolving the chicken and egg problem (as mentioned in this excellent answer) you had with your `init` script. You can find which SELinux rules are needed by searching for SELinux violations (avc errors) in the device logs on startup:

```
adb logcat | grep avc

```

With this, you will be able to have an `init` script that loads new policies with `sepolicy-inject`.

---
Tags: root-access, linux, services, selinux, init.d
---