Hide cell broadcast settings link if needed.
Bug: 25939664 Change-Id: Iccf7d17267aecadff0d18f9fb4f464f3597e4c3e
This commit is contained in:
@@ -68,7 +68,6 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
|
|||||||
private static final String KEY_PROXY_SETTINGS = "proxy_settings";
|
private static final String KEY_PROXY_SETTINGS = "proxy_settings";
|
||||||
private static final String KEY_MOBILE_NETWORK_SETTINGS = "mobile_network_settings";
|
private static final String KEY_MOBILE_NETWORK_SETTINGS = "mobile_network_settings";
|
||||||
private static final String KEY_MANAGE_MOBILE_PLAN = "manage_mobile_plan";
|
private static final String KEY_MANAGE_MOBILE_PLAN = "manage_mobile_plan";
|
||||||
private static final String KEY_CELL_BROADCAST_SETTINGS = "cell_broadcast_settings";
|
|
||||||
private static final String KEY_WFC_SETTINGS = "wifi_calling_settings";
|
private static final String KEY_WFC_SETTINGS = "wifi_calling_settings";
|
||||||
|
|
||||||
public static final String EXIT_ECM_RESULT = "exit_ecm_result";
|
public static final String EXIT_ECM_RESULT = "exit_ecm_result";
|
||||||
@@ -327,26 +326,6 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
|
|||||||
p.setEnabled(!TetherSettings
|
p.setEnabled(!TetherSettings
|
||||||
.isProvisioningNeededButUnavailable(getActivity()));
|
.isProvisioningNeededButUnavailable(getActivity()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable link to CMAS app settings depending on the value in config.xml.
|
|
||||||
boolean isCellBroadcastAppLinkEnabled = this.getResources().getBoolean(
|
|
||||||
com.android.internal.R.bool.config_cellBroadcastAppLinks);
|
|
||||||
try {
|
|
||||||
if (isCellBroadcastAppLinkEnabled) {
|
|
||||||
if (mPm.getApplicationEnabledSetting("com.android.cellbroadcastreceiver")
|
|
||||||
== PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
|
|
||||||
isCellBroadcastAppLinkEnabled = false; // CMAS app disabled
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (IllegalArgumentException ignored) {
|
|
||||||
isCellBroadcastAppLinkEnabled = false; // CMAS app not installed
|
|
||||||
}
|
|
||||||
if (!isAdmin || !isCellBroadcastAppLinkEnabled
|
|
||||||
|| mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_CELL_BROADCASTS)) {
|
|
||||||
PreferenceScreen root = getPreferenceScreen();
|
|
||||||
Preference ps = findPreference(KEY_CELL_BROADCAST_SETTINGS);
|
|
||||||
if (ps != null) root.removePreference(ps);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -478,23 +457,6 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
|
|||||||
result.add(KEY_TETHER_SETTINGS);
|
result.add(KEY_TETHER_SETTINGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable link to CMAS app settings depending on the value in config.xml.
|
|
||||||
boolean isCellBroadcastAppLinkEnabled = context.getResources().getBoolean(
|
|
||||||
com.android.internal.R.bool.config_cellBroadcastAppLinks);
|
|
||||||
try {
|
|
||||||
if (isCellBroadcastAppLinkEnabled) {
|
|
||||||
if (pm.getApplicationEnabledSetting("com.android.cellbroadcastreceiver")
|
|
||||||
== PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
|
|
||||||
isCellBroadcastAppLinkEnabled = false; // CMAS app disabled
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (IllegalArgumentException ignored) {
|
|
||||||
isCellBroadcastAppLinkEnabled = false; // CMAS app not installed
|
|
||||||
}
|
|
||||||
if (isSecondaryUser || !isCellBroadcastAppLinkEnabled) {
|
|
||||||
result.add(KEY_CELL_BROADCAST_SETTINGS);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -76,6 +76,7 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab
|
|||||||
private static final String KEY_VIBRATE_WHEN_RINGING = "vibrate_when_ringing";
|
private static final String KEY_VIBRATE_WHEN_RINGING = "vibrate_when_ringing";
|
||||||
private static final String KEY_WIFI_DISPLAY = "wifi_display";
|
private static final String KEY_WIFI_DISPLAY = "wifi_display";
|
||||||
private static final String KEY_ZEN_MODE = "zen_mode";
|
private static final String KEY_ZEN_MODE = "zen_mode";
|
||||||
|
private static final String KEY_CELL_BROADCAST_SETTINGS = "cell_broadcast_settings";
|
||||||
|
|
||||||
private static final String[] RESTRICTED_KEYS = {
|
private static final String[] RESTRICTED_KEYS = {
|
||||||
KEY_MEDIA_VOLUME,
|
KEY_MEDIA_VOLUME,
|
||||||
@@ -105,6 +106,7 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab
|
|||||||
private ComponentName mSuppressor;
|
private ComponentName mSuppressor;
|
||||||
private int mRingerMode = -1;
|
private int mRingerMode = -1;
|
||||||
|
|
||||||
|
private PackageManager mPm;
|
||||||
private UserManager mUserManager;
|
private UserManager mUserManager;
|
||||||
private RingtonePreference mRequestPreference;
|
private RingtonePreference mRequestPreference;
|
||||||
|
|
||||||
@@ -117,6 +119,7 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
mContext = getActivity();
|
mContext = getActivity();
|
||||||
|
mPm = getPackageManager();
|
||||||
mUserManager = UserManager.get(getContext());
|
mUserManager = UserManager.get(getContext());
|
||||||
mVoiceCapable = Utils.isVoiceCapable(mContext);
|
mVoiceCapable = Utils.isVoiceCapable(mContext);
|
||||||
|
|
||||||
@@ -143,6 +146,24 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab
|
|||||||
com.android.internal.R.drawable.ic_audio_ring_notif_mute);
|
com.android.internal.R.drawable.ic_audio_ring_notif_mute);
|
||||||
removePreference(KEY_RING_VOLUME);
|
removePreference(KEY_RING_VOLUME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enable link to CMAS app settings depending on the value in config.xml.
|
||||||
|
boolean isCellBroadcastAppLinkEnabled = this.getResources().getBoolean(
|
||||||
|
com.android.internal.R.bool.config_cellBroadcastAppLinks);
|
||||||
|
try {
|
||||||
|
if (isCellBroadcastAppLinkEnabled) {
|
||||||
|
if (mPm.getApplicationEnabledSetting("com.android.cellbroadcastreceiver")
|
||||||
|
== PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
|
||||||
|
isCellBroadcastAppLinkEnabled = false; // CMAS app disabled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IllegalArgumentException ignored) {
|
||||||
|
isCellBroadcastAppLinkEnabled = false; // CMAS app not installed
|
||||||
|
}
|
||||||
|
if (!mUserManager.isAdminUser() || !isCellBroadcastAppLinkEnabled
|
||||||
|
|| mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_CELL_BROADCASTS)) {
|
||||||
|
removePreference(KEY_CELL_BROADCAST_SETTINGS);
|
||||||
|
}
|
||||||
initRingtones();
|
initRingtones();
|
||||||
initVibrateWhenRinging();
|
initVibrateWhenRinging();
|
||||||
updateRingerMode();
|
updateRingerMode();
|
||||||
@@ -545,7 +566,7 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab
|
|||||||
public List<SearchIndexableResource> getXmlResourcesToIndex(
|
public List<SearchIndexableResource> getXmlResourcesToIndex(
|
||||||
Context context, boolean enabled) {
|
Context context, boolean enabled) {
|
||||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||||
sir.xmlResId = R.xml.configure_notification_settings;
|
sir.xmlResId = R.xml.sound_settings;
|
||||||
return Arrays.asList(sir);
|
return Arrays.asList(sir);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -559,6 +580,27 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab
|
|||||||
rt.add(KEY_WIFI_DISPLAY);
|
rt.add(KEY_WIFI_DISPLAY);
|
||||||
rt.add(KEY_VIBRATE_WHEN_RINGING);
|
rt.add(KEY_VIBRATE_WHEN_RINGING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final PackageManager pm = context.getPackageManager();
|
||||||
|
final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||||
|
|
||||||
|
// Enable link to CMAS app settings depending on the value in config.xml.
|
||||||
|
boolean isCellBroadcastAppLinkEnabled = context.getResources().getBoolean(
|
||||||
|
com.android.internal.R.bool.config_cellBroadcastAppLinks);
|
||||||
|
try {
|
||||||
|
if (isCellBroadcastAppLinkEnabled) {
|
||||||
|
if (pm.getApplicationEnabledSetting("com.android.cellbroadcastreceiver")
|
||||||
|
== PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
|
||||||
|
isCellBroadcastAppLinkEnabled = false; // CMAS app disabled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IllegalArgumentException ignored) {
|
||||||
|
isCellBroadcastAppLinkEnabled = false; // CMAS app not installed
|
||||||
|
}
|
||||||
|
if (!um.isAdminUser() || !isCellBroadcastAppLinkEnabled) {
|
||||||
|
rt.add(KEY_CELL_BROADCAST_SETTINGS);
|
||||||
|
}
|
||||||
|
|
||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -155,7 +155,7 @@ public final class SearchIndexableResources {
|
|||||||
sResMap.put(SoundSettings.class.getName(),
|
sResMap.put(SoundSettings.class.getName(),
|
||||||
new SearchIndexableResource(
|
new SearchIndexableResource(
|
||||||
Ranking.getRankForClassName(SoundSettings.class.getName()),
|
Ranking.getRankForClassName(SoundSettings.class.getName()),
|
||||||
R.xml.sound_settings,
|
NO_DATA_RES_ID,
|
||||||
SoundSettings.class.getName(),
|
SoundSettings.class.getName(),
|
||||||
R.drawable.ic_settings_sound));
|
R.drawable.ic_settings_sound));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user