@Test public void testGetLicenseDurationRemainingSec() throws Exception { long licenseDuration = 1000; int playbackDuration = 200; setStubLicenseAndPlaybackDurationValues(licenseDuration, playbackDuration); setDefaultStubKeySetId(); byte[] offlineLicenseKeySetId = offlineLicenseHelper.downloadLicense(newDrmInitData()); Pair<Long, Long> licenseDurationRemainingSec = offlineLicenseHelper.getLicenseDurationRemainingSec(offlineLicenseKeySetId); assertThat(licenseDurationRemainingSec.first).isEqualTo(licenseDuration); assertThat(licenseDurationRemainingSec.second).isEqualTo(playbackDuration); }
public synchronized Pair<Long, Long> getLicenseDurationRemainingSec(byte[] offlineLicenseKeySetId) throws DrmSessionException { Assertions.checkNotNull(offlineLicenseKeySetId); DrmSession<T> drmSession = openBlockingKeyRequest( DefaultDrmSessionManager.MODE_QUERY, offlineLicenseKeySetId, DUMMY_DRM_INIT_DATA); DrmSessionException error = drmSession.getError(); Pair<Long, Long> licenseDurationRemainingSec = WidevineUtil.getLicenseDurationRemainingSec(drmSession); drmSessionManager.releaseSession(drmSession); if (error != null) { if (error.getCause() instanceof KeysExpiredException) { return Pair.create(0L, 0L); } throw error; } return Assertions.checkNotNull(licenseDurationRemainingSec); }
OfflineLicenseHelper { public synchronized Pair<Long, Long> getLicenseDurationRemainingSec(byte[] offlineLicenseKeySetId) throws DrmSessionException { Assertions.checkNotNull(offlineLicenseKeySetId); DrmSession<T> drmSession = openBlockingKeyRequest( DefaultDrmSessionManager.MODE_QUERY, offlineLicenseKeySetId, DUMMY_DRM_INIT_DATA); DrmSessionException error = drmSession.getError(); Pair<Long, Long> licenseDurationRemainingSec = WidevineUtil.getLicenseDurationRemainingSec(drmSession); drmSessionManager.releaseSession(drmSession); if (error != null) { if (error.getCause() instanceof KeysExpiredException) { return Pair.create(0L, 0L); } throw error; } return Assertions.checkNotNull(licenseDurationRemainingSec); } }
OfflineLicenseHelper { public synchronized Pair<Long, Long> getLicenseDurationRemainingSec(byte[] offlineLicenseKeySetId) throws DrmSessionException { Assertions.checkNotNull(offlineLicenseKeySetId); DrmSession<T> drmSession = openBlockingKeyRequest( DefaultDrmSessionManager.MODE_QUERY, offlineLicenseKeySetId, DUMMY_DRM_INIT_DATA); DrmSessionException error = drmSession.getError(); Pair<Long, Long> licenseDurationRemainingSec = WidevineUtil.getLicenseDurationRemainingSec(drmSession); drmSessionManager.releaseSession(drmSession); if (error != null) { if (error.getCause() instanceof KeysExpiredException) { return Pair.create(0L, 0L); } throw error; } return Assertions.checkNotNull(licenseDurationRemainingSec); } OfflineLicenseHelper(
      UUID uuid,
      ExoMediaDrm<T> mediaDrm,
      MediaDrmCallback callback,
      @Nullable HashMap<String, String> optionalKeyRequestParameters); }
OfflineLicenseHelper { public synchronized Pair<Long, Long> getLicenseDurationRemainingSec(byte[] offlineLicenseKeySetId) throws DrmSessionException { Assertions.checkNotNull(offlineLicenseKeySetId); DrmSession<T> drmSession = openBlockingKeyRequest( DefaultDrmSessionManager.MODE_QUERY, offlineLicenseKeySetId, DUMMY_DRM_INIT_DATA); DrmSessionException error = drmSession.getError(); Pair<Long, Long> licenseDurationRemainingSec = WidevineUtil.getLicenseDurationRemainingSec(drmSession); drmSessionManager.releaseSession(drmSession); if (error != null) { if (error.getCause() instanceof KeysExpiredException) { return Pair.create(0L, 0L); } throw error; } return Assertions.checkNotNull(licenseDurationRemainingSec); } OfflineLicenseHelper(
      UUID uuid,
      ExoMediaDrm<T> mediaDrm,
      MediaDrmCallback callback,
      @Nullable HashMap<String, String> optionalKeyRequestParameters); static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(
      String defaultLicenseUrl, Factory httpDataSourceFactory); static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(
      String defaultLicenseUrl, boolean forceDefaultLicenseUrl, Factory httpDataSourceFactory); static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(
      String defaultLicenseUrl,
      boolean forceDefaultLicenseUrl,
      Factory httpDataSourceFactory,
      @Nullable HashMap<String, String> optionalKeyRequestParameters); synchronized byte[] getPropertyByteArray(String key); synchronized void setPropertyByteArray(String key, byte[] value); synchronized String getPropertyString(String key); synchronized void setPropertyString(String key, String value); synchronized byte[] downloadLicense(DrmInitData drmInitData); synchronized byte[] renewLicense(byte[] offlineLicenseKeySetId); synchronized void releaseLicense(byte[] offlineLicenseKeySetId); synchronized Pair<Long, Long> getLicenseDurationRemainingSec(byte[] offlineLicenseKeySetId); void release(); }
OfflineLicenseHelper { public synchronized Pair<Long, Long> getLicenseDurationRemainingSec(byte[] offlineLicenseKeySetId) throws DrmSessionException { Assertions.checkNotNull(offlineLicenseKeySetId); DrmSession<T> drmSession = openBlockingKeyRequest( DefaultDrmSessionManager.MODE_QUERY, offlineLicenseKeySetId, DUMMY_DRM_INIT_DATA); DrmSessionException error = drmSession.getError(); Pair<Long, Long> licenseDurationRemainingSec = WidevineUtil.getLicenseDurationRemainingSec(drmSession); drmSessionManager.releaseSession(drmSession); if (error != null) { if (error.getCause() instanceof KeysExpiredException) { return Pair.create(0L, 0L); } throw error; } return Assertions.checkNotNull(licenseDurationRemainingSec); } OfflineLicenseHelper(
      UUID uuid,
      ExoMediaDrm<T> mediaDrm,
      MediaDrmCallback callback,
      @Nullable HashMap<String, String> optionalKeyRequestParameters); static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(
      String defaultLicenseUrl, Factory httpDataSourceFactory); static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(
      String defaultLicenseUrl, boolean forceDefaultLicenseUrl, Factory httpDataSourceFactory); static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(
      String defaultLicenseUrl,
      boolean forceDefaultLicenseUrl,
      Factory httpDataSourceFactory,
      @Nullable HashMap<String, String> optionalKeyRequestParameters); synchronized byte[] getPropertyByteArray(String key); synchronized void setPropertyByteArray(String key, byte[] value); synchronized String getPropertyString(String key); synchronized void setPropertyString(String key, String value); synchronized byte[] downloadLicense(DrmInitData drmInitData); synchronized byte[] renewLicense(byte[] offlineLicenseKeySetId); synchronized void releaseLicense(byte[] offlineLicenseKeySetId); synchronized Pair<Long, Long> getLicenseDurationRemainingSec(byte[] offlineLicenseKeySetId); void release();  }