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

Commit 46abffb3 authored by Mark Renouf's avatar Mark Renouf
Browse files

Fix UsbResolverActivity SuperNotCalledException (pt2)

Instead of calling the normal path, this change creates
a path to call Activity#onCreate directly and avoid
initializing state when the activity is about to self
finish()

Bug: 201719995
Test: adb shell am start -n
      com.android.systemui/com.android.systemui.usb.UsbResolverActivity
Change-Id: I40ee792e341b828a3e288b1fc713f6df13728b4a
parent c1512c20
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -314,6 +314,15 @@ public class ResolverActivity extends Activity implements
        return intent;
    }

    /**
     * Call {@link Activity#onCreate} without initializing anything further. This should
     * only be used when the activity is about to be immediately finished to avoid wasting
     * initializing steps and leaking resources.
     */
    protected void super_onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // Use a specialized prompt when we're handling the 'Home' app startActivity()
+2 −4
Original line number Diff line number Diff line
@@ -63,8 +63,7 @@ public class UsbResolverActivity extends ResolverActivity {
        Intent intent = getIntent();
        Parcelable targetParcelable = intent.getParcelableExtra(Intent.EXTRA_INTENT);
        if (!(targetParcelable instanceof Intent)) {
            super.onCreate(savedInstanceState);
            onStop(); // unregister receiver registered in onCreate (PackageMonitor)
            super_onCreate(savedInstanceState);
            Log.w("UsbResolverActivity", "Target is not an intent: " + targetParcelable);
            finish();
            return;
@@ -97,8 +96,7 @@ public class UsbResolverActivity extends ResolverActivity {
        } else {
            mAccessory = (UsbAccessory)target.getParcelableExtra(UsbManager.EXTRA_ACCESSORY);
            if (mAccessory == null) {
                super.onCreate(savedInstanceState);
                onStop(); // unregister receiver registered in onCreate (PackageMonitor)
                super_onCreate(savedInstanceState);
                Log.e(TAG, "no device or accessory");
                finish();
                return;