src/api-impl: fix up code style, mainly for code imported from AOSP

used the following (plus manual edits):
`clang-format --style="{BasedOnStyle: LLVM, IndentWidth: 8, UseTab: Always, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: true, ColumnLimit: 0}`
This commit is contained in:
Mis012
2023-06-22 11:45:46 +02:00
parent 824b821f5a
commit 0a9591c474
208 changed files with 154568 additions and 150150 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -16,7 +16,7 @@
package android.content.pm;
//import android.graphics.drawable.Drawable;
// import android.graphics.drawable.Drawable;
import android.util.Printer;
/**
@@ -28,143 +28,147 @@ import android.util.Printer;
* in the implementation of Parcelable in subclasses.
*/
public class ComponentInfo extends PackageItemInfo {
/**
* Global information about the application/package this component is a
* part of.
*/
public ApplicationInfo applicationInfo;
/**
* The name of the process this component should run in.
* From the "android:process" attribute or, if not set, the same
* as <var>applicationInfo.processName</var>.
*/
public String processName;
/**
* Global information about the application/package this component is a
* part of.
*/
public ApplicationInfo applicationInfo;
/**
* A string resource identifier (in the package's resources) containing
* a user-readable description of the component. From the "description"
* attribute or, if not set, 0.
*/
public int descriptionRes;
/**
* Indicates whether or not this component may be instantiated. Note that this value can be
* overriden by the one in its parent {@link ApplicationInfo}.
*/
public boolean enabled = true;
/**
* The name of the process this component should run in.
* From the "android:process" attribute or, if not set, the same
* as <var>applicationInfo.processName</var>.
*/
public String processName;
/**
* Set to true if this component is available for use by other applications.
* Comes from {@link android.R.attr#exported android:exported} of the
* &lt;activity&gt;, &lt;receiver&gt;, &lt;service&gt;, or
* &lt;provider&gt; tag.
*/
public boolean exported = false;
public ComponentInfo() {
}
/**
* A string resource identifier (in the package's resources) containing
* a user-readable description of the component. From the "description"
* attribute or, if not set, 0.
*/
public int descriptionRes;
public ComponentInfo(ComponentInfo orig) {
super(orig);
applicationInfo = orig.applicationInfo;
processName = orig.processName;
descriptionRes = orig.descriptionRes;
enabled = orig.enabled;
exported = orig.exported;
}
/**
* Indicates whether or not this component may be instantiated. Note that this value can be
* overriden by the one in its parent {@link ApplicationInfo}.
*/
public boolean enabled = true;
@Override public CharSequence loadLabel(PackageManager pm) {/*
if (nonLocalizedLabel != null) {
return nonLocalizedLabel;
}
ApplicationInfo ai = applicationInfo;
CharSequence label;
if (labelRes != 0) {
label = pm.getText(packageName, labelRes, ai);
if (label != null) {
return label;
}
}
if (ai.nonLocalizedLabel != null) {
return ai.nonLocalizedLabel;
}
if (ai.labelRes != 0) {
label = pm.getText(packageName, ai.labelRes, ai);
if (label != null) {
return label;
}
}
return name;
*/return null;}
/**
* Set to true if this component is available for use by other applications.
* Comes from {@link android.R.attr#exported android:exported} of the
* &lt;activity&gt;, &lt;receiver&gt;, &lt;service&gt;, or
* &lt;provider&gt; tag.
*/
public boolean exported = false;
/**
* Return whether this component and its enclosing application are enabled.
*/
public boolean isEnabled() {
return enabled /*&& applicationInfo.enabled*/;
}
/**
* Return the icon resource identifier to use for this component. If
* the component defines an icon, that is used; else, the application
* icon is used.
*
* @return The icon associated with this component.
*/
public final int getIconResource() {
return icon;// != 0 ? icon : applicationInfo.icon;
}
public ComponentInfo() {
}
/**
* Return the logo resource identifier to use for this component. If
* the component defines a logo, that is used; else, the application
* logo is used.
*
* @return The logo associated with this component.
*/
public final int getLogoResource() {
return logo;// != 0 ? logo : applicationInfo.logo;
}
protected void dumpFront(Printer pw, String prefix) {
super.dumpFront(pw, prefix);
pw.println(prefix + "enabled=" + enabled + " exported=" + exported
+ " processName=" + processName);
if (descriptionRes != 0) {
pw.println(prefix + "description=" + descriptionRes);
}
}
protected void dumpBack(Printer pw, String prefix) {
if (applicationInfo != null) {
pw.println(prefix + "ApplicationInfo:");
//applicationInfo.dump(pw, prefix + " ");
} else {
pw.println(prefix + "ApplicationInfo: null");
}
super.dumpBack(pw, prefix);
}
/**
* @hide
*/
@Override protected Drawable loadDefaultIcon(PackageManager pm) {
return null;//applicationInfo.loadIcon(pm);
}
/**
* @hide
*/
@Override
protected Drawable loadDefaultLogo(PackageManager pm) {
return null;//applicationInfo.loadLogo(pm);
}
/**
* @hide
*/
@Override protected ApplicationInfo getApplicationInfo() {
return applicationInfo;
}
public ComponentInfo(ComponentInfo orig) {
super(orig);
applicationInfo = orig.applicationInfo;
processName = orig.processName;
descriptionRes = orig.descriptionRes;
enabled = orig.enabled;
exported = orig.exported;
}
@Override
public CharSequence loadLabel(PackageManager pm) { /*
if (nonLocalizedLabel != null) {
return nonLocalizedLabel;
}
ApplicationInfo ai = applicationInfo;
CharSequence label;
if (labelRes != 0) {
label = pm.getText(packageName, labelRes, ai);
if (label != null) {
return label;
}
}
if (ai.nonLocalizedLabel != null) {
return ai.nonLocalizedLabel;
}
if (ai.labelRes != 0) {
label = pm.getText(packageName, ai.labelRes, ai);
if (label != null) {
return label;
}
}
return name;
*/
return null;
}
/**
* Return whether this component and its enclosing application are enabled.
*/
public boolean isEnabled() {
return enabled /*&& applicationInfo.enabled*/;
}
/**
* Return the icon resource identifier to use for this component. If
* the component defines an icon, that is used; else, the application
* icon is used.
*
* @return The icon associated with this component.
*/
public final int getIconResource() {
return icon; // != 0 ? icon : applicationInfo.icon;
}
/**
* Return the logo resource identifier to use for this component. If
* the component defines a logo, that is used; else, the application
* logo is used.
*
* @return The logo associated with this component.
*/
public final int getLogoResource() {
return logo; // != 0 ? logo : applicationInfo.logo;
}
protected void dumpFront(Printer pw, String prefix) {
super.dumpFront(pw, prefix);
pw.println(prefix + "enabled=" + enabled + " exported=" + exported + " processName=" + processName);
if (descriptionRes != 0) {
pw.println(prefix + "description=" + descriptionRes);
}
}
protected void dumpBack(Printer pw, String prefix) {
if (applicationInfo != null) {
pw.println(prefix + "ApplicationInfo:");
// applicationInfo.dump(pw, prefix + " ");
} else {
pw.println(prefix + "ApplicationInfo: null");
}
super.dumpBack(pw, prefix);
}
/**
* @hide
*/
@Override
protected Drawable loadDefaultIcon(PackageManager pm) {
return null; // applicationInfo.loadIcon(pm);
}
/**
* @hide
*/
@Override
protected Drawable loadDefaultLogo(PackageManager pm) {
return null; // applicationInfo.loadLogo(pm);
}
/**
* @hide
*/
@Override
protected ApplicationInfo getApplicationInfo() {
return applicationInfo;
}
}

View File

@@ -22,95 +22,89 @@ package android.content.pm;
* AndroidManifest.xml's &lt;uses-configuration&gt; and &lt;uses-feature&gt; tags.
*/
public class ConfigurationInfo {
/**
* The kind of touch screen attached to the device.
* One of: {@link android.content.res.Configuration#TOUCHSCREEN_NOTOUCH},
* {@link android.content.res.Configuration#TOUCHSCREEN_STYLUS},
* {@link android.content.res.Configuration#TOUCHSCREEN_FINGER}.
*/
public int reqTouchScreen;
/**
* Application's input method preference.
* One of: {@link android.content.res.Configuration#KEYBOARD_UNDEFINED},
* {@link android.content.res.Configuration#KEYBOARD_NOKEYS},
* {@link android.content.res.Configuration#KEYBOARD_QWERTY},
* {@link android.content.res.Configuration#KEYBOARD_12KEY}
*/
public int reqKeyboardType;
/**
* A flag indicating whether any keyboard is available.
* one of: {@link android.content.res.Configuration#NAVIGATION_UNDEFINED},
* {@link android.content.res.Configuration#NAVIGATION_DPAD},
* {@link android.content.res.Configuration#NAVIGATION_TRACKBALL},
* {@link android.content.res.Configuration#NAVIGATION_WHEEL}
*/
public int reqNavigation;
/**
* Value for {@link #reqInputFeatures}: if set, indicates that the application
* requires a hard keyboard
*/
public static final int INPUT_FEATURE_HARD_KEYBOARD = 0x00000001;
/**
* Value for {@link #reqInputFeatures}: if set, indicates that the application
* requires a five way navigation device
*/
public static final int INPUT_FEATURE_FIVE_WAY_NAV = 0x00000002;
/**
* Flags associated with the input features. Any combination of
* {@link #INPUT_FEATURE_HARD_KEYBOARD},
* {@link #INPUT_FEATURE_FIVE_WAY_NAV}
*/
public int reqInputFeatures = 0;
/**
* The kind of touch screen attached to the device.
* One of: {@link android.content.res.Configuration#TOUCHSCREEN_NOTOUCH},
* {@link android.content.res.Configuration#TOUCHSCREEN_STYLUS},
* {@link android.content.res.Configuration#TOUCHSCREEN_FINGER}.
*/
public int reqTouchScreen;
/**
* Default value for {@link #reqGlEsVersion};
*/
public static final int GL_ES_VERSION_UNDEFINED = 0;
/**
* The GLES version used by an application. The upper order 16 bits represent the
* major version and the lower order 16 bits the minor version.
*/
public int reqGlEsVersion;
/**
* Application's input method preference.
* One of: {@link android.content.res.Configuration#KEYBOARD_UNDEFINED},
* {@link android.content.res.Configuration#KEYBOARD_NOKEYS},
* {@link android.content.res.Configuration#KEYBOARD_QWERTY},
* {@link android.content.res.Configuration#KEYBOARD_12KEY}
*/
public int reqKeyboardType;
public ConfigurationInfo() {
}
/**
* A flag indicating whether any keyboard is available.
* one of: {@link android.content.res.Configuration#NAVIGATION_UNDEFINED},
* {@link android.content.res.Configuration#NAVIGATION_DPAD},
* {@link android.content.res.Configuration#NAVIGATION_TRACKBALL},
* {@link android.content.res.Configuration#NAVIGATION_WHEEL}
*/
public int reqNavigation;
public ConfigurationInfo(ConfigurationInfo orig) {
reqTouchScreen = orig.reqTouchScreen;
reqKeyboardType = orig.reqKeyboardType;
reqNavigation = orig.reqNavigation;
reqInputFeatures = orig.reqInputFeatures;
reqGlEsVersion = orig.reqGlEsVersion;
}
/**
* Value for {@link #reqInputFeatures}: if set, indicates that the application
* requires a hard keyboard
*/
public static final int INPUT_FEATURE_HARD_KEYBOARD = 0x00000001;
public String toString() {
return "ConfigurationInfo{"
+ Integer.toHexString(System.identityHashCode(this))
+ " touchscreen = " + reqTouchScreen
+ " inputMethod = " + reqKeyboardType
+ " navigation = " + reqNavigation
+ " reqInputFeatures = " + reqInputFeatures
+ " reqGlEsVersion = " + reqGlEsVersion + "}";
}
/**
* Value for {@link #reqInputFeatures}: if set, indicates that the application
* requires a five way navigation device
*/
public static final int INPUT_FEATURE_FIVE_WAY_NAV = 0x00000002;
public int describeContents() {
return 0;
}
/**
* Flags associated with the input features. Any combination of
* {@link #INPUT_FEATURE_HARD_KEYBOARD},
* {@link #INPUT_FEATURE_FIVE_WAY_NAV}
*/
public int reqInputFeatures = 0;
/**
* This method extracts the major and minor version of reqGLEsVersion attribute
* and returns it as a string. Say reqGlEsVersion value of 0x00010002 is returned
* as 1.2
* @return String representation of the reqGlEsVersion attribute
*/
public String getGlEsVersion() {
int major = ((reqGlEsVersion & 0xffff0000) >> 16);
int minor = reqGlEsVersion & 0x0000ffff;
return String.valueOf(major)+"."+String.valueOf(minor);
}
/**
* Default value for {@link #reqGlEsVersion};
*/
public static final int GL_ES_VERSION_UNDEFINED = 0;
/**
* The GLES version used by an application. The upper order 16 bits represent the
* major version and the lower order 16 bits the minor version.
*/
public int reqGlEsVersion;
public ConfigurationInfo() {
}
public ConfigurationInfo(ConfigurationInfo orig) {
reqTouchScreen = orig.reqTouchScreen;
reqKeyboardType = orig.reqKeyboardType;
reqNavigation = orig.reqNavigation;
reqInputFeatures = orig.reqInputFeatures;
reqGlEsVersion = orig.reqGlEsVersion;
}
public String toString() {
return "ConfigurationInfo{" + Integer.toHexString(System.identityHashCode(this)) + " touchscreen = " + reqTouchScreen + " inputMethod = " + reqKeyboardType + " navigation = " + reqNavigation + " reqInputFeatures = " + reqInputFeatures + " reqGlEsVersion = " + reqGlEsVersion + "}";
}
public int describeContents() {
return 0;
}
/**
* This method extracts the major and minor version of reqGLEsVersion attribute
* and returns it as a string. Say reqGlEsVersion value of 0x00010002 is returned
* as 1.2
* @return String representation of the reqGlEsVersion attribute
*/
public String getGlEsVersion() {
int major = ((reqGlEsVersion & 0xffff0000) >> 16);
int minor = reqGlEsVersion & 0x0000ffff;
return String.valueOf(major) + "." + String.valueOf(minor);
}
}

View File

@@ -22,70 +22,65 @@ package android.content.pm;
* AndroidManifest.xml's &lt;uses-feature&gt; tag.
*/
public class FeatureInfo {
/**
* The name of this feature, for example "android.hardware.camera". If
* this is null, then this is an OpenGL ES version feature as described
* in {@link #reqGlEsVersion}.
*/
public String name;
/**
* Default value for {@link #reqGlEsVersion};
*/
public static final int GL_ES_VERSION_UNDEFINED = 0;
/**
* The GLES version used by an application. The upper order 16 bits represent the
* major version and the lower order 16 bits the minor version. Only valid
* if {@link #name} is null.
*/
public int reqGlEsVersion;
/**
* The name of this feature, for example "android.hardware.camera". If
* this is null, then this is an OpenGL ES version feature as described
* in {@link #reqGlEsVersion}.
*/
public String name;
/**
* Set on {@link #flags} if this feature has been required by the application.
*/
public static final int FLAG_REQUIRED = 0x0001;
/**
* Additional flags. May be zero or more of {@link #FLAG_REQUIRED}.
*/
public int flags;
public FeatureInfo() {
}
/**
* Default value for {@link #reqGlEsVersion};
*/
public static final int GL_ES_VERSION_UNDEFINED = 0;
public FeatureInfo(FeatureInfo orig) {
name = orig.name;
reqGlEsVersion = orig.reqGlEsVersion;
flags = orig.flags;
}
/**
* The GLES version used by an application. The upper order 16 bits represent the
* major version and the lower order 16 bits the minor version. Only valid
* if {@link #name} is null.
*/
public int reqGlEsVersion;
public String toString() {
if (name != null) {
return "FeatureInfo{"
+ Integer.toHexString(System.identityHashCode(this))
+ " " + name + " fl=0x" + Integer.toHexString(flags) + "}";
} else {
return "FeatureInfo{"
+ Integer.toHexString(System.identityHashCode(this))
+ " glEsVers=" + getGlEsVersion()
+ " fl=0x" + Integer.toHexString(flags) + "}";
}
}
/**
* Set on {@link #flags} if this feature has been required by the application.
*/
public static final int FLAG_REQUIRED = 0x0001;
public int describeContents() {
return 0;
}
/**
* Additional flags. May be zero or more of {@link #FLAG_REQUIRED}.
*/
public int flags;
/**
* This method extracts the major and minor version of reqGLEsVersion attribute
* and returns it as a string. Say reqGlEsVersion value of 0x00010002 is returned
* as 1.2
* @return String representation of the reqGlEsVersion attribute
*/
public String getGlEsVersion() {
int major = ((reqGlEsVersion & 0xffff0000) >> 16);
int minor = reqGlEsVersion & 0x0000ffff;
return String.valueOf(major)+"."+String.valueOf(minor);
}
public FeatureInfo() {
}
public FeatureInfo(FeatureInfo orig) {
name = orig.name;
reqGlEsVersion = orig.reqGlEsVersion;
flags = orig.flags;
}
public String toString() {
if (name != null) {
return "FeatureInfo{" + Integer.toHexString(System.identityHashCode(this)) + " " + name + " fl=0x" + Integer.toHexString(flags) + "}";
} else {
return "FeatureInfo{" + Integer.toHexString(System.identityHashCode(this)) + " glEsVers=" + getGlEsVersion() + " fl=0x" + Integer.toHexString(flags) + "}";
}
}
public int describeContents() {
return 0;
}
/**
* This method extracts the major and minor version of reqGLEsVersion attribute
* and returns it as a string. Say reqGlEsVersion value of 0x00010002 is returned
* as 1.2
* @return String representation of the reqGlEsVersion attribute
*/
public String getGlEsVersion() {
int major = ((reqGlEsVersion & 0xffff0000) >> 16);
int minor = reqGlEsVersion & 0x0000ffff;
return String.valueOf(major) + "." + String.valueOf(minor);
}
}

View File

@@ -22,64 +22,64 @@ package android.content.pm;
* from the AndroidManifest.xml's &lt;instrumentation&gt; tag.
*/
public class InstrumentationInfo extends PackageItemInfo {
/**
* The name of the application package being instrumented. From the
* "package" attribute.
*/
public String targetPackage;
/**
* Full path to the location of this package.
*/
public String sourceDir;
/**
* Full path to the location of the publicly available parts of this package (i.e. the resources
* and manifest). For non-forward-locked apps this will be the same as {@link #sourceDir).
*/
public String publicSourceDir;
/**
* Full path to a directory assigned to the package for its persistent
* data.
*/
public String dataDir;
/**
* The name of the application package being instrumented. From the
* "package" attribute.
*/
public String targetPackage;
/**
* Full path to the directory where the native JNI libraries are stored.
*
* {@hide}
*/
public String nativeLibraryDir;
/**
* Full path to the location of this package.
*/
public String sourceDir;
/**
* Specifies whether or not this instrumentation will handle profiling.
*/
public boolean handleProfiling;
/** Specifies whether or not to run this instrumentation as a functional test */
public boolean functionalTest;
/**
* Full path to the location of the publicly available parts of this package (i.e. the resources
* and manifest). For non-forward-locked apps this will be the same as {@link #sourceDir).
*/
public String publicSourceDir;
/**
* Full path to a directory assigned to the package for its persistent
* data.
*/
public String dataDir;
public InstrumentationInfo() {
}
/**
* Full path to the directory where the native JNI libraries are stored.
*
* {@hide}
*/
public String nativeLibraryDir;
public InstrumentationInfo(InstrumentationInfo orig) {
super(orig);
targetPackage = orig.targetPackage;
sourceDir = orig.sourceDir;
publicSourceDir = orig.publicSourceDir;
dataDir = orig.dataDir;
nativeLibraryDir = orig.nativeLibraryDir;
handleProfiling = orig.handleProfiling;
functionalTest = orig.functionalTest;
}
/**
* Specifies whether or not this instrumentation will handle profiling.
*/
public boolean handleProfiling;
public String toString() {
return "InstrumentationInfo{"
+ Integer.toHexString(System.identityHashCode(this))
+ " " + packageName + "}";
}
/**
* Specifies whether or not to run this instrumentation as a functional test
*/
public boolean functionalTest;
public int describeContents() {
return 0;
}
public InstrumentationInfo() {
}
public InstrumentationInfo(InstrumentationInfo orig) {
super(orig);
targetPackage = orig.targetPackage;
sourceDir = orig.sourceDir;
publicSourceDir = orig.publicSourceDir;
dataDir = orig.dataDir;
nativeLibraryDir = orig.nativeLibraryDir;
handleProfiling = orig.handleProfiling;
functionalTest = orig.functionalTest;
}
public String toString() {
return "InstrumentationInfo{" + Integer.toHexString(System.identityHashCode(this)) + " " + packageName + "}";
}
public int describeContents() {
return 0;
}
}

View File

@@ -17,7 +17,6 @@
package android.content.pm;
import android.util.Slog;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -25,7 +24,6 @@ import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import libcore.io.IoUtils;
/**
@@ -35,85 +33,90 @@ import libcore.io.IoUtils;
* @hide
*/
public class ManifestDigest {
private static final String TAG = "ManifestDigest";
private static final String TAG = "ManifestDigest";
/** The digest of the manifest in our preferred order. */
private final byte[] mDigest;
/**
* The digest of the manifest in our preferred order.
*/
private final byte[] mDigest;
/** What we print out first when toString() is called. */
private static final String TO_STRING_PREFIX = "ManifestDigest {mDigest=";
/**
* What we print out first when toString() is called.
*/
private static final String TO_STRING_PREFIX = "ManifestDigest {mDigest=";
/** Digest algorithm to use. */
private static final String DIGEST_ALGORITHM = "SHA-256";
/**
* Digest algorithm to use.
*/
private static final String DIGEST_ALGORITHM = "SHA-256";
ManifestDigest(byte[] digest) {
mDigest = digest;
}
ManifestDigest(byte[] digest) {
mDigest = digest;
}
static ManifestDigest fromInputStream(InputStream fileIs) {
if (fileIs == null) {
return null;
}
static ManifestDigest fromInputStream(InputStream fileIs) {
if (fileIs == null) {
return null;
}
final MessageDigest md;
try {
md = MessageDigest.getInstance(DIGEST_ALGORITHM);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(DIGEST_ALGORITHM + " must be available", e);
}
final MessageDigest md;
try {
md = MessageDigest.getInstance(DIGEST_ALGORITHM);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(DIGEST_ALGORITHM + " must be available", e);
}
final DigestInputStream dis = new DigestInputStream(new BufferedInputStream(fileIs), md);
try {
byte[] readBuffer = new byte[8192];
while (dis.read(readBuffer, 0, readBuffer.length) != -1) {
// not using
}
} catch (IOException e) {
Slog.w(TAG, "Could not read manifest");
return null;
} finally {
IoUtils.closeQuietly(dis);
}
final DigestInputStream dis = new DigestInputStream(new BufferedInputStream(fileIs), md);
try {
byte[] readBuffer = new byte[8192];
while (dis.read(readBuffer, 0, readBuffer.length) != -1) {
// not using
}
} catch (IOException e) {
Slog.w(TAG, "Could not read manifest");
return null;
} finally {
IoUtils.closeQuietly(dis);
}
final byte[] digest = md.digest();
return new ManifestDigest(digest);
}
final byte[] digest = md.digest();
return new ManifestDigest(digest);
}
public int describeContents() {
return 0;
}
public int describeContents() {
return 0;
}
@Override
public boolean equals(Object o) {
if (!(o instanceof ManifestDigest)) {
return false;
}
@Override
public boolean equals(Object o) {
if (!(o instanceof ManifestDigest)) {
return false;
}
final ManifestDigest other = (ManifestDigest) o;
final ManifestDigest other = (ManifestDigest)o;
return this == other || Arrays.equals(mDigest, other.mDigest);
}
return this == other || Arrays.equals(mDigest, other.mDigest);
}
@Override
public int hashCode() {
return Arrays.hashCode(mDigest);
}
@Override
public int hashCode() {
return Arrays.hashCode(mDigest);
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder(TO_STRING_PREFIX.length()
+ (mDigest.length * 3) + 1);
@Override
public String toString() {
final StringBuilder sb = new StringBuilder(TO_STRING_PREFIX.length() + (mDigest.length * 3) + 1);
sb.append(TO_STRING_PREFIX);
sb.append(TO_STRING_PREFIX);
final int N = mDigest.length;
for (int i = 0; i < N; i++) {
final byte b = mDigest[i];
sb.append(String.format("%02x", b));
sb.append(',');
}
sb.append('}');
final int N = mDigest.length;
for (int i = 0; i < N; i++) {
final byte b = mDigest[i];
sb.append(String.format("%02x", b));
sb.append(',');
}
sb.append('}');
return sb.toString();
}
return sb.toString();
}
}

View File

@@ -21,220 +21,223 @@ package android.content.pm;
* to all of the information collected from AndroidManifest.xml.
*/
public class PackageInfo {
/**
* The name of this package. From the &lt;manifest&gt; tag's "name"
* attribute.
*/
public String packageName = "com.example.app"; // FIXME
/**
* The name of this package. From the &lt;manifest&gt; tag's "name"
* attribute.
*/
public String packageName = "com.example.app"; // FIXME
/**
* The version number of this package, as specified by the &lt;manifest&gt;
* tag's {@link android.R.styleable#AndroidManifest_versionCode versionCode}
* attribute.
*/
public int versionCode = 1; //FIXME
/**
* The version name of this package, as specified by the &lt;manifest&gt;
* tag's {@link android.R.styleable#AndroidManifest_versionName versionName}
* attribute.
*/
public String versionName = "v0.FIXME";
/**
* The shared user ID name of this package, as specified by the &lt;manifest&gt;
* tag's {@link android.R.styleable#AndroidManifest_sharedUserId sharedUserId}
* attribute.
*/
public String sharedUserId;
/**
* The shared user ID label of this package, as specified by the &lt;manifest&gt;
* tag's {@link android.R.styleable#AndroidManifest_sharedUserLabel sharedUserLabel}
* attribute.
*/
public int sharedUserLabel;
/**
* Information collected from the &lt;application&gt; tag, or null if
* there was none.
*/
public ApplicationInfo applicationInfo;
/**
* The time at which the app was first installed. Units are as
* per {@link System#currentTimeMillis()}.
*/
public long firstInstallTime;
/**
* The version number of this package, as specified by the &lt;manifest&gt;
* tag's {@link android.R.styleable#AndroidManifest_versionCode versionCode}
* attribute.
*/
public int versionCode = 1; // FIXME
/**
* The time at which the app was last updated. Units are as
* per {@link System#currentTimeMillis()}.
*/
public long lastUpdateTime;
/**
* The version name of this package, as specified by the &lt;manifest&gt;
* tag's {@link android.R.styleable#AndroidManifest_versionName versionName}
* attribute.
*/
public String versionName = "v0.FIXME";
/**
* All kernel group-IDs that have been assigned to this package.
* This is only filled in if the flag {@link PackageManager#GET_GIDS} was set.
*/
public int[] gids;
/**
* The shared user ID name of this package, as specified by the &lt;manifest&gt;
* tag's {@link android.R.styleable#AndroidManifest_sharedUserId sharedUserId}
* attribute.
*/
public String sharedUserId;
/**
* Array of all {@link android.R.styleable#AndroidManifestActivity
* &lt;activity&gt;} tags included under &lt;application&gt;,
* or null if there were none. This is only filled in if the flag
* {@link PackageManager#GET_ACTIVITIES} was set.
*/
public ActivityInfo[] activities;
/**
* The shared user ID label of this package, as specified by the &lt;manifest&gt;
* tag's {@link android.R.styleable#AndroidManifest_sharedUserLabel sharedUserLabel}
* attribute.
*/
public int sharedUserLabel;
/**
* Array of all {@link android.R.styleable#AndroidManifestReceiver
* &lt;receiver&gt;} tags included under &lt;application&gt;,
* or null if there were none. This is only filled in if the flag
* {@link PackageManager#GET_RECEIVERS} was set.
*/
public ActivityInfo[] receivers;
/**
* Information collected from the &lt;application&gt; tag, or null if
* there was none.
*/
public ApplicationInfo applicationInfo;
/**
* Array of all {@link android.R.styleable#AndroidManifestService
* &lt;service&gt;} tags included under &lt;application&gt;,
* or null if there were none. This is only filled in if the flag
* {@link PackageManager#GET_SERVICES} was set.
*/
public ServiceInfo[] services;
/**
* The time at which the app was first installed. Units are as
* per {@link System#currentTimeMillis()}.
*/
public long firstInstallTime;
/**
* Array of all {@link android.R.styleable#AndroidManifestProvider
* &lt;provider&gt;} tags included under &lt;application&gt;,
* or null if there were none. This is only filled in if the flag
* {@link PackageManager#GET_PROVIDERS} was set.
*/
public ProviderInfo[] providers;
/**
* The time at which the app was last updated. Units are as
* per {@link System#currentTimeMillis()}.
*/
public long lastUpdateTime;
/**
* Array of all {@link android.R.styleable#AndroidManifestInstrumentation
* &lt;instrumentation&gt;} tags included under &lt;manifest&gt;,
* or null if there were none. This is only filled in if the flag
* {@link PackageManager#GET_INSTRUMENTATION} was set.
*/
public InstrumentationInfo[] instrumentation;
/**
* Array of all {@link android.R.styleable#AndroidManifestPermission
* &lt;permission&gt;} tags included under &lt;manifest&gt;,
* or null if there were none. This is only filled in if the flag
* {@link PackageManager#GET_PERMISSIONS} was set.
*/
public PermissionInfo[] permissions;
/**
* Array of all {@link android.R.styleable#AndroidManifestUsesPermission
* &lt;uses-permission&gt;} tags included under &lt;manifest&gt;,
* or null if there were none. This is only filled in if the flag
* {@link PackageManager#GET_PERMISSIONS} was set. This list includes
* all permissions requested, even those that were not granted or known
* by the system at install time.
*/
public String[] requestedPermissions;
/**
* Array of flags of all {@link android.R.styleable#AndroidManifestUsesPermission
* &lt;uses-permission&gt;} tags included under &lt;manifest&gt;,
* or null if there were none. This is only filled in if the flag
* {@link PackageManager#GET_PERMISSIONS} was set. Each value matches
* the corresponding entry in {@link #requestedPermissions}, and will have
* the flags {@link #REQUESTED_PERMISSION_REQUIRED} and
* {@link #REQUESTED_PERMISSION_GRANTED} set as appropriate.
*/
public int[] requestedPermissionsFlags;
/**
* All kernel group-IDs that have been assigned to this package.
* This is only filled in if the flag {@link PackageManager#GET_GIDS} was set.
*/
public int[] gids;
/**
* Flag for {@link #requestedPermissionsFlags}: the requested permission
* is required for the application to run; the user can not optionally
* disable it. Currently all permissions are required.
*/
public static final int REQUESTED_PERMISSION_REQUIRED = 1<<0;
/**
* Array of all {@link android.R.styleable#AndroidManifestActivity
* &lt;activity&gt;} tags included under &lt;application&gt;,
* or null if there were none. This is only filled in if the flag
* {@link PackageManager#GET_ACTIVITIES} was set.
*/
public ActivityInfo[] activities;
/**
* Flag for {@link #requestedPermissionsFlags}: the requested permission
* is currently granted to the application.
*/
public static final int REQUESTED_PERMISSION_GRANTED = 1<<1;
/**
* Array of all {@link android.R.styleable#AndroidManifestReceiver
* &lt;receiver&gt;} tags included under &lt;application&gt;,
* or null if there were none. This is only filled in if the flag
* {@link PackageManager#GET_RECEIVERS} was set.
*/
public ActivityInfo[] receivers;
/**
* Array of all signatures read from the package file. This is only filled
* in if the flag {@link PackageManager#GET_SIGNATURES} was set.
*/
public Signature[] signatures;
/**
* Application specified preferred configuration
* {@link android.R.styleable#AndroidManifestUsesConfiguration
* &lt;uses-configuration&gt;} tags included under &lt;manifest&gt;,
* or null if there were none. This is only filled in if the flag
* {@link PackageManager#GET_CONFIGURATIONS} was set.
*/
public ConfigurationInfo[] configPreferences;
/**
* Array of all {@link android.R.styleable#AndroidManifestService
* &lt;service&gt;} tags included under &lt;application&gt;,
* or null if there were none. This is only filled in if the flag
* {@link PackageManager#GET_SERVICES} was set.
*/
public ServiceInfo[] services;
/**
* The features that this application has said it requires.
*/
public FeatureInfo[] reqFeatures;
/**
* Array of all {@link android.R.styleable#AndroidManifestProvider
* &lt;provider&gt;} tags included under &lt;application&gt;,
* or null if there were none. This is only filled in if the flag
* {@link PackageManager#GET_PROVIDERS} was set.
*/
public ProviderInfo[] providers;
/**
* Constant corresponding to <code>auto</code> in
* the {@link android.R.attr#installLocation} attribute.
* @hide
*/
public static final int INSTALL_LOCATION_UNSPECIFIED = -1;
/**
* Constant corresponding to <code>auto</code> in
* the {@link android.R.attr#installLocation} attribute.
* @hide
*/
public static final int INSTALL_LOCATION_AUTO = 0;
/**
* Constant corresponding to <code>internalOnly</code> in
* the {@link android.R.attr#installLocation} attribute.
* @hide
*/
public static final int INSTALL_LOCATION_INTERNAL_ONLY = 1;
/**
* Constant corresponding to <code>preferExternal</code> in
* the {@link android.R.attr#installLocation} attribute.
* @hide
*/
public static final int INSTALL_LOCATION_PREFER_EXTERNAL = 2;
/**
* The install location requested by the activity. From the
* {@link android.R.attr#installLocation} attribute, one of
* {@link #INSTALL_LOCATION_AUTO},
* {@link #INSTALL_LOCATION_INTERNAL_ONLY},
* {@link #INSTALL_LOCATION_PREFER_EXTERNAL}
* @hide
*/
public int installLocation = INSTALL_LOCATION_INTERNAL_ONLY;
/**
* Array of all {@link android.R.styleable#AndroidManifestInstrumentation
* &lt;instrumentation&gt;} tags included under &lt;manifest&gt;,
* or null if there were none. This is only filled in if the flag
* {@link PackageManager#GET_INSTRUMENTATION} was set.
*/
public InstrumentationInfo[] instrumentation;
/** @hide */
public boolean requiredForAllUsers;
/**
* Array of all {@link android.R.styleable#AndroidManifestPermission
* &lt;permission&gt;} tags included under &lt;manifest&gt;,
* or null if there were none. This is only filled in if the flag
* {@link PackageManager#GET_PERMISSIONS} was set.
*/
public PermissionInfo[] permissions;
/** @hide */
public String restrictedAccountType;
/**
* Array of all {@link android.R.styleable#AndroidManifestUsesPermission
* &lt;uses-permission&gt;} tags included under &lt;manifest&gt;,
* or null if there were none. This is only filled in if the flag
* {@link PackageManager#GET_PERMISSIONS} was set. This list includes
* all permissions requested, even those that were not granted or known
* by the system at install time.
*/
public String[] requestedPermissions;
/** @hide */
public String requiredAccountType;
/**
* Array of flags of all {@link android.R.styleable#AndroidManifestUsesPermission
* &lt;uses-permission&gt;} tags included under &lt;manifest&gt;,
* or null if there were none. This is only filled in if the flag
* {@link PackageManager#GET_PERMISSIONS} was set. Each value matches
* the corresponding entry in {@link #requestedPermissions}, and will have
* the flags {@link #REQUESTED_PERMISSION_REQUIRED} and
* {@link #REQUESTED_PERMISSION_GRANTED} set as appropriate.
*/
public int[] requestedPermissionsFlags;
public PackageInfo() {
}
/**
* Flag for {@link #requestedPermissionsFlags}: the requested permission
* is required for the application to run; the user can not optionally
* disable it. Currently all permissions are required.
*/
public static final int REQUESTED_PERMISSION_REQUIRED = 1 << 0;
public String toString() {
return "PackageInfo{"
+ Integer.toHexString(System.identityHashCode(this))
+ " " + packageName + "}";
}
/**
* Flag for {@link #requestedPermissionsFlags}: the requested permission
* is currently granted to the application.
*/
public static final int REQUESTED_PERMISSION_GRANTED = 1 << 1;
public int describeContents() {
return 0;
}
/**
* Array of all signatures read from the package file. This is only filled
* in if the flag {@link PackageManager#GET_SIGNATURES} was set.
*/
public Signature[] signatures;
/**
* Application specified preferred configuration
* {@link android.R.styleable#AndroidManifestUsesConfiguration
* &lt;uses-configuration&gt;} tags included under &lt;manifest&gt;,
* or null if there were none. This is only filled in if the flag
* {@link PackageManager#GET_CONFIGURATIONS} was set.
*/
public ConfigurationInfo[] configPreferences;
/**
* The features that this application has said it requires.
*/
public FeatureInfo[] reqFeatures;
/**
* Constant corresponding to <code>auto</code> in
* the {@link android.R.attr#installLocation} attribute.
* @hide
*/
public static final int INSTALL_LOCATION_UNSPECIFIED = -1;
/**
* Constant corresponding to <code>auto</code> in
* the {@link android.R.attr#installLocation} attribute.
* @hide
*/
public static final int INSTALL_LOCATION_AUTO = 0;
/**
* Constant corresponding to <code>internalOnly</code> in
* the {@link android.R.attr#installLocation} attribute.
* @hide
*/
public static final int INSTALL_LOCATION_INTERNAL_ONLY = 1;
/**
* Constant corresponding to <code>preferExternal</code> in
* the {@link android.R.attr#installLocation} attribute.
* @hide
*/
public static final int INSTALL_LOCATION_PREFER_EXTERNAL = 2;
/**
* The install location requested by the activity. From the
* {@link android.R.attr#installLocation} attribute, one of
* {@link #INSTALL_LOCATION_AUTO},
* {@link #INSTALL_LOCATION_INTERNAL_ONLY},
* {@link #INSTALL_LOCATION_PREFER_EXTERNAL}
* @hide
*/
public int installLocation = INSTALL_LOCATION_INTERNAL_ONLY;
/**
* @hide
*/
public boolean requiredForAllUsers;
/**
* @hide
*/
public String restrictedAccountType;
/**
* @hide
*/
public String requiredAccountType;
public PackageInfo() {
}
public String toString() {
return "PackageInfo{" + Integer.toHexString(System.identityHashCode(this)) + " " + packageName + "}";
}
public int describeContents() {
return 0;
}
}

View File

@@ -17,12 +17,10 @@
package android.content.pm;
import android.content.res.XmlResourceParser;
//import android.graphics.drawable.Drawable;
// import android.graphics.drawable.Drawable;
import android.os.Bundle;
//import android.text.TextUtils;
// import android.text.TextUtils;
import android.util.Printer;
import java.text.Collator;
import java.util.Comparator;
@@ -36,231 +34,233 @@ import java.util.Comparator;
* in the implementation of Parcelable in subclasses.
*/
public class PackageItemInfo {
/**
* Public name of this item. From the "android:name" attribute.
*/
public String name;
/**
* Name of the package that this item is in.
*/
public String packageName;
/**
* A string resource identifier (in the package's resources) of this
* component's label. From the "label" attribute or, if not set, 0.
*/
public int labelRes;
/**
* The string provided in the AndroidManifest file, if any. You
* probably don't want to use this. You probably want
* {@link PackageManager#getApplicationLabel}
*/
public CharSequence nonLocalizedLabel;
/**
* A drawable resource identifier (in the package's resources) of this
* component's icon. From the "icon" attribute or, if not set, 0.
*/
public int icon;
/**
* A drawable resource identifier (in the package's resources) of this
* component's logo. Logos may be larger/wider than icons and are
* displayed by certain UI elements in place of a name or name/icon
* combination. From the "logo" attribute or, if not set, 0.
*/
public int logo;
/**
* Additional meta-data associated with this component. This field
* will only be filled in if you set the
* {@link PackageManager#GET_META_DATA} flag when requesting the info.
*/
public Bundle metaData;
public PackageItemInfo() {
}
/**
* Public name of this item. From the "android:name" attribute.
*/
public String name;
public PackageItemInfo(PackageItemInfo orig) {
name = orig.name;
if (name != null) name = name.trim();
packageName = orig.packageName;
labelRes = orig.labelRes;
nonLocalizedLabel = orig.nonLocalizedLabel;
if (nonLocalizedLabel != null) nonLocalizedLabel = nonLocalizedLabel.toString().trim();
icon = orig.icon;
logo = orig.logo;
metaData = orig.metaData;
}
/**
* Name of the package that this item is in.
*/
public String packageName;
/**
* Retrieve the current textual label associated with this item. This
* will call back on the given PackageManager to load the label from
* the application.
*
* @param pm A PackageManager from which the label can be loaded; usually
* the PackageManager from which you originally retrieved this item.
*
* @return Returns a CharSequence containing the item's label. If the
* item does not have a label, its name is returned.
*/
public CharSequence loadLabel(PackageManager pm) {
if (nonLocalizedLabel != null) {
return nonLocalizedLabel;
}
if (labelRes != 0) {
CharSequence label = pm.getText(packageName, labelRes, getApplicationInfo());
if (label != null) {
return label.toString().trim();
}
}
if (name != null) {
return name;
}
return packageName;
}
/**
* Retrieve the current graphical icon associated with this item. This
* will call back on the given PackageManager to load the icon from
* the application.
*
* @param pm A PackageManager from which the icon can be loaded; usually
* the PackageManager from which you originally retrieved this item.
*
* @return Returns a Drawable containing the item's icon. If the
* item does not have an icon, the item's default icon is returned
* such as the default activity icon.
*/
public Drawable loadIcon(PackageManager pm) {
if (icon != 0) {
Drawable dr = pm.getDrawable(packageName, icon, getApplicationInfo());
if (dr != null) {
return dr;
}
}
return loadDefaultIcon(pm);
}
/**
* Retrieve the default graphical icon associated with this item.
*
* @param pm A PackageManager from which the icon can be loaded; usually
* the PackageManager from which you originally retrieved this item.
*
* @return Returns a Drawable containing the item's default icon
* such as the default activity icon.
*
* @hide
*/
protected Drawable loadDefaultIcon(PackageManager pm) {
return pm.getDefaultActivityIcon();
}
/**
* Retrieve the current graphical logo associated with this item. This
* will call back on the given PackageManager to load the logo from
* the application.
*
* @param pm A PackageManager from which the logo can be loaded; usually
* the PackageManager from which you originally retrieved this item.
*
* @return Returns a Drawable containing the item's logo. If the item
* does not have a logo, this method will return null.
*/
public Drawable loadLogo(PackageManager pm) {
if (logo != 0) {
Drawable d = pm.getDrawable(packageName, logo, getApplicationInfo());
if (d != null) {
return d;
}
}
return loadDefaultLogo(pm);
}
/**
* Retrieve the default graphical logo associated with this item.
*
* @param pm A PackageManager from which the logo can be loaded; usually
* the PackageManager from which you originally retrieved this item.
*
* @return Returns a Drawable containing the item's default logo
* or null if no default logo is available.
*
* @hide
*/
protected Drawable loadDefaultLogo(PackageManager pm) {
return null;
}
/**
* Load an XML resource attached to the meta-data of this item. This will
* retrieved the name meta-data entry, and if defined call back on the
* given PackageManager to load its XML file from the application.
*
* @param pm A PackageManager from which the XML can be loaded; usually
* the PackageManager from which you originally retrieved this item.
* @param name Name of the meta-date you would like to load.
*
* @return Returns an XmlPullParser you can use to parse the XML file
* assigned as the given meta-data. If the meta-data name is not defined
* or the XML resource could not be found, null is returned.
*/
public XmlResourceParser loadXmlMetaData(PackageManager pm, String name) {
if (metaData != null) {
int resid = metaData.getInt(name);
if (resid != 0) {
return pm.getXml(packageName, resid, getApplicationInfo());
}
}
return null;
}
/**
* A string resource identifier (in the package's resources) of this
* component's label. From the "label" attribute or, if not set, 0.
*/
public int labelRes;
protected void dumpFront(Printer pw, String prefix) {
if (name != null) {
pw.println(prefix + "name=" + name);
}
pw.println(prefix + "packageName=" + packageName);
if (labelRes != 0 || nonLocalizedLabel != null || icon != 0) {
pw.println(prefix + "labelRes=0x" + Integer.toHexString(labelRes)
+ " nonLocalizedLabel=" + nonLocalizedLabel
+ " icon=0x" + Integer.toHexString(icon));
}
}
protected void dumpBack(Printer pw, String prefix) {
// no back here
}
/**
* The string provided in the AndroidManifest file, if any. You
* probably don't want to use this. You probably want
* {@link PackageManager#getApplicationLabel}
*/
public CharSequence nonLocalizedLabel;
/**
* Get the ApplicationInfo for the application to which this item belongs,
* if available, otherwise returns null.
*
* @return Returns the ApplicationInfo of this item, or null if not known.
*
* @hide
*/
protected ApplicationInfo getApplicationInfo() {
return null;
}
/**
* A drawable resource identifier (in the package's resources) of this
* component's icon. From the "icon" attribute or, if not set, 0.
*/
public int icon;
public static class DisplayNameComparator
implements Comparator<PackageItemInfo> {
public DisplayNameComparator(PackageManager pm) {
mPM = pm;
}
/**
* A drawable resource identifier (in the package's resources) of this
* component's logo. Logos may be larger/wider than icons and are
* displayed by certain UI elements in place of a name or name/icon
* combination. From the "logo" attribute or, if not set, 0.
*/
public int logo;
public final int compare(PackageItemInfo aa, PackageItemInfo ab) {
CharSequence sa = aa.loadLabel(mPM);
if (sa == null) sa = aa.name;
CharSequence sb = ab.loadLabel(mPM);
if (sb == null) sb = ab.name;
return sCollator.compare(sa.toString(), sb.toString());
}
/**
* Additional meta-data associated with this component. This field
* will only be filled in if you set the
* {@link PackageManager#GET_META_DATA} flag when requesting the info.
*/
public Bundle metaData;
private final Collator sCollator = Collator.getInstance();
private PackageManager mPM;
}
public PackageItemInfo() {
}
public PackageItemInfo(PackageItemInfo orig) {
name = orig.name;
if (name != null)
name = name.trim();
packageName = orig.packageName;
labelRes = orig.labelRes;
nonLocalizedLabel = orig.nonLocalizedLabel;
if (nonLocalizedLabel != null)
nonLocalizedLabel = nonLocalizedLabel.toString().trim();
icon = orig.icon;
logo = orig.logo;
metaData = orig.metaData;
}
/**
* Retrieve the current textual label associated with this item. This
* will call back on the given PackageManager to load the label from
* the application.
*
* @param pm A PackageManager from which the label can be loaded; usually
* the PackageManager from which you originally retrieved this item.
*
* @return Returns a CharSequence containing the item's label. If the
* item does not have a label, its name is returned.
*/
public CharSequence loadLabel(PackageManager pm) {
if (nonLocalizedLabel != null) {
return nonLocalizedLabel;
}
if (labelRes != 0) {
CharSequence label = pm.getText(packageName, labelRes, getApplicationInfo());
if (label != null) {
return label.toString().trim();
}
}
if (name != null) {
return name;
}
return packageName;
}
/**
* Retrieve the current graphical icon associated with this item. This
* will call back on the given PackageManager to load the icon from
* the application.
*
* @param pm A PackageManager from which the icon can be loaded; usually
* the PackageManager from which you originally retrieved this item.
*
* @return Returns a Drawable containing the item's icon. If the
* item does not have an icon, the item's default icon is returned
* such as the default activity icon.
*/
public Drawable loadIcon(PackageManager pm) {
if (icon != 0) {
Drawable dr = pm.getDrawable(packageName, icon, getApplicationInfo());
if (dr != null) {
return dr;
}
}
return loadDefaultIcon(pm);
}
/**
* Retrieve the default graphical icon associated with this item.
*
* @param pm A PackageManager from which the icon can be loaded; usually
* the PackageManager from which you originally retrieved this item.
*
* @return Returns a Drawable containing the item's default icon
* such as the default activity icon.
*
* @hide
*/
protected Drawable loadDefaultIcon(PackageManager pm) {
return pm.getDefaultActivityIcon();
}
/**
* Retrieve the current graphical logo associated with this item. This
* will call back on the given PackageManager to load the logo from
* the application.
*
* @param pm A PackageManager from which the logo can be loaded; usually
* the PackageManager from which you originally retrieved this item.
*
* @return Returns a Drawable containing the item's logo. If the item
* does not have a logo, this method will return null.
*/
public Drawable loadLogo(PackageManager pm) {
if (logo != 0) {
Drawable d = pm.getDrawable(packageName, logo, getApplicationInfo());
if (d != null) {
return d;
}
}
return loadDefaultLogo(pm);
}
/**
* Retrieve the default graphical logo associated with this item.
*
* @param pm A PackageManager from which the logo can be loaded; usually
* the PackageManager from which you originally retrieved this item.
*
* @return Returns a Drawable containing the item's default logo
* or null if no default logo is available.
*
* @hide
*/
protected Drawable loadDefaultLogo(PackageManager pm) {
return null;
}
/**
* Load an XML resource attached to the meta-data of this item. This will
* retrieved the name meta-data entry, and if defined call back on the
* given PackageManager to load its XML file from the application.
*
* @param pm A PackageManager from which the XML can be loaded; usually
* the PackageManager from which you originally retrieved this item.
* @param name Name of the meta-date you would like to load.
*
* @return Returns an XmlPullParser you can use to parse the XML file
* assigned as the given meta-data. If the meta-data name is not defined
* or the XML resource could not be found, null is returned.
*/
public XmlResourceParser loadXmlMetaData(PackageManager pm, String name) {
if (metaData != null) {
int resid = metaData.getInt(name);
if (resid != 0) {
return pm.getXml(packageName, resid, getApplicationInfo());
}
}
return null;
}
protected void dumpFront(Printer pw, String prefix) {
if (name != null) {
pw.println(prefix + "name=" + name);
}
pw.println(prefix + "packageName=" + packageName);
if (labelRes != 0 || nonLocalizedLabel != null || icon != 0) {
pw.println(prefix + "labelRes=0x" + Integer.toHexString(labelRes) + " nonLocalizedLabel=" + nonLocalizedLabel + " icon=0x" + Integer.toHexString(icon));
}
}
protected void dumpBack(Printer pw, String prefix) {
// no back here
}
/**
* Get the ApplicationInfo for the application to which this item belongs,
* if available, otherwise returns null.
*
* @return Returns the ApplicationInfo of this item, or null if not known.
*
* @hide
*/
protected ApplicationInfo getApplicationInfo() {
return null;
}
public static class DisplayNameComparator
implements Comparator<PackageItemInfo> {
public DisplayNameComparator(PackageManager pm) {
mPM = pm;
}
public final int compare(PackageItemInfo aa, PackageItemInfo ab) {
CharSequence sa = aa.loadLabel(mPM);
if (sa == null)
sa = aa.name;
CharSequence sb = ab.loadLabel(mPM);
if (sb == null)
sb = ab.name;
return sCollator.compare(sa.toString(), sb.toString());
}
private final Collator sCollator = Collator.getInstance();
private PackageManager mPM;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -25,33 +25,35 @@ import java.util.HashSet;
* @hide
*/
public class PackageUserState {
public boolean stopped;
public boolean notLaunched;
public boolean installed;
public boolean blocked; // Is the app restricted by owner / admin
public int enabled;
public boolean stopped;
public boolean notLaunched;
public boolean installed;
public boolean blocked; // Is the app restricted by owner / admin
public int enabled;
public String lastDisableAppCaller;
public String lastDisableAppCaller;
public HashSet<String> disabledComponents;
public HashSet<String> enabledComponents;
public HashSet<String> disabledComponents;
public HashSet<String> enabledComponents;
public PackageUserState() {
installed = true;
blocked = false;
enabled = COMPONENT_ENABLED_STATE_DEFAULT;
}
public PackageUserState() {
installed = true;
blocked = false;
enabled = COMPONENT_ENABLED_STATE_DEFAULT;
}
public PackageUserState(PackageUserState o) {
installed = o.installed;
stopped = o.stopped;
notLaunched = o.notLaunched;
enabled = o.enabled;
blocked = o.blocked;
lastDisableAppCaller = o.lastDisableAppCaller;
disabledComponents = o.disabledComponents != null
? new HashSet<String>(o.disabledComponents) : null;
enabledComponents = o.enabledComponents != null
? new HashSet<String>(o.enabledComponents) : null;
}
public PackageUserState(PackageUserState o) {
installed = o.installed;
stopped = o.stopped;
notLaunched = o.notLaunched;
enabled = o.enabled;
blocked = o.blocked;
lastDisableAppCaller = o.lastDisableAppCaller;
disabledComponents = o.disabledComponents != null
? new HashSet<String>(o.disabledComponents)
: null;
enabledComponents = o.enabledComponents != null
? new HashSet<String>(o.enabledComponents)
: null;
}
}

View File

@@ -23,21 +23,21 @@ import android.os.PatternMatcher;
* in a {@link ProviderInfo}.
*/
public class PathPermission extends PatternMatcher {
private final String mReadPermission;
private final String mWritePermission;
public PathPermission(String pattern, int type, String readPermission,
String writePermission) {
super(pattern, type);
mReadPermission = readPermission;
mWritePermission = writePermission;
}
public String getReadPermission() {
return mReadPermission;
}
public String getWritePermission() {
return mWritePermission;
}
private final String mReadPermission;
private final String mWritePermission;
public PathPermission(String pattern, int type, String readPermission,
String writePermission) {
super(pattern, type);
mReadPermission = readPermission;
mWritePermission = writePermission;
}
public String getReadPermission() {
return mReadPermission;
}
public String getWritePermission() {
return mWritePermission;
}
}

View File

@@ -16,7 +16,7 @@
package android.content.pm;
//import android.text.TextUtils;
// import android.text.TextUtils;
/**
* Information you can retrieve about a particular security permission
@@ -24,80 +24,78 @@ package android.content.pm;
* AndroidManifest.xml's &lt;permission-group&gt; tags.
*/
public class PermissionGroupInfo extends PackageItemInfo {
/**
* A string resource identifier (in the package's resources) of this
* permission's description. From the "description" attribute or,
* if not set, 0.
*/
public int descriptionRes;
/**
* A string resource identifier (in the package's resources) of this
* permission's description. From the "description" attribute or,
* if not set, 0.
*/
public int descriptionRes;
/**
* The description string provided in the AndroidManifest file, if any. You
* probably don't want to use this, since it will be null if the description
* is in a resource. You probably want
* {@link PermissionInfo#loadDescription} instead.
*/
public CharSequence nonLocalizedDescription;
/**
* The description string provided in the AndroidManifest file, if any. You
* probably don't want to use this, since it will be null if the description
* is in a resource. You probably want
* {@link PermissionInfo#loadDescription} instead.
*/
public CharSequence nonLocalizedDescription;
/**
* Flag for {@link #flags}, corresponding to <code>personalInfo</code>
* value of {@link android.R.attr#permissionGroupFlags}.
*/
public static final int FLAG_PERSONAL_INFO = 1<<0;
/**
* Flag for {@link #flags}, corresponding to <code>personalInfo</code>
* value of {@link android.R.attr#permissionGroupFlags}.
*/
public static final int FLAG_PERSONAL_INFO = 1 << 0;
/**
* Additional flags about this group as given by
* {@link android.R.attr#permissionGroupFlags}.
*/
public int flags;
/**
* Additional flags about this group as given by
* {@link android.R.attr#permissionGroupFlags}.
*/
public int flags;
/**
* Prioritization of this group, for visually sorting with other groups.
*/
public int priority;
/**
* Prioritization of this group, for visually sorting with other groups.
*/
public int priority;
public PermissionGroupInfo() {
}
public PermissionGroupInfo() {
}
public PermissionGroupInfo(PermissionGroupInfo orig) {
super(orig);
descriptionRes = orig.descriptionRes;
nonLocalizedDescription = orig.nonLocalizedDescription;
flags = orig.flags;
priority = orig.priority;
}
public PermissionGroupInfo(PermissionGroupInfo orig) {
super(orig);
descriptionRes = orig.descriptionRes;
nonLocalizedDescription = orig.nonLocalizedDescription;
flags = orig.flags;
priority = orig.priority;
}
/**
* Retrieve the textual description of this permission. This
* will call back on the given PackageManager to load the description from
* the application.
*
* @param pm A PackageManager from which the label can be loaded; usually
* the PackageManager from which you originally retrieved this item.
*
* @return Returns a CharSequence containing the permission's description.
* If there is no description, null is returned.
*/
public CharSequence loadDescription(PackageManager pm) {
if (nonLocalizedDescription != null) {
return nonLocalizedDescription;
}
if (descriptionRes != 0) {
CharSequence label = pm.getText(packageName, descriptionRes, null);
if (label != null) {
return label;
}
}
return null;
}
/**
* Retrieve the textual description of this permission. This
* will call back on the given PackageManager to load the description from
* the application.
*
* @param pm A PackageManager from which the label can be loaded; usually
* the PackageManager from which you originally retrieved this item.
*
* @return Returns a CharSequence containing the permission's description.
* If there is no description, null is returned.
*/
public CharSequence loadDescription(PackageManager pm) {
if (nonLocalizedDescription != null) {
return nonLocalizedDescription;
}
if (descriptionRes != 0) {
CharSequence label = pm.getText(packageName, descriptionRes, null);
if (label != null) {
return label;
}
}
return null;
}
public String toString() {
return "PermissionGroupInfo{"
+ Integer.toHexString(System.identityHashCode(this))
+ " " + name + " flgs=0x" + Integer.toHexString(flags) + "}";
}
public String toString() {
return "PermissionGroupInfo{" + Integer.toHexString(System.identityHashCode(this)) + " " + name + " flgs=0x" + Integer.toHexString(flags) + "}";
}
public int describeContents() {
return 0;
}
public int describeContents() {
return 0;
}
}

View File

@@ -22,179 +22,181 @@ package android.content.pm;
* AndroidManifest.xml's &lt;permission&gt; tags.
*/
public class PermissionInfo extends PackageItemInfo {
/**
* A normal application value for {@link #protectionLevel}, corresponding
* to the <code>normal</code> value of
* {@link android.R.attr#protectionLevel}.
*/
public static final int PROTECTION_NORMAL = 0;
/**
* A normal application value for {@link #protectionLevel}, corresponding
* to the <code>normal</code> value of
* {@link android.R.attr#protectionLevel}.
*/
public static final int PROTECTION_NORMAL = 0;
/**
* Dangerous value for {@link #protectionLevel}, corresponding
* to the <code>dangerous</code> value of
* {@link android.R.attr#protectionLevel}.
*/
public static final int PROTECTION_DANGEROUS = 1;
/**
* Dangerous value for {@link #protectionLevel}, corresponding
* to the <code>dangerous</code> value of
* {@link android.R.attr#protectionLevel}.
*/
public static final int PROTECTION_DANGEROUS = 1;
/**
* System-level value for {@link #protectionLevel}, corresponding
* to the <code>signature</code> value of
* {@link android.R.attr#protectionLevel}.
*/
public static final int PROTECTION_SIGNATURE = 2;
/**
* System-level value for {@link #protectionLevel}, corresponding
* to the <code>signature</code> value of
* {@link android.R.attr#protectionLevel}.
*/
public static final int PROTECTION_SIGNATURE = 2;
/**
* System-level value for {@link #protectionLevel}, corresponding
* to the <code>signatureOrSystem</code> value of
* {@link android.R.attr#protectionLevel}.
*/
public static final int PROTECTION_SIGNATURE_OR_SYSTEM = 3;
/**
* System-level value for {@link #protectionLevel}, corresponding
* to the <code>signatureOrSystem</code> value of
* {@link android.R.attr#protectionLevel}.
*/
public static final int PROTECTION_SIGNATURE_OR_SYSTEM = 3;
/**
* Additional flag for {@link #protectionLevel}, corresponding
* to the <code>system</code> value of
* {@link android.R.attr#protectionLevel}.
*/
public static final int PROTECTION_FLAG_SYSTEM = 0x10;
/**
* Additional flag for {@link #protectionLevel}, corresponding
* to the <code>system</code> value of
* {@link android.R.attr#protectionLevel}.
*/
public static final int PROTECTION_FLAG_SYSTEM = 0x10;
/**
* Additional flag for {@link #protectionLevel}, corresponding
* to the <code>development</code> value of
* {@link android.R.attr#protectionLevel}.
*/
public static final int PROTECTION_FLAG_DEVELOPMENT = 0x20;
/**
* Additional flag for {@link #protectionLevel}, corresponding
* to the <code>development</code> value of
* {@link android.R.attr#protectionLevel}.
*/
public static final int PROTECTION_FLAG_DEVELOPMENT = 0x20;
/**
* Mask for {@link #protectionLevel}: the basic protection type.
*/
public static final int PROTECTION_MASK_BASE = 0xf;
/**
* Mask for {@link #protectionLevel}: the basic protection type.
*/
public static final int PROTECTION_MASK_BASE = 0xf;
/**
* Mask for {@link #protectionLevel}: additional flag bits.
*/
public static final int PROTECTION_MASK_FLAGS = 0xf0;
/**
* Mask for {@link #protectionLevel}: additional flag bits.
*/
public static final int PROTECTION_MASK_FLAGS = 0xf0;
/**
* The level of access this permission is protecting, as per
* {@link android.R.attr#protectionLevel}. Values may be
* {@link #PROTECTION_NORMAL}, {@link #PROTECTION_DANGEROUS}, or
* {@link #PROTECTION_SIGNATURE}. May also include the additional
* flags {@link #PROTECTION_FLAG_SYSTEM} or {@link #PROTECTION_FLAG_DEVELOPMENT}
* (which only make sense in combination with the base
* {@link #PROTECTION_SIGNATURE}.
*/
public int protectionLevel;
/**
* The level of access this permission is protecting, as per
* {@link android.R.attr#protectionLevel}. Values may be
* {@link #PROTECTION_NORMAL}, {@link #PROTECTION_DANGEROUS}, or
* {@link #PROTECTION_SIGNATURE}. May also include the additional
* flags {@link #PROTECTION_FLAG_SYSTEM} or {@link #PROTECTION_FLAG_DEVELOPMENT}
* (which only make sense in combination with the base
* {@link #PROTECTION_SIGNATURE}.
*/
public int protectionLevel;
/**
* The group this permission is a part of, as per
* {@link android.R.attr#permissionGroup}.
*/
public String group;
/**
* The group this permission is a part of, as per
* {@link android.R.attr#permissionGroup}.
*/
public String group;
/**
* Flag for {@link #flags}, corresponding to <code>costsMoney</code>
* value of {@link android.R.attr#permissionFlags}.
*/
public static final int FLAG_COSTS_MONEY = 1<<0;
/**
* Flag for {@link #flags}, corresponding to <code>costsMoney</code>
* value of {@link android.R.attr#permissionFlags}.
*/
public static final int FLAG_COSTS_MONEY = 1 << 0;
/**
* Additional flags about this permission as given by
* {@link android.R.attr#permissionFlags}.
*/
public int flags;
/**
* Additional flags about this permission as given by
* {@link android.R.attr#permissionFlags}.
*/
public int flags;
/**
* A string resource identifier (in the package's resources) of this
* permission's description. From the "description" attribute or,
* if not set, 0.
*/
public int descriptionRes;
/**
* A string resource identifier (in the package's resources) of this
* permission's description. From the "description" attribute or,
* if not set, 0.
*/
public int descriptionRes;
/**
* The description string provided in the AndroidManifest file, if any. You
* probably don't want to use this, since it will be null if the description
* is in a resource. You probably want
* {@link PermissionInfo#loadDescription} instead.
*/
public CharSequence nonLocalizedDescription;
/**
* The description string provided in the AndroidManifest file, if any. You
* probably don't want to use this, since it will be null if the description
* is in a resource. You probably want
* {@link PermissionInfo#loadDescription} instead.
*/
public CharSequence nonLocalizedDescription;
/** @hide */
public static int fixProtectionLevel(int level) {
if (level == PROTECTION_SIGNATURE_OR_SYSTEM) {
level = PROTECTION_SIGNATURE | PROTECTION_FLAG_SYSTEM;
}
return level;
}
/**
* @hide
*/
public static int fixProtectionLevel(int level) {
if (level == PROTECTION_SIGNATURE_OR_SYSTEM) {
level = PROTECTION_SIGNATURE | PROTECTION_FLAG_SYSTEM;
}
return level;
}
/** @hide */
public static String protectionToString(int level) {
String protLevel = "????";
switch (level&PROTECTION_MASK_BASE) {
case PermissionInfo.PROTECTION_DANGEROUS:
protLevel = "dangerous";
break;
case PermissionInfo.PROTECTION_NORMAL:
protLevel = "normal";
break;
case PermissionInfo.PROTECTION_SIGNATURE:
protLevel = "signature";
break;
case PermissionInfo.PROTECTION_SIGNATURE_OR_SYSTEM:
protLevel = "signatureOrSystem";
break;
}
if ((level&PermissionInfo.PROTECTION_FLAG_SYSTEM) != 0) {
protLevel += "|system";
}
if ((level&PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 0) {
protLevel += "|development";
}
return protLevel;
}
/**
* @hide
*/
public static String protectionToString(int level) {
String protLevel = "????";
switch (level & PROTECTION_MASK_BASE) {
case PermissionInfo.PROTECTION_DANGEROUS:
protLevel = "dangerous";
break;
case PermissionInfo.PROTECTION_NORMAL:
protLevel = "normal";
break;
case PermissionInfo.PROTECTION_SIGNATURE:
protLevel = "signature";
break;
case PermissionInfo.PROTECTION_SIGNATURE_OR_SYSTEM:
protLevel = "signatureOrSystem";
break;
}
if ((level & PermissionInfo.PROTECTION_FLAG_SYSTEM) != 0) {
protLevel += "|system";
}
if ((level & PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 0) {
protLevel += "|development";
}
return protLevel;
}
public PermissionInfo() {
}
public PermissionInfo() {
}
public PermissionInfo(PermissionInfo orig) {
super(orig);
protectionLevel = orig.protectionLevel;
flags = orig.flags;
group = orig.group;
descriptionRes = orig.descriptionRes;
nonLocalizedDescription = orig.nonLocalizedDescription;
}
public PermissionInfo(PermissionInfo orig) {
super(orig);
protectionLevel = orig.protectionLevel;
flags = orig.flags;
group = orig.group;
descriptionRes = orig.descriptionRes;
nonLocalizedDescription = orig.nonLocalizedDescription;
}
/**
* Retrieve the textual description of this permission. This
* will call back on the given PackageManager to load the description from
* the application.
*
* @param pm A PackageManager from which the label can be loaded; usually
* the PackageManager from which you originally retrieved this item.
*
* @return Returns a CharSequence containing the permission's description.
* If there is no description, null is returned.
*/
public CharSequence loadDescription(PackageManager pm) {
if (nonLocalizedDescription != null) {
return nonLocalizedDescription;
}
if (descriptionRes != 0) {
CharSequence label = pm.getText(packageName, descriptionRes, null);
if (label != null) {
return label;
}
}
return null;
}
/**
* Retrieve the textual description of this permission. This
* will call back on the given PackageManager to load the description from
* the application.
*
* @param pm A PackageManager from which the label can be loaded; usually
* the PackageManager from which you originally retrieved this item.
*
* @return Returns a CharSequence containing the permission's description.
* If there is no description, null is returned.
*/
public CharSequence loadDescription(PackageManager pm) {
if (nonLocalizedDescription != null) {
return nonLocalizedDescription;
}
if (descriptionRes != 0) {
CharSequence label = pm.getText(packageName, descriptionRes, null);
if (label != null) {
return label;
}
}
return null;
}
public String toString() {
return "PermissionInfo{"
+ Integer.toHexString(System.identityHashCode(this))
+ " " + name + "}";
}
public String toString() {
return "PermissionInfo{" + Integer.toHexString(System.identityHashCode(this)) + " " + name + "}";
}
public int describeContents() {
return 0;
}
public int describeContents() {
return 0;
}
}

View File

@@ -26,102 +26,113 @@ import android.util.Printer;
* PackageManager.resolveContentProvider()}.
*/
public final class ProviderInfo extends ComponentInfo {
/** The name provider is published under content:// */
public String authority = null;
/** Optional permission required for read-only access this content
* provider. */
public String readPermission = null;
/** Optional permission required for read/write access this content
* provider. */
public String writePermission = null;
/** If true, additional permissions to specific Uris in this content
* provider can be granted, as per the
* {@link android.R.styleable#AndroidManifestProvider_grantUriPermissions
* grantUriPermissions} attribute.
*/
public boolean grantUriPermissions = false;
/**
* If non-null, these are the patterns that are allowed for granting URI
* permissions. Any URI that does not match one of these patterns will not
* allowed to be granted. If null, all URIs are allowed. The
* {@link PackageManager#GET_URI_PERMISSION_PATTERNS
* PackageManager.GET_URI_PERMISSION_PATTERNS} flag must be specified for
* this field to be filled in.
*/
public PatternMatcher[] uriPermissionPatterns = null;
/**
* If non-null, these are path-specific permissions that are allowed for
* accessing the provider. Any permissions listed here will allow a
* holding client to access the provider, and the provider will check
* the URI it provides when making calls against the patterns here.
*/
public PathPermission[] pathPermissions = null;
/** If true, this content provider allows multiple instances of itself
* to run in different process. If false, a single instances is always
* run in {@link #processName}. */
public boolean multiprocess = false;
/** Used to control initialization order of single-process providers
* running in the same process. Higher goes first. */
public int initOrder = 0;
/**
* Bit in {@link #flags}: If set, a single instance of the provider will
* run for all users on the device. Set from the
* {@link android.R.attr#singleUser} attribute.
*/
public static final int FLAG_SINGLE_USER = 0x40000000;
/**
* The name provider is published under content://
*/
public String authority = null;
/**
* Options that have been set in the provider declaration in the
* manifest.
* These include: {@link #FLAG_SINGLE_USER}.
*/
public int flags = 0;
/**
* Optional permission required for read-only access this content
* provider.
*/
public String readPermission = null;
/**
* Whether or not this provider is syncable.
* @deprecated This flag is now being ignored. The current way to make a provider
* syncable is to provide a SyncAdapter service for a given provider/account type.
*/
@Deprecated
public boolean isSyncable = false;
/**
* Optional permission required for read/write access this content
* provider.
*/
public String writePermission = null;
public ProviderInfo() {
}
/**
* If true, additional permissions to specific Uris in this content
* provider can be granted, as per the
* {@link android.R.styleable#AndroidManifestProvider_grantUriPermissions
* grantUriPermissions} attribute.
*/
public boolean grantUriPermissions = false;
public ProviderInfo(ProviderInfo orig) {
super(orig);
authority = orig.authority;
readPermission = orig.readPermission;
writePermission = orig.writePermission;
grantUriPermissions = orig.grantUriPermissions;
uriPermissionPatterns = orig.uriPermissionPatterns;
pathPermissions = orig.pathPermissions;
multiprocess = orig.multiprocess;
initOrder = orig.initOrder;
flags = orig.flags;
isSyncable = orig.isSyncable;
}
/**
* If non-null, these are the patterns that are allowed for granting URI
* permissions. Any URI that does not match one of these patterns will not
* allowed to be granted. If null, all URIs are allowed. The
* {@link PackageManager#GET_URI_PERMISSION_PATTERNS
* PackageManager.GET_URI_PERMISSION_PATTERNS} flag must be specified for
* this field to be filled in.
*/
public PatternMatcher[] uriPermissionPatterns = null;
public void dump(Printer pw, String prefix) {
super.dumpFront(pw, prefix);
pw.println(prefix + "authority=" + authority);
pw.println(prefix + "flags=0x" + Integer.toHexString(flags));
}
/**
* If non-null, these are path-specific permissions that are allowed for
* accessing the provider. Any permissions listed here will allow a
* holding client to access the provider, and the provider will check
* the URI it provides when making calls against the patterns here.
*/
public PathPermission[] pathPermissions = null;
public int describeContents() {
return 0;
}
/**
* If true, this content provider allows multiple instances of itself
* to run in different process. If false, a single instances is always
* run in {@link #processName}.
*/
public boolean multiprocess = false;
public String toString() {
return "ContentProviderInfo{name=" + authority + " className=" + name + "}";
}
/**
* Used to control initialization order of single-process providers
* running in the same process. Higher goes first.
*/
public int initOrder = 0;
/**
* Bit in {@link #flags}: If set, a single instance of the provider will
* run for all users on the device. Set from the
* {@link android.R.attr#singleUser} attribute.
*/
public static final int FLAG_SINGLE_USER = 0x40000000;
/**
* Options that have been set in the provider declaration in the
* manifest.
* These include: {@link #FLAG_SINGLE_USER}.
*/
public int flags = 0;
/**
* Whether or not this provider is syncable.
* @deprecated This flag is now being ignored. The current way to make a provider
* syncable is to provide a SyncAdapter service for a given provider/account type.
*/
@Deprecated
public boolean isSyncable = false;
public ProviderInfo() {
}
public ProviderInfo(ProviderInfo orig) {
super(orig);
authority = orig.authority;
readPermission = orig.readPermission;
writePermission = orig.writePermission;
grantUriPermissions = orig.grantUriPermissions;
uriPermissionPatterns = orig.uriPermissionPatterns;
pathPermissions = orig.pathPermissions;
multiprocess = orig.multiprocess;
initOrder = orig.initOrder;
flags = orig.flags;
isSyncable = orig.isSyncable;
}
public void dump(Printer pw, String prefix) {
super.dumpFront(pw, prefix);
pw.println(prefix + "authority=" + authority);
pw.println(prefix + "flags=0x" + Integer.toHexString(flags));
}
public int describeContents() {
return 0;
}
public String toString() {
return "ContentProviderInfo{name=" + authority + " className=" + name + "}";
}
}

View File

@@ -1,5 +1,4 @@
package android.content.pm;
public class ResolveInfo {
}

View File

@@ -24,65 +24,63 @@ import android.util.Printer;
* AndroidManifest.xml's &lt;service&gt; tags.
*/
public class ServiceInfo extends ComponentInfo {
/**
* Optional name of a permission required to be able to access this
* Service. From the "permission" attribute.
*/
public String permission;
/**
* Optional name of a permission required to be able to access this
* Service. From the "permission" attribute.
*/
public String permission;
/**
* Bit in {@link #flags}: If set, the service will automatically be
* stopped by the system if the user removes a task that is rooted
* in one of the application's activities. Set from the
* {@link android.R.attr#stopWithTask} attribute.
*/
public static final int FLAG_STOP_WITH_TASK = 0x0001;
/**
* Bit in {@link #flags}: If set, the service will automatically be
* stopped by the system if the user removes a task that is rooted
* in one of the application's activities. Set from the
* {@link android.R.attr#stopWithTask} attribute.
*/
public static final int FLAG_STOP_WITH_TASK = 0x0001;
/**
* Bit in {@link #flags}: If set, the service will run in its own
* isolated process. Set from the
* {@link android.R.attr#isolatedProcess} attribute.
*/
public static final int FLAG_ISOLATED_PROCESS = 0x0002;
/**
* Bit in {@link #flags}: If set, the service will run in its own
* isolated process. Set from the
* {@link android.R.attr#isolatedProcess} attribute.
*/
public static final int FLAG_ISOLATED_PROCESS = 0x0002;
/**
* Bit in {@link #flags}: If set, a single instance of the service will
* run for all users on the device. Set from the
* {@link android.R.attr#singleUser} attribute.
*/
public static final int FLAG_SINGLE_USER = 0x40000000;
/**
* Bit in {@link #flags}: If set, a single instance of the service will
* run for all users on the device. Set from the
* {@link android.R.attr#singleUser} attribute.
*/
public static final int FLAG_SINGLE_USER = 0x40000000;
/**
* Options that have been set in the service declaration in the
* manifest.
* These include:
* {@link #FLAG_STOP_WITH_TASK}, {@link #FLAG_ISOLATED_PROCESS},
* {@link #FLAG_SINGLE_USER}.
*/
public int flags;
/**
* Options that have been set in the service declaration in the
* manifest.
* These include:
* {@link #FLAG_STOP_WITH_TASK}, {@link #FLAG_ISOLATED_PROCESS},
* {@link #FLAG_SINGLE_USER}.
*/
public int flags;
public ServiceInfo() {
}
public ServiceInfo() {
}
public ServiceInfo(ServiceInfo orig) {
super(orig);
permission = orig.permission;
flags = orig.flags;
}
public ServiceInfo(ServiceInfo orig) {
super(orig);
permission = orig.permission;
flags = orig.flags;
}
public void dump(Printer pw, String prefix) {
super.dumpFront(pw, prefix);
pw.println(prefix + "permission=" + permission);
pw.println(prefix + "flags=0x" + Integer.toHexString(flags));
}
public String toString() {
return "ServiceInfo{"
+ Integer.toHexString(System.identityHashCode(this))
+ " " + name + "}";
}
public void dump(Printer pw, String prefix) {
super.dumpFront(pw, prefix);
pw.println(prefix + "permission=" + permission);
pw.println(prefix + "flags=0x" + Integer.toHexString(flags));
}
public int describeContents() {
return 0;
}
public String toString() {
return "ServiceInfo{" + Integer.toHexString(System.identityHashCode(this)) + " " + name + "}";
}
public int describeContents() {
return 0;
}
}

View File

@@ -17,7 +17,6 @@
package android.content.pm;
import com.android.internal.util.ArrayUtils;
import java.io.ByteArrayInputStream;
import java.lang.ref.SoftReference;
import java.security.PublicKey;
@@ -31,160 +30,162 @@ import java.util.Arrays;
* application package.
*/
public class Signature {
private final byte[] mSignature;
private int mHashCode;
private boolean mHaveHashCode;
private SoftReference<String> mStringRef;
private final byte[] mSignature;
private int mHashCode;
private boolean mHaveHashCode;
private SoftReference<String> mStringRef;
/**
* Create Signature from an existing raw byte array.
*/
public Signature(byte[] signature) {
mSignature = signature.clone();
}
/**
* Create Signature from an existing raw byte array.
*/
public Signature(byte[] signature) {
mSignature = signature.clone();
}
private static final int parseHexDigit(int nibble) {
if ('0' <= nibble && nibble <= '9') {
return nibble - '0';
} else if ('a' <= nibble && nibble <= 'f') {
return nibble - 'a' + 10;
} else if ('A' <= nibble && nibble <= 'F') {
return nibble - 'A' + 10;
} else {
throw new IllegalArgumentException("Invalid character " + nibble + " in hex string");
}
}
private static final int parseHexDigit(int nibble) {
if ('0' <= nibble && nibble <= '9') {
return nibble - '0';
} else if ('a' <= nibble && nibble <= 'f') {
return nibble - 'a' + 10;
} else if ('A' <= nibble && nibble <= 'F') {
return nibble - 'A' + 10;
} else {
throw new IllegalArgumentException("Invalid character " + nibble + " in hex string");
}
}
/**
* Create Signature from a text representation previously returned by
* {@link #toChars} or {@link #toCharsString()}. Signatures are expected to
* be a hex-encoded ASCII string.
*
* @param text hex-encoded string representing the signature
* @throws IllegalArgumentException when signature is odd-length
*/
public Signature(String text) {
final byte[] input = text.getBytes();
final int N = input.length;
/**
* Create Signature from a text representation previously returned by
* {@link #toChars} or {@link #toCharsString()}. Signatures are expected to
* be a hex-encoded ASCII string.
*
* @param text hex-encoded string representing the signature
* @throws IllegalArgumentException when signature is odd-length
*/
public Signature(String text) {
final byte[] input = text.getBytes();
final int N = input.length;
if (N % 2 != 0) {
throw new IllegalArgumentException("text size " + N + " is not even");
}
if (N % 2 != 0) {
throw new IllegalArgumentException("text size " + N + " is not even");
}
final byte[] sig = new byte[N / 2];
int sigIndex = 0;
final byte[] sig = new byte[N / 2];
int sigIndex = 0;
for (int i = 0; i < N;) {
final int hi = parseHexDigit(input[i++]);
final int lo = parseHexDigit(input[i++]);
sig[sigIndex++] = (byte) ((hi << 4) | lo);
}
for (int i = 0; i < N;) {
final int hi = parseHexDigit(input[i++]);
final int lo = parseHexDigit(input[i++]);
sig[sigIndex++] = (byte)((hi << 4) | lo);
}
mSignature = sig;
}
mSignature = sig;
}
/**
* Encode the Signature as ASCII text.
*/
public char[] toChars() {
return toChars(null, null);
}
/**
* Encode the Signature as ASCII text.
*/
public char[] toChars() {
return toChars(null, null);
}
/**
* Encode the Signature as ASCII text in to an existing array.
*
* @param existingArray Existing char array or null.
* @param outLen Output parameter for the number of characters written in
* to the array.
* @return Returns either <var>existingArray</var> if it was large enough
* to hold the ASCII representation, or a newly created char[] array if
* needed.
*/
public char[] toChars(char[] existingArray, int[] outLen) {
byte[] sig = mSignature;
final int N = sig.length;
final int N2 = N*2;
char[] text = existingArray == null || N2 > existingArray.length
? new char[N2] : existingArray;
for (int j=0; j<N; j++) {
byte v = sig[j];
int d = (v>>4)&0xf;
text[j*2] = (char)(d >= 10 ? ('a' + d - 10) : ('0' + d));
d = v&0xf;
text[j*2+1] = (char)(d >= 10 ? ('a' + d - 10) : ('0' + d));
}
if (outLen != null) outLen[0] = N;
return text;
}
/**
* Encode the Signature as ASCII text in to an existing array.
*
* @param existingArray Existing char array or null.
* @param outLen Output parameter for the number of characters written in
* to the array.
* @return Returns either <var>existingArray</var> if it was large enough
* to hold the ASCII representation, or a newly created char[] array if
* needed.
*/
public char[] toChars(char[] existingArray, int[] outLen) {
byte[] sig = mSignature;
final int N = sig.length;
final int N2 = N * 2;
char[] text = existingArray == null || N2 > existingArray.length
? new char[N2]
: existingArray;
for (int j = 0; j < N; j++) {
byte v = sig[j];
int d = (v >> 4) & 0xf;
text[j * 2] = (char)(d >= 10 ? ('a' + d - 10) : ('0' + d));
d = v & 0xf;
text[j * 2 + 1] = (char)(d >= 10 ? ('a' + d - 10) : ('0' + d));
}
if (outLen != null)
outLen[0] = N;
return text;
}
/**
* Return the result of {@link #toChars()} as a String.
*/
public String toCharsString() {
String str = mStringRef == null ? null : mStringRef.get();
if (str != null) {
return str;
}
str = new String(toChars());
mStringRef = new SoftReference<String>(str);
return str;
}
/**
* Return the result of {@link #toChars()} as a String.
*/
public String toCharsString() {
String str = mStringRef == null ? null : mStringRef.get();
if (str != null) {
return str;
}
str = new String(toChars());
mStringRef = new SoftReference<String>(str);
return str;
}
/**
* @return the contents of this signature as a byte array.
*/
public byte[] toByteArray() {
byte[] bytes = new byte[mSignature.length];
System.arraycopy(mSignature, 0, bytes, 0, mSignature.length);
return bytes;
}
/**
* @return the contents of this signature as a byte array.
*/
public byte[] toByteArray() {
byte[] bytes = new byte[mSignature.length];
System.arraycopy(mSignature, 0, bytes, 0, mSignature.length);
return bytes;
}
/**
* Returns the public key for this signature.
*
* @throws CertificateException when Signature isn't a valid X.509
* certificate; shouldn't happen.
* @hide
*/
public PublicKey getPublicKey() throws CertificateException {
final CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
final ByteArrayInputStream bais = new ByteArrayInputStream(mSignature);
final Certificate cert = certFactory.generateCertificate(bais);
return cert.getPublicKey();
}
/**
* Returns the public key for this signature.
*
* @throws CertificateException when Signature isn't a valid X.509
* certificate; shouldn't happen.
* @hide
*/
public PublicKey getPublicKey() throws CertificateException {
final CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
final ByteArrayInputStream bais = new ByteArrayInputStream(mSignature);
final Certificate cert = certFactory.generateCertificate(bais);
return cert.getPublicKey();
}
@Override
public boolean equals(Object obj) {
try {
if (obj != null) {
Signature other = (Signature)obj;
return this == other || Arrays.equals(mSignature, other.mSignature);
}
} catch (ClassCastException e) {
}
return false;
}
@Override
public boolean equals(Object obj) {
try {
if (obj != null) {
Signature other = (Signature)obj;
return this == other || Arrays.equals(mSignature, other.mSignature);
}
} catch (ClassCastException e) {
}
return false;
}
@Override
public int hashCode() {
if (mHaveHashCode) {
return mHashCode;
}
mHashCode = Arrays.hashCode(mSignature);
mHaveHashCode = true;
return mHashCode;
}
@Override
public int hashCode() {
if (mHaveHashCode) {
return mHashCode;
}
mHashCode = Arrays.hashCode(mSignature);
mHaveHashCode = true;
return mHashCode;
}
public int describeContents() {
return 0;
}
public int describeContents() {
return 0;
}
/**
* Test if given {@link Signature} sets are exactly equal.
*
* @hide
*/
public static boolean areExactMatch(Signature[] a, Signature[] b) {
return ArrayUtils.containsAll(a, b) && ArrayUtils.containsAll(b, a);
}
/**
* Test if given {@link Signature} sets are exactly equal.
*
* @hide
*/
public static boolean areExactMatch(Signature[] a, Signature[] b) {
return ArrayUtils.containsAll(a, b) && ArrayUtils.containsAll(b, a);
}
}

View File

@@ -25,33 +25,37 @@ import java.security.PublicKey;
* @hide
*/
public class VerifierInfo {
/** Package name of the verifier. */
public final String packageName;
/**
* Package name of the verifier.
*/
public final String packageName;
/** Signatures used to sign the package verifier's package. */
public final PublicKey publicKey;
/**
* Signatures used to sign the package verifier's package.
*/
public final PublicKey publicKey;
/**
* Creates an object that represents a verifier info object.
*
* @param packageName the package name in Java-style. Must not be {@code
* null} or empty.
* @param publicKey the public key for the signer encoded in Base64. Must
* not be {@code null} or empty.
* @throws IllegalArgumentException if either argument is null or empty.
*/
public VerifierInfo(String packageName, PublicKey publicKey) {
if (packageName == null || packageName.length() == 0) {
throw new IllegalArgumentException("packageName must not be null or empty");
} else if (publicKey == null) {
throw new IllegalArgumentException("publicKey must not be null");
}
/**
* Creates an object that represents a verifier info object.
*
* @param packageName the package name in Java-style. Must not be {@code
* null} or empty.
* @param publicKey the public key for the signer encoded in Base64. Must
* not be {@code null} or empty.
* @throws IllegalArgumentException if either argument is null or empty.
*/
public VerifierInfo(String packageName, PublicKey publicKey) {
if (packageName == null || packageName.length() == 0) {
throw new IllegalArgumentException("packageName must not be null or empty");
} else if (publicKey == null) {
throw new IllegalArgumentException("publicKey must not be null");
}
this.packageName = packageName;
this.publicKey = publicKey;
}
this.packageName = packageName;
this.publicKey = publicKey;
}
public int describeContents() {
return 0;
}
public int describeContents() {
return 0;
}
}