From f8880561e67e1da246970b49b14285efd4164ab1 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Fri, 26 Feb 2016 13:03:01 -0700 Subject: [PATCH] When system server goes down, crash apps more. Similar to first patch, but now using new "rethrowFromSystemServer()" method which internally translates DeadObjectException into DeadSystemException. New logic over in Log.printlns() now suppresses the DeadSystemException stack traces, since they're misleading and just added pressure to the precious log buffer space. Add some extra RuntimeInit checks to suppress logging-about-logging when the system server is dead. Bug: 27364859 Change-Id: I05316b3e8e42416b30a56a76c09cd3113a018123 --- api/current.txt | 4 + api/system-current.txt | 4 + api/test-current.txt | 4 + .../java/android/accounts/AccountManager.java | 72 ++---- core/java/android/app/ActivityManager.java | 104 ++++----- core/java/android/app/ActivityThread.java | 57 +++-- core/java/android/app/AppOpsManager.java | 34 +-- .../app/ApplicationPackageManager.java | 220 +++++++++--------- core/java/android/app/ContextImpl.java | 60 ++--- core/java/android/app/LoadedApk.java | 14 +- .../java/android/app/NotificationManager.java | 43 ++-- core/java/android/app/trust/TrustManager.java | 25 +- .../android/appwidget/AppWidgetManager.java | 76 +++--- .../android/content/ClipboardManager.java | 11 +- .../android/content/RestrictionsManager.java | 10 +- .../java/android/content/pm/LauncherApps.java | 16 +- .../android/content/pm/PackageInstaller.java | 40 ++-- .../display/DisplayManagerGlobal.java | 41 ++-- .../java/android/hardware/usb/UsbManager.java | 36 ++- .../android/net/NetworkPolicyManager.java | 16 +- core/java/android/net/TrafficStats.java | 6 +- core/java/android/os/DeadSystemException.java | 27 +++ core/java/android/os/DropBoxManager.java | 26 ++- core/java/android/os/RemoteException.java | 22 ++ core/java/android/os/StrictMode.java | 18 +- core/java/android/os/UserManager.java | 102 ++++---- .../android/os/storage/StorageManager.java | 73 +++--- core/java/android/print/PrintManager.java | 25 +- .../PersistentDataBlockManager.java | 26 +-- core/java/android/util/Log.java | 7 + .../com/android/internal/os/RuntimeInit.java | 21 +- .../android/location/LocationManager.java | 87 +++---- media/java/android/media/AudioManager.java | 136 +++++------ .../server/am/ActivityManagerService.java | 2 +- 34 files changed, 754 insertions(+), 711 deletions(-) create mode 100644 core/java/android/os/DeadSystemException.java diff --git a/api/current.txt b/api/current.txt index 3adf222a59350..f7a316d063e5b 100644 --- a/api/current.txt +++ b/api/current.txt @@ -28471,6 +28471,10 @@ package android.os { ctor public DeadObjectException(java.lang.String); } + public class DeadSystemException extends android.os.DeadObjectException { + ctor public DeadSystemException(); + } + public final class Debug { method public static deprecated void changeDebugPort(int); method public static void dumpHprofData(java.lang.String) throws java.io.IOException; diff --git a/api/system-current.txt b/api/system-current.txt index f42360f212d3a..b2b59826f3bcb 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -30773,6 +30773,10 @@ package android.os { ctor public DeadObjectException(java.lang.String); } + public class DeadSystemException extends android.os.DeadObjectException { + ctor public DeadSystemException(); + } + public final class Debug { method public static deprecated void changeDebugPort(int); method public static void dumpHprofData(java.lang.String) throws java.io.IOException; diff --git a/api/test-current.txt b/api/test-current.txt index be69fa69d73c2..472daf698b749 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -28480,6 +28480,10 @@ package android.os { ctor public DeadObjectException(java.lang.String); } + public class DeadSystemException extends android.os.DeadObjectException { + ctor public DeadSystemException(); + } + public final class Debug { method public static deprecated void changeDebugPort(int); method public static void dumpHprofData(java.lang.String) throws java.io.IOException; diff --git a/core/java/android/accounts/AccountManager.java b/core/java/android/accounts/AccountManager.java index 1d9e3bb4b4bb0..e520b406656bf 100644 --- a/core/java/android/accounts/AccountManager.java +++ b/core/java/android/accounts/AccountManager.java @@ -353,8 +353,7 @@ public class AccountManager { try { return mService.getPassword(account); } catch (RemoteException e) { - // won't ever happen - throw new RuntimeException(e); + throw e.rethrowFromSystemServer(); } } @@ -382,8 +381,7 @@ public class AccountManager { try { return mService.getUserData(account, key); } catch (RemoteException e) { - // won't ever happen - throw new RuntimeException(e); + throw e.rethrowFromSystemServer(); } } @@ -402,8 +400,7 @@ public class AccountManager { try { return mService.getAuthenticatorTypes(UserHandle.getCallingUserId()); } catch (RemoteException e) { - // will never happen - throw new RuntimeException(e); + throw e.rethrowFromSystemServer(); } } @@ -424,8 +421,7 @@ public class AccountManager { try { return mService.getAuthenticatorTypes(userId); } catch (RemoteException e) { - // will never happen - throw new RuntimeException(e); + throw e.rethrowFromSystemServer(); } } @@ -449,8 +445,7 @@ public class AccountManager { try { return mService.getAccounts(null, mContext.getOpPackageName()); } catch (RemoteException e) { - // won't ever happen - throw new RuntimeException(e); + throw e.rethrowFromSystemServer(); } } @@ -475,8 +470,7 @@ public class AccountManager { try { return mService.getAccountsAsUser(null, userId, mContext.getOpPackageName()); } catch (RemoteException e) { - // won't ever happen - throw new RuntimeException(e); + throw e.rethrowFromSystemServer(); } } @@ -493,8 +487,7 @@ public class AccountManager { try { return mService.getAccountsForPackage(packageName, uid, mContext.getOpPackageName()); } catch (RemoteException re) { - // won't ever happen - throw new RuntimeException(re); + throw re.rethrowFromSystemServer(); } } @@ -512,8 +505,7 @@ public class AccountManager { return mService.getAccountsByTypeForPackage(type, packageName, mContext.getOpPackageName()); } catch (RemoteException re) { - // won't ever happen - throw new RuntimeException(re); + throw re.rethrowFromSystemServer(); } } @@ -552,8 +544,7 @@ public class AccountManager { return mService.getAccountsAsUser(type, userHandle.getIdentifier(), mContext.getOpPackageName()); } catch (RemoteException e) { - // won't ever happen - throw new RuntimeException(e); + throw e.rethrowFromSystemServer(); } } @@ -572,8 +563,7 @@ public class AccountManager { try { mService.updateAppPermission(account, authTokenType, uid, value); } catch (RemoteException e) { - // won't ever happen - throw new RuntimeException(e); + throw e.rethrowFromSystemServer(); } } @@ -742,8 +732,7 @@ public class AccountManager { try { return mService.addAccountExplicitly(account, password, userdata); } catch (RemoteException e) { - // Can happen if there was a SecurityException was thrown. - throw new RuntimeException(e); + throw e.rethrowFromSystemServer(); } } @@ -768,7 +757,7 @@ public class AccountManager { try { return mService.accountAuthenticated(account); } catch (RemoteException e) { - throw new RuntimeException(e); + throw e.rethrowFromSystemServer(); } } @@ -836,8 +825,7 @@ public class AccountManager { try { return mService.getPreviousName(account); } catch (RemoteException e) { - // will never happen - throw new RuntimeException(e); + throw e.rethrowFromSystemServer(); } } @@ -1008,8 +996,7 @@ public class AccountManager { try { return mService.removeAccountExplicitly(account); } catch (RemoteException e) { - // May happen if the caller doesn't match the signature of the authenticator. - throw new RuntimeException(e); + throw e.rethrowFromSystemServer(); } } @@ -1036,8 +1023,7 @@ public class AccountManager { mService.invalidateAuthToken(accountType, authToken); } } catch (RemoteException e) { - // won't ever happen - throw new RuntimeException(e); + throw e.rethrowFromSystemServer(); } } @@ -1068,8 +1054,7 @@ public class AccountManager { try { return mService.peekAuthToken(account, authTokenType); } catch (RemoteException e) { - // won't ever happen - throw new RuntimeException(e); + throw e.rethrowFromSystemServer(); } } @@ -1098,8 +1083,7 @@ public class AccountManager { try { mService.setPassword(account, password); } catch (RemoteException e) { - // won't ever happen - throw new RuntimeException(e); + throw e.rethrowFromSystemServer(); } } @@ -1127,8 +1111,7 @@ public class AccountManager { try { mService.clearPassword(account); } catch (RemoteException e) { - // won't ever happen - throw new RuntimeException(e); + throw e.rethrowFromSystemServer(); } } @@ -1156,8 +1139,7 @@ public class AccountManager { try { mService.setUserData(account, key, value); } catch (RemoteException e) { - // Will happen if there is not signature match. - throw new RuntimeException(e); + throw e.rethrowFromSystemServer(); } } @@ -1186,8 +1168,7 @@ public class AccountManager { try { mService.setAuthToken(account, authTokenType, authToken); } catch (RemoteException e) { - // won't ever happen - throw new RuntimeException(e); + throw e.rethrowFromSystemServer(); } } @@ -1588,7 +1569,7 @@ public class AccountManager { mService.addSharedAccountsFromParentUser(parentUser.getIdentifier(), user.getIdentifier()); } catch (RemoteException re) { - throw new IllegalStateException(re); + throw re.rethrowFromSystemServer(); } } @@ -1641,8 +1622,7 @@ public class AccountManager { boolean val = mService.removeSharedAccountAsUser(account, user.getIdentifier()); return val; } catch (RemoteException re) { - // won't ever happen - throw new RuntimeException(re); + throw re.rethrowFromSystemServer(); } } @@ -1655,8 +1635,7 @@ public class AccountManager { try { return mService.getSharedAccountsAsUser(user.getIdentifier()); } catch (RemoteException re) { - // won't ever happen - throw new RuntimeException(re); + throw re.rethrowFromSystemServer(); } } @@ -1878,7 +1857,7 @@ public class AccountManager { try { return mService.someUserHasAccount(account); } catch (RemoteException re) { - throw new RuntimeException(re); + throw re.rethrowFromSystemServer(); } } @@ -2039,8 +2018,7 @@ public class AccountManager { try { doWork(); } catch (RemoteException e) { - // this will only happen if the system process is dead, which means - // we will be dying ourselves + throw e.rethrowFromSystemServer(); } } else { set(bundle); diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index 8b010f3cdb838..4aab163597d61 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -716,7 +716,7 @@ public class ActivityManager { try { return ActivityManagerNative.getDefault().getFrontActivityScreenCompatMode(); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -725,7 +725,7 @@ public class ActivityManager { try { ActivityManagerNative.getDefault().setFrontActivityScreenCompatMode(mode); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -734,7 +734,7 @@ public class ActivityManager { try { return ActivityManagerNative.getDefault().getPackageScreenCompatMode(packageName); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -743,7 +743,7 @@ public class ActivityManager { try { ActivityManagerNative.getDefault().setPackageScreenCompatMode(packageName, mode); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -752,7 +752,7 @@ public class ActivityManager { try { return ActivityManagerNative.getDefault().getPackageAskScreenCompat(packageName); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -761,7 +761,7 @@ public class ActivityManager { try { ActivityManagerNative.getDefault().setPackageAskScreenCompat(packageName, ask); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1046,7 +1046,7 @@ public class ActivityManager { return ActivityManagerNative.getDefault().getTaskDescriptionIcon(iconFilename, userId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } return null; @@ -1427,7 +1427,7 @@ public class ActivityManager { return ActivityManagerNative.getDefault().getRecentTasks(maxNum, flags, UserHandle.myUserId()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1452,7 +1452,7 @@ public class ActivityManager { return ActivityManagerNative.getDefault().getRecentTasks(maxNum, flags, userId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1587,7 +1587,7 @@ public class ActivityManager { try { appTasks = ActivityManagerNative.getDefault().getAppTasks(mContext.getPackageName()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } int numAppTasks = appTasks.size(); for (int i = 0; i < numAppTasks; i++) { @@ -1612,7 +1612,7 @@ public class ActivityManager { try { mAppTaskThumbnailSize = ActivityManagerNative.getDefault().getAppTaskThumbnailSize(); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } } @@ -1678,7 +1678,7 @@ public class ActivityManager { return ActivityManagerNative.getDefault().addAppTask(activity.getActivityToken(), intent, description, thumbnail); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1720,7 +1720,7 @@ public class ActivityManager { try { return ActivityManagerNative.getDefault().getTasks(maxNum, 0); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1736,7 +1736,7 @@ public class ActivityManager { try { return ActivityManagerNative.getDefault().removeTask(taskId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1895,7 +1895,7 @@ public class ActivityManager { try { return ActivityManagerNative.getDefault().getTaskThumbnail(id); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1904,7 +1904,7 @@ public class ActivityManager { try { return ActivityManagerNative.getDefault().isInHomeStack(taskId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1953,7 +1953,7 @@ public class ActivityManager { try { ActivityManagerNative.getDefault().moveTaskToFront(taskId, flags, options); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2139,7 +2139,7 @@ public class ActivityManager { return ActivityManagerNative.getDefault() .getServices(maxNum, 0); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2154,7 +2154,7 @@ public class ActivityManager { return ActivityManagerNative.getDefault() .getRunningServiceControlPanel(service); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2258,7 +2258,7 @@ public class ActivityManager { try { ActivityManagerNative.getDefault().getMemoryInfo(outInfo); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2377,7 +2377,7 @@ public class ActivityManager { return ActivityManagerNative.getDefault().clearApplicationUserData(packageName, observer, UserHandle.myUserId()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2411,7 +2411,7 @@ public class ActivityManager { return ActivityManagerNative.getDefault().getGrantedUriPermissions(packageName, UserHandle.myUserId()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2429,7 +2429,7 @@ public class ActivityManager { ActivityManagerNative.getDefault().clearGrantedUriPermissions(packageName, UserHandle.myUserId()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2549,7 +2549,7 @@ public class ActivityManager { try { return ActivityManagerNative.getDefault().getProcessesInErrorState(); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2863,7 +2863,7 @@ public class ActivityManager { try { return ActivityManagerNative.getDefault().getRunningExternalApplications(); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2880,7 +2880,7 @@ public class ActivityManager { return ActivityManagerNative.getDefault().setProcessMemoryTrimLevel(process, userId, level); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2898,7 +2898,7 @@ public class ActivityManager { try { return ActivityManagerNative.getDefault().getRunningAppProcesses(); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2917,7 +2917,7 @@ public class ActivityManager { mContext.getOpPackageName()); return RunningAppProcessInfo.procStateToImportance(procState); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2936,7 +2936,7 @@ public class ActivityManager { try { ActivityManagerNative.getDefault().getMyMemoryState(outState); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2955,7 +2955,7 @@ public class ActivityManager { try { return ActivityManagerNative.getDefault().getProcessMemoryInfo(pids); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2989,7 +2989,7 @@ public class ActivityManager { ActivityManagerNative.getDefault().killBackgroundProcesses(packageName, UserHandle.myUserId()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -3006,7 +3006,7 @@ public class ActivityManager { ActivityManagerNative.getDefault().killUid(UserHandle.getAppId(uid), UserHandle.getUserId(uid), reason); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -3033,7 +3033,7 @@ public class ActivityManager { try { ActivityManagerNative.getDefault().forceStopPackage(packageName, userId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -3052,7 +3052,7 @@ public class ActivityManager { try { return ActivityManagerNative.getDefault().getDeviceConfigurationInfo(); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -3142,7 +3142,7 @@ public class ActivityManager { try { return ActivityManagerNative.getDefault().isUserAMonkey(); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -3218,7 +3218,7 @@ public class ActivityManager { return AppGlobals.getPackageManager() .checkUidPermission(permission, uid); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -3228,7 +3228,7 @@ public class ActivityManager { return AppGlobals.getPackageManager() .checkUidPermission(permission, uid); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -3265,7 +3265,7 @@ public class ActivityManager { return ActivityManagerNative.getDefault().handleIncomingUser(callingPid, callingUid, userId, allowAll, requireFull, name, callerPackage); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -3280,7 +3280,7 @@ public class ActivityManager { ui = ActivityManagerNative.getDefault().getCurrentUser(); return ui != null ? ui.id : 0; } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -3292,7 +3292,7 @@ public class ActivityManager { try { return ActivityManagerNative.getDefault().switchUser(userid); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -3316,7 +3316,7 @@ public class ActivityManager { try { return ActivityManagerNative.getDefault().isUserRunning(userId, 0); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -3326,7 +3326,7 @@ public class ActivityManager { return ActivityManagerNative.getDefault().isUserRunning(userId, ActivityManager.FLAG_AND_LOCKED); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -3336,7 +3336,7 @@ public class ActivityManager { return ActivityManagerNative.getDefault().isUserRunning(userId, ActivityManager.FLAG_AND_UNLOCKED); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -3421,7 +3421,7 @@ public class ActivityManager { ActivityManagerNative.getDefault().setDumpHeapDebugLimit(null, 0, pssSize, mContext.getPackageName()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -3440,7 +3440,7 @@ public class ActivityManager { try { ActivityManagerNative.getDefault().setDumpHeapDebugLimit(null, 0, 0, null); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -3451,7 +3451,7 @@ public class ActivityManager { try { ActivityManagerNative.getDefault().startLockTaskMode(taskId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -3462,7 +3462,7 @@ public class ActivityManager { try { ActivityManagerNative.getDefault().stopLockTaskMode(); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -3489,7 +3489,7 @@ public class ActivityManager { try { return ActivityManagerNative.getDefault().getLockTaskModeState(); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -3512,7 +3512,7 @@ public class ActivityManager { try { mAppTaskImpl.finishAndRemoveTask(); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -3525,7 +3525,7 @@ public class ActivityManager { try { return mAppTaskImpl.getTaskInfo(); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -3539,7 +3539,7 @@ public class ActivityManager { try { mAppTaskImpl.moveToFront(); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -3581,7 +3581,7 @@ public class ActivityManager { try { mAppTaskImpl.setExcludeFromRecents(exclude); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } } diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index a38df615ceff1..0020a50c48fb0 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -1693,7 +1693,7 @@ public final class ActivityThread { am.activityIdle(a.token, a.createdConfig, stopProfiling); a.createdConfig = null; } catch (RemoteException ex) { - // Ignore + throw ex.rethrowFromSystemServer(); } } prev = a; @@ -1833,7 +1833,7 @@ public final class ActivityThread { | PackageManager.MATCH_DEBUG_TRIAGED_MISSING, userId); } catch (RemoteException e) { - // Ignore + throw e.rethrowFromSystemServer(); } if (ai != null) { @@ -2592,6 +2592,7 @@ public final class ActivityThread { try { displayId = ActivityManagerNative.getDefault().getActivityDisplayId(r.token); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } ContextImpl appContext = ContextImpl.createActivityContext( @@ -2697,7 +2698,7 @@ public final class ActivityThread { .finishActivity(r.token, Activity.RESULT_CANCELED, null, Activity.DONT_FINISH_TASK_WITH_ACTIVITY); } catch (RemoteException ex) { - // Ignore + throw ex.rethrowFromSystemServer(); } } } @@ -2726,6 +2727,7 @@ public final class ActivityThread { ActivityManagerNative.getDefault().reportSizeConfigurations(r.token, horizontal.copyKeys(), vertical.copyKeys(), smallest.copyKeys()); } catch (RemoteException ex) { + throw ex.rethrowFromSystemServer(); } } @@ -2802,6 +2804,7 @@ public final class ActivityThread { try { mgr.reportAssistContextExtras(cmd.requestToken, data, structure, content, referrer); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -2838,6 +2841,7 @@ public final class ActivityThread { try { ActivityManagerNative.getDefault().backgroundResourcesReleased(token); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -2992,8 +2996,7 @@ public final class ActivityThread { return; } } catch (RemoteException e) { - Slog.e(TAG, "Can't reach package manager", e); - return; + throw e.rethrowFromSystemServer(); } // no longer idle; we have backup work to do @@ -3054,7 +3057,7 @@ public final class ActivityThread { try { ActivityManagerNative.getDefault().backupAgentCreated(packageName, binder); } catch (RemoteException e) { - // nothing to do. + throw e.rethrowFromSystemServer(); } } catch (Exception e) { throw new RuntimeException("Unable to create BackupAgent " @@ -3116,7 +3119,7 @@ public final class ActivityThread { ActivityManagerNative.getDefault().serviceDoneExecuting( data.token, SERVICE_DONE_EXECUTING_ANON, 0, 0); } catch (RemoteException e) { - // nothing to do. + throw e.rethrowFromSystemServer(); } } catch (Exception e) { if (!mInstrumentation.onException(service, e)) { @@ -3147,6 +3150,7 @@ public final class ActivityThread { } ensureJitEnabled(); } catch (RemoteException ex) { + throw ex.rethrowFromSystemServer(); } } catch (Exception e) { if (!mInstrumentation.onException(s, e)) { @@ -3174,6 +3178,7 @@ public final class ActivityThread { data.token, SERVICE_DONE_EXECUTING_ANON, 0, 0); } } catch (RemoteException ex) { + throw ex.rethrowFromSystemServer(); } } catch (Exception e) { if (!mInstrumentation.onException(s, e)) { @@ -3255,7 +3260,7 @@ public final class ActivityThread { ActivityManagerNative.getDefault().serviceDoneExecuting( data.token, SERVICE_DONE_EXECUTING_START, data.startId, res); } catch (RemoteException e) { - // nothing to do. + throw e.rethrowFromSystemServer(); } ensureJitEnabled(); } catch (Exception e) { @@ -3286,9 +3291,7 @@ public final class ActivityThread { ActivityManagerNative.getDefault().serviceDoneExecuting( token, SERVICE_DONE_EXECUTING_STOP, 0, 0); } catch (RemoteException e) { - // nothing to do. - Slog.i(TAG, "handleStopService: unable to execute serviceDoneExecuting for " - + token, e); + throw e.rethrowFromSystemServer(); } } catch (Exception e) { if (!mInstrumentation.onException(s, e)) { @@ -3398,6 +3401,7 @@ public final class ActivityThread { willBeVisible = ActivityManagerNative.getDefault().willActivityBeVisible( a.getActivityToken()); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } if (r.window == null && !a.mFinished && willBeVisible) { @@ -3481,6 +3485,7 @@ public final class ActivityThread { try { ActivityManagerNative.getDefault().activityResumed(token); } catch (RemoteException ex) { + throw ex.rethrowFromSystemServer(); } } @@ -3492,6 +3497,7 @@ public final class ActivityThread { .finishActivity(token, Activity.RESULT_CANCELED, null, Activity.DONT_FINISH_TASK_WITH_ACTIVITY); } catch (RemoteException ex) { + throw ex.rethrowFromSystemServer(); } } } @@ -3577,6 +3583,7 @@ public final class ActivityThread { try { ActivityManagerNative.getDefault().activityPaused(token); } catch (RemoteException ex) { + throw ex.rethrowFromSystemServer(); } } mSomeActivitiesChanged = true; @@ -3670,6 +3677,7 @@ public final class ActivityThread { ActivityManagerNative.getDefault().activityStopped( activity.token, state, persistentState, description); } catch (RemoteException ex) { + throw ex.rethrowFromSystemServer(); } } } @@ -3909,6 +3917,7 @@ public final class ActivityThread { try { ActivityManagerNative.getDefault().activitySlept(r.token); } catch (RemoteException ex) { + throw ex.rethrowFromSystemServer(); } } else { if (r.stopped && r.activity.mVisibleFromServer) { @@ -4175,7 +4184,7 @@ public final class ActivityThread { try { ActivityManagerNative.getDefault().activityDestroyed(token); } catch (RemoteException ex) { - // If the system process has died, it's game over for everyone. + throw ex.rethrowFromSystemServer(); } } mSomeActivitiesChanged = true; @@ -4216,7 +4225,7 @@ public final class ActivityThread { try { ActivityManagerNative.getDefault().activityRelaunched(token); } catch (RemoteException e) { - e.printStackTrace(); + throw e.rethrowFromSystemServer(); } } break; @@ -4337,7 +4346,7 @@ public final class ActivityThread { try { ActivityManagerNative.getDefault().activityRelaunched(tmp.token); } catch (RemoteException e) { - // If the system process has died, it's game over for everyone. + throw e.rethrowFromSystemServer(); } } return; @@ -4363,7 +4372,7 @@ public final class ActivityThread { WindowManagerGlobal.getWindowSession().prepareToReplaceChildren(r.token); } } catch (RemoteException e) { - // If the system process has died, it's game over for everyone. + throw e.rethrowFromSystemServer(); } @@ -4408,7 +4417,7 @@ public final class ActivityThread { r.window.reportActivityRelaunched(); } } catch (RemoteException e) { - // If the system process has died, it's game over for everyone. + throw e.rethrowFromSystemServer(); } } } @@ -4688,6 +4697,7 @@ public final class ActivityThread { try { ActivityManagerNative.getDefault().dumpHeapFinished(dhd.path); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -4770,7 +4780,7 @@ public final class ActivityThread { RenderScriptCacheDir.setupDiskCache(cacheDir); } } catch (RemoteException e) { - // Ignore + throw e.rethrowFromSystemServer(); } } @@ -4962,6 +4972,7 @@ public final class ActivityThread { try { mgr.showWaitingForDebugger(mAppThread, true); } catch (RemoteException ex) { + throw ex.rethrowFromSystemServer(); } Debug.waitForDebugger(); @@ -4969,6 +4980,7 @@ public final class ActivityThread { try { mgr.showWaitingForDebugger(mAppThread, false); } catch (RemoteException ex) { + throw ex.rethrowFromSystemServer(); } } else { @@ -4996,7 +5008,9 @@ public final class ActivityThread { try { final ProxyInfo proxyInfo = service.getProxyForNetwork(null); Proxy.setHttpProxySystemProperty(proxyInfo); - } catch (RemoteException e) {} + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } } // Instrumentation info affects the class loader, so load it before @@ -5160,6 +5174,7 @@ public final class ActivityThread { try { am.finishInstrumentation(mAppThread, resultCode, results); } catch (RemoteException ex) { + throw ex.rethrowFromSystemServer(); } } @@ -5189,6 +5204,7 @@ public final class ActivityThread { ActivityManagerNative.getDefault().publishContentProviders( getApplicationThread(), results); } catch (RemoteException ex) { + throw ex.rethrowFromSystemServer(); } } @@ -5210,6 +5226,7 @@ public final class ActivityThread { holder = ActivityManagerNative.getDefault().getContentProvider( getApplicationThread(), auth, userId, stable); } catch (RemoteException ex) { + throw ex.rethrowFromSystemServer(); } if (holder == null) { Slog.e(TAG, "Failed to find provider info for " + auth); @@ -5497,6 +5514,7 @@ public final class ActivityThread { ActivityManagerNative.getDefault() .appNotRespondingViaProvider(prc.holder.connection); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } } @@ -5676,7 +5694,7 @@ public final class ActivityThread { try { mgr.attachApplication(mAppThread); } catch (RemoteException ex) { - // Ignore + throw ex.rethrowFromSystemServer(); } // Watch for getting close to heap limit. BinderInternal.addGcWatcher(new Runnable() { @@ -5695,6 +5713,7 @@ public final class ActivityThread { try { mgr.releaseSomeActivities(mAppThread); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } } diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index 93452fda1e1a1..9d1dfdd24a881 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -1236,8 +1236,8 @@ public class AppOpsManager { try { return mService.getPackagesForOps(ops); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } - return null; } /** @@ -1252,8 +1252,8 @@ public class AppOpsManager { try { return mService.getOpsForPackage(uid, packageName, ops); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } - return null; } /** @hide */ @@ -1261,6 +1261,7 @@ public class AppOpsManager { try { mService.setUidMode(code, uid, mode); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -1269,6 +1270,7 @@ public class AppOpsManager { try { mService.setUserRestriction(code, restricted, token, mContext.getUserId()); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -1277,6 +1279,7 @@ public class AppOpsManager { try { mService.setMode(code, uid, packageName, mode); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -1297,6 +1300,7 @@ public class AppOpsManager { final int uid = Binder.getCallingUid(); mService.setAudioRestriction(code, usage, uid, mode, exceptionPackages); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -1305,6 +1309,7 @@ public class AppOpsManager { try { mService.resetAllModes(UserHandle.myUserId(), null); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -1361,6 +1366,7 @@ public class AppOpsManager { try { mService.startWatchingMode(op, packageName, cb); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } } @@ -1376,6 +1382,7 @@ public class AppOpsManager { try { mService.stopWatchingMode(cb); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } } @@ -1540,8 +1547,8 @@ public class AppOpsManager { } return mode; } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } - return MODE_IGNORED; } /** @@ -1553,8 +1560,8 @@ public class AppOpsManager { try { return mService.checkOperation(op, uid, packageName); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } - return MODE_ERRORED; } /** @@ -1570,7 +1577,7 @@ public class AppOpsManager { "Package " + packageName + " does not belong to " + uid); } } catch (RemoteException e) { - throw new SecurityException("Unable to verify package ownership", e); + throw e.rethrowFromSystemServer(); } } @@ -1586,8 +1593,8 @@ public class AppOpsManager { } return mode; } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } - return MODE_IGNORED; } /** @@ -1599,8 +1606,8 @@ public class AppOpsManager { try { return mService.checkAudioOperation(op, stream, uid, packageName); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } - return MODE_ERRORED; } /** @@ -1626,8 +1633,8 @@ public class AppOpsManager { } return mode; } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } - return MODE_IGNORED; } /** @@ -1669,8 +1676,8 @@ public class AppOpsManager { return mService.noteProxyOperation(op, mContext.getOpPackageName(), Binder.getCallingUid(), proxiedPackageName); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } - return MODE_ERRORED; } /** @@ -1682,8 +1689,8 @@ public class AppOpsManager { try { return mService.noteOperation(op, uid, packageName); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } - return MODE_ERRORED; } /** @hide */ @@ -1700,7 +1707,7 @@ public class AppOpsManager { try { sToken = service.getToken(new Binder()); } catch (RemoteException e) { - // System is dead, whatevs. + throw e.rethrowFromSystemServer(); } return sToken; } @@ -1731,8 +1738,8 @@ public class AppOpsManager { } return mode; } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } - return MODE_IGNORED; } /** @@ -1744,8 +1751,8 @@ public class AppOpsManager { try { return mService.startOperation(getToken(mService), op, uid, packageName); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } - return MODE_ERRORED; } /** @hide */ @@ -1764,6 +1771,7 @@ public class AppOpsManager { try { mService.finishOperation(getToken(mService), op, uid, packageName); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java index 6d716cc869eb8..4d466d34a79c5 100644 --- a/core/java/android/app/ApplicationPackageManager.java +++ b/core/java/android/app/ApplicationPackageManager.java @@ -143,7 +143,7 @@ public class ApplicationPackageManager extends PackageManager { return pi; } } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } throw new NameNotFoundException(packageName); @@ -154,7 +154,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.currentToCanonicalPackageNames(names); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -163,7 +163,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.canonicalToCurrentPackageNames(names); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -227,7 +227,7 @@ public class ApplicationPackageManager extends PackageManager { return gids; } } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } throw new NameNotFoundException(packageName); @@ -252,7 +252,7 @@ public class ApplicationPackageManager extends PackageManager { return uid; } } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } throw new NameNotFoundException(packageName); @@ -267,7 +267,7 @@ public class ApplicationPackageManager extends PackageManager { return pi; } } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } throw new NameNotFoundException(name); @@ -282,7 +282,7 @@ public class ApplicationPackageManager extends PackageManager { return pi; } } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } throw new NameNotFoundException(group); @@ -297,7 +297,7 @@ public class ApplicationPackageManager extends PackageManager { return pgi; } } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } throw new NameNotFoundException(name); @@ -308,7 +308,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.getAllPermissionGroups(flags); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -330,7 +330,7 @@ public class ApplicationPackageManager extends PackageManager { return maybeAdjustApplicationInfo(ai); } } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } throw new NameNotFoundException(packageName); @@ -370,7 +370,7 @@ public class ApplicationPackageManager extends PackageManager { return ai; } } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } throw new NameNotFoundException(className.toString()); @@ -385,7 +385,7 @@ public class ApplicationPackageManager extends PackageManager { return ai; } } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } throw new NameNotFoundException(className.toString()); @@ -400,7 +400,7 @@ public class ApplicationPackageManager extends PackageManager { return si; } } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } throw new NameNotFoundException(className.toString()); @@ -415,7 +415,7 @@ public class ApplicationPackageManager extends PackageManager { return pi; } } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } throw new NameNotFoundException(className.toString()); @@ -426,7 +426,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.getSystemSharedLibraryNames(); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -436,7 +436,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.getServicesSystemSharedLibraryPackageName(); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -445,7 +445,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.getSystemAvailableFeatures(); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -459,7 +459,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.hasSystemFeature(name, version); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -468,7 +468,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.checkPermission(permName, pkgName, mContext.getUserId()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -477,7 +477,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.isPermissionRevokedByPolicy(permName, pkgName, mContext.getUserId()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -491,7 +491,7 @@ public class ApplicationPackageManager extends PackageManager { try { mPermissionsControllerPackageName = mPM.getPermissionControllerPackageName(); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } return mPermissionsControllerPackageName; @@ -503,7 +503,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.addPermission(info); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -512,7 +512,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.addPermissionAsync(info); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -521,7 +521,7 @@ public class ApplicationPackageManager extends PackageManager { try { mPM.removePermission(name); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -531,7 +531,7 @@ public class ApplicationPackageManager extends PackageManager { try { mPM.grantRuntimePermission(packageName, permissionName, user.getIdentifier()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -541,7 +541,7 @@ public class ApplicationPackageManager extends PackageManager { try { mPM.revokeRuntimePermission(packageName, permissionName, user.getIdentifier()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -550,7 +550,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.getPermissionFlags(permissionName, packageName, user.getIdentifier()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -561,7 +561,7 @@ public class ApplicationPackageManager extends PackageManager { mPM.updatePermissionFlags(permissionName, packageName, flagMask, flagValues, user.getIdentifier()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -571,7 +571,7 @@ public class ApplicationPackageManager extends PackageManager { return mPM.shouldShowRequestPermissionRationale(permission, mContext.getPackageName(), mContext.getUserId()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -580,7 +580,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.checkSignatures(pkg1, pkg2); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -589,7 +589,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.checkUidSignatures(uid1, uid2); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -598,7 +598,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.getPackagesForUid(uid); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -607,7 +607,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.getNameForUid(uid); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -620,7 +620,7 @@ public class ApplicationPackageManager extends PackageManager { return uid; } } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } throw new NameNotFoundException("No shared userid for user:"+sharedUserName); } @@ -638,7 +638,7 @@ public class ApplicationPackageManager extends PackageManager { ParceledListSlice slice = mPM.getInstalledPackages(flags, userId); return slice.getList(); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -652,7 +652,7 @@ public class ApplicationPackageManager extends PackageManager { permissions, flags, userId); return slice.getList(); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -664,7 +664,7 @@ public class ApplicationPackageManager extends PackageManager { ParceledListSlice slice = mPM.getInstalledApplications(flags, userId); return slice.getList(); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -680,7 +680,7 @@ public class ApplicationPackageManager extends PackageManager { } return Collections.emptyList(); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -695,7 +695,7 @@ public class ApplicationPackageManager extends PackageManager { } return null; } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -705,7 +705,7 @@ public class ApplicationPackageManager extends PackageManager { return mPM.isEphemeralApplication( mContext.getPackageName(), mContext.getUserId()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -727,7 +727,7 @@ public class ApplicationPackageManager extends PackageManager { return EmptyArray.BYTE; } } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -737,7 +737,7 @@ public class ApplicationPackageManager extends PackageManager { return mPM.setEphemeralApplicationCookie( mContext.getPackageName(), cookie, mContext.getUserId()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -755,7 +755,7 @@ public class ApplicationPackageManager extends PackageManager { flags, userId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -776,7 +776,7 @@ public class ApplicationPackageManager extends PackageManager { flags, userId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -808,7 +808,7 @@ public class ApplicationPackageManager extends PackageManager { specificTypes, intent, intent.resolveTypeIfNeeded(resolver), flags, mContext.getUserId()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -824,7 +824,7 @@ public class ApplicationPackageManager extends PackageManager { flags, userId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -842,7 +842,7 @@ public class ApplicationPackageManager extends PackageManager { flags, mContext.getUserId()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -855,7 +855,7 @@ public class ApplicationPackageManager extends PackageManager { flags, userId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -871,7 +871,7 @@ public class ApplicationPackageManager extends PackageManager { return mPM.queryIntentContentProviders(intent, intent.resolveTypeIfNeeded(mContext.getContentResolver()), flags, userId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -891,7 +891,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.resolveContentProvider(name, flags, userId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -903,7 +903,7 @@ public class ApplicationPackageManager extends PackageManager { = mPM.queryContentProviders(processName, uid, flags); return slice != null ? slice.getList() : null; } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -918,7 +918,7 @@ public class ApplicationPackageManager extends PackageManager { return ii; } } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } throw new NameNotFoundException(className.toString()); @@ -930,7 +930,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.queryInstrumentation(targetPackage, flags); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1197,7 +1197,7 @@ public class ApplicationPackageManager extends PackageManager { return getResourcesForApplication(ai); } } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } throw new NameNotFoundException("Package " + appPackageName + " doesn't exist"); } @@ -1212,7 +1212,7 @@ public class ApplicationPackageManager extends PackageManager { } return mCachedSafeMode != 0; } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1228,7 +1228,7 @@ public class ApplicationPackageManager extends PackageManager { mPM.addOnPermissionsChangeListener(delegate); mPermissionListeners.put(listener, delegate); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } } @@ -1242,7 +1242,7 @@ public class ApplicationPackageManager extends PackageManager { mPM.removeOnPermissionsChangeListener(delegate); mPermissionListeners.remove(listener); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } } @@ -1544,7 +1544,7 @@ public class ApplicationPackageManager extends PackageManager { mPM.installPackageAsUser(originPath, observer.getBinder(), flags, installerPackageName, verificationParams, null, userId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1563,7 +1563,7 @@ public class ApplicationPackageManager extends PackageManager { } return res; } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1572,7 +1572,7 @@ public class ApplicationPackageManager extends PackageManager { try { mPM.verifyPendingInstall(id, response); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1582,7 +1582,7 @@ public class ApplicationPackageManager extends PackageManager { try { mPM.extendVerificationTimeout(id, verificationCodeAtTimeout, millisecondsToDelay); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1591,7 +1591,7 @@ public class ApplicationPackageManager extends PackageManager { try { mPM.verifyIntentFilter(id, verificationCode, outFailedDomains); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1600,7 +1600,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.getIntentVerificationStatus(packageName, userId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1609,7 +1609,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.updateIntentVerificationStatus(packageName, status, userId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1618,7 +1618,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.getIntentFilterVerifications(packageName); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1627,7 +1627,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.getAllIntentFilters(packageName); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1636,7 +1636,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.getDefaultBrowserPackageName(userId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1645,7 +1645,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.setDefaultBrowserPackageName(packageName, userId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1655,7 +1655,7 @@ public class ApplicationPackageManager extends PackageManager { try { mPM.setInstallerPackageName(targetPackage, installerPackageName); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1664,7 +1664,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.getInstallerPackageName(packageName); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1673,7 +1673,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.getMoveStatus(moveId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1685,7 +1685,7 @@ public class ApplicationPackageManager extends PackageManager { try { mPM.registerMoveCallback(delegate); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } mDelegates.add(delegate); } @@ -1700,7 +1700,7 @@ public class ApplicationPackageManager extends PackageManager { try { mPM.unregisterMoveCallback(delegate); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } i.remove(); } @@ -1722,7 +1722,7 @@ public class ApplicationPackageManager extends PackageManager { return mPM.movePackage(packageName, volumeUuid); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1788,7 +1788,7 @@ public class ApplicationPackageManager extends PackageManager { return false; } } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } // Otherwise we can move to any private volume @@ -1809,7 +1809,7 @@ public class ApplicationPackageManager extends PackageManager { return mPM.movePrimaryStorage(volumeUuid); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1866,7 +1866,7 @@ public class ApplicationPackageManager extends PackageManager { try { mPM.deletePackageAsUser(packageName, observer, userId, flags); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1876,7 +1876,7 @@ public class ApplicationPackageManager extends PackageManager { try { mPM.clearApplicationUserData(packageName, observer, mContext.getUserId()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @Override @@ -1885,7 +1885,7 @@ public class ApplicationPackageManager extends PackageManager { try { mPM.deleteApplicationCacheFiles(packageName, observer); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1895,7 +1895,7 @@ public class ApplicationPackageManager extends PackageManager { try { mPM.freeStorageAndNotify(volumeUuid, idealStorageSize, observer); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1904,7 +1904,7 @@ public class ApplicationPackageManager extends PackageManager { try { mPM.freeStorage(volumeUuid, freeStorageSize, pi); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1914,7 +1914,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.setPackagesSuspendedAsUser(packageNames, suspended, userId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1923,7 +1923,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.isPackageSuspendedForUser(packageName, userId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1933,7 +1933,7 @@ public class ApplicationPackageManager extends PackageManager { try { mPM.getPackageSizeInfo(packageName, userHandle, observer); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @Override @@ -1941,7 +1941,7 @@ public class ApplicationPackageManager extends PackageManager { try { mPM.addPackageToPreferred(packageName); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1950,7 +1950,7 @@ public class ApplicationPackageManager extends PackageManager { try { mPM.removePackageFromPreferred(packageName); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1959,7 +1959,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.getPreferredPackages(flags); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1969,7 +1969,7 @@ public class ApplicationPackageManager extends PackageManager { try { mPM.addPreferredActivity(filter, match, set, activity, mContext.getUserId()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1979,7 +1979,7 @@ public class ApplicationPackageManager extends PackageManager { try { mPM.addPreferredActivity(filter, match, set, activity, userId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1989,7 +1989,7 @@ public class ApplicationPackageManager extends PackageManager { try { mPM.replacePreferredActivity(filter, match, set, activity, mContext.getUserId()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2000,7 +2000,7 @@ public class ApplicationPackageManager extends PackageManager { try { mPM.replacePreferredActivity(filter, match, set, activity, userId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2009,7 +2009,7 @@ public class ApplicationPackageManager extends PackageManager { try { mPM.clearPackagePreferredActivities(packageName); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2019,7 +2019,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.getPreferredActivities(outFilters, outActivities, packageName); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2028,7 +2028,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.getHomeActivities(outActivities); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2038,7 +2038,7 @@ public class ApplicationPackageManager extends PackageManager { try { mPM.setComponentEnabledSetting(componentName, newState, flags, mContext.getUserId()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2047,7 +2047,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.getComponentEnabledSetting(componentName, mContext.getUserId()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2058,7 +2058,7 @@ public class ApplicationPackageManager extends PackageManager { mPM.setApplicationEnabledSetting(packageName, newState, flags, mContext.getUserId(), mContext.getOpPackageName()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2067,7 +2067,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.getApplicationEnabledSetting(packageName, mContext.getUserId()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2078,7 +2078,7 @@ public class ApplicationPackageManager extends PackageManager { return mPM.setApplicationHiddenSettingAsUser(packageName, hidden, user.getIdentifier()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2087,7 +2087,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.getApplicationHiddenSettingAsUser(packageName, user.getIdentifier()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2099,7 +2099,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.getKeySetByAlias(packageName, alias); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2110,7 +2110,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.getSigningKeySet(packageName); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2122,7 +2122,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.isPackageSignedByKeySet(packageName, ks); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2134,7 +2134,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.isPackageSignedByKeySetExactly(packageName, ks); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2146,7 +2146,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.getVerifierDeviceIdentity(); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2158,7 +2158,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.isUpgrade(); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2170,7 +2170,7 @@ public class ApplicationPackageManager extends PackageManager { mInstaller = new PackageInstaller(mContext, this, mPM.getPackageInstaller(), mContext.getPackageName(), mContext.getUserId()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } return mInstaller; @@ -2182,7 +2182,7 @@ public class ApplicationPackageManager extends PackageManager { try { return mPM.isPackageAvailable(packageName, mContext.getUserId()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2196,7 +2196,7 @@ public class ApplicationPackageManager extends PackageManager { mPM.addCrossProfileIntentFilter(filter, mContext.getOpPackageName(), sourceUserId, targetUserId, flags); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -2208,7 +2208,7 @@ public class ApplicationPackageManager extends PackageManager { try { mPM.clearCrossProfileIntentFilters(sourceUserId, mContext.getOpPackageName()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index 8884949f361cf..47eec8bbfbfdd 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -813,7 +813,7 @@ class ContextImpl extends Context { null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, options, user.getIdentifier()); } catch (RemoteException e) { - throw new RuntimeException("Failure from system", e); + throw e.rethrowFromSystemServer(); } } @@ -878,7 +878,7 @@ class ContextImpl extends Context { } Instrumentation.checkStartActivityResult(result, null); } catch (RemoteException e) { - throw new RuntimeException("Failure from system", e); + throw e.rethrowFromSystemServer(); } } @@ -893,7 +893,7 @@ class ContextImpl extends Context { Activity.RESULT_OK, null, null, null, AppOpsManager.OP_NONE, null, false, false, getUserId()); } catch (RemoteException e) { - throw new RuntimeException("Failure from system", e); + throw e.rethrowFromSystemServer(); } } @@ -910,7 +910,7 @@ class ContextImpl extends Context { Activity.RESULT_OK, null, null, receiverPermissions, AppOpsManager.OP_NONE, null, false, false, getUserId()); } catch (RemoteException e) { - throw new RuntimeException("Failure from system", e); + throw e.rethrowFromSystemServer(); } } @@ -925,7 +925,7 @@ class ContextImpl extends Context { Activity.RESULT_OK, null, null, receiverPermissions, AppOpsManager.OP_NONE, null, false, false, getUserId()); } catch (RemoteException e) { - throw new RuntimeException("Failure from system", e); + throw e.rethrowFromSystemServer(); } } @@ -942,7 +942,7 @@ class ContextImpl extends Context { Activity.RESULT_OK, null, null, receiverPermissions, AppOpsManager.OP_NONE, options, false, false, getUserId()); } catch (RemoteException e) { - throw new RuntimeException("Failure from system", e); + throw e.rethrowFromSystemServer(); } } @@ -959,7 +959,7 @@ class ContextImpl extends Context { Activity.RESULT_OK, null, null, receiverPermissions, appOp, null, false, false, getUserId()); } catch (RemoteException e) { - throw new RuntimeException("Failure from system", e); + throw e.rethrowFromSystemServer(); } } @@ -976,7 +976,7 @@ class ContextImpl extends Context { Activity.RESULT_OK, null, null, receiverPermissions, AppOpsManager.OP_NONE, null, true, false, getUserId()); } catch (RemoteException e) { - throw new RuntimeException("Failure from system", e); + throw e.rethrowFromSystemServer(); } } @@ -1039,7 +1039,7 @@ class ContextImpl extends Context { initialCode, initialData, initialExtras, receiverPermissions, appOp, options, true, false, getUserId()); } catch (RemoteException e) { - throw new RuntimeException("Failure from system", e); + throw e.rethrowFromSystemServer(); } } @@ -1052,7 +1052,7 @@ class ContextImpl extends Context { intent, resolvedType, null, Activity.RESULT_OK, null, null, null, AppOpsManager.OP_NONE, null, false, false, user.getIdentifier()); } catch (RemoteException e) { - throw new RuntimeException("Failure from system", e); + throw e.rethrowFromSystemServer(); } } @@ -1075,7 +1075,7 @@ class ContextImpl extends Context { Activity.RESULT_OK, null, null, receiverPermissions, appOp, null, false, false, user.getIdentifier()); } catch (RemoteException e) { - throw new RuntimeException("Failure from system", e); + throw e.rethrowFromSystemServer(); } } @@ -1126,7 +1126,7 @@ class ContextImpl extends Context { initialCode, initialData, initialExtras, receiverPermissions, appOp, options, true, false, user.getIdentifier()); } catch (RemoteException e) { - throw new RuntimeException("Failure from system", e); + throw e.rethrowFromSystemServer(); } } @@ -1142,7 +1142,7 @@ class ContextImpl extends Context { Activity.RESULT_OK, null, null, null, AppOpsManager.OP_NONE, null, false, true, getUserId()); } catch (RemoteException e) { - throw new RuntimeException("Failure from system", e); + throw e.rethrowFromSystemServer(); } } @@ -1178,7 +1178,7 @@ class ContextImpl extends Context { initialCode, initialData, initialExtras, null, AppOpsManager.OP_NONE, null, true, true, getUserId()); } catch (RemoteException e) { - throw new RuntimeException("Failure from system", e); + throw e.rethrowFromSystemServer(); } } @@ -1195,7 +1195,7 @@ class ContextImpl extends Context { ActivityManagerNative.getDefault().unbroadcastIntent( mMainThread.getApplicationThread(), intent, getUserId()); } catch (RemoteException e) { - throw new RuntimeException("Failure from system", e); + throw e.rethrowFromSystemServer(); } } @@ -1210,7 +1210,7 @@ class ContextImpl extends Context { Activity.RESULT_OK, null, null, null, AppOpsManager.OP_NONE, null, false, true, user.getIdentifier()); } catch (RemoteException e) { - throw new RuntimeException("Failure from system", e); + throw e.rethrowFromSystemServer(); } } @@ -1225,7 +1225,7 @@ class ContextImpl extends Context { Activity.RESULT_OK, null, null, null, AppOpsManager.OP_NONE, options, false, true, user.getIdentifier()); } catch (RemoteException e) { - throw new RuntimeException("Failure from system", e); + throw e.rethrowFromSystemServer(); } } @@ -1260,7 +1260,7 @@ class ContextImpl extends Context { initialCode, initialData, initialExtras, null, AppOpsManager.OP_NONE, null, true, true, user.getIdentifier()); } catch (RemoteException e) { - throw new RuntimeException("Failure from system", e); + throw e.rethrowFromSystemServer(); } } @@ -1277,7 +1277,7 @@ class ContextImpl extends Context { ActivityManagerNative.getDefault().unbroadcastIntent( mMainThread.getApplicationThread(), intent, user.getIdentifier()); } catch (RemoteException e) { - throw new RuntimeException("Failure from system", e); + throw e.rethrowFromSystemServer(); } } @@ -1325,7 +1325,7 @@ class ContextImpl extends Context { mMainThread.getApplicationThread(), mBasePackageName, rd, filter, broadcastPermission, userId); } catch (RemoteException e) { - return null; + throw e.rethrowFromSystemServer(); } } @@ -1337,6 +1337,7 @@ class ContextImpl extends Context { try { ActivityManagerNative.getDefault().unregisterReceiver(rd); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } else { throw new RuntimeException("Not supported in system context"); @@ -1393,7 +1394,7 @@ class ContextImpl extends Context { } return cn; } catch (RemoteException e) { - throw new RuntimeException("Failure from system", e); + throw e.rethrowFromSystemServer(); } } @@ -1415,7 +1416,7 @@ class ContextImpl extends Context { } return res != 0; } catch (RemoteException e) { - throw new RuntimeException("Failure from system", e); + throw e.rethrowFromSystemServer(); } } @@ -1474,7 +1475,7 @@ class ContextImpl extends Context { } return res != 0; } catch (RemoteException e) { - throw new RuntimeException("Failure from system", e); + throw e.rethrowFromSystemServer(); } } @@ -1489,6 +1490,7 @@ class ContextImpl extends Context { try { ActivityManagerNative.getDefault().unbindService(sd); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } else { throw new RuntimeException("Not supported in system context"); @@ -1506,7 +1508,7 @@ class ContextImpl extends Context { className, profileFile, 0, arguments, null, null, getUserId(), null /* ABI override */); } catch (RemoteException e) { - throw new RuntimeException("Failure from system", e); + throw e.rethrowFromSystemServer(); } } @@ -1530,7 +1532,7 @@ class ContextImpl extends Context { return ActivityManagerNative.getDefault().checkPermission( permission, pid, uid); } catch (RemoteException e) { - return PackageManager.PERMISSION_DENIED; + throw e.rethrowFromSystemServer(); } } @@ -1545,7 +1547,7 @@ class ContextImpl extends Context { return ActivityManagerNative.getDefault().checkPermissionWithToken( permission, pid, uid, callerToken); } catch (RemoteException e) { - return PackageManager.PERMISSION_DENIED; + throw e.rethrowFromSystemServer(); } } @@ -1631,6 +1633,7 @@ class ContextImpl extends Context { mMainThread.getApplicationThread(), toPackage, ContentProvider.getUriWithoutUserId(uri), modeFlags, resolveUserId(uri)); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -1641,6 +1644,7 @@ class ContextImpl extends Context { mMainThread.getApplicationThread(), ContentProvider.getUriWithoutUserId(uri), modeFlags, resolveUserId(uri)); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -1651,7 +1655,7 @@ class ContextImpl extends Context { ContentProvider.getUriWithoutUserId(uri), pid, uid, modeFlags, resolveUserId(uri), null); } catch (RemoteException e) { - return PackageManager.PERMISSION_DENIED; + throw e.rethrowFromSystemServer(); } } @@ -1663,7 +1667,7 @@ class ContextImpl extends Context { ContentProvider.getUriWithoutUserId(uri), pid, uid, modeFlags, resolveUserId(uri), callerToken); } catch (RemoteException e) { - return PackageManager.PERMISSION_DENIED; + throw e.rethrowFromSystemServer(); } } diff --git a/core/java/android/app/LoadedApk.java b/core/java/android/app/LoadedApk.java index 838b8cbc0c337..ae433eb5be02a 100644 --- a/core/java/android/app/LoadedApk.java +++ b/core/java/android/app/LoadedApk.java @@ -252,7 +252,7 @@ public final class LoadedApk { ai = ActivityThread.getPackageManager().getApplicationInfo(packageName, PackageManager.GET_SHARED_LIBRARY_FILES, UserHandle.myUserId()); } catch (RemoteException e) { - throw new AssertionError(e); + throw e.rethrowFromSystemServer(); } if (ai == null) { @@ -285,7 +285,7 @@ public final class LoadedApk { try { ActivityThread.getPackageManager().notifyPackageUse(mPackageName); } catch (RemoteException re) { - // Ignored. + throw re.rethrowFromSystemServer(); } } @@ -297,6 +297,7 @@ public final class LoadedApk { try { ActivityManagerNative.getDefault().addPackageDependency(mPackageName); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -452,8 +453,7 @@ public final class LoadedApk { pi = pm.getPackageInfo(mPackageName, PackageManager.MATCH_DEBUG_TRIAGED_MISSING, UserHandle.myUserId()); } catch (RemoteException e) { - throw new IllegalStateException("Unable to get package info for " - + mPackageName + "; is system dying?", e); + throw e.rethrowFromSystemServer(); } if (pi == null) { throw new IllegalStateException("Unable to get package info for " @@ -710,7 +710,7 @@ public final class LoadedApk { ActivityManagerNative.getDefault().unregisterReceiver( rd.getIIntentReceiver()); } catch (RemoteException e) { - // system crashed, nothing we can do + throw e.rethrowFromSystemServer(); } } } @@ -736,7 +736,7 @@ public final class LoadedApk { ActivityManagerNative.getDefault().unbindService( sd.getIServiceConnection()); } catch (RemoteException e) { - // system crashed, nothing we can do + throw e.rethrowFromSystemServer(); } sd.doForget(); } @@ -861,7 +861,7 @@ public final class LoadedApk { } mgr.finishReceiver(this, resultCode, data, extras, false, intent.getFlags()); } catch (RemoteException e) { - Slog.w(ActivityThread.TAG, "Couldn't finish broadcast to unregistered receiver"); + throw e.rethrowFromSystemServer(); } } } diff --git a/core/java/android/app/NotificationManager.java b/core/java/android/app/NotificationManager.java index eb928af05b1d4..344315d5266f3 100644 --- a/core/java/android/app/NotificationManager.java +++ b/core/java/android/app/NotificationManager.java @@ -264,6 +264,7 @@ public class NotificationManager Log.w(TAG, "notify: id corrupted: sent " + id + ", got back " + idOut[0]); } } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -304,6 +305,7 @@ public class NotificationManager try { service.cancelNotificationWithTag(pkg, tag, id, user.getIdentifier()); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -319,6 +321,7 @@ public class NotificationManager try { service.cancelAllNotifications(pkg, UserHandle.myUserId()); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -330,7 +333,7 @@ public class NotificationManager try { return service.getEffectsSuppressor(); } catch (RemoteException e) { - return null; + throw e.rethrowFromSystemServer(); } } @@ -342,7 +345,7 @@ public class NotificationManager try { return service.matchesCallFilter(extras); } catch (RemoteException e) { - return false; + throw e.rethrowFromSystemServer(); } } @@ -354,7 +357,7 @@ public class NotificationManager try { return service.isSystemConditionProviderEnabled(path); } catch (RemoteException e) { - return false; + throw e.rethrowFromSystemServer(); } } @@ -366,6 +369,7 @@ public class NotificationManager try { service.setZenMode(mode, conditionId, reason); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -377,8 +381,8 @@ public class NotificationManager try { return service.getZenMode(); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } - return Global.ZEN_MODE_OFF; } /** @@ -389,8 +393,8 @@ public class NotificationManager try { return service.getZenModeConfig(); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } - return null; } /** @@ -401,8 +405,8 @@ public class NotificationManager try { return service.getRuleInstanceCount(owner); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } - return 0; } /** @@ -417,8 +421,8 @@ public class NotificationManager try { return service.getAutomaticZenRules(); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } - return null; } /** @@ -437,8 +441,8 @@ public class NotificationManager try { return service.getAutomaticZenRule(id); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } - return null; } /** @@ -457,8 +461,8 @@ public class NotificationManager try { return service.addAutomaticZenRule(automaticZenRule); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } - return null; } /** @@ -478,8 +482,8 @@ public class NotificationManager try { return service.updateAutomaticZenRule(automaticZenRule); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } - return false; } /** @@ -499,8 +503,8 @@ public class NotificationManager try { return service.removeAutomaticZenRule(id); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } - return false; } /** @@ -513,8 +517,8 @@ public class NotificationManager try { return service.removeAutomaticZenRules(packageName); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } - return false; } /** @@ -525,8 +529,8 @@ public class NotificationManager try { return service.getPackageImportance(mContext.getPackageName()); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } - return NotificationListenerService.Ranking.IMPORTANCE_UNSPECIFIED; } /** @@ -537,8 +541,8 @@ public class NotificationManager try { return service.areNotificationsEnabled(mContext.getPackageName()); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } - return false; } /** @@ -560,8 +564,8 @@ public class NotificationManager try { return service.isNotificationPolicyAccessGranted(mContext.getOpPackageName()); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } - return false; } /** @hide */ @@ -570,8 +574,8 @@ public class NotificationManager try { return service.isNotificationPolicyAccessGrantedForPackage(pkg); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } - return false; } /** @@ -586,8 +590,8 @@ public class NotificationManager try { return service.getNotificationPolicy(mContext.getOpPackageName()); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } - return null; } /** @@ -605,6 +609,7 @@ public class NotificationManager try { service.setNotificationPolicy(mContext.getOpPackageName(), policy); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -614,6 +619,7 @@ public class NotificationManager try { service.setNotificationPolicyAccessGranted(pkg, granted); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -630,8 +636,9 @@ public class NotificationManager return rt; } } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } - return new ArraySet(); + return new ArraySet<>(); } private Context mContext; diff --git a/core/java/android/app/trust/TrustManager.java b/core/java/android/app/trust/TrustManager.java index 999d8260cad39..0f5cb6f4b8e1f 100644 --- a/core/java/android/app/trust/TrustManager.java +++ b/core/java/android/app/trust/TrustManager.java @@ -16,8 +16,6 @@ package android.app.trust; -import com.android.internal.widget.LockPatternUtils; - import android.Manifest; import android.annotation.RequiresPermission; import android.os.Handler; @@ -26,7 +24,8 @@ import android.os.Looper; import android.os.Message; import android.os.RemoteException; import android.util.ArrayMap; -import android.util.Log; + +import com.android.internal.widget.LockPatternUtils; /** * See {@link com.android.server.trust.TrustManagerService} @@ -62,7 +61,7 @@ public class TrustManager { try { mService.setDeviceLockedForUser(userId, locked); } catch (RemoteException e) { - onError(e); + throw e.rethrowFromSystemServer(); } } @@ -77,7 +76,7 @@ public class TrustManager { try { mService.reportUnlockAttempt(successful, userId); } catch (RemoteException e) { - onError(e); + throw e.rethrowFromSystemServer(); } } @@ -90,7 +89,7 @@ public class TrustManager { try { mService.reportEnabledTrustAgentsChanged(userId); } catch (RemoteException e) { - onError(e); + throw e.rethrowFromSystemServer(); } } @@ -103,7 +102,7 @@ public class TrustManager { try { mService.reportKeyguardShowingChanged(); } catch (RemoteException e) { - onError(e); + throw e.rethrowFromSystemServer(); } } @@ -134,7 +133,7 @@ public class TrustManager { mService.registerTrustListener(iTrustListener); mTrustListeners.put(trustListener, iTrustListener); } catch (RemoteException e) { - onError(e); + throw e.rethrowFromSystemServer(); } } @@ -149,7 +148,7 @@ public class TrustManager { try { mService.unregisterTrustListener(iTrustListener); } catch (RemoteException e) { - onError(e); + throw e.rethrowFromSystemServer(); } } } @@ -163,16 +162,10 @@ public class TrustManager { try { return mService.isTrustUsuallyManaged(userId); } catch (RemoteException e) { - return false; + throw e.rethrowFromSystemServer(); } } - - - private void onError(Exception e) { - Log.e(TAG, "Error while calling TrustManagerService", e); - } - private final Handler mHandler = new Handler(Looper.getMainLooper()) { @Override public void handleMessage(Message msg) { diff --git a/core/java/android/appwidget/AppWidgetManager.java b/core/java/android/appwidget/AppWidgetManager.java index 278c9d6f86999..9f654c25e2c5f 100644 --- a/core/java/android/appwidget/AppWidgetManager.java +++ b/core/java/android/appwidget/AppWidgetManager.java @@ -472,9 +472,8 @@ public class AppWidgetManager { } try { mService.updateAppWidgetIds(mPackageName, appWidgetIds, views); - } - catch (RemoteException e) { - throw new RuntimeException("system server dead?", e); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -495,9 +494,8 @@ public class AppWidgetManager { } try { mService.updateAppWidgetOptions(mPackageName, appWidgetId, options); - } - catch (RemoteException e) { - throw new RuntimeException("system server dead?", e); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -518,9 +516,8 @@ public class AppWidgetManager { } try { return mService.getAppWidgetOptions(mPackageName, appWidgetId); - } - catch (RemoteException e) { - throw new RuntimeException("system server dead?", e); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -581,7 +578,7 @@ public class AppWidgetManager { try { mService.partiallyUpdateAppWidgetIds(mPackageName, appWidgetIds, views); } catch (RemoteException e) { - throw new RuntimeException("system server dead?", e); + throw e.rethrowFromSystemServer(); } } @@ -635,9 +632,8 @@ public class AppWidgetManager { } try { mService.updateAppWidgetProvider(provider, views); - } - catch (RemoteException e) { - throw new RuntimeException("system server dead?", e); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -654,9 +650,8 @@ public class AppWidgetManager { } try { mService.notifyAppWidgetViewDataChanged(mPackageName, appWidgetIds, viewId); - } - catch (RemoteException e) { - throw new RuntimeException("system server dead?", e); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -764,9 +759,8 @@ public class AppWidgetManager { convertSizesToPixels(info); } return providers.getList(); - } - catch (RemoteException e) { - throw new RuntimeException("system server dead?", e); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -787,9 +781,8 @@ public class AppWidgetManager { convertSizesToPixels(info); } return info; - } - catch (RemoteException e) { - throw new RuntimeException("system server dead?", e); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -918,9 +911,8 @@ public class AppWidgetManager { } try { return mService.hasBindAppWidgetPermission(packageName, userId); - } - catch (RemoteException e) { - throw new RuntimeException("system server dead?", e); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -939,9 +931,8 @@ public class AppWidgetManager { } try { return mService.hasBindAppWidgetPermission(packageName, UserHandle.myUserId()); - } - catch (RemoteException e) { - throw new RuntimeException("system server dead?", e); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -979,9 +970,8 @@ public class AppWidgetManager { } try { mService.setBindAppWidgetPermission(packageName, userId, permission); - } - catch (RemoteException e) { - throw new RuntimeException("system server dead?", e); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -1005,9 +995,8 @@ public class AppWidgetManager { } try { mService.bindRemoteViewsService(packageName, appWidgetId, intent, connection); - } - catch (RemoteException e) { - throw new RuntimeException("system server dead?", e); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -1029,9 +1018,8 @@ public class AppWidgetManager { } try { mService.unbindRemoteViewsService(packageName, appWidgetId, intent); - } - catch (RemoteException e) { - throw new RuntimeException("system server dead?", e); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -1048,9 +1036,8 @@ public class AppWidgetManager { } try { return mService.getAppWidgetIds(provider); - } - catch (RemoteException e) { - throw new RuntimeException("system server dead?", e); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -1063,8 +1050,8 @@ public class AppWidgetManager { } try { return mService.isBoundWidgetPackage(packageName, userId); - } catch (RemoteException re) { - throw new RuntimeException("system server dead?", re); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -1076,9 +1063,8 @@ public class AppWidgetManager { try { return mService.bindAppWidgetId(mPackageName, appWidgetId, profileId, provider, options); - } - catch (RemoteException e) { - throw new RuntimeException("system server dead?", e); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } diff --git a/core/java/android/content/ClipboardManager.java b/core/java/android/content/ClipboardManager.java index e67da2bfe7f85..1266f73a2f448 100644 --- a/core/java/android/content/ClipboardManager.java +++ b/core/java/android/content/ClipboardManager.java @@ -122,6 +122,7 @@ public class ClipboardManager extends android.text.ClipboardManager { } getService().setPrimaryClip(clip, mContext.getOpPackageName()); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -132,7 +133,7 @@ public class ClipboardManager extends android.text.ClipboardManager { try { return getService().getPrimaryClip(mContext.getOpPackageName()); } catch (RemoteException e) { - return null; + throw e.rethrowFromSystemServer(); } } @@ -144,7 +145,7 @@ public class ClipboardManager extends android.text.ClipboardManager { try { return getService().getPrimaryClipDescription(mContext.getOpPackageName()); } catch (RemoteException e) { - return null; + throw e.rethrowFromSystemServer(); } } @@ -155,7 +156,7 @@ public class ClipboardManager extends android.text.ClipboardManager { try { return getService().hasPrimaryClip(mContext.getOpPackageName()); } catch (RemoteException e) { - return false; + throw e.rethrowFromSystemServer(); } } @@ -166,6 +167,7 @@ public class ClipboardManager extends android.text.ClipboardManager { getService().addPrimaryClipChangedListener( mPrimaryClipChangedServiceListener, mContext.getOpPackageName()); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } mPrimaryClipChangedListeners.add(what); @@ -180,6 +182,7 @@ public class ClipboardManager extends android.text.ClipboardManager { getService().removePrimaryClipChangedListener( mPrimaryClipChangedServiceListener); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } } @@ -213,7 +216,7 @@ public class ClipboardManager extends android.text.ClipboardManager { try { return getService().hasClipboardText(mContext.getOpPackageName()); } catch (RemoteException e) { - return false; + throw e.rethrowFromSystemServer(); } } diff --git a/core/java/android/content/RestrictionsManager.java b/core/java/android/content/RestrictionsManager.java index a7744e7a1208d..6893067e060b3 100644 --- a/core/java/android/content/RestrictionsManager.java +++ b/core/java/android/content/RestrictionsManager.java @@ -422,7 +422,7 @@ public class RestrictionsManager { return mService.getApplicationRestrictions(mContext.getPackageName()); } } catch (RemoteException re) { - Log.w(TAG, "Couldn't reach service"); + throw re.rethrowFromSystemServer(); } return null; } @@ -439,7 +439,7 @@ public class RestrictionsManager { return mService.hasRestrictionsProvider(); } } catch (RemoteException re) { - Log.w(TAG, "Couldn't reach service"); + throw re.rethrowFromSystemServer(); } return false; } @@ -477,7 +477,7 @@ public class RestrictionsManager { request); } } catch (RemoteException re) { - Log.w(TAG, "Couldn't reach service"); + throw re.rethrowFromSystemServer(); } } @@ -487,7 +487,7 @@ public class RestrictionsManager { return mService.createLocalApprovalIntent(); } } catch (RemoteException re) { - Log.w(TAG, "Couldn't reach service"); + throw re.rethrowFromSystemServer(); } return null; } @@ -519,7 +519,7 @@ public class RestrictionsManager { mService.notifyPermissionResponse(packageName, response); } } catch (RemoteException re) { - Log.w(TAG, "Couldn't reach service"); + throw re.rethrowFromSystemServer(); } } diff --git a/core/java/android/content/pm/LauncherApps.java b/core/java/android/content/pm/LauncherApps.java index 8c7d327720a37..e443d5073c549 100644 --- a/core/java/android/content/pm/LauncherApps.java +++ b/core/java/android/content/pm/LauncherApps.java @@ -171,7 +171,7 @@ public class LauncherApps { try { activities = mService.getLauncherActivities(packageName, user); } catch (RemoteException re) { - throw new RuntimeException("Failed to call LauncherAppsService", re); + throw re.rethrowFromSystemServer(); } if (activities == null) { return Collections.EMPTY_LIST; @@ -208,7 +208,7 @@ public class LauncherApps { return info; } } catch (RemoteException re) { - throw new RuntimeException("Failed to call LauncherAppsService", re); + throw re.rethrowFromSystemServer(); } return null; } @@ -229,7 +229,7 @@ public class LauncherApps { try { mService.startActivityAsUser(component, sourceBounds, opts, user); } catch (RemoteException re) { - // Oops! + throw re.rethrowFromSystemServer(); } } @@ -247,7 +247,7 @@ public class LauncherApps { try { mService.showAppDetailsAsUser(component, sourceBounds, opts, user); } catch (RemoteException re) { - // Oops! + throw re.rethrowFromSystemServer(); } } @@ -263,7 +263,7 @@ public class LauncherApps { try { return mService.isPackageEnabled(packageName, user); } catch (RemoteException re) { - throw new RuntimeException("Failed to call LauncherAppsService", re); + throw re.rethrowFromSystemServer(); } } @@ -282,7 +282,7 @@ public class LauncherApps { try { return mService.getApplicationInfo(packageName, flags, user); } catch (RemoteException re) { - throw new RuntimeException("Failed to call LauncherAppsService", re); + throw re.rethrowFromSystemServer(); } } @@ -298,7 +298,7 @@ public class LauncherApps { try { return mService.isActivityEnabled(component, user); } catch (RemoteException re) { - throw new RuntimeException("Failed to call LauncherAppsService", re); + throw re.rethrowFromSystemServer(); } } @@ -327,6 +327,7 @@ public class LauncherApps { try { mService.addOnAppsChangedListener(mAppsChangedListener); } catch (RemoteException re) { + throw re.rethrowFromSystemServer(); } } } @@ -346,6 +347,7 @@ public class LauncherApps { try { mService.removeOnAppsChangedListener(mAppsChangedListener); } catch (RemoteException re) { + throw re.rethrowFromSystemServer(); } } } diff --git a/core/java/android/content/pm/PackageInstaller.java b/core/java/android/content/pm/PackageInstaller.java index 32830053fae2d..2cbb7825ec80e 100644 --- a/core/java/android/content/pm/PackageInstaller.java +++ b/core/java/android/content/pm/PackageInstaller.java @@ -301,7 +301,7 @@ public class PackageInstaller { ExceptionUtils.maybeUnwrapIOException(e); throw e; } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -321,7 +321,7 @@ public class PackageInstaller { ExceptionUtils.maybeUnwrapIOException(e); throw e; } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -337,7 +337,7 @@ public class PackageInstaller { try { mInstaller.updateSessionAppIcon(sessionId, appIcon); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -353,7 +353,7 @@ public class PackageInstaller { final String val = (appLabel != null) ? appLabel.toString() : null; mInstaller.updateSessionAppLabel(sessionId, val); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -370,7 +370,7 @@ public class PackageInstaller { try { mInstaller.abandonSession(sessionId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -385,7 +385,7 @@ public class PackageInstaller { try { return mInstaller.getSessionInfo(sessionId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -403,7 +403,7 @@ public class PackageInstaller { try { return mInstaller.getAllSessions(mUserId).getList(); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -414,7 +414,7 @@ public class PackageInstaller { try { return mInstaller.getMySessions(mInstallerPackageName, mUserId).getList(); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -427,7 +427,7 @@ public class PackageInstaller { try { mInstaller.uninstall(packageName, mInstallerPackageName, 0, statusReceiver, mUserId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -436,7 +436,7 @@ public class PackageInstaller { try { mInstaller.setPermissionsResult(sessionId, accepted); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -611,7 +611,7 @@ public class PackageInstaller { try { mInstaller.registerCallback(delegate, mUserId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } mDelegates.add(delegate); } @@ -634,7 +634,7 @@ public class PackageInstaller { try { mInstaller.unregisterCallback(delegate); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } i.remove(); } @@ -681,7 +681,7 @@ public class PackageInstaller { try { mSession.setClientProgress(progress); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -690,7 +690,7 @@ public class PackageInstaller { try { mSession.addClientProgress(progress); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -734,7 +734,7 @@ public class PackageInstaller { ExceptionUtils.maybeUnwrapIOException(e); throw e; } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -767,7 +767,7 @@ public class PackageInstaller { ExceptionUtils.maybeUnwrapIOException(e); throw e; } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -790,7 +790,7 @@ public class PackageInstaller { ExceptionUtils.maybeUnwrapIOException(e); throw e; } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -810,7 +810,7 @@ public class PackageInstaller { try { mSession.commit(statusReceiver); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -823,7 +823,7 @@ public class PackageInstaller { try { mSession.close(); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -837,7 +837,7 @@ public class PackageInstaller { try { mSession.abandon(); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } } diff --git a/core/java/android/hardware/display/DisplayManagerGlobal.java b/core/java/android/hardware/display/DisplayManagerGlobal.java index 121a187b3639f..93da3e5af4e94 100644 --- a/core/java/android/hardware/display/DisplayManagerGlobal.java +++ b/core/java/android/hardware/display/DisplayManagerGlobal.java @@ -132,8 +132,7 @@ public final class DisplayManagerGlobal { return info; } } catch (RemoteException ex) { - Log.e(TAG, "Could not get display information from display manager.", ex); - return null; + throw ex.rethrowFromSystemServer(); } } @@ -159,8 +158,7 @@ public final class DisplayManagerGlobal { return displayIds; } } catch (RemoteException ex) { - Log.e(TAG, "Could not get display ids from display manager.", ex); - return new int[] { Display.DEFAULT_DISPLAY }; + throw ex.rethrowFromSystemServer(); } } @@ -237,8 +235,7 @@ public final class DisplayManagerGlobal { try { mDm.registerCallback(mCallback); } catch (RemoteException ex) { - Log.e(TAG, "Failed to register callback with display manager service.", ex); - mCallback = null; + throw ex.rethrowFromSystemServer(); } } } @@ -267,7 +264,7 @@ public final class DisplayManagerGlobal { try { mDm.startWifiDisplayScan(); } catch (RemoteException ex) { - Log.e(TAG, "Failed to scan for Wifi displays.", ex); + throw ex.rethrowFromSystemServer(); } } } @@ -279,7 +276,7 @@ public final class DisplayManagerGlobal { try { mDm.stopWifiDisplayScan(); } catch (RemoteException ex) { - Log.e(TAG, "Failed to scan for Wifi displays.", ex); + throw ex.rethrowFromSystemServer(); } } else if (mWifiDisplayScanNestCount < 0) { Log.wtf(TAG, "Wifi display scan nest count became negative: " @@ -297,7 +294,7 @@ public final class DisplayManagerGlobal { try { mDm.connectWifiDisplay(deviceAddress); } catch (RemoteException ex) { - Log.e(TAG, "Failed to connect to Wifi display " + deviceAddress + ".", ex); + throw ex.rethrowFromSystemServer(); } } @@ -305,7 +302,7 @@ public final class DisplayManagerGlobal { try { mDm.pauseWifiDisplay(); } catch (RemoteException ex) { - Log.e(TAG, "Failed to pause Wifi display.", ex); + throw ex.rethrowFromSystemServer(); } } @@ -313,7 +310,7 @@ public final class DisplayManagerGlobal { try { mDm.resumeWifiDisplay(); } catch (RemoteException ex) { - Log.e(TAG, "Failed to resume Wifi display.", ex); + throw ex.rethrowFromSystemServer(); } } @@ -321,7 +318,7 @@ public final class DisplayManagerGlobal { try { mDm.disconnectWifiDisplay(); } catch (RemoteException ex) { - Log.e(TAG, "Failed to disconnect from Wifi display.", ex); + throw ex.rethrowFromSystemServer(); } } @@ -333,8 +330,7 @@ public final class DisplayManagerGlobal { try { mDm.renameWifiDisplay(deviceAddress, alias); } catch (RemoteException ex) { - Log.e(TAG, "Failed to rename Wifi display " + deviceAddress - + " with alias " + alias + ".", ex); + throw ex.rethrowFromSystemServer(); } } @@ -346,7 +342,7 @@ public final class DisplayManagerGlobal { try { mDm.forgetWifiDisplay(deviceAddress); } catch (RemoteException ex) { - Log.e(TAG, "Failed to forget Wifi display.", ex); + throw ex.rethrowFromSystemServer(); } } @@ -354,8 +350,7 @@ public final class DisplayManagerGlobal { try { return mDm.getWifiDisplayStatus(); } catch (RemoteException ex) { - Log.e(TAG, "Failed to get Wifi display status.", ex); - return new WifiDisplayStatus(); + throw ex.rethrowFromSystemServer(); } } @@ -363,7 +358,7 @@ public final class DisplayManagerGlobal { try { mDm.requestColorTransform(displayId, colorTransformId); } catch (RemoteException ex) { - Log.e(TAG, "Failed to request color transform.", ex); + throw ex.rethrowFromSystemServer(); } } @@ -385,8 +380,7 @@ public final class DisplayManagerGlobal { displayId = mDm.createVirtualDisplay(callbackWrapper, projectionToken, context.getPackageName(), name, width, height, densityDpi, surface, flags); } catch (RemoteException ex) { - Log.e(TAG, "Could not create virtual display: " + name, ex); - return null; + throw ex.rethrowFromSystemServer(); } if (displayId < 0) { Log.e(TAG, "Could not create virtual display: " + name); @@ -399,6 +393,7 @@ public final class DisplayManagerGlobal { try { mDm.releaseVirtualDisplay(callbackWrapper); } catch (RemoteException ex) { + throw ex.rethrowFromSystemServer(); } return null; } @@ -409,7 +404,7 @@ public final class DisplayManagerGlobal { try { mDm.setVirtualDisplaySurface(token, surface); } catch (RemoteException ex) { - Log.w(TAG, "Failed to set virtual display surface.", ex); + throw ex.rethrowFromSystemServer(); } } @@ -418,7 +413,7 @@ public final class DisplayManagerGlobal { try { mDm.resizeVirtualDisplay(token, width, height, densityDpi); } catch (RemoteException ex) { - Log.w(TAG, "Failed to resize virtual display.", ex); + throw ex.rethrowFromSystemServer(); } } @@ -426,7 +421,7 @@ public final class DisplayManagerGlobal { try { mDm.releaseVirtualDisplay(token); } catch (RemoteException ex) { - Log.w(TAG, "Failed to release virtual display.", ex); + throw ex.rethrowFromSystemServer(); } } diff --git a/core/java/android/hardware/usb/UsbManager.java b/core/java/android/hardware/usb/UsbManager.java index 1e3bcd0fc796a..3792e5c03756f 100644 --- a/core/java/android/hardware/usb/UsbManager.java +++ b/core/java/android/hardware/usb/UsbManager.java @@ -302,8 +302,7 @@ public class UsbManager { } return result; } catch (RemoteException e) { - Log.e(TAG, "RemoteException in getDeviceList", e); - return null; + throw e.rethrowFromSystemServer(); } } @@ -347,8 +346,7 @@ public class UsbManager { return new UsbAccessory[] { accessory }; } } catch (RemoteException e) { - Log.e(TAG, "RemoteException in getAccessoryList", e); - return null; + throw e.rethrowFromSystemServer(); } } @@ -362,8 +360,7 @@ public class UsbManager { try { return mService.openAccessory(accessory); } catch (RemoteException e) { - Log.e(TAG, "RemoteException in openAccessory", e); - return null; + throw e.rethrowFromSystemServer(); } } @@ -380,8 +377,7 @@ public class UsbManager { try { return mService.hasDevicePermission(device); } catch (RemoteException e) { - Log.e(TAG, "RemoteException in hasPermission", e); - return false; + throw e.rethrowFromSystemServer(); } } @@ -398,8 +394,7 @@ public class UsbManager { try { return mService.hasAccessoryPermission(accessory); } catch (RemoteException e) { - Log.e(TAG, "RemoteException in hasPermission", e); - return false; + throw e.rethrowFromSystemServer(); } } @@ -425,7 +420,7 @@ public class UsbManager { try { mService.requestDevicePermission(device, mContext.getPackageName(), pi); } catch (RemoteException e) { - Log.e(TAG, "RemoteException in requestPermission", e); + throw e.rethrowFromSystemServer(); } } @@ -451,7 +446,7 @@ public class UsbManager { try { mService.requestAccessoryPermission(accessory, mContext.getPackageName(), pi); } catch (RemoteException e) { - Log.e(TAG, "RemoteException in requestPermission", e); + throw e.rethrowFromSystemServer(); } } @@ -466,7 +461,7 @@ public class UsbManager { try { mService.grantDevicePermission(device, Process.myUid()); } catch (RemoteException e) { - Log.e(TAG, "RemoteException in grantPermission", e); + throw e.rethrowFromSystemServer(); } } @@ -486,8 +481,7 @@ public class UsbManager { try { return mService.isFunctionEnabled(function); } catch (RemoteException e) { - Log.e(TAG, "RemoteException in setCurrentFunction", e); - return false; + throw e.rethrowFromSystemServer(); } } @@ -517,7 +511,7 @@ public class UsbManager { try { mService.setCurrentFunction(function); } catch (RemoteException e) { - Log.e(TAG, "RemoteException in setCurrentFunction", e); + throw e.rethrowFromSystemServer(); } } @@ -533,7 +527,7 @@ public class UsbManager { try { mService.setUsbDataUnlocked(unlocked); } catch (RemoteException e) { - Log.e(TAG, "RemoteException in setUsbDataUnlocked", e); + throw e.rethrowFromSystemServer(); } } @@ -554,9 +548,8 @@ public class UsbManager { try { return mService.getPorts(); } catch (RemoteException e) { - Log.e(TAG, "RemoteException in getPorts", e); + throw e.rethrowFromSystemServer(); } - return null; } /** @@ -573,9 +566,8 @@ public class UsbManager { try { return mService.getPortStatus(port.getId()); } catch (RemoteException e) { - Log.e(TAG, "RemoteException in getPortStatus", e); + throw e.rethrowFromSystemServer(); } - return null; } /** @@ -604,7 +596,7 @@ public class UsbManager { try { mService.setPortRoles(port.getId(), powerRole, dataRole); } catch (RemoteException e) { - Log.e(TAG, "RemoteException in setPortRole", e); + throw e.rethrowFromSystemServer(); } } diff --git a/core/java/android/net/NetworkPolicyManager.java b/core/java/android/net/NetworkPolicyManager.java index a83e722403102..94de933292948 100644 --- a/core/java/android/net/NetworkPolicyManager.java +++ b/core/java/android/net/NetworkPolicyManager.java @@ -106,6 +106,7 @@ public class NetworkPolicyManager { try { mService.setUidPolicy(uid, policy); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -118,6 +119,7 @@ public class NetworkPolicyManager { try { mService.addUidPolicy(uid, policy); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -130,6 +132,7 @@ public class NetworkPolicyManager { try { mService.removeUidPolicy(uid, policy); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -137,7 +140,7 @@ public class NetworkPolicyManager { try { return mService.getUidPolicy(uid); } catch (RemoteException e) { - return POLICY_NONE; + throw e.rethrowFromSystemServer(); } } @@ -145,7 +148,7 @@ public class NetworkPolicyManager { try { return mService.getUidsWithPolicy(policy); } catch (RemoteException e) { - return new int[0]; + throw e.rethrowFromSystemServer(); } } @@ -153,6 +156,7 @@ public class NetworkPolicyManager { try { mService.registerListener(listener); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -160,6 +164,7 @@ public class NetworkPolicyManager { try { mService.unregisterListener(listener); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -167,6 +172,7 @@ public class NetworkPolicyManager { try { mService.setNetworkPolicies(policies); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -174,7 +180,7 @@ public class NetworkPolicyManager { try { return mService.getNetworkPolicies(mContext.getOpPackageName()); } catch (RemoteException e) { - return null; + throw e.rethrowFromSystemServer(); } } @@ -182,6 +188,7 @@ public class NetworkPolicyManager { try { mService.setRestrictBackground(restrictBackground); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -189,7 +196,7 @@ public class NetworkPolicyManager { try { return mService.getRestrictBackground(); } catch (RemoteException e) { - return false; + throw e.rethrowFromSystemServer(); } } @@ -202,6 +209,7 @@ public class NetworkPolicyManager { try { mService.factoryReset(subscriber); } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } diff --git a/core/java/android/net/TrafficStats.java b/core/java/android/net/TrafficStats.java index e82485da32f79..ba8bd34bfc6d6 100644 --- a/core/java/android/net/TrafficStats.java +++ b/core/java/android/net/TrafficStats.java @@ -310,7 +310,7 @@ public class TrafficStats { try { getStatsService().incrementOperationCount(uid, tag, operationCount); } catch (RemoteException e) { - throw new RuntimeException(e); + throw e.rethrowFromSystemServer(); } } @@ -653,7 +653,7 @@ public class TrafficStats { try { return getStatsService().getDataLayerSnapshotForUid(uid); } catch (RemoteException e) { - throw new RuntimeException(e); + throw e.rethrowFromSystemServer(); } } @@ -666,7 +666,7 @@ public class TrafficStats { try { return getStatsService().getMobileIfaces(); } catch (RemoteException e) { - throw new RuntimeException(e); + throw e.rethrowFromSystemServer(); } } diff --git a/core/java/android/os/DeadSystemException.java b/core/java/android/os/DeadSystemException.java new file mode 100644 index 0000000000000..595365c554726 --- /dev/null +++ b/core/java/android/os/DeadSystemException.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.os; + +/** + * The core Android system has died and is going through a runtime restart. All + * running apps will be promptly be killed. + */ +public class DeadSystemException extends DeadObjectException { + public DeadSystemException() { + super(); + } +} diff --git a/core/java/android/os/DropBoxManager.java b/core/java/android/os/DropBoxManager.java index 2b144683dc708..0d940723b7d20 100644 --- a/core/java/android/os/DropBoxManager.java +++ b/core/java/android/os/DropBoxManager.java @@ -267,7 +267,11 @@ public class DropBoxManager { * @param data value to store */ public void addText(String tag, String data) { - try { mService.add(new Entry(tag, 0, data)); } catch (RemoteException e) {} + try { + mService.add(new Entry(tag, 0, data)); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } } /** @@ -279,7 +283,11 @@ public class DropBoxManager { */ public void addData(String tag, byte[] data, int flags) { if (data == null) throw new NullPointerException("data == null"); - try { mService.add(new Entry(tag, 0, data, flags)); } catch (RemoteException e) {} + try { + mService.add(new Entry(tag, 0, data, flags)); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } } /** @@ -297,7 +305,7 @@ public class DropBoxManager { try { mService.add(entry); } catch (RemoteException e) { - // ignore + throw e.rethrowFromSystemServer(); } finally { entry.close(); } @@ -312,7 +320,11 @@ public class DropBoxManager { * @return whether events with that tag would be accepted */ public boolean isTagEnabled(String tag) { - try { return mService.isTagEnabled(tag); } catch (RemoteException e) { return false; } + try { + return mService.isTagEnabled(tag); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } } /** @@ -325,7 +337,11 @@ public class DropBoxManager { * @return the next entry, or null if there are no more entries */ public Entry getNextEntry(String tag, long msec) { - try { return mService.getNextEntry(tag, msec); } catch (RemoteException e) { return null; } + try { + return mService.getNextEntry(tag, msec); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } } // TODO: It may be useful to have some sort of notification mechanism diff --git a/core/java/android/os/RemoteException.java b/core/java/android/os/RemoteException.java index 98d75233e8dfb..6d25fc17bd6a1 100644 --- a/core/java/android/os/RemoteException.java +++ b/core/java/android/os/RemoteException.java @@ -15,6 +15,7 @@ */ package android.os; + import android.util.AndroidException; /** @@ -33,4 +34,25 @@ public class RemoteException extends AndroidException { public RuntimeException rethrowAsRuntimeException() { throw new RuntimeException(this); } + + /** + * Rethrow this exception when we know it came from the system server. This + * gives us an opportunity to throw a nice clean + * {@link DeadSystemException} signal to avoid spamming logs with + * misleading stack traces. + *

+ * Apps making calls into the system server may end up persisting internal + * state or making security decisions based on the perceived success or + * failure of a call, or any default values returned. For this reason, we + * want to strongly throw when there was trouble with the transaction. + * + * @hide + */ + public RuntimeException rethrowFromSystemServer() { + if (this instanceof DeadObjectException) { + throw new RuntimeException(new DeadSystemException()); + } else { + throw new RuntimeException(this); + } + } } diff --git a/core/java/android/os/StrictMode.java b/core/java/android/os/StrictMode.java index 91d88da8b7333..e4a76db7a86cd 100644 --- a/core/java/android/os/StrictMode.java +++ b/core/java/android/os/StrictMode.java @@ -1517,7 +1517,11 @@ public final class StrictMode { violationMaskSubset, info); } catch (RemoteException e) { - Log.e(TAG, "RemoteException trying to handle StrictMode violation", e); + if (e instanceof DeadObjectException) { + // System process is dead; ignore + } else { + Log.e(TAG, "RemoteException trying to handle StrictMode violation", e); + } } finally { // Restore the policy. setThreadPolicyMask(savedPolicyMask); @@ -1569,7 +1573,11 @@ public final class StrictMode { info); } } catch (RemoteException e) { - Log.e(TAG, "RemoteException handling StrictMode violation", e); + if (e instanceof DeadObjectException) { + // System process is dead; ignore + } else { + Log.e(TAG, "RemoteException handling StrictMode violation", e); + } } int outstanding = sDropboxCallsInFlight.decrementAndGet(); if (LOG_V) Log.d(TAG, "Dropbox complete; in-flight=" + outstanding); @@ -1897,7 +1905,11 @@ public final class StrictMode { violationMaskSubset, info); } catch (RemoteException e) { - Log.e(TAG, "RemoteException trying to handle StrictMode violation", e); + if (e instanceof DeadObjectException) { + // System process is dead; ignore + } else { + Log.e(TAG, "RemoteException trying to handle StrictMode violation", e); + } } finally { // Restore the policy. setThreadPolicyMask(savedPolicyMask); diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java index 0edc43c755b4e..20b3798b56b89 100644 --- a/core/java/android/os/UserManager.java +++ b/core/java/android/os/UserManager.java @@ -699,7 +699,7 @@ public class UserManager { try { return mService.getUserInfo(getUserHandle()).name; } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -769,7 +769,7 @@ public class UserManager { try { return mService.isRestricted(); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -781,7 +781,7 @@ public class UserManager { try { return mService.canHaveRestrictedProfile(userId); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -844,7 +844,7 @@ public class UserManager { try { return ActivityManagerNative.getDefault().isUserRunning(userId, 0); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -861,7 +861,7 @@ public class UserManager { return ActivityManagerNative.getDefault().isUserRunning( user.getIdentifier(), ActivityManager.FLAG_OR_STOPPED); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -890,7 +890,7 @@ public class UserManager { return ActivityManagerNative.getDefault().isUserRunning( user.getIdentifier(), ActivityManager.FLAG_AND_LOCKED); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -919,7 +919,7 @@ public class UserManager { return ActivityManagerNative.getDefault().isUserRunning( user.getIdentifier(), ActivityManager.FLAG_AND_UNLOCKED); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -964,7 +964,7 @@ public class UserManager { try { return mService.getUserInfo(userHandle); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -985,7 +985,7 @@ public class UserManager { try { return mService.getUserRestrictions(userHandle.getIdentifier()); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1001,7 +1001,7 @@ public class UserManager { try { return mService.hasBaseUserRestriction(restrictionKey, userHandle.getIdentifier()); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1057,7 +1057,7 @@ public class UserManager { try { mService.setUserRestriction(key, value, userHandle.getIdentifier()); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1084,7 +1084,7 @@ public class UserManager { return mService.hasUserRestriction(restrictionKey, userHandle.getIdentifier()); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1138,7 +1138,7 @@ public class UserManager { mService.setUserRestriction(DISALLOW_OUTGOING_CALLS, true, user.id); } } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } return user; } @@ -1158,7 +1158,7 @@ public class UserManager { Settings.Secure.SKIP_FIRST_USE_HINTS, "1", guest.id); } } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } return guest; } @@ -1179,7 +1179,7 @@ public class UserManager { try { return mService.createProfileForUser(name, flags, userHandle); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1202,7 +1202,7 @@ public class UserManager { } return user; } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1271,7 +1271,7 @@ public class UserManager { try { return mService.getSeedAccountName(); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1285,7 +1285,7 @@ public class UserManager { try { return mService.getSeedAccountType(); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1301,7 +1301,7 @@ public class UserManager { try { return mService.getSeedAccountOptions(); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1322,7 +1322,7 @@ public class UserManager { mService.setSeedAccountData(userId, accountName, accountType, accountOptions, /* persist= */ true); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1335,7 +1335,7 @@ public class UserManager { try { mService.clearSeedAccountData(); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1350,7 +1350,7 @@ public class UserManager { try { return mService.markGuestForDeletion(userHandle); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1370,7 +1370,7 @@ public class UserManager { try { mService.setUserEnabled(userHandle); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1392,7 +1392,7 @@ public class UserManager { try { return mService.getUsers(false); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1414,7 +1414,7 @@ public class UserManager { } return result; } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1430,7 +1430,7 @@ public class UserManager { try { return mService.getUserAccount(userHandle); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1446,7 +1446,7 @@ public class UserManager { try { mService.setUserAccount(userHandle, accountName); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1461,7 +1461,7 @@ public class UserManager { try { return mService.getPrimaryUser(); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1498,7 +1498,7 @@ public class UserManager { try { return mService.canAddMoreManagedProfiles(userId, allowedToRemoveOne); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1517,7 +1517,7 @@ public class UserManager { try { return mService.getProfiles(userHandle, false /* enabledOnly */); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1532,7 +1532,7 @@ public class UserManager { try { return mService.isSameProfileGroup(userId, otherUserId); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1550,7 +1550,7 @@ public class UserManager { try { return mService.getProfiles(userHandle, true /* enabledOnly */); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1566,7 +1566,7 @@ public class UserManager { try { users = mService.getProfiles(UserHandle.myUserId(), true /* enabledOnly */); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } for (UserInfo info : users) { UserHandle userHandle = new UserHandle(info.id); @@ -1586,7 +1586,7 @@ public class UserManager { try { return mService.getCredentialOwnerProfile(userHandle); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1600,7 +1600,7 @@ public class UserManager { try { return mService.getProfileParent(userHandle); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1615,7 +1615,7 @@ public class UserManager { try { mService.setQuietModeEnabled(userHandle, enableQuietMode); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1629,7 +1629,7 @@ public class UserManager { try { return mService.isQuietModeEnabled(userHandle.getIdentifier()); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1715,7 +1715,7 @@ public class UserManager { try { return mService.getUsers(excludeDying); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1729,7 +1729,7 @@ public class UserManager { try { return mService.removeUser(userHandle); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1745,7 +1745,7 @@ public class UserManager { try { mService.setUserName(userHandle, name); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1759,7 +1759,7 @@ public class UserManager { try { mService.setUserIcon(userHandle, icon); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1784,7 +1784,7 @@ public class UserManager { } } } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } return null; } @@ -1840,7 +1840,7 @@ public class UserManager { try { return mService.getUserSerialNumber(userHandle); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1857,7 +1857,7 @@ public class UserManager { try { return mService.getUserHandle(userSerialNumber); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1884,7 +1884,7 @@ public class UserManager { try { return mService.getApplicationRestrictions(packageName); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1895,7 +1895,7 @@ public class UserManager { try { return mService.getApplicationRestrictionsForUser(packageName, user.getIdentifier()); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1907,7 +1907,7 @@ public class UserManager { try { mService.setApplicationRestrictions(packageName, restrictions, user.getIdentifier()); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1931,7 +1931,7 @@ public class UserManager { try { mService.setDefaultGuestRestrictions(restrictions); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1943,7 +1943,7 @@ public class UserManager { try { return mService.getDefaultGuestRestrictions(); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1957,7 +1957,7 @@ public class UserManager { try { return mService.getUserCreationTime(userHandle.getIdentifier()); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } @@ -1973,7 +1973,7 @@ public class UserManager { try { return mService.someUserHasSeedAccount(accountName, accountType); } catch (RemoteException re) { - throw re.rethrowAsRuntimeException(); + throw re.rethrowFromSystemServer(); } } } diff --git a/core/java/android/os/storage/StorageManager.java b/core/java/android/os/storage/StorageManager.java index 97ee90dc9ea23..17df7080acf18 100644 --- a/core/java/android/os/storage/StorageManager.java +++ b/core/java/android/os/storage/StorageManager.java @@ -332,7 +332,7 @@ public class StorageManager { try { mMountService.registerListener(delegate); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } mDelegates.add(delegate); } @@ -353,7 +353,7 @@ public class StorageManager { try { mMountService.unregisterListener(delegate); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } i.remove(); } @@ -434,10 +434,8 @@ public class StorageManager { } catch (IOException e) { throw new IllegalArgumentException("Failed to resolve path: " + rawPath, e); } catch (RemoteException e) { - Log.e(TAG, "Failed to mount OBB", e); + throw e.rethrowFromSystemServer(); } - - return false; } /** @@ -469,10 +467,8 @@ public class StorageManager { mMountService.unmountObb(rawPath, force, mObbActionListener, nonce); return true; } catch (RemoteException e) { - Log.e(TAG, "Failed to mount OBB", e); + throw e.rethrowFromSystemServer(); } - - return false; } /** @@ -487,10 +483,8 @@ public class StorageManager { try { return mMountService.isObbMounted(rawPath); } catch (RemoteException e) { - Log.e(TAG, "Failed to check if OBB is mounted", e); + throw e.rethrowFromSystemServer(); } - - return false; } /** @@ -508,10 +502,8 @@ public class StorageManager { try { return mMountService.getMountedObbPath(rawPath); } catch (RemoteException e) { - Log.e(TAG, "Failed to find mounted path for OBB", e); + throw e.rethrowFromSystemServer(); } - - return null; } /** {@hide} */ @@ -519,7 +511,7 @@ public class StorageManager { try { return Arrays.asList(mMountService.getDisks()); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -605,7 +597,7 @@ public class StorageManager { try { return Arrays.asList(mMountService.getVolumes(0)); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -620,7 +612,7 @@ public class StorageManager { } return res; } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -629,7 +621,7 @@ public class StorageManager { try { return Arrays.asList(mMountService.getVolumeRecords(0)); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -672,7 +664,7 @@ public class StorageManager { try { mMountService.mount(volId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -681,7 +673,7 @@ public class StorageManager { try { mMountService.unmount(volId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -690,7 +682,7 @@ public class StorageManager { try { mMountService.format(volId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -699,7 +691,7 @@ public class StorageManager { try { return mMountService.benchmark(volId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -708,7 +700,7 @@ public class StorageManager { try { mMountService.partitionPublic(diskId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -717,7 +709,7 @@ public class StorageManager { try { mMountService.partitionPrivate(diskId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -726,7 +718,7 @@ public class StorageManager { try { mMountService.partitionMixed(diskId, ratio); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -759,7 +751,7 @@ public class StorageManager { try { mMountService.setVolumeNickname(fsUuid, nickname); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -769,7 +761,7 @@ public class StorageManager { mMountService.setVolumeUserFlags(fsUuid, inited ? VolumeRecord.USER_FLAG_INITED : 0, VolumeRecord.USER_FLAG_INITED); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -779,7 +771,7 @@ public class StorageManager { mMountService.setVolumeUserFlags(fsUuid, snoozed ? VolumeRecord.USER_FLAG_SNOOZED : 0, VolumeRecord.USER_FLAG_SNOOZED); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -788,7 +780,7 @@ public class StorageManager { try { mMountService.forgetVolume(fsUuid); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -802,7 +794,7 @@ public class StorageManager { try { return mMountService.getPrimaryStorageUuid(); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -816,7 +808,7 @@ public class StorageManager { try { mMountService.setPrimaryStorageUuid(volumeUuid, callback); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -900,7 +892,7 @@ public class StorageManager { } return mountService.getVolumeList(uid, packageName, flags); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -984,7 +976,7 @@ public class StorageManager { try { mMountService.createUserKey(userId, serialNumber, ephemeral); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -993,7 +985,7 @@ public class StorageManager { try { mMountService.destroyUserKey(userId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1002,7 +994,7 @@ public class StorageManager { try { mMountService.unlockUserKey(userId, serialNumber, token, secret); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1011,7 +1003,7 @@ public class StorageManager { try { mMountService.lockUserKey(userId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1020,7 +1012,7 @@ public class StorageManager { try { mMountService.prepareUserStorage(volumeUuid, userId, serialNumber, flags); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1029,7 +1021,7 @@ public class StorageManager { try { return mMountService.isUserKeyUnlocked(userId); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } @@ -1064,7 +1056,8 @@ public class StorageManager { } } } - } catch (RemoteException ignored) { + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } return path; } @@ -1074,7 +1067,7 @@ public class StorageManager { try { return mMountService.mountAppFuse(name); } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); + throw e.rethrowFromSystemServer(); } } diff --git a/core/java/android/print/PrintManager.java b/core/java/android/print/PrintManager.java index 58f260cbe1cf5..0540036f1a496 100644 --- a/core/java/android/print/PrintManager.java +++ b/core/java/android/print/PrintManager.java @@ -232,9 +232,8 @@ public final class PrintManager { try { return mService.getPrintJobInfo(printJobId, mAppId, mUserId); } catch (RemoteException re) { - Log.e(LOG_TAG, "Error getting a print job info:" + printJobId, re); + throw re.rethrowFromSystemServer(); } - return null; } /** @@ -258,7 +257,7 @@ public final class PrintManager { mService.addPrintJobStateChangeListener(wrappedListener, mAppId, mUserId); mPrintJobStateChangeListeners.put(listener, wrappedListener); } catch (RemoteException re) { - Log.e(LOG_TAG, "Error adding print job state change listener", re); + throw re.rethrowFromSystemServer(); } } @@ -288,7 +287,7 @@ public final class PrintManager { try { mService.removePrintJobStateChangeListener(wrappedListener, mUserId); } catch (RemoteException re) { - Log.e(LOG_TAG, "Error removing print job state change listener", re); + throw re.rethrowFromSystemServer(); } } @@ -311,7 +310,7 @@ public final class PrintManager { return new PrintJob(printJob, this); } } catch (RemoteException re) { - Log.e(LOG_TAG, "Error getting print job", re); + throw re.rethrowFromSystemServer(); } return null; } @@ -334,9 +333,8 @@ public final class PrintManager { try { return mService.getCustomPrinterIcon(printerId, mUserId); } catch (RemoteException re) { - Log.e(LOG_TAG, "Error getting custom printer icon", re); + throw re.rethrowFromSystemServer(); } - return null; } /** @@ -362,9 +360,8 @@ public final class PrintManager { } return printJobs; } catch (RemoteException re) { - Log.e(LOG_TAG, "Error getting print jobs", re); + throw re.rethrowFromSystemServer(); } - return Collections.emptyList(); } void cancelPrintJob(PrintJobId printJobId) { @@ -375,7 +372,7 @@ public final class PrintManager { try { mService.cancelPrintJob(printJobId, mAppId, mUserId); } catch (RemoteException re) { - Log.e(LOG_TAG, "Error canceling a print job: " + printJobId, re); + throw re.rethrowFromSystemServer(); } } @@ -387,7 +384,7 @@ public final class PrintManager { try { mService.restartPrintJob(printJobId, mAppId, mUserId); } catch (RemoteException re) { - Log.e(LOG_TAG, "Error restarting a print job: " + printJobId, re); + throw re.rethrowFromSystemServer(); } } @@ -475,7 +472,7 @@ public final class PrintManager { } } } catch (RemoteException re) { - Log.e(LOG_TAG, "Error creating a print job", re); + throw re.rethrowFromSystemServer(); } return null; } @@ -497,7 +494,7 @@ public final class PrintManager { return enabledServices; } } catch (RemoteException re) { - Log.e(LOG_TAG, "Error getting the enabled print services", re); + throw re.rethrowFromSystemServer(); } return Collections.emptyList(); } @@ -519,7 +516,7 @@ public final class PrintManager { return installedServices; } } catch (RemoteException re) { - Log.e(LOG_TAG, "Error getting the installed print services", re); + throw re.rethrowFromSystemServer(); } return Collections.emptyList(); } diff --git a/core/java/android/service/persistentdata/PersistentDataBlockManager.java b/core/java/android/service/persistentdata/PersistentDataBlockManager.java index ddb6980046ed8..cfeed51da86f2 100644 --- a/core/java/android/service/persistentdata/PersistentDataBlockManager.java +++ b/core/java/android/service/persistentdata/PersistentDataBlockManager.java @@ -85,8 +85,7 @@ public class PersistentDataBlockManager { try { return sService.write(data); } catch (RemoteException e) { - onError("writing data"); - return -1; + throw e.rethrowFromSystemServer(); } } @@ -97,8 +96,7 @@ public class PersistentDataBlockManager { try { return sService.read(); } catch (RemoteException e) { - onError("reading data"); - return null; + throw e.rethrowFromSystemServer(); } } @@ -111,8 +109,7 @@ public class PersistentDataBlockManager { try { return sService.getDataBlockSize(); } catch (RemoteException e) { - onError("getting data block size"); - return -1; + throw e.rethrowFromSystemServer(); } } @@ -125,8 +122,7 @@ public class PersistentDataBlockManager { try { return sService.getMaximumDataBlockSize(); } catch (RemoteException e) { - onError("getting maximum data block size"); - return -1; + throw e.rethrowFromSystemServer(); } } @@ -138,7 +134,7 @@ public class PersistentDataBlockManager { try { sService.wipe(); } catch (RemoteException e) { - onError("wiping persistent partition"); + throw e.rethrowFromSystemServer(); } } @@ -149,7 +145,7 @@ public class PersistentDataBlockManager { try { sService.setOemUnlockEnabled(enabled); } catch (RemoteException e) { - onError("setting OEM unlock enabled to " + enabled); + throw e.rethrowFromSystemServer(); } } @@ -160,8 +156,7 @@ public class PersistentDataBlockManager { try { return sService.getOemUnlockEnabled(); } catch (RemoteException e) { - onError("getting OEM unlock enabled bit"); - return false; + throw e.rethrowFromSystemServer(); } } @@ -178,12 +173,7 @@ public class PersistentDataBlockManager { try { return sService.getFlashLockState(); } catch (RemoteException e) { - onError("getting flash lock state"); - return FLASH_LOCK_UNKNOWN; + throw e.rethrowFromSystemServer(); } } - - private void onError(String msg) { - Slog.v(TAG, "Remote exception while " + msg); - } } diff --git a/core/java/android/util/Log.java b/core/java/android/util/Log.java index 3d7cb4954e5b6..5bc6c9480025d 100644 --- a/core/java/android/util/Log.java +++ b/core/java/android/util/Log.java @@ -16,6 +16,8 @@ package android.util; +import android.os.DeadSystemException; + import com.android.internal.os.RuntimeInit; import com.android.internal.util.FastPrintWriter; import com.android.internal.util.LineBreakBufferedWriter; @@ -405,6 +407,11 @@ public final class Log { if (t instanceof UnknownHostException) { break; } + if (t instanceof DeadSystemException) { + lbbw.println("DeadSystemException: The system died; " + + "earlier logs will point to the root cause"); + break; + } t = t.getCause(); } if (t == null) { diff --git a/core/java/com/android/internal/os/RuntimeInit.java b/core/java/com/android/internal/os/RuntimeInit.java index e2982019d3bf3..fff9d7c3247b0 100644 --- a/core/java/com/android/internal/os/RuntimeInit.java +++ b/core/java/com/android/internal/os/RuntimeInit.java @@ -20,6 +20,7 @@ import android.app.ActivityManagerNative; import android.app.ActivityThread; import android.app.ApplicationErrorReport; import android.os.Build; +import android.os.DeadObjectException; import android.os.Debug; import android.os.IBinder; import android.os.Process; @@ -96,10 +97,14 @@ public class RuntimeInit { ActivityManagerNative.getDefault().handleApplicationCrash( mApplicationObject, new ApplicationErrorReport.CrashInfo(e)); } catch (Throwable t2) { - try { - Clog_e(TAG, "Error reporting crash", t2); - } catch (Throwable t3) { - // Even Clog_e() fails! Oh well. + if (t2 instanceof DeadObjectException) { + // System process is dead; ignore + } else { + try { + Clog_e(TAG, "Error reporting crash", t2); + } catch (Throwable t3) { + // Even Clog_e() fails! Oh well. + } } } finally { // Try everything to make sure this process goes away. @@ -358,8 +363,12 @@ public class RuntimeInit { System.exit(10); } } catch (Throwable t2) { - Slog.e(TAG, "Error reporting WTF", t2); - Slog.e(TAG, "Original WTF:", t); + if (t2 instanceof DeadObjectException) { + // System process is dead; ignore + } else { + Slog.e(TAG, "Error reporting WTF", t2); + Slog.e(TAG, "Original WTF:", t); + } } } diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java index e14e36d8c2701..3cd47e73d3407 100644 --- a/location/java/android/location/LocationManager.java +++ b/location/java/android/location/LocationManager.java @@ -307,7 +307,7 @@ public class LocationManager { try { mService.locationCallbackFinished(this); } catch (RemoteException e) { - Log.e(TAG, "locationCallbackFinished: RemoteException", e); + throw e.rethrowFromSystemServer(); } } } @@ -341,9 +341,8 @@ public class LocationManager { try { return mService.getAllProviders(); } catch (RemoteException e) { - Log.e(TAG, "RemoteException", e); + throw e.rethrowFromSystemServer(); } - return null; } /** @@ -357,9 +356,8 @@ public class LocationManager { try { return mService.getProviders(null, enabledOnly); } catch (RemoteException e) { - Log.e(TAG, "RemoteException", e); + throw e.rethrowFromSystemServer(); } - return null; } /** @@ -382,9 +380,8 @@ public class LocationManager { } return createProvider(name, properties); } catch (RemoteException e) { - Log.e(TAG, "RemoteException", e); + throw e.rethrowFromSystemServer(); } - return null; } /** @@ -402,9 +399,8 @@ public class LocationManager { try { return mService.getProviders(criteria, enabledOnly); } catch (RemoteException e) { - Log.e(TAG, "RemoteException", e); + throw e.rethrowFromSystemServer(); } - return null; } /** @@ -434,9 +430,8 @@ public class LocationManager { try { return mService.getBestProvider(criteria, enabledOnly); } catch (RemoteException e) { - Log.e(TAG, "RemoteException", e); + throw e.rethrowFromSystemServer(); } - return null; } /** @@ -885,7 +880,7 @@ public class LocationManager { try { mService.requestLocationUpdates(request, transport, intent, packageName); } catch (RemoteException e) { - Log.e(TAG, "RemoteException", e); + throw e.rethrowFromSystemServer(); } } @@ -911,7 +906,7 @@ public class LocationManager { try { mService.removeUpdates(transport, null, packageName); } catch (RemoteException e) { - Log.e(TAG, "RemoteException", e); + throw e.rethrowFromSystemServer(); } } @@ -930,7 +925,7 @@ public class LocationManager { try { mService.removeUpdates(null, intent, packageName); } catch (RemoteException e) { - Log.e(TAG, "RemoteException", e); + throw e.rethrowFromSystemServer(); } } @@ -992,7 +987,7 @@ public class LocationManager { try { mService.requestGeofence(request, fence, intent, mContext.getPackageName()); } catch (RemoteException e) { - Log.e(TAG, "RemoteException", e); + throw e.rethrowFromSystemServer(); } } @@ -1040,7 +1035,7 @@ public class LocationManager { try { mService.requestGeofence(request, fence, intent, mContext.getPackageName()); } catch (RemoteException e) { - Log.e(TAG, "RemoteException", e); + throw e.rethrowFromSystemServer(); } } @@ -1067,7 +1062,7 @@ public class LocationManager { try { mService.removeGeofence(null, intent, packageName); } catch (RemoteException e) { - Log.e(TAG, "RemoteException", e); + throw e.rethrowFromSystemServer(); } } @@ -1095,7 +1090,7 @@ public class LocationManager { try { mService.removeGeofence(fence, intent, packageName); } catch (RemoteException e) { - Log.e(TAG, "RemoteException", e); + throw e.rethrowFromSystemServer(); } } @@ -1117,7 +1112,7 @@ public class LocationManager { try { mService.removeGeofence(null, intent, packageName); } catch (RemoteException e) { - Log.e(TAG, "RemoteException", e); + throw e.rethrowFromSystemServer(); } } @@ -1148,8 +1143,7 @@ public class LocationManager { try { return mService.isProviderEnabled(provider); } catch (RemoteException e) { - Log.e(TAG, "RemoteException", e); - return false; + throw e.rethrowFromSystemServer(); } } @@ -1173,8 +1167,7 @@ public class LocationManager { try { return mService.getLastLocation(null, packageName); } catch (RemoteException e) { - Log.e(TAG, "RemoteException", e); - return null; + throw e.rethrowFromSystemServer(); } } @@ -1205,8 +1198,7 @@ public class LocationManager { try { return mService.getLastLocation(request, packageName); } catch (RemoteException e) { - Log.e(TAG, "RemoteException", e); - return null; + throw e.rethrowFromSystemServer(); } } @@ -1237,7 +1229,7 @@ public class LocationManager { try { mService.addTestProvider(name, properties, mContext.getOpPackageName()); } catch (RemoteException e) { - Log.e(TAG, "RemoteException", e); + throw e.rethrowFromSystemServer(); } } @@ -1255,7 +1247,7 @@ public class LocationManager { try { mService.removeTestProvider(provider, mContext.getOpPackageName()); } catch (RemoteException e) { - Log.e(TAG, "RemoteException", e); + throw e.rethrowFromSystemServer(); } } @@ -1292,7 +1284,7 @@ public class LocationManager { try { mService.setTestProviderLocation(provider, loc, mContext.getOpPackageName()); } catch (RemoteException e) { - Log.e(TAG, "RemoteException", e); + throw e.rethrowFromSystemServer(); } } @@ -1310,7 +1302,7 @@ public class LocationManager { try { mService.clearTestProviderLocation(provider, mContext.getOpPackageName()); } catch (RemoteException e) { - Log.e(TAG, "RemoteException", e); + throw e.rethrowFromSystemServer(); } } @@ -1330,7 +1322,7 @@ public class LocationManager { try { mService.setTestProviderEnabled(provider, enabled, mContext.getOpPackageName()); } catch (RemoteException e) { - Log.e(TAG, "RemoteException", e); + throw e.rethrowFromSystemServer(); } } @@ -1348,7 +1340,7 @@ public class LocationManager { try { mService.clearTestProviderEnabled(provider, mContext.getOpPackageName()); } catch (RemoteException e) { - Log.e(TAG, "RemoteException", e); + throw e.rethrowFromSystemServer(); } } @@ -1371,7 +1363,7 @@ public class LocationManager { mService.setTestProviderStatus(provider, status, extras, updateTime, mContext.getOpPackageName()); } catch (RemoteException e) { - Log.e(TAG, "RemoteException", e); + throw e.rethrowFromSystemServer(); } } @@ -1389,7 +1381,7 @@ public class LocationManager { try { mService.clearTestProviderStatus(provider, mContext.getOpPackageName()); } catch (RemoteException e) { - Log.e(TAG, "RemoteException", e); + throw e.rethrowFromSystemServer(); } } @@ -1615,8 +1607,7 @@ public class LocationManager { mGpsStatusListeners.put(listener, transport); } } catch (RemoteException e) { - Log.e(TAG, "RemoteException in registerGpsStatusListener: ", e); - result = false; + throw e.rethrowFromSystemServer(); } return result; @@ -1635,7 +1626,7 @@ public class LocationManager { mService.unregisterGnssStatusCallback(transport); } } catch (RemoteException e) { - Log.e(TAG, "RemoteException in unregisterGpsStatusListener: ", e); + throw e.rethrowFromSystemServer(); } } @@ -1679,8 +1670,7 @@ public class LocationManager { mGnssStatusListeners.put(callback, transport); } } catch (RemoteException e) { - Log.e(TAG, "RemoteException in registerGnssStatusCallback: ", e); - result = false; + throw e.rethrowFromSystemServer(); } return result; @@ -1698,7 +1688,7 @@ public class LocationManager { mService.unregisterGnssStatusCallback(transport); } } catch (RemoteException e) { - Log.e(TAG, "RemoteException in unregisterGnssStatusCallback: ", e); + throw e.rethrowFromSystemServer(); } } @@ -1728,8 +1718,7 @@ public class LocationManager { mGpsNmeaListeners.put(listener, transport); } } catch (RemoteException e) { - Log.e(TAG, "RemoteException in registerGpsStatusListener: ", e); - result = false; + throw e.rethrowFromSystemServer(); } return result; @@ -1748,7 +1737,7 @@ public class LocationManager { mService.unregisterGnssStatusCallback(transport); } } catch (RemoteException e) { - Log.e(TAG, "RemoteException in unregisterGpsStatusListener: ", e); + throw e.rethrowFromSystemServer(); } } @@ -1792,8 +1781,7 @@ public class LocationManager { mGnssNmeaListeners.put(listener, transport); } } catch (RemoteException e) { - Log.e(TAG, "RemoteException in registerGnssStatusCallback: ", e); - result = false; + throw e.rethrowFromSystemServer(); } return result; @@ -1811,7 +1799,7 @@ public class LocationManager { mService.unregisterGnssStatusCallback(transport); } } catch (RemoteException e) { - Log.e(TAG, "RemoteException in unregisterGnssStatusCallback: ", e); + throw e.rethrowFromSystemServer(); } } @@ -1963,8 +1951,7 @@ public class LocationManager { try { return mService.getGnssYearOfHardware(); } catch (RemoteException e) { - Log.e(TAG, "RemoteException in getGnssSystemInfo: ", e); - return 0; + throw e.rethrowFromSystemServer(); } } @@ -1983,8 +1970,7 @@ public class LocationManager { try { return mService.sendExtraCommand(provider, command, extras); } catch (RemoteException e) { - Log.e(TAG, "RemoteException in sendExtraCommand: ", e); - return false; + throw e.rethrowFromSystemServer(); } } @@ -1998,8 +1984,7 @@ public class LocationManager { try { return mService.sendNiResponse(notifId, userResponse); } catch (RemoteException e) { - Log.e(TAG, "RemoteException in sendNiResponse: ", e); - return false; + throw e.rethrowFromSystemServer(); } } diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java index 7f3b9c21b0f94..c7e96cf664bb9 100644 --- a/media/java/android/media/AudioManager.java +++ b/media/java/android/media/AudioManager.java @@ -809,7 +809,7 @@ public class AudioManager { service.adjustStreamVolume(streamType, direction, flags, getContext().getOpPackageName()); } catch (RemoteException e) { - Log.e(TAG, "Dead object in adjustStreamVolume", e); + throw e.rethrowFromSystemServer(); } } @@ -877,7 +877,7 @@ public class AudioManager { service.setMasterMute(mute, flags, getContext().getOpPackageName(), UserHandle.getCallingUserId()); } catch (RemoteException e) { - Log.e(TAG, "Dead object in setMasterMute", e); + throw e.rethrowFromSystemServer(); } } @@ -893,8 +893,7 @@ public class AudioManager { try { return service.getRingerModeExternal(); } catch (RemoteException e) { - Log.e(TAG, "Dead object in getRingerMode", e); - return RINGER_MODE_NORMAL; + throw e.rethrowFromSystemServer(); } } @@ -914,8 +913,7 @@ public class AudioManager { try { return service.isValidRingerMode(ringerMode); } catch (RemoteException e) { - Log.e(TAG, "Dead object in isValidRingerMode", e); - return false; + throw e.rethrowFromSystemServer(); } } @@ -931,8 +929,7 @@ public class AudioManager { try { return service.getStreamMaxVolume(streamType); } catch (RemoteException e) { - Log.e(TAG, "Dead object in getStreamMaxVolume", e); - return 0; + throw e.rethrowFromSystemServer(); } } @@ -949,8 +946,7 @@ public class AudioManager { try { return service.getStreamMinVolume(streamType); } catch (RemoteException e) { - Log.e(TAG, "Dead object in getStreamMinVolume", e); - return 0; + throw e.rethrowFromSystemServer(); } } @@ -967,8 +963,7 @@ public class AudioManager { try { return service.getStreamVolume(streamType); } catch (RemoteException e) { - Log.e(TAG, "Dead object in getStreamVolume", e); - return 0; + throw e.rethrowFromSystemServer(); } } @@ -982,8 +977,7 @@ public class AudioManager { try { return service.getLastAudibleStreamVolume(streamType); } catch (RemoteException e) { - Log.e(TAG, "Dead object in getLastAudibleStreamVolume", e); - return 0; + throw e.rethrowFromSystemServer(); } } @@ -998,8 +992,7 @@ public class AudioManager { try { return service.getUiSoundsStreamType(); } catch (RemoteException e) { - Log.e(TAG, "Dead object in getUiSoundsStreamType", e); - return STREAM_RING; + throw e.rethrowFromSystemServer(); } } @@ -1024,7 +1017,7 @@ public class AudioManager { try { service.setRingerModeExternal(ringerMode, getContext().getOpPackageName()); } catch (RemoteException e) { - Log.e(TAG, "Dead object in setRingerMode", e); + throw e.rethrowFromSystemServer(); } } @@ -1045,7 +1038,7 @@ public class AudioManager { try { service.setStreamVolume(streamType, index, flags, getContext().getOpPackageName()); } catch (RemoteException e) { - Log.e(TAG, "Dead object in setStreamVolume", e); + throw e.rethrowFromSystemServer(); } } @@ -1122,8 +1115,7 @@ public class AudioManager { try { return service.isStreamMute(streamType); } catch (RemoteException e) { - Log.e(TAG, "Dead object in isStreamMute", e); - return false; + throw e.rethrowFromSystemServer(); } } @@ -1137,8 +1129,7 @@ public class AudioManager { try { return service.isMasterMute(); } catch (RemoteException e) { - Log.e(TAG, "Dead object in isMasterMute", e); - return false; + throw e.rethrowFromSystemServer(); } } @@ -1154,7 +1145,7 @@ public class AudioManager { try { service.forceVolumeControlStream(streamType, mICallBack); } catch (RemoteException e) { - Log.e(TAG, "Dead object in forceVolumeControlStream", e); + throw e.rethrowFromSystemServer(); } } @@ -1182,8 +1173,7 @@ public class AudioManager { try { return service.shouldVibrate(vibrateType); } catch (RemoteException e) { - Log.e(TAG, "Dead object in shouldVibrate", e); - return false; + throw e.rethrowFromSystemServer(); } } @@ -1209,8 +1199,7 @@ public class AudioManager { try { return service.getVibrateSetting(vibrateType); } catch (RemoteException e) { - Log.e(TAG, "Dead object in getVibrateSetting", e); - return VIBRATE_SETTING_OFF; + throw e.rethrowFromSystemServer(); } } @@ -1237,7 +1226,7 @@ public class AudioManager { try { service.setVibrateSetting(vibrateType, vibrateSetting); } catch (RemoteException e) { - Log.e(TAG, "Dead object in setVibrateSetting", e); + throw e.rethrowFromSystemServer(); } } @@ -1255,7 +1244,7 @@ public class AudioManager { try { service.setSpeakerphoneOn(on); } catch (RemoteException e) { - Log.e(TAG, "Dead object in setSpeakerphoneOn", e); + throw e.rethrowFromSystemServer(); } } @@ -1269,8 +1258,7 @@ public class AudioManager { try { return service.isSpeakerphoneOn(); } catch (RemoteException e) { - Log.e(TAG, "Dead object in isSpeakerphoneOn", e); - return false; + throw e.rethrowFromSystemServer(); } } @@ -1411,7 +1399,7 @@ public class AudioManager { service.startBluetoothSco(mICallBack, getContext().getApplicationInfo().targetSdkVersion); } catch (RemoteException e) { - Log.e(TAG, "Dead object in startBluetoothSco", e); + throw e.rethrowFromSystemServer(); } } @@ -1435,7 +1423,7 @@ public class AudioManager { try { service.startBluetoothScoVirtualCall(mICallBack); } catch (RemoteException e) { - Log.e(TAG, "Dead object in startBluetoothScoVirtualCall", e); + throw e.rethrowFromSystemServer(); } } @@ -1454,7 +1442,7 @@ public class AudioManager { try { service.stopBluetoothSco(mICallBack); } catch (RemoteException e) { - Log.e(TAG, "Dead object in stopBluetoothSco", e); + throw e.rethrowFromSystemServer(); } } @@ -1472,7 +1460,7 @@ public class AudioManager { try { service.setBluetoothScoOn(on); } catch (RemoteException e) { - Log.e(TAG, "Dead object in setBluetoothScoOn", e); + throw e.rethrowFromSystemServer(); } } @@ -1487,8 +1475,7 @@ public class AudioManager { try { return service.isBluetoothScoOn(); } catch (RemoteException e) { - Log.e(TAG, "Dead object in isBluetoothScoOn", e); - return false; + throw e.rethrowFromSystemServer(); } } @@ -1560,7 +1547,7 @@ public class AudioManager { service.setMicrophoneMute(on, getContext().getOpPackageName(), UserHandle.getCallingUserId()); } catch (RemoteException e) { - Log.e(TAG, "Dead object in setMicrophoneMute", e); + throw e.rethrowFromSystemServer(); } } @@ -1593,7 +1580,7 @@ public class AudioManager { try { service.setMode(mode, mICallBack, mApplicationContext.getOpPackageName()); } catch (RemoteException e) { - Log.e(TAG, "Dead object in setMode", e); + throw e.rethrowFromSystemServer(); } } @@ -1609,8 +1596,7 @@ public class AudioManager { try { return service.getMode(); } catch (RemoteException e) { - Log.e(TAG, "Dead object in getMode", e); - return MODE_INVALID; + throw e.rethrowFromSystemServer(); } } @@ -1747,8 +1733,7 @@ public class AudioManager { try { return service.getCurrentAudioFocus() == AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE; } catch (RemoteException e) { - Log.e(TAG, "Dead object in isAudioFocusExclusive()", e); - return false; + throw e.rethrowFromSystemServer(); } } @@ -1914,7 +1899,7 @@ public class AudioManager { try { service.playSoundEffect(effectType); } catch (RemoteException e) { - Log.e(TAG, "Dead object in playSoundEffect"+e); + throw e.rethrowFromSystemServer(); } } @@ -1949,7 +1934,7 @@ public class AudioManager { try { service.playSoundEffect(effectType); } catch (RemoteException e) { - Log.e(TAG, "Dead object in playSoundEffect"+e); + throw e.rethrowFromSystemServer(); } } @@ -1981,7 +1966,7 @@ public class AudioManager { try { service.playSoundEffectVolume(effectType, volume); } catch (RemoteException e) { - Log.e(TAG, "Dead object in playSoundEffect"+e); + throw e.rethrowFromSystemServer(); } } @@ -2003,7 +1988,7 @@ public class AudioManager { try { service.loadSoundEffects(); } catch (RemoteException e) { - Log.e(TAG, "Dead object in loadSoundEffects"+e); + throw e.rethrowFromSystemServer(); } } @@ -2017,7 +2002,7 @@ public class AudioManager { try { service.unloadSoundEffects(); } catch (RemoteException e) { - Log.e(TAG, "Dead object in unloadSoundEffects"+e); + throw e.rethrowFromSystemServer(); } } @@ -2428,7 +2413,7 @@ public class AudioManager { getContext().getOpPackageName() /* package name */, flags, ap != null ? ap.cb() : null); } catch (RemoteException e) { - Log.e(TAG, "Can't call requestAudioFocus() on AudioService:", e); + throw e.rethrowFromSystemServer(); } return status; } @@ -2454,7 +2439,7 @@ public class AudioManager { AUDIOFOCUS_FLAG_LOCK, null /* policy token */); } catch (RemoteException e) { - Log.e(TAG, "Can't call requestAudioFocusForCall() on AudioService:", e); + throw e.rethrowFromSystemServer(); } } @@ -2470,7 +2455,7 @@ public class AudioManager { service.abandonAudioFocus(null, AudioSystem.IN_VOICE_COMM_FOCUS_ID, null /*AudioAttributes, legacy behavior*/); } catch (RemoteException e) { - Log.e(TAG, "Can't call abandonAudioFocusForCall() on AudioService:", e); + throw e.rethrowFromSystemServer(); } } @@ -2499,7 +2484,7 @@ public class AudioManager { status = service.abandonAudioFocus(mAudioFocusDispatcher, getIdForAudioFocusListener(l), aa); } catch (RemoteException e) { - Log.e(TAG, "Can't call abandonAudioFocus() on AudioService:", e); + throw e.rethrowFromSystemServer(); } return status; } @@ -2713,8 +2698,7 @@ public class AudioManager { } // successful registration } catch (RemoteException e) { - Log.e(TAG, "Dead object in registerAudioPolicyAsync()", e); - return ERROR; + throw e.rethrowFromSystemServer(); } return SUCCESS; } @@ -2733,7 +2717,7 @@ public class AudioManager { service.unregisterAudioPolicyAsync(policy.cb()); policy.setRegistration(null); } catch (RemoteException e) { - Log.e(TAG, "Dead object in unregisterAudioPolicyAsync()", e); + throw e.rethrowFromSystemServer(); } } @@ -2793,7 +2777,7 @@ public class AudioManager { try { service.registerRecordingCallback(mRecCb); } catch (RemoteException e) { - Log.e(TAG, "Dead object in registerRecordingCallback", e); + throw e.rethrowFromSystemServer(); } } } else { @@ -2825,7 +2809,7 @@ public class AudioManager { try { service.unregisterRecordingCallback(mRecCb); } catch (RemoteException e) { - Log.e(TAG, "Dead object in unregisterRecordingCallback", e); + throw e.rethrowFromSystemServer(); } } } else { @@ -2845,8 +2829,7 @@ public class AudioManager { try { return service.getActiveRecordConfigurations(); } catch (RemoteException e) { - Log.e(TAG, "Unable to retrieve active record configurations", e); - return null; + throw e.rethrowFromSystemServer(); } } @@ -2929,7 +2912,7 @@ public class AudioManager { try { service.reloadAudioSettings(); } catch (RemoteException e) { - Log.e(TAG, "Dead object in reloadAudioSettings"+e); + throw e.rethrowFromSystemServer(); } } @@ -2944,7 +2927,7 @@ public class AudioManager { try { service.avrcpSupportsAbsoluteVolume(address, support); } catch (RemoteException e) { - Log.e(TAG, "Dead object in avrcpSupportsAbsoluteVolume", e); + throw e.rethrowFromSystemServer(); } } @@ -3238,7 +3221,7 @@ public class AudioManager { service.setWiredDeviceConnectionState(type, state, address, name, mApplicationContext.getOpPackageName()); } catch (RemoteException e) { - Log.e(TAG, "Dead object in setWiredDeviceConnectionState "+e); + throw e.rethrowFromSystemServer(); } } @@ -3260,7 +3243,7 @@ public class AudioManager { try { delay = service.setBluetoothA2dpDeviceConnectionState(device, state, profile); } catch (RemoteException e) { - Log.e(TAG, "Dead object in setBluetoothA2dpDeviceConnectionState "+e); + throw e.rethrowFromSystemServer(); } return delay; } @@ -3270,7 +3253,7 @@ public class AudioManager { try { return getService().getRingtonePlayer(); } catch (RemoteException e) { - return null; + throw e.rethrowFromSystemServer(); } } @@ -3365,7 +3348,7 @@ public class AudioManager { try { getService().setVolumeController(controller); } catch (RemoteException e) { - Log.w(TAG, "Error setting volume controller", e); + throw e.rethrowFromSystemServer(); } } @@ -3379,7 +3362,7 @@ public class AudioManager { try { getService().notifyVolumeControllerVisible(controller, visible); } catch (RemoteException e) { - Log.w(TAG, "Error notifying about volume controller visibility", e); + throw e.rethrowFromSystemServer(); } } @@ -3391,8 +3374,7 @@ public class AudioManager { try { return getService().isStreamAffectedByRingerMode(streamType); } catch (RemoteException e) { - Log.w(TAG, "Error calling isStreamAffectedByRingerMode", e); - return false; + throw e.rethrowFromSystemServer(); } } @@ -3404,8 +3386,7 @@ public class AudioManager { try { return getService().isStreamAffectedByMute(streamType); } catch (RemoteException e) { - Log.w(TAG, "Error calling isStreamAffectedByMute", e); - return false; + throw e.rethrowFromSystemServer(); } } @@ -3417,7 +3398,7 @@ public class AudioManager { try { getService().disableSafeMediaVolume(mApplicationContext.getOpPackageName()); } catch (RemoteException e) { - Log.w(TAG, "Error disabling safe media volume", e); + throw e.rethrowFromSystemServer(); } } @@ -3429,7 +3410,7 @@ public class AudioManager { try { getService().setRingerModeInternal(ringerMode, getContext().getOpPackageName()); } catch (RemoteException e) { - Log.w(TAG, "Error calling setRingerModeInternal", e); + throw e.rethrowFromSystemServer(); } } @@ -3441,8 +3422,7 @@ public class AudioManager { try { return getService().getRingerModeInternal(); } catch (RemoteException e) { - Log.w(TAG, "Error calling getRingerModeInternal", e); - return RINGER_MODE_NORMAL; + throw e.rethrowFromSystemServer(); } } @@ -3454,7 +3434,7 @@ public class AudioManager { try { getService().setVolumePolicy(policy); } catch (RemoteException e) { - Log.w(TAG, "Error calling setVolumePolicy", e); + throw e.rethrowFromSystemServer(); } } @@ -3469,8 +3449,7 @@ public class AudioManager { try { return getService().setHdmiSystemAudioSupported(on); } catch (RemoteException e) { - Log.w(TAG, "Error setting system audio mode", e); - return AudioSystem.DEVICE_NONE; + throw e.rethrowFromSystemServer(); } } @@ -3484,8 +3463,7 @@ public class AudioManager { try { return getService().isHdmiSystemAudioSupported(); } catch (RemoteException e) { - Log.w(TAG, "Error querying system audio mode", e); - return false; + throw e.rethrowFromSystemServer(); } } diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index b594ae80c8a66..5f40e5c380858 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -12708,7 +12708,7 @@ public final class ActivityManagerService extends ActivityManagerNative PackageManager.COMPONENT_ENABLED_STATE_ENABLED, 0, UserHandle.USER_SYSTEM); } catch (RemoteException e) { - e.rethrowAsRuntimeException(); + throw e.rethrowAsRuntimeException(); } } startHomeActivityLocked(currentUserId, "systemReady");