示例#1
0
 /**
  * This cannot be offloaded to the database (as we did with the query which updates apps,
  * depending on whether their apks are compatible or not). The reason is that we need to interact
  * with the CompatibilityChecker in order to see if, and why an apk is not compatible.
  */
 private void calcApkCompatibilityFlags(List<Apk> apks) {
   for (final Apk apk : apks) {
     final List<String> reasons = checker.getIncompatibleReasons(apk);
     if (reasons.size() > 0) {
       apk.compatible = false;
       apk.incompatibleReasons = Utils.CommaSeparatedList.make(reasons);
     } else {
       apk.compatible = true;
       apk.incompatibleReasons = null;
     }
   }
 }
示例#2
0
  public static void main(String[] args) throws Exception {
    Config config = new Config();
    Apk apkInfo = new Apk();
    apkInfo.setApk("IVersion");
    apkInfo.setUrl("https://os.alipayobjects.com/rmsportal/PvAXMBnwAkomkee.apk");
    apkInfo.setTimestamp(System.currentTimeMillis());
    config.update = Arrays.asList(apkInfo);
    config.delete = Arrays.asList("id");

    File file = new File("config.json");
    BufferedWriter writer = new BufferedWriter(new FileWriter(file));
    writer.write(JSON.toJSONString(config));
    writer.flush();
    writer.close();
  }
示例#3
0
 public static void update(Context context, Apk apk) {
   ContentResolver resolver = context.getContentResolver();
   Uri uri = getContentUri(apk.packageName, apk.vercode);
   resolver.update(uri, apk.toContentValues(), null, null);
 }
示例#4
0
 /**
  * Creates an insert {@link ContentProviderOperation} for the {@link Apk} in question.
  * <strong>Does not do any checks to see if the apk already exists or not.</strong>
  */
 private ContentProviderOperation insertNewApk(final Apk apk) {
   ContentValues values = apk.toContentValues();
   Uri uri = TempApkProvider.getContentUri();
   return ContentProviderOperation.newInsert(uri).withValues(values).build();
 }
示例#5
0
 /**
  * Creates an update {@link ContentProviderOperation} for the {@link Apk} in question.
  * <strong>Does not do any checks to see if the apk already exists or not.</strong>
  */
 private ContentProviderOperation updateExistingApk(final Apk apk) {
   Uri uri = TempApkProvider.getApkUri(apk);
   ContentValues values = apk.toContentValues();
   return ContentProviderOperation.newUpdate(uri).withValues(values).build();
 }