- 需要启动exported为false的页面可以使用
START_ANY_ACTIVITY
权限,在AndroidManifeset.xml中直接声明就可以,当然应用得有系统签名的权限,三方签名的应用是没有该权限的
// ActivityStarter.java
private int startActivity(IApplicationThread caller, Intent intent, Intent ephemeralIntent,
String resolvedType, ActivityInfo aInfo, ResolveInfo rInfo,
IVoiceInteractionSession voiceSession, IVoiceInteractor voiceInteractor,
IBinder resultTo, String resultWho, int requestCode, int callingPid, int callingUid,
String callingPackage, int realCallingPid, int realCallingUid, int startFlags,
SafeActivityOptions options,
boolean ignoreTargetSecurity, boolean componentSpecified, ActivityRecord[] outActivity,
TaskRecord inTask, boolean allowPendingRemoteAnimationRegistryLookup) {
......
boolean abort = !mSupervisor.checkStartAnyActivityPermission(intent, aInfo, resultWho,
requestCode, callingPid, callingUid, callingPackage, ignoreTargetSecurity,
inTask != null, callerApp, resultRecord, resultStack);
......
}
// ActivityStackSupervisor.java
boolean checkStartAnyActivityPermission(Intent intent, ActivityInfo aInfo,
String resultWho, int requestCode, int callingPid, int callingUid,
String callingPackage, boolean ignoreTargetSecurity, boolean launchingInTask,
ProcessRecord callerApp, ActivityRecord resultRecord, ActivityStack resultStack) {
final boolean isCallerRecents = mService.getRecentTasks() != null &&
mService.getRecentTasks().isCallerRecents(callingUid);
// 校验START_ANY_ACTIVITY权限
final int startAnyPerm = mService.checkPermission(START_ANY_ACTIVITY, callingPid,
callingUid);
if (startAnyPerm == PERMISSION_GRANTED || (isCallerRecents && launchingInTask)) {
// If the caller has START_ANY_ACTIVITY, ignore all checks below. In addition, if the
// caller is the recents component and we are specifically starting an activity in an
// existing task, then also allow the activity to be fully relaunched.
return true;
}
......
}
- 可以解决
SecurityException: Permission Denial
异常
java.lang.SecurityException: Permission Denial: starting Intent { flg=0x10000000 cmp=com.chan.test/com.chan.test.activities.MainActivity } from ProcessRecord{168983d 2145:com.chan.test1/u0a15} (pid=2145, uid=10015) not exported from uid 10063