Update to Android Lollipop and features of working with an external memory card. Physical damage to the microSD memory card

It's finished! On a tablet, namely on Asus MeMO Pad 7, which I replaced my honest hard worker, has received an update to Android 5.0.1. Now I have a device with Lollipop, or, as they say on the Internet, with Lollipop.

The update arrived somewhat unexpectedly. To be honest, I waited in April new firmware to phone ( Asus ZenFone 5) - her, by at least, promised. No one said anything about the tablet, and here it’s up to you, get it and sign for it.

This actually discouraged me (in a good way, of course), also because I purchased the tablet in December, and it had version 4.3. That is, this is the second significant update of the operating system (in fact, there were more updates, but the number Android versions has not changed). The previous manufacturer of my devices - Samsung - could not boast of such a rate of fire, although they also updated the operating system twice: from Android 3.2 to Android 4.1.2 (via 4.0.1). But we had to wait much longer for these new versions.

Well, long live surprises! Having received a notification about the release of a new firmware version, I immediately downloaded it, which is more than 700 meters, and launched the update. Since I downloaded not through my home network, but through a mobile network, everything took a little more time: from the start of the download to the completion of the update, about an hour passed. The update itself lasted about twenty minutes, but potentially could take longer - because after installing the operating system, the update process follows installed programs. My counter counted to 205. But now, the process is over and it’s time to see what has changed.

The first thing that caught my eye was the more sophisticated graphics when unlocking the device. The second is the hand in the notification area. I endured it for a couple of days, hoping that by chance I would see something related to it somewhere. I didn't see it. Then I began to search purposefully and found an explanation on it on 4pda. It turns out that notifications are divided into important and not so important, and it is possible to specify which notifications you want to receive. If you set the option Always notify , then the hand disappears if the option Only important alerts , then the hand appears. To be honest, I removed my hand several times, but for some reason it always comes back. Why? I don't know yet.

Here, in fact, is the procedure for “removing” this hand:

The method given above is not complicated at all. But you can achieve the result even faster and easier: press one of the two volume control buttons - a window will appear on the screen allowing you to change the volume levels for various components systems, and also, attention, manage Alert modes . True, for some reason, these same Alert Modes are displayed in this way quick option not always. I haven’t found a pattern yet, but, to be honest, I didn’t really look for it.

I did not find any official Android updates (for our region) on the official websites.

I found information on the forums that Google released a firmware version for Russia in January 2015. But it is being implemented very slowly on customer devices.

This way, I can wait until my device receives a message that there is a software update. After that I can update Android.

I bought new phone Samsung Galaxy S5, and immediately encountered a problem in the operating room Android system. More precisely, version Android 4.4 KitKat. This version of Android introduced new feature Google developers.

Applications are now denied access to editing files on the SD card!This causes some applications to not work!

I'll tell you how to get around this problem!

Good afternoon, dear readers of our blog!

The other day I bought myself a new phone! Samsung Galaxy S5!

ENJOYING YOUR NEW PHONE

I congratulate myself on a successful purchase, which I have been dreaming about for several years! The phone turned out to be remarkably fast, powerful, beautiful and convenient!

I already had it before HTC phone(he is already about 4-5 years old) with an Android system. One of the first phones with such a system (at the time of purchase). I studied it inside and out, reflashed the system several times, and chose the Android firmware, which was much superior in functionality to the official one at that time.

For those who are not in the know, flashing is a replacement operating system phone. Well, that's about it reinstalling Windows on the computer.

A lot of time has passed, many versions of Android have been released (at the time of purchase I had Android 2.2). The new versions and the phones on which they were installed are much superior to my old smartphone. Therefore, I was very surprised by the power, speed and functionality.

I enjoyed it for about 4 days. Then I came across a problem!

PROBLEM! The file system prohibits editing the file!

After next update, the phone's operating system itself has been updated to Android 4.4

Imagine my surprise when I was unable to edit a single file on own phone! At first I was guilty of glitches, I checked in different folders, tried to edit the file from the computer (by connecting the cable to the phone). There was no way to edit the files!

After looking at the information about the operating system in Settings - About device - SE Status for Android, I saw the word Enforcing.

This is code word Google means a version of Android where application rights are limited at the operating system kernel level! EMAE! Well, I got it!

I turned to the Internet to solve the problem

Here's what I found:

X I just noticed that my phone is completely new, with a 5-year manufacturer’s warranty!

If you get Root access ( administrator rights in the Android system), then the warranty from the manufacturer (Samsung) disappears. In fact, some hacker sites claim that there is special methods return the factory counter to its original position. The factory counter is reset to zero when Root access is obtained. This indicates to the service company that the phone has been hacked and is not covered under warranty.

To influence this counter, you need to disassemble the phone and get into the chips. Therefore, do not fall for such deceptions!

If you get Root access, your warranty will disappear! Tested on my old phone!


IN new version Android 5.0 Google uses a different logic for denying access to external SD cards memory.

1. How does the new logic work?

Applications are installed on the system in compiled form. That is, in a form ready for launch. This increases performance, multitasking and reduces battery consumption.

In other words, previously there were distribution files in the system ( installation files) and the system, when starting the application, compiled it before launching. In other words, the files were packed, while the application was running, the files were unpacked and launched.

Now, in Android 5.0, all applications are installed in a compiled, unzipped form. This results in applications using more space but running faster!

2. What does this lead to?

  1. Access rights are assigned to the application DURING INSTALLATION!
  2. The user has the right to set the rights for a specific application during installation.
  3. The user can change the permissions of the application. For example, if you trust a program, you can allow it to edit files on an external memory card.

I WANT TO UPDATE ANDROID TO VERSION 5.0 to solve the problem!

If I update the OFFICIAL version of the operating system, I WILL KEEP THE WARRANTY!

But I need a version of Android for Russia (specifically for it, and not for another country), so as not to suffer with English words in the interface.

I'll try to find her.

Official program Samsung support Kies phones says my phone is updated to latest version By.

I did not find any official Android updates (for our region) on the official websites.

I found information on the forums that Google released a firmware version for Russia in January 2015. But it is being implemented very slowly on customer devices.

This way, I can wait until my device receives a message that there is a software update. After that I can update Android.

You can flash the new firmware yourself without waiting for an invitation.

A WORKING way to edit files (using a computer) on a phone with Android 4.4 version Enforcing.

After I decided to wait official update, began to rummage through file system on the phone. And I discovered something strange:

  1. You have rights to edit folders - move, rename!
  2. You can delete files, move them to other folders (as copies)
  3. No rights to edit files!

And I immediately came up with a working way to change the file using an intermediate copy! Systems analysis in action...

That is, what we do:

  1. Opening the file for editing
  2. Save it on your computer (it won’t let you save a copy on your phone!)
  3. delete a file from the phone
  4. rewrite the copy to the location of the deleted file!

This way we get the modified file (using an intermediate copy)!

That's how things are, comrades!

If there is news, I’ll post it right away!

And now bye, see you soon!

Problem

The message directs you to visit two websites:

This looks like an internal example (maybe shown in API demos later), but it's quite difficult to understand what's going on.

This is the official documentation for the new API, but it doesn't have enough information on how to use it.

This is what he tells you:

If you really need full access to the entire document subtree, start by running ACTION_OPEN_DOCUMENT_TREE to allow the user to select a directory. Then pass the resulting getData() to fromTreeUri(Context, Uri) to begin working with the user's selected tree.

When navigating a tree of DocumentFile instances, you can always use getUri() to get the Uri representing the underlying document for that object for use with openInputStream(Uri), etc.

To simplify the code on devices running KITKAT or earlier, you can use fromFile(File), which emulates the behavior of the DocumentProvider.

Questions

I have a few questions about the new API:

2 answers

Many good questions, let me understand. :)

How do you use it?

Here's a great tutorial for interacting with the storage access framework in KitKat:

Interaction with new APIs Lollipop is very similar. To prompt the user to select a directory tree, you can run such an intent like this:

Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); startActivityForResult(intent, 42);

Then in your onActivityResult() you can pass the user's selected Uri to a new DocumentFile helper class. Here's a short example that lists the files in a selected directory and then creates a new file:

Public void onActivityResult(int requestCode, int resultCode, Intent resultData) ( if (resultCode == RESULT_OK) ( Uri treeUri = resultData.getData(); DocumentFile pickedDir = DocumentFile.fromTreeUri(this, treeUri); // List all existing files inside picked directory for (Document File file: pickedDir.listFiles()) ( Log.d(TAG, "Found file " + file.getName() + " with size " + file.length()); ) // Create a new file and write into it DocumentFile newFile = pickedDir.createFile("text/plain", "My Novel"); OutputStream out = getContentResolver().openOutputStream(newFile.getUri()); out.write("A long time ago...".getBytes()); out.close(); ) )

If you want to access this Uri from native code, you can call ContentResolver.openFileDescriptor() and then use ParcelFileDescriptor.getFd() or detachFd() to obtain a traditional POSIX integer file descriptor.

How can you check access to files/folders?

By default Uris returned with Storage capabilities Access Framework, does not persist across reboots. The platform "offers" the ability to save permission, but you still need to "take" permission if you want it. In our example above you would call:

GetContentResolver().takePersistableUriPermission(treeUri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);

You can always find out what persistent grants are available for your application through the ContentResolver.getPersistedUriPermissions() API. If you no longer need access to the stored Uri, you can release it using ContentResolver.releasePersistableUriPermission() .

Is this available on KitKat?

No, we cannot retroactively add new features to older versions of the platform.

Can I see which applications have access to files/folders?

Currently no user interface which shows this, but you can find the information in the "Granted Permissions Uri" section of the adb shell dumpsys activity providers output.

What happens if the application is installed for multiple users on the same device?

Uri resolution permissions are isolated per user, like all other multi-user platform features. That is, the same application running under two by different users, has no overlay or shared Uri permissions.

Can permissions be revoked?

The DocumentProvider routine can revoke the permission at any time, for example when it is removed cloud document. The most common way to detect these revoked permissions is when they disappear from ContentResolver.getPersistedUriPermissions() mentioned above.

Permissions are also revoked whenever application data is cleared for any application participating in the grant.

Will the query run recursively on the selected folder?

Yep, the ACTION_OPEN_DOCUMENT_TREE intent gives you recursive access to existing and newly created files and directories.

Does it provide multiple options?

Yes, multiple selection has been supported since KitKat, and you can enable it by setting EXTRA_ALLOW_MULTIPLE when running your ACTION_OPEN_DOCUMENT intent. You can use Intent.setType() or EXTRA_MIME_TYPES to narrow down the file types that can be selected:

Is there a way for the emulator to try the new API?

Yes, the primary storage device should appear in the builder, even on the emulator. If your application uses the storage access framework to access shared storage, you no longer need the READ/WRITE_EXTERNAL_STORAGE permissions and can remove them or use the android:maxSdkVersion function to request them only on earlier versions of the framework.

What happens when the user replaces the SD card with another one?

When physical media is involved, the UUID (such as serial number FAT) of the underlying media is always written into the returned Uri. The system uses this to connect to the media that has been selected by the user, even if the user changes media between multiple slots.

If the user changes on the second card, you need to request access to new map. Because the system remembers grants based on UUID, you will continue to have previously granted access to the original card if the user reinserts it later.

In my Github Android project below, you can find working code that allows writing to extSdCard on Android 5. It assumes the user gives access to the entire SD card and then allows writing everywhere on that card. (If you only want to access single files, things get simpler.)

Main code snipplets

Launching the storage access platform:

@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void triggerStorageAccessFramework() ( Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); startActivityForResult(intent, REQUEST_CODE_STORAGE_ACCESS); )

Processing the response from the storage access platform:

@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public final void onActivityResult(final int requestCode, final int resultCode, final Intent resultData) ( if (requestCode == SettingsFragment.REQUEST_CODE_STORAGE_ACCESS) ( Uri treeUri = null; if (resultCode == Activity .RESULT_OK) ( // Get Uri from Storage Access Framework. treeUri = resultData.getData(); // Persist URI in shared preference so that you can use it later. // Use your own framework here instead of PreferenceUtil. PreferenceUtil.setSharedPreferenceUri(R.string.key_internal_uri_extsdcard, treeUri); // Persistent access permissions. final int takeFlags = resultData.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); getActivity().getContentResolver().takePersistableUriPermission(treeUri, takeFlags); ) ) )

Getting the output stream for a file through the storage access platform (using the stored URL, assuming it is the external SD card's root folder URL)

DocumentFile targetDocument = getDocumentFile(file, false); OutputStream outStream = Application.getAppContext(). getContentResolver().openOutputStream(targetDocument.getUri());

The following helper methods are used:

Public static DocumentFile getDocumentFile(final File file, final boolean isDirectory) ( String baseFolder = getExtSdCardFolder(file); if (baseFolder == null) ( return null; ) String relativePath = null; try ( String fullPath = file.getCanonicalPath(); relativePath = fullPath.substring(baseFolder.length() + 1); catch (IOException e) ( return null; ) Uri treeUri = PreferenceUtil.getSharedPreferenceUri(R.string.key_internal_uri_extsdcard); if (treeUri == null) ( return null); ; ) // start with root of SD card and then parse through document tree. DocumentFile document = DocumentFile.fromTreeUri(Application.getAppContext(), treeUri parts = relativePath.split("\\/"); i = 0;< parts.length; i++) { DocumentFile nextDocument = document.findFile(parts[i]); if (nextDocument == null) { if ((i < parts.length - 1) || isDirectory) { nextDocument = document.createDirectory(parts[i]); } else { nextDocument = document.createFile("image", parts[i]); } } document = nextDocument; } return document; } public static String getExtSdCardFolder(final File file) { String extSdPaths = getExtSdCardPaths(); try { for (int i = 0; i < extSdPaths.length; i++) { if (file.getCanonicalPath().startsWith(extSdPaths[i])) { return extSdPaths[i]; } } } catch (IOException e) { return null; } return null; } /** * Get a list of external SD card paths. (Kitkat or higher.) * * @return A list of external SD card paths. */ @TargetApi(Build.VERSION_CODES.KITKAT) private static String getExtSdCardPaths() { Listpaths = new ArrayList<>(); for (File file: Application.getAppContext().getExternalFilesDirs("external")) ( if (file != null && !file.equals(Application.getAppContext().getExternalFilesDir("external"))) ( int index = file .getAbsolutePath().lastIndexOf("/Android/data");< 0) { Log.w(Application.TAG, "Unexpected external file dir: " + file.getAbsolutePath()); } else { String path = file.getAbsolutePath().substring(0, index); try { path = new File(path).getCanonicalPath(); } catch (IOException e) { // Keep non-canonical path. } paths.add(path); } } } return paths.toArray(new String); } /** * Retrieve the application context. * * @return The(statically stored) application context */ public static Context getAppContext() ( return Application.mApplication.getApplicationContext(); )

Let's talk about how to remove write protection from an SD memory card on Android. Many people face this problem when they try to copy or move files to an SD card. In this article you will find several ways to remove protection Android entries.

How to remove write protection from Android SD card

If you get an error like the image above when you try to copy files or format your SD card, then know that this is not your problem. Moreover, the memory card is not damaged or infected with a virus, it is simply write-protected. Without further ado, we will look at several methods on how to remove Android write protection.

How to remove Android write protection from SD card using Regedit

Most problems and errors can be easily resolved using the registry. We can also use it to remove Android write protection.


This method works in most cases, but if for some reason you are unable to use it, then try the following methods.

How to remove Android write protection from SD card using Diskpart

  1. Insert the SD memory card into your computer and launch Command Prompt. You can do this by pressing the WIN+R key and typing “CMD,” or simply typing “Command Prompt” into the Start menu.
  2. In the window command line you must enter the following commands in order.

  • diskpart
  • list disk
  • select disk x (where X is your SD card number)
  • attributes disk clear readonly
  • clean
  • create partition primary
  • format fs=fat32

If this method did not help to remove Android write protection, do not despair, we have a couple more solutions to this problem.

Change resolution

  1. Insert the SD memory card into the computer. Click right click mouse to the memory card and select Properties. Then in the Security tab you will find your account name.
  2. Change the SD card resolution to Read/Write, Read/Execute, or Full Control.

This method will remove Android write protection.

Alternatively, you can look closely at your SD card to find the lock button. If it is, just switch it. The lock button is used to protect data from being deleted or full formatting memory cards.

We hope you were able to remove Android write protection. If you have any questions, please write in the comments below.

With the update to, users received a number of restrictions on the use of SD cards. Until recently, this problem could be solved using custom firmware or rolling back to a more early version OS. Now the former opportunities can be returned to Android 4.4 KitKat. Read on to find out how to do this.

First of all, you will need to root your Android devices. The second important condition is the application SDFix. Download the application at Android for free you can directly from . To do this, use the link below.

Having installed SDFix on your own Android, you will restore your former capabilities in a few taps. The principle of operation of the application is that SDFix adds the Android UNIX group "media_rw" to WRITE_EXTERNAL_STORAGE thus used in Android 4.4 KitKat XML the file changes to platform.xml. This creates backup initial setup platform.xml.original-pre-sdfix, which can be used to restore restrictions. To return the system to stock, you need to use an explorer that supports root access and replace platform.xml with platform.xml.original-pre-sdfix.

Separately, it should be noted that applications that use SD will receive more low level security. Also important is the fact that SDFix results in permanent changes, which means that once the old permissions are restored, the application can be deleted.