-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #354 from smartdevicelink/bugfix/issue_353
Add protection against incorrect implementations of SdlRouterService
- Loading branch information
Showing
4 changed files
with
48 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
sdl_android_lib/src/com/smartdevicelink/util/AndroidTools.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.smartdevicelink.util; | ||
|
||
import android.content.ComponentName; | ||
import android.content.Context; | ||
import android.content.pm.PackageManager; | ||
import android.content.pm.ServiceInfo; | ||
import android.content.pm.PackageManager.NameNotFoundException; | ||
|
||
public class AndroidTools { | ||
/** | ||
* Check to see if a component is exported | ||
* @param Context object used to retrieve the package manager | ||
* @param componentName of the component in question | ||
* @return true if this component is tagged as exported | ||
*/ | ||
public static boolean isServiceExported(Context context, ComponentName name) { | ||
try { | ||
ServiceInfo serviceInfo = context.getPackageManager().getServiceInfo(name, PackageManager.GET_META_DATA); | ||
return serviceInfo.exported; | ||
} catch (NameNotFoundException e) { | ||
e.printStackTrace(); | ||
} | ||
return false; | ||
} | ||
} |