Loading src/com/android/settings/SettingsActivity.java +2 −11 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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) Loading src/com/android/settings/Utils.java +12 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 src/com/android/settings/applications/InstalledAppDetails.java +21 −11 Original line number Diff line number Diff line Loading @@ -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 { Loading @@ -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); } Loading @@ -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(); } Loading Loading @@ -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); Loading Loading @@ -458,7 +466,9 @@ public class InstalledAppDetails extends AppInfoBase mPm, context)); mNotificationPreference.setSummary(getNotificationSummary(mAppEntry, context, mBackend)); if (mDataPreference != null) { mDataPreference.setSummary(getDataSummary()); } updateBattery(); Loading Loading
src/com/android/settings/SettingsActivity.java +2 −11 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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) Loading
src/com/android/settings/Utils.java +12 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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
src/com/android/settings/applications/InstalledAppDetails.java +21 −11 Original line number Diff line number Diff line Loading @@ -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 { Loading @@ -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); } Loading @@ -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(); } Loading Loading @@ -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); Loading Loading @@ -458,7 +466,9 @@ public class InstalledAppDetails extends AppInfoBase mPm, context)); mNotificationPreference.setSummary(getNotificationSummary(mAppEntry, context, mBackend)); if (mDataPreference != null) { mDataPreference.setSummary(getDataSummary()); } updateBattery(); Loading