Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1e899dc1 authored by Gary Mai's avatar Gary Mai
Browse files

Handle revoked permissions when resuming the app (1/2)

The activities that create these fragments will request permissions
but if these fragments were created and the permissions were revoked
then Activity's super.onCreate() will recreate these fragments before
the permission activity is started, which causes a bunch of issues
since the original activity never finishes it's onCreate method so
many things aren't initialized for the fragments.
So in activities that maybe start the permission activity and have
visisble fragments, instead of returning, continue initializing
everything.
In the case of editor, not being able to select a raw contact delta
is a legit case so it should have been handled as a failure and in
general we shouldn't be attempting to bind the editors if we don't
have the permissions.

Test: Manually verified removing permissions and going back to the
app from the recent apps screen doesn't crash while viewing:
  * main list
  * groups view
  * first level suggestions
  * duplicates view
  * account view
  * editor
  * settings
  * pick group member to add view
  * pick phone numbers to send to from group
  * pick emails to send to from group

The behavior is permissions get requested and will go back to the
original activity (PeopleActivity with main list loaded or the
editor activity).

Bug: 34741297
Change-Id: Ie234b1f44e83372b9c0ad9658fa4a2e9b40572b0
parent 7826cb2f
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -44,9 +44,7 @@ public class NonPhoneActivity extends ContactsActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (RequestPermissionsActivity.startPermissionActivity(this)) {
            return;
        }
        RequestPermissionsActivity.startPermissionActivityIfNeeded(this);

        final String phoneNumber = getPhoneNumber();
        if (TextUtils.isEmpty(phoneNumber)) {
+1 −1
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ public class AttachPhotoActivity extends ContactsActivity {
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);

        if (RequestPermissionsActivity.startPermissionActivity(this)) {
        if (RequestPermissionsActivity.startPermissionActivityIfNeeded(this)) {
            return;
        }

+1 −3
Original line number Diff line number Diff line
@@ -319,9 +319,7 @@ public class ContactEditorActivity extends AppCompatContactsActivity implements
    public void onCreate(Bundle savedState) {
        super.onCreate(savedState);

        if (RequestPermissionsActivity.startPermissionActivity(this)) {
            return;
        }
        RequestPermissionsActivity.startPermissionActivityIfNeeded(this);

        final Intent intent = getIntent();
        final String action = intent.getAction();
+1 −1
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ public class ContactEditorSpringBoardActivity extends AppCompatContactsActivity
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if (RequestPermissionsActivity.startPermissionActivity(this)) {
        if (RequestPermissionsActivity.startPermissionActivityIfNeeded(this)) {
            return;
        }

+1 −3
Original line number Diff line number Diff line
@@ -107,9 +107,7 @@ public class ContactSelectionActivity extends AppCompatContactsActivity implemen
    protected void onCreate(Bundle savedState) {
        super.onCreate(savedState);

        if (RequestPermissionsActivity.startPermissionActivity(this)) {
            return;
        }
        RequestPermissionsActivity.startPermissionActivityIfNeeded(this);

        if (savedState != null) {
            mActionCode = savedState.getInt(KEY_ACTION_CODE);
Loading