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

Commit 5ddff937 authored by Doris Ling's avatar Doris Ling Committed by Android (Google) Code Review
Browse files

Merge "Fix crash in ExternalSourceDetailPreferenceController." into pi-dev

parents 24cfa88e c3e4619a
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.settings.applications.appinfo;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.os.UserManager;
import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference;
@@ -57,9 +58,13 @@ public class ExternalSourceDetailPreferenceController extends AppInfoPreferenceC

    @VisibleForTesting
    boolean isPotentialAppSource() {
        final PackageInfo packageInfo = mParent.getPackageInfo();
        if (packageInfo == null) {
            return false;
        }
        AppStateInstallAppsBridge.InstallAppsState appState =
                new AppStateInstallAppsBridge(mContext, null, null).createInstallAppsStateFor(
                        mPackageName, mParent.getPackageInfo().applicationInfo.uid);
                        mPackageName, packageInfo.applicationInfo.uid);
        return appState.isPotentialAppSource();
    }

+8 −0
Original line number Diff line number Diff line
@@ -101,4 +101,12 @@ public class ExternalSourceDetailPreferenceControllerTest {

        verify(mPreference).setSummary(summary);
    }

    @Test
    public void isPotentialAppSource_nullPackageInfo_shouldNotCrash() {
        when(mUserManager.isManagedProfile()).thenReturn(false);

        mController.isPotentialAppSource();
        // no crash
    }
}