1 /* 2 * Copyright 2022 Google LLC 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.google.android.libraries.mobiledatadownload.delta; 17 18 import android.net.Uri; 19 import com.google.mobiledatadownload.internal.MetadataProto.DeltaFile.DiffDecoder; 20 import java.io.IOException; 21 22 /** 23 * Delta decoder Interface. 24 * 25 * <p>A delta decoder is to generate full content with a much smaller delta content providing a base 26 * content. 27 */ 28 public interface DeltaDecoder { 29 30 /** Throws when delta decode fails. */ 31 class DeltaDecodeException extends IOException { DeltaDecodeException(Throwable cause)32 public DeltaDecodeException(Throwable cause) { 33 super(cause); 34 } 35 DeltaDecodeException(String msg)36 public DeltaDecodeException(String msg) { 37 super(msg); 38 } 39 } 40 41 /** 42 * Decode file from base file and delta file and writes to the target uri. 43 * 44 * @param baseUri The input base file URI 45 * @param deltaUri The input delta file URI 46 * @param targetUri The target decoded output file URI 47 * @throws DeltaDecodeException 48 */ decode(Uri baseUri, Uri deltaUri, Uri targetUri)49 void decode(Uri baseUri, Uri deltaUri, Uri targetUri) throws DeltaDecodeException; 50 51 /** Get the supported delta decoder name. */ getDecoderName()52 DiffDecoder getDecoderName(); 53 } 54