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

Commit ac60addc authored by Qiang Chen's avatar Qiang Chen Committed by Linux Build Service Account
Browse files

DataUsageSummary: Invoke vendor part of the MobileNetwiorkSettings

Using vendor part of the MobileNetworkSettings rather than default
one if NetworkSettings Apk is available.

CRs-Fixed: 1041029

Change-Id: Ic5ab9ae3bc7da61151fa26b5e61ecc1b3fb9c74b
parent 825c4d82
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -1156,5 +1156,25 @@ public final class Utils extends com.android.settingslib.Utils {
        }
        return false;
    }

    /**
     * check whether NetworkSetting apk exist in system, if yes, return true, else
     * return false.
     */
    public static boolean isNetworkSettingsApkAvailable(Context context) {
        // check whether the target handler exist in system
        Intent intent = new Intent("org.codeaurora.settings.NETWORK_OPERATOR_SETTINGS_ASYNC");
        PackageManager pm = context.getPackageManager();
        List<ResolveInfo> list = pm.queryIntentActivities(intent, 0);
        for (ResolveInfo resolveInfo : list){
            // check is it installed in system.img, exclude the application
            // installed by user
            if ((resolveInfo.activityInfo.applicationInfo.flags &
                    ApplicationInfo.FLAG_SYSTEM) != 0) {
                return true;
            }
        }
        return false;
    }
}
+1 −21
Original line number Diff line number Diff line
@@ -122,26 +122,6 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
        return super.onPreferenceTreeClick(preference);
    }

    /**
     * check whether NetworkSetting apk exist in system, if yes, return true, else
     * return false.
     */
    private boolean isNetworkSettingsApkAvailable() {

            // check whether the target handler exist in system
            Intent intent = new Intent("org.codeaurora.settings.NETWORK_OPERATOR_SETTINGS_ASYNC");
            List<ResolveInfo> list = mPm.queryIntentActivities(intent, 0);
            for (ResolveInfo resolveInfo : list){
                // check is it installed in system.img, exclude the application
                // installed by user
                if ((resolveInfo.activityInfo.applicationInfo.flags &
                        ApplicationInfo.FLAG_SYSTEM) != 0) {
                    return true;
                }
            }
        return false;
    }

    public void onMobileNetworkSettingsClick() {
        log("onMobileNetworkSettingsClick:");
        final Intent intent = new Intent(Intent.ACTION_MAIN);
@@ -332,7 +312,7 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
            removePreference(KEY_MOBILE_NETWORK_SETTINGS);
            removePreference(KEY_MANAGE_MOBILE_PLAN);
        } else {
            mIsNetworkSettingsAvailable = isNetworkSettingsApkAvailable();
            mIsNetworkSettingsAvailable = Utils.isNetworkSettingsApkAvailable(getActivity());
        }
        // Remove Mobile Network Settings and Manage Mobile Plan
        // if config_show_mobile_plan sets false.
+11 −3
Original line number Diff line number Diff line
@@ -146,9 +146,17 @@ public class DataUsageSummary extends DataUsageBase implements Indexable {
        switch (item.getItemId()) {
            case R.id.data_usage_menu_cellular_networks: {
                final Intent intent = new Intent(Intent.ACTION_MAIN);
                if (Utils.isNetworkSettingsApkAvailable(getContext())) {
                    Log.d(TAG, "qti MobileNetworkSettings Enabled");
                    // prepare intent to start qti MobileNetworkSettings activity
                    intent.setComponent(new ComponentName("com.qualcomm.qti.networksetting",
                            "com.qualcomm.qti.networksetting.MobileNetworkSettings"));
                    startActivity(intent);
                } else {
                    intent.setComponent(new ComponentName("com.android.phone",
                            "com.android.phone.MobileNetworkSettings"));
                    startActivity(intent);
                }
                return true;
            }
            case R.id.data_usage_menu_app_network_access: {