diff options
author | Andrew Lee <anwlee@google.com> | 2014-08-12 18:11:27 -0700 |
---|---|---|
committer | Andrew Lee <anwlee@google.com> | 2014-08-14 13:53:31 -0700 |
commit | 84c3780d1bb720aca5706ecaccfc58a4638db5ed (patch) | |
tree | 035a36120479de9127750f093f01de8343f4c445 /src | |
parent | e8411583d356db0568d2aafd9a7e2b0781c89e2b (diff) |
Disable call settings for secondary users.
Bug: 15847952
Change-Id: I50f4995a08c9c1feac097242aec97a375213759e
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/dialer/settings/DialerSettingsActivity.java | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/src/com/android/dialer/settings/DialerSettingsActivity.java b/src/com/android/dialer/settings/DialerSettingsActivity.java index 8d41d775e..b47a4edd2 100644 --- a/src/com/android/dialer/settings/DialerSettingsActivity.java +++ b/src/com/android/dialer/settings/DialerSettingsActivity.java @@ -5,6 +5,8 @@ import com.google.common.collect.Lists; import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; +import android.os.UserHandle; +import android.os.UserManager; import android.preference.PreferenceManager; import android.preference.PreferenceActivity.Header; import android.text.TextUtils; @@ -29,6 +31,8 @@ public class DialerSettingsActivity extends AnalyticsPreferenceActivity { protected SharedPreferences mPreferences; private HeaderAdapter mHeaderAdapter; + private static final int OWNER_HANDLE_ID = 0; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -42,15 +46,17 @@ public class DialerSettingsActivity extends AnalyticsPreferenceActivity { public void onBuildHeaders(List<Header> target) { final Header contactDisplayHeader = new Header(); contactDisplayHeader.titleRes = R.string.settings_contact_display_options_title; - contactDisplayHeader.summaryRes = R.string.settings_contact_display_options_description; contactDisplayHeader.fragment = DisplayOptionsPreferenceFragment.class.getName(); target.add(contactDisplayHeader); - final Header callSettingHeader = new Header(); - callSettingHeader.titleRes = R.string.call_settings_label; - callSettingHeader.summaryRes = R.string.call_settings_description; - callSettingHeader.intent = DialtactsActivity.getCallSettingsIntent(); - target.add(callSettingHeader); + // Only add the call settings header if the current user is the primary/owner user. + if (isPrimaryUser()) { + final Header callSettingHeader = new Header(); + callSettingHeader.titleRes = R.string.call_settings_label; + callSettingHeader.summaryRes = R.string.call_settings_description; + callSettingHeader.intent = DialtactsActivity.getCallSettingsIntent(); + target.add(callSettingHeader); + } } @Override @@ -85,6 +91,23 @@ public class DialerSettingsActivity extends AnalyticsPreferenceActivity { } /** + * Whether a user handle associated with the current user is that of the primary owner. That is, + * whether there is a user handle which has an id which matches the owner's handle. + * @return Whether the current user is the primary user. + */ + private boolean isPrimaryUser() { + UserManager userManager = (UserManager) getSystemService(Context.USER_SERVICE); + List<UserHandle> userHandles = userManager.getUserProfiles(); + for (int i = 0; i < userHandles.size(); i++){ + if (userHandles.get(i).myUserId() == OWNER_HANDLE_ID) { + return true; + } + } + + return false; + } + + /** * This custom {@code ArrayAdapter} is mostly identical to the equivalent one in * {@code PreferenceActivity}, except with a local layout resource. */ @@ -130,7 +153,6 @@ public class DialerSettingsActivity extends AnalyticsPreferenceActivity { } else { holder.summary.setVisibility(View.GONE); } - return view; } } |