Refactor UidDetailProvider and its dependencies to SettingsLib.

so that it can be reused by Wear app data usage.

Change-Id: Id05f888274e15fbeffa175ee8073de02a8966867
This commit is contained in:
Wei Liu
2015-08-24 17:29:04 -07:00
parent 0e309b867d
commit 6e58d516f0
15 changed files with 22 additions and 442 deletions

View File

@@ -89,8 +89,8 @@ import android.widget.TabWidget;
import com.android.internal.util.UserIcons;
import com.android.settings.UserAdapter.UserDetails;
import com.android.settings.dashboard.DashboardTile;
import com.android.settings.drawable.CircleFramedDrawable;
import com.android.settingslib.applications.ApplicationsState;
import com.android.settingslib.drawable.CircleFramedDrawable;
import java.io.IOException;
import java.io.InputStream;
@@ -460,36 +460,6 @@ public final class Utils {
view.setPaddingRelative(paddingStart, 0, paddingEnd, paddingBottom);
}
/**
* Return string resource that best describes combination of tethering
* options available on this device.
*/
public static int getTetheringLabel(ConnectivityManager cm) {
String[] usbRegexs = cm.getTetherableUsbRegexs();
String[] wifiRegexs = cm.getTetherableWifiRegexs();
String[] bluetoothRegexs = cm.getTetherableBluetoothRegexs();
boolean usbAvailable = usbRegexs.length != 0;
boolean wifiAvailable = wifiRegexs.length != 0;
boolean bluetoothAvailable = bluetoothRegexs.length != 0;
if (wifiAvailable && usbAvailable && bluetoothAvailable) {
return R.string.tether_settings_title_all;
} else if (wifiAvailable && usbAvailable) {
return R.string.tether_settings_title_all;
} else if (wifiAvailable && bluetoothAvailable) {
return R.string.tether_settings_title_all;
} else if (wifiAvailable) {
return R.string.tether_settings_title_wifi;
} else if (usbAvailable && bluetoothAvailable) {
return R.string.tether_settings_title_usb_bluetooth;
} else if (usbAvailable) {
return R.string.tether_settings_title_usb;
} else {
return R.string.tether_settings_title_bluetooth;
}
}
/* Used by UserSettings as well. Call this on a non-ui thread. */
public static boolean copyMeProfilePhoto(Context context, UserInfo user) {
Uri contactUri = Profile.CONTENT_URI;
@@ -904,45 +874,6 @@ public final class Utils {
manager.setOemUnlockEnabled(enabled);
}
/**
* Returns a circular icon for a user.
*/
public static Drawable getUserIcon(Context context, UserManager um, UserInfo user) {
if (user.isManagedProfile()) {
// We use predefined values for managed profiles
Bitmap b = BitmapFactory.decodeResource(context.getResources(),
com.android.internal.R.drawable.ic_corp_icon);
return CircleFramedDrawable.getInstance(context, b);
}
if (user.iconPath != null) {
Bitmap icon = um.getUserIcon(user.id);
if (icon != null) {
return CircleFramedDrawable.getInstance(context, icon);
}
}
return CircleFramedDrawable.getInstance(context, UserIcons.convertToBitmap(
UserIcons.getDefaultUserIcon(user.id, /* light= */ false)));
}
/**
* Returns a label for the user, in the form of "User: user name" or "Work profile".
*/
public static String getUserLabel(Context context, UserInfo info) {
String name = info != null ? info.name : null;
if (info.isManagedProfile()) {
// We use predefined values for managed profiles
return context.getString(R.string.managed_user_title);
} else if (info.isGuest()) {
name = context.getString(R.string.user_guest);
}
if (name == null && info != null) {
name = Integer.toString(info.id);
} else if (info == null) {
name = context.getString(R.string.unknown);
}
return context.getResources().getString(R.string.running_process_item_user_label, name);
}
/**
* Return whether or not the user should have a SIM Cards option in Settings.
* TODO: Change back to returning true if count is greater than one after testing.