Merge "Fix removal of optional settings tiles" into lmp-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
f34c350194
@@ -1084,19 +1084,21 @@ public class SettingsActivity extends Activity
|
|||||||
while (n >= 0) {
|
while (n >= 0) {
|
||||||
|
|
||||||
DashboardTile tile = category.getTile(n);
|
DashboardTile tile = category.getTile(n);
|
||||||
|
boolean removeTile = false;
|
||||||
id = (int) tile.id;
|
id = (int) tile.id;
|
||||||
if (id == R.id.operator_settings || id == R.id.manufacturer_settings) {
|
if (id == R.id.operator_settings || id == R.id.manufacturer_settings) {
|
||||||
Utils.updateTileToSpecificActivityFromMetaDataOrRemove(this, category, tile);
|
if (!Utils.updateTileToSpecificActivityFromMetaDataOrRemove(this, tile)) {
|
||||||
|
removeTile = true;
|
||||||
|
}
|
||||||
} else if (id == R.id.wifi_settings) {
|
} else if (id == R.id.wifi_settings) {
|
||||||
// Remove WiFi Settings if WiFi service is not available.
|
// Remove WiFi Settings if WiFi service is not available.
|
||||||
if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI)) {
|
if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI)) {
|
||||||
category.removeTile(n);
|
removeTile = true;
|
||||||
}
|
}
|
||||||
} else if (id == R.id.bluetooth_settings) {
|
} else if (id == R.id.bluetooth_settings) {
|
||||||
// Remove Bluetooth Settings if Bluetooth service is not available.
|
// Remove Bluetooth Settings if Bluetooth service is not available.
|
||||||
if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) {
|
if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) {
|
||||||
category.removeTile(n);
|
removeTile = true;
|
||||||
}
|
}
|
||||||
} 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
|
||||||
@@ -1104,7 +1106,7 @@ public class SettingsActivity extends Activity
|
|||||||
.asInterface(ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE));
|
.asInterface(ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE));
|
||||||
try {
|
try {
|
||||||
if (!netManager.isBandwidthControlEnabled()) {
|
if (!netManager.isBandwidthControlEnabled()) {
|
||||||
category.removeTile(n);
|
removeTile = true;
|
||||||
}
|
}
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
// ignored
|
// ignored
|
||||||
@@ -1113,11 +1115,11 @@ public class SettingsActivity extends Activity
|
|||||||
// Remove battery settings when battery is not available. (e.g. TV)
|
// Remove battery settings when battery is not available. (e.g. TV)
|
||||||
|
|
||||||
if (!mBatteryPresent) {
|
if (!mBatteryPresent) {
|
||||||
category.removeTile(n);
|
removeTile = true;
|
||||||
}
|
}
|
||||||
} else if (id == R.id.home_settings) {
|
} else if (id == R.id.home_settings) {
|
||||||
if (!updateHomeSettingTiles(tile)) {
|
if (!updateHomeSettingTiles(tile)) {
|
||||||
category.removeTile(n);
|
removeTile = true;
|
||||||
}
|
}
|
||||||
} else if (id == R.id.user_settings) {
|
} else if (id == R.id.user_settings) {
|
||||||
boolean hasMultipleUsers =
|
boolean hasMultipleUsers =
|
||||||
@@ -1127,38 +1129,40 @@ public class SettingsActivity extends Activity
|
|||||||
|| (!UserManager.supportsMultipleUsers()
|
|| (!UserManager.supportsMultipleUsers()
|
||||||
&& !hasMultipleUsers)
|
&& !hasMultipleUsers)
|
||||||
|| Utils.isMonkeyRunning()) {
|
|| Utils.isMonkeyRunning()) {
|
||||||
category.removeTile(n);
|
removeTile = true;
|
||||||
}
|
}
|
||||||
} else if (id == R.id.nfc_payment_settings) {
|
} else if (id == R.id.nfc_payment_settings) {
|
||||||
if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC)) {
|
if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC)) {
|
||||||
category.removeTile(n);
|
removeTile = true;
|
||||||
} else {
|
} else {
|
||||||
// Only show if NFC is on and we have the HCE feature
|
// Only show if NFC is on and we have the HCE feature
|
||||||
NfcAdapter adapter = NfcAdapter.getDefaultAdapter(this);
|
NfcAdapter adapter = NfcAdapter.getDefaultAdapter(this);
|
||||||
if (!adapter.isEnabled() || !getPackageManager().hasSystemFeature(
|
if (!adapter.isEnabled() || !getPackageManager().hasSystemFeature(
|
||||||
PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)) {
|
PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)) {
|
||||||
category.removeTile(n);
|
removeTile = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (id == R.id.print_settings) {
|
} else if (id == R.id.print_settings) {
|
||||||
boolean hasPrintingSupport = getPackageManager().hasSystemFeature(
|
boolean hasPrintingSupport = getPackageManager().hasSystemFeature(
|
||||||
PackageManager.FEATURE_PRINTING);
|
PackageManager.FEATURE_PRINTING);
|
||||||
if (!hasPrintingSupport) {
|
if (!hasPrintingSupport) {
|
||||||
category.removeTile(n);
|
removeTile = true;
|
||||||
}
|
}
|
||||||
} else if (id == R.id.development_settings) {
|
} else if (id == R.id.development_settings) {
|
||||||
if (!showDev || um.hasUserRestriction(
|
if (!showDev || um.hasUserRestriction(
|
||||||
UserManager.DISALLOW_DEBUGGING_FEATURES)) {
|
UserManager.DISALLOW_DEBUGGING_FEATURES)) {
|
||||||
category.removeTile(n);
|
removeTile = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UserHandle.MU_ENABLED && UserHandle.myUserId() != 0
|
if (UserHandle.MU_ENABLED && UserHandle.myUserId() != 0
|
||||||
&& !ArrayUtils.contains(SETTINGS_FOR_RESTRICTED, id)
|
&& !ArrayUtils.contains(SETTINGS_FOR_RESTRICTED, id)) {
|
||||||
&& n < category.getTilesCount()) {
|
removeTile = true;
|
||||||
category.removeTile(n);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (removeTile && n < category.getTilesCount()) {
|
||||||
|
category.removeTile(n);
|
||||||
|
}
|
||||||
n--;
|
n--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -177,7 +177,7 @@ public final class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean updateTileToSpecificActivityFromMetaDataOrRemove(Context context,
|
public static boolean updateTileToSpecificActivityFromMetaDataOrRemove(Context context,
|
||||||
DashboardCategory target, DashboardTile tile) {
|
DashboardTile tile) {
|
||||||
|
|
||||||
Intent intent = tile.intent;
|
Intent intent = tile.intent;
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
@@ -230,9 +230,6 @@ public final class Utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Did not find a matching activity, so remove the preference
|
|
||||||
target.removeTile(tile);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user