diff options
author | Jeff Sharkey <jsharkey@android.com> | 2013-10-09 13:52:17 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2013-10-09 13:52:26 -0700 |
commit | 15be83612c34b65404f15d0feafdb4a329467769 (patch) | |
tree | 5e1591fc46e791a7781ecca2234c1fdbfe861bb4 /packages/DocumentsUI/src/com/android | |
parent | d2e1e810a79ce0988df57c0bcbcd184e14a067b4 (diff) | |
download | frameworks_base-15be83612c34b65404f15d0feafdb4a329467769.zip frameworks_base-15be83612c34b65404f15d0feafdb4a329467769.tar.gz frameworks_base-15be83612c34b65404f15d0feafdb4a329467769.tar.bz2 |
Support overriding calling package in Documents.
Calling package is only used to pick the stack to restore, not for
security purposes. This lets other system tools (like Printing)
indicate the real caller.
Bug: 11149540
Change-Id: I155e32577eaeda7dfcb80a7d84ac3b54f281590a
Diffstat (limited to 'packages/DocumentsUI/src/com/android')
-rw-r--r-- | packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java b/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java index 7660779..d675e8d 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java +++ b/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java @@ -292,7 +292,7 @@ public class DocumentsActivity extends Activity { @Override protected Void doInBackground(Void... params) { // Restore last stack for calling package - final String packageName = getCallingPackage(); + final String packageName = getCallingPackageMaybeExtra(); final Cursor cursor = getContentResolver() .query(RecentsProvider.buildResume(packageName), null, null, null, null); try { @@ -783,6 +783,11 @@ public class DocumentsActivity extends Activity { return mState.stack.peek(); } + private String getCallingPackageMaybeExtra() { + final String extra = getIntent().getStringExtra(DocumentsContract.EXTRA_PACKAGE_NAME); + return (extra != null) ? extra : getCallingPackage(); + } + public Executor getCurrentExecutor() { final DocumentInfo cwd = getCurrentDirectory(); if (cwd != null && cwd.authority != null) { @@ -921,7 +926,7 @@ public class DocumentsActivity extends Activity { if (requestCode == CODE_FORWARD && resultCode != RESULT_CANCELED) { // Remember that we last picked via external app - final String packageName = getCallingPackage(); + final String packageName = getCallingPackageMaybeExtra(); final ContentValues values = new ContentValues(); values.put(ResumeColumns.EXTERNAL, 1); getContentResolver().insert(RecentsProvider.buildResume(packageName), values); @@ -1002,7 +1007,7 @@ public class DocumentsActivity extends Activity { } // Remember location for next app launch - final String packageName = getCallingPackage(); + final String packageName = getCallingPackageMaybeExtra(); values.clear(); values.put(ResumeColumns.STACK, rawStack); values.put(ResumeColumns.EXTERNAL, 0); |