Dan Egnor | 621bc54 | 2010-03-25 16:20:14 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.server; |
| 18 | |
| 19 | import android.content.Context; |
| 20 | import android.os.Binder; |
| 21 | import android.os.Environment; |
Michael Wachenschwanz | 3e20a10 | 2017-12-14 18:32:14 -0800 | [diff] [blame] | 22 | import android.os.IBinder; |
| 23 | import android.os.IStoraged; |
| 24 | import android.os.RemoteException; |
| 25 | import android.os.ServiceManager; |
Dan Egnor | 621bc54 | 2010-03-25 16:20:14 -0700 | [diff] [blame] | 26 | import android.os.StatFs; |
| 27 | import android.os.SystemClock; |
Jeff Sharkey | b92b05b | 2016-01-28 09:50:00 -0700 | [diff] [blame] | 28 | import android.os.storage.StorageManager; |
Amith Yamasani | 38f91ff | 2017-01-10 14:42:38 -0800 | [diff] [blame] | 29 | import android.service.diskstats.DiskStatsAppSizesProto; |
| 30 | import android.service.diskstats.DiskStatsCachedValuesProto; |
| 31 | import android.service.diskstats.DiskStatsFreeSpaceProto; |
| 32 | import android.service.diskstats.DiskStatsServiceDumpProto; |
Daniel Nishi | 090b2d9 | 2016-12-13 10:38:42 -0800 | [diff] [blame] | 33 | import android.util.Log; |
Amith Yamasani | 38f91ff | 2017-01-10 14:42:38 -0800 | [diff] [blame] | 34 | import android.util.Slog; |
| 35 | import android.util.proto.ProtoOutputStream; |
Daniel Nishi | 090b2d9 | 2016-12-13 10:38:42 -0800 | [diff] [blame] | 36 | |
Jeff Sharkey | fe9a53b | 2017-03-31 14:08:23 -0600 | [diff] [blame] | 37 | import com.android.internal.util.DumpUtils; |
Daniel Nishi | 090b2d9 | 2016-12-13 10:38:42 -0800 | [diff] [blame] | 38 | import com.android.server.storage.DiskStatsFileLogger; |
| 39 | import com.android.server.storage.DiskStatsLoggingService; |
| 40 | |
| 41 | import libcore.io.IoUtils; |
| 42 | |
Amith Yamasani | 38f91ff | 2017-01-10 14:42:38 -0800 | [diff] [blame] | 43 | import org.json.JSONArray; |
Daniel Nishi | 090b2d9 | 2016-12-13 10:38:42 -0800 | [diff] [blame] | 44 | import org.json.JSONException; |
| 45 | import org.json.JSONObject; |
Dan Egnor | 621bc54 | 2010-03-25 16:20:14 -0700 | [diff] [blame] | 46 | |
| 47 | import java.io.File; |
| 48 | import java.io.FileDescriptor; |
| 49 | import java.io.FileOutputStream; |
| 50 | import java.io.IOException; |
| 51 | import java.io.PrintWriter; |
| 52 | |
| 53 | /** |
| 54 | * This service exists only as a "dumpsys" target which reports |
| 55 | * statistics about the status of the disk. |
| 56 | */ |
| 57 | public class DiskStatsService extends Binder { |
Jeff Sharkey | eb4cc492 | 2012-04-26 18:17:29 -0700 | [diff] [blame] | 58 | private static final String TAG = "DiskStatsService"; |
Daniel Nishi | 090b2d9 | 2016-12-13 10:38:42 -0800 | [diff] [blame] | 59 | private static final String DISKSTATS_DUMP_FILE = "/data/system/diskstats_cache.json"; |
Jeff Sharkey | eb4cc492 | 2012-04-26 18:17:29 -0700 | [diff] [blame] | 60 | |
Dan Egnor | 621bc54 | 2010-03-25 16:20:14 -0700 | [diff] [blame] | 61 | private final Context mContext; |
| 62 | |
| 63 | public DiskStatsService(Context context) { |
| 64 | mContext = context; |
Daniel Nishi | 090b2d9 | 2016-12-13 10:38:42 -0800 | [diff] [blame] | 65 | DiskStatsLoggingService.schedule(context); |
Dan Egnor | 621bc54 | 2010-03-25 16:20:14 -0700 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | @Override |
| 69 | protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
Jeff Sharkey | 6df866a | 2017-03-31 14:08:23 -0600 | [diff] [blame] | 70 | if (!DumpUtils.checkDumpAndUsageStatsPermission(mContext, TAG, pw)) return; |
Dan Egnor | 621bc54 | 2010-03-25 16:20:14 -0700 | [diff] [blame] | 71 | |
| 72 | // Run a quick-and-dirty performance test: write 512 bytes |
| 73 | byte[] junk = new byte[512]; |
| 74 | for (int i = 0; i < junk.length; i++) junk[i] = (byte) i; // Write nonzero bytes |
| 75 | |
| 76 | File tmp = new File(Environment.getDataDirectory(), "system/perftest.tmp"); |
| 77 | FileOutputStream fos = null; |
| 78 | IOException error = null; |
| 79 | |
| 80 | long before = SystemClock.uptimeMillis(); |
| 81 | try { |
| 82 | fos = new FileOutputStream(tmp); |
| 83 | fos.write(junk); |
| 84 | } catch (IOException e) { |
| 85 | error = e; |
| 86 | } finally { |
| 87 | try { if (fos != null) fos.close(); } catch (IOException e) {} |
| 88 | } |
| 89 | |
| 90 | long after = SystemClock.uptimeMillis(); |
| 91 | if (tmp.exists()) tmp.delete(); |
| 92 | |
Amith Yamasani | 38f91ff | 2017-01-10 14:42:38 -0800 | [diff] [blame] | 93 | boolean protoFormat = hasOption(args, "--proto"); |
| 94 | ProtoOutputStream proto = null; |
| 95 | |
| 96 | if (protoFormat) { |
| 97 | proto = new ProtoOutputStream(fd); |
| 98 | pw = null; |
| 99 | proto.write(DiskStatsServiceDumpProto.HAS_TEST_ERROR, error != null); |
| 100 | if (error != null) { |
| 101 | proto.write(DiskStatsServiceDumpProto.ERROR_MESSAGE, error.toString()); |
| 102 | } else { |
| 103 | proto.write(DiskStatsServiceDumpProto.WRITE_512B_LATENCY_MILLIS, after - before); |
| 104 | } |
Dan Egnor | 621bc54 | 2010-03-25 16:20:14 -0700 | [diff] [blame] | 105 | } else { |
Amith Yamasani | 38f91ff | 2017-01-10 14:42:38 -0800 | [diff] [blame] | 106 | if (error != null) { |
| 107 | pw.print("Test-Error: "); |
| 108 | pw.println(error.toString()); |
| 109 | } else { |
| 110 | pw.print("Latency: "); |
| 111 | pw.print(after - before); |
| 112 | pw.println("ms [512B Data Write]"); |
| 113 | } |
Dan Egnor | 621bc54 | 2010-03-25 16:20:14 -0700 | [diff] [blame] | 114 | } |
| 115 | |
Michael Wachenschwanz | 3e20a10 | 2017-12-14 18:32:14 -0800 | [diff] [blame] | 116 | if (protoFormat) { |
| 117 | reportDiskWriteSpeedProto(proto); |
| 118 | } else { |
| 119 | reportDiskWriteSpeed(pw); |
| 120 | } |
| 121 | |
Amith Yamasani | 38f91ff | 2017-01-10 14:42:38 -0800 | [diff] [blame] | 122 | reportFreeSpace(Environment.getDataDirectory(), "Data", pw, proto, |
| 123 | DiskStatsFreeSpaceProto.FOLDER_DATA); |
| 124 | reportFreeSpace(Environment.getDownloadCacheDirectory(), "Cache", pw, proto, |
| 125 | DiskStatsFreeSpaceProto.FOLDER_CACHE); |
| 126 | reportFreeSpace(new File("/system"), "System", pw, proto, |
| 127 | DiskStatsFreeSpaceProto.FOLDER_SYSTEM); |
Dan Egnor | 621bc54 | 2010-03-25 16:20:14 -0700 | [diff] [blame] | 128 | |
Amith Yamasani | 38f91ff | 2017-01-10 14:42:38 -0800 | [diff] [blame] | 129 | boolean fileBased = StorageManager.isFileEncryptedNativeOnly(); |
| 130 | boolean blockBased = fileBased ? false : StorageManager.isBlockEncrypted(); |
| 131 | if (protoFormat) { |
| 132 | if (fileBased) { |
| 133 | proto.write(DiskStatsServiceDumpProto.ENCRYPTION, |
| 134 | DiskStatsServiceDumpProto.ENCRYPTION_FILE_BASED); |
| 135 | } else if (blockBased) { |
| 136 | proto.write(DiskStatsServiceDumpProto.ENCRYPTION, |
| 137 | DiskStatsServiceDumpProto.ENCRYPTION_FULL_DISK); |
| 138 | } else { |
| 139 | proto.write(DiskStatsServiceDumpProto.ENCRYPTION, |
| 140 | DiskStatsServiceDumpProto.ENCRYPTION_NONE); |
| 141 | } |
| 142 | } else if (fileBased) { |
Jeff Sharkey | b92b05b | 2016-01-28 09:50:00 -0700 | [diff] [blame] | 143 | pw.println("File-based Encryption: true"); |
| 144 | } |
| 145 | |
Amith Yamasani | 38f91ff | 2017-01-10 14:42:38 -0800 | [diff] [blame] | 146 | if (protoFormat) { |
| 147 | reportCachedValuesProto(proto); |
| 148 | } else { |
| 149 | reportCachedValues(pw); |
| 150 | } |
Daniel Nishi | 090b2d9 | 2016-12-13 10:38:42 -0800 | [diff] [blame] | 151 | |
Amith Yamasani | 38f91ff | 2017-01-10 14:42:38 -0800 | [diff] [blame] | 152 | if (protoFormat) { |
| 153 | proto.flush(); |
| 154 | } |
Dan Egnor | 621bc54 | 2010-03-25 16:20:14 -0700 | [diff] [blame] | 155 | // TODO: Read /proc/yaffs and report interesting values; |
| 156 | // add configurable (through args) performance test parameters. |
| 157 | } |
| 158 | |
Amith Yamasani | 38f91ff | 2017-01-10 14:42:38 -0800 | [diff] [blame] | 159 | private void reportFreeSpace(File path, String name, PrintWriter pw, |
| 160 | ProtoOutputStream proto, int folderType) { |
Dan Egnor | 621bc54 | 2010-03-25 16:20:14 -0700 | [diff] [blame] | 161 | try { |
| 162 | StatFs statfs = new StatFs(path.getPath()); |
| 163 | long bsize = statfs.getBlockSize(); |
| 164 | long avail = statfs.getAvailableBlocks(); |
| 165 | long total = statfs.getBlockCount(); |
| 166 | if (bsize <= 0 || total <= 0) { |
| 167 | throw new IllegalArgumentException( |
| 168 | "Invalid stat: bsize=" + bsize + " avail=" + avail + " total=" + total); |
| 169 | } |
| 170 | |
Amith Yamasani | 38f91ff | 2017-01-10 14:42:38 -0800 | [diff] [blame] | 171 | if (proto != null) { |
| 172 | long freeSpaceToken = proto.start(DiskStatsServiceDumpProto.PARTITIONS_FREE_SPACE); |
| 173 | proto.write(DiskStatsFreeSpaceProto.FOLDER, folderType); |
Kweku Adams | e7d2f0e | 2018-03-15 11:29:42 -0700 | [diff] [blame] | 174 | proto.write(DiskStatsFreeSpaceProto.AVAILABLE_SPACE_KB, avail * bsize / 1024); |
| 175 | proto.write(DiskStatsFreeSpaceProto.TOTAL_SPACE_KB, total * bsize / 1024); |
Amith Yamasani | 38f91ff | 2017-01-10 14:42:38 -0800 | [diff] [blame] | 176 | proto.end(freeSpaceToken); |
| 177 | } else { |
| 178 | pw.print(name); |
| 179 | pw.print("-Free: "); |
| 180 | pw.print(avail * bsize / 1024); |
| 181 | pw.print("K / "); |
| 182 | pw.print(total * bsize / 1024); |
| 183 | pw.print("K total = "); |
| 184 | pw.print(avail * 100 / total); |
| 185 | pw.println("% free"); |
| 186 | } |
Dan Egnor | 621bc54 | 2010-03-25 16:20:14 -0700 | [diff] [blame] | 187 | } catch (IllegalArgumentException e) { |
Amith Yamasani | 38f91ff | 2017-01-10 14:42:38 -0800 | [diff] [blame] | 188 | if (proto != null) { |
| 189 | // Empty proto |
| 190 | } else { |
| 191 | pw.print(name); |
| 192 | pw.print("-Error: "); |
| 193 | pw.println(e.toString()); |
| 194 | } |
Dan Egnor | 621bc54 | 2010-03-25 16:20:14 -0700 | [diff] [blame] | 195 | return; |
| 196 | } |
| 197 | } |
Daniel Nishi | 090b2d9 | 2016-12-13 10:38:42 -0800 | [diff] [blame] | 198 | |
Amith Yamasani | 38f91ff | 2017-01-10 14:42:38 -0800 | [diff] [blame] | 199 | private boolean hasOption(String[] args, String arg) { |
| 200 | for (String opt : args) { |
| 201 | if (arg.equals(opt)) { |
| 202 | return true; |
| 203 | } |
| 204 | } |
| 205 | return false; |
| 206 | } |
| 207 | |
| 208 | // If you change this method, make sure to modify the Proto version of this method as well. |
Daniel Nishi | 090b2d9 | 2016-12-13 10:38:42 -0800 | [diff] [blame] | 209 | private void reportCachedValues(PrintWriter pw) { |
| 210 | try { |
| 211 | String jsonString = IoUtils.readFileAsString(DISKSTATS_DUMP_FILE); |
| 212 | JSONObject json = new JSONObject(jsonString); |
| 213 | pw.print("App Size: "); |
| 214 | pw.println(json.getLong(DiskStatsFileLogger.APP_SIZE_AGG_KEY)); |
Daniel Nishi | b6cc838 | 2017-09-14 17:10:00 -0700 | [diff] [blame] | 215 | pw.print("App Data Size: "); |
| 216 | pw.println(json.getLong(DiskStatsFileLogger.APP_DATA_SIZE_AGG_KEY)); |
Daniel Nishi | 090b2d9 | 2016-12-13 10:38:42 -0800 | [diff] [blame] | 217 | pw.print("App Cache Size: "); |
| 218 | pw.println(json.getLong(DiskStatsFileLogger.APP_CACHE_AGG_KEY)); |
| 219 | pw.print("Photos Size: "); |
| 220 | pw.println(json.getLong(DiskStatsFileLogger.PHOTOS_KEY)); |
| 221 | pw.print("Videos Size: "); |
| 222 | pw.println(json.getLong(DiskStatsFileLogger.VIDEOS_KEY)); |
| 223 | pw.print("Audio Size: "); |
| 224 | pw.println(json.getLong(DiskStatsFileLogger.AUDIO_KEY)); |
| 225 | pw.print("Downloads Size: "); |
| 226 | pw.println(json.getLong(DiskStatsFileLogger.DOWNLOADS_KEY)); |
| 227 | pw.print("System Size: "); |
| 228 | pw.println(json.getLong(DiskStatsFileLogger.SYSTEM_KEY)); |
| 229 | pw.print("Other Size: "); |
| 230 | pw.println(json.getLong(DiskStatsFileLogger.MISC_KEY)); |
| 231 | pw.print("Package Names: "); |
| 232 | pw.println(json.getJSONArray(DiskStatsFileLogger.PACKAGE_NAMES_KEY)); |
| 233 | pw.print("App Sizes: "); |
| 234 | pw.println(json.getJSONArray(DiskStatsFileLogger.APP_SIZES_KEY)); |
Daniel Nishi | b6cc838 | 2017-09-14 17:10:00 -0700 | [diff] [blame] | 235 | pw.print("App Data Sizes: "); |
| 236 | pw.println(json.getJSONArray(DiskStatsFileLogger.APP_DATA_KEY)); |
Daniel Nishi | 090b2d9 | 2016-12-13 10:38:42 -0800 | [diff] [blame] | 237 | pw.print("Cache Sizes: "); |
| 238 | pw.println(json.getJSONArray(DiskStatsFileLogger.APP_CACHES_KEY)); |
| 239 | } catch (IOException | JSONException e) { |
| 240 | Log.w(TAG, "exception reading diskstats cache file", e); |
| 241 | } |
| 242 | } |
| 243 | |
Amith Yamasani | 38f91ff | 2017-01-10 14:42:38 -0800 | [diff] [blame] | 244 | private void reportCachedValuesProto(ProtoOutputStream proto) { |
| 245 | try { |
| 246 | String jsonString = IoUtils.readFileAsString(DISKSTATS_DUMP_FILE); |
| 247 | JSONObject json = new JSONObject(jsonString); |
| 248 | long cachedValuesToken = proto.start(DiskStatsServiceDumpProto.CACHED_FOLDER_SIZES); |
| 249 | |
Kweku Adams | e7d2f0e | 2018-03-15 11:29:42 -0700 | [diff] [blame] | 250 | proto.write(DiskStatsCachedValuesProto.AGG_APPS_SIZE_KB, |
Amith Yamasani | 38f91ff | 2017-01-10 14:42:38 -0800 | [diff] [blame] | 251 | json.getLong(DiskStatsFileLogger.APP_SIZE_AGG_KEY)); |
Kweku Adams | e7d2f0e | 2018-03-15 11:29:42 -0700 | [diff] [blame] | 252 | proto.write(DiskStatsCachedValuesProto.AGG_APPS_DATA_SIZE_KB, |
Daniel Nishi | b6cc838 | 2017-09-14 17:10:00 -0700 | [diff] [blame] | 253 | json.getLong(DiskStatsFileLogger.APP_DATA_SIZE_AGG_KEY)); |
Kweku Adams | e7d2f0e | 2018-03-15 11:29:42 -0700 | [diff] [blame] | 254 | proto.write(DiskStatsCachedValuesProto.AGG_APPS_CACHE_SIZE_KB, |
Amith Yamasani | 38f91ff | 2017-01-10 14:42:38 -0800 | [diff] [blame] | 255 | json.getLong(DiskStatsFileLogger.APP_CACHE_AGG_KEY)); |
Kweku Adams | e7d2f0e | 2018-03-15 11:29:42 -0700 | [diff] [blame] | 256 | proto.write(DiskStatsCachedValuesProto.PHOTOS_SIZE_KB, |
Amith Yamasani | 38f91ff | 2017-01-10 14:42:38 -0800 | [diff] [blame] | 257 | json.getLong(DiskStatsFileLogger.PHOTOS_KEY)); |
Kweku Adams | e7d2f0e | 2018-03-15 11:29:42 -0700 | [diff] [blame] | 258 | proto.write(DiskStatsCachedValuesProto.VIDEOS_SIZE_KB, |
Amith Yamasani | 38f91ff | 2017-01-10 14:42:38 -0800 | [diff] [blame] | 259 | json.getLong(DiskStatsFileLogger.VIDEOS_KEY)); |
Kweku Adams | e7d2f0e | 2018-03-15 11:29:42 -0700 | [diff] [blame] | 260 | proto.write(DiskStatsCachedValuesProto.AUDIO_SIZE_KB, |
Amith Yamasani | 38f91ff | 2017-01-10 14:42:38 -0800 | [diff] [blame] | 261 | json.getLong(DiskStatsFileLogger.AUDIO_KEY)); |
Kweku Adams | e7d2f0e | 2018-03-15 11:29:42 -0700 | [diff] [blame] | 262 | proto.write(DiskStatsCachedValuesProto.DOWNLOADS_SIZE_KB, |
Amith Yamasani | 38f91ff | 2017-01-10 14:42:38 -0800 | [diff] [blame] | 263 | json.getLong(DiskStatsFileLogger.DOWNLOADS_KEY)); |
Kweku Adams | e7d2f0e | 2018-03-15 11:29:42 -0700 | [diff] [blame] | 264 | proto.write(DiskStatsCachedValuesProto.SYSTEM_SIZE_KB, |
Amith Yamasani | 38f91ff | 2017-01-10 14:42:38 -0800 | [diff] [blame] | 265 | json.getLong(DiskStatsFileLogger.SYSTEM_KEY)); |
Kweku Adams | e7d2f0e | 2018-03-15 11:29:42 -0700 | [diff] [blame] | 266 | proto.write(DiskStatsCachedValuesProto.OTHER_SIZE_KB, |
Amith Yamasani | 38f91ff | 2017-01-10 14:42:38 -0800 | [diff] [blame] | 267 | json.getLong(DiskStatsFileLogger.MISC_KEY)); |
| 268 | |
| 269 | JSONArray packageNamesArray = json.getJSONArray(DiskStatsFileLogger.PACKAGE_NAMES_KEY); |
| 270 | JSONArray appSizesArray = json.getJSONArray(DiskStatsFileLogger.APP_SIZES_KEY); |
Daniel Nishi | b6cc838 | 2017-09-14 17:10:00 -0700 | [diff] [blame] | 271 | JSONArray appDataSizesArray = json.getJSONArray(DiskStatsFileLogger.APP_DATA_KEY); |
Amith Yamasani | 38f91ff | 2017-01-10 14:42:38 -0800 | [diff] [blame] | 272 | JSONArray cacheSizesArray = json.getJSONArray(DiskStatsFileLogger.APP_CACHES_KEY); |
| 273 | final int len = packageNamesArray.length(); |
Daniel Nishi | b6cc838 | 2017-09-14 17:10:00 -0700 | [diff] [blame] | 274 | if (len == appSizesArray.length() |
| 275 | && len == appDataSizesArray.length() |
| 276 | && len == cacheSizesArray.length()) { |
Amith Yamasani | 38f91ff | 2017-01-10 14:42:38 -0800 | [diff] [blame] | 277 | for (int i = 0; i < len; i++) { |
| 278 | long packageToken = proto.start(DiskStatsCachedValuesProto.APP_SIZES); |
| 279 | |
| 280 | proto.write(DiskStatsAppSizesProto.PACKAGE_NAME, |
| 281 | packageNamesArray.getString(i)); |
Kweku Adams | e7d2f0e | 2018-03-15 11:29:42 -0700 | [diff] [blame] | 282 | proto.write(DiskStatsAppSizesProto.APP_SIZE_KB, appSizesArray.getLong(i)); |
| 283 | proto.write(DiskStatsAppSizesProto.APP_DATA_SIZE_KB, appDataSizesArray.getLong(i)); |
| 284 | proto.write(DiskStatsAppSizesProto.CACHE_SIZE_KB, cacheSizesArray.getLong(i)); |
Amith Yamasani | 38f91ff | 2017-01-10 14:42:38 -0800 | [diff] [blame] | 285 | |
| 286 | proto.end(packageToken); |
| 287 | } |
| 288 | } else { |
Daniel Nishi | b6cc838 | 2017-09-14 17:10:00 -0700 | [diff] [blame] | 289 | Slog.wtf(TAG, "Sizes of packageNamesArray, appSizesArray, appDataSizesArray " |
| 290 | + " and cacheSizesArray are not the same"); |
Amith Yamasani | 38f91ff | 2017-01-10 14:42:38 -0800 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | proto.end(cachedValuesToken); |
| 294 | } catch (IOException | JSONException e) { |
| 295 | Log.w(TAG, "exception reading diskstats cache file", e); |
| 296 | } |
| 297 | } |
Michael Wachenschwanz | 3e20a10 | 2017-12-14 18:32:14 -0800 | [diff] [blame] | 298 | |
| 299 | private int getRecentPerf() throws RemoteException, IllegalStateException { |
| 300 | IBinder binder = ServiceManager.getService("storaged"); |
| 301 | if (binder == null) throw new IllegalStateException("storaged not found"); |
| 302 | IStoraged storaged = IStoraged.Stub.asInterface(binder); |
| 303 | return storaged.getRecentPerf(); |
| 304 | } |
| 305 | |
| 306 | // Keep reportDiskWriteSpeed and reportDiskWriteSpeedProto in sync |
| 307 | private void reportDiskWriteSpeed(PrintWriter pw) { |
| 308 | try { |
| 309 | long perf = getRecentPerf(); |
| 310 | if (perf != 0) { |
| 311 | pw.print("Recent Disk Write Speed (kB/s) = "); |
| 312 | pw.println(perf); |
| 313 | } else { |
| 314 | pw.println("Recent Disk Write Speed data unavailable"); |
| 315 | Log.w(TAG, "Recent Disk Write Speed data unavailable!"); |
| 316 | } |
| 317 | } catch (RemoteException | IllegalStateException e) { |
| 318 | pw.println(e.toString()); |
| 319 | Log.e(TAG, e.toString()); |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | private void reportDiskWriteSpeedProto(ProtoOutputStream proto) { |
| 324 | try { |
| 325 | long perf = getRecentPerf(); |
| 326 | if (perf != 0) { |
| 327 | proto.write(DiskStatsServiceDumpProto.BENCHMARKED_WRITE_SPEED_KBPS, perf); |
| 328 | } else { |
| 329 | Log.w(TAG, "Recent Disk Write Speed data unavailable!"); |
| 330 | } |
| 331 | } catch (RemoteException | IllegalStateException e) { |
| 332 | Log.e(TAG, e.toString()); |
| 333 | } |
| 334 | } |
Dan Egnor | 621bc54 | 2010-03-25 16:20:14 -0700 | [diff] [blame] | 335 | } |