You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
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:
@@ -1,5 +1,4 @@
|
||||
package android.content;
|
||||
|
||||
public class ActivityNotFoundException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
package android.content;
|
||||
|
||||
public class BroadcastReceiver {
|
||||
|
||||
}
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
*/
|
||||
package android.content;
|
||||
import android.content.Context;
|
||||
import android.os.Message;
|
||||
import android.os.RemoteException;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Message;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -49,78 +49,80 @@ class ClipDescription {}
|
||||
* @see android.content.Context#getSystemService
|
||||
*/
|
||||
public class ClipboardManager extends android.text.ClipboardManager {
|
||||
static final int MSG_REPORT_PRIMARY_CLIP_CHANGED = 1;
|
||||
/**
|
||||
* Defines a listener callback that is invoked when the primary clip on the clipboard changes.
|
||||
* Objects that want to register a listener call
|
||||
* {@link android.content.ClipboardManager#addPrimaryClipChangedListener(OnPrimaryClipChangedListener)
|
||||
* addPrimaryClipChangedListener()} with an
|
||||
* object that implements OnPrimaryClipChangedListener.
|
||||
*
|
||||
*/
|
||||
public interface OnPrimaryClipChangedListener {
|
||||
/**
|
||||
* Callback that is invoked by {@link android.content.ClipboardManager} when the primary
|
||||
* clip changes.
|
||||
*/
|
||||
void onPrimaryClipChanged();
|
||||
}
|
||||
/** {@hide} */
|
||||
public ClipboardManager(Context context, Handler handler) {
|
||||
}
|
||||
public ClipboardManager() {
|
||||
}
|
||||
/**
|
||||
* Sets the current primary clip on the clipboard. This is the clip that
|
||||
* is involved in normal cut and paste operations.
|
||||
*
|
||||
* @param clip The clipped data item to set.
|
||||
*/
|
||||
public void setPrimaryClip(ClipData clip) {
|
||||
}
|
||||
/**
|
||||
* Returns the current primary clip on the clipboard.
|
||||
*/
|
||||
public ClipData getPrimaryClip() {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Returns a description of the current primary clip on the clipboard
|
||||
* but not a copy of its data.
|
||||
*/
|
||||
public ClipDescription getPrimaryClipDescription() {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Returns true if there is currently a primary clip on the clipboard.
|
||||
*/
|
||||
public boolean hasPrimaryClip() {
|
||||
return false;
|
||||
}
|
||||
public void addPrimaryClipChangedListener(OnPrimaryClipChangedListener what) {
|
||||
}
|
||||
public void removePrimaryClipChangedListener(OnPrimaryClipChangedListener what) {
|
||||
}
|
||||
/**
|
||||
* @deprecated Use {@link #getPrimaryClip()} instead. This retrieves
|
||||
* the primary clip and tries to coerce it to a string.
|
||||
*/
|
||||
public CharSequence getText() {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* @deprecated Use {@link #setPrimaryClip(ClipData)} instead. This
|
||||
* creates a ClippedItem holding the given text and sets it as the
|
||||
* primary clip. It has no label or icon.
|
||||
*/
|
||||
public void setText(CharSequence text) {
|
||||
}
|
||||
/**
|
||||
* @deprecated Use {@link #hasPrimaryClip()} instead.
|
||||
*/
|
||||
public boolean hasText() {
|
||||
return false;
|
||||
}
|
||||
void reportPrimaryClipChanged() {
|
||||
}
|
||||
static final int MSG_REPORT_PRIMARY_CLIP_CHANGED = 1;
|
||||
/**
|
||||
* Defines a listener callback that is invoked when the primary clip on the clipboard changes.
|
||||
* Objects that want to register a listener call
|
||||
* {@link android.content.ClipboardManager#addPrimaryClipChangedListener(OnPrimaryClipChangedListener)
|
||||
* addPrimaryClipChangedListener()} with an
|
||||
* object that implements OnPrimaryClipChangedListener.
|
||||
*
|
||||
*/
|
||||
public interface OnPrimaryClipChangedListener {
|
||||
/**
|
||||
* Callback that is invoked by {@link android.content.ClipboardManager} when the primary
|
||||
* clip changes.
|
||||
*/
|
||||
void onPrimaryClipChanged();
|
||||
}
|
||||
/**
|
||||
* {@hide}
|
||||
*/
|
||||
public ClipboardManager(Context context, Handler handler) {
|
||||
}
|
||||
public ClipboardManager() {
|
||||
}
|
||||
/**
|
||||
* Sets the current primary clip on the clipboard. This is the clip that
|
||||
* is involved in normal cut and paste operations.
|
||||
*
|
||||
* @param clip The clipped data item to set.
|
||||
*/
|
||||
public void setPrimaryClip(ClipData clip) {
|
||||
}
|
||||
/**
|
||||
* Returns the current primary clip on the clipboard.
|
||||
*/
|
||||
public ClipData getPrimaryClip() {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Returns a description of the current primary clip on the clipboard
|
||||
* but not a copy of its data.
|
||||
*/
|
||||
public ClipDescription getPrimaryClipDescription() {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Returns true if there is currently a primary clip on the clipboard.
|
||||
*/
|
||||
public boolean hasPrimaryClip() {
|
||||
return false;
|
||||
}
|
||||
public void addPrimaryClipChangedListener(OnPrimaryClipChangedListener what) {
|
||||
}
|
||||
public void removePrimaryClipChangedListener(OnPrimaryClipChangedListener what) {
|
||||
}
|
||||
/**
|
||||
* @deprecated Use {@link #getPrimaryClip()} instead. This retrieves
|
||||
* the primary clip and tries to coerce it to a string.
|
||||
*/
|
||||
public CharSequence getText() {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* @deprecated Use {@link #setPrimaryClip(ClipData)} instead. This
|
||||
* creates a ClippedItem holding the given text and sets it as the
|
||||
* primary clip. It has no label or icon.
|
||||
*/
|
||||
public void setText(CharSequence text) {
|
||||
}
|
||||
/**
|
||||
* @deprecated Use {@link #hasPrimaryClip()} instead.
|
||||
*/
|
||||
public boolean hasText() {
|
||||
return false;
|
||||
}
|
||||
void reportPrimaryClipChanged() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,236 +27,244 @@ import java.lang.Comparable;
|
||||
* pieces of information, encapsulated here, are required to identify
|
||||
* a component: the package (a String) it exists in, and the class (a String)
|
||||
* name inside of that package.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public final class ComponentName implements Cloneable, Comparable<ComponentName> {
|
||||
private final String mPackage;
|
||||
private final String mClass;
|
||||
private final String mPackage;
|
||||
private final String mClass;
|
||||
|
||||
/**
|
||||
* Create a new component identifier.
|
||||
*
|
||||
* @param pkg The name of the package that the component exists in. Can
|
||||
* not be null.
|
||||
* @param cls The name of the class inside of <var>pkg</var> that
|
||||
* implements the component. Can not be null.
|
||||
*/
|
||||
public ComponentName(String pkg, String cls) {
|
||||
if (pkg == null) throw new NullPointerException("package name is null");
|
||||
if (cls == null) throw new NullPointerException("class name is null");
|
||||
mPackage = pkg;
|
||||
mClass = cls;
|
||||
}
|
||||
/**
|
||||
* Create a new component identifier.
|
||||
*
|
||||
* @param pkg The name of the package that the component exists in. Can
|
||||
* not be null.
|
||||
* @param cls The name of the class inside of <var>pkg</var> that
|
||||
* implements the component. Can not be null.
|
||||
*/
|
||||
public ComponentName(String pkg, String cls) {
|
||||
if (pkg == null)
|
||||
throw new NullPointerException("package name is null");
|
||||
if (cls == null)
|
||||
throw new NullPointerException("class name is null");
|
||||
mPackage = pkg;
|
||||
mClass = cls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new component identifier from a Context and class name.
|
||||
*
|
||||
* @param pkg A Context for the package implementing the component,
|
||||
* from which the actual package name will be retrieved.
|
||||
* @param cls The name of the class inside of <var>pkg</var> that
|
||||
* implements the component.
|
||||
*/
|
||||
public ComponentName(Context pkg, String cls) {
|
||||
if (cls == null) throw new NullPointerException("class name is null");
|
||||
mPackage = pkg.getPackageName();
|
||||
mClass = cls;
|
||||
}
|
||||
/**
|
||||
* Create a new component identifier from a Context and class name.
|
||||
*
|
||||
* @param pkg A Context for the package implementing the component,
|
||||
* from which the actual package name will be retrieved.
|
||||
* @param cls The name of the class inside of <var>pkg</var> that
|
||||
* implements the component.
|
||||
*/
|
||||
public ComponentName(Context pkg, String cls) {
|
||||
if (cls == null)
|
||||
throw new NullPointerException("class name is null");
|
||||
mPackage = pkg.getPackageName();
|
||||
mClass = cls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new component identifier from a Context and Class object.
|
||||
*
|
||||
* @param pkg A Context for the package implementing the component, from
|
||||
* which the actual package name will be retrieved.
|
||||
* @param cls The Class object of the desired component, from which the
|
||||
* actual class name will be retrieved.
|
||||
*/
|
||||
public ComponentName(Context pkg, Class<?> cls) {
|
||||
mPackage = pkg.getPackageName();
|
||||
mClass = cls.getName();
|
||||
}
|
||||
/**
|
||||
* Create a new component identifier from a Context and Class object.
|
||||
*
|
||||
* @param pkg A Context for the package implementing the component, from
|
||||
* which the actual package name will be retrieved.
|
||||
* @param cls The Class object of the desired component, from which the
|
||||
* actual class name will be retrieved.
|
||||
*/
|
||||
public ComponentName(Context pkg, Class<?> cls) {
|
||||
mPackage = pkg.getPackageName();
|
||||
mClass = cls.getName();
|
||||
}
|
||||
|
||||
public ComponentName clone() {
|
||||
return new ComponentName(mPackage, mClass);
|
||||
}
|
||||
public ComponentName clone() {
|
||||
return new ComponentName(mPackage, mClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the package name of this component.
|
||||
*/
|
||||
public String getPackageName() {
|
||||
return mPackage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class name of this component.
|
||||
*/
|
||||
public String getClassName() {
|
||||
return mClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class name, either fully qualified or in a shortened form
|
||||
* (with a leading '.') if it is a suffix of the package.
|
||||
*/
|
||||
public String getShortClassName() {
|
||||
if (mClass.startsWith(mPackage)) {
|
||||
int PN = mPackage.length();
|
||||
int CN = mClass.length();
|
||||
if (CN > PN && mClass.charAt(PN) == '.') {
|
||||
return mClass.substring(PN, CN);
|
||||
}
|
||||
}
|
||||
return mClass;
|
||||
}
|
||||
|
||||
private static void appendShortClassName(StringBuilder sb, String packageName,
|
||||
String className) {
|
||||
if (className.startsWith(packageName)) {
|
||||
int PN = packageName.length();
|
||||
int CN = className.length();
|
||||
if (CN > PN && className.charAt(PN) == '.') {
|
||||
sb.append(className, PN, CN);
|
||||
return;
|
||||
}
|
||||
}
|
||||
sb.append(className);
|
||||
}
|
||||
/**
|
||||
* Return the package name of this component.
|
||||
*/
|
||||
public String getPackageName() {
|
||||
return mPackage;
|
||||
}
|
||||
|
||||
private static void printShortClassName(PrintWriter pw, String packageName,
|
||||
String className) {
|
||||
if (className.startsWith(packageName)) {
|
||||
int PN = packageName.length();
|
||||
int CN = className.length();
|
||||
if (CN > PN && className.charAt(PN) == '.') {
|
||||
pw.write(className, PN, CN-PN);
|
||||
return;
|
||||
}
|
||||
}
|
||||
pw.print(className);
|
||||
}
|
||||
/**
|
||||
* Return the class name of this component.
|
||||
*/
|
||||
public String getClassName() {
|
||||
return mClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a String that unambiguously describes both the package and
|
||||
* class names contained in the ComponentName. You can later recover
|
||||
* the ComponentName from this string through
|
||||
* {@link #unflattenFromString(String)}.
|
||||
*
|
||||
* @return Returns a new String holding the package and class names. This
|
||||
* is represented as the package name, concatenated with a '/' and then the
|
||||
* class name.
|
||||
*
|
||||
* @see #unflattenFromString(String)
|
||||
*/
|
||||
public String flattenToString() {
|
||||
return mPackage + "/" + mClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* The same as {@link #flattenToString()}, but abbreviates the class
|
||||
* name if it is a suffix of the package. The result can still be used
|
||||
* with {@link #unflattenFromString(String)}.
|
||||
*
|
||||
* @return Returns a new String holding the package and class names. This
|
||||
* is represented as the package name, concatenated with a '/' and then the
|
||||
* class name.
|
||||
*
|
||||
* @see #unflattenFromString(String)
|
||||
*/
|
||||
public String flattenToShortString() {
|
||||
StringBuilder sb = new StringBuilder(mPackage.length() + mClass.length());
|
||||
appendShortString(sb, mPackage, mClass);
|
||||
return sb.toString();
|
||||
}
|
||||
/**
|
||||
* Return the class name, either fully qualified or in a shortened form
|
||||
* (with a leading '.') if it is a suffix of the package.
|
||||
*/
|
||||
public String getShortClassName() {
|
||||
if (mClass.startsWith(mPackage)) {
|
||||
int PN = mPackage.length();
|
||||
int CN = mClass.length();
|
||||
if (CN > PN && mClass.charAt(PN) == '.') {
|
||||
return mClass.substring(PN, CN);
|
||||
}
|
||||
}
|
||||
return mClass;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public void appendShortString(StringBuilder sb) {
|
||||
appendShortString(sb, mPackage, mClass);
|
||||
}
|
||||
private static void appendShortClassName(StringBuilder sb, String packageName,
|
||||
String className) {
|
||||
if (className.startsWith(packageName)) {
|
||||
int PN = packageName.length();
|
||||
int CN = className.length();
|
||||
if (CN > PN && className.charAt(PN) == '.') {
|
||||
sb.append(className, PN, CN);
|
||||
return;
|
||||
}
|
||||
}
|
||||
sb.append(className);
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public static void appendShortString(StringBuilder sb, String packageName, String className) {
|
||||
sb.append(packageName).append('/');
|
||||
appendShortClassName(sb, packageName, className);
|
||||
}
|
||||
private static void printShortClassName(PrintWriter pw, String packageName,
|
||||
String className) {
|
||||
if (className.startsWith(packageName)) {
|
||||
int PN = packageName.length();
|
||||
int CN = className.length();
|
||||
if (CN > PN && className.charAt(PN) == '.') {
|
||||
pw.write(className, PN, CN - PN);
|
||||
return;
|
||||
}
|
||||
}
|
||||
pw.print(className);
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public static void printShortString(PrintWriter pw, String packageName, String className) {
|
||||
pw.print(packageName);
|
||||
pw.print('/');
|
||||
printShortClassName(pw, packageName, className);
|
||||
}
|
||||
/**
|
||||
* Return a String that unambiguously describes both the package and
|
||||
* class names contained in the ComponentName. You can later recover
|
||||
* the ComponentName from this string through
|
||||
* {@link #unflattenFromString(String)}.
|
||||
*
|
||||
* @return Returns a new String holding the package and class names. This
|
||||
* is represented as the package name, concatenated with a '/' and then the
|
||||
* class name.
|
||||
*
|
||||
* @see #unflattenFromString(String)
|
||||
*/
|
||||
public String flattenToString() {
|
||||
return mPackage + "/" + mClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recover a ComponentName from a String that was previously created with
|
||||
* {@link #flattenToString()}. It splits the string at the first '/',
|
||||
* taking the part before as the package name and the part after as the
|
||||
* class name. As a special convenience (to use, for example, when
|
||||
* parsing component names on the command line), if the '/' is immediately
|
||||
* followed by a '.' then the final class name will be the concatenation
|
||||
* of the package name with the string following the '/'. Thus
|
||||
* "com.foo/.Blah" becomes package="com.foo" class="com.foo.Blah".
|
||||
*
|
||||
* @param str The String that was returned by flattenToString().
|
||||
* @return Returns a new ComponentName containing the package and class
|
||||
* names that were encoded in <var>str</var>
|
||||
*
|
||||
* @see #flattenToString()
|
||||
*/
|
||||
public static ComponentName unflattenFromString(String str) {
|
||||
int sep = str.indexOf('/');
|
||||
if (sep < 0 || (sep+1) >= str.length()) {
|
||||
return null;
|
||||
}
|
||||
String pkg = str.substring(0, sep);
|
||||
String cls = str.substring(sep+1);
|
||||
if (cls.length() > 0 && cls.charAt(0) == '.') {
|
||||
cls = pkg + cls;
|
||||
}
|
||||
return new ComponentName(pkg, cls);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return string representation of this class without the class's name
|
||||
* as a prefix.
|
||||
*/
|
||||
public String toShortString() {
|
||||
return "{" + mPackage + "/" + mClass + "}";
|
||||
}
|
||||
/**
|
||||
* The same as {@link #flattenToString()}, but abbreviates the class
|
||||
* name if it is a suffix of the package. The result can still be used
|
||||
* with {@link #unflattenFromString(String)}.
|
||||
*
|
||||
* @return Returns a new String holding the package and class names. This
|
||||
* is represented as the package name, concatenated with a '/' and then the
|
||||
* class name.
|
||||
*
|
||||
* @see #unflattenFromString(String)
|
||||
*/
|
||||
public String flattenToShortString() {
|
||||
StringBuilder sb = new StringBuilder(mPackage.length() + mClass.length());
|
||||
appendShortString(sb, mPackage, mClass);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ComponentInfo{" + mPackage + "/" + mClass + "}";
|
||||
}
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public void appendShortString(StringBuilder sb) {
|
||||
appendShortString(sb, mPackage, mClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
try {
|
||||
if (obj != null) {
|
||||
ComponentName other = (ComponentName)obj;
|
||||
// Note: no null checks, because mPackage and mClass can
|
||||
// never be null.
|
||||
return mPackage.equals(other.mPackage)
|
||||
&& mClass.equals(other.mClass);
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public static void appendShortString(StringBuilder sb, String packageName, String className) {
|
||||
sb.append(packageName).append('/');
|
||||
appendShortClassName(sb, packageName, className);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return mPackage.hashCode() + mClass.hashCode();
|
||||
}
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public static void printShortString(PrintWriter pw, String packageName, String className) {
|
||||
pw.print(packageName);
|
||||
pw.print('/');
|
||||
printShortClassName(pw, packageName, className);
|
||||
}
|
||||
|
||||
public int compareTo(ComponentName that) {
|
||||
int v;
|
||||
v = this.mPackage.compareTo(that.mPackage);
|
||||
if (v != 0) {
|
||||
return v;
|
||||
}
|
||||
return this.mClass.compareTo(that.mClass);
|
||||
}
|
||||
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* Recover a ComponentName from a String that was previously created with
|
||||
* {@link #flattenToString()}. It splits the string at the first '/',
|
||||
* taking the part before as the package name and the part after as the
|
||||
* class name. As a special convenience (to use, for example, when
|
||||
* parsing component names on the command line), if the '/' is immediately
|
||||
* followed by a '.' then the final class name will be the concatenation
|
||||
* of the package name with the string following the '/'. Thus
|
||||
* "com.foo/.Blah" becomes package="com.foo" class="com.foo.Blah".
|
||||
*
|
||||
* @param str The String that was returned by flattenToString().
|
||||
* @return Returns a new ComponentName containing the package and class
|
||||
* names that were encoded in <var>str</var>
|
||||
*
|
||||
* @see #flattenToString()
|
||||
*/
|
||||
public static ComponentName unflattenFromString(String str) {
|
||||
int sep = str.indexOf('/');
|
||||
if (sep < 0 || (sep + 1) >= str.length()) {
|
||||
return null;
|
||||
}
|
||||
String pkg = str.substring(0, sep);
|
||||
String cls = str.substring(sep + 1);
|
||||
if (cls.length() > 0 && cls.charAt(0) == '.') {
|
||||
cls = pkg + cls;
|
||||
}
|
||||
return new ComponentName(pkg, cls);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return string representation of this class without the class's name
|
||||
* as a prefix.
|
||||
*/
|
||||
public String toShortString() {
|
||||
return "{" + mPackage + "/" + mClass + "}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ComponentInfo{" + mPackage + "/" + mClass + "}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
try {
|
||||
if (obj != null) {
|
||||
ComponentName other = (ComponentName)obj;
|
||||
// Note: no null checks, because mPackage and mClass can
|
||||
// never be null.
|
||||
return mPackage.equals(other.mPackage) && mClass.equals(other.mClass);
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return mPackage.hashCode() + mClass.hashCode();
|
||||
}
|
||||
|
||||
public int compareTo(ComponentName that) {
|
||||
int v;
|
||||
v = this.mPackage.compareTo(that.mPackage);
|
||||
if (v != 0) {
|
||||
return v;
|
||||
}
|
||||
return this.mClass.compareTo(that.mClass);
|
||||
}
|
||||
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package android.content;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.database.ContentObserver;
|
||||
import android.net.Uri;
|
||||
|
||||
public class ContentResolver {
|
||||
public final void registerContentObserver(Uri uri, boolean notifyForDescendants, ContentObserver observer) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,40 +1,36 @@
|
||||
package android.content;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import android.content.pm.PackageManager;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.AlarmManager;
|
||||
import android.app.Application;
|
||||
import android.app.KeyguardManager;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.SharedPreferencesImpl;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.AssetManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.content.Intent;
|
||||
import android.content.BroadcastReceiver;
|
||||
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.content.SharedPreferences;
|
||||
import android.app.SharedPreferencesImpl;
|
||||
import android.hardware.SensorManager;
|
||||
import android.hardware.display.DisplayManager;
|
||||
import android.hardware.usb.UsbManager;
|
||||
import android.media.AudioManager;
|
||||
import android.media.MediaRouter;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.os.Looper;
|
||||
import android.os.PowerManager;
|
||||
import android.app.Application;
|
||||
|
||||
import android.os.Vibrator;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.WindowManager;
|
||||
import android.view.WindowManagerImpl;
|
||||
import android.content.ClipboardManager;
|
||||
import android.hardware.SensorManager;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.app.KeyguardManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.media.AudioManager;
|
||||
import android.app.ActivityManager;
|
||||
import android.hardware.usb.UsbManager;
|
||||
import android.os.Vibrator;
|
||||
import android.hardware.display.DisplayManager;
|
||||
import android.media.MediaRouter;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.AlarmManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
@@ -77,7 +73,7 @@ public class Context extends Object {
|
||||
System.out.println("new Context! this one is: " + this);
|
||||
}
|
||||
|
||||
public int checkPermission (String permission, int pid, int uid) {
|
||||
public int checkPermission(String permission, int pid, int uid) {
|
||||
return getPackageManager().checkPermission(permission, "dummy");
|
||||
}
|
||||
|
||||
@@ -85,7 +81,7 @@ public class Context extends Object {
|
||||
return r.newTheme();
|
||||
}
|
||||
|
||||
public ApplicationInfo getApplicationInfo () {
|
||||
public ApplicationInfo getApplicationInfo() {
|
||||
// TODO: do this somewhere saner?
|
||||
application_info.nativeLibraryDir = (new File(getDataDirFile(), "lib")).getAbsolutePath();
|
||||
return application_info;
|
||||
@@ -132,7 +128,7 @@ public class Context extends Object {
|
||||
case "alarm":
|
||||
return new AlarmManager();
|
||||
default:
|
||||
System.out.println("!!!!!!! getSystemService: case >"+name+"< is not implemented yet");
|
||||
System.out.println("!!!!!!! getSystemService: case >" + name + "< is not implemented yet");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -175,11 +171,11 @@ public class Context extends Object {
|
||||
return new File(base, name);
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
"File " + name + " contains a path separator");
|
||||
"File " + name + " contains a path separator");
|
||||
}
|
||||
|
||||
private File getDataDirFile() {
|
||||
if(data_dir == null) {
|
||||
if (data_dir == null) {
|
||||
data_dir = android.os.Environment.getExternalStorageDirectory();
|
||||
}
|
||||
return data_dir;
|
||||
@@ -190,7 +186,7 @@ public class Context extends Object {
|
||||
files_dir = new File(getDataDirFile(), "files");
|
||||
}
|
||||
if (!files_dir.exists()) {
|
||||
if(!files_dir.mkdirs()) {
|
||||
if (!files_dir.mkdirs()) {
|
||||
if (files_dir.exists()) {
|
||||
// spurious failure; probably racing with another process for this app
|
||||
return files_dir;
|
||||
@@ -207,29 +203,29 @@ public class Context extends Object {
|
||||
}
|
||||
|
||||
public File getObbDir() {
|
||||
if (obb_dir == null) {
|
||||
if (obb_dir == null) {
|
||||
obb_dir = new File(getDataDirFile(), "obb");
|
||||
}
|
||||
return obb_dir;
|
||||
}
|
||||
|
||||
public File[] getObbDirs() {
|
||||
return new File[]{getObbDir()};
|
||||
return new File[] {getObbDir()};
|
||||
}
|
||||
|
||||
// FIXME: should be something like /tmp/cache, but may need to create that directory
|
||||
public File getCacheDir() {
|
||||
if (cache_dir == null) {
|
||||
cache_dir = new File("/tmp/");
|
||||
}
|
||||
return cache_dir;
|
||||
if (cache_dir == null) {
|
||||
cache_dir = new File("/tmp/");
|
||||
}
|
||||
return cache_dir;
|
||||
}
|
||||
|
||||
private File getPreferencesDir() {
|
||||
if (prefs_dir == null) {
|
||||
prefs_dir = new File(getDataDirFile(), "shared_prefs");
|
||||
}
|
||||
return prefs_dir;
|
||||
if (prefs_dir == null) {
|
||||
prefs_dir = new File(getDataDirFile(), "shared_prefs");
|
||||
}
|
||||
return prefs_dir;
|
||||
}
|
||||
|
||||
public File getSharedPrefsFile(String name) {
|
||||
@@ -237,7 +233,7 @@ public class Context extends Object {
|
||||
}
|
||||
|
||||
public SharedPreferences getSharedPreferences(String name, int mode) {
|
||||
System.out.println("\n\n...> getSharedPreferences("+name+",)\n\n");
|
||||
System.out.println("\n\n...> getSharedPreferences(" + name + ",)\n\n");
|
||||
File prefsFile = getSharedPrefsFile(name);
|
||||
return new SharedPreferencesImpl(prefsFile, mode);
|
||||
}
|
||||
@@ -248,7 +244,7 @@ public class Context extends Object {
|
||||
}
|
||||
|
||||
public ComponentName startService(Intent service) {
|
||||
return new ComponentName("","");
|
||||
return new ComponentName("", "");
|
||||
}
|
||||
|
||||
// FIXME - it should be *trivial* to do actually implement this
|
||||
@@ -257,12 +253,12 @@ public class Context extends Object {
|
||||
}
|
||||
|
||||
public FileOutputStream openFileOutput(String name, int mode) throws java.io.FileNotFoundException {
|
||||
System.out.println("openFileOutput called for: '"+name+"'");
|
||||
System.out.println("openFileOutput called for: '" + name + "'");
|
||||
return new FileOutputStream(android.os.Environment.getExternalStorageDirectory().getPath() + "/files/" + name);
|
||||
}
|
||||
|
||||
public int checkCallingOrSelfPermission(String permission) {
|
||||
System.out.println("!!! app wants to know if it has a permission: >"+permission+"<");
|
||||
System.out.println("!!! app wants to know if it has a permission: >" + permission + "<");
|
||||
|
||||
return -1; // PackageManager.PERMISSION_DENIED
|
||||
}
|
||||
@@ -270,8 +266,8 @@ public class Context extends Object {
|
||||
public void registerComponentCallbacks(ComponentCallbacks callbacks) {}
|
||||
|
||||
// these may not look like typical stubs, but they definitely are stubs
|
||||
public final TypedArray obtainStyledAttributes (AttributeSet set, int[] attrs) { return new TypedArray(r, new int[1000], new int[1000], 0); }
|
||||
public final TypedArray obtainStyledAttributes (AttributeSet set, int[] attrs, int defStyleAttr, int defStyleRes) { return new TypedArray(r, new int[1000], new int[1000], 0); }
|
||||
public final TypedArray obtainStyledAttributes (int resid, int[] attrs) { return new TypedArray(r, new int[1000], new int[1000], 0); }
|
||||
public final TypedArray obtainStyledAttributes (int[] attrs) { return new TypedArray(r, new int[1000], new int[1000], 0); }
|
||||
public final TypedArray obtainStyledAttributes(AttributeSet set, int[] attrs) { return new TypedArray(r, new int[1000], new int[1000], 0); }
|
||||
public final TypedArray obtainStyledAttributes(AttributeSet set, int[] attrs, int defStyleAttr, int defStyleRes) { return new TypedArray(r, new int[1000], new int[1000], 0); }
|
||||
public final TypedArray obtainStyledAttributes(int resid, int[] attrs) { return new TypedArray(r, new int[1000], new int[1000], 0); }
|
||||
public final TypedArray obtainStyledAttributes(int[] attrs) { return new TypedArray(r, new int[1000], new int[1000], 0); }
|
||||
}
|
||||
|
||||
@@ -3,16 +3,15 @@ package android.content;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Intent {
|
||||
public Intent () {}
|
||||
public Intent (Intent o) {}
|
||||
public Intent (String action) {}
|
||||
public Intent (String action, Uri uri) {}
|
||||
public Intent (Context packageContext, Class<?> cls) {}
|
||||
public Intent (String action, Uri uri, Context packageContext, Class<?> cls) {}
|
||||
public Intent() {}
|
||||
public Intent(Intent o) {}
|
||||
public Intent(String action) {}
|
||||
public Intent(String action, Uri uri) {}
|
||||
public Intent(Context packageContext, Class<?> cls) {}
|
||||
public Intent(String action, Uri uri, Context packageContext, Class<?> cls) {}
|
||||
|
||||
public Intent setFlags(int flags) {
|
||||
return this; //??
|
||||
@@ -21,7 +20,7 @@ public class Intent {
|
||||
return this; //??
|
||||
}
|
||||
|
||||
public Intent putExtra (String name, Parcelable value) {
|
||||
public Intent putExtra(String name, Parcelable value) {
|
||||
return this; //??
|
||||
}
|
||||
|
||||
|
||||
@@ -21,34 +21,34 @@ package android.content;
|
||||
* constraints.
|
||||
*/
|
||||
public class OperationApplicationException extends Exception {
|
||||
private final int mNumSuccessfulYieldPoints;
|
||||
private final int mNumSuccessfulYieldPoints;
|
||||
|
||||
public OperationApplicationException() {
|
||||
super();
|
||||
mNumSuccessfulYieldPoints = 0;
|
||||
}
|
||||
public OperationApplicationException(String message) {
|
||||
super(message);
|
||||
mNumSuccessfulYieldPoints = 0;
|
||||
}
|
||||
public OperationApplicationException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
mNumSuccessfulYieldPoints = 0;
|
||||
}
|
||||
public OperationApplicationException(Throwable cause) {
|
||||
super(cause);
|
||||
mNumSuccessfulYieldPoints = 0;
|
||||
}
|
||||
public OperationApplicationException(int numSuccessfulYieldPoints) {
|
||||
super();
|
||||
mNumSuccessfulYieldPoints = numSuccessfulYieldPoints;
|
||||
}
|
||||
public OperationApplicationException(String message, int numSuccessfulYieldPoints) {
|
||||
super(message);
|
||||
mNumSuccessfulYieldPoints = numSuccessfulYieldPoints;
|
||||
}
|
||||
public OperationApplicationException() {
|
||||
super();
|
||||
mNumSuccessfulYieldPoints = 0;
|
||||
}
|
||||
public OperationApplicationException(String message) {
|
||||
super(message);
|
||||
mNumSuccessfulYieldPoints = 0;
|
||||
}
|
||||
public OperationApplicationException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
mNumSuccessfulYieldPoints = 0;
|
||||
}
|
||||
public OperationApplicationException(Throwable cause) {
|
||||
super(cause);
|
||||
mNumSuccessfulYieldPoints = 0;
|
||||
}
|
||||
public OperationApplicationException(int numSuccessfulYieldPoints) {
|
||||
super();
|
||||
mNumSuccessfulYieldPoints = numSuccessfulYieldPoints;
|
||||
}
|
||||
public OperationApplicationException(String message, int numSuccessfulYieldPoints) {
|
||||
super(message);
|
||||
mNumSuccessfulYieldPoints = numSuccessfulYieldPoints;
|
||||
}
|
||||
|
||||
public int getNumSuccessfulYieldPoints() {
|
||||
return mNumSuccessfulYieldPoints;
|
||||
}
|
||||
public int getNumSuccessfulYieldPoints() {
|
||||
return mNumSuccessfulYieldPoints;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
package android.content;
|
||||
|
||||
public interface ServiceConnection {
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
* <activity>, <receiver>, <service>, or
|
||||
* <provider> 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
|
||||
* <activity>, <receiver>, <service>, or
|
||||
* <provider> 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,95 +22,89 @@ package android.content.pm;
|
||||
* AndroidManifest.xml's <uses-configuration> and <uses-feature> 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,70 +22,65 @@ package android.content.pm;
|
||||
* AndroidManifest.xml's <uses-feature> 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,64 +22,64 @@ package android.content.pm;
|
||||
* from the AndroidManifest.xml's <instrumentation> 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 <manifest> tag's "name"
|
||||
* attribute.
|
||||
*/
|
||||
public String packageName = "com.example.app"; // FIXME
|
||||
/**
|
||||
* The name of this package. From the <manifest> tag's "name"
|
||||
* attribute.
|
||||
*/
|
||||
public String packageName = "com.example.app"; // FIXME
|
||||
|
||||
/**
|
||||
* The version number of this package, as specified by the <manifest>
|
||||
* 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 <manifest>
|
||||
* 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 <manifest>
|
||||
* 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 <manifest>
|
||||
* tag's {@link android.R.styleable#AndroidManifest_sharedUserLabel sharedUserLabel}
|
||||
* attribute.
|
||||
*/
|
||||
public int sharedUserLabel;
|
||||
|
||||
/**
|
||||
* Information collected from the <application> 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 <manifest>
|
||||
* 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 <manifest>
|
||||
* 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 <manifest>
|
||||
* tag's {@link android.R.styleable#AndroidManifest_sharedUserId sharedUserId}
|
||||
* attribute.
|
||||
*/
|
||||
public String sharedUserId;
|
||||
|
||||
/**
|
||||
* Array of all {@link android.R.styleable#AndroidManifestActivity
|
||||
* <activity>} tags included under <application>,
|
||||
* 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 <manifest>
|
||||
* tag's {@link android.R.styleable#AndroidManifest_sharedUserLabel sharedUserLabel}
|
||||
* attribute.
|
||||
*/
|
||||
public int sharedUserLabel;
|
||||
|
||||
/**
|
||||
* Array of all {@link android.R.styleable#AndroidManifestReceiver
|
||||
* <receiver>} tags included under <application>,
|
||||
* 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 <application> tag, or null if
|
||||
* there was none.
|
||||
*/
|
||||
public ApplicationInfo applicationInfo;
|
||||
|
||||
/**
|
||||
* Array of all {@link android.R.styleable#AndroidManifestService
|
||||
* <service>} tags included under <application>,
|
||||
* 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
|
||||
* <provider>} tags included under <application>,
|
||||
* 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
|
||||
* <instrumentation>} tags included under <manifest>,
|
||||
* 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
|
||||
* <permission>} tags included under <manifest>,
|
||||
* 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
|
||||
* <uses-permission>} tags included under <manifest>,
|
||||
* 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
|
||||
* <uses-permission>} tags included under <manifest>,
|
||||
* 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
|
||||
* <activity>} tags included under <application>,
|
||||
* 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
|
||||
* <receiver>} tags included under <application>,
|
||||
* 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
|
||||
* <uses-configuration>} tags included under <manifest>,
|
||||
* 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
|
||||
* <service>} tags included under <application>,
|
||||
* 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
|
||||
* <provider>} tags included under <application>,
|
||||
* 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
|
||||
* <instrumentation>} tags included under <manifest>,
|
||||
* 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
|
||||
* <permission>} tags included under <manifest>,
|
||||
* 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
|
||||
* <uses-permission>} tags included under <manifest>,
|
||||
* 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
|
||||
* <uses-permission>} tags included under <manifest>,
|
||||
* 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
|
||||
* <uses-configuration>} tags included under <manifest>,
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user