Hide default phone preference when there is no phone app.

Bug: 29859821
Change-Id: Ia6de0de04d74f4f947243f38ac2bd190ae586401
(cherry picked from commit bc6fc60683)
This commit is contained in:
Fan Zhang
2016-08-15 12:32:20 -07:00
parent a928b294d9
commit dc1e04035b

View File

@@ -82,9 +82,13 @@ public class DefaultPhonePreference extends AppListPreference implements SelfAva
return false;
}
final UserManager um =
(UserManager) context.getSystemService(Context.USER_SERVICE);
return !um.hasUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS);
final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
final boolean hasUserRestriction =
um.hasUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS);
final CharSequence[] entries = getEntries();
return !hasUserRestriction
&& entries != null
&& entries.length > 0;
}
public static boolean hasPhonePreference(String pkg, Context context) {