- 需要啟動exported為false的頁面可以使用
START_ANY_ACTIVITY
權(quán)限螃诅,在AndroidManifeset.xml中直接聲明就可以,當(dāng)然應(yīng)用得有系統(tǒng)簽名的權(quán)限取董,三方簽名的應(yīng)用是沒有該權(quán)限的
// 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權(quán)限
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