When system server goes down, crash apps.

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 the default values returned.

The reality is that if the system process just died, init will be
along shortly to kill all running apps, so we should have no problem
rethrowing the RemoteException as a RuntimeException.

Bug: 27364859
Change-Id: If632cc36f68cd399a34de513b2d979abaa36fcaa
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index b1927d0..8b010f3 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -716,8 +716,7 @@
         try {
             return ActivityManagerNative.getDefault().getFrontActivityScreenCompatMode();
         } catch (RemoteException e) {
-            // System dead, we will be dead too soon!
-            return 0;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -726,7 +725,7 @@
         try {
             ActivityManagerNative.getDefault().setFrontActivityScreenCompatMode(mode);
         } catch (RemoteException e) {
-            // System dead, we will be dead too soon!
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -735,8 +734,7 @@
         try {
             return ActivityManagerNative.getDefault().getPackageScreenCompatMode(packageName);
         } catch (RemoteException e) {
-            // System dead, we will be dead too soon!
-            return 0;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -745,7 +743,7 @@
         try {
             ActivityManagerNative.getDefault().setPackageScreenCompatMode(packageName, mode);
         } catch (RemoteException e) {
-            // System dead, we will be dead too soon!
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -754,8 +752,7 @@
         try {
             return ActivityManagerNative.getDefault().getPackageAskScreenCompat(packageName);
         } catch (RemoteException e) {
-            // System dead, we will be dead too soon!
-            return false;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -764,7 +761,7 @@
         try {
             ActivityManagerNative.getDefault().setPackageAskScreenCompat(packageName, ask);
         } catch (RemoteException e) {
-            // System dead, we will be dead too soon!
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1049,6 +1046,7 @@
                     return ActivityManagerNative.getDefault().getTaskDescriptionIcon(iconFilename,
                             userId);
                 } catch (RemoteException e) {
+                    throw e.rethrowAsRuntimeException();
                 }
             }
             return null;
@@ -1429,8 +1427,7 @@
             return ActivityManagerNative.getDefault().getRecentTasks(maxNum,
                     flags, UserHandle.myUserId());
         } catch (RemoteException e) {
-            // System dead, we will be dead too soon!
-            return null;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1455,8 +1452,7 @@
             return ActivityManagerNative.getDefault().getRecentTasks(maxNum,
                     flags, userId);
         } catch (RemoteException e) {
-            // System dead, we will be dead too soon!
-            return null;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1591,8 +1587,7 @@
         try {
             appTasks = ActivityManagerNative.getDefault().getAppTasks(mContext.getPackageName());
         } catch (RemoteException e) {
-            // System dead, we will be dead too soon!
-            return null;
+            throw e.rethrowAsRuntimeException();
         }
         int numAppTasks = appTasks.size();
         for (int i = 0; i < numAppTasks; i++) {
@@ -1617,7 +1612,7 @@
             try {
                 mAppTaskThumbnailSize = ActivityManagerNative.getDefault().getAppTaskThumbnailSize();
             } catch (RemoteException e) {
-                throw new IllegalStateException("System dead?", e);
+                throw e.rethrowAsRuntimeException();
             }
         }
     }
@@ -1683,7 +1678,7 @@
             return ActivityManagerNative.getDefault().addAppTask(activity.getActivityToken(),
                     intent, description, thumbnail);
         } catch (RemoteException e) {
-            throw new IllegalStateException("System dead?", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1725,8 +1720,7 @@
         try {
             return ActivityManagerNative.getDefault().getTasks(maxNum, 0);
         } catch (RemoteException e) {
-            // System dead, we will be dead too soon!
-            return null;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1742,8 +1736,7 @@
         try {
             return ActivityManagerNative.getDefault().removeTask(taskId);
         } catch (RemoteException e) {
-            // System dead, we will be dead too soon!
-            return false;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1902,8 +1895,7 @@
         try {
             return ActivityManagerNative.getDefault().getTaskThumbnail(id);
         } catch (RemoteException e) {
-            // System dead, we will be dead too soon!
-            return null;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1912,8 +1904,7 @@
         try {
             return ActivityManagerNative.getDefault().isInHomeStack(taskId);
         } catch (RemoteException e) {
-            // System dead, we will be dead too soon!
-            return false;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1962,7 +1953,7 @@
         try {
             ActivityManagerNative.getDefault().moveTaskToFront(taskId, flags, options);
         } catch (RemoteException e) {
-            // System dead, we will be dead too soon!
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -2148,8 +2139,7 @@
             return ActivityManagerNative.getDefault()
                     .getServices(maxNum, 0);
         } catch (RemoteException e) {
-            // System dead, we will be dead too soon!
-            return null;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -2164,8 +2154,7 @@
             return ActivityManagerNative.getDefault()
                     .getRunningServiceControlPanel(service);
         } catch (RemoteException e) {
-            // System dead, we will be dead too soon!
-            return null;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -2269,6 +2258,7 @@
         try {
             ActivityManagerNative.getDefault().getMemoryInfo(outInfo);
         } catch (RemoteException e) {
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -2387,7 +2377,7 @@
             return ActivityManagerNative.getDefault().clearApplicationUserData(packageName,
                     observer, UserHandle.myUserId());
         } catch (RemoteException e) {
-            return false;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -2421,8 +2411,7 @@
             return ActivityManagerNative.getDefault().getGrantedUriPermissions(packageName,
                     UserHandle.myUserId());
         } catch (RemoteException e) {
-            Log.e(TAG, "Couldn't get granted URI permissions for :" + packageName, e);
-            return ParceledListSlice.emptyList();
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -2440,7 +2429,7 @@
             ActivityManagerNative.getDefault().clearGrantedUriPermissions(packageName,
                     UserHandle.myUserId());
         } catch (RemoteException e) {
-            Log.e(TAG, "Couldn't clear granted URI permissions for :" + packageName, e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -2560,7 +2549,7 @@
         try {
             return ActivityManagerNative.getDefault().getProcessesInErrorState();
         } catch (RemoteException e) {
-            return null;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -2874,7 +2863,7 @@
         try {
             return ActivityManagerNative.getDefault().getRunningExternalApplications();
         } catch (RemoteException e) {
-            return null;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -2891,7 +2880,7 @@
             return ActivityManagerNative.getDefault().setProcessMemoryTrimLevel(process, userId,
                     level);
         } catch (RemoteException e) {
-            return false;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -2909,7 +2898,7 @@
         try {
             return ActivityManagerNative.getDefault().getRunningAppProcesses();
         } catch (RemoteException e) {
-            return null;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -2928,7 +2917,7 @@
                     mContext.getOpPackageName());
             return RunningAppProcessInfo.procStateToImportance(procState);
         } catch (RemoteException e) {
-            return RunningAppProcessInfo.IMPORTANCE_GONE;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -2947,6 +2936,7 @@
         try {
             ActivityManagerNative.getDefault().getMyMemoryState(outState);
         } catch (RemoteException e) {
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -2965,7 +2955,7 @@
         try {
             return ActivityManagerNative.getDefault().getProcessMemoryInfo(pids);
         } catch (RemoteException e) {
-            return null;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -2999,6 +2989,7 @@
             ActivityManagerNative.getDefault().killBackgroundProcesses(packageName,
                     UserHandle.myUserId());
         } catch (RemoteException e) {
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -3015,7 +3006,7 @@
             ActivityManagerNative.getDefault().killUid(UserHandle.getAppId(uid),
                     UserHandle.getUserId(uid), reason);
         } catch (RemoteException e) {
-            Log.e(TAG, "Couldn't kill uid:" + uid, e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -3042,6 +3033,7 @@
         try {
             ActivityManagerNative.getDefault().forceStopPackage(packageName, userId);
         } catch (RemoteException e) {
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -3060,8 +3052,8 @@
         try {
             return ActivityManagerNative.getDefault().getDeviceConfigurationInfo();
         } catch (RemoteException e) {
+            throw e.rethrowAsRuntimeException();
         }
-        return null;
     }
 
     /**
@@ -3150,8 +3142,8 @@
         try {
             return ActivityManagerNative.getDefault().isUserAMonkey();
         } catch (RemoteException e) {
+            throw e.rethrowAsRuntimeException();
         }
-        return false;
     }
 
     /**
@@ -3226,10 +3218,8 @@
             return AppGlobals.getPackageManager()
                     .checkUidPermission(permission, uid);
         } catch (RemoteException e) {
-            // Should never happen, but if it does... deny!
-            Slog.e(TAG, "PackageManager is dead?!?", e);
+            throw e.rethrowAsRuntimeException();
         }
-        return PackageManager.PERMISSION_DENIED;
     }
 
     /** @hide */
@@ -3238,10 +3228,8 @@
             return AppGlobals.getPackageManager()
                     .checkUidPermission(permission, uid);
         } catch (RemoteException e) {
-            // Should never happen, but if it does... deny!
-            Slog.e(TAG, "PackageManager is dead?!?", e);
+            throw e.rethrowAsRuntimeException();
         }
-        return PackageManager.PERMISSION_DENIED;
     }
 
     /**
@@ -3277,7 +3265,7 @@
             return ActivityManagerNative.getDefault().handleIncomingUser(callingPid,
                     callingUid, userId, allowAll, requireFull, name, callerPackage);
         } catch (RemoteException e) {
-            throw new SecurityException("Failed calling activity manager", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -3292,7 +3280,7 @@
             ui = ActivityManagerNative.getDefault().getCurrentUser();
             return ui != null ? ui.id : 0;
         } catch (RemoteException e) {
-            return 0;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -3304,7 +3292,7 @@
         try {
             return ActivityManagerNative.getDefault().switchUser(userid);
         } catch (RemoteException e) {
-            return false;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -3328,7 +3316,7 @@
         try {
             return ActivityManagerNative.getDefault().isUserRunning(userId, 0);
         } catch (RemoteException e) {
-            return false;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -3338,7 +3326,7 @@
             return ActivityManagerNative.getDefault().isUserRunning(userId,
                     ActivityManager.FLAG_AND_LOCKED);
         } catch (RemoteException e) {
-            return false;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -3348,7 +3336,7 @@
             return ActivityManagerNative.getDefault().isUserRunning(userId,
                     ActivityManager.FLAG_AND_UNLOCKED);
         } catch (RemoteException e) {
-            return false;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -3433,6 +3421,7 @@
             ActivityManagerNative.getDefault().setDumpHeapDebugLimit(null, 0, pssSize,
                     mContext.getPackageName());
         } catch (RemoteException e) {
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -3451,6 +3440,7 @@
         try {
             ActivityManagerNative.getDefault().setDumpHeapDebugLimit(null, 0, 0, null);
         } catch (RemoteException e) {
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -3461,6 +3451,7 @@
         try {
             ActivityManagerNative.getDefault().startLockTaskMode(taskId);
         } catch (RemoteException e) {
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -3471,6 +3462,7 @@
         try {
             ActivityManagerNative.getDefault().stopLockTaskMode();
         } catch (RemoteException e) {
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -3497,7 +3489,7 @@
         try {
             return ActivityManagerNative.getDefault().getLockTaskModeState();
         } catch (RemoteException e) {
-            return ActivityManager.LOCK_TASK_MODE_NONE;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -3520,7 +3512,7 @@
             try {
                 mAppTaskImpl.finishAndRemoveTask();
             } catch (RemoteException e) {
-                Slog.e(TAG, "Invalid AppTask", e);
+                throw e.rethrowAsRuntimeException();
             }
         }
 
@@ -3533,8 +3525,7 @@
             try {
                 return mAppTaskImpl.getTaskInfo();
             } catch (RemoteException e) {
-                Slog.e(TAG, "Invalid AppTask", e);
-                return null;
+                throw e.rethrowAsRuntimeException();
             }
         }
 
@@ -3548,7 +3539,7 @@
             try {
                 mAppTaskImpl.moveToFront();
             } catch (RemoteException e) {
-                Slog.e(TAG, "Invalid AppTask", e);
+                throw e.rethrowAsRuntimeException();
             }
         }
 
@@ -3590,7 +3581,7 @@
             try {
                 mAppTaskImpl.setExcludeFromRecents(exclude);
             } catch (RemoteException e) {
-                Slog.e(TAG, "Invalid AppTask", e);
+                throw e.rethrowAsRuntimeException();
             }
         }
     }
diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java
index 91eabcc..6d716cc 100644
--- a/core/java/android/app/ApplicationPackageManager.java
+++ b/core/java/android/app/ApplicationPackageManager.java
@@ -143,7 +143,7 @@
                 return pi;
             }
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
 
         throw new NameNotFoundException(packageName);
@@ -154,7 +154,7 @@
         try {
             return mPM.currentToCanonicalPackageNames(names);
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -163,7 +163,7 @@
         try {
             return mPM.canonicalToCurrentPackageNames(names);
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -227,7 +227,7 @@
                 return gids;
             }
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
 
         throw new NameNotFoundException(packageName);
@@ -252,7 +252,7 @@
                 return uid;
             }
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
 
         throw new NameNotFoundException(packageName);
@@ -267,7 +267,7 @@
                 return pi;
             }
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
 
         throw new NameNotFoundException(name);
@@ -282,7 +282,7 @@
                 return pi;
             }
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
 
         throw new NameNotFoundException(group);
@@ -297,7 +297,7 @@
                 return pgi;
             }
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
 
         throw new NameNotFoundException(name);
@@ -308,7 +308,7 @@
         try {
             return mPM.getAllPermissionGroups(flags);
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -330,7 +330,7 @@
                 return maybeAdjustApplicationInfo(ai);
             }
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
 
         throw new NameNotFoundException(packageName);
@@ -370,7 +370,7 @@
                 return ai;
             }
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
 
         throw new NameNotFoundException(className.toString());
@@ -385,7 +385,7 @@
                 return ai;
             }
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
 
         throw new NameNotFoundException(className.toString());
@@ -400,7 +400,7 @@
                 return si;
             }
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
 
         throw new NameNotFoundException(className.toString());
@@ -415,7 +415,7 @@
                 return pi;
             }
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
 
         throw new NameNotFoundException(className.toString());
@@ -426,7 +426,7 @@
         try {
             return mPM.getSystemSharedLibraryNames();
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -436,7 +436,7 @@
         try {
             return mPM.getServicesSystemSharedLibraryPackageName();
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -445,7 +445,7 @@
         try {
             return mPM.getSystemAvailableFeatures();
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -459,7 +459,7 @@
         try {
             return mPM.hasSystemFeature(name, version);
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -468,7 +468,7 @@
         try {
             return mPM.checkPermission(permName, pkgName, mContext.getUserId());
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -477,7 +477,7 @@
         try {
             return mPM.isPermissionRevokedByPolicy(permName, pkgName, mContext.getUserId());
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -491,7 +491,7 @@
                 try {
                     mPermissionsControllerPackageName = mPM.getPermissionControllerPackageName();
                 } catch (RemoteException e) {
-                    throw new RuntimeException("Package manager has died", e);
+                    throw e.rethrowAsRuntimeException();
                 }
             }
             return mPermissionsControllerPackageName;
@@ -503,7 +503,7 @@
         try {
             return mPM.addPermission(info);
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -512,7 +512,7 @@
         try {
             return mPM.addPermissionAsync(info);
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -521,7 +521,7 @@
         try {
             mPM.removePermission(name);
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -531,7 +531,7 @@
         try {
             mPM.grantRuntimePermission(packageName, permissionName, user.getIdentifier());
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -541,7 +541,7 @@
         try {
             mPM.revokeRuntimePermission(packageName, permissionName, user.getIdentifier());
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -550,7 +550,7 @@
         try {
             return mPM.getPermissionFlags(permissionName, packageName, user.getIdentifier());
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -561,7 +561,7 @@
             mPM.updatePermissionFlags(permissionName, packageName, flagMask,
                     flagValues, user.getIdentifier());
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -571,7 +571,7 @@
             return mPM.shouldShowRequestPermissionRationale(permission,
                     mContext.getPackageName(), mContext.getUserId());
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -580,7 +580,7 @@
         try {
             return mPM.checkSignatures(pkg1, pkg2);
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -589,7 +589,7 @@
         try {
             return mPM.checkUidSignatures(uid1, uid2);
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -598,7 +598,7 @@
         try {
             return mPM.getPackagesForUid(uid);
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -607,7 +607,7 @@
         try {
             return mPM.getNameForUid(uid);
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -620,7 +620,7 @@
                 return uid;
             }
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
         throw new NameNotFoundException("No shared userid for user:"+sharedUserName);
     }
@@ -638,7 +638,7 @@
             ParceledListSlice<PackageInfo> slice = mPM.getInstalledPackages(flags, userId);
             return slice.getList();
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -652,7 +652,7 @@
                     permissions, flags, userId);
             return slice.getList();
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -664,7 +664,7 @@
             ParceledListSlice<ApplicationInfo> slice = mPM.getInstalledApplications(flags, userId);
             return slice.getList();
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -680,7 +680,7 @@
             }
             return Collections.emptyList();
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -695,7 +695,7 @@
             }
             return null;
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -705,9 +705,8 @@
             return mPM.isEphemeralApplication(
                     mContext.getPackageName(), mContext.getUserId());
         } catch (RemoteException e) {
-            Log.e(TAG, "System server is dead", e);
+            throw e.rethrowAsRuntimeException();
         }
-        return false;
     }
 
     @Override
@@ -724,11 +723,12 @@
                     mContext.getPackageName(), mContext.getUserId());
             if (cookie != null) {
                 return cookie;
+            } else {
+                return EmptyArray.BYTE;
             }
         } catch (RemoteException e) {
-            Log.e(TAG, "System server is dead", e);
+            throw e.rethrowAsRuntimeException();
         }
-        return EmptyArray.BYTE;
     }
 
     @Override
@@ -737,9 +737,8 @@
             return mPM.setEphemeralApplicationCookie(
                     mContext.getPackageName(), cookie, mContext.getUserId());
         } catch (RemoteException e) {
-            Log.e(TAG, "System server is dead", e);
+            throw e.rethrowAsRuntimeException();
         }
-        return false;
     }
 
     @Override
@@ -756,7 +755,7 @@
                 flags,
                 userId);
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -777,7 +776,7 @@
                 flags,
                 userId);
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -809,7 +808,7 @@
                                                   specificTypes, intent, intent.resolveTypeIfNeeded(resolver),
                                                   flags, mContext.getUserId());
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -825,7 +824,7 @@
                 flags,
                 userId);
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -843,7 +842,7 @@
                 flags,
                 mContext.getUserId());
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -856,7 +855,7 @@
                 flags,
                 userId);
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -872,7 +871,7 @@
             return mPM.queryIntentContentProviders(intent,
                     intent.resolveTypeIfNeeded(mContext.getContentResolver()), flags, userId);
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -892,7 +891,7 @@
         try {
             return mPM.resolveContentProvider(name, flags, userId);
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -904,7 +903,7 @@
                     = mPM.queryContentProviders(processName, uid, flags);
             return slice != null ? slice.getList() : null;
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -919,7 +918,7 @@
                 return ii;
             }
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
 
         throw new NameNotFoundException(className.toString());
@@ -931,7 +930,7 @@
         try {
             return mPM.queryInstrumentation(targetPackage, flags);
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1198,7 +1197,7 @@
                 return getResourcesForApplication(ai);
             }
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
         throw new NameNotFoundException("Package " + appPackageName + " doesn't exist");
     }
@@ -1213,7 +1212,7 @@
             }
             return mCachedSafeMode != 0;
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1229,7 +1228,7 @@
                 mPM.addOnPermissionsChangeListener(delegate);
                 mPermissionListeners.put(listener, delegate);
             } catch (RemoteException e) {
-                throw new RuntimeException("Package manager has died", e);
+                throw e.rethrowAsRuntimeException();
             }
         }
     }
@@ -1243,7 +1242,7 @@
                     mPM.removeOnPermissionsChangeListener(delegate);
                     mPermissionListeners.remove(listener);
                 } catch (RemoteException e) {
-                    throw new RuntimeException("Package manager has died", e);
+                    throw e.rethrowAsRuntimeException();
                 }
             }
         }
@@ -1544,7 +1543,8 @@
         try {
             mPM.installPackageAsUser(originPath, observer.getBinder(), flags, installerPackageName,
                     verificationParams, null, userId);
-        } catch (RemoteException ignored) {
+        } catch (RemoteException e) {
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1563,8 +1563,7 @@
             }
             return res;
         } catch (RemoteException e) {
-            // Should never happen!
-            throw new NameNotFoundException("Package " + packageName + " doesn't exist");
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1573,7 +1572,7 @@
         try {
             mPM.verifyPendingInstall(id, response);
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1583,7 +1582,7 @@
         try {
             mPM.extendVerificationTimeout(id, verificationCodeAtTimeout, millisecondsToDelay);
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1592,7 +1591,7 @@
         try {
             mPM.verifyIntentFilter(id, verificationCode, outFailedDomains);
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1601,8 +1600,7 @@
         try {
             return mPM.getIntentVerificationStatus(packageName, userId);
         } catch (RemoteException e) {
-            // Should never happen!
-            return PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1611,8 +1609,7 @@
         try {
             return mPM.updateIntentVerificationStatus(packageName, status, userId);
         } catch (RemoteException e) {
-            // Should never happen!
-            return false;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1621,8 +1618,7 @@
         try {
             return mPM.getIntentFilterVerifications(packageName);
         } catch (RemoteException e) {
-            // Should never happen!
-            return null;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1631,8 +1627,7 @@
         try {
             return mPM.getAllIntentFilters(packageName);
         } catch (RemoteException e) {
-            // Should never happen!
-            return null;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1641,8 +1636,7 @@
         try {
             return mPM.getDefaultBrowserPackageName(userId);
         } catch (RemoteException e) {
-            // Should never happen!
-            return null;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1651,8 +1645,7 @@
         try {
             return mPM.setDefaultBrowserPackageName(packageName, userId);
         } catch (RemoteException e) {
-            // Should never happen!
-            return false;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1662,7 +1655,7 @@
         try {
             mPM.setInstallerPackageName(targetPackage, installerPackageName);
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1671,9 +1664,8 @@
         try {
             return mPM.getInstallerPackageName(packageName);
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
-        return null;
     }
 
     @Override
@@ -1796,7 +1788,7 @@
                 return false;
             }
         } catch (RemoteException e) {
-            throw new RuntimeException("Package manager has died", e);
+            throw e.rethrowAsRuntimeException();
         }
 
         // Otherwise we can move to any private volume
@@ -1874,7 +1866,7 @@
         try {
             mPM.deletePackageAsUser(packageName, observer, userId, flags);
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1884,7 +1876,7 @@
         try {
             mPM.clearApplicationUserData(packageName, observer, mContext.getUserId());
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
     }
     @Override
@@ -1893,7 +1885,7 @@
         try {
             mPM.deleteApplicationCacheFiles(packageName, observer);
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1903,7 +1895,7 @@
         try {
             mPM.freeStorageAndNotify(volumeUuid, idealStorageSize, observer);
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1912,7 +1904,7 @@
         try {
             mPM.freeStorage(volumeUuid, freeStorageSize, pi);
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1922,9 +1914,8 @@
         try {
             return mPM.setPackagesSuspendedAsUser(packageNames, suspended, userId);
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
-        return packageNames;
     }
 
     @Override
@@ -1932,9 +1923,8 @@
         try {
             return mPM.isPackageSuspendedForUser(packageName, userId);
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
-        return false;
     }
 
     @Override
@@ -1943,7 +1933,7 @@
         try {
             mPM.getPackageSizeInfo(packageName, userHandle, observer);
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
     }
     @Override
@@ -1951,7 +1941,7 @@
         try {
             mPM.addPackageToPreferred(packageName);
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1960,7 +1950,7 @@
         try {
             mPM.removePackageFromPreferred(packageName);
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1969,9 +1959,8 @@
         try {
             return mPM.getPreferredPackages(flags);
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
-        return new ArrayList<PackageInfo>();
     }
 
     @Override
@@ -1980,7 +1969,7 @@
         try {
             mPM.addPreferredActivity(filter, match, set, activity, mContext.getUserId());
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -1990,7 +1979,7 @@
         try {
             mPM.addPreferredActivity(filter, match, set, activity, userId);
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -2000,7 +1989,7 @@
         try {
             mPM.replacePreferredActivity(filter, match, set, activity, mContext.getUserId());
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -2011,7 +2000,7 @@
         try {
             mPM.replacePreferredActivity(filter, match, set, activity, userId);
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -2020,7 +2009,7 @@
         try {
             mPM.clearPackagePreferredActivities(packageName);
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -2030,9 +2019,8 @@
         try {
             return mPM.getPreferredActivities(outFilters, outActivities, packageName);
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
-        return 0;
     }
 
     @Override
@@ -2040,9 +2028,8 @@
         try {
             return mPM.getHomeActivities(outActivities);
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
-        return null;
     }
 
     @Override
@@ -2051,7 +2038,7 @@
         try {
             mPM.setComponentEnabledSetting(componentName, newState, flags, mContext.getUserId());
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -2060,9 +2047,8 @@
         try {
             return mPM.getComponentEnabledSetting(componentName, mContext.getUserId());
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
-        return PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
     }
 
     @Override
@@ -2072,7 +2058,7 @@
             mPM.setApplicationEnabledSetting(packageName, newState, flags,
                     mContext.getUserId(), mContext.getOpPackageName());
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -2081,9 +2067,8 @@
         try {
             return mPM.getApplicationEnabledSetting(packageName, mContext.getUserId());
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
-        return PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
     }
 
     @Override
@@ -2092,20 +2077,18 @@
         try {
             return mPM.setApplicationHiddenSettingAsUser(packageName, hidden,
                     user.getIdentifier());
-        } catch (RemoteException re) {
-            // Should never happen!
+        } catch (RemoteException e) {
+            throw e.rethrowAsRuntimeException();
         }
-        return false;
     }
 
     @Override
     public boolean getApplicationHiddenSettingAsUser(String packageName, UserHandle user) {
         try {
             return mPM.getApplicationHiddenSettingAsUser(packageName, user.getIdentifier());
-        } catch (RemoteException re) {
-            // Should never happen!
+        } catch (RemoteException e) {
+            throw e.rethrowAsRuntimeException();
         }
-        return false;
     }
 
     /** @hide */
@@ -2113,26 +2096,22 @@
     public KeySet getKeySetByAlias(String packageName, String alias) {
         Preconditions.checkNotNull(packageName);
         Preconditions.checkNotNull(alias);
-        KeySet ks;
         try {
-            ks = mPM.getKeySetByAlias(packageName, alias);
+            return mPM.getKeySetByAlias(packageName, alias);
         } catch (RemoteException e) {
-            return null;
+            throw e.rethrowAsRuntimeException();
         }
-        return ks;
     }
 
     /** @hide */
     @Override
     public KeySet getSigningKeySet(String packageName) {
         Preconditions.checkNotNull(packageName);
-        KeySet ks;
         try {
-            ks = mPM.getSigningKeySet(packageName);
+            return mPM.getSigningKeySet(packageName);
         } catch (RemoteException e) {
-            return null;
+            throw e.rethrowAsRuntimeException();
         }
-        return ks;
     }
 
     /** @hide */
@@ -2143,7 +2122,7 @@
         try {
             return mPM.isPackageSignedByKeySet(packageName, ks);
         } catch (RemoteException e) {
-            return false;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -2155,7 +2134,7 @@
         try {
             return mPM.isPackageSignedByKeySetExactly(packageName, ks);
         } catch (RemoteException e) {
-            return false;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -2167,9 +2146,8 @@
         try {
             return mPM.getVerifierDeviceIdentity();
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
-        return null;
     }
 
     /**
@@ -2180,7 +2158,7 @@
         try {
             return mPM.isUpgrade();
         } catch (RemoteException e) {
-            return false;
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -2218,7 +2196,7 @@
             mPM.addCrossProfileIntentFilter(filter, mContext.getOpPackageName(),
                     sourceUserId, targetUserId, flags);
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
     }
 
@@ -2230,7 +2208,7 @@
         try {
             mPM.clearCrossProfileIntentFilters(sourceUserId, mContext.getOpPackageName());
         } catch (RemoteException e) {
-            // Should never happen!
+            throw e.rethrowAsRuntimeException();
         }
     }
 
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index da7f85f..0edc43c 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -36,7 +36,6 @@
 import android.graphics.drawable.Drawable;
 import android.os.storage.StorageManager;
 import android.provider.Settings;
-import android.util.Log;
 import android.view.WindowManager.LayoutParams;
 
 import com.android.internal.R;
@@ -700,8 +699,7 @@
         try {
             return mService.getUserInfo(getUserHandle()).name;
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not get user name", re);
-            return "";
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -771,8 +769,7 @@
         try {
             return mService.isRestricted();
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not check if user is limited ", re);
-            return false;
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -784,8 +781,7 @@
         try {
             return mService.canHaveRestrictedProfile(userId);
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not check if user can have restricted profile", re);
-            return false;
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -847,8 +843,8 @@
     public boolean isUserRunning(int userId) {
         try {
             return ActivityManagerNative.getDefault().isUserRunning(userId, 0);
-        } catch (RemoteException e) {
-            return false;
+        } catch (RemoteException re) {
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -864,8 +860,8 @@
             // TODO: reconcile stopped vs stopping?
             return ActivityManagerNative.getDefault().isUserRunning(
                     user.getIdentifier(), ActivityManager.FLAG_OR_STOPPED);
-        } catch (RemoteException e) {
-            return false;
+        } catch (RemoteException re) {
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -893,8 +889,8 @@
         try {
             return ActivityManagerNative.getDefault().isUserRunning(
                     user.getIdentifier(), ActivityManager.FLAG_AND_LOCKED);
-        } catch (RemoteException e) {
-            return false;
+        } catch (RemoteException re) {
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -922,8 +918,8 @@
         try {
             return ActivityManagerNative.getDefault().isUserRunning(
                     user.getIdentifier(), ActivityManager.FLAG_AND_UNLOCKED);
-        } catch (RemoteException e) {
-            return false;
+        } catch (RemoteException re) {
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -968,8 +964,7 @@
         try {
             return mService.getUserInfo(userHandle);
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not get user info", re);
-            return null;
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -990,8 +985,7 @@
         try {
             return mService.getUserRestrictions(userHandle.getIdentifier());
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not get user restrictions", re);
-            return Bundle.EMPTY;
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1007,9 +1001,7 @@
         try {
             return mService.hasBaseUserRestriction(restrictionKey, userHandle.getIdentifier());
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not get base user restrictions for user " +
-                    userHandle.getIdentifier(), re);
-            return false;
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1065,7 +1057,7 @@
         try {
             mService.setUserRestriction(key, value, userHandle.getIdentifier());
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not set user restriction", re);
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1092,8 +1084,7 @@
             return mService.hasUserRestriction(restrictionKey,
                     userHandle.getIdentifier());
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not check user restrictions", re);
-            return false;
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1147,7 +1138,7 @@
                 mService.setUserRestriction(DISALLOW_OUTGOING_CALLS, true, user.id);
             }
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not create a user", re);
+            throw re.rethrowAsRuntimeException();
         }
         return user;
     }
@@ -1167,7 +1158,7 @@
                         Settings.Secure.SKIP_FIRST_USE_HINTS, "1", guest.id);
             }
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not create a user", re);
+            throw re.rethrowAsRuntimeException();
         }
         return guest;
     }
@@ -1188,8 +1179,7 @@
         try {
             return mService.createProfileForUser(name, flags, userHandle);
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not create a user", re);
-            return null;
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1211,10 +1201,9 @@
                         UserHandle.of(user.id));
             }
             return user;
-        } catch (RemoteException e) {
-            Log.w(TAG, "Could not create a restricted profile", e);
+        } catch (RemoteException re) {
+            throw re.rethrowAsRuntimeException();
         }
-        return null;
     }
 
     /**
@@ -1282,8 +1271,7 @@
         try {
             return mService.getSeedAccountName();
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not get the seed account name", re);
-            return null;
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1297,8 +1285,7 @@
         try {
             return mService.getSeedAccountType();
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not get the seed account type", re);
-            return null;
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1314,8 +1301,7 @@
         try {
             return mService.getSeedAccountOptions();
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not get the seed account options", re);
-            return null;
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1336,7 +1322,7 @@
             mService.setSeedAccountData(userId, accountName, accountType, accountOptions,
                     /* persist= */ true);
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not set the seed account data", re);
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1349,7 +1335,7 @@
         try {
             mService.clearSeedAccountData();
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not clear the seed account data", re);
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1364,8 +1350,7 @@
         try {
             return mService.markGuestForDeletion(userHandle);
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not mark guest for deletion", re);
-            return false;
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1384,8 +1369,8 @@
     public void setUserEnabled(@UserIdInt int userHandle) {
         try {
             mService.setUserEnabled(userHandle);
-        } catch (RemoteException e) {
-            Log.w(TAG, "Could not enable the profile", e);
+        } catch (RemoteException re) {
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1407,8 +1392,7 @@
         try {
             return mService.getUsers(false);
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not get user list", re);
-            return null;
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1430,8 +1414,7 @@
             }
             return result;
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not get users list", re);
-            return null;
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1447,8 +1430,7 @@
         try {
             return mService.getUserAccount(userHandle);
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not get user account", re);
-            return null;
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1464,7 +1446,7 @@
         try {
             mService.setUserAccount(userHandle, accountName);
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not set user account", re);
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1479,8 +1461,7 @@
         try {
             return mService.getPrimaryUser();
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not get Primary user", re);
-            return null;
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1517,8 +1498,7 @@
         try {
             return mService.canAddMoreManagedProfiles(userId, allowedToRemoveOne);
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not check if we can add more managed profiles", re);
-            return false;
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1537,8 +1517,7 @@
         try {
             return mService.getProfiles(userHandle, false /* enabledOnly */);
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not get user list", re);
-            return null;
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1553,8 +1532,7 @@
         try {
             return mService.isSameProfileGroup(userId, otherUserId);
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not get user list", re);
-            return false;
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1572,8 +1550,7 @@
         try {
             return mService.getProfiles(userHandle, true /* enabledOnly */);
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not get user list", re);
-            return null;
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1589,8 +1566,7 @@
         try {
             users = mService.getProfiles(UserHandle.myUserId(), true /* enabledOnly */);
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not get user list", re);
-            return null;
+            throw re.rethrowAsRuntimeException();
         }
         for (UserInfo info : users) {
             UserHandle userHandle = new UserHandle(info.id);
@@ -1610,8 +1586,7 @@
         try {
             return mService.getCredentialOwnerProfile(userHandle);
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not get credential owner", re);
-            return -1;
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1625,8 +1600,7 @@
         try {
             return mService.getProfileParent(userHandle);
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not get profile parent", re);
-            return null;
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1640,8 +1614,8 @@
     public void setQuietModeEnabled(@UserIdInt int userHandle, boolean enableQuietMode) {
         try {
             mService.setQuietModeEnabled(userHandle, enableQuietMode);
-        } catch (RemoteException e) {
-            Log.w(TAG, "Could not change the profile's quiet mode", e);
+        } catch (RemoteException re) {
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1654,10 +1628,9 @@
     public boolean isQuietModeEnabled(UserHandle userHandle) {
         try {
             return mService.isQuietModeEnabled(userHandle.getIdentifier());
-        } catch (RemoteException e) {
-            Log.w(TAG, "Could not query the profile's quiet mode", e);
+        } catch (RemoteException re) {
+            throw re.rethrowAsRuntimeException();
         }
-        return false;
     }
 
     /**
@@ -1742,8 +1715,7 @@
         try {
             return mService.getUsers(excludeDying);
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not get user list", re);
-            return null;
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1757,8 +1729,7 @@
         try {
             return mService.removeUser(userHandle);
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not remove user ", re);
-            return false;
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1774,7 +1745,7 @@
         try {
             mService.setUserName(userHandle, name);
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not set the user name ", re);
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1788,7 +1759,7 @@
         try {
             mService.setUserIcon(userHandle, icon);
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not set the user icon ", re);
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1813,7 +1784,7 @@
                 }
             }
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not get the user icon ", re);
+            throw re.rethrowAsRuntimeException();
         }
         return null;
     }
@@ -1869,9 +1840,8 @@
         try {
             return mService.getUserSerialNumber(userHandle);
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not get serial number for user " + userHandle);
+            throw re.rethrowAsRuntimeException();
         }
-        return -1;
     }
 
     /**
@@ -1887,9 +1857,8 @@
         try {
             return mService.getUserHandle(userSerialNumber);
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not get userHandle for user " + userSerialNumber);
+            throw re.rethrowAsRuntimeException();
         }
-        return -1;
     }
 
     /**
@@ -1915,9 +1884,8 @@
         try {
             return mService.getApplicationRestrictions(packageName);
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not get application restrictions for package " + packageName);
+            throw re.rethrowAsRuntimeException();
         }
-        return null;
     }
 
     /**
@@ -1927,9 +1895,8 @@
         try {
             return mService.getApplicationRestrictionsForUser(packageName, user.getIdentifier());
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not get application restrictions for user " + user.getIdentifier());
+            throw re.rethrowAsRuntimeException();
         }
-        return null;
     }
 
     /**
@@ -1940,7 +1907,7 @@
         try {
             mService.setApplicationRestrictions(packageName, restrictions, user.getIdentifier());
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not set application restrictions for user " + user.getIdentifier());
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1964,7 +1931,7 @@
         try {
             mService.setDefaultGuestRestrictions(restrictions);
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not set guest restrictions");
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -1976,9 +1943,8 @@
         try {
             return mService.getDefaultGuestRestrictions();
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not set guest restrictions");
+            throw re.rethrowAsRuntimeException();
         }
-        return new Bundle();
     }
 
     /**
@@ -1991,8 +1957,7 @@
         try {
             return mService.getUserCreationTime(userHandle.getIdentifier());
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not get user creation time", re);
-            return 0;
+            throw re.rethrowAsRuntimeException();
         }
     }
 
@@ -2008,8 +1973,7 @@
         try {
             return mService.someUserHasSeedAccount(accountName, accountType);
         } catch (RemoteException re) {
-            Log.w(TAG, "Could not check seed accounts", re);
-            return false;
+            throw re.rethrowAsRuntimeException();
         }
     }
 }