Beispiel #1
0
  /**
   * Check if ads should be hidden.
   *
   * @param context {@link Context}
   * @return true if ads should be hidden
   */
  public static boolean hideAds(final Context context) {
    PackageManager pm = context.getPackageManager();
    Intent donationCheck = new Intent(DONATOR_BROADCAST_CHECK);
    ResolveInfo ri = pm.resolveService(donationCheck, 0);
    if (ri == null) {
      return false;
    } else {
      ComponentName cn = new ComponentName(ri.serviceInfo.packageName, ri.serviceInfo.name);
      int i = pm.getComponentEnabledSetting(cn);
      if (i == PackageManager.COMPONENT_ENABLED_STATE_ENABLED
          || i == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT && ri.serviceInfo.enabled) {
        int match = pm.checkSignatures(context.getPackageName(), ri.serviceInfo.packageName);
        if (match != PackageManager.SIGNATURE_MATCH) {
          Log.e(TAG, "signatures do not match: " + match);
          return false;
        }
        donationCheck.setComponent(cn);
      } else {
        Log.w(TAG, ri.serviceInfo.packageName + ": " + ri.serviceInfo.enabled);
        return false;
      }
    }

    double r = Math.random();
    if (r < CHECK_DONATOR_LIC) {
      // verify donator license
      ComponentName cn = context.startService(donationCheck);
      return cn != null;
    } else {
      return true;
    }
  }
 public static void b(Context context, Intent intent) {
   String s = intent.getAction();
   if ("android.intent.action.PACKAGE_ADDED".equals(s)) {
     String s1 = intent.getData().getEncodedSchemeSpecificPart();
     if (it.a) {
       Log.d(
           "ReceiverHelper",
           (new StringBuilder()).append("got an ").append(s).append("for").append(s1).toString());
     }
     PackageManager packagemanager = context.getPackageManager();
     if (packagemanager.checkSignatures(context.getPackageName(), s1) >= 0) {
       Intent intent1 = new Intent("com.dianxinos.appupdate.intent.NOTIFY_INSTALLED");
       intent1.setComponent(
           new ComponentName(s1, "com.dianxinos.appupdate.NotifyInstalledReceiver"));
       if (!packagemanager.queryBroadcastReceivers(intent1, 0).isEmpty()) {
         context.sendBroadcast(intent1);
         if (it.a) {
           Log.d(
               "ReceiverHelper",
               (new StringBuilder())
                   .append("sent an com.dianxinos.appupdate.intent.NOTIFY_INSTALLED ")
                   .append(intent1.getComponent())
                   .toString());
           return;
         }
       }
     }
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    PackageManager manager = getPackageManager();
    if (manager.checkSignatures(
            "hu.zoliweb.android.dndcallblocker", "hu.zoliweb.android.dndcallblocker.key")
        == PackageManager.SIGNATURE_MATCH) {
      setContentView(R.layout.noad_main_screen);
    } else {
      setContentView(R.layout.main_screen);
    }

    Resources res = getResources(); // Resource object to get Drawables
    TabHost tabHost = getTabHost(); // The activity TabHost
    TabHost.TabSpec spec; // Resusable TabSpec for each tab
    Intent intent; // Reusable Intent for each tab

    // Create an Intent to launch an Activity for the tab (to be reused)
    intent = new Intent().setClass(this, DNDCallBlockerPreferenceActivity.class);

    // Initialize a TabSpec for each tab and add it to the TabHost
    spec =
        tabHost
            .newTabSpec("preferences")
            .setIndicator(
                this.getString(R.string.tab_prefs), res.getDrawable(R.drawable.ic_tab_settings))
            .setContent(intent);
    tabHost.addTab(spec);

    // Do the same for the other tabs
    intent = new Intent().setClass(this, DNDCallBlockerLogActivity.class);
    spec =
        tabHost
            .newTabSpec("log")
            .setIndicator(
                this.getString(R.string.tab_log), res.getDrawable(R.drawable.ic_tab_history))
            .setContent(intent);
    tabHost.addTab(spec);

    intent = new Intent().setClass(this, DNDCallBlockerInfoActivity.class);
    spec =
        tabHost
            .newTabSpec("info")
            .setIndicator(
                this.getString(R.string.tab_info), res.getDrawable(R.drawable.ic_tab_info))
            .setContent(intent);
    tabHost.addTab(spec);

    tabHost.setCurrentTab(0);
  }
Beispiel #4
0
 public static boolean canBeStarted(Context context, Intent intent, boolean checkSignature) {
   final PackageManager manager = context.getApplicationContext().getPackageManager();
   final ResolveInfo info = manager.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
   if (info == null) {
     return false;
   }
   final ActivityInfo activityInfo = info.activityInfo;
   if (activityInfo == null) {
     return false;
   }
   if (!checkSignature) {
     return true;
   }
   return PackageManager.SIGNATURE_MATCH
       == manager.checkSignatures(context.getPackageName(), activityInfo.packageName);
 }
Beispiel #5
0
 public static boolean elitePresent(Context context, boolean versionCheck, int minVersion) {
   PackageManager pm = context.getPackageManager();
   int sigs = pm.checkSignatures("com.noshufou.android.su", "com.noshufou.android.su.elite");
   if (sigs != PackageManager.SIGNATURE_MATCH) {
     return false;
   } else {
     if (versionCheck) {
       PackageInfo pi;
       try {
         pi = pm.getPackageInfo("com.noshufou.android.su.elite", 0);
         if (pi.versionCode >= minVersion) {
           return true;
         } else {
           return false;
         }
       } catch (NameNotFoundException e) {
         return false;
       }
     } else {
       return true;
     }
   }
 }
 public static boolean isSystemSignaturePackage(PackageManager pm, String packageName) {
   return pm.checkSignatures("android", packageName) != PackageManager.SIGNATURE_NO_MATCH;
 }