Merge "Throw exception from startActivity if not allowed." into klp-modular-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
1a7e9e66a6
@@ -147,6 +147,7 @@ public class ActivityView extends ViewGroup {
|
|||||||
if (mSurface != null) {
|
if (mSurface != null) {
|
||||||
mActivityContainer.startActivity(intent);
|
mActivityContainer.startActivity(intent);
|
||||||
} else {
|
} else {
|
||||||
|
mActivityContainer.checkEmbeddedAllowed(intent);
|
||||||
mQueuedIntent = intent;
|
mQueuedIntent = intent;
|
||||||
mQueuedPendingIntent = null;
|
mQueuedPendingIntent = null;
|
||||||
}
|
}
|
||||||
@@ -162,6 +163,7 @@ public class ActivityView extends ViewGroup {
|
|||||||
if (mSurface != null) {
|
if (mSurface != null) {
|
||||||
mActivityContainer.startActivityIntentSender(iIntentSender);
|
mActivityContainer.startActivityIntentSender(iIntentSender);
|
||||||
} else {
|
} else {
|
||||||
|
mActivityContainer.checkEmbeddedAllowedIntentSender(iIntentSender);
|
||||||
mQueuedPendingIntent = iIntentSender;
|
mQueuedPendingIntent = iIntentSender;
|
||||||
mQueuedIntent = null;
|
mQueuedIntent = null;
|
||||||
}
|
}
|
||||||
@@ -177,6 +179,7 @@ public class ActivityView extends ViewGroup {
|
|||||||
if (mSurface != null) {
|
if (mSurface != null) {
|
||||||
mActivityContainer.startActivityIntentSender(iIntentSender);
|
mActivityContainer.startActivityIntentSender(iIntentSender);
|
||||||
} else {
|
} else {
|
||||||
|
mActivityContainer.checkEmbeddedAllowedIntentSender(iIntentSender);
|
||||||
mQueuedPendingIntent = iIntentSender;
|
mQueuedPendingIntent = iIntentSender;
|
||||||
mQueuedIntent = null;
|
mQueuedIntent = null;
|
||||||
}
|
}
|
||||||
@@ -326,6 +329,24 @@ public class ActivityView extends ViewGroup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void checkEmbeddedAllowed(Intent intent) {
|
||||||
|
try {
|
||||||
|
mIActivityContainer.checkEmbeddedAllowed(intent);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"ActivityView: Unable to startActivity from Intent. " + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void checkEmbeddedAllowedIntentSender(IIntentSender intentSender) {
|
||||||
|
try {
|
||||||
|
mIActivityContainer.checkEmbeddedAllowedIntentSender(intentSender);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"ActivityView: Unable to startActivity from IntentSender. " + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int getDisplayId() {
|
int getDisplayId() {
|
||||||
try {
|
try {
|
||||||
return mIActivityContainer.getDisplayId();
|
return mIActivityContainer.getDisplayId();
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ interface IActivityContainer {
|
|||||||
void setSurface(in Surface surface, int width, int height, int density);
|
void setSurface(in Surface surface, int width, int height, int density);
|
||||||
int startActivity(in Intent intent);
|
int startActivity(in Intent intent);
|
||||||
int startActivityIntentSender(in IIntentSender intentSender);
|
int startActivityIntentSender(in IIntentSender intentSender);
|
||||||
|
void checkEmbeddedAllowed(in Intent intent);
|
||||||
|
void checkEmbeddedAllowedIntentSender(in IIntentSender intentSender);
|
||||||
int getDisplayId();
|
int getDisplayId();
|
||||||
boolean injectEvent(in InputEvent event);
|
boolean injectEvent(in InputEvent event);
|
||||||
void release();
|
void release();
|
||||||
|
|||||||
@@ -3057,6 +3057,40 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
|||||||
null, 0, FORCE_NEW_TASK_FLAGS, FORCE_NEW_TASK_FLAGS, null, this);
|
null, 0, FORCE_NEW_TASK_FLAGS, FORCE_NEW_TASK_FLAGS, null, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkEmbeddedAllowedInner(Intent intent, String resolvedType) {
|
||||||
|
int userId = mService.handleIncomingUser(Binder.getCallingPid(),
|
||||||
|
Binder.getCallingUid(), mCurrentUser, false, true, "ActivityContainer", null);
|
||||||
|
if (resolvedType == null) {
|
||||||
|
resolvedType = intent.getType();
|
||||||
|
if (resolvedType == null && intent.getData() != null
|
||||||
|
&& "content".equals(intent.getData().getScheme())) {
|
||||||
|
resolvedType = mService.getProviderMimeType(intent.getData(), userId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ActivityInfo aInfo = resolveActivity(intent, resolvedType, 0, null, null, userId);
|
||||||
|
if ((aInfo.flags & ActivityInfo.FLAG_ALLOW_EMBEDDED) == 0) {
|
||||||
|
throw new SecurityException(
|
||||||
|
"Attempt to embed activity that has not set allowEmbedded=\"true\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Throw a SecurityException if allowEmbedded is not true */
|
||||||
|
@Override
|
||||||
|
public final void checkEmbeddedAllowed(Intent intent) {
|
||||||
|
checkEmbeddedAllowedInner(intent, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Throw a SecurityException if allowEmbedded is not true */
|
||||||
|
@Override
|
||||||
|
public final void checkEmbeddedAllowedIntentSender(IIntentSender intentSender) {
|
||||||
|
if (!(intentSender instanceof PendingIntentRecord)) {
|
||||||
|
throw new IllegalArgumentException("Bad PendingIntent object");
|
||||||
|
}
|
||||||
|
PendingIntentRecord pendingIntent = (PendingIntentRecord) intentSender;
|
||||||
|
checkEmbeddedAllowedInner(pendingIntent.key.requestIntent,
|
||||||
|
pendingIntent.key.requestResolvedType);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBinder asBinder() {
|
public IBinder asBinder() {
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
Reference in New Issue
Block a user