Use a more efficient API to tell if a process belongs to springboard or not.

llvm-svn: 160655
This commit is contained in:
Jim Ingham 2012-07-24 01:23:53 +00:00
parent 45da9e2653
commit 1bfe4f6417
2 changed files with 6 additions and 44 deletions

View File

@ -49,28 +49,8 @@ static CFStringRef CopyBundleIDForPath (const char *app_buncle_path, DNBError &e
static bool
IsSBProcess (nub_process_t pid)
{
bool opt_runningApps = true;
bool opt_debuggable = false;
CFReleaser<CFArrayRef> sbsAppIDs (::SBSCopyApplicationDisplayIdentifiers (opt_runningApps, opt_debuggable));
if (sbsAppIDs.get() != NULL)
{
CFIndex count = ::CFArrayGetCount (sbsAppIDs.get());
CFIndex i = 0;
for (i = 0; i < count; i++)
{
CFStringRef displayIdentifier = (CFStringRef)::CFArrayGetValueAtIndex (sbsAppIDs.get(), i);
// Get the process id for the app (if there is one)
pid_t sbs_pid = INVALID_NUB_PROCESS;
if (::SBSProcessIDForDisplayIdentifier ((CFStringRef)displayIdentifier, &sbs_pid) == TRUE)
{
if (sbs_pid == pid)
return true;
}
}
}
return false;
CFReleaser<CFArrayRef> appIdsForPID (::SBSCopyDisplayIdentifiersForProcessID(pid));
return appIdsForPID.get() != NULL;
}
#endif

View File

@ -120,28 +120,10 @@ bool
IsSBProcess (nub_process_t pid)
{
#ifdef WITH_SPRINGBOARD
bool opt_runningApps = true;
bool opt_debuggable = false;
CFReleaser<CFArrayRef> sbsAppIDs (::SBSCopyApplicationDisplayIdentifiers (opt_runningApps, opt_debuggable));
if (sbsAppIDs.get() != NULL)
{
CFIndex count = ::CFArrayGetCount (sbsAppIDs.get());
CFIndex i = 0;
for (i = 0; i < count; i++)
{
CFStringRef displayIdentifier = (CFStringRef)::CFArrayGetValueAtIndex (sbsAppIDs.get(), i);
// Get the process id for the app (if there is one)
pid_t sbs_pid = INVALID_NUB_PROCESS;
if (::SBSProcessIDForDisplayIdentifier ((CFStringRef)displayIdentifier, &sbs_pid) == TRUE)
{
if (sbs_pid == pid)
return true;
}
}
}
#endif
CFReleaser<CFArrayRef> appIdsForPID (::SBSCopyDisplayIdentifiersForProcessID(pid));
return appIdsForPID.get() != NULL;
#else
return false;
#endif
}