android.os.PersistableBundle#getInt ( )源码实例Demo

下面列出了android.os.PersistableBundle#getInt ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: MediaSDK   文件: PlatformScheduler.java
@Override
public boolean onStartJob(JobParameters params) {
  logd("PlatformSchedulerService started");
  PersistableBundle extras = params.getExtras();
  Requirements requirements = new Requirements(extras.getInt(KEY_REQUIREMENTS));
  if (requirements.checkRequirements(this)) {
    logd("Requirements are met");
    String serviceAction = extras.getString(KEY_SERVICE_ACTION);
    String servicePackage = extras.getString(KEY_SERVICE_PACKAGE);
    Intent intent =
        new Intent(Assertions.checkNotNull(serviceAction)).setPackage(servicePackage);
    logd("Starting service action: " + serviceAction + " package: " + servicePackage);
    Util.startForegroundService(this, intent);
  } else {
    logd("Requirements are not met");
    jobFinished(params, /* needsReschedule */ true);
  }
  return false;
}
 
@Override
public void updateSystemUpdateInfo(PersistableBundle infoBundle) {
    mContext.enforceCallingOrSelfPermission(Manifest.permission.RECOVERY, TAG);

    int status = infoBundle.getInt(KEY_STATUS, STATUS_UNKNOWN);
    if (status == STATUS_UNKNOWN) {
        Slog.w(TAG, "Invalid status info. Ignored");
        return;
    }

    // There could be multiple updater apps running on a device. But only one at most should
    // be active (i.e. with a pending update), with the rest reporting idle status. We will
    // only accept the reported status if any of the following conditions holds:
    //   a) none has been reported before;
    //   b) the current on-file status was last reported by the same caller;
    //   c) an active update is being reported.
    int uid = Binder.getCallingUid();
    if (mLastUid == UID_UNKNOWN || mLastUid == uid || status != STATUS_IDLE) {
        synchronized (mLock) {
            saveSystemUpdateInfoLocked(infoBundle, uid);
        }
    } else {
        Slog.i(TAG, "Inactive updater reporting IDLE status. Ignored");
    }
}
 
源代码3 项目: TelePlus-Android   文件: PlatformScheduler.java
@Override
public boolean onStartJob(JobParameters params) {
  logd("PlatformSchedulerService started");
  PersistableBundle extras = params.getExtras();
  Requirements requirements = new Requirements(extras.getInt(KEY_REQUIREMENTS));
  if (requirements.checkRequirements(this)) {
    logd("Requirements are met");
    String serviceAction = extras.getString(KEY_SERVICE_ACTION);
    String servicePackage = extras.getString(KEY_SERVICE_PACKAGE);
    Intent intent = new Intent(serviceAction).setPackage(servicePackage);
    logd("Starting service action: " + serviceAction + " package: " + servicePackage);
    Util.startForegroundService(this, intent);
  } else {
    logd("Requirements are not met");
    jobFinished(params, /* needsReschedule */ true);
  }
  return false;
}
 
源代码4 项目: TelePlus-Android   文件: PlatformScheduler.java
@Override
public boolean onStartJob(JobParameters params) {
  logd("PlatformSchedulerService started");
  PersistableBundle extras = params.getExtras();
  Requirements requirements = new Requirements(extras.getInt(KEY_REQUIREMENTS));
  if (requirements.checkRequirements(this)) {
    logd("Requirements are met");
    String serviceAction = extras.getString(KEY_SERVICE_ACTION);
    String servicePackage = extras.getString(KEY_SERVICE_PACKAGE);
    Intent intent = new Intent(serviceAction).setPackage(servicePackage);
    logd("Starting service action: " + serviceAction + " package: " + servicePackage);
    Util.startForegroundService(this, intent);
  } else {
    logd("Requirements are not met");
    jobFinished(params, /* needsReschedule */ true);
  }
  return false;
}
 
源代码5 项目: Telegram-FOSS   文件: PlatformScheduler.java
@Override
public boolean onStartJob(JobParameters params) {
  logd("PlatformSchedulerService started");
  PersistableBundle extras = params.getExtras();
  Requirements requirements = new Requirements(extras.getInt(KEY_REQUIREMENTS));
  if (requirements.checkRequirements(this)) {
    logd("Requirements are met");
    String serviceAction = extras.getString(KEY_SERVICE_ACTION);
    String servicePackage = extras.getString(KEY_SERVICE_PACKAGE);
    Intent intent =
        new Intent(Assertions.checkNotNull(serviceAction)).setPackage(servicePackage);
    logd("Starting service action: " + serviceAction + " package: " + servicePackage);
    Util.startForegroundService(this, intent);
  } else {
    logd("Requirements are not met");
    jobFinished(params, /* needsReschedule */ true);
  }
  return false;
}
 
源代码6 项目: Telegram   文件: PlatformScheduler.java
@Override
public boolean onStartJob(JobParameters params) {
  logd("PlatformSchedulerService started");
  PersistableBundle extras = params.getExtras();
  Requirements requirements = new Requirements(extras.getInt(KEY_REQUIREMENTS));
  if (requirements.checkRequirements(this)) {
    logd("Requirements are met");
    String serviceAction = extras.getString(KEY_SERVICE_ACTION);
    String servicePackage = extras.getString(KEY_SERVICE_PACKAGE);
    Intent intent =
        new Intent(Assertions.checkNotNull(serviceAction)).setPackage(servicePackage);
    logd("Starting service action: " + serviceAction + " package: " + servicePackage);
    Util.startForegroundService(this, intent);
  } else {
    logd("Requirements are not met");
    jobFinished(params, /* needsReschedule */ true);
  }
  return false;
}
 
private void saveSystemUpdateInfoLocked(PersistableBundle infoBundle, int uid) {
    // Wrap the incoming bundle with extra info (e.g. version, uid, boot count). We use nested
    // PersistableBundle to avoid manually parsing XML attributes when loading the info back.
    PersistableBundle outBundle = new PersistableBundle();
    outBundle.putPersistableBundle(KEY_INFO_BUNDLE, infoBundle);
    outBundle.putInt(KEY_VERSION, INFO_FILE_VERSION);
    outBundle.putInt(KEY_UID, uid);
    outBundle.putInt(KEY_BOOT_COUNT, getBootCount());

    // Only update the info on success.
    if (writeInfoFileLocked(outBundle)) {
        mLastUid = uid;
        mLastStatus = infoBundle.getInt(KEY_STATUS);
    }
}
 
@Override
public void onPostCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
    super.onPostCreate(savedInstanceState, persistentState);
    // Restore state from PersistableBundle
    if (persistentState != null) {
        mDocumentCounter = persistentState.getInt(KEY_EXTRA_NEW_DOCUMENT_COUNTER);
    }
}
 
源代码9 项目: your-local-weather   文件: Location.java
public Location(PersistableBundle persistentBundle) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        id = persistentBundle.getLong("id");
        latitude = persistentBundle.getDouble("latitude");
        longitude = persistentBundle.getDouble("longitude");
        orderId = persistentBundle.getInt("orderId");
        localeAbbrev = persistentBundle.getString("locale");
        locale = new Locale(localeAbbrev);
        nickname = persistentBundle.getString("nickname");;
        accuracy = new Double(persistentBundle.getDouble("accuracy")).floatValue();
        locationSource = persistentBundle.getString("locationSource");
        lastLocationUpdate = persistentBundle.getLong("lastLocationUpdate");
        address = PersistableBundleBuilder.toAddress(persistentBundle.getPersistableBundle("address"));
    }
}
 
源代码10 项目: your-local-weather   文件: VoiceSettingParameter.java
public VoiceSettingParameter(PersistableBundle persistentBundle) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        id = persistentBundle.getLong("id");
        voiceSettingId = persistentBundle.getLong("voiceSettingId");
        paramTypeId = persistentBundle.getInt("paramTypeId");
        paramBooleanValue = mapIntToBoolean(persistentBundle.getInt("paramBooleanValue"));
        paramLongValue = persistentBundle.getLong("paramLongValue");
        paramStringValue = persistentBundle.getString("paramStringValue");
    }
}
 
源代码11 项目: materialistic   文件: SyncDelegate.java
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
Job(PersistableBundle bundle) {
    id = bundle.getString(EXTRA_ID);
    connectionEnabled = bundle.getInt(EXTRA_CONNECTION_ENABLED) == 1;
    readabilityEnabled = bundle.getInt(EXTRA_READABILITY_ENABLED) == 1;
    articleEnabled = bundle.getInt(EXTRA_ARTICLE_ENABLED) == 1;
    commentsEnabled = bundle.getInt(EXTRA_COMMENTS_ENABLED) == 1;
    notificationEnabled = bundle.getInt(EXTRA_NOTIFICATION_ENABLED) == 1;
}
 
@Override
public void onPostCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
    super.onPostCreate(savedInstanceState, persistentState);
    // Restore state from PersistableBundle
    if (persistentState != null) {
        mDocumentCounter = persistentState.getInt(KEY_EXTRA_NEW_DOCUMENT_COUNTER);
    }
}