Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e5c42621 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Improve reporting to apps of transaction too large failures.

If the app tried to do various things with too much data --
starting an activity, starting a service, sending a broadcast --
this would fairly silently fail with little indication of what
was going on.  Fix this in two ways:

- Now when the native code generates a TransactionTooLargeException,
  it may include an additional message in it telling you how much
  data was in the parcel being sent, to help you understand why
  this happening.

- In all the framework code paths where we call to the system and
  may fail, convert these failures into a a runtime exception and
  rethrow them back to the app so that it will clearly get the
  above message.

Change-Id: I745159b97d3edb6fca86aa09cbc40c1f15a7d128
parent 8b20cdb2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -23576,6 +23576,7 @@ package android.os {
  public class TransactionTooLargeException extends android.os.RemoteException {
    ctor public TransactionTooLargeException();
    ctor public TransactionTooLargeException(java.lang.String);
  }
  public final class UserHandle implements android.os.Parcelable {
+1 −0
Original line number Diff line number Diff line
@@ -25498,6 +25498,7 @@ package android.os {
  public class TransactionTooLargeException extends android.os.RemoteException {
    ctor public TransactionTooLargeException();
    ctor public TransactionTooLargeException(java.lang.String);
  }
  public final class UserHandle implements android.os.Parcelable {
+21 −6
Original line number Diff line number Diff line
@@ -689,7 +689,8 @@ class ContextImpl extends Context {
                intent.resolveTypeIfNeeded(getContentResolver()),
                null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, options,
                user.getIdentifier());
        } catch (RemoteException re) {
        } catch (RemoteException e) {
            throw new RuntimeException("Failure from system", e);
        }
    }

@@ -754,6 +755,7 @@ class ContextImpl extends Context {
            }
            Instrumentation.checkStartActivityResult(result, null);
        } catch (RemoteException e) {
            throw new RuntimeException("Failure from system", e);
        }
    }

@@ -768,6 +770,7 @@ class ContextImpl extends Context {
                Activity.RESULT_OK, null, null, null, AppOpsManager.OP_NONE, false, false,
                getUserId());
        } catch (RemoteException e) {
            throw new RuntimeException("Failure from system", e);
        }
    }

@@ -782,6 +785,7 @@ class ContextImpl extends Context {
                Activity.RESULT_OK, null, null, receiverPermission, AppOpsManager.OP_NONE,
                false, false, getUserId());
        } catch (RemoteException e) {
            throw new RuntimeException("Failure from system", e);
        }
    }

@@ -796,6 +800,7 @@ class ContextImpl extends Context {
                Activity.RESULT_OK, null, null, receiverPermission, appOp, false, false,
                getUserId());
        } catch (RemoteException e) {
            throw new RuntimeException("Failure from system", e);
        }
    }

@@ -811,6 +816,7 @@ class ContextImpl extends Context {
                Activity.RESULT_OK, null, null, receiverPermission, AppOpsManager.OP_NONE, true, false,
                getUserId());
        } catch (RemoteException e) {
            throw new RuntimeException("Failure from system", e);
        }
    }

@@ -854,6 +860,7 @@ class ContextImpl extends Context {
                initialCode, initialData, initialExtras, receiverPermission, appOp,
                    true, false, getUserId());
        } catch (RemoteException e) {
            throw new RuntimeException("Failure from system", e);
        }
    }

@@ -866,6 +873,7 @@ class ContextImpl extends Context {
                    intent, resolvedType, null, Activity.RESULT_OK, null, null, null,
                    AppOpsManager.OP_NONE, false, false, user.getIdentifier());
        } catch (RemoteException e) {
            throw new RuntimeException("Failure from system", e);
        }
    }

@@ -886,6 +894,7 @@ class ContextImpl extends Context {
                    Activity.RESULT_OK, null, null, receiverPermission, appOp, false, false,
                    user.getIdentifier());
        } catch (RemoteException e) {
            throw new RuntimeException("Failure from system", e);
        }
    }

@@ -927,6 +936,7 @@ class ContextImpl extends Context {
                initialCode, initialData, initialExtras, receiverPermission,
                    appOp, true, false, user.getIdentifier());
        } catch (RemoteException e) {
            throw new RuntimeException("Failure from system", e);
        }
    }

@@ -942,6 +952,7 @@ class ContextImpl extends Context {
                Activity.RESULT_OK, null, null, null, AppOpsManager.OP_NONE, false, true,
                getUserId());
        } catch (RemoteException e) {
            throw new RuntimeException("Failure from system", e);
        }
    }

@@ -977,6 +988,7 @@ class ContextImpl extends Context {
                initialCode, initialData, initialExtras, null,
                    AppOpsManager.OP_NONE, true, true, getUserId());
        } catch (RemoteException e) {
            throw new RuntimeException("Failure from system", e);
        }
    }

@@ -993,6 +1005,7 @@ class ContextImpl extends Context {
            ActivityManagerNative.getDefault().unbroadcastIntent(
                    mMainThread.getApplicationThread(), intent, getUserId());
        } catch (RemoteException e) {
            throw new RuntimeException("Failure from system", e);
        }
    }

@@ -1006,6 +1019,7 @@ class ContextImpl extends Context {
                mMainThread.getApplicationThread(), intent, resolvedType, null,
                Activity.RESULT_OK, null, null, null, AppOpsManager.OP_NONE, false, true, user.getIdentifier());
        } catch (RemoteException e) {
            throw new RuntimeException("Failure from system", e);
        }
    }

@@ -1040,6 +1054,7 @@ class ContextImpl extends Context {
                initialCode, initialData, initialExtras, null,
                    AppOpsManager.OP_NONE, true, true, user.getIdentifier());
        } catch (RemoteException e) {
            throw new RuntimeException("Failure from system", e);
        }
    }

@@ -1056,6 +1071,7 @@ class ContextImpl extends Context {
            ActivityManagerNative.getDefault().unbroadcastIntent(
                    mMainThread.getApplicationThread(), intent, user.getIdentifier());
        } catch (RemoteException e) {
            throw new RuntimeException("Failure from system", e);
        }
    }

@@ -1171,7 +1187,7 @@ class ContextImpl extends Context {
            }
            return cn;
        } catch (RemoteException e) {
            return null;
            throw new RuntimeException("Failure from system", e);
        }
    }

@@ -1193,7 +1209,7 @@ class ContextImpl extends Context {
            }
            return res != 0;
        } catch (RemoteException e) {
            return false;
            throw new RuntimeException("Failure from system", e);
        }
    }

@@ -1242,7 +1258,7 @@ class ContextImpl extends Context {
            }
            return res != 0;
        } catch (RemoteException e) {
            return false;
            throw new RuntimeException("Failure from system", e);
        }
    }

@@ -1274,9 +1290,8 @@ class ContextImpl extends Context {
                    className, profileFile, 0, arguments, null, null, getUserId(),
                    null /* ABI override */);
        } catch (RemoteException e) {
            // System has crashed, nothing we can do.
            throw new RuntimeException("Failure from system", e);
        }
        return false;
    }

    @Override
+6 −0
Original line number Diff line number Diff line
@@ -1506,6 +1506,7 @@ public class Instrumentation {
                        requestCode, 0, null, options);
            checkStartActivityResult(result, intent);
        } catch (RemoteException e) {
            throw new RuntimeException("Failure from system", e);
        }
        return null;
    }
@@ -1563,6 +1564,7 @@ public class Instrumentation {
                        token, options, userId);
            checkStartActivityResult(result, intents[0]);
        } catch (RemoteException e) {
            throw new RuntimeException("Failure from system", e);
        }
    }

@@ -1622,6 +1624,7 @@ public class Instrumentation {
                        token, target, requestCode, 0, null, options);
            checkStartActivityResult(result, intent);
        } catch (RemoteException e) {
            throw new RuntimeException("Failure from system", e);
        }
        return null;
    }
@@ -1682,6 +1685,7 @@ public class Instrumentation {
                        requestCode, 0, null, options, user.getIdentifier());
            checkStartActivityResult(result, intent);
        } catch (RemoteException e) {
            throw new RuntimeException("Failure from system", e);
        }
        return null;
    }
@@ -1719,6 +1723,7 @@ public class Instrumentation {
                        requestCode, 0, null, options, userId);
            checkStartActivityResult(result, intent);
        } catch (RemoteException e) {
            throw new RuntimeException("Failure from system", e);
        }
        return null;
    }
@@ -1753,6 +1758,7 @@ public class Instrumentation {
                    intent, intent.resolveTypeIfNeeded(who.getContentResolver()), options);
            checkStartActivityResult(result, intent);
        } catch (RemoteException e) {
            throw new RuntimeException("Failure from system", e);
        }
        return;
    }
+4 −0
Original line number Diff line number Diff line
@@ -56,4 +56,8 @@ public class TransactionTooLargeException extends RemoteException {
    public TransactionTooLargeException() {
        super();
    }

    public TransactionTooLargeException(String msg) {
        super(msg);
    }
}
Loading