Remove data item from app info when not supported
Bug: 21207963 Change-Id: I91693d9a85c0905cbb021181967fa16aac61d3ea
This commit is contained in:
@@ -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,14 +1245,8 @@ 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()) {
|
||||
removeTile = true;
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
// ignored
|
||||
if (!Utils.isBandwidthControlEnabled()) {
|
||||
removeTile = true;
|
||||
}
|
||||
} else if (id == R.id.battery_settings) {
|
||||
// Remove battery settings when battery is not available. (e.g. TV)
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@@ -226,12 +226,16 @@ public class InstalledAppDetails extends AppInfoBase
|
||||
setHasOptionsMenu(true);
|
||||
addPreferencesFromResource(R.xml.installed_app_details);
|
||||
|
||||
INetworkStatsService statsService = INetworkStatsService.Stub.asInterface(
|
||||
ServiceManager.getService(Context.NETWORK_STATS_SERVICE));
|
||||
try {
|
||||
mStatsSession = statsService.openSession();
|
||||
} catch (RemoteException e) {
|
||||
throw new RuntimeException(e);
|
||||
if (Utils.isBandwidthControlEnabled()) {
|
||||
INetworkStatsService statsService = INetworkStatsService.Stub.asInterface(
|
||||
ServiceManager.getService(Context.NETWORK_STATS_SERVICE));
|
||||
try {
|
||||
mStatsSession = statsService.openSession();
|
||||
} 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);
|
||||
getLoaderManager().restartLoader(LOADER_CHART_DATA,
|
||||
ChartDataLoader.buildArgs(getTemplate(getContext()), app),
|
||||
mDataCallbacks);
|
||||
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);
|
||||
mDataPreference.setOnPreferenceClickListener(this);
|
||||
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));
|
||||
mDataPreference.setSummary(getDataSummary());
|
||||
if (mDataPreference != null) {
|
||||
mDataPreference.setSummary(getDataSummary());
|
||||
}
|
||||
|
||||
updateBattery();
|
||||
|
||||
|
Reference in New Issue
Block a user