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

Commit d19398ab authored by Jan Nordqvist's avatar Jan Nordqvist Committed by android-build-merger
Browse files

Merge "Fixing incorrect method to launch mobile data plan app." into pi-dev am: 27441a98

am: 6bc28cdb

Change-Id: If762696a406b96cb4cdc8a30bcd1b8d70db2804b
parents 1e881215 6bc28cdb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -187,7 +187,7 @@ public class DataUsageSummaryPreference extends Preference {
            updateCarrierInfo(carrierInfo);
            if (mLaunchIntent != null) {
                launchButton.setOnClickListener((view) -> {
                    getContext().sendBroadcast(mLaunchIntent);
                    getContext().startActivity(mLaunchIntent);
                });
                launchButton.setVisibility(View.VISIBLE);
            } else {
+26 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.graphics.Typeface;
import android.net.NetworkTemplate;
import android.os.Bundle;
import android.support.v7.preference.PreferenceViewHolder;
import android.telephony.SubscriptionManager;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
@@ -409,6 +410,31 @@ public class DataUsageSummaryPreferenceTest {
        assertThat(mDataRemaining.getText()).isEqualTo("");
    }

    @Test
    public void testSetAppIntent_toMdpApp_intentCorrect() {
        final Activity activity = Robolectric.setupActivity(Activity.class);
        final Intent intent = new Intent(SubscriptionManager.ACTION_MANAGE_SUBSCRIPTION_PLANS);
        intent.setPackage("test-owner.example.com");
        intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, 42);

        mSummaryPreference.setUsageInfo(mCycleEnd, mUpdateTime, DUMMY_CARRIER, 0 /* numPlans */,
                intent);

        bindViewHolder();
        assertThat(mLaunchButton.getVisibility()).isEqualTo(View.VISIBLE);
        assertThat(mLaunchButton.getText())
                .isEqualTo(mContext.getString(R.string.launch_mdp_app_text));

        mLaunchButton.callOnClick();
        ShadowActivity shadowActivity = Shadows.shadowOf(activity);
        Intent startedIntent = shadowActivity.getNextStartedActivity();
        assertThat(startedIntent.getAction())
                .isEqualTo(SubscriptionManager.ACTION_MANAGE_SUBSCRIPTION_PLANS);
        assertThat(startedIntent.getPackage()).isEqualTo("test-owner.example.com");
        assertThat(startedIntent.getIntExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, -1))
                .isEqualTo(42);
    }

    @Test
    public void testSetWifiMode_withUsageInfo_dataUsageShown() {
        final int daysLeft = 3;