Home | History | Annotate | Download | only in sdk
      1 /*
      2  * Copyright (C) 2012 The Android Open Source Project
      3  *
      4  * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php
      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 
     17 package com.android.ide.eclipse.adt.internal.sdk;
     18 
     19 import com.android.annotations.NonNull;
     20 import com.android.manifmerger.ICallback;
     21 import com.android.manifmerger.ManifestMerger;
     22 import com.android.sdklib.IAndroidTarget;
     23 
     24 /**
     25  * A {@link ManifestMerger} {@link ICallback} that returns the
     26  * proper API level for known API codenames.
     27  */
     28 public class AdtManifestMergeCallback implements ICallback {
     29     @Override
     30     public int queryCodenameApiLevel(@NonNull String codename) {
     31         Sdk sdk = Sdk.getCurrent();
     32         if (sdk != null) {
     33             IAndroidTarget t = sdk.getTargetFromHashString(
     34                     IAndroidTarget.PLATFORM_HASH_PREFIX + codename);
     35             if (t != null) {
     36                 return t.getVersion().getApiLevel();
     37             }
     38         }
     39         return ICallback.UNKNOWN_CODENAME;
     40     }
     41 }
     42