Loading src/com/android/documentsui/Model.java +3 −3 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ import static com.android.documentsui.base.Shared.DEBUG; import static com.android.documentsui.base.Shared.VERBOSE; import android.annotation.IntDef; import android.app.RecoverableSecurityException; import android.app.AuthenticationRequiredException; import android.database.Cursor; import android.database.MergeCursor; import android.net.Uri; Loading Loading @@ -310,10 +310,10 @@ public class Model { return mUpdateType == TYPE_UPDATE_EXCEPTION; } public boolean hasRecoverableException() { public boolean hasAuthenticationException() { return mRemoteActionEnabled && hasException() && mException instanceof RecoverableSecurityException; && mException instanceof AuthenticationRequiredException; } public @Nullable Exception getException() { Loading src/com/android/documentsui/dirlist/Message.java +14 −8 Original line number Diff line number Diff line Loading @@ -17,15 +17,16 @@ package com.android.documentsui.dirlist; import android.annotation.Nullable; import android.app.Activity; import android.app.RecoverableSecurityException; import android.app.AuthenticationRequiredException; import android.app.PendingIntent; import android.graphics.drawable.Drawable; import android.util.Log; import com.android.documentsui.Model.Update; import com.android.documentsui.R; import com.android.documentsui.base.RootInfo; import com.android.documentsui.base.Shared; import com.android.documentsui.dirlist.DocumentsAdapter.Environment; import com.android.documentsui.Model.Update; /** * Data object used by {@link InflateMessageDocumentHolder} and {@link HeaderMessageDocumentHolder}. Loading Loading @@ -92,6 +93,7 @@ abstract class Message { final static class HeaderMessage extends Message { private static final String TAG = "HeaderMessage"; HeaderMessage(Environment env, Runnable callback) { super(env, callback); Loading @@ -103,7 +105,7 @@ abstract class Message { // Error gets first dibs ... for now // TODO: These should be different Message objects getting updated instead of // overwriting. if (event.hasRecoverableException()) { if (event.hasAuthenticationException()) { updateToRecoverableExceptionHeader(event); } else if (mEnv.getModel().error != null) { update(mEnv.getModel().error, null, Loading @@ -122,9 +124,13 @@ abstract class Message { mEnv.getContext().getString(R.string.open_app, root.title), mEnv.getContext().getDrawable(R.drawable.ic_dialog_info)); mCallback = () -> { RecoverableSecurityException exception = (RecoverableSecurityException) event.getException(); exception.showAsDialog((Activity) mEnv.getContext()); AuthenticationRequiredException exception = (AuthenticationRequiredException) event.getException(); try { exception.getUserAction().send(); } catch (PendingIntent.CanceledException ignored) { Log.d(TAG, "User Action either caneled or ignored."); } }; } } Loading @@ -138,7 +144,7 @@ abstract class Message { @Override void update(Update event) { reset(); if (event.hasException() && !event.hasRecoverableException()) { if (event.hasException() && !event.hasAuthenticationException()) { updateToInflatedErrorMesage( Shared.DEBUG ? Shared.getStackTrace(event.getException()) : null); } else if (mEnv.getModel().getModelIds().length == 0) { Loading tests/common/com/android/documentsui/DemoProvider.java +5 −6 Original line number Diff line number Diff line Loading @@ -16,13 +16,12 @@ package com.android.documentsui; import android.app.AuthenticationRequiredException; import android.app.PendingIntent; import android.app.RecoverableSecurityException; import android.content.Intent; import android.database.Cursor; import android.database.MatrixCursor; import android.os.Bundle; import android.os.Parcel; import android.provider.DocumentsContract; import java.io.FileNotFoundException; Loading Loading @@ -91,17 +90,17 @@ public class DemoProvider extends TestRootProvider { case "throw a nice exception": throw new RuntimeException(); case "throw a recoverable exception": case "throw a authentication exception": PendingIntent intent = PendingIntent.getActivity(getContext(), 0, new Intent(), 0); throw new RecoverableSecurityException(new UnsupportedOperationException(), "message", "title", intent); throw new AuthenticationRequiredException(new UnsupportedOperationException(), intent); default: addFolder(c, "show info"); addFolder(c, "show error"); addFolder(c, "show both error and info"); addFolder(c, "throw a nice exception"); addFolder(c, "throw a recoverable exception"); addFolder(c, "throw a authentication exception"); break; } Loading tests/functional/com/android/documentsui/FilesActivityUiTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -64,7 +64,7 @@ public class FilesActivityUiTest extends ActivityTest<FilesActivity> { public void testProtectedFolder_showsAuthenticationUi() throws Exception { bots.roots.openRoot("Demo Root"); bots.main.switchToListMode(); bots.directory.openDocument("throw a recoverable exception"); bots.directory.openDocument("throw a authentication exception"); bots.directory.assertHeaderMessageText( "Authentication is required to see the content of this directory"); Loading Loading
src/com/android/documentsui/Model.java +3 −3 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ import static com.android.documentsui.base.Shared.DEBUG; import static com.android.documentsui.base.Shared.VERBOSE; import android.annotation.IntDef; import android.app.RecoverableSecurityException; import android.app.AuthenticationRequiredException; import android.database.Cursor; import android.database.MergeCursor; import android.net.Uri; Loading Loading @@ -310,10 +310,10 @@ public class Model { return mUpdateType == TYPE_UPDATE_EXCEPTION; } public boolean hasRecoverableException() { public boolean hasAuthenticationException() { return mRemoteActionEnabled && hasException() && mException instanceof RecoverableSecurityException; && mException instanceof AuthenticationRequiredException; } public @Nullable Exception getException() { Loading
src/com/android/documentsui/dirlist/Message.java +14 −8 Original line number Diff line number Diff line Loading @@ -17,15 +17,16 @@ package com.android.documentsui.dirlist; import android.annotation.Nullable; import android.app.Activity; import android.app.RecoverableSecurityException; import android.app.AuthenticationRequiredException; import android.app.PendingIntent; import android.graphics.drawable.Drawable; import android.util.Log; import com.android.documentsui.Model.Update; import com.android.documentsui.R; import com.android.documentsui.base.RootInfo; import com.android.documentsui.base.Shared; import com.android.documentsui.dirlist.DocumentsAdapter.Environment; import com.android.documentsui.Model.Update; /** * Data object used by {@link InflateMessageDocumentHolder} and {@link HeaderMessageDocumentHolder}. Loading Loading @@ -92,6 +93,7 @@ abstract class Message { final static class HeaderMessage extends Message { private static final String TAG = "HeaderMessage"; HeaderMessage(Environment env, Runnable callback) { super(env, callback); Loading @@ -103,7 +105,7 @@ abstract class Message { // Error gets first dibs ... for now // TODO: These should be different Message objects getting updated instead of // overwriting. if (event.hasRecoverableException()) { if (event.hasAuthenticationException()) { updateToRecoverableExceptionHeader(event); } else if (mEnv.getModel().error != null) { update(mEnv.getModel().error, null, Loading @@ -122,9 +124,13 @@ abstract class Message { mEnv.getContext().getString(R.string.open_app, root.title), mEnv.getContext().getDrawable(R.drawable.ic_dialog_info)); mCallback = () -> { RecoverableSecurityException exception = (RecoverableSecurityException) event.getException(); exception.showAsDialog((Activity) mEnv.getContext()); AuthenticationRequiredException exception = (AuthenticationRequiredException) event.getException(); try { exception.getUserAction().send(); } catch (PendingIntent.CanceledException ignored) { Log.d(TAG, "User Action either caneled or ignored."); } }; } } Loading @@ -138,7 +144,7 @@ abstract class Message { @Override void update(Update event) { reset(); if (event.hasException() && !event.hasRecoverableException()) { if (event.hasException() && !event.hasAuthenticationException()) { updateToInflatedErrorMesage( Shared.DEBUG ? Shared.getStackTrace(event.getException()) : null); } else if (mEnv.getModel().getModelIds().length == 0) { Loading
tests/common/com/android/documentsui/DemoProvider.java +5 −6 Original line number Diff line number Diff line Loading @@ -16,13 +16,12 @@ package com.android.documentsui; import android.app.AuthenticationRequiredException; import android.app.PendingIntent; import android.app.RecoverableSecurityException; import android.content.Intent; import android.database.Cursor; import android.database.MatrixCursor; import android.os.Bundle; import android.os.Parcel; import android.provider.DocumentsContract; import java.io.FileNotFoundException; Loading Loading @@ -91,17 +90,17 @@ public class DemoProvider extends TestRootProvider { case "throw a nice exception": throw new RuntimeException(); case "throw a recoverable exception": case "throw a authentication exception": PendingIntent intent = PendingIntent.getActivity(getContext(), 0, new Intent(), 0); throw new RecoverableSecurityException(new UnsupportedOperationException(), "message", "title", intent); throw new AuthenticationRequiredException(new UnsupportedOperationException(), intent); default: addFolder(c, "show info"); addFolder(c, "show error"); addFolder(c, "show both error and info"); addFolder(c, "throw a nice exception"); addFolder(c, "throw a recoverable exception"); addFolder(c, "throw a authentication exception"); break; } Loading
tests/functional/com/android/documentsui/FilesActivityUiTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -64,7 +64,7 @@ public class FilesActivityUiTest extends ActivityTest<FilesActivity> { public void testProtectedFolder_showsAuthenticationUi() throws Exception { bots.roots.openRoot("Demo Root"); bots.main.switchToListMode(); bots.directory.openDocument("throw a recoverable exception"); bots.directory.openDocument("throw a authentication exception"); bots.directory.assertHeaderMessageText( "Authentication is required to see the content of this directory"); Loading