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.nfc.NfcAdapter;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.INetworkManagementService;
|
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.RemoteException;
|
|
||||||
import android.os.ServiceManager;
|
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
@@ -1248,15 +1245,9 @@ public class SettingsActivity extends Activity
|
|||||||
}
|
}
|
||||||
} else if (id == R.id.data_usage_settings) {
|
} else if (id == R.id.data_usage_settings) {
|
||||||
// Remove data usage when kernel module not enabled
|
// Remove data usage when kernel module not enabled
|
||||||
final INetworkManagementService netManager = INetworkManagementService.Stub
|
if (!Utils.isBandwidthControlEnabled()) {
|
||||||
.asInterface(ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE));
|
|
||||||
try {
|
|
||||||
if (!netManager.isBandwidthControlEnabled()) {
|
|
||||||
removeTile = true;
|
removeTile = true;
|
||||||
}
|
}
|
||||||
} catch (RemoteException e) {
|
|
||||||
// ignored
|
|
||||||
}
|
|
||||||
} else if (id == R.id.battery_settings) {
|
} else if (id == R.id.battery_settings) {
|
||||||
// Remove battery settings when battery is not available. (e.g. TV)
|
// 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.BatteryManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
import android.os.INetworkManagementService;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
import android.os.ServiceManager;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.os.storage.StorageManager;
|
import android.os.storage.StorageManager;
|
||||||
@@ -1179,4 +1181,14 @@ public final class Utils {
|
|||||||
return null;
|
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,6 +226,7 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
addPreferencesFromResource(R.xml.installed_app_details);
|
addPreferencesFromResource(R.xml.installed_app_details);
|
||||||
|
|
||||||
|
if (Utils.isBandwidthControlEnabled()) {
|
||||||
INetworkStatsService statsService = INetworkStatsService.Stub.asInterface(
|
INetworkStatsService statsService = INetworkStatsService.Stub.asInterface(
|
||||||
ServiceManager.getService(Context.NETWORK_STATS_SERVICE));
|
ServiceManager.getService(Context.NETWORK_STATS_SERVICE));
|
||||||
try {
|
try {
|
||||||
@@ -233,6 +234,9 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
removePreference(KEY_DATA);
|
||||||
|
}
|
||||||
mBatteryHelper = new BatteryStatsHelper(getActivity(), true);
|
mBatteryHelper = new BatteryStatsHelper(getActivity(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,9 +253,11 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
}
|
}
|
||||||
AppItem app = new AppItem(mAppEntry.info.uid);
|
AppItem app = new AppItem(mAppEntry.info.uid);
|
||||||
app.addUid(mAppEntry.info.uid);
|
app.addUid(mAppEntry.info.uid);
|
||||||
|
if (mStatsSession != null) {
|
||||||
getLoaderManager().restartLoader(LOADER_CHART_DATA,
|
getLoaderManager().restartLoader(LOADER_CHART_DATA,
|
||||||
ChartDataLoader.buildArgs(getTemplate(getContext()), app),
|
ChartDataLoader.buildArgs(getTemplate(getContext()), app),
|
||||||
mDataCallbacks);
|
mDataCallbacks);
|
||||||
|
}
|
||||||
new BatteryUpdater().execute();
|
new BatteryUpdater().execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,7 +288,9 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
mPermissionsPreference = findPreference(KEY_PERMISSION);
|
mPermissionsPreference = findPreference(KEY_PERMISSION);
|
||||||
mPermissionsPreference.setOnPreferenceClickListener(this);
|
mPermissionsPreference.setOnPreferenceClickListener(this);
|
||||||
mDataPreference = findPreference(KEY_DATA);
|
mDataPreference = findPreference(KEY_DATA);
|
||||||
|
if (mDataPreference != null) {
|
||||||
mDataPreference.setOnPreferenceClickListener(this);
|
mDataPreference.setOnPreferenceClickListener(this);
|
||||||
|
}
|
||||||
mBatteryPreference = findPreference(KEY_BATTERY);
|
mBatteryPreference = findPreference(KEY_BATTERY);
|
||||||
mBatteryPreference.setEnabled(false);
|
mBatteryPreference.setEnabled(false);
|
||||||
mBatteryPreference.setOnPreferenceClickListener(this);
|
mBatteryPreference.setOnPreferenceClickListener(this);
|
||||||
@@ -458,7 +466,9 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
mPm, context));
|
mPm, context));
|
||||||
mNotificationPreference.setSummary(getNotificationSummary(mAppEntry, context,
|
mNotificationPreference.setSummary(getNotificationSummary(mAppEntry, context,
|
||||||
mBackend));
|
mBackend));
|
||||||
|
if (mDataPreference != null) {
|
||||||
mDataPreference.setSummary(getDataSummary());
|
mDataPreference.setSummary(getDataSummary());
|
||||||
|
}
|
||||||
|
|
||||||
updateBattery();
|
updateBattery();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user