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

Commit b2e07cd0 authored by Jason Monk's avatar Jason Monk Committed by Android (Google) Code Review
Browse files

Merge "Remove data item from app info when not supported" into mnc-dev

parents 462e7008 b45e27bc
Loading
Loading
Loading
Loading
+2 −11
Original line number Diff line number Diff line
@@ -39,10 +39,7 @@ import android.content.res.XmlResourceParser;
import android.nfc.NfcAdapter;
import android.os.Bundle;
import android.os.Handler;
import android.os.INetworkManagementService;
import android.os.Message;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.preference.Preference;
@@ -1248,15 +1245,9 @@ public class SettingsActivity extends Activity
                    }
                } else if (id == R.id.data_usage_settings) {
                    // Remove data usage when kernel module not enabled
                    final INetworkManagementService netManager = INetworkManagementService.Stub
                            .asInterface(ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE));
                    try {
                        if (!netManager.isBandwidthControlEnabled()) {
                    if (!Utils.isBandwidthControlEnabled()) {
                        removeTile = true;
                    }
                    } catch (RemoteException e) {
                        // ignored
                    }
                } else if (id == R.id.battery_settings) {
                    // Remove battery settings when battery is not available. (e.g. TV)

+12 −0
Original line number Diff line number Diff line
@@ -55,7 +55,9 @@ import android.net.Uri;
import android.os.BatteryManager;
import android.os.Bundle;
import android.os.IBinder;
import android.os.INetworkManagementService;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.os.storage.StorageManager;
@@ -1179,4 +1181,14 @@ public final class Utils {
            return null;
        }
    }

    public static boolean isBandwidthControlEnabled() {
        final INetworkManagementService netManager = INetworkManagementService.Stub
                .asInterface(ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE));
        try {
            return netManager.isBandwidthControlEnabled();
        } catch (RemoteException e) {
            return false;
        }
    }
}
 No newline at end of file
+21 −11
Original line number Diff line number Diff line
@@ -226,6 +226,7 @@ public class InstalledAppDetails extends AppInfoBase
        setHasOptionsMenu(true);
        addPreferencesFromResource(R.xml.installed_app_details);

        if (Utils.isBandwidthControlEnabled()) {
            INetworkStatsService statsService = INetworkStatsService.Stub.asInterface(
                    ServiceManager.getService(Context.NETWORK_STATS_SERVICE));
            try {
@@ -233,6 +234,9 @@ public class InstalledAppDetails extends AppInfoBase
            } catch (RemoteException e) {
                throw new RuntimeException(e);
            }
        } else {
            removePreference(KEY_DATA);
        }
        mBatteryHelper = new BatteryStatsHelper(getActivity(), true);
    }

@@ -249,9 +253,11 @@ public class InstalledAppDetails extends AppInfoBase
        }
        AppItem app = new AppItem(mAppEntry.info.uid);
        app.addUid(mAppEntry.info.uid);
        if (mStatsSession != null) {
            getLoaderManager().restartLoader(LOADER_CHART_DATA,
                    ChartDataLoader.buildArgs(getTemplate(getContext()), app),
                    mDataCallbacks);
        }
        new BatteryUpdater().execute();
    }

@@ -282,7 +288,9 @@ public class InstalledAppDetails extends AppInfoBase
        mPermissionsPreference = findPreference(KEY_PERMISSION);
        mPermissionsPreference.setOnPreferenceClickListener(this);
        mDataPreference = findPreference(KEY_DATA);
        if (mDataPreference != null) {
            mDataPreference.setOnPreferenceClickListener(this);
        }
        mBatteryPreference = findPreference(KEY_BATTERY);
        mBatteryPreference.setEnabled(false);
        mBatteryPreference.setOnPreferenceClickListener(this);
@@ -458,7 +466,9 @@ public class InstalledAppDetails extends AppInfoBase
                mPm, context));
        mNotificationPreference.setSummary(getNotificationSummary(mAppEntry, context,
                mBackend));
        if (mDataPreference != null) {
            mDataPreference.setSummary(getDataSummary());
        }

        updateBattery();