The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 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.smoketest; |
| 18 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 19 | import android.app.ActivityManager; |
Omari Stephens | 9f5a511 | 2012-01-18 22:36:42 -0800 | [diff] [blame] | 20 | import android.app.ActivityManager.ProcessErrorStateInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 21 | import android.content.Context; |
Omari Stephens | 9f5a511 | 2012-01-18 22:36:42 -0800 | [diff] [blame] | 22 | import android.content.ComponentName; |
| 23 | import android.content.Intent; |
| 24 | import android.content.pm.PackageManager; |
| 25 | import android.content.pm.ResolveInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | import android.test.AndroidTestCase; |
| 27 | import android.util.Log; |
| 28 | |
Omari Stephens | 9f5a511 | 2012-01-18 22:36:42 -0800 | [diff] [blame] | 29 | import java.util.ArrayList; |
| 30 | import java.util.Collection; |
Omari Stephens | a6a3536 | 2012-04-25 21:07:57 -0700 | [diff] [blame] | 31 | import java.util.Collections; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | import java.util.Iterator; |
Omari Stephens | a6a3536 | 2012-04-25 21:07:57 -0700 | [diff] [blame] | 33 | import java.util.LinkedHashSet; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | import java.util.List; |
Omari Stephens | 9f5a511 | 2012-01-18 22:36:42 -0800 | [diff] [blame] | 35 | import java.util.Set; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | |
| 37 | /** |
Omari Stephens | a6a3536 | 2012-04-25 21:07:57 -0700 | [diff] [blame] | 38 | * This smoke test is designed to check for crashes and ANRs in an attempt to quickly determine if |
| 39 | * all minimal functionality in the build is working properly. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 40 | */ |
| 41 | public class ProcessErrorsTest extends AndroidTestCase { |
Omari Stephens | a6a3536 | 2012-04-25 21:07:57 -0700 | [diff] [blame] | 42 | |
Omari Stephens | 9f5a511 | 2012-01-18 22:36:42 -0800 | [diff] [blame] | 43 | private static final String TAG = "ProcessErrorsTest"; |
Omari Stephens | 5ae3dfe | 2012-03-08 18:27:33 -0800 | [diff] [blame] | 44 | |
| 45 | private final Intent mHomeIntent; |
| 46 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 47 | protected ActivityManager mActivityManager; |
Omari Stephens | 9f5a511 | 2012-01-18 22:36:42 -0800 | [diff] [blame] | 48 | protected PackageManager mPackageManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 49 | |
Omari Stephens | a6a3536 | 2012-04-25 21:07:57 -0700 | [diff] [blame] | 50 | /** |
| 51 | * Used to buffer asynchronously-caused crashes and ANRs so that we can have a big fail-party |
| 52 | * in the catch-all testCase. |
| 53 | */ |
| 54 | private static final Collection<ProcessError> mAsyncErrors = |
| 55 | Collections.synchronizedSet(new LinkedHashSet<ProcessError>()); |
| 56 | |
Omari Stephens | 5ae3dfe | 2012-03-08 18:27:33 -0800 | [diff] [blame] | 57 | public ProcessErrorsTest() { |
| 58 | mHomeIntent = new Intent(Intent.ACTION_MAIN); |
| 59 | mHomeIntent.addCategory(Intent.CATEGORY_HOME); |
| 60 | mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 61 | } |
| 62 | |
Omari Stephens | a6a3536 | 2012-04-25 21:07:57 -0700 | [diff] [blame] | 63 | /** |
| 64 | * {@inheritDoc} |
| 65 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 66 | @Override |
| 67 | public void setUp() throws Exception { |
| 68 | super.setUp(); |
Omari Stephens | a6a3536 | 2012-04-25 21:07:57 -0700 | [diff] [blame] | 69 | // First, make sure we have a Context |
| 70 | assertNotNull("getContext() returned null!", getContext()); |
| 71 | |
Omari Stephens | 9f5a511 | 2012-01-18 22:36:42 -0800 | [diff] [blame] | 72 | mActivityManager = (ActivityManager) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 73 | getContext().getSystemService(Context.ACTIVITY_SERVICE); |
Omari Stephens | 9f5a511 | 2012-01-18 22:36:42 -0800 | [diff] [blame] | 74 | mPackageManager = getContext().getPackageManager(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | public void testSetUpConditions() throws Exception { |
| 78 | assertNotNull(mActivityManager); |
Omari Stephens | 9f5a511 | 2012-01-18 22:36:42 -0800 | [diff] [blame] | 79 | assertNotNull(mPackageManager); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 80 | } |
| 81 | |
Omari Stephens | 5ae3dfe | 2012-03-08 18:27:33 -0800 | [diff] [blame] | 82 | public void testNoProcessErrorsAfterBoot() throws Exception { |
Omari Stephens | 9f5a511 | 2012-01-18 22:36:42 -0800 | [diff] [blame] | 83 | final String reportMsg = checkForProcessErrors(); |
| 84 | if (reportMsg != null) { |
| 85 | Log.w(TAG, reportMsg); |
| 86 | } |
| 87 | |
| 88 | // report a non-empty list back to the test framework |
| 89 | assertNull(reportMsg, reportMsg); |
| 90 | } |
| 91 | |
Omari Stephens | a6a3536 | 2012-04-25 21:07:57 -0700 | [diff] [blame] | 92 | /** |
| 93 | * A test that runs all Launcher-launchable activities and verifies that no ANRs or crashes |
| 94 | * happened while doing so. |
| 95 | */ |
| 96 | public void testRunAllActivities() throws Exception { |
| 97 | final Set<ProcessError> errSet = new LinkedHashSet<ProcessError>(); |
Omari Stephens | 5ae3dfe | 2012-03-08 18:27:33 -0800 | [diff] [blame] | 98 | |
Omari Stephens | a6a3536 | 2012-04-25 21:07:57 -0700 | [diff] [blame] | 99 | for (ResolveInfo app : getLauncherActivities(mPackageManager)) { |
| 100 | final Collection<ProcessError> errProcs = runOneActivity(app); |
| 101 | if (errProcs != null) { |
| 102 | errSet.addAll(errProcs); |
| 103 | } |
| 104 | } |
Omari Stephens | 5ae3dfe | 2012-03-08 18:27:33 -0800 | [diff] [blame] | 105 | |
Omari Stephens | a6a3536 | 2012-04-25 21:07:57 -0700 | [diff] [blame] | 106 | if (!errSet.isEmpty()) { |
| 107 | fail(String.format("Got %d errors:\n%s", errSet.size(), |
| 108 | reportWrappedListContents(errSet))); |
| 109 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 110 | } |
Omari Stephens | 9f5a511 | 2012-01-18 22:36:42 -0800 | [diff] [blame] | 111 | |
| 112 | /** |
Omari Stephens | a6a3536 | 2012-04-25 21:07:57 -0700 | [diff] [blame] | 113 | * This test checks for asynchronously-caused errors (crashes or ANRs) and fails in case any |
| 114 | * were found. This prevents us from needing to fail unrelated testcases when, for instance |
| 115 | * a background thread causes a crash or ANR. |
| 116 | * <p /> |
| 117 | * Because this behavior depends on the contents of static member {@link mAsyncErrors}, we clear |
| 118 | * that state here as a side-effect so that if two successive runs happen in the same process, |
| 119 | * the asynchronous errors in the second test run won't include errors produced during the first |
| 120 | * run. |
Omari Stephens | 5ae3dfe | 2012-03-08 18:27:33 -0800 | [diff] [blame] | 121 | */ |
Omari Stephens | a6a3536 | 2012-04-25 21:07:57 -0700 | [diff] [blame] | 122 | public void testZZReportAsyncErrors() throws Exception { |
| 123 | try { |
| 124 | if (!mAsyncErrors.isEmpty()) { |
| 125 | fail(String.format("Got %d asynchronous errors:\n%s", mAsyncErrors.size(), |
| 126 | reportWrappedListContents(mAsyncErrors))); |
| 127 | } |
| 128 | } finally { |
| 129 | // Reset state just in case we should get another set of runs in the same process |
| 130 | mAsyncErrors.clear(); |
| 131 | } |
Omari Stephens | 5ae3dfe | 2012-03-08 18:27:33 -0800 | [diff] [blame] | 132 | } |
| 133 | |
Omari Stephens | 5ae3dfe | 2012-03-08 18:27:33 -0800 | [diff] [blame] | 134 | |
| 135 | /** |
| 136 | * A method to run the specified Activity and return a {@link Collection} of the Activities that |
| 137 | * were in an error state, as listed by {@link ActivityManager.getProcessesInErrorState()}. |
| 138 | * <p /> |
| 139 | * The method will launch the app, wait for 7 seconds, check for apps in the error state, send |
| 140 | * the Home intent, wait for 2 seconds, and then return. |
| 141 | */ |
Omari Stephens | ad8037e | 2012-03-13 21:52:13 -0700 | [diff] [blame] | 142 | public Collection<ProcessError> runOneActivity(ResolveInfo app) { |
Omari Stephens | 5ae3dfe | 2012-03-08 18:27:33 -0800 | [diff] [blame] | 143 | final long appLaunchWait = 7000; |
| 144 | final long homeLaunchWait = 2000; |
| 145 | |
| 146 | Log.i(TAG, String.format("Running activity %s/%s", app.activityInfo.packageName, |
| 147 | app.activityInfo.name)); |
| 148 | |
Omari Stephens | ad8037e | 2012-03-13 21:52:13 -0700 | [diff] [blame] | 149 | // We check for any Crash or ANR dialogs that are already up, and we ignore them. This is |
| 150 | // so that we don't report crashes that were caused by prior apps (which those particular |
Omari Stephens | a6a3536 | 2012-04-25 21:07:57 -0700 | [diff] [blame] | 151 | // tests should have caught and reported already). |
Omari Stephens | ad8037e | 2012-03-13 21:52:13 -0700 | [diff] [blame] | 152 | final Collection<ProcessError> preErrProcs = |
| 153 | ProcessError.fromCollection(mActivityManager.getProcessesInErrorState()); |
| 154 | |
Omari Stephens | 5ae3dfe | 2012-03-08 18:27:33 -0800 | [diff] [blame] | 155 | // launch app, and wait 7 seconds for it to start/settle |
| 156 | final Intent intent = intentForActivity(app); |
| 157 | getContext().startActivity(intent); |
| 158 | try { |
| 159 | Thread.sleep(appLaunchWait); |
| 160 | } catch (InterruptedException e) { |
| 161 | // ignore |
| 162 | } |
| 163 | |
Omari Stephens | 5ae3dfe | 2012-03-08 18:27:33 -0800 | [diff] [blame] | 164 | // Send the "home" intent and wait 2 seconds for us to get there |
| 165 | getContext().startActivity(mHomeIntent); |
| 166 | try { |
| 167 | Thread.sleep(homeLaunchWait); |
| 168 | } catch (InterruptedException e) { |
| 169 | // ignore |
| 170 | } |
| 171 | |
Omari Stephens | bf29121 | 2012-03-13 23:17:45 -0700 | [diff] [blame] | 172 | // See if there are any errors. We wait until down here to give ANRs as much time as |
| 173 | // possible to occur. |
| 174 | final Collection<ProcessError> errProcs = |
| 175 | ProcessError.fromCollection(mActivityManager.getProcessesInErrorState()); |
Omari Stephens | a6a3536 | 2012-04-25 21:07:57 -0700 | [diff] [blame] | 176 | |
| 177 | // Distinguish the asynchronous crashes/ANRs from the synchronous ones by checking the |
| 178 | // crash package name against the package name for {@code app} |
| 179 | if (errProcs != null) { |
| 180 | Iterator<ProcessError> errIter = errProcs.iterator(); |
| 181 | while (errIter.hasNext()) { |
| 182 | ProcessError err = errIter.next(); |
| 183 | if (!packageMatches(app, err)) { |
| 184 | // async! Drop into mAsyncErrors and don't report now |
| 185 | mAsyncErrors.add(err); |
| 186 | errIter.remove(); |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | // Take the difference between the remaining current error processes and the ones that were |
| 191 | // present when we started. The result is guaranteed to be: |
| 192 | // 1) Errors that are pertinent to this app's package |
| 193 | // 2) Errors that are pertinent to this particular app invocation |
Omari Stephens | bf29121 | 2012-03-13 23:17:45 -0700 | [diff] [blame] | 194 | if (errProcs != null && preErrProcs != null) { |
| 195 | errProcs.removeAll(preErrProcs); |
| 196 | } |
| 197 | |
Omari Stephens | 5ae3dfe | 2012-03-08 18:27:33 -0800 | [diff] [blame] | 198 | return errProcs; |
| 199 | } |
| 200 | |
Omari Stephens | a6a3536 | 2012-04-25 21:07:57 -0700 | [diff] [blame] | 201 | private String checkForProcessErrors() throws Exception { |
| 202 | List<ProcessErrorStateInfo> errList; |
| 203 | errList = mActivityManager.getProcessesInErrorState(); |
Omari Stephens | 9f5a511 | 2012-01-18 22:36:42 -0800 | [diff] [blame] | 204 | |
Omari Stephens | a6a3536 | 2012-04-25 21:07:57 -0700 | [diff] [blame] | 205 | // note: this contains information about each process that is currently in an error |
| 206 | // condition. if the list is empty (null) then "we're good". |
Omari Stephens | 9f5a511 | 2012-01-18 22:36:42 -0800 | [diff] [blame] | 207 | |
Omari Stephens | a6a3536 | 2012-04-25 21:07:57 -0700 | [diff] [blame] | 208 | // if the list is non-empty, then it's useful to report the contents of the list |
| 209 | final String reportMsg = reportListContents(errList); |
| 210 | return reportMsg; |
Omari Stephens | 9f5a511 | 2012-01-18 22:36:42 -0800 | [diff] [blame] | 211 | } |
| 212 | |
Omari Stephens | a6a3536 | 2012-04-25 21:07:57 -0700 | [diff] [blame] | 213 | /** |
| 214 | * A helper function that checks whether the specified error could have been caused by the |
| 215 | * specified app. |
| 216 | * |
| 217 | * @param app The app to check against |
| 218 | * @param err The error that we're considering |
| 219 | */ |
| 220 | private static boolean packageMatches(ResolveInfo app, ProcessError err) { |
| 221 | final String appPkg = app.activityInfo.packageName; |
| 222 | final String errPkg = err.info.processName; |
| 223 | Log.d(TAG, String.format("packageMatches(%s, %s)", appPkg, errPkg)); |
| 224 | return appPkg.equals(errPkg); |
| 225 | } |
| 226 | |
| 227 | /** |
| 228 | * A helper function to query the provided {@link PackageManager} for a list of Activities that |
| 229 | * can be launched from Launcher. |
| 230 | */ |
| 231 | static List<ResolveInfo> getLauncherActivities(PackageManager pm) { |
| 232 | final Intent launchable = new Intent(Intent.ACTION_MAIN); |
| 233 | launchable.addCategory(Intent.CATEGORY_LAUNCHER); |
| 234 | final List<ResolveInfo> activities = pm.queryIntentActivities(launchable, 0); |
| 235 | return activities; |
| 236 | } |
| 237 | |
| 238 | /** |
| 239 | * A helper function to create an {@link Intent} to run, given a {@link ResolveInfo} specifying |
| 240 | * an activity to be launched. |
| 241 | */ |
| 242 | static Intent intentForActivity(ResolveInfo app) { |
| 243 | final ComponentName component = new ComponentName(app.activityInfo.packageName, |
| 244 | app.activityInfo.name); |
| 245 | final Intent intent = new Intent(Intent.ACTION_MAIN); |
| 246 | intent.setComponent(component); |
| 247 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 248 | intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
| 249 | return intent; |
| 250 | } |
| 251 | |
| 252 | /** |
| 253 | * Report error reports for {@link ProcessErrorStateInfo} instances that are wrapped inside of |
| 254 | * {@link ProcessError} instances. Just unwraps and calls |
| 255 | * {@see reportListContents(Collection<ProcessErrorStateInfo>)}. |
| 256 | */ |
| 257 | static String reportWrappedListContents(Collection<ProcessError> errList) { |
Omari Stephens | 9f5a511 | 2012-01-18 22:36:42 -0800 | [diff] [blame] | 258 | List<ProcessErrorStateInfo> newList = new ArrayList<ProcessErrorStateInfo>(errList.size()); |
| 259 | for (ProcessError err : errList) { |
| 260 | newList.add(err.info); |
| 261 | } |
| 262 | return reportListContents(newList); |
| 263 | } |
| 264 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 265 | /** |
| 266 | * This helper function will dump the actual error reports. |
| 267 | * |
| 268 | * @param errList The error report containing one or more error records. |
| 269 | * @return Returns a string containing all of the errors. |
| 270 | */ |
Omari Stephens | a6a3536 | 2012-04-25 21:07:57 -0700 | [diff] [blame] | 271 | private static String reportListContents(Collection<ProcessErrorStateInfo> errList) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 272 | if (errList == null) return null; |
| 273 | |
| 274 | StringBuilder builder = new StringBuilder(); |
| 275 | |
Omari Stephens | 9f5a511 | 2012-01-18 22:36:42 -0800 | [diff] [blame] | 276 | Iterator<ProcessErrorStateInfo> iter = errList.iterator(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 277 | while (iter.hasNext()) { |
Omari Stephens | 9f5a511 | 2012-01-18 22:36:42 -0800 | [diff] [blame] | 278 | ProcessErrorStateInfo entry = iter.next(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 279 | |
| 280 | String condition; |
| 281 | switch (entry.condition) { |
| 282 | case ActivityManager.ProcessErrorStateInfo.CRASHED: |
Omari Stephens | bf29121 | 2012-03-13 23:17:45 -0700 | [diff] [blame] | 283 | condition = "a CRASH"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 284 | break; |
| 285 | case ActivityManager.ProcessErrorStateInfo.NOT_RESPONDING: |
Omari Stephens | bf29121 | 2012-03-13 23:17:45 -0700 | [diff] [blame] | 286 | condition = "an ANR"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 287 | break; |
| 288 | default: |
Omari Stephens | bf29121 | 2012-03-13 23:17:45 -0700 | [diff] [blame] | 289 | condition = "an unknown error"; |
Dan Egnor | b7f0367 | 2009-12-09 16:22:32 -0800 | [diff] [blame] | 290 | break; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 291 | } |
| 292 | |
Omari Stephens | bf29121 | 2012-03-13 23:17:45 -0700 | [diff] [blame] | 293 | builder.append(String.format("Process %s encountered %s (%s)", entry.processName, |
| 294 | condition, entry.shortMsg)); |
| 295 | if (entry.condition == ActivityManager.ProcessErrorStateInfo.CRASHED) { |
| 296 | builder.append(String.format(" with stack trace:\n%s\n", entry.stackTrace)); |
| 297 | } |
Omari Stephens | 9f5a511 | 2012-01-18 22:36:42 -0800 | [diff] [blame] | 298 | builder.append("\n"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 299 | } |
| 300 | return builder.toString(); |
| 301 | } |
Omari Stephens | 9f5a511 | 2012-01-18 22:36:42 -0800 | [diff] [blame] | 302 | |
| 303 | /** |
| 304 | * A {@link ProcessErrorStateInfo} wrapper class that hashes how we want (so that equivalent |
| 305 | * crashes are considered equal). |
| 306 | */ |
Omari Stephens | 5ae3dfe | 2012-03-08 18:27:33 -0800 | [diff] [blame] | 307 | static class ProcessError { |
Omari Stephens | 9f5a511 | 2012-01-18 22:36:42 -0800 | [diff] [blame] | 308 | public final ProcessErrorStateInfo info; |
| 309 | |
| 310 | public ProcessError(ProcessErrorStateInfo newInfo) { |
| 311 | info = newInfo; |
| 312 | } |
| 313 | |
| 314 | public static Collection<ProcessError> fromCollection(Collection<ProcessErrorStateInfo> in) |
| 315 | { |
Omari Stephens | ad8037e | 2012-03-13 21:52:13 -0700 | [diff] [blame] | 316 | if (in == null) { |
| 317 | return null; |
| 318 | } |
| 319 | |
Omari Stephens | 9f5a511 | 2012-01-18 22:36:42 -0800 | [diff] [blame] | 320 | List<ProcessError> out = new ArrayList<ProcessError>(in.size()); |
| 321 | for (ProcessErrorStateInfo info : in) { |
| 322 | out.add(new ProcessError(info)); |
| 323 | } |
| 324 | return out; |
| 325 | } |
| 326 | |
| 327 | private boolean strEquals(String a, String b) { |
| 328 | if ((a == null) && (b == null)) { |
| 329 | return true; |
| 330 | } else if ((a == null) || (b == null)) { |
| 331 | return false; |
| 332 | } else { |
| 333 | return a.equals(b); |
| 334 | } |
| 335 | } |
| 336 | |
| 337 | @Override |
| 338 | public boolean equals(Object other) { |
| 339 | if (other == null) return false; |
| 340 | if (!(other instanceof ProcessError)) return false; |
| 341 | ProcessError peOther = (ProcessError) other; |
| 342 | |
| 343 | return (info.condition == peOther.info.condition) |
| 344 | && strEquals(info.longMsg, peOther.info.longMsg) |
| 345 | && (info.pid == peOther.info.pid) |
| 346 | && strEquals(info.processName, peOther.info.processName) |
| 347 | && strEquals(info.shortMsg, peOther.info.shortMsg) |
| 348 | && strEquals(info.stackTrace, peOther.info.stackTrace) |
| 349 | && strEquals(info.tag, peOther.info.tag) |
| 350 | && (info.uid == peOther.info.uid); |
| 351 | } |
| 352 | |
| 353 | private int hash(Object obj) { |
| 354 | if (obj == null) { |
| 355 | return 13; |
| 356 | } else { |
| 357 | return obj.hashCode(); |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | @Override |
| 362 | public int hashCode() { |
| 363 | int code = 17; |
| 364 | code += info.condition; |
| 365 | code *= hash(info.longMsg); |
| 366 | code += info.pid; |
| 367 | code *= hash(info.processName); |
| 368 | code *= hash(info.shortMsg); |
| 369 | code *= hash(info.stackTrace); |
| 370 | code *= hash(info.tag); |
| 371 | code += info.uid; |
| 372 | return code; |
| 373 | } |
| 374 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 375 | } |