Skip to content

Instantly share code, notes, and snippets.

@mateor
Forked from phillipberndt/gist:5339943
Created June 5, 2013 14:49
Show Gist options
  • Save mateor/5714426 to your computer and use it in GitHub Desktop.
Save mateor/5714426 to your computer and use it in GitHub Desktop.
diff --git a/services/java/com/android/server/PrivacyTelephonyRegistry.java b/services/java/com/android/server/PrivacyTelephonyRegistry.java
index 15ddea7..2a0a5df 100644
--- a/services/java/com/android/server/PrivacyTelephonyRegistry.java
+++ b/services/java/com/android/server/PrivacyTelephonyRegistry.java
@@ -57,18 +57,27 @@ public class PrivacyTelephonyRegistry extends TelephonyRegistry{
private static final int PERMISSION_CALL_STATE = 3;
private static final int PERMISSION_SERVICE_STATE = 4;
+
+ private Context _context;
public PrivacyTelephonyRegistry(Context context) {
super(context);
- pSetMan = PrivacySettingsManager.getPrivacyService();
- try{
- registerPrivacy();
- } catch(Exception e){
- Log.e(P_TAG,"failed to register privacy broadcastreceiver", e);
- }
+ this._context = context;
Log.i(P_TAG,"constructor ready");
}
+
+ private void initialize() {
+ if(ServiceManager.getService("privacy") != null) {
+ pSetMan = new PrivacySettingsManager(_context, IPrivacySettingsManager.Stub.asInterface(ServiceManager.getService("privacy")));
+ try{
+ registerPrivacy();
+ } catch(Exception e){
+ Log.e(P_TAG,"failed to register privacy broadcastreceiver");
+ }
+ }
+ }
+
/** This broadCastReceiver receives the privacy intent for blocking phonecalls and faking phonestate */
private final BroadcastReceiver privacyReceiver = new BroadcastReceiver()
{
@@ -268,6 +277,10 @@ public class PrivacyTelephonyRegistry extends TelephonyRegistry{
private boolean isPackageAllowed(int PERMISSION, String packageName){
+ if(pSetMan == null) {
+ initialize();
+ if(pSetMan == null) return false;
+ }
PrivacySettings settings;
try {
if (pSetMan == null) pSetMan = PrivacySettingsManager.getPrivacyService();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment