New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 891218 link

Starred by 0 users

Issue metadata

Status: Fixed
Owner:
hobby only
Closed: Oct 29
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug

Blocking:
issue 817292



Sign in to add a comment

Create file for serialised passwords in PasswordUIViewAndroid instead of SavePasswordsPreferences

Project Member Reported by vabr@chromium.org, Oct 2

Issue description

This is a follow-up to  issue 817293 .

When Chrome on Android exports passwords, the Java UI code creates the target file for exported passwords first, then calls the C++ backend to fill it with passwords.

This unnecessarily splits the I/O operations at two places, results in more different error handlers and potentially causes a StrictModeDiskReadViolation for the I/O operations done from Java.

Instead, Java should just provide the target directory path, then the C++ backend should create the file in it and fill it in one go.
This way:
 * Any errors coming from the file creation will be reported by the already existing error reporting present for the writing errors.
 * The I/O will happen in one place, properly checked for running on a suitable thread.
 
Just for the record, this is the log about StrictModeDiskReadViolation recorded during exporting passwords:

D/StrictMode(21614): StrictMode policy violation; ~duration=45 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=2591 violation=2
D/StrictMode(21614): 	at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1137)
D/StrictMode(21614): 	at libcore.io.BlockGuardOs.access(BlockGuardOs.java:67)
D/StrictMode(21614): 	at java.io.File.doAccess(File.java:283)
D/StrictMode(21614): 	at java.io.File.exists(File.java:363)
D/StrictMode(21614): 	at android.app.ContextImpl.createFilesDirLocked(ContextImpl.java:995)
D/StrictMode(21614): 	at android.app.ContextImpl.getCacheDir(ContextImpl.java:1080)
D/StrictMode(21614): 	at android.content.ContextWrapper.getCacheDir(ContextWrapper.java:232)
D/StrictMode(21614): 	at org.chromium.chrome.browser.preferences.password.ExportFlow.createTempFileName(ExportFlow.java:496)
D/StrictMode(21614): 	at org.chromium.chrome.browser.preferences.password.ExportFlow.startExporting(ExportFlow.java:287)
D/StrictMode(21614): 	at org.chromium.chrome.browser.preferences.password.SavePasswordsPreferences.onOptionsItemSelected(SavePasswordsPreferences.java:176)
D/StrictMode(21614): 	at org.chromium.chrome.browser.preferences.Preferences.onOptionsItemSelected(Preferences.java:242)
D/StrictMode(21614): 	at android.app.Activity.onMenuItemSelected(Activity.java:2885)
D/StrictMode(21614): 	at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:380)
D/StrictMode(21614): 	at android.support.v7.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:195)
D/StrictMode(21614): 	at android.support.v7.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:108)
D/StrictMode(21614): 	at java.lang.reflect.Method.invoke(Native Method)
D/StrictMode(21614): 	at java.lang.reflect.Method.invoke(Method.java:372)
D/StrictMode(21614): 	at org.chromium.base.ApplicationStatus$WindowCallbackProxy.invoke(ApplicationStatus.java:198)
D/StrictMode(21614): 	at java.lang.reflect.Proxy.invoke(Proxy.java:397)
D/StrictMode(21614): 	at $Proxy0.onMenuItemSelected(Unknown Source)
D/StrictMode(21614): 	at android.support.v7.app.AppCompatDelegateImplV9.onMenuItemSelected(AppCompatDelegateImplV9.java:674)
D/StrictMode(21614): 	at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:822)
D/StrictMode(21614): 	at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:171)
D/StrictMode(21614): 	at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:973)
D/StrictMode(21614): 	at android.support.v7.view.menu.MenuPopup.onItemClick(MenuPopup.java:127)
D/StrictMode(21614): 	at android.widget.AdapterView.performItemClick(AdapterView.java:305)
D/StrictMode(21614): 	at android.widget.AbsListView.performItemClick(AbsListView.java:1146)
D/StrictMode(21614): 	at android.widget.AbsListView$PerformClick.run(AbsListView.java:3053)
D/StrictMode(21614): 	at android.widget.AbsListView$3.run(AbsListView.java:3860)
D/StrictMode(21614): 	at android.os.Handler.handleCallback(Handler.java:739)
D/StrictMode(21614): 	at android.os.Handler.dispatchMessage(Handler.java:95)
D/StrictMode(21614): 	at android.os.Looper.loop(Looper.java:135)
D/StrictMode(21614): 	at android.app.ActivityThread.main(ActivityThread.java:5254)
D/StrictMode(21614): 	at java.lang.reflect.Method.invoke(Native Method)
D/StrictMode(21614): 	at java.lang.reflect.Method.invoke(Method.java:372)
D/StrictMode(21614): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
D/StrictMode(21614): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

Hm, now I realised the StrictModeDiskReadViolation comes from using android.content.ContextWrapper.getCacheDir. That's not something to be addressed on this bug, and it seems out of Chrome's control. In general, StrictModeDiskReadViolation occurrences are tracked in bug 398264.
Adding a figure to help with review of https://crrev.com/c/1256813
Schema of changes for crbug.com_891218.png
54.7 KB View Download
Just for my own record, dumping links to a discussion about custom callbacks on the internal team: go/alrnp, and to an older approved CL which added a 2-value callback: https://crrev.com/c/926527
Project Member

Comment 5 by bugdroid1@chromium.org, Oct 28

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/ddb5f9f89cb68eed764f8d0a7fca4af238a53d74

commit ddb5f9f89cb68eed764f8d0a7fca4af238a53d74
Author: Vaclav Brozek <vabr@chromium.org>
Date: Sun Oct 28 14:08:56 2018

[Password export][Android] Create file in native code

When Chrome exports passwords, it creates a temporary file, serializes
the passwords into it and shares it through an intent.

So far, creating the file happened from the Java code, while writing
to it from the native C++ backend. This required gathering and
reporting I/O errors from two places.

This CL moves the file creation next to the writing code in the native
C++ backend.

As a side effect to achieve the goal, this CL also adds a two-argument
callback for the communication across Java bindings, because
Callback.java only accepts a single argument. The added callback has
fixed argument types (and int and a string), because generalising
seems like a significant effort and there is no clear demand for
that. OTOH, the new callback ends up in base, next to the single-arg
callback, so that it is visible to developers in the future.

Bug:  891218 
Change-Id: Ida685baa72456f8631356f219ea80ad7db195db5
Reviewed-on: https://chromium-review.googlesource.com/c/1256813
Reviewed-by: Tommy Nyquist <nyquist@chromium.org>
Reviewed-by: Ted Choc <tedchoc@chromium.org>
Commit-Queue: Vaclav Brozek <vabr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603376}
[modify] https://crrev.com/ddb5f9f89cb68eed764f8d0a7fca4af238a53d74/base/BUILD.gn
[add] https://crrev.com/ddb5f9f89cb68eed764f8d0a7fca4af238a53d74/base/android/int_string_callback.cc
[add] https://crrev.com/ddb5f9f89cb68eed764f8d0a7fca4af238a53d74/base/android/int_string_callback.h
[add] https://crrev.com/ddb5f9f89cb68eed764f8d0a7fca4af238a53d74/base/android/java/src/org/chromium/base/IntStringCallback.java
[modify] https://crrev.com/ddb5f9f89cb68eed764f8d0a7fca4af238a53d74/chrome/android/java/src/org/chromium/chrome/browser/preferences/password/ExportFlow.java
[modify] https://crrev.com/ddb5f9f89cb68eed764f8d0a7fca4af238a53d74/chrome/android/java/src/org/chromium/chrome/browser/preferences/password/PasswordManagerHandler.java
[modify] https://crrev.com/ddb5f9f89cb68eed764f8d0a7fca4af238a53d74/chrome/android/java/src/org/chromium/chrome/browser/preferences/password/PasswordUIView.java
[modify] https://crrev.com/ddb5f9f89cb68eed764f8d0a7fca4af238a53d74/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/password/SavePasswordsPreferencesTest.java
[modify] https://crrev.com/ddb5f9f89cb68eed764f8d0a7fca4af238a53d74/chrome/browser/android/password_ui_view_android.cc
[modify] https://crrev.com/ddb5f9f89cb68eed764f8d0a7fca4af238a53d74/chrome/browser/android/password_ui_view_android.h
[modify] https://crrev.com/ddb5f9f89cb68eed764f8d0a7fca4af238a53d74/chrome/browser/android/password_ui_view_android_unittest.cc

Status: Fixed (was: Started)

Sign in to add a comment