Wei Liu | 30275c1 | 2015-08-24 17:35:49 -0700 | [diff] [blame] | 1 | package com.android.settingslib; |
| 2 | |
Andrew Sapperstein | 5c37344 | 2016-06-12 13:17:16 -0700 | [diff] [blame] | 3 | import android.annotation.ColorInt; |
Wei Liu | 30275c1 | 2015-08-24 17:35:49 -0700 | [diff] [blame] | 4 | import android.content.Context; |
Jason Monk | c06fbb1 | 2016-01-08 14:12:18 -0500 | [diff] [blame] | 5 | import android.content.Intent; |
Julia Reynolds | 21c3054 | 2016-01-15 15:00:02 -0500 | [diff] [blame] | 6 | import android.content.pm.PackageInfo; |
| 7 | import android.content.pm.PackageManager; |
| 8 | import android.content.pm.PackageManager.NameNotFoundException; |
Julia Reynolds | 21c3054 | 2016-01-15 15:00:02 -0500 | [diff] [blame] | 9 | import android.content.pm.Signature; |
Fan Zhang | 73b161d | 2017-02-08 11:46:54 -0800 | [diff] [blame] | 10 | import android.content.pm.UserInfo; |
jackqdyulei | b68fd7a | 2017-01-04 15:43:26 -0800 | [diff] [blame] | 11 | import android.content.res.ColorStateList; |
Jason Monk | c06fbb1 | 2016-01-08 14:12:18 -0500 | [diff] [blame] | 12 | import android.content.res.Resources; |
Andrew Sapperstein | 5c37344 | 2016-06-12 13:17:16 -0700 | [diff] [blame] | 13 | import android.content.res.TypedArray; |
Wei Liu | 30275c1 | 2015-08-24 17:35:49 -0700 | [diff] [blame] | 14 | import android.graphics.Bitmap; |
| 15 | import android.graphics.BitmapFactory; |
Jason Monk | 3250885 | 2017-01-18 09:17:13 -0500 | [diff] [blame] | 16 | import android.graphics.Color; |
Wei Liu | 30275c1 | 2015-08-24 17:35:49 -0700 | [diff] [blame] | 17 | import android.graphics.drawable.Drawable; |
Sundeep Ghuman | f84e057 | 2017-01-10 13:43:03 -0800 | [diff] [blame] | 18 | import android.graphics.drawable.LayerDrawable; |
Wei Liu | 30275c1 | 2015-08-24 17:35:49 -0700 | [diff] [blame] | 19 | import android.net.ConnectivityManager; |
Sundeep Ghuman | 699deaf | 2017-02-13 15:32:13 -0800 | [diff] [blame] | 20 | import android.net.NetworkBadging; |
Jason Monk | c06fbb1 | 2016-01-08 14:12:18 -0500 | [diff] [blame] | 21 | import android.os.BatteryManager; |
Wei Liu | 30275c1 | 2015-08-24 17:35:49 -0700 | [diff] [blame] | 22 | import android.os.UserManager; |
Philip P. Moltmann | 545a58a | 2016-06-28 14:14:06 -0700 | [diff] [blame] | 23 | import android.print.PrintManager; |
Daniel Nishi | 5398280 | 2017-05-23 15:54:34 -0700 | [diff] [blame] | 24 | import android.provider.Settings; |
Sundeep Ghuman | d57f324 | 2017-01-13 15:31:48 -0800 | [diff] [blame] | 25 | import android.view.View; |
| 26 | |
Wei Liu | 30275c1 | 2015-08-24 17:35:49 -0700 | [diff] [blame] | 27 | import com.android.internal.util.UserIcons; |
Evan Rosky | aa7f51f | 2016-03-16 13:15:53 -0700 | [diff] [blame] | 28 | import com.android.settingslib.drawable.UserIconDrawable; |
Wei Liu | 30275c1 | 2015-08-24 17:35:49 -0700 | [diff] [blame] | 29 | |
Jason Monk | c06fbb1 | 2016-01-08 14:12:18 -0500 | [diff] [blame] | 30 | import java.text.NumberFormat; |
| 31 | |
| 32 | public class Utils { |
Svetoslav Ganov | a9c2500 | 2016-04-13 19:25:56 -0700 | [diff] [blame] | 33 | private static Signature[] sSystemSignature; |
| 34 | private static String sPermissionControllerPackageName; |
| 35 | private static String sServicesSystemSharedLibPackageName; |
| 36 | private static String sSharedSystemSharedLibPackageName; |
Wei Liu | 30275c1 | 2015-08-24 17:35:49 -0700 | [diff] [blame] | 37 | |
Sundeep Ghuman | 9d10a3c | 2017-06-16 00:05:16 +0000 | [diff] [blame] | 38 | static final int[] WIFI_PIE_FOR_BADGING = { |
Sundeep Ghuman | f84e057 | 2017-01-10 13:43:03 -0800 | [diff] [blame] | 39 | com.android.internal.R.drawable.ic_signal_wifi_badged_0_bars, |
| 40 | com.android.internal.R.drawable.ic_signal_wifi_badged_1_bar, |
| 41 | com.android.internal.R.drawable.ic_signal_wifi_badged_2_bars, |
| 42 | com.android.internal.R.drawable.ic_signal_wifi_badged_3_bars, |
| 43 | com.android.internal.R.drawable.ic_signal_wifi_badged_4_bars |
| 44 | }; |
| 45 | |
Wei Liu | 30275c1 | 2015-08-24 17:35:49 -0700 | [diff] [blame] | 46 | /** |
| 47 | * Return string resource that best describes combination of tethering |
| 48 | * options available on this device. |
| 49 | */ |
| 50 | public static int getTetheringLabel(ConnectivityManager cm) { |
| 51 | String[] usbRegexs = cm.getTetherableUsbRegexs(); |
| 52 | String[] wifiRegexs = cm.getTetherableWifiRegexs(); |
| 53 | String[] bluetoothRegexs = cm.getTetherableBluetoothRegexs(); |
| 54 | |
| 55 | boolean usbAvailable = usbRegexs.length != 0; |
| 56 | boolean wifiAvailable = wifiRegexs.length != 0; |
| 57 | boolean bluetoothAvailable = bluetoothRegexs.length != 0; |
| 58 | |
| 59 | if (wifiAvailable && usbAvailable && bluetoothAvailable) { |
| 60 | return R.string.tether_settings_title_all; |
| 61 | } else if (wifiAvailable && usbAvailable) { |
| 62 | return R.string.tether_settings_title_all; |
| 63 | } else if (wifiAvailable && bluetoothAvailable) { |
| 64 | return R.string.tether_settings_title_all; |
| 65 | } else if (wifiAvailable) { |
| 66 | return R.string.tether_settings_title_wifi; |
| 67 | } else if (usbAvailable && bluetoothAvailable) { |
| 68 | return R.string.tether_settings_title_usb_bluetooth; |
| 69 | } else if (usbAvailable) { |
| 70 | return R.string.tether_settings_title_usb; |
| 71 | } else { |
| 72 | return R.string.tether_settings_title_bluetooth; |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Returns a label for the user, in the form of "User: user name" or "Work profile". |
| 78 | */ |
| 79 | public static String getUserLabel(Context context, UserInfo info) { |
| 80 | String name = info != null ? info.name : null; |
| 81 | if (info.isManagedProfile()) { |
| 82 | // We use predefined values for managed profiles |
| 83 | return context.getString(R.string.managed_user_title); |
| 84 | } else if (info.isGuest()) { |
| 85 | name = context.getString(R.string.user_guest); |
| 86 | } |
| 87 | if (name == null && info != null) { |
| 88 | name = Integer.toString(info.id); |
| 89 | } else if (info == null) { |
| 90 | name = context.getString(R.string.unknown); |
| 91 | } |
| 92 | return context.getResources().getString(R.string.running_process_item_user_label, name); |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Returns a circular icon for a user. |
| 97 | */ |
Evan Rosky | aa7f51f | 2016-03-16 13:15:53 -0700 | [diff] [blame] | 98 | public static UserIconDrawable getUserIcon(Context context, UserManager um, UserInfo user) { |
| 99 | final int iconSize = UserIconDrawable.getSizeForList(context); |
Wei Liu | 30275c1 | 2015-08-24 17:35:49 -0700 | [diff] [blame] | 100 | if (user.isManagedProfile()) { |
| 101 | // We use predefined values for managed profiles |
| 102 | Bitmap b = BitmapFactory.decodeResource(context.getResources(), |
| 103 | com.android.internal.R.drawable.ic_corp_icon); |
Evan Rosky | aa7f51f | 2016-03-16 13:15:53 -0700 | [diff] [blame] | 104 | return new UserIconDrawable(iconSize).setIcon(b).bake(); |
Wei Liu | 30275c1 | 2015-08-24 17:35:49 -0700 | [diff] [blame] | 105 | } |
| 106 | if (user.iconPath != null) { |
| 107 | Bitmap icon = um.getUserIcon(user.id); |
| 108 | if (icon != null) { |
Evan Rosky | aa7f51f | 2016-03-16 13:15:53 -0700 | [diff] [blame] | 109 | return new UserIconDrawable(iconSize).setIcon(icon).bake(); |
Wei Liu | 30275c1 | 2015-08-24 17:35:49 -0700 | [diff] [blame] | 110 | } |
| 111 | } |
Evan Rosky | aa7f51f | 2016-03-16 13:15:53 -0700 | [diff] [blame] | 112 | return new UserIconDrawable(iconSize).setIconDrawable( |
| 113 | UserIcons.getDefaultUserIcon(user.id, /* light= */ false)).bake(); |
Wei Liu | 30275c1 | 2015-08-24 17:35:49 -0700 | [diff] [blame] | 114 | } |
Jason Monk | c06fbb1 | 2016-01-08 14:12:18 -0500 | [diff] [blame] | 115 | |
jackqdyulei | 5dc1f36 | 2017-02-17 14:41:05 -0800 | [diff] [blame] | 116 | /** Formats a double from 0.0..100.0 with an option to round **/ |
| 117 | public static String formatPercentage(double percentage, boolean round) { |
| 118 | final int localPercentage = round ? Math.round((float) percentage) : (int) percentage; |
| 119 | return formatPercentage(localPercentage); |
| 120 | } |
| 121 | |
Jason Monk | c06fbb1 | 2016-01-08 14:12:18 -0500 | [diff] [blame] | 122 | /** Formats the ratio of amount/total as a percentage. */ |
| 123 | public static String formatPercentage(long amount, long total) { |
| 124 | return formatPercentage(((double) amount) / total); |
| 125 | } |
| 126 | |
| 127 | /** Formats an integer from 0..100 as a percentage. */ |
| 128 | public static String formatPercentage(int percentage) { |
| 129 | return formatPercentage(((double) percentage) / 100.0); |
| 130 | } |
| 131 | |
| 132 | /** Formats a double from 0.0..1.0 as a percentage. */ |
Daniel Nishi | 3f94f68 | 2017-06-27 14:38:06 -0700 | [diff] [blame] | 133 | public static String formatPercentage(double percentage) { |
jackqdyulei | 5dc1f36 | 2017-02-17 14:41:05 -0800 | [diff] [blame] | 134 | return NumberFormat.getPercentInstance().format(percentage); |
Jason Monk | c06fbb1 | 2016-01-08 14:12:18 -0500 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | public static int getBatteryLevel(Intent batteryChangedIntent) { |
| 138 | int level = batteryChangedIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0); |
| 139 | int scale = batteryChangedIntent.getIntExtra(BatteryManager.EXTRA_SCALE, 100); |
| 140 | return (level * 100) / scale; |
| 141 | } |
| 142 | |
| 143 | public static String getBatteryStatus(Resources res, Intent batteryChangedIntent) { |
Muyuan Li | 18d2b32 | 2016-03-31 13:53:56 -0700 | [diff] [blame] | 144 | int status = batteryChangedIntent.getIntExtra(BatteryManager.EXTRA_STATUS, |
Jason Monk | c06fbb1 | 2016-01-08 14:12:18 -0500 | [diff] [blame] | 145 | BatteryManager.BATTERY_STATUS_UNKNOWN); |
| 146 | String statusString; |
| 147 | if (status == BatteryManager.BATTERY_STATUS_CHARGING) { |
jackqdyulei | 806f78d | 2017-03-24 12:13:49 -0700 | [diff] [blame] | 148 | statusString = res.getString(R.string.battery_info_status_charging); |
Jason Monk | c06fbb1 | 2016-01-08 14:12:18 -0500 | [diff] [blame] | 149 | } else if (status == BatteryManager.BATTERY_STATUS_DISCHARGING) { |
| 150 | statusString = res.getString(R.string.battery_info_status_discharging); |
| 151 | } else if (status == BatteryManager.BATTERY_STATUS_NOT_CHARGING) { |
| 152 | statusString = res.getString(R.string.battery_info_status_not_charging); |
| 153 | } else if (status == BatteryManager.BATTERY_STATUS_FULL) { |
| 154 | statusString = res.getString(R.string.battery_info_status_full); |
| 155 | } else { |
| 156 | statusString = res.getString(R.string.battery_info_status_unknown); |
| 157 | } |
| 158 | |
| 159 | return statusString; |
| 160 | } |
Julia Reynolds | 21c3054 | 2016-01-15 15:00:02 -0500 | [diff] [blame] | 161 | |
Andrew Sapperstein | 5c37344 | 2016-06-12 13:17:16 -0700 | [diff] [blame] | 162 | @ColorInt |
| 163 | public static int getColorAccent(Context context) { |
Jason Monk | 3250885 | 2017-01-18 09:17:13 -0500 | [diff] [blame] | 164 | return getColorAttr(context, android.R.attr.colorAccent); |
Andrew Sapperstein | 5c37344 | 2016-06-12 13:17:16 -0700 | [diff] [blame] | 165 | } |
| 166 | |
jackqdyulei | b68fd7a | 2017-01-04 15:43:26 -0800 | [diff] [blame] | 167 | @ColorInt |
| 168 | public static int getColorError(Context context) { |
Jason Monk | 58be7a6 | 2017-02-01 20:17:51 -0500 | [diff] [blame] | 169 | return getColorAttr(context, android.R.attr.colorError); |
jackqdyulei | b68fd7a | 2017-01-04 15:43:26 -0800 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | @ColorInt |
| 173 | public static int getDefaultColor(Context context, int resId) { |
| 174 | final ColorStateList list = |
| 175 | context.getResources().getColorStateList(resId, context.getTheme()); |
| 176 | |
| 177 | return list.getDefaultColor(); |
| 178 | } |
| 179 | |
Jason Monk | 3250885 | 2017-01-18 09:17:13 -0500 | [diff] [blame] | 180 | @ColorInt |
| 181 | public static int getDisabled(Context context, int inputColor) { |
| 182 | return applyAlphaAttr(context, android.R.attr.disabledAlpha, inputColor); |
| 183 | } |
| 184 | |
| 185 | @ColorInt |
| 186 | public static int applyAlphaAttr(Context context, int attr, int inputColor) { |
| 187 | TypedArray ta = context.obtainStyledAttributes(new int[]{attr}); |
| 188 | float alpha = ta.getFloat(0, 0); |
| 189 | ta.recycle(); |
Jason Monk | 824ffff | 2017-04-11 15:49:06 -0400 | [diff] [blame] | 190 | return applyAlpha(alpha, inputColor); |
| 191 | } |
| 192 | |
| 193 | @ColorInt |
| 194 | public static int applyAlpha(float alpha, int inputColor) { |
Jason Monk | 3250885 | 2017-01-18 09:17:13 -0500 | [diff] [blame] | 195 | alpha *= Color.alpha(inputColor); |
| 196 | return Color.argb((int) (alpha), Color.red(inputColor), Color.green(inputColor), |
| 197 | Color.blue(inputColor)); |
| 198 | } |
| 199 | |
| 200 | @ColorInt |
| 201 | public static int getColorAttr(Context context, int attr) { |
| 202 | TypedArray ta = context.obtainStyledAttributes(new int[]{attr}); |
| 203 | @ColorInt int colorAccent = ta.getColor(0, 0); |
| 204 | ta.recycle(); |
| 205 | return colorAccent; |
| 206 | } |
| 207 | |
Jason Monk | 9a376bc | 2017-05-10 09:52:10 -0400 | [diff] [blame] | 208 | public static int getThemeAttr(Context context, int attr) { |
| 209 | TypedArray ta = context.obtainStyledAttributes(new int[]{attr}); |
| 210 | int theme = ta.getResourceId(0, 0); |
| 211 | ta.recycle(); |
| 212 | return theme; |
| 213 | } |
| 214 | |
Jason Monk | 790442e | 2017-02-13 17:49:39 -0500 | [diff] [blame] | 215 | public static Drawable getDrawable(Context context, int attr) { |
| 216 | TypedArray ta = context.obtainStyledAttributes(new int[]{attr}); |
| 217 | Drawable drawable = ta.getDrawable(0); |
| 218 | ta.recycle(); |
| 219 | return drawable; |
| 220 | } |
| 221 | |
Julia Reynolds | 21c3054 | 2016-01-15 15:00:02 -0500 | [diff] [blame] | 222 | /** |
| 223 | * Determine whether a package is a "system package", in which case certain things (like |
| 224 | * disabling notifications or disabling the package altogether) should be disallowed. |
| 225 | */ |
Tony Mak | bfba9d4 | 2016-07-14 15:29:44 +0800 | [diff] [blame] | 226 | public static boolean isSystemPackage(Resources resources, PackageManager pm, PackageInfo pkg) { |
Julia Reynolds | 21c3054 | 2016-01-15 15:00:02 -0500 | [diff] [blame] | 227 | if (sSystemSignature == null) { |
| 228 | sSystemSignature = new Signature[]{ getSystemSignature(pm) }; |
| 229 | } |
Svet Ganov | 81fb0d4 | 2016-03-04 09:27:23 -0800 | [diff] [blame] | 230 | if (sPermissionControllerPackageName == null) { |
| 231 | sPermissionControllerPackageName = pm.getPermissionControllerPackageName(); |
| 232 | } |
Svetoslav Ganov | a9c2500 | 2016-04-13 19:25:56 -0700 | [diff] [blame] | 233 | if (sServicesSystemSharedLibPackageName == null) { |
| 234 | sServicesSystemSharedLibPackageName = pm.getServicesSystemSharedLibraryPackageName(); |
| 235 | } |
| 236 | if (sSharedSystemSharedLibPackageName == null) { |
| 237 | sSharedSystemSharedLibPackageName = pm.getSharedSystemSharedLibraryPackageName(); |
| 238 | } |
Svet Ganov | 81fb0d4 | 2016-03-04 09:27:23 -0800 | [diff] [blame] | 239 | return (sSystemSignature[0] != null |
| 240 | && sSystemSignature[0].equals(getFirstSignature(pkg))) |
Svetoslav Ganov | a9c2500 | 2016-04-13 19:25:56 -0700 | [diff] [blame] | 241 | || pkg.packageName.equals(sPermissionControllerPackageName) |
| 242 | || pkg.packageName.equals(sServicesSystemSharedLibPackageName) |
Philip P. Moltmann | 545a58a | 2016-06-28 14:14:06 -0700 | [diff] [blame] | 243 | || pkg.packageName.equals(sSharedSystemSharedLibPackageName) |
Tony Mak | bfba9d4 | 2016-07-14 15:29:44 +0800 | [diff] [blame] | 244 | || pkg.packageName.equals(PrintManager.PRINT_SPOOLER_PACKAGE_NAME) |
| 245 | || isDeviceProvisioningPackage(resources, pkg.packageName); |
Julia Reynolds | 21c3054 | 2016-01-15 15:00:02 -0500 | [diff] [blame] | 246 | } |
| 247 | |
Julia Reynolds | 21c3054 | 2016-01-15 15:00:02 -0500 | [diff] [blame] | 248 | private static Signature getFirstSignature(PackageInfo pkg) { |
| 249 | if (pkg != null && pkg.signatures != null && pkg.signatures.length > 0) { |
| 250 | return pkg.signatures[0]; |
| 251 | } |
| 252 | return null; |
| 253 | } |
| 254 | |
| 255 | private static Signature getSystemSignature(PackageManager pm) { |
| 256 | try { |
| 257 | final PackageInfo sys = pm.getPackageInfo("android", PackageManager.GET_SIGNATURES); |
| 258 | return getFirstSignature(sys); |
| 259 | } catch (NameNotFoundException e) { |
| 260 | } |
| 261 | return null; |
| 262 | } |
Tony Mak | bfba9d4 | 2016-07-14 15:29:44 +0800 | [diff] [blame] | 263 | |
| 264 | /** |
| 265 | * Returns {@code true} if the supplied package is the device provisioning app. Otherwise, |
| 266 | * returns {@code false}. |
| 267 | */ |
| 268 | public static boolean isDeviceProvisioningPackage(Resources resources, String packageName) { |
| 269 | String deviceProvisioningPackage = resources.getString( |
| 270 | com.android.internal.R.string.config_deviceProvisioningPackage); |
| 271 | return deviceProvisioningPackage != null && deviceProvisioningPackage.equals(packageName); |
| 272 | } |
Sundeep Ghuman | f84e057 | 2017-01-10 13:43:03 -0800 | [diff] [blame] | 273 | |
| 274 | /** |
| 275 | * Returns a badged Wifi icon drawable. |
| 276 | * |
| 277 | * <p>The first layer contains the Wifi pie and the second layer contains the badge. Callers |
| 278 | * should set the drawable to the appropriate size and tint color. |
| 279 | * |
| 280 | * @param context The caller's context (must have access to internal resources) |
| 281 | * @param level The number of bars to show (0-4) |
| 282 | * @param badge The badge enum {@see android.net.ScoredNetwork} |
| 283 | * |
| 284 | * @throws IllegalArgumentException if an invalid badge enum is given |
| 285 | * |
| 286 | * @deprecated TODO(sghuman): Finalize the form of this method and then move it to a new |
| 287 | * location. |
| 288 | */ |
| 289 | public static LayerDrawable getBadgedWifiIcon(Context context, int level, int badge) { |
| 290 | return new LayerDrawable( |
| 291 | new Drawable[] { |
| 292 | context.getDrawable(WIFI_PIE_FOR_BADGING[level]), |
| 293 | context.getDrawable(getWifiBadgeResource(badge)) |
| 294 | }); |
| 295 | } |
| 296 | |
Sundeep Ghuman | 9d10a3c | 2017-06-16 00:05:16 +0000 | [diff] [blame] | 297 | private static int getWifiBadgeResource(int badge) { |
Sundeep Ghuman | f84e057 | 2017-01-10 13:43:03 -0800 | [diff] [blame] | 298 | switch (badge) { |
Sundeep Ghuman | 699deaf | 2017-02-13 15:32:13 -0800 | [diff] [blame] | 299 | case NetworkBadging.BADGING_NONE: |
Sundeep Ghuman | d57f324 | 2017-01-13 15:31:48 -0800 | [diff] [blame] | 300 | return View.NO_ID; |
Sundeep Ghuman | 699deaf | 2017-02-13 15:32:13 -0800 | [diff] [blame] | 301 | case NetworkBadging.BADGING_SD: |
Sundeep Ghuman | f84e057 | 2017-01-10 13:43:03 -0800 | [diff] [blame] | 302 | return com.android.internal.R.drawable.ic_signal_wifi_badged_sd; |
Sundeep Ghuman | 699deaf | 2017-02-13 15:32:13 -0800 | [diff] [blame] | 303 | case NetworkBadging.BADGING_HD: |
Sundeep Ghuman | f84e057 | 2017-01-10 13:43:03 -0800 | [diff] [blame] | 304 | return com.android.internal.R.drawable.ic_signal_wifi_badged_hd; |
Sundeep Ghuman | 699deaf | 2017-02-13 15:32:13 -0800 | [diff] [blame] | 305 | case NetworkBadging.BADGING_4K: |
Sundeep Ghuman | f84e057 | 2017-01-10 13:43:03 -0800 | [diff] [blame] | 306 | return com.android.internal.R.drawable.ic_signal_wifi_badged_4k; |
| 307 | default: |
| 308 | throw new IllegalArgumentException( |
| 309 | "No badge resource found for badge value: " + badge); |
| 310 | } |
| 311 | } |
Daniel Nishi | 5398280 | 2017-05-23 15:54:34 -0700 | [diff] [blame] | 312 | |
| 313 | public static int getDefaultStorageManagerDaysToRetain(Resources resources) { |
| 314 | int defaultDays = Settings.Secure.AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN_DEFAULT; |
| 315 | try { |
| 316 | defaultDays = |
| 317 | resources.getInteger( |
| 318 | com.android |
| 319 | .internal |
| 320 | .R |
| 321 | .integer |
| 322 | .config_storageManagerDaystoRetainDefault); |
| 323 | } catch (Resources.NotFoundException e) { |
| 324 | // We are likely in a test environment. |
| 325 | } |
| 326 | return defaultDays; |
| 327 | } |
Wei Liu | 30275c1 | 2015-08-24 17:35:49 -0700 | [diff] [blame] | 328 | } |