001/** 002 * Copyright 2013 John Ericksen 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.androidtransfuse.model.manifest; 017 018import org.androidtransfuse.model.Mergeable; 019import org.androidtransfuse.processor.MergeCollection; 020 021import javax.xml.bind.annotation.XmlAttribute; 022import javax.xml.bind.annotation.XmlElement; 023import javax.xml.bind.annotation.XmlRootElement; 024import javax.xml.bind.annotation.XmlType; 025import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 026import java.util.ArrayList; 027import java.util.List; 028 029/** 030 * attributes: 031 * xmlns:android="http://schemas.android.com/apk/res/android" 032 * package="string" 033 * android:sharedUserId="string" 034 * android:sharedUserLabel="string resource" 035 * android:versionCode="integer" 036 * android:versionName="string" 037 * android:installLocation=["auto" | "internalOnly" | "preferExternal"] 038 * <p/> 039 * must contain: 040 * <application> 041 * <p/> 042 * can contain: 043 * <instrumentation> 044 * <permission> 045 * <permission-group> 046 * <permission-tree> 047 * <uses-configuration> 048 * <uses-permission> 049 * <uses-sdk> 050 * <compatible-screens> 051 * 052 * @author John Ericksen 053 */ 054@XmlRootElement(name = "manifest") 055@XmlType(propOrder = { 056 // root manifest element attributes 057 "applicationPackage", 058 "sharedUserId", 059 "sharedUserLabel", 060 "versionCode", 061 "versionName", 062 "installLocation", 063 // top level elements 064 "usesPermissions", 065 "permissions", 066 "permissionTrees", 067 "permissionGroups", 068 "instrumentations", 069 "usesSDKs", 070 "usesConfigurations", 071 "usesFeatures", 072 "supportsScreens", 073 "compatibleScreens", 074 "applications" 075 } 076) 077public class Manifest extends Mergeable { 078 079 private String applicationPackage; 080 private String sharedUserId; 081 private String sharedUserLabel; 082 private Integer versionCode; 083 private String versionName; 084 private InstallLocation installLocation; 085 private List<UsesPermission> usesPermissions = new ArrayList<UsesPermission>(); 086 private List<UsesSDK> usesSDKs = new ArrayList<UsesSDK>(); 087 private List<Application> applications = new ArrayList<Application>(); 088 private List<Instrumentation> instrumentations = new ArrayList<Instrumentation>(); 089 private List<Permission> permissions = new ArrayList<Permission>(); 090 private List<PermissionGroup> permissionGroups = new ArrayList<PermissionGroup>(); 091 private List<PermissionTree> permissionTrees = new ArrayList<PermissionTree>(); 092 private List<SupportsScreens> supportsScreens = new ArrayList<SupportsScreens>(); 093 private List<UsesFeature> usesFeatures = new ArrayList<UsesFeature>(); 094 private List<UsesConfiguration> usesConfigurations = new ArrayList<UsesConfiguration>(); 095 private List<CompatibleScreens> compatibleScreens = new ArrayList<CompatibleScreens>(); 096 097 @XmlAttribute(name = "package") 098 public String getApplicationPackage() { 099 return applicationPackage; 100 } 101 102 public void setApplicationPackage(String applicationPackage) { 103 this.applicationPackage = applicationPackage; 104 } 105 106 @XmlAttribute(name = "sharedUserId", namespace = ManifestNamespaceMapper.ANDROID_URI) 107 public String getSharedUserId() { 108 return sharedUserId; 109 } 110 111 public void setSharedUserId(String sharedUserId) { 112 this.sharedUserId = sharedUserId; 113 } 114 115 @XmlAttribute(name = "sharedUserLabel", namespace = ManifestNamespaceMapper.ANDROID_URI) 116 public String getSharedUserLabel() { 117 return sharedUserLabel; 118 } 119 120 public void setSharedUserLabel(String sharedUserLabel) { 121 this.sharedUserLabel = sharedUserLabel; 122 } 123 124 @XmlAttribute(name = "versionCode", namespace = ManifestNamespaceMapper.ANDROID_URI) 125 public Integer getVersionCode() { 126 return versionCode; 127 } 128 129 public void setVersionCode(Integer versionCode) { 130 this.versionCode = versionCode; 131 } 132 133 @XmlAttribute(name = "versionName", namespace = ManifestNamespaceMapper.ANDROID_URI) 134 public String getVersionName() { 135 return versionName; 136 } 137 138 public void setVersionName(String versionName) { 139 this.versionName = versionName; 140 } 141 142 @XmlAttribute(name = "installLocation", namespace = ManifestNamespaceMapper.ANDROID_URI) 143 @XmlJavaTypeAdapter(LabeledConverter.InstallLocationConverter.class) 144 public InstallLocation getInstallLocation() { 145 return installLocation; 146 } 147 148 public void setInstallLocation(InstallLocation installLocation) { 149 this.installLocation = installLocation; 150 } 151 152 @MergeCollection(collectionType = ArrayList.class, type = Application.class) 153 @XmlElement(name = "application") 154 public List<Application> getApplications() { 155 return applications; 156 } 157 158 public void setApplications(List<Application> applications) { 159 this.applications = applications; 160 } 161 162 @XmlElement(name = "instrumentation") 163 public List<Instrumentation> getInstrumentations() { 164 return instrumentations; 165 } 166 167 public void setInstrumentations(List<Instrumentation> instrumentations) { 168 this.instrumentations = instrumentations; 169 } 170 171 @XmlElement(name = "permission") 172 public List<Permission> getPermissions() { 173 return permissions; 174 } 175 176 @MergeCollection(collectionType = ArrayList.class, type = Permission.class) 177 public void setPermissions(List<Permission> permissions) { 178 this.permissions = permissions; 179 } 180 181 @XmlElement(name = "permission-group") 182 public List<PermissionGroup> getPermissionGroups() { 183 return permissionGroups; 184 } 185 186 public void setPermissionGroups(List<PermissionGroup> permissionGroups) { 187 this.permissionGroups = permissionGroups; 188 } 189 190 @XmlElement(name = "permission-tree") 191 public List<PermissionTree> getPermissionTrees() { 192 return permissionTrees; 193 } 194 195 public void setPermissionTrees(List<PermissionTree> permissionTrees) { 196 this.permissionTrees = permissionTrees; 197 } 198 199 @XmlElement(name = "uses-configuration") 200 public List<UsesConfiguration> getUsesConfigurations() { 201 return usesConfigurations; 202 } 203 204 public void setUsesConfigurations(List<UsesConfiguration> usesConfigurations) { 205 this.usesConfigurations = usesConfigurations; 206 } 207 208 @MergeCollection(collectionType = ArrayList.class, type = UsesPermission.class) 209 @XmlElement(name = "uses-permission") 210 public List<UsesPermission> getUsesPermissions() { 211 return usesPermissions; 212 } 213 214 public void setUsesPermissions(List<UsesPermission> usesPermissions) { 215 this.usesPermissions = usesPermissions; 216 } 217 218 @MergeCollection(collectionType = ArrayList.class, type = UsesSDK.class) 219 @XmlElement(name = "uses-sdk") 220 public List<UsesSDK> getUsesSDKs() { 221 return usesSDKs; 222 } 223 224 public void setUsesSDKs(List<UsesSDK> usesSDKs) { 225 this.usesSDKs = usesSDKs; 226 } 227 228 @XmlElement(name = "supports-screens") 229 public List<SupportsScreens> getSupportsScreens() { 230 return supportsScreens; 231 } 232 233 public void setSupportsScreens(List<SupportsScreens> supportsScreens) { 234 this.supportsScreens = supportsScreens; 235 } 236 237 @MergeCollection(collectionType = ArrayList.class, type = UsesFeature.class) 238 @XmlElement(name = "uses-feature") 239 public List<UsesFeature> getUsesFeatures() { 240 return usesFeatures; 241 } 242 243 public void setUsesFeatures(List<UsesFeature> usesFeatures) { 244 this.usesFeatures = usesFeatures; 245 } 246 247 @XmlElement(name = "compatible-screens") 248 public List<CompatibleScreens> getCompatibleScreens() { 249 return compatibleScreens; 250 } 251 252 public void setCompatibleScreens(List<CompatibleScreens> compatibleScreens) { 253 this.compatibleScreens = compatibleScreens; 254 } 255 256 public void updatePackages() { 257 if(applicationPackage != null){ 258 for (Application application : applications) { 259 application.updatePackage(applicationPackage); 260 } 261 } 262 } 263}