android support! thanks to TachiWeb devs.

This commit is contained in:
Aria Moradi
2021-01-02 04:57:20 +03:30
parent ced07d4e1e
commit 1e46a0c78c
291 changed files with 68699 additions and 16 deletions
@@ -0,0 +1,64 @@
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.content;
import android.content.res.Configuration;
/**
* The set of callback APIs that are common to all application components
* ({@link android.app.Activity}, {@link android.app.Service},
* {@link ContentProvider}, and {@link android.app.Application}).
*
* <p class="note"><strong>Note:</strong> You should also implement the {@link
* ComponentCallbacks2} interface, which provides the {@link
* ComponentCallbacks2#onTrimMemory} callback to help your app manage its memory usage more
* effectively.</p>
*/
public interface ComponentCallbacks {
/**
* Called by the system when the device configuration changes while your
* component is running. Note that, unlike activities, other components
* are never restarted when a configuration changes: they must always deal
* with the results of the change, such as by re-retrieving resources.
*
* <p>At the time that this function has been called, your Resources
* object will have been updated to return resource values matching the
* new configuration.
*
* <p>For more information, read <a href="{@docRoot}guide/topics/resources/runtime-changes.html"
* >Handling Runtime Changes</a>.
*
* @param newConfig The new device configuration.
*/
void onConfigurationChanged(Configuration newConfig);
/**
* This is called when the overall system is running low on memory, and
* actively running processes should trim their memory usage. While
* the exact point at which this will be called is not defined, generally
* it will happen when all background process have been killed.
* That is, before reaching the point of killing processes hosting
* service and foreground UI that we would like to avoid killing.
*
* <p>You should implement this method to release
* any caches or other unnecessary resources you may be holding on to.
* The system will perform a garbage collection for you after returning from this method.
* <p>Preferably, you should implement {@link ComponentCallbacks2#onTrimMemory} from
* {@link ComponentCallbacks2} to incrementally unload your resources based on various
* levels of memory demands. That API is available for API level 14 and higher, so you should
* only use this {@link #onLowMemory} method as a fallback for older versions, which can be
* treated the same as {@link ComponentCallbacks2#onTrimMemory} with the {@link
* ComponentCallbacks2#TRIM_MEMORY_COMPLETE} level.</p>
*/
void onLowMemory();
}
@@ -0,0 +1,168 @@
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.content;
import android.annotation.IntDef;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* Extended {@link ComponentCallbacks} interface with a new callback for
* finer-grained memory management. This interface is available in all application components
* ({@link android.app.Activity}, {@link android.app.Service},
* {@link ContentProvider}, and {@link android.app.Application}).
*
* <p>You should implement {@link #onTrimMemory} to incrementally release memory based on current
* system constraints. Using this callback to release your resources helps provide a more
* responsive system overall, but also directly benefits the user experience for
* your app by allowing the system to keep your process alive longer. That is,
* if you <em>don't</em> trim your resources based on memory levels defined by this callback,
* the system is more likely to kill your process while it is cached in the least-recently used
* (LRU) list, thus requiring your app to restart and restore all state when the user returns to it.
*
* <p>The values provided by {@link #onTrimMemory} do not represent a single linear progression of
* memory limits, but provide you different types of clues about memory availability:</p>
* <ul>
* <li>When your app is running:
* <ol>
* <li>{@link #TRIM_MEMORY_RUNNING_MODERATE} <br>The device is beginning to run low on memory.
* Your app is running and not killable.
* <li>{@link #TRIM_MEMORY_RUNNING_LOW} <br>The device is running much lower on memory.
* Your app is running and not killable, but please release unused resources to improve system
* performance (which directly impacts your app's performance).
* <li>{@link #TRIM_MEMORY_RUNNING_CRITICAL} <br>The device is running extremely low on memory.
* Your app is not yet considered a killable process, but the system will begin killing
* background processes if apps do not release resources, so you should release non-critical
* resources now to prevent performance degradation.
* </ol>
* </li>
* <li>When your app's visibility changes:
* <ol>
* <li>{@link #TRIM_MEMORY_UI_HIDDEN} <br>Your app's UI is no longer visible, so this is a good
* time to release large resources that are used only by your UI.
* </ol>
* </li>
* <li>When your app's process resides in the background LRU list:
* <ol>
* <li>{@link #TRIM_MEMORY_BACKGROUND} <br>The system is running low on memory and your process is
* near the beginning of the LRU list. Although your app process is not at a high risk of being
* killed, the system may already be killing processes in the LRU list, so you should release
* resources that are easy to recover so your process will remain in the list and resume
* quickly when the user returns to your app.
* <li>{@link #TRIM_MEMORY_MODERATE} <br>The system is running low on memory and your process is
* near the middle of the LRU list. If the system becomes further constrained for memory, there's a
* chance your process will be killed.
* <li>{@link #TRIM_MEMORY_COMPLETE} <br>The system is running low on memory and your process is
* one of the first to be killed if the system does not recover memory now. You should release
* absolutely everything that's not critical to resuming your app state.
* <p>To support API levels lower than 14, you can use the {@link #onLowMemory} method as a
* fallback that's roughly equivalent to the {@link ComponentCallbacks2#TRIM_MEMORY_COMPLETE} level.
* </li>
* </ol>
* <p class="note"><strong>Note:</strong> When the system begins
* killing processes in the LRU list, although it primarily works bottom-up, it does give some
* consideration to which processes are consuming more memory and will thus provide more gains in
* memory if killed. So the less memory you consume while in the LRU list overall, the better
* your chances are to remain in the list and be able to quickly resume.</p>
* </li>
* </ul>
* <p>More information about the different stages of a process lifecycle (such as what it means
* to be placed in the background LRU list) is provided in the <a
* href="{@docRoot}guide/components/processes-and-threads.html#Lifecycle">Processes and Threads</a>
* document.
*/
public interface ComponentCallbacks2 extends ComponentCallbacks {
/** @hide */
@IntDef(prefix = { "TRIM_MEMORY_" }, value = {
TRIM_MEMORY_COMPLETE,
TRIM_MEMORY_MODERATE,
TRIM_MEMORY_BACKGROUND,
TRIM_MEMORY_UI_HIDDEN,
TRIM_MEMORY_RUNNING_CRITICAL,
TRIM_MEMORY_RUNNING_LOW,
TRIM_MEMORY_RUNNING_MODERATE,
})
@Retention(RetentionPolicy.SOURCE)
public @interface TrimMemoryLevel {}
/**
* Level for {@link #onTrimMemory(int)}: the process is nearing the end
* of the background LRU list, and if more memory isn't found soon it will
* be killed.
*/
static final int TRIM_MEMORY_COMPLETE = 80;
/**
* Level for {@link #onTrimMemory(int)}: the process is around the middle
* of the background LRU list; freeing memory can help the system keep
* other processes running later in the list for better overall performance.
*/
static final int TRIM_MEMORY_MODERATE = 60;
/**
* Level for {@link #onTrimMemory(int)}: the process has gone on to the
* LRU list. This is a good opportunity to clean up resources that can
* efficiently and quickly be re-built if the user returns to the app.
*/
static final int TRIM_MEMORY_BACKGROUND = 40;
/**
* Level for {@link #onTrimMemory(int)}: the process had been showing
* a user interface, and is no longer doing so. Large allocations with
* the UI should be released at this point to allow memory to be better
* managed.
*/
static final int TRIM_MEMORY_UI_HIDDEN = 20;
/**
* Level for {@link #onTrimMemory(int)}: the process is not an expendable
* background process, but the device is running extremely low on memory
* and is about to not be able to keep any background processes running.
* Your running process should free up as many non-critical resources as it
* can to allow that memory to be used elsewhere. The next thing that
* will happen after this is {@link #onLowMemory()} called to report that
* nothing at all can be kept in the background, a situation that can start
* to notably impact the user.
*/
static final int TRIM_MEMORY_RUNNING_CRITICAL = 15;
/**
* Level for {@link #onTrimMemory(int)}: the process is not an expendable
* background process, but the device is running low on memory.
* Your running process should free up unneeded resources to allow that
* memory to be used elsewhere.
*/
static final int TRIM_MEMORY_RUNNING_LOW = 10;
/**
* Level for {@link #onTrimMemory(int)}: the process is not an expendable
* background process, but the device is running moderately low on memory.
* Your running process may want to release some unneeded resources for
* use elsewhere.
*/
static final int TRIM_MEMORY_RUNNING_MODERATE = 5;
/**
* Called when the operating system has determined that it is a good
* time for a process to trim unneeded memory from its process. This will
* happen for example when it goes in the background and there is not enough
* memory to keep as many background processes running as desired. You
* should never compare to exact values of the level, since new intermediate
* values may be added -- you will typically want to compare if the value
* is greater or equal to a level you are interested in.
*
* <p>To retrieve the processes current trim level at any point, you can
* use {@link android.app.ActivityManager#getMyMemoryState
* ActivityManager.getMyMemoryState(RunningAppProcessInfo)}.
*
* @param level The context of the trim, giving a hint of the amount of
* trimming the application may like to perform.
*/
void onTrimMemory(@TrimMemoryLevel int level);
}
@@ -0,0 +1,362 @@
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.content;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import java.io.PrintWriter;
import java.lang.Comparable;
/**
* Identifier for a specific application component
* ({@link android.app.Activity}, {@link android.app.Service},
* {@link android.content.BroadcastReceiver}, or
* {@link android.content.ContentProvider}) that is available. Two
* 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 Parcelable, Cloneable, Comparable<ComponentName> {
private final String mPackage;
private final String mClass;
/**
* Create a new component identifier where the class name may be specified
* as either absolute or relative to the containing package.
*
* <p>Relative package names begin with a <code>'.'</code> character. For a package
* <code>"com.example"</code> and class name <code>".app.MyActivity"</code> this method
* will return a ComponentName with the package <code>"com.example"</code>and class name
* <code>"com.example.app.MyActivity"</code>. Fully qualified class names are also
* permitted.</p>
*
* @param pkg the name of the package the component exists in
* @param cls the name of the class inside of <var>pkg</var> that implements
* the component
* @return the new ComponentName
*/
public static ComponentName createRelative(String pkg, String cls) {
if (TextUtils.isEmpty(cls)) {
throw new IllegalArgumentException("class name cannot be empty");
}
final String fullName;
if (cls.charAt(0) == '.') {
// Relative to the package. Prepend the package name.
fullName = pkg + cls;
} else {
// Fully qualified package name.
fullName = cls;
}
return new ComponentName(pkg, fullName);
}
/**
* Create a new component identifier where the class name may be specified
* as either absolute or relative to the containing package.
*
* <p>Relative package names begin with a <code>'.'</code> character. For a package
* <code>"com.example"</code> and class name <code>".app.MyActivity"</code> this method
* will return a ComponentName with the package <code>"com.example"</code>and class name
* <code>"com.example.app.MyActivity"</code>. Fully qualified class names are also
* permitted.</p>
*
* @param pkg a Context for the package implementing the component
* @param cls the name of the class inside of <var>pkg</var> that implements
* the component
* @return the new ComponentName
*/
public static ComponentName createRelative(Context pkg, String cls) {
return createRelative(pkg.getPackageName(), 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 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);
}
/**
* 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);
}
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 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();
}
/** @hide */
public void appendShortString(StringBuilder sb) {
appendShortString(sb, mPackage, mClass);
}
/** @hide */
public static void appendShortString(StringBuilder sb, String packageName, String className) {
sb.append(packageName).append('/');
appendShortClassName(sb, packageName, className);
}
/** @hide */
public static void printShortString(PrintWriter pw, String packageName, String className) {
pw.print(packageName);
pw.print('/');
printShortClassName(pw, packageName, className);
}
/**
* 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;
}
public void writeToParcel(Parcel out, int flags) {
out.writeString(mPackage);
out.writeString(mClass);
}
/**
* Write a ComponentName to a Parcel, handling null pointers. Must be
* read with {@link #readFromParcel(Parcel)}.
*
* @param c The ComponentName to be written.
* @param out The Parcel in which the ComponentName will be placed.
*
* @see #readFromParcel(Parcel)
*/
public static void writeToParcel(ComponentName c, Parcel out) {
if (c != null) {
c.writeToParcel(out, 0);
} else {
out.writeString(null);
}
}
/**
* Read a ComponentName from a Parcel that was previously written
* with {@link #writeToParcel(ComponentName, Parcel)}, returning either
* a null or new object as appropriate.
*
* @param in The Parcel from which to read the ComponentName
* @return Returns a new ComponentName matching the previously written
* object, or null if a null had been written.
*
* @see #writeToParcel(ComponentName, Parcel)
*/
public static ComponentName readFromParcel(Parcel in) {
String pkg = in.readString();
return pkg != null ? new ComponentName(pkg, in) : null;
}
public static final Parcelable.Creator<ComponentName> CREATOR
= new Parcelable.Creator<ComponentName>() {
public ComponentName createFromParcel(Parcel in) {
return new ComponentName(in);
}
public ComponentName[] newArray(int size) {
return new ComponentName[size];
}
};
/**
* Instantiate a new ComponentName from the data in a Parcel that was
* previously written with {@link #writeToParcel(Parcel, int)}. Note that you
* must not use this with data written by
* {@link #writeToParcel(ComponentName, Parcel)} since it is not possible
* to handle a null ComponentObject here.
*
* @param in The Parcel containing the previously written ComponentName,
* positioned at the location in the buffer where it was written.
*/
public ComponentName(Parcel in) {
mPackage = in.readString();
if (mPackage == null) throw new NullPointerException(
"package name is null");
mClass = in.readString();
if (mClass == null) throw new NullPointerException(
"class name is null");
}
private ComponentName(String pkg, Parcel in) {
mPackage = pkg;
mClass = in.readString();
}
}
@@ -0,0 +1,473 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.content;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* This class is used to store a set of values that the {@link ContentResolver}
* can process.
*/
public final class ContentValues implements Parcelable {
public static final String TAG = "ContentValues";
/** Holds the actual values */
private HashMap<String, Object> mValues;
/**
* Creates an empty set of values using the default initial size
*/
public ContentValues() {
// Choosing a default size of 8 based on analysis of typical
// consumption by applications.
mValues = new HashMap<String, Object>(8);
}
/**
* Creates an empty set of values using the given initial size
*
* @param size the initial size of the set of values
*/
public ContentValues(int size) {
mValues = new HashMap<String, Object>(size, 1.0f);
}
/**
* Creates a set of values copied from the given set
*
* @param from the values to copy
*/
public ContentValues(ContentValues from) {
mValues = new HashMap<String, Object>(from.mValues);
}
/**
* Creates a set of values copied from the given HashMap. This is used
* by the Parcel unmarshalling code.
*
* @param values the values to start with
* {@hide}
*/
private ContentValues(HashMap<String, Object> values) {
mValues = values;
}
@Override
public boolean equals(Object object) {
if (!(object instanceof ContentValues)) {
return false;
}
return mValues.equals(((ContentValues) object).mValues);
}
@Override
public int hashCode() {
return mValues.hashCode();
}
/**
* Adds a value to the set.
*
* @param key the name of the value to put
* @param value the data for the value to put
*/
public void put(String key, String value) {
mValues.put(key, value);
}
/**
* Adds all values from the passed in ContentValues.
*
* @param other the ContentValues from which to copy
*/
public void putAll(ContentValues other) {
mValues.putAll(other.mValues);
}
/**
* Adds a value to the set.
*
* @param key the name of the value to put
* @param value the data for the value to put
*/
public void put(String key, Byte value) {
mValues.put(key, value);
}
/**
* Adds a value to the set.
*
* @param key the name of the value to put
* @param value the data for the value to put
*/
public void put(String key, Short value) {
mValues.put(key, value);
}
/**
* Adds a value to the set.
*
* @param key the name of the value to put
* @param value the data for the value to put
*/
public void put(String key, Integer value) {
mValues.put(key, value);
}
/**
* Adds a value to the set.
*
* @param key the name of the value to put
* @param value the data for the value to put
*/
public void put(String key, Long value) {
mValues.put(key, value);
}
/**
* Adds a value to the set.
*
* @param key the name of the value to put
* @param value the data for the value to put
*/
public void put(String key, Float value) {
mValues.put(key, value);
}
/**
* Adds a value to the set.
*
* @param key the name of the value to put
* @param value the data for the value to put
*/
public void put(String key, Double value) {
mValues.put(key, value);
}
/**
* Adds a value to the set.
*
* @param key the name of the value to put
* @param value the data for the value to put
*/
public void put(String key, Boolean value) {
mValues.put(key, value);
}
/**
* Adds a value to the set.
*
* @param key the name of the value to put
* @param value the data for the value to put
*/
public void put(String key, byte[] value) {
mValues.put(key, value);
}
/**
* Adds a null value to the set.
*
* @param key the name of the value to make null
*/
public void putNull(String key) {
mValues.put(key, null);
}
/**
* Returns the number of values.
*
* @return the number of values
*/
public int size() {
return mValues.size();
}
/**
* Remove a single value.
*
* @param key the name of the value to remove
*/
public void remove(String key) {
mValues.remove(key);
}
/**
* Removes all values.
*/
public void clear() {
mValues.clear();
}
/**
* Returns true if this object has the named value.
*
* @param key the value to check for
* @return {@code true} if the value is present, {@code false} otherwise
*/
public boolean containsKey(String key) {
return mValues.containsKey(key);
}
/**
* Gets a value. Valid value types are {@link String}, {@link Boolean},
* {@link Number}, and {@code byte[]} implementations.
*
* @param key the value to get
* @return the data for the value, or {@code null} if the value is missing or if {@code null}
* was previously added with the given {@code key}
*/
public Object get(String key) {
return mValues.get(key);
}
/**
* Gets a value and converts it to a String.
*
* @param key the value to get
* @return the String for the value
*/
public String getAsString(String key) {
Object value = mValues.get(key);
return value != null ? value.toString() : null;
}
/**
* Gets a value and converts it to a Long.
*
* @param key the value to get
* @return the Long value, or {@code null} if the value is missing or cannot be converted
*/
public Long getAsLong(String key) {
Object value = mValues.get(key);
try {
return value != null ? ((Number) value).longValue() : null;
} catch (ClassCastException e) {
if (value instanceof CharSequence) {
try {
return Long.valueOf(value.toString());
} catch (NumberFormatException e2) {
Log.e(TAG, "Cannot parse Long value for " + value + " at key " + key);
return null;
}
} else {
Log.e(TAG, "Cannot cast value for " + key + " to a Long: " + value, e);
return null;
}
}
}
/**
* Gets a value and converts it to an Integer.
*
* @param key the value to get
* @return the Integer value, or {@code null} if the value is missing or cannot be converted
*/
public Integer getAsInteger(String key) {
Object value = mValues.get(key);
try {
return value != null ? ((Number) value).intValue() : null;
} catch (ClassCastException e) {
if (value instanceof CharSequence) {
try {
return Integer.valueOf(value.toString());
} catch (NumberFormatException e2) {
Log.e(TAG, "Cannot parse Integer value for " + value + " at key " + key);
return null;
}
} else {
Log.e(TAG, "Cannot cast value for " + key + " to a Integer: " + value, e);
return null;
}
}
}
/**
* Gets a value and converts it to a Short.
*
* @param key the value to get
* @return the Short value, or {@code null} if the value is missing or cannot be converted
*/
public Short getAsShort(String key) {
Object value = mValues.get(key);
try {
return value != null ? ((Number) value).shortValue() : null;
} catch (ClassCastException e) {
if (value instanceof CharSequence) {
try {
return Short.valueOf(value.toString());
} catch (NumberFormatException e2) {
Log.e(TAG, "Cannot parse Short value for " + value + " at key " + key);
return null;
}
} else {
Log.e(TAG, "Cannot cast value for " + key + " to a Short: " + value, e);
return null;
}
}
}
/**
* Gets a value and converts it to a Byte.
*
* @param key the value to get
* @return the Byte value, or {@code null} if the value is missing or cannot be converted
*/
public Byte getAsByte(String key) {
Object value = mValues.get(key);
try {
return value != null ? ((Number) value).byteValue() : null;
} catch (ClassCastException e) {
if (value instanceof CharSequence) {
try {
return Byte.valueOf(value.toString());
} catch (NumberFormatException e2) {
Log.e(TAG, "Cannot parse Byte value for " + value + " at key " + key);
return null;
}
} else {
Log.e(TAG, "Cannot cast value for " + key + " to a Byte: " + value, e);
return null;
}
}
}
/**
* Gets a value and converts it to a Double.
*
* @param key the value to get
* @return the Double value, or {@code null} if the value is missing or cannot be converted
*/
public Double getAsDouble(String key) {
Object value = mValues.get(key);
try {
return value != null ? ((Number) value).doubleValue() : null;
} catch (ClassCastException e) {
if (value instanceof CharSequence) {
try {
return Double.valueOf(value.toString());
} catch (NumberFormatException e2) {
Log.e(TAG, "Cannot parse Double value for " + value + " at key " + key);
return null;
}
} else {
Log.e(TAG, "Cannot cast value for " + key + " to a Double: " + value, e);
return null;
}
}
}
/**
* Gets a value and converts it to a Float.
*
* @param key the value to get
* @return the Float value, or {@code null} if the value is missing or cannot be converted
*/
public Float getAsFloat(String key) {
Object value = mValues.get(key);
try {
return value != null ? ((Number) value).floatValue() : null;
} catch (ClassCastException e) {
if (value instanceof CharSequence) {
try {
return Float.valueOf(value.toString());
} catch (NumberFormatException e2) {
Log.e(TAG, "Cannot parse Float value for " + value + " at key " + key);
return null;
}
} else {
Log.e(TAG, "Cannot cast value for " + key + " to a Float: " + value, e);
return null;
}
}
}
/**
* Gets a value and converts it to a Boolean.
*
* @param key the value to get
* @return the Boolean value, or {@code null} if the value is missing or cannot be converted
*/
public Boolean getAsBoolean(String key) {
Object value = mValues.get(key);
try {
return (Boolean) value;
} catch (ClassCastException e) {
if (value instanceof CharSequence) {
return Boolean.valueOf(value.toString());
} else if (value instanceof Number) {
return ((Number) value).intValue() != 0;
} else {
Log.e(TAG, "Cannot cast value for " + key + " to a Boolean: " + value, e);
return null;
}
}
}
/**
* Gets a value that is a byte array. Note that this method will not convert
* any other types to byte arrays.
*
* @param key the value to get
* @return the {@code byte[]} value, or {@code null} is the value is missing or not a
* {@code byte[]}
*/
public byte[] getAsByteArray(String key) {
Object value = mValues.get(key);
if (value instanceof byte[]) {
return (byte[]) value;
} else {
return null;
}
}
/**
* Returns a set of all of the keys and values
*
* @return a set of all of the keys and values
*/
public Set<Map.Entry<String, Object>> valueSet() {
return mValues.entrySet();
}
/**
* Returns a set of all of the keys
*
* @return a set of all of the keys
*/
public Set<String> keySet() {
return mValues.keySet();
}
public static final Parcelable.Creator<ContentValues> CREATOR =
new Parcelable.Creator<ContentValues>() {
@SuppressWarnings({"deprecation", "unchecked"})
public ContentValues createFromParcel(Parcel in) {
// TODO - what ClassLoader should be passed to readHashMap?
HashMap<String, Object> values = in.readHashMap(null);
return new ContentValues(values);
}
public ContentValues[] newArray(int size) {
return new ContentValues[size];
}
};
public int describeContents() {
return 0;
}
@SuppressWarnings("deprecation")
public void writeToParcel(Parcel parcel, int flags) {
parcel.writeMap(mValues);
}
/**
* Unsupported, here until we get proper bulk insert APIs.
* {@hide}
*/
@Deprecated
public void putStringArrayList(String key, ArrayList<String> value) {
mValues.put(key, value);
}
/**
* Unsupported, here until we get proper bulk insert APIs.
* {@hide}
*/
@SuppressWarnings("unchecked")
@Deprecated
public ArrayList<String> getStringArrayList(String key) {
return (ArrayList<String>) mValues.get(key);
}
/**
* Returns a string containing a concise, human-readable description of this object.
* @return a printable representation of this object.
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
for (String name : mValues.keySet()) {
String value = getAsString(name);
if (sb.length() > 0) sb.append(" ");
sb.append(name + "=" + value);
}
return sb.toString();
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,720 @@
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.content;
import android.annotation.SystemApi;
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.database.DatabaseErrorHandler;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.UserHandle;
import android.view.Display;
import android.view.DisplayAdjustments;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
/**
* Proxying implementation of Context that simply delegates all of its calls to
* another Context. Can be subclassed to modify behavior without changing
* the original Context.
*/
public class ContextWrapper extends Context {
Context mBase;
public ContextWrapper(Context base) {
mBase = base;
}
/**
* Set the base context for this ContextWrapper. All calls will then be
* delegated to the base context. Throws
* IllegalStateException if a base context has already been set.
*
* @param base The new base context for this wrapper.
*/
protected void attachBaseContext(Context base) {
if (mBase != null) {
throw new IllegalStateException("Base context already set");
}
mBase = base;
}
/**
* @return the base context as set by the constructor or setBaseContext
*/
public Context getBaseContext() {
return mBase;
}
@Override
public AssetManager getAssets() {
return mBase.getAssets();
}
@Override
public Resources getResources() {
return mBase.getResources();
}
@Override
public PackageManager getPackageManager() {
return mBase.getPackageManager();
}
@Override
public ContentResolver getContentResolver() {
return mBase.getContentResolver();
}
@Override
public Looper getMainLooper() {
return mBase.getMainLooper();
}
@Override
public Context getApplicationContext() {
return mBase.getApplicationContext();
}
@Override
public void setTheme(int resid) {
mBase.setTheme(resid);
}
/** @hide */
@Override
public int getThemeResId() {
return mBase.getThemeResId();
}
@Override
public Resources.Theme getTheme() {
return mBase.getTheme();
}
@Override
public ClassLoader getClassLoader() {
return mBase.getClassLoader();
}
@Override
public String getPackageName() {
return mBase.getPackageName();
}
/** @hide */
@Override
public String getBasePackageName() {
return mBase.getBasePackageName();
}
/** @hide */
@Override
public String getOpPackageName() {
return mBase.getOpPackageName();
}
@Override
public ApplicationInfo getApplicationInfo() {
return mBase.getApplicationInfo();
}
@Override
public String getPackageResourcePath() {
return mBase.getPackageResourcePath();
}
@Override
public String getPackageCodePath() {
return mBase.getPackageCodePath();
}
@Override
public SharedPreferences getSharedPreferences(String name, int mode) {
return mBase.getSharedPreferences(name, mode);
}
/** @removed */
@Override
public SharedPreferences getSharedPreferences(File file, int mode) {
return mBase.getSharedPreferences(file, mode);
}
@Override
public boolean moveSharedPreferencesFrom(Context sourceContext, String name) {
return mBase.moveSharedPreferencesFrom(sourceContext, name);
}
@Override
public boolean deleteSharedPreferences(String name) {
return mBase.deleteSharedPreferences(name);
}
@Override
public FileInputStream openFileInput(String name)
throws FileNotFoundException {
return mBase.openFileInput(name);
}
@Override
public FileOutputStream openFileOutput(String name, int mode)
throws FileNotFoundException {
return mBase.openFileOutput(name, mode);
}
@Override
public boolean deleteFile(String name) {
return mBase.deleteFile(name);
}
@Override
public File getFileStreamPath(String name) {
return mBase.getFileStreamPath(name);
}
/** @removed */
@Override
public File getSharedPreferencesPath(String name) {
return mBase.getSharedPreferencesPath(name);
}
@Override
public String[] fileList() {
return mBase.fileList();
}
@Override
public File getDataDir() {
return mBase.getDataDir();
}
@Override
public File getFilesDir() {
return mBase.getFilesDir();
}
@Override
public File getNoBackupFilesDir() {
return mBase.getNoBackupFilesDir();
}
@Override
public File getExternalFilesDir(String type) {
return mBase.getExternalFilesDir(type);
}
@Override
public File[] getExternalFilesDirs(String type) {
return mBase.getExternalFilesDirs(type);
}
@Override
public File getObbDir() {
return mBase.getObbDir();
}
@Override
public File[] getObbDirs() {
return mBase.getObbDirs();
}
@Override
public File getCacheDir() {
return mBase.getCacheDir();
}
@Override
public File getCodeCacheDir() {
return mBase.getCodeCacheDir();
}
@Override
public File getExternalCacheDir() {
return mBase.getExternalCacheDir();
}
@Override
public File[] getExternalCacheDirs() {
return mBase.getExternalCacheDirs();
}
@Override
public File[] getExternalMediaDirs() {
return mBase.getExternalMediaDirs();
}
@Override
public File getDir(String name, int mode) {
return mBase.getDir(name, mode);
}
@Override
public SQLiteDatabase openOrCreateDatabase(String name, int mode, CursorFactory factory) {
return mBase.openOrCreateDatabase(name, mode, factory);
}
@Override
public SQLiteDatabase openOrCreateDatabase(String name, int mode, CursorFactory factory,
DatabaseErrorHandler errorHandler) {
return mBase.openOrCreateDatabase(name, mode, factory, errorHandler);
}
@Override
public boolean moveDatabaseFrom(Context sourceContext, String name) {
return mBase.moveDatabaseFrom(sourceContext, name);
}
@Override
public boolean deleteDatabase(String name) {
return mBase.deleteDatabase(name);
}
@Override
public File getDatabasePath(String name) {
return mBase.getDatabasePath(name);
}
@Override
public String[] databaseList() {
return mBase.databaseList();
}
@Override
@Deprecated
public Drawable getWallpaper() {
return mBase.getWallpaper();
}
@Override
@Deprecated
public Drawable peekWallpaper() {
return mBase.peekWallpaper();
}
@Override
@Deprecated
public int getWallpaperDesiredMinimumWidth() {
return mBase.getWallpaperDesiredMinimumWidth();
}
@Override
@Deprecated
public int getWallpaperDesiredMinimumHeight() {
return mBase.getWallpaperDesiredMinimumHeight();
}
@Override
@Deprecated
public void setWallpaper(Bitmap bitmap) throws IOException {
mBase.setWallpaper(bitmap);
}
@Override
@Deprecated
public void setWallpaper(InputStream data) throws IOException {
mBase.setWallpaper(data);
}
@Override
@Deprecated
public void clearWallpaper() throws IOException {
mBase.clearWallpaper();
}
@Override
public void startActivity(Intent intent) {
mBase.startActivity(intent);
}
/** @hide */
@Override
public void startActivityAsUser(Intent intent, UserHandle user) {
mBase.startActivityAsUser(intent, user);
}
/** @hide **/
public void startActivityForResult(
String who, Intent intent, int requestCode, Bundle options) {
mBase.startActivityForResult(who, intent, requestCode, options);
}
/** @hide **/
public boolean canStartActivityForResult() {
return mBase.canStartActivityForResult();
}
@Override
public void startActivity(Intent intent, Bundle options) {
mBase.startActivity(intent, options);
}
/** @hide */
@Override
public void startActivityAsUser(Intent intent, Bundle options, UserHandle user) {
mBase.startActivityAsUser(intent, options, user);
}
@Override
public void startActivities(Intent[] intents) {
mBase.startActivities(intents);
}
@Override
public void startActivities(Intent[] intents, Bundle options) {
mBase.startActivities(intents, options);
}
/** @hide */
@Override
public void startActivitiesAsUser(Intent[] intents, Bundle options, UserHandle userHandle) {
mBase.startActivitiesAsUser(intents, options, userHandle);
}
@Override
public void startIntentSender(IntentSender intent,
Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
throws IntentSender.SendIntentException {
mBase.startIntentSender(intent, fillInIntent, flagsMask,
flagsValues, extraFlags);
}
@Override
public void startIntentSender(IntentSender intent,
Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags,
Bundle options) throws IntentSender.SendIntentException {
mBase.startIntentSender(intent, fillInIntent, flagsMask,
flagsValues, extraFlags, options);
}
@Override
public void sendBroadcast(Intent intent) {
mBase.sendBroadcast(intent);
}
@Override
public void sendBroadcast(Intent intent, String receiverPermission) {
mBase.sendBroadcast(intent, receiverPermission);
}
/** @hide */
@Override
public void sendBroadcastMultiplePermissions(Intent intent, String[] receiverPermissions) {
mBase.sendBroadcastMultiplePermissions(intent, receiverPermissions);
}
/** @hide */
@SystemApi
@Override
public void sendBroadcast(Intent intent, String receiverPermission, Bundle options) {
mBase.sendBroadcast(intent, receiverPermission, options);
}
/** @hide */
@Override
public void sendBroadcast(Intent intent, String receiverPermission, int appOp) {
mBase.sendBroadcast(intent, receiverPermission, appOp);
}
@Override
public void sendOrderedBroadcast(Intent intent,
String receiverPermission) {
mBase.sendOrderedBroadcast(intent, receiverPermission);
}
@Override
public void sendOrderedBroadcast(
Intent intent, String receiverPermission, BroadcastReceiver resultReceiver,
Handler scheduler, int initialCode, String initialData,
Bundle initialExtras) {
mBase.sendOrderedBroadcast(intent, receiverPermission,
resultReceiver, scheduler, initialCode,
initialData, initialExtras);
}
/** @hide */
@SystemApi
@Override
public void sendOrderedBroadcast(
Intent intent, String receiverPermission, Bundle options, BroadcastReceiver resultReceiver,
Handler scheduler, int initialCode, String initialData,
Bundle initialExtras) {
mBase.sendOrderedBroadcast(intent, receiverPermission,
options, resultReceiver, scheduler, initialCode,
initialData, initialExtras);
}
/** @hide */
@Override
public void sendOrderedBroadcast(
Intent intent, String receiverPermission, int appOp, BroadcastReceiver resultReceiver,
Handler scheduler, int initialCode, String initialData,
Bundle initialExtras) {
mBase.sendOrderedBroadcast(intent, receiverPermission, appOp,
resultReceiver, scheduler, initialCode,
initialData, initialExtras);
}
@Override
public void sendBroadcastAsUser(Intent intent, UserHandle user) {
mBase.sendBroadcastAsUser(intent, user);
}
@Override
public void sendBroadcastAsUser(Intent intent, UserHandle user,
String receiverPermission) {
mBase.sendBroadcastAsUser(intent, user, receiverPermission);
}
/** @hide */
@Override
public void sendBroadcastAsUser(Intent intent, UserHandle user,
String receiverPermission, int appOp) {
mBase.sendBroadcastAsUser(intent, user, receiverPermission, appOp);
}
@Override
public void sendOrderedBroadcastAsUser(Intent intent, UserHandle user,
String receiverPermission, BroadcastReceiver resultReceiver, Handler scheduler,
int initialCode, String initialData, Bundle initialExtras) {
mBase.sendOrderedBroadcastAsUser(intent, user, receiverPermission, resultReceiver,
scheduler, initialCode, initialData, initialExtras);
}
/** @hide */
@Override
public void sendOrderedBroadcastAsUser(Intent intent, UserHandle user,
String receiverPermission, int appOp, BroadcastReceiver resultReceiver,
Handler scheduler, int initialCode, String initialData, Bundle initialExtras) {
mBase.sendOrderedBroadcastAsUser(intent, user, receiverPermission, appOp, resultReceiver,
scheduler, initialCode, initialData, initialExtras);
}
/** @hide */
@Override
public void sendOrderedBroadcastAsUser(Intent intent, UserHandle user,
String receiverPermission, int appOp, Bundle options, BroadcastReceiver resultReceiver,
Handler scheduler, int initialCode, String initialData, Bundle initialExtras) {
mBase.sendOrderedBroadcastAsUser(intent, user, receiverPermission, appOp, options,
resultReceiver, scheduler, initialCode, initialData, initialExtras);
}
@Override
@Deprecated
public void sendStickyBroadcast(Intent intent) {
mBase.sendStickyBroadcast(intent);
}
@Override
@Deprecated
public void sendStickyOrderedBroadcast(
Intent intent, BroadcastReceiver resultReceiver,
Handler scheduler, int initialCode, String initialData,
Bundle initialExtras) {
mBase.sendStickyOrderedBroadcast(intent,
resultReceiver, scheduler, initialCode,
initialData, initialExtras);
}
@Override
@Deprecated
public void removeStickyBroadcast(Intent intent) {
mBase.removeStickyBroadcast(intent);
}
@Override
@Deprecated
public void sendStickyBroadcastAsUser(Intent intent, UserHandle user) {
mBase.sendStickyBroadcastAsUser(intent, user);
}
/** @hide */
@Override
@Deprecated
public void sendStickyBroadcastAsUser(Intent intent, UserHandle user, Bundle options) {
mBase.sendStickyBroadcastAsUser(intent, user, options);
}
@Override
@Deprecated
public void sendStickyOrderedBroadcastAsUser(Intent intent,
UserHandle user, BroadcastReceiver resultReceiver,
Handler scheduler, int initialCode, String initialData,
Bundle initialExtras) {
mBase.sendStickyOrderedBroadcastAsUser(intent, user, resultReceiver,
scheduler, initialCode, initialData, initialExtras);
}
@Override
@Deprecated
public void removeStickyBroadcastAsUser(Intent intent, UserHandle user) {
mBase.removeStickyBroadcastAsUser(intent, user);
}
@Override
public Intent registerReceiver(
BroadcastReceiver receiver, IntentFilter filter) {
return mBase.registerReceiver(receiver, filter);
}
@Override
public Intent registerReceiver(
BroadcastReceiver receiver, IntentFilter filter,
String broadcastPermission, Handler scheduler) {
return mBase.registerReceiver(receiver, filter, broadcastPermission,
scheduler);
}
/** @hide */
@Override
public Intent registerReceiverAsUser(
BroadcastReceiver receiver, UserHandle user, IntentFilter filter,
String broadcastPermission, Handler scheduler) {
return mBase.registerReceiverAsUser(receiver, user, filter, broadcastPermission,
scheduler);
}
@Override
public void unregisterReceiver(BroadcastReceiver receiver) {
mBase.unregisterReceiver(receiver);
}
@Override
public ComponentName startService(Intent service) {
return mBase.startService(service);
}
@Override
public boolean stopService(Intent name) {
return mBase.stopService(name);
}
/** @hide */
@Override
public ComponentName startServiceAsUser(Intent service, UserHandle user) {
return mBase.startServiceAsUser(service, user);
}
/** @hide */
@Override
public boolean stopServiceAsUser(Intent name, UserHandle user) {
return mBase.stopServiceAsUser(name, user);
}
@Override
public boolean bindService(Intent service, ServiceConnection conn,
int flags) {
return mBase.bindService(service, conn, flags);
}
/** @hide */
@Override
public boolean bindServiceAsUser(Intent service, ServiceConnection conn, int flags,
UserHandle user) {
return mBase.bindServiceAsUser(service, conn, flags, user);
}
@Override
public void unbindService(ServiceConnection conn) {
mBase.unbindService(conn);
}
@Override
public boolean startInstrumentation(ComponentName className,
String profileFile, Bundle arguments) {
return mBase.startInstrumentation(className, profileFile, arguments);
}
@Override
public Object getSystemService(String name) {
return mBase.getSystemService(name);
}
@Override
public String getSystemServiceName(Class<?> serviceClass) {
return mBase.getSystemServiceName(serviceClass);
}
@Override
public int checkPermission(String permission, int pid, int uid) {
return mBase.checkPermission(permission, pid, uid);
}
/** @hide */
@Override
public int checkPermission(String permission, int pid, int uid, IBinder callerToken) {
return mBase.checkPermission(permission, pid, uid, callerToken);
}
@Override
public int checkCallingPermission(String permission) {
return mBase.checkCallingPermission(permission);
}
@Override
public int checkCallingOrSelfPermission(String permission) {
return mBase.checkCallingOrSelfPermission(permission);
}
@Override
public int checkSelfPermission(String permission) {
return mBase.checkSelfPermission(permission);
}
@Override
public void enforcePermission(
String permission, int pid, int uid, String message) {
mBase.enforcePermission(permission, pid, uid, message);
}
@Override
public void enforceCallingPermission(String permission, String message) {
mBase.enforceCallingPermission(permission, message);
}
@Override
public void enforceCallingOrSelfPermission(
String permission, String message) {
mBase.enforceCallingOrSelfPermission(permission, message);
}
@Override
public void grantUriPermission(String toPackage, Uri uri, int modeFlags) {
mBase.grantUriPermission(toPackage, uri, modeFlags);
}
@Override
public void revokeUriPermission(Uri uri, int modeFlags) {
mBase.revokeUriPermission(uri, modeFlags);
}
@Override
public int checkUriPermission(Uri uri, int pid, int uid, int modeFlags) {
return mBase.checkUriPermission(uri, pid, uid, modeFlags);
}
/** @hide */
@Override
public int checkUriPermission(Uri uri, int pid, int uid, int modeFlags, IBinder callerToken) {
return mBase.checkUriPermission(uri, pid, uid, modeFlags, callerToken);
}
@Override
public int checkCallingUriPermission(Uri uri, int modeFlags) {
return mBase.checkCallingUriPermission(uri, modeFlags);
}
@Override
public int checkCallingOrSelfUriPermission(Uri uri, int modeFlags) {
return mBase.checkCallingOrSelfUriPermission(uri, modeFlags);
}
@Override
public int checkUriPermission(Uri uri, String readPermission,
String writePermission, int pid, int uid, int modeFlags) {
return mBase.checkUriPermission(uri, readPermission, writePermission,
pid, uid, modeFlags);
}
@Override
public void enforceUriPermission(
Uri uri, int pid, int uid, int modeFlags, String message) {
mBase.enforceUriPermission(uri, pid, uid, modeFlags, message);
}
@Override
public void enforceCallingUriPermission(
Uri uri, int modeFlags, String message) {
mBase.enforceCallingUriPermission(uri, modeFlags, message);
}
@Override
public void enforceCallingOrSelfUriPermission(
Uri uri, int modeFlags, String message) {
mBase.enforceCallingOrSelfUriPermission(uri, modeFlags, message);
}
@Override
public void enforceUriPermission(
Uri uri, String readPermission, String writePermission,
int pid, int uid, int modeFlags, String message) {
mBase.enforceUriPermission(
uri, readPermission, writePermission, pid, uid, modeFlags,
message);
}
@Override
public Context createPackageContext(String packageName, int flags)
throws PackageManager.NameNotFoundException {
return mBase.createPackageContext(packageName, flags);
}
/** @hide */
@Override
public Context createPackageContextAsUser(String packageName, int flags, UserHandle user)
throws PackageManager.NameNotFoundException {
return mBase.createPackageContextAsUser(packageName, flags, user);
}
/** @hide */
@Override
public Context createApplicationContext(ApplicationInfo application,
int flags) throws PackageManager.NameNotFoundException {
return mBase.createApplicationContext(application, flags);
}
/** @hide */
@Override
public int getUserId() {
return mBase.getUserId();
}
@Override
public Context createConfigurationContext(Configuration overrideConfiguration) {
return mBase.createConfigurationContext(overrideConfiguration);
}
@Override
public Context createDisplayContext(Display display) {
return mBase.createDisplayContext(display);
}
@Override
public boolean isRestricted() {
return mBase.isRestricted();
}
/** @hide */
@Override
public DisplayAdjustments getDisplayAdjustments(int displayId) {
return mBase.getDisplayAdjustments(displayId);
}
/**
* @hide
*/
@Override
public Display getDisplay() {
return mBase.getDisplay();
}
@Override
public Context createDeviceProtectedStorageContext() {
return mBase.createDeviceProtectedStorageContext();
}
/** {@hide} */
@SystemApi
@Override
public Context createCredentialProtectedStorageContext() {
return mBase.createCredentialProtectedStorageContext();
}
@Override
public boolean isDeviceProtectedStorage() {
return mBase.isDeviceProtectedStorage();
}
/** {@hide} */
@SystemApi
@Override
public boolean isCredentialProtectedStorage() {
return mBase.isCredentialProtectedStorage();
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,370 @@
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.content;
import android.annotation.Nullable;
import java.util.Map;
import java.util.Set;
/**
* Interface for accessing and modifying preference data returned by {@link
* Context#getSharedPreferences}. For any particular set of preferences,
* there is a single instance of this class that all clients share.
* Modifications to the preferences must go through an {@link Editor} object
* to ensure the preference values remain in a consistent state and control
* when they are committed to storage. Objects that are returned from the
* various <code>get</code> methods must be treated as immutable by the application.
*
* <p><em>Note: This class does not support use across multiple processes.</em>
*
* <div class="special reference">
* <h3>Developer Guides</h3>
* <p>For more information about using SharedPreferences, read the
* <a href="{@docRoot}guide/topics/data/data-storage.html#pref">Data Storage</a>
* developer guide.</p></div>
*
* @see Context#getSharedPreferences
*/
public interface SharedPreferences {
/**
* Interface definition for a callback to be invoked when a shared
* preference is changed.
*/
public interface OnSharedPreferenceChangeListener {
/**
* Called when a shared preference is changed, added, or removed. This
* may be called even if a preference is set to its existing value.
*
* <p>This callback will be run on your main thread.
*
* @param sharedPreferences The {@link SharedPreferences} that received
* the change.
* @param key The key of the preference that was changed, added, or
* removed.
*/
void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key);
}
/**
* Interface used for modifying values in a {@link SharedPreferences}
* object. All changes you make in an editor are batched, and not copied
* back to the original {@link SharedPreferences} until you call {@link #commit}
* or {@link #apply}
*/
public interface Editor {
/**
* Set a String value in the preferences editor, to be written back once
* {@link #commit} or {@link #apply} are called.
*
* @param key The name of the preference to modify.
* @param value The new value for the preference. Passing {@code null}
* for this argument is equivalent to calling {@link #remove(String)} with
* this key.
*
* @return Returns a reference to the same Editor object, so you can
* chain put calls together.
*/
Editor putString(String key, @Nullable String value);
/**
* Set a set of String values in the preferences editor, to be written
* back once {@link #commit} or {@link #apply} is called.
*
* @param key The name of the preference to modify.
* @param values The set of new values for the preference. Passing {@code null}
* for this argument is equivalent to calling {@link #remove(String)} with
* this key.
* @return Returns a reference to the same Editor object, so you can
* chain put calls together.
*/
Editor putStringSet(String key, @Nullable Set<String> values);
/**
* Set an int value in the preferences editor, to be written back once
* {@link #commit} or {@link #apply} are called.
*
* @param key The name of the preference to modify.
* @param value The new value for the preference.
*
* @return Returns a reference to the same Editor object, so you can
* chain put calls together.
*/
Editor putInt(String key, int value);
/**
* Set a long value in the preferences editor, to be written back once
* {@link #commit} or {@link #apply} are called.
*
* @param key The name of the preference to modify.
* @param value The new value for the preference.
*
* @return Returns a reference to the same Editor object, so you can
* chain put calls together.
*/
Editor putLong(String key, long value);
/**
* Set a float value in the preferences editor, to be written back once
* {@link #commit} or {@link #apply} are called.
*
* @param key The name of the preference to modify.
* @param value The new value for the preference.
*
* @return Returns a reference to the same Editor object, so you can
* chain put calls together.
*/
Editor putFloat(String key, float value);
/**
* Set a boolean value in the preferences editor, to be written back
* once {@link #commit} or {@link #apply} are called.
*
* @param key The name of the preference to modify.
* @param value The new value for the preference.
*
* @return Returns a reference to the same Editor object, so you can
* chain put calls together.
*/
Editor putBoolean(String key, boolean value);
/**
* Mark in the editor that a preference value should be removed, which
* will be done in the actual preferences once {@link #commit} is
* called.
*
* <p>Note that when committing back to the preferences, all removals
* are done first, regardless of whether you called remove before
* or after put methods on this editor.
*
* @param key The name of the preference to remove.
*
* @return Returns a reference to the same Editor object, so you can
* chain put calls together.
*/
Editor remove(String key);
/**
* Mark in the editor to remove <em>all</em> values from the
* preferences. Once commit is called, the only remaining preferences
* will be any that you have defined in this editor.
*
* <p>Note that when committing back to the preferences, the clear
* is done first, regardless of whether you called clear before
* or after put methods on this editor.
*
* @return Returns a reference to the same Editor object, so you can
* chain put calls together.
*/
Editor clear();
/**
* Commit your preferences changes back from this Editor to the
* {@link SharedPreferences} object it is editing. This atomically
* performs the requested modifications, replacing whatever is currently
* in the SharedPreferences.
*
* <p>Note that when two editors are modifying preferences at the same
* time, the last one to call commit wins.
*
* <p>If you don't care about the return value and you're
* using this from your application's main thread, consider
* using {@link #apply} instead.
*
* @return Returns true if the new values were successfully written
* to persistent storage.
*/
boolean commit();
/**
* Commit your preferences changes back from this Editor to the
* {@link SharedPreferences} object it is editing. This atomically
* performs the requested modifications, replacing whatever is currently
* in the SharedPreferences.
*
* <p>Note that when two editors are modifying preferences at the same
* time, the last one to call apply wins.
*
* <p>Unlike {@link #commit}, which writes its preferences out
* to persistent storage synchronously, {@link #apply}
* commits its changes to the in-memory
* {@link SharedPreferences} immediately but starts an
* asynchronous commit to disk and you won't be notified of
* any failures. If another editor on this
* {@link SharedPreferences} does a regular {@link #commit}
* while a {@link #apply} is still outstanding, the
* {@link #commit} will block until all async commits are
* completed as well as the commit itself.
*
* <p>As {@link SharedPreferences} instances are singletons within
* a process, it's safe to replace any instance of {@link #commit} with
* {@link #apply} if you were already ignoring the return value.
*
* <p>You don't need to worry about Android component
* lifecycles and their interaction with <code>apply()</code>
* writing to disk. The framework makes sure in-flight disk
* writes from <code>apply()</code> complete before switching
* states.
*
* <p class='note'>The SharedPreferences.Editor interface
* isn't expected to be implemented directly. However, if you
* previously did implement it and are now getting errors
* about missing <code>apply()</code>, you can simply call
* {@link #commit} from <code>apply()</code>.
*/
void apply();
}
/**
* Retrieve all values from the preferences.
*
* <p>Note that you <em>must not</em> modify the collection returned
* by this method, or alter any of its contents. The consistency of your
* stored data is not guaranteed if you do.
*
* @return Returns a map containing a list of pairs key/value representing
* the preferences.
*
* @throws NullPointerException
*/
Map<String, ?> getAll();
/**
* Retrieve a String value from the preferences.
*
* @param key The name of the preference to retrieve.
* @param defValue Value to return if this preference does not exist.
*
* @return Returns the preference value if it exists, or defValue. Throws
* ClassCastException if there is a preference with this name that is not
* a String.
*
* @throws ClassCastException
*/
@Nullable
String getString(String key, @Nullable String defValue);
/**
* Retrieve a set of String values from the preferences.
*
* <p>Note that you <em>must not</em> modify the set instance returned
* by this call. The consistency of the stored data is not guaranteed
* if you do, nor is your ability to modify the instance at all.
*
* @param key The name of the preference to retrieve.
* @param defValues Values to return if this preference does not exist.
*
* @return Returns the preference values if they exist, or defValues.
* Throws ClassCastException if there is a preference with this name
* that is not a Set.
*
* @throws ClassCastException
*/
@Nullable
Set<String> getStringSet(String key, @Nullable Set<String> defValues);
/**
* Retrieve an int value from the preferences.
*
* @param key The name of the preference to retrieve.
* @param defValue Value to return if this preference does not exist.
*
* @return Returns the preference value if it exists, or defValue. Throws
* ClassCastException if there is a preference with this name that is not
* an int.
*
* @throws ClassCastException
*/
int getInt(String key, int defValue);
/**
* Retrieve a long value from the preferences.
*
* @param key The name of the preference to retrieve.
* @param defValue Value to return if this preference does not exist.
*
* @return Returns the preference value if it exists, or defValue. Throws
* ClassCastException if there is a preference with this name that is not
* a long.
*
* @throws ClassCastException
*/
long getLong(String key, long defValue);
/**
* Retrieve a float value from the preferences.
*
* @param key The name of the preference to retrieve.
* @param defValue Value to return if this preference does not exist.
*
* @return Returns the preference value if it exists, or defValue. Throws
* ClassCastException if there is a preference with this name that is not
* a float.
*
* @throws ClassCastException
*/
float getFloat(String key, float defValue);
/**
* Retrieve a boolean value from the preferences.
*
* @param key The name of the preference to retrieve.
* @param defValue Value to return if this preference does not exist.
*
* @return Returns the preference value if it exists, or defValue. Throws
* ClassCastException if there is a preference with this name that is not
* a boolean.
*
* @throws ClassCastException
*/
boolean getBoolean(String key, boolean defValue);
/**
* Checks whether the preferences contains a preference.
*
* @param key The name of the preference to check.
* @return Returns true if the preference exists in the preferences,
* otherwise false.
*/
boolean contains(String key);
/**
* Create a new Editor for these preferences, through which you can make
* modifications to the data in the preferences and atomically commit those
* changes back to the SharedPreferences object.
*
* <p>Note that you <em>must</em> call {@link Editor#commit} to have any
* changes you perform in the Editor actually show up in the
* SharedPreferences.
*
* @return Returns a new instance of the {@link Editor} interface, allowing
* you to modify the values in this SharedPreferences object.
*/
Editor edit();
/**
* Registers a callback to be invoked when a change happens to a preference.
*
* <p class="caution"><strong>Caution:</strong> The preference manager does
* not currently store a strong reference to the listener. You must store a
* strong reference to the listener, or it will be susceptible to garbage
* collection. We recommend you keep a reference to the listener in the
* instance data of an object that will exist as long as you need the
* listener.</p>
*
* @param listener The callback that will run.
* @see #unregisterOnSharedPreferenceChangeListener
*/
void registerOnSharedPreferenceChangeListener(OnSharedPreferenceChangeListener listener);
/**
* Unregisters a previous callback.
*
* @param listener The callback that should be unregistered.
* @see #registerOnSharedPreferenceChangeListener
*/
void unregisterOnSharedPreferenceChangeListener(OnSharedPreferenceChangeListener listener);
}
@@ -0,0 +1,999 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.content.pm;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import java.text.Collator;
import java.util.Comparator;
/**
* Information you can retrieve about a particular application. This
* corresponds to information collected from the AndroidManifest.xml's
* &lt;application&gt; tag.
*/
public class ApplicationInfo extends PackageItemInfo implements Parcelable {
/**
* Default task affinity of all activities in this application. See
* {@link ActivityInfo#taskAffinity} for more information. This comes
* from the "taskAffinity" attribute.
*/
public String taskAffinity;
/**
* Optional name of a permission required to be able to access this
* application's components. From the "permission" attribute.
*/
public String permission;
/**
* The name of the process this application should run in. From the
* "process" attribute or, if not set, the same as
* <var>packageName</var>.
*/
public String processName;
/**
* Class implementing the Application object. From the "class"
* attribute.
*/
public String className;
/**
* A style resource identifier (in the package's resources) of the
* description of an application. From the "description" attribute
* or, if not set, 0.
*/
public int descriptionRes;
/**
* A style resource identifier (in the package's resources) of the
* default visual theme of the application. From the "theme" attribute
* or, if not set, 0.
*/
public int theme;
/**
* Class implementing the Application's manage space
* functionality. From the "manageSpaceActivity"
* attribute. This is an optional attribute and will be null if
* applications don't specify it in their manifest
*/
public String manageSpaceActivityName;
/**
* Class implementing the Application's backup functionality. From
* the "backupAgent" attribute. This is an optional attribute and
* will be null if the application does not specify it in its manifest.
*
* <p>If android:allowBackup is set to false, this attribute is ignored.
*/
public String backupAgentName;
/**
* An optional attribute that indicates the app supports automatic backup of app data.
* <p>0 is the default and means the app's entire data folder + managed external storage will
* be backed up;
* Any negative value indicates the app does not support full-data backup, though it may still
* want to participate via the traditional key/value backup API;
* A positive number specifies an xml resource in which the application has defined its backup
* include/exclude criteria.
* <p>If android:allowBackup is set to false, this attribute is ignored.
*
* @see android.content.Context#getNoBackupFilesDir()
* @see #FLAG_ALLOW_BACKUP
*
* @hide
*/
public int fullBackupContent = 0;
/**
* The default extra UI options for activities in this application.
* Set from the {@link android.R.attr#uiOptions} attribute in the
* activity's manifest.
*/
public int uiOptions = 0;
/**
* Value for {@link #flags}: if set, this application is installed in the
* device's system image.
*/
public static final int FLAG_SYSTEM = 1<<0;
/**
* Value for {@link #flags}: set to true if this application would like to
* allow debugging of its
* code, even when installed on a non-development system. Comes
* from {@link android.R.styleable#AndroidManifestApplication_debuggable
* android:debuggable} of the &lt;application&gt; tag.
*/
public static final int FLAG_DEBUGGABLE = 1<<1;
/**
* Value for {@link #flags}: set to true if this application has code
* associated with it. Comes
* from {@link android.R.styleable#AndroidManifestApplication_hasCode
* android:hasCode} of the &lt;application&gt; tag.
*/
public static final int FLAG_HAS_CODE = 1<<2;
/**
* Value for {@link #flags}: set to true if this application is persistent.
* Comes from {@link android.R.styleable#AndroidManifestApplication_persistent
* android:persistent} of the &lt;application&gt; tag.
*/
public static final int FLAG_PERSISTENT = 1<<3;
/**
* Value for {@link #flags}: set to true if this application holds the
* {@link android.Manifest.permission#FACTORY_TEST} permission and the
* device is running in factory test mode.
*/
public static final int FLAG_FACTORY_TEST = 1<<4;
/**
* Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
* Comes from {@link android.R.styleable#AndroidManifestApplication_allowTaskReparenting
* android:allowTaskReparenting} of the &lt;application&gt; tag.
*/
public static final int FLAG_ALLOW_TASK_REPARENTING = 1<<5;
/**
* Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
* Comes from {@link android.R.styleable#AndroidManifestApplication_allowClearUserData
* android:allowClearUserData} of the &lt;application&gt; tag.
*/
public static final int FLAG_ALLOW_CLEAR_USER_DATA = 1<<6;
/**
* Value for {@link #flags}: this is set if this application has been
* installed as an update to a built-in system application.
*/
public static final int FLAG_UPDATED_SYSTEM_APP = 1<<7;
/**
* Value for {@link #flags}: this is set if the application has specified
* {@link android.R.styleable#AndroidManifestApplication_testOnly
* android:testOnly} to be true.
*/
public static final int FLAG_TEST_ONLY = 1<<8;
/**
* Value for {@link #flags}: true when the application's window can be
* reduced in size for smaller screens. Corresponds to
* {@link android.R.styleable#AndroidManifestSupportsScreens_smallScreens
* android:smallScreens}.
*/
public static final int FLAG_SUPPORTS_SMALL_SCREENS = 1<<9;
/**
* Value for {@link #flags}: true when the application's window can be
* displayed on normal screens. Corresponds to
* {@link android.R.styleable#AndroidManifestSupportsScreens_normalScreens
* android:normalScreens}.
*/
public static final int FLAG_SUPPORTS_NORMAL_SCREENS = 1<<10;
/**
* Value for {@link #flags}: true when the application's window can be
* increased in size for larger screens. Corresponds to
* {@link android.R.styleable#AndroidManifestSupportsScreens_largeScreens
* android:largeScreens}.
*/
public static final int FLAG_SUPPORTS_LARGE_SCREENS = 1<<11;
/**
* Value for {@link #flags}: true when the application knows how to adjust
* its UI for different screen sizes. Corresponds to
* {@link android.R.styleable#AndroidManifestSupportsScreens_resizeable
* android:resizeable}.
*/
public static final int FLAG_RESIZEABLE_FOR_SCREENS = 1<<12;
/**
* Value for {@link #flags}: true when the application knows how to
* accomodate different screen densities. Corresponds to
* {@link android.R.styleable#AndroidManifestSupportsScreens_anyDensity
* android:anyDensity}.
*/
public static final int FLAG_SUPPORTS_SCREEN_DENSITIES = 1<<13;
/**
* Value for {@link #flags}: set to true if this application would like to
* request the VM to operate under the safe mode. Comes from
* {@link android.R.styleable#AndroidManifestApplication_vmSafeMode
* android:vmSafeMode} of the &lt;application&gt; tag.
*/
public static final int FLAG_VM_SAFE_MODE = 1<<14;
/**
* Value for {@link #flags}: set to <code>false</code> if the application does not wish
* to permit any OS-driven backups of its data; <code>true</code> otherwise.
*
* <p>Comes from the
* {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
* attribute of the &lt;application&gt; tag.
*/
public static final int FLAG_ALLOW_BACKUP = 1<<15;
/**
* Value for {@link #flags}: set to <code>false</code> if the application must be kept
* in memory following a full-system restore operation; <code>true</code> otherwise.
* Ordinarily, during a full system restore operation each application is shut down
* following execution of its agent's onRestore() method. Setting this attribute to
* <code>false</code> prevents this. Most applications will not need to set this attribute.
*
* <p>If
* {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
* is set to <code>false</code> or no
* {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
* is specified, this flag will be ignored.
*
* <p>Comes from the
* {@link android.R.styleable#AndroidManifestApplication_killAfterRestore android:killAfterRestore}
* attribute of the &lt;application&gt; tag.
*/
public static final int FLAG_KILL_AFTER_RESTORE = 1<<16;
/**
* Value for {@link #flags}: Set to <code>true</code> if the application's backup
* agent claims to be able to handle restore data even "from the future,"
* i.e. from versions of the application with a versionCode greater than
* the one currently installed on the device. <i>Use with caution!</i> By default
* this attribute is <code>false</code> and the Backup Manager will ensure that data
* from "future" versions of the application are never supplied during a restore operation.
*
* <p>If
* {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
* is set to <code>false</code> or no
* {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
* is specified, this flag will be ignored.
*
* <p>Comes from the
* {@link android.R.styleable#AndroidManifestApplication_restoreAnyVersion android:restoreAnyVersion}
* attribute of the &lt;application&gt; tag.
*/
public static final int FLAG_RESTORE_ANY_VERSION = 1<<17;
/**
* Value for {@link #flags}: Set to true if the application is
* currently installed on external/removable/unprotected storage. Such
* applications may not be available if their storage is not currently
* mounted. When the storage it is on is not available, it will look like
* the application has been uninstalled (its .apk is no longer available)
* but its persistent data is not removed.
*/
public static final int FLAG_EXTERNAL_STORAGE = 1<<18;
/**
* Value for {@link #flags}: true when the application's window can be
* increased in size for extra large screens. Corresponds to
* {@link android.R.styleable#AndroidManifestSupportsScreens_xlargeScreens
* android:xlargeScreens}.
*/
public static final int FLAG_SUPPORTS_XLARGE_SCREENS = 1<<19;
/**
* Value for {@link #flags}: true when the application has requested a
* large heap for its processes. Corresponds to
* {@link android.R.styleable#AndroidManifestApplication_largeHeap
* android:largeHeap}.
*/
public static final int FLAG_LARGE_HEAP = 1<<20;
/**
* Value for {@link #flags}: true if this application's package is in
* the stopped state.
*/
public static final int FLAG_STOPPED = 1<<21;
/**
* Value for {@link #flags}: true when the application is willing to support
* RTL (right to left). All activities will inherit this value.
*
* Set from the {@link android.R.attr#supportsRtl} attribute in the
* activity's manifest.
*
* Default value is false (no support for RTL).
*/
public static final int FLAG_SUPPORTS_RTL = 1<<22;
/**
* Value for {@link #flags}: true if the application is currently
* installed for the calling user.
*/
public static final int FLAG_INSTALLED = 1<<23;
/**
* Value for {@link #flags}: true if the application only has its
* data installed; the application package itself does not currently
* exist on the device.
*/
public static final int FLAG_IS_DATA_ONLY = 1<<24;
/**
* Value for {@link #flags}: true if the application was declared to be a game, or
* false if it is a non-game application.
*/
public static final int FLAG_IS_GAME = 1<<25;
/**
* Value for {@link #flags}: {@code true} if the application asks that only
* full-data streaming backups of its data be performed even though it defines
* a {@link android.app.backup.BackupAgent BackupAgent}, which normally
* indicates that the app will manage its backed-up data via incremental
* key/value updates.
*/
public static final int FLAG_FULL_BACKUP_ONLY = 1<<26;
/**
* Value for {@link #flags}: {@code true} if the application may use cleartext network traffic
* (e.g., HTTP rather than HTTPS; WebSockets rather than WebSockets Secure; XMPP, IMAP, STMP
* without STARTTLS or TLS). If {@code false}, the app declares that it does not intend to use
* cleartext network traffic, in which case platform components (e.g., HTTP stacks,
* {@code DownloadManager}, {@code MediaPlayer}) will refuse app's requests to use cleartext
* traffic. Third-party libraries are encouraged to honor this flag as well.
*
* <p>NOTE: {@code WebView} does not honor this flag.
*
* <p>This flag is ignored on Android N and above if an Android Network Security Config is
* present.
*
* <p>This flag comes from
* {@link android.R.styleable#AndroidManifestApplication_usesCleartextTraffic
* android:usesCleartextTraffic} of the &lt;application&gt; tag.
*/
public static final int FLAG_USES_CLEARTEXT_TRAFFIC = 1<<27;
/**
* When set installer extracts native libs from .apk files.
*/
public static final int FLAG_EXTRACT_NATIVE_LIBS = 1<<28;
/**
* Value for {@link #flags}: {@code true} when the application's rendering
* should be hardware accelerated.
*/
public static final int FLAG_HARDWARE_ACCELERATED = 1<<29;
/**
* Value for {@link #flags}: true if this application's package is in
* the suspended state.
*/
public static final int FLAG_SUSPENDED = 1<<30;
/**
* Value for {@link #flags}: true if code from this application will need to be
* loaded into other applications' processes. On devices that support multiple
* instruction sets, this implies the code might be loaded into a process that's
* using any of the devices supported instruction sets.
*
* <p> The system might treat such applications specially, for eg., by
* extracting the application's native libraries for all supported instruction
* sets or by compiling the application's dex code for all supported instruction
* sets.
*/
public static final int FLAG_MULTIARCH = 1 << 31;
/**
* Flags associated with the application. Any combination of
* {@link #FLAG_SYSTEM}, {@link #FLAG_DEBUGGABLE}, {@link #FLAG_HAS_CODE},
* {@link #FLAG_PERSISTENT}, {@link #FLAG_FACTORY_TEST}, and
* {@link #FLAG_ALLOW_TASK_REPARENTING}
* {@link #FLAG_ALLOW_CLEAR_USER_DATA}, {@link #FLAG_UPDATED_SYSTEM_APP},
* {@link #FLAG_TEST_ONLY}, {@link #FLAG_SUPPORTS_SMALL_SCREENS},
* {@link #FLAG_SUPPORTS_NORMAL_SCREENS},
* {@link #FLAG_SUPPORTS_LARGE_SCREENS}, {@link #FLAG_SUPPORTS_XLARGE_SCREENS},
* {@link #FLAG_RESIZEABLE_FOR_SCREENS},
* {@link #FLAG_SUPPORTS_SCREEN_DENSITIES}, {@link #FLAG_VM_SAFE_MODE},
* {@link #FLAG_ALLOW_BACKUP}, {@link #FLAG_KILL_AFTER_RESTORE},
* {@link #FLAG_RESTORE_ANY_VERSION}, {@link #FLAG_EXTERNAL_STORAGE},
* {@link #FLAG_LARGE_HEAP}, {@link #FLAG_STOPPED},
* {@link #FLAG_SUPPORTS_RTL}, {@link #FLAG_INSTALLED},
* {@link #FLAG_IS_DATA_ONLY}, {@link #FLAG_IS_GAME},
* {@link #FLAG_FULL_BACKUP_ONLY}, {@link #FLAG_USES_CLEARTEXT_TRAFFIC},
* {@link #FLAG_MULTIARCH}.
*/
public int flags = 0;
/**
* Value for {@link #privateFlags}: true if the application is hidden via restrictions and for
* most purposes is considered as not installed.
* {@hide}
*/
public static final int PRIVATE_FLAG_HIDDEN = 1<<0;
/**
* Value for {@link #privateFlags}: set to <code>true</code> if the application
* has reported that it is heavy-weight, and thus can not participate in
* the normal application lifecycle.
*
* <p>Comes from the
* android.R.styleable#AndroidManifestApplication_cantSaveState
* attribute of the &lt;application&gt; tag.
*
* {@hide}
*/
public static final int PRIVATE_FLAG_CANT_SAVE_STATE = 1<<1;
/**
* Value for {@link #privateFlags}: Set to true if the application has been
* installed using the forward lock option.
*
* NOTE: DO NOT CHANGE THIS VALUE! It is saved in packages.xml.
*
* {@hide}
*/
public static final int PRIVATE_FLAG_FORWARD_LOCK = 1<<2;
/**
* Value for {@link #privateFlags}: set to {@code true} if the application
* is permitted to hold privileged permissions.
*
* {@hide}
*/
public static final int PRIVATE_FLAG_PRIVILEGED = 1<<3;
/**
* Value for {@link #privateFlags}: {@code true} if the application has any IntentFiler
* with some data URI using HTTP or HTTPS with an associated VIEW action.
*
* {@hide}
*/
public static final int PRIVATE_FLAG_HAS_DOMAIN_URLS = 1<<4;
/**
* When set, the default data storage directory for this app is pointed at
* the device-protected location.
*
* @hide
*/
public static final int PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE = 1 << 5;
/**
* When set, assume that all components under the given app are direct boot
* aware, unless otherwise specified.
*
* @hide
*/
public static final int PRIVATE_FLAG_DIRECT_BOOT_AWARE = 1 << 6;
/**
* Value for {@link #privateFlags}: set to {@code true} if the application
* is AutoPlay.
*
* {@hide}
*/
public static final int PRIVATE_FLAG_AUTOPLAY = 1 << 7;
/**
* When set, at least one component inside this application is direct boot
* aware.
*
* @hide
*/
public static final int PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE = 1 << 8;
/**
* Value for {@link #flags}: {@code true} if the application is blocked via restrictions
* and for most purposes is considered as not installed.
* {@hide}
*/
public static final int PRIVATE_FLAG_EPHEMERAL = 1 << 9;
/**
* When set, signals that the application is required for the system user and should not be
* uninstalled.
*
* @hide
*/
public static final int PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER = 1 << 10;
/**
* When set, the activities associated with this application are resizeable by default.
* @see android.R.styleable#AndroidManifestActivity_resizeableActivity
*
* @hide
*/
public static final int PRIVATE_FLAG_RESIZEABLE_ACTIVITIES = 1 << 11;
/**
* Value for {@link #privateFlags}: {@code true} means the OS should go ahead and
* run full-data backup operations for the app even when it is in a
* foreground-equivalent run state. Defaults to {@code false} if unspecified.
* @hide
*/
public static final int PRIVATE_FLAG_BACKUP_IN_FOREGROUND = 1 << 12;
/**
* Private/hidden flags. See {@code PRIVATE_FLAG_...} constants.
* {@hide}
*/
public int privateFlags;
/**
* The required smallest screen width the application can run on. If 0,
* nothing has been specified. Comes from
* {@link android.R.styleable#AndroidManifestSupportsScreens_requiresSmallestWidthDp
* android:requiresSmallestWidthDp} attribute of the &lt;supports-screens&gt; tag.
*/
public int requiresSmallestWidthDp = 0;
/**
* The maximum smallest screen width the application is designed for. If 0,
* nothing has been specified. Comes from
* {@link android.R.styleable#AndroidManifestSupportsScreens_compatibleWidthLimitDp
* android:compatibleWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
*/
public int compatibleWidthLimitDp = 0;
/**
* The maximum smallest screen width the application will work on. If 0,
* nothing has been specified. Comes from
* {@link android.R.styleable#AndroidManifestSupportsScreens_largestWidthLimitDp
* android:largestWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
*/
public int largestWidthLimitDp = 0;
/** {@hide} */
public String volumeUuid;
/** {@hide} */
public String scanSourceDir;
/** {@hide} */
public String scanPublicSourceDir;
/**
* Full path to the base APK for this application.
*/
public String sourceDir;
/**
* Full path to the publicly available parts of {@link #sourceDir},
* including resources and manifest. This may be different from
* {@link #sourceDir} if an application is forward locked.
*/
public String publicSourceDir;
/**
* Full paths to zero or more split APKs that, when combined with the base
* APK defined in {@link #sourceDir}, form a complete application.
*/
public String[] splitSourceDirs;
/**
* Full path to the publicly available parts of {@link #splitSourceDirs},
* including resources and manifest. This may be different from
* {@link #splitSourceDirs} if an application is forward locked.
*/
public String[] splitPublicSourceDirs;
/**
* Full paths to the locations of extra resource packages this application
* uses. This field is only used if there are extra resource packages,
* otherwise it is null.
*
* {@hide}
*/
public String[] resourceDirs;
/**
* String retrieved from the seinfo tag found in selinux policy. This value
* can be overridden with a value set through the mac_permissions.xml policy
* construct. This value is useful in setting an SELinux security context on
* the process as well as its data directory. The String default is being used
* here to represent a catchall label when no policy matches.
*
* {@hide}
*/
public String seinfo = "default";
/**
* Paths to all shared libraries this application is linked against. This
* field is only set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
* PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving
* the structure.
*/
public String[] sharedLibraryFiles;
/**
* Full path to the default directory assigned to the package for its
* persistent data.
*/
public String dataDir;
/**
* Full path to the device-protected directory assigned to the package for
* its persistent data.
*
* @see Context#createDeviceProtectedStorageContext()
*/
public String deviceProtectedDataDir;
/** @removed */
@Deprecated
public String deviceEncryptedDataDir;
/**
* Full path to the credential-protected directory assigned to the package
* for its persistent data.
*
* @hide
*/
@SystemApi
public String credentialProtectedDataDir;
/** @removed */
@Deprecated
public String credentialEncryptedDataDir;
/**
* Full path to the directory where native JNI libraries are stored.
*/
public String nativeLibraryDir;
/**
* Full path where unpacked native libraries for {@link #secondaryCpuAbi}
* are stored, if present.
*
* The main reason this exists is for bundled multi-arch apps, where
* it's not trivial to calculate the location of libs for the secondary abi
* given the location of the primary.
*
* TODO: Change the layout of bundled installs so that we can use
* nativeLibraryRootDir & nativeLibraryRootRequiresIsa there as well.
* (e.g {@code [ "/system/app-lib/Foo/arm", "/system/app-lib/Foo/arm64" ]}
* instead of {@code [ "/system/lib/Foo", "/system/lib64/Foo" ]}.
*
* @hide
*/
public String secondaryNativeLibraryDir;
/**
* The root path where unpacked native libraries are stored.
* <p>
* When {@link #nativeLibraryRootRequiresIsa} is set, the libraries are
* placed in ISA-specific subdirectories under this path, otherwise the
* libraries are placed directly at this path.
*
* @hide
*/
public String nativeLibraryRootDir;
/**
* Flag indicating that ISA must be appended to
* {@link #nativeLibraryRootDir} to be useful.
*
* @hide
*/
public boolean nativeLibraryRootRequiresIsa;
/**
* The primary ABI that this application requires, This is inferred from the ABIs
* of the native JNI libraries the application bundles. Will be {@code null}
* if this application does not require any particular ABI.
*
* If non-null, the application will always be launched with this ABI.
*
* {@hide}
*/
public String primaryCpuAbi;
/**
* The secondary ABI for this application. Might be non-null for multi-arch
* installs. The application itself never uses this ABI, but other applications that
* use its code might.
*
* {@hide}
*/
public String secondaryCpuAbi;
/**
* The kernel user-ID that has been assigned to this application;
* currently this is not a unique ID (multiple applications can have
* the same uid).
*/
public int uid;
/**
* The minimum SDK version this application can run on. It will not run
* on earlier versions.
*/
public int minSdkVersion;
/**
* The minimum SDK version this application targets. It may run on earlier
* versions, but it knows how to work with any new behavior added at this
* version. Will be {@link android.os.Build.VERSION_CODES#CUR_DEVELOPMENT}
* if this is a development build and the app is targeting that. You should
* compare that this number is >= the SDK version number at which your
* behavior was introduced.
*/
public int targetSdkVersion;
/**
* The app's declared version code.
* @hide
*/
public int versionCode;
/**
* When false, indicates that all components within this application are
* considered disabled, regardless of their individually set enabled status.
*/
public boolean enabled = true;
/**
* For convenient access to the current enabled setting of this app.
* @hide
*/
public int enabledSetting = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
/**
* For convenient access to package's install location.
* @hide
*/
public int installLocation = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
/**
* Resource file providing the application's Network Security Config.
* @hide
*/
public int networkSecurityConfigRes;
/**
* @return true if "supportsRtl" has been set to true in the AndroidManifest
* @hide
*/
public boolean hasRtlSupport() {
return (flags & FLAG_SUPPORTS_RTL) == FLAG_SUPPORTS_RTL;
}
/** {@hide} */
public boolean hasCode() {
return (flags & FLAG_HAS_CODE) != 0;
}
public static class DisplayNameComparator
implements Comparator<ApplicationInfo> {
public DisplayNameComparator(PackageManager pm) {
mPM = pm;
}
public final int compare(ApplicationInfo aa, ApplicationInfo ab) {
CharSequence sa = mPM.getApplicationLabel(aa);
if (sa == null) {
sa = aa.packageName;
}
CharSequence sb = mPM.getApplicationLabel(ab);
if (sb == null) {
sb = ab.packageName;
}
return sCollator.compare(sa.toString(), sb.toString());
}
private final Collator sCollator = Collator.getInstance();
private PackageManager mPM;
}
public ApplicationInfo() {
}
public ApplicationInfo(ApplicationInfo orig) {
super(orig);
taskAffinity = orig.taskAffinity;
permission = orig.permission;
processName = orig.processName;
className = orig.className;
theme = orig.theme;
flags = orig.flags;
privateFlags = orig.privateFlags;
requiresSmallestWidthDp = orig.requiresSmallestWidthDp;
compatibleWidthLimitDp = orig.compatibleWidthLimitDp;
largestWidthLimitDp = orig.largestWidthLimitDp;
volumeUuid = orig.volumeUuid;
scanSourceDir = orig.scanSourceDir;
scanPublicSourceDir = orig.scanPublicSourceDir;
sourceDir = orig.sourceDir;
publicSourceDir = orig.publicSourceDir;
splitSourceDirs = orig.splitSourceDirs;
splitPublicSourceDirs = orig.splitPublicSourceDirs;
nativeLibraryDir = orig.nativeLibraryDir;
secondaryNativeLibraryDir = orig.secondaryNativeLibraryDir;
nativeLibraryRootDir = orig.nativeLibraryRootDir;
nativeLibraryRootRequiresIsa = orig.nativeLibraryRootRequiresIsa;
primaryCpuAbi = orig.primaryCpuAbi;
secondaryCpuAbi = orig.secondaryCpuAbi;
resourceDirs = orig.resourceDirs;
seinfo = orig.seinfo;
sharedLibraryFiles = orig.sharedLibraryFiles;
dataDir = orig.dataDir;
deviceEncryptedDataDir = deviceProtectedDataDir = orig.deviceProtectedDataDir;
credentialEncryptedDataDir = credentialProtectedDataDir = orig.credentialProtectedDataDir;
uid = orig.uid;
minSdkVersion = orig.minSdkVersion;
targetSdkVersion = orig.targetSdkVersion;
versionCode = orig.versionCode;
enabled = orig.enabled;
enabledSetting = orig.enabledSetting;
installLocation = orig.installLocation;
manageSpaceActivityName = orig.manageSpaceActivityName;
descriptionRes = orig.descriptionRes;
uiOptions = orig.uiOptions;
backupAgentName = orig.backupAgentName;
fullBackupContent = orig.fullBackupContent;
networkSecurityConfigRes = orig.networkSecurityConfigRes;
}
public String toString() {
return "ApplicationInfo{"
+ Integer.toHexString(System.identityHashCode(this))
+ " " + packageName + "}";
}
public int describeContents() {
return 0;
}
public void writeToParcel(Parcel dest, int parcelableFlags) {
super.writeToParcel(dest, parcelableFlags);
dest.writeString(taskAffinity);
dest.writeString(permission);
dest.writeString(processName);
dest.writeString(className);
dest.writeInt(theme);
dest.writeInt(flags);
dest.writeInt(privateFlags);
dest.writeInt(requiresSmallestWidthDp);
dest.writeInt(compatibleWidthLimitDp);
dest.writeInt(largestWidthLimitDp);
dest.writeString(volumeUuid);
dest.writeString(scanSourceDir);
dest.writeString(scanPublicSourceDir);
dest.writeString(sourceDir);
dest.writeString(publicSourceDir);
dest.writeStringArray(splitSourceDirs);
dest.writeStringArray(splitPublicSourceDirs);
dest.writeString(nativeLibraryDir);
dest.writeString(secondaryNativeLibraryDir);
dest.writeString(nativeLibraryRootDir);
dest.writeInt(nativeLibraryRootRequiresIsa ? 1 : 0);
dest.writeString(primaryCpuAbi);
dest.writeString(secondaryCpuAbi);
dest.writeStringArray(resourceDirs);
dest.writeString(seinfo);
dest.writeStringArray(sharedLibraryFiles);
dest.writeString(dataDir);
dest.writeString(deviceProtectedDataDir);
dest.writeString(credentialProtectedDataDir);
dest.writeInt(uid);
dest.writeInt(minSdkVersion);
dest.writeInt(targetSdkVersion);
dest.writeInt(versionCode);
dest.writeInt(enabled ? 1 : 0);
dest.writeInt(enabledSetting);
dest.writeInt(installLocation);
dest.writeString(manageSpaceActivityName);
dest.writeString(backupAgentName);
dest.writeInt(descriptionRes);
dest.writeInt(uiOptions);
dest.writeInt(fullBackupContent);
dest.writeInt(networkSecurityConfigRes);
}
public static final Parcelable.Creator<ApplicationInfo> CREATOR
= new Parcelable.Creator<ApplicationInfo>() {
public ApplicationInfo createFromParcel(Parcel source) {
return new ApplicationInfo(source);
}
public ApplicationInfo[] newArray(int size) {
return new ApplicationInfo[size];
}
};
private ApplicationInfo(Parcel source) {
super(source);
taskAffinity = source.readString();
permission = source.readString();
processName = source.readString();
className = source.readString();
theme = source.readInt();
flags = source.readInt();
privateFlags = source.readInt();
requiresSmallestWidthDp = source.readInt();
compatibleWidthLimitDp = source.readInt();
largestWidthLimitDp = source.readInt();
volumeUuid = source.readString();
scanSourceDir = source.readString();
scanPublicSourceDir = source.readString();
sourceDir = source.readString();
publicSourceDir = source.readString();
nativeLibraryDir = source.readString();
secondaryNativeLibraryDir = source.readString();
nativeLibraryRootDir = source.readString();
nativeLibraryRootRequiresIsa = source.readInt() != 0;
primaryCpuAbi = source.readString();
secondaryCpuAbi = source.readString();
seinfo = source.readString();
dataDir = source.readString();
deviceEncryptedDataDir = deviceProtectedDataDir = source.readString();
credentialEncryptedDataDir = credentialProtectedDataDir = source.readString();
uid = source.readInt();
minSdkVersion = source.readInt();
targetSdkVersion = source.readInt();
versionCode = source.readInt();
enabled = source.readInt() != 0;
enabledSetting = source.readInt();
installLocation = source.readInt();
manageSpaceActivityName = source.readString();
backupAgentName = source.readString();
descriptionRes = source.readInt();
uiOptions = source.readInt();
fullBackupContent = source.readInt();
networkSecurityConfigRes = source.readInt();
}
/**
* Retrieve the textual description of the application. This
* will call back on the given PackageManager to load the description from
* the application.
*
* @param pm A PackageManager from which the label can be loaded; usually
* the PackageManager from which you originally retrieved this item.
*
* @return Returns a CharSequence containing the application's description.
* If there is no description, null is returned.
*/
public CharSequence loadDescription(PackageManager pm) {
if (descriptionRes != 0) {
CharSequence label = pm.getText(packageName, descriptionRes, this);
if (label != null) {
return label;
}
}
return null;
}
/**
* Disable compatibility mode
*
* @hide
*/
public void disableCompatibilityMode() {
flags |= (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS);
}
private boolean isPackageUnavailable(PackageManager pm) {
try {
return pm.getPackageInfo(packageName, 0) == null;
} catch (NameNotFoundException ex) {
return true;
}
}
/**
* @hide
*/
public boolean isForwardLocked() {
return (privateFlags & ApplicationInfo.PRIVATE_FLAG_FORWARD_LOCK) != 0;
}
/**
* @hide
*/
@TestApi
public boolean isSystemApp() {
return (flags & ApplicationInfo.FLAG_SYSTEM) != 0;
}
/**
* @hide
*/
@TestApi
public boolean isPrivilegedApp() {
return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0;
}
/**
* @hide
*/
public boolean isUpdatedSystemApp() {
return (flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
}
/** @hide */
public boolean isInternal() {
return (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) == 0;
}
/** @hide */
public boolean isExternalAsec() {
return TextUtils.isEmpty(volumeUuid)
&& (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0;
}
/** @hide */
public boolean isDefaultToDeviceProtectedStorage() {
return (privateFlags
& ApplicationInfo.PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) != 0;
}
/** @hide */
public boolean isDirectBootAware() {
return (privateFlags & ApplicationInfo.PRIVATE_FLAG_DIRECT_BOOT_AWARE) != 0;
}
/** @hide */
public boolean isPartiallyDirectBootAware() {
return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE) != 0;
}
/**
* @hide
*/
public boolean isAutoPlayApp() {
return (privateFlags & ApplicationInfo.PRIVATE_FLAG_AUTOPLAY) != 0;
}
/**
* @hide
*/
public boolean isEphemeralApp() {
return (privateFlags & ApplicationInfo.PRIVATE_FLAG_EPHEMERAL) != 0;
}
/**
* @hide
*/
public boolean isRequiredForSystemUser() {
return (privateFlags & ApplicationInfo.PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER) != 0;
}
/**
* @hide
*/
protected ApplicationInfo getApplicationInfo() {
return this;
}
/** {@hide} */ public void setCodePath(String codePath) { scanSourceDir = codePath; }
/** {@hide} */ public void setBaseCodePath(String baseCodePath) { sourceDir = baseCodePath; }
/** {@hide} */ public void setSplitCodePaths(String[] splitCodePaths) { splitSourceDirs = splitCodePaths; }
/** {@hide} */ public void setResourcePath(String resourcePath) { scanPublicSourceDir = resourcePath; }
/** {@hide} */ public void setBaseResourcePath(String baseResourcePath) { publicSourceDir = baseResourcePath; }
/** {@hide} */ public void setSplitResourcePaths(String[] splitResourcePaths) { splitPublicSourceDirs = splitResourcePaths; }
/** {@hide} */ public String getCodePath() { return scanSourceDir; }
/** {@hide} */ public String getBaseCodePath() { return sourceDir; }
/** {@hide} */ public String[] getSplitCodePaths() { return splitSourceDirs; }
/** {@hide} */ public String getResourcePath() { return scanPublicSourceDir; }
/** {@hide} */ public String getBaseResourcePath() { return publicSourceDir; }
/** {@hide} */ public String[] getSplitResourcePaths() { return splitSourceDirs; }
}
@@ -0,0 +1,132 @@
/*
* Copyright (C) 2009 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.content.pm;
import android.os.Parcel;
import android.os.Parcelable;
/**
* Definition of a single optional hardware or software feature of an Android
* device.
* <p>
* This object is used to represent both features supported by a device and
* features requested by an app. Apps can request that certain features be
* available as a prerequisite to being installed through the
* {@code uses-feature} tag in their manifests.
* <p>
* Starting in {@link android.os.Build.VERSION_CODES#N}, features can have a
* version, which must always be backwards compatible. That is, a device
* claiming to support version 3 of a specific feature must support apps
* requesting version 1 of that feature.
*/
public class FeatureInfo implements Parcelable {
/**
* 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;
/**
* If this object represents a feature supported by a device, this is the
* maximum version of this feature supported by the device. The device
* implicitly supports all older versions of this feature.
* <p>
* If this object represents a feature requested by an app, this is the
* minimum version of the feature required by the app.
* <p>
* When a feature version is undefined by a device, it's assumed to be
* version 0.
*/
public int version;
/**
* 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;
/**
* 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() {
}
public FeatureInfo(FeatureInfo orig) {
name = orig.name;
version = orig.version;
reqGlEsVersion = orig.reqGlEsVersion;
flags = orig.flags;
}
@Override
public String toString() {
if (name != null) {
return "FeatureInfo{"
+ Integer.toHexString(System.identityHashCode(this))
+ " " + name + " v=" + version + " fl=0x" + Integer.toHexString(flags) + "}";
} else {
return "FeatureInfo{"
+ Integer.toHexString(System.identityHashCode(this))
+ " glEsVers=" + getGlEsVersion()
+ " fl=0x" + Integer.toHexString(flags) + "}";
}
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int parcelableFlags) {
dest.writeString(name);
dest.writeInt(version);
dest.writeInt(reqGlEsVersion);
dest.writeInt(flags);
}
public static final Creator<FeatureInfo> CREATOR = new Creator<FeatureInfo>() {
@Override
public FeatureInfo createFromParcel(Parcel source) {
return new FeatureInfo(source);
}
@Override
public FeatureInfo[] newArray(int size) {
return new FeatureInfo[size];
}
};
private FeatureInfo(Parcel source) {
name = source.readString();
version = source.readInt();
reqGlEsVersion = source.readInt();
flags = source.readInt();
}
/**
* 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);
}
}
@@ -0,0 +1,127 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.content.pm;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;
import kotlin.NotImplementedError;
/**
* This class represents the state of an instant app. Instant apps can
* be installed or uninstalled. If the app is installed you can call
* {@link #getApplicationInfo()} to get the app info, otherwise this
* class provides APIs to get basic app info for showing it in the UI,
* such as permissions, label, package name.
*
* @hide
*/
@SystemApi
public final class InstantAppInfo implements Parcelable {
private final ApplicationInfo mApplicationInfo;
private final String mPackageName;
private final CharSequence mLabelText;
private final String[] mRequestedPermissions;
private final String[] mGrantedPermissions;
public InstantAppInfo(ApplicationInfo appInfo,
String[] requestedPermissions, String[] grantedPermissions) {
mApplicationInfo = appInfo;
mPackageName = null;
mLabelText = null;
mRequestedPermissions = requestedPermissions;
mGrantedPermissions = grantedPermissions;
}
public InstantAppInfo(String packageName, CharSequence label,
String[] requestedPermissions, String[] grantedPermissions) {
mApplicationInfo = null;
mPackageName = packageName;
mLabelText = label;
mRequestedPermissions = requestedPermissions;
mGrantedPermissions = grantedPermissions;
}
private InstantAppInfo(Parcel parcel) {
throw new NotImplementedError();
}
/**
* @return The application info if the app is installed,
* <code>null</code> otherwise,
*/
public @Nullable ApplicationInfo getApplicationInfo() {
return mApplicationInfo;
}
/**
* @return The package name.
*/
public @NonNull String getPackageName() {
if (mApplicationInfo != null) {
return mApplicationInfo.packageName;
}
return mPackageName;
}
/**
* @param packageManager Package manager for loading resources.
* @return Loads the label if the app is installed or returns the cached one otherwise.
*/
public @NonNull CharSequence loadLabel(@NonNull PackageManager packageManager) {
if (mApplicationInfo != null) {
return mApplicationInfo.loadLabel(packageManager);
}
return mLabelText;
}
/**
* @param packageManager Package manager for loading resources.
* @return Loads the icon if the app is installed or returns the cached one otherwise.
*/
public @NonNull Drawable loadIcon(@NonNull PackageManager packageManager) {
if (mApplicationInfo != null) {
return mApplicationInfo.loadIcon(packageManager);
}
return packageManager.getInstantAppIcon(mPackageName);
}
/**
* @return The requested permissions.
*/
public @Nullable String[] getRequestedPermissions() {
return mRequestedPermissions;
}
/**
* @return The granted permissions.
*/
public @Nullable String[] getGrantedPermissions() {
return mGrantedPermissions;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int flags) {
throw new NotImplementedError();
}
public static final Creator<InstantAppInfo> CREATOR =
new Creator<InstantAppInfo>() {
@Override
public InstantAppInfo createFromParcel(Parcel parcel) {
return new InstantAppInfo(parcel);
}
@Override
public InstantAppInfo[] newArray(int size) {
return new InstantAppInfo[0];
}
};
}
@@ -0,0 +1,223 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.content.pm;
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED;
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK;
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS;
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK;
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER;
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.ArraySet;
import android.util.Log;
import com.android.internal.util.XmlUtils;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlSerializer;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Set;
/**
* The {@link com.android.server.pm.PackageManagerService} maintains some
* {@link IntentFilterVerificationInfo}s for each domain / package name.
*
* @hide
*/
@SystemApi
public final class IntentFilterVerificationInfo implements Parcelable {
private static final String TAG = IntentFilterVerificationInfo.class.getName();
private static final String TAG_DOMAIN = "domain";
private static final String ATTR_DOMAIN_NAME = "name";
private static final String ATTR_PACKAGE_NAME = "packageName";
private static final String ATTR_STATUS = "status";
private ArraySet<String> mDomains = new ArraySet<>();
private String mPackageName;
private int mMainStatus;
/** @hide */
public IntentFilterVerificationInfo() {
mPackageName = null;
mMainStatus = INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED;
}
/** @hide */
public IntentFilterVerificationInfo(String packageName, ArraySet<String> domains) {
mPackageName = packageName;
mDomains = domains;
mMainStatus = INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED;
}
/** @hide */
public IntentFilterVerificationInfo(XmlPullParser parser)
throws IOException, XmlPullParserException {
readFromXml(parser);
}
/** @hide */
public IntentFilterVerificationInfo(Parcel source) {
readFromParcel(source);
}
public String getPackageName() {
return mPackageName;
}
public int getStatus() {
return mMainStatus;
}
/** @hide */
public void setStatus(int s) {
if (s >= INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED &&
s <= INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER) {
mMainStatus = s;
} else {
Log.w(TAG, "Trying to set a non supported status: " + s);
}
}
public Set<String> getDomains() {
return mDomains;
}
/** @hide */
public void setDomains(ArraySet<String> list) {
mDomains = list;
}
/** @hide */
public String getDomainsString() {
StringBuilder sb = new StringBuilder();
for (String str : mDomains) {
if (sb.length() > 0) {
sb.append(" ");
}
sb.append(str);
}
return sb.toString();
}
String getStringFromXml(XmlPullParser parser, String attribute, String defaultValue) {
String value = parser.getAttributeValue(null, attribute);
if (value == null) {
String msg = "Missing element under " + TAG +": " + attribute + " at " +
parser.getPositionDescription();
Log.w(TAG, msg);
return defaultValue;
} else {
return value;
}
}
int getIntFromXml(XmlPullParser parser, String attribute, int defaultValue) {
String value = parser.getAttributeValue(null, attribute);
if (TextUtils.isEmpty(value)) {
String msg = "Missing element under " + TAG +": " + attribute + " at " +
parser.getPositionDescription();
Log.w(TAG, msg);
return defaultValue;
} else {
return Integer.parseInt(value);
}
}
/** @hide */
public void readFromXml(XmlPullParser parser) throws XmlPullParserException,
IOException {
mPackageName = getStringFromXml(parser, ATTR_PACKAGE_NAME, null);
if (mPackageName == null) {
Log.e(TAG, "Package name cannot be null!");
}
int status = getIntFromXml(parser, ATTR_STATUS, -1);
if (status == -1) {
Log.e(TAG, "Unknown status value: " + status);
}
mMainStatus = status;
int outerDepth = parser.getDepth();
int type;
while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
&& (type != XmlPullParser.END_TAG
|| parser.getDepth() > outerDepth)) {
if (type == XmlPullParser.END_TAG
|| type == XmlPullParser.TEXT) {
continue;
}
String tagName = parser.getName();
if (tagName.equals(TAG_DOMAIN)) {
String name = getStringFromXml(parser, ATTR_DOMAIN_NAME, null);
if (!TextUtils.isEmpty(name)) {
mDomains.add(name);
}
} else {
Log.w(TAG, "Unknown tag parsing IntentFilter: " + tagName);
}
XmlUtils.skipCurrentTag(parser);
}
}
/** @hide */
public void writeToXml(XmlSerializer serializer) throws IOException {
serializer.attribute(null, ATTR_PACKAGE_NAME, mPackageName);
serializer.attribute(null, ATTR_STATUS, String.valueOf(mMainStatus));
for (String str : mDomains) {
serializer.startTag(null, TAG_DOMAIN);
serializer.attribute(null, ATTR_DOMAIN_NAME, str);
serializer.endTag(null, TAG_DOMAIN);
}
}
/** @hide */
public String getStatusString() {
return getStatusStringFromValue(((long)mMainStatus) << 32);
}
/** @hide */
public static String getStatusStringFromValue(long val) {
StringBuilder sb = new StringBuilder();
switch ((int)(val >> 32)) {
case INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS:
sb.append("always : ");
sb.append(Long.toHexString(val & 0x00000000FFFFFFFF));
break;
case INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK:
sb.append("ask");
break;
case INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER:
sb.append("never");
break;
case INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK:
sb.append("always-ask");
break;
case INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED:
default:
sb.append("undefined");
break;
}
return sb.toString();
}
@Override
public int describeContents() {
return 0;
}
private void readFromParcel(Parcel source) {
mPackageName = source.readString();
mMainStatus = source.readInt();
ArrayList<String> list = new ArrayList<>();
source.readStringList(list);
mDomains.addAll(list);
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(mPackageName);
dest.writeInt(mMainStatus);
dest.writeStringList(new ArrayList<>(mDomains));
}
public static final Creator<IntentFilterVerificationInfo> CREATOR =
new Creator<IntentFilterVerificationInfo>() {
public IntentFilterVerificationInfo createFromParcel(Parcel source) {
return new IntentFilterVerificationInfo(source);
}
public IntentFilterVerificationInfo[] newArray(int size) {
return new IntentFilterVerificationInfo[size];
}
};
}
@@ -0,0 +1,95 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.content.pm;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
/**
* Represents a {@code KeySet} that has been declared in the AndroidManifest.xml
* file for the application. A {@code KeySet} can be used explicitly to
* represent a trust relationship with other applications on the device.
* @hide
*/
public class KeySet implements Parcelable {
private IBinder token;
/** @hide */
public KeySet(IBinder token) {
if (token == null) {
throw new NullPointerException("null value for KeySet IBinder token");
}
this.token = token;
}
/** @hide */
public IBinder getToken() {
return token;
}
/** @hide */
@Override
public boolean equals(Object o) {
if (o instanceof KeySet) {
KeySet ks = (KeySet) o;
return token == ks.token;
}
return false;
}
/** @hide */
@Override
public int hashCode() {
return token.hashCode();
}
/**
* Implement Parcelable
* @hide
*/
public static final Parcelable.Creator<KeySet> CREATOR
= new Parcelable.Creator<KeySet>() {
/**
* Create a KeySet from a Parcel
*
* @param source The parcel containing the KeySet
*/
public KeySet createFromParcel(Parcel source) {
return readFromParcel(source);
}
/**
* Create an array of null KeySets
*/
public KeySet[] newArray(int size) {
return new KeySet[size];
}
};
/**
* @hide
*/
private static KeySet readFromParcel(Parcel in) {
IBinder token = in.readStrongBinder();
return new KeySet(token);
}
/**
* @hide
*/
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeStrongBinder(token);
}
/**
* @hide
*/
@Override
public int describeContents() {
return 0;
}
}
@@ -0,0 +1,353 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.content.pm;
import android.os.Parcel;
import android.os.Parcelable;
/**
* Overall information about the contents of a package. This corresponds
* to all of the information collected from AndroidManifest.xml.
*/
public class PackageInfo implements Parcelable {
/**
* The name of this package. From the &lt;manifest&gt; tag's "name"
* attribute.
*/
public String packageName;
/**
* The names of any installed split APKs for this package.
*/
public String[] splitNames;
/**
* The version number of this package, as specified by the &lt;manifest&gt;
* tag's {@link android.R.styleable#AndroidManifest_versionCode versionCode}
* attribute.
*/
public int versionCode;
/**
* The version name of this package, as specified by the &lt;manifest&gt;
* tag's {@link android.R.styleable#AndroidManifest_versionName versionName}
* attribute.
*/
public String versionName;
/**
* The revision number of the base APK for this package, as specified by the
* &lt;manifest&gt; tag's
* {@link android.R.styleable#AndroidManifest_revisionCode revisionCode}
* attribute.
*/
public int baseRevisionCode;
/**
* The revision number of any split APKs for this package, as specified by
* the &lt;manifest&gt; tag's
* {@link android.R.styleable#AndroidManifest_revisionCode revisionCode}
* attribute. Indexes are a 1:1 mapping against {@link #splitNames}.
*/
public int[] splitRevisionCodes;
/**
* The shared user ID name of this package, as specified by the &lt;manifest&gt;
* tag's {@link android.R.styleable#AndroidManifest_sharedUserId sharedUserId}
* attribute.
*/
public String sharedUserId;
/**
* The shared user ID label of this package, as specified by the &lt;manifest&gt;
* tag's {@link android.R.styleable#AndroidManifest_sharedUserLabel sharedUserLabel}
* attribute.
*/
public int sharedUserLabel;
/**
* Information collected from the &lt;application&gt; tag, or null if
* there was none.
*/
public ApplicationInfo applicationInfo;
/**
* The time at which the app was first installed. Units are as
* per {@link System#currentTimeMillis()}.
*/
public long firstInstallTime;
/**
* The time at which the app was last updated. Units are as
* per {@link System#currentTimeMillis()}.
*/
public long lastUpdateTime;
/**
* 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;
/**
* Array of all {@link android.R.styleable#AndroidManifestActivity
* &lt;activity&gt;} tags included under &lt;application&gt;,
* or null if there were none. This is only filled in if the flag
* {@link PackageManager#GET_ACTIVITIES} was set.
*/
public ActivityInfo[] activities;
/**
* Array of all {@link android.R.styleable#AndroidManifestReceiver
* &lt;receiver&gt;} tags included under &lt;application&gt;,
* or null if there were none. This is only filled in if the flag
* {@link PackageManager#GET_RECEIVERS} was set.
*/
public ActivityInfo[] receivers;
/**
* Array of all {@link android.R.styleable#AndroidManifestService
* &lt;service&gt;} tags included under &lt;application&gt;,
* or null if there were none. This is only filled in if the flag
* {@link PackageManager#GET_SERVICES} was set.
*/
public ServiceInfo[] services;
/**
* Array of all {@link android.R.styleable#AndroidManifestProvider
* &lt;provider&gt;} tags included under &lt;application&gt;,
* or null if there were none. This is only filled in if the flag
* {@link PackageManager#GET_PROVIDERS} was set.
*/
public ProviderInfo[] providers;
/**
* Array of all {@link android.R.styleable#AndroidManifestInstrumentation
* &lt;instrumentation&gt;} tags included under &lt;manifest&gt;,
* or null if there were none. This is only filled in if the flag
* {@link PackageManager#GET_INSTRUMENTATION} was set.
*/
public InstrumentationInfo[] instrumentation;
/**
* Array of all {@link android.R.styleable#AndroidManifestPermission
* &lt;permission&gt;} tags included under &lt;manifest&gt;,
* or null if there were none. This is only filled in if the flag
* {@link PackageManager#GET_PERMISSIONS} was set.
*/
public PermissionInfo[] permissions;
/**
* Array of all {@link android.R.styleable#AndroidManifestUsesPermission
* &lt;uses-permission&gt;} tags included under &lt;manifest&gt;,
* or null if there were none. This is only filled in if the flag
* {@link PackageManager#GET_PERMISSIONS} was set. This list includes
* all permissions requested, even those that were not granted or known
* by the system at install time.
*/
public String[] requestedPermissions;
/**
* Array of flags of all {@link android.R.styleable#AndroidManifestUsesPermission
* &lt;uses-permission&gt;} tags included under &lt;manifest&gt;,
* or null if there were none. This is only filled in if the flag
* {@link PackageManager#GET_PERMISSIONS} was set. Each value matches
* the corresponding entry in {@link #requestedPermissions}, and will have
* the flag {@link #REQUESTED_PERMISSION_GRANTED} set as appropriate.
*/
public int[] requestedPermissionsFlags;
/**
* 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.
*
* @removed We do not support required permissions.
*/
public static final int REQUESTED_PERMISSION_REQUIRED = 1<<0;
/**
* 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 signatures read from the package file. This is only filled
* in if the flag {@link PackageManager#GET_SIGNATURES} was set.
*/
public Signature[] signatures;
/**
* Application specified preferred configuration
* {@link android.R.styleable#AndroidManifestUsesConfiguration
* &lt;uses-configuration&gt;} tags included under &lt;manifest&gt;,
* or null if there were none. This is only filled in if the flag
* {@link PackageManager#GET_CONFIGURATIONS} was set.
*/
public ConfigurationInfo[] configPreferences;
/**
* Features that this application has requested.
*
* @see FeatureInfo#FLAG_REQUIRED
*/
public FeatureInfo[] reqFeatures;
/**
* Groups of features that this application has requested.
* Each group contains a set of features that are required.
* A device must match the features listed in {@link #reqFeatures} and one
* or more FeatureGroups in order to have satisfied the feature requirement.
*
* @see FeatureInfo#FLAG_REQUIRED
*/
public FeatureGroupInfo[] featureGroups;
/**
* 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.
*/
public static final int INSTALL_LOCATION_AUTO = 0;
/**
* Constant corresponding to <code>internalOnly</code> in the
* {@link android.R.attr#installLocation} attribute.
*/
public static final int INSTALL_LOCATION_INTERNAL_ONLY = 1;
/**
* Constant corresponding to <code>preferExternal</code> in the
* {@link android.R.attr#installLocation} attribute.
*/
public static final int INSTALL_LOCATION_PREFER_EXTERNAL = 2;
/**
* The install location requested by the package. From the
* {@link android.R.attr#installLocation} attribute, one of
* {@link #INSTALL_LOCATION_AUTO}, {@link #INSTALL_LOCATION_INTERNAL_ONLY},
* {@link #INSTALL_LOCATION_PREFER_EXTERNAL}
*/
public int installLocation = INSTALL_LOCATION_INTERNAL_ONLY;
/** @hide */
public boolean coreApp;
/** @hide */
public boolean requiredForAllUsers;
/** @hide */
public String restrictedAccountType;
/** @hide */
public String requiredAccountType;
/**
* What package, if any, this package will overlay.
*
* Package name of target package, or null.
* @hide
*/
public String overlayTarget;
public PackageInfo() {
}
@Override
public String toString() {
return "PackageInfo{"
+ Integer.toHexString(System.identityHashCode(this))
+ " " + packageName + "}";
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int parcelableFlags) {
dest.writeString(packageName);
dest.writeStringArray(splitNames);
dest.writeInt(versionCode);
dest.writeString(versionName);
dest.writeInt(baseRevisionCode);
dest.writeIntArray(splitRevisionCodes);
dest.writeString(sharedUserId);
dest.writeInt(sharedUserLabel);
if (applicationInfo != null) {
dest.writeInt(1);
applicationInfo.writeToParcel(dest, parcelableFlags);
} else {
dest.writeInt(0);
}
dest.writeLong(firstInstallTime);
dest.writeLong(lastUpdateTime);
dest.writeIntArray(gids);
dest.writeTypedArray(activities, parcelableFlags | Parcelable.PARCELABLE_ELIDE_DUPLICATES);
dest.writeTypedArray(receivers, parcelableFlags | Parcelable.PARCELABLE_ELIDE_DUPLICATES);
dest.writeTypedArray(services, parcelableFlags | Parcelable.PARCELABLE_ELIDE_DUPLICATES);
dest.writeTypedArray(providers, parcelableFlags | Parcelable.PARCELABLE_ELIDE_DUPLICATES);
dest.writeTypedArray(instrumentation, parcelableFlags);
dest.writeTypedArray(permissions, parcelableFlags);
dest.writeStringArray(requestedPermissions);
dest.writeIntArray(requestedPermissionsFlags);
dest.writeTypedArray(signatures, parcelableFlags);
dest.writeTypedArray(configPreferences, parcelableFlags);
dest.writeTypedArray(reqFeatures, parcelableFlags);
dest.writeTypedArray(featureGroups, parcelableFlags);
dest.writeInt(installLocation);
dest.writeInt(coreApp ? 1 : 0);
dest.writeInt(requiredForAllUsers ? 1 : 0);
dest.writeString(restrictedAccountType);
dest.writeString(requiredAccountType);
dest.writeString(overlayTarget);
}
public static final Parcelable.Creator<PackageInfo> CREATOR
= new Parcelable.Creator<PackageInfo>() {
@Override
public PackageInfo createFromParcel(Parcel source) {
return new PackageInfo(source);
}
@Override
public PackageInfo[] newArray(int size) {
return new PackageInfo[size];
}
};
private PackageInfo(Parcel source) {
packageName = source.readString();
splitNames = source.createStringArray();
versionCode = source.readInt();
versionName = source.readString();
baseRevisionCode = source.readInt();
splitRevisionCodes = source.createIntArray();
sharedUserId = source.readString();
sharedUserLabel = source.readInt();
int hasApp = source.readInt();
if (hasApp != 0) {
applicationInfo = ApplicationInfo.CREATOR.createFromParcel(source);
}
firstInstallTime = source.readLong();
lastUpdateTime = source.readLong();
gids = source.createIntArray();
activities = source.createTypedArray(ActivityInfo.CREATOR);
receivers = source.createTypedArray(ActivityInfo.CREATOR);
services = source.createTypedArray(ServiceInfo.CREATOR);
providers = source.createTypedArray(ProviderInfo.CREATOR);
instrumentation = source.createTypedArray(InstrumentationInfo.CREATOR);
permissions = source.createTypedArray(PermissionInfo.CREATOR);
requestedPermissions = source.createStringArray();
requestedPermissionsFlags = source.createIntArray();
signatures = source.createTypedArray(Signature.CREATOR);
configPreferences = source.createTypedArray(ConfigurationInfo.CREATOR);
reqFeatures = source.createTypedArray(FeatureInfo.CREATOR);
featureGroups = source.createTypedArray(FeatureGroupInfo.CREATOR);
installLocation = source.readInt();
coreApp = source.readInt() != 0;
requiredForAllUsers = source.readInt() != 0;
restrictedAccountType = source.readString();
requiredAccountType = source.readString();
overlayTarget = source.readString();
// The component lists were flattened with the redundant ApplicationInfo
// instances omitted. Distribute the canonical one here as appropriate.
if (applicationInfo != null) {
propagateApplicationInfo(applicationInfo, activities);
propagateApplicationInfo(applicationInfo, receivers);
propagateApplicationInfo(applicationInfo, services);
propagateApplicationInfo(applicationInfo, providers);
}
}
private void propagateApplicationInfo(ApplicationInfo appInfo, ComponentInfo[] components) {
if (components != null) {
for (ComponentInfo ci : components) {
ci.applicationInfo = appInfo;
}
}
}
}
@@ -0,0 +1,346 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.content.pm;
import android.content.res.XmlResourceParser;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Parcel;
import android.util.Printer;
import kotlin.NotImplementedError;
import java.text.Collator;
import java.util.Comparator;
/**
* Base class containing information common to all package items held by
* the package manager. This provides a very common basic set of attributes:
* a label, icon, and meta-data. This class is not intended
* to be used by itself; it is simply here to share common definitions
* between all items returned by the package manager. As such, it does not
* itself implement Parcelable, but does provide convenience methods to assist
* in the implementation of Parcelable in subclasses.
*/
public class PackageItemInfo {
private static final float MAX_LABEL_SIZE_PX = 500f;
/**
* 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 banner. From the "banner" attribute or, if not set, 0.
*/
public int banner;
/**
* 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;
/**
* If different of UserHandle.USER_NULL, The icon of this item will be the one of that user.
* @hide
*/
public int showUserIcon;
public PackageItemInfo() {
// showUserIcon = UserHandle.USER_NULL;
}
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;
banner = orig.banner;
logo = orig.logo;
metaData = orig.metaData;
showUserIcon = orig.showUserIcon;
}
/**
* 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) {
throw new NotImplementedError();
}
/**
* Retrieve the current graphical icon associated with this item without
* the addition of a work badge if applicable.
* 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 loadUnbadgedIcon(PackageManager pm) {
throw new NotImplementedError();
}
/**
* Retrieve the current graphical banner associated with this item. This
* will call back on the given PackageManager to load the banner from
* the application.
*
* @param pm A PackageManager from which the banner can be loaded; usually
* the PackageManager from which you originally retrieved this item.
*
* @return Returns a Drawable containing the item's banner. If the item
* does not have a banner, this method will return null.
*/
public Drawable loadBanner(PackageManager pm) {
if (banner != 0) {
Drawable dr = pm.getDrawable(packageName, banner, getApplicationInfo());
if (dr != null) {
return dr;
}
}
return loadDefaultBanner(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
*/
public Drawable loadDefaultIcon(PackageManager pm) {
return pm.getDefaultActivityIcon();
}
/**
* Retrieve the default graphical banner associated with this item.
*
* @param pm A PackageManager from which the banner can be loaded; usually
* the PackageManager from which you originally retrieved this item.
*
* @return Returns a Drawable containing the item's default banner
* or null if no default logo is available.
*
* @hide
*/
protected Drawable loadDefaultBanner(PackageManager pm) {
return null;
}
/**
* 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;
}
/**
* @hide Flag for dumping: include all details.
*/
public static final int DUMP_FLAG_DETAILS = 1<<0;
/**
* @hide Flag for dumping: include nested ApplicationInfo.
*/
public static final int DUMP_FLAG_APPLICATION = 1<<1;
/**
* @hide Flag for dumping: all flags to dump everything.
*/
public static final int DUMP_FLAG_ALL = DUMP_FLAG_DETAILS | DUMP_FLAG_APPLICATION;
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 || banner != 0) {
pw.println(prefix + "labelRes=0x" + Integer.toHexString(labelRes)
+ " nonLocalizedLabel=" + nonLocalizedLabel
+ " icon=0x" + Integer.toHexString(icon)
+ " banner=0x" + Integer.toHexString(banner));
}
}
protected void dumpBack(Printer pw, String prefix) {
// no back here
}
public void writeToParcel(Parcel dest, int parcelableFlags) {
dest.writeString(name);
dest.writeString(packageName);
dest.writeInt(labelRes);
dest.writeInt(icon);
dest.writeInt(logo);
dest.writeBundle(metaData);
dest.writeInt(banner);
dest.writeInt(showUserIcon);
}
protected PackageItemInfo(Parcel source) {
name = source.readString();
packageName = source.readString();
labelRes = source.readInt();
icon = source.readInt();
logo = source.readInt();
metaData = source.readBundle();
banner = source.readInt();
showUserIcon = source.readInt();
}
/**
* Get the ApplicationInfo for the application to which this item belongs,
* if available, otherwise returns null.
*
* @return Returns the ApplicationInfo of this item, or null if not known.
*
* @hide
*/
protected ApplicationInfo getApplicationInfo() {
return null;
}
public static class DisplayNameComparator
implements Comparator<PackageItemInfo> {
public DisplayNameComparator(PackageManager pm) {
mPM = pm;
}
public final int compare(PackageItemInfo aa, PackageItemInfo ab) {
CharSequence sa = aa.loadLabel(mPM);
if (sa == null) sa = aa.name;
CharSequence sb = ab.loadLabel(mPM);
if (sb == null) sb = ab.name;
return sCollator.compare(sa.toString(), sb.toString());
}
private final Collator sCollator = Collator.getInstance();
private PackageManager mPM;
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,15 @@
package android.content.pm;
public class PackageParser {
public static class PackageParserException extends Exception {
public final int error;
public PackageParserException(int error, String detailMessage) {
super(detailMessage);
this.error = error;
}
public PackageParserException(int error, String detailMessage, Throwable throwable) {
super(detailMessage, throwable);
this.error = error;
}
}
}
@@ -0,0 +1,178 @@
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.content.pm;
import android.os.Parcel;
import android.os.Parcelable;
import java.io.ByteArrayInputStream;
import java.lang.ref.SoftReference;
import java.security.PublicKey;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.util.Arrays;
/**
* Opaque, immutable representation of a signature associated with an
* application package.
*/
public class Signature implements Parcelable {
private final byte[] mSignature;
private int mHashCode;
private boolean mHaveHashCode;
private SoftReference<String> mStringRef;
/**
* Create Signature from an existing raw byte array.
*/
public Signature(byte[] signature) {
mSignature = signature.clone();
}
private static final int parseHexDigit(int nibble) {
if ('0' <= nibble && nibble <= '9') {
return nibble - '0';
} else if ('a' <= nibble && nibble <= 'f') {
return nibble - 'a' + 10;
} else if ('A' <= nibble && nibble <= 'F') {
return nibble - 'A' + 10;
} else {
throw new IllegalArgumentException("Invalid character " + nibble + " in hex string");
}
}
/**
* Create Signature from a text representation previously returned by
* {@link #toChars} or {@link #toCharsString()}. Signatures are expected to
* be a hex-encoded ASCII string.
*
* @param text hex-encoded string representing the signature
* @throws IllegalArgumentException when signature is odd-length
*/
public Signature(String text) {
final byte[] input = text.getBytes();
final int N = input.length;
if (N % 2 != 0) {
throw new IllegalArgumentException("text size " + N + " is not even");
}
final byte[] sig = new byte[N / 2];
int sigIndex = 0;
for (int i = 0; i < N;) {
final int hi = parseHexDigit(input[i++]);
final int lo = parseHexDigit(input[i++]);
sig[sigIndex++] = (byte) ((hi << 4) | lo);
}
mSignature = sig;
}
/**
* Encode the Signature as ASCII text.
*/
public char[] toChars() {
return toChars(null, null);
}
/**
* Encode the Signature as ASCII text in to an existing array.
*
* @param existingArray Existing char array or null.
* @param outLen Output parameter for the number of characters written in
* to the array.
* @return Returns either <var>existingArray</var> if it was large enough
* to hold the ASCII representation, or a newly created char[] array if
* needed.
*/
public char[] toChars(char[] existingArray, int[] outLen) {
byte[] sig = mSignature;
final int N = sig.length;
final int N2 = N*2;
char[] text = existingArray == null || N2 > existingArray.length
? new char[N2] : existingArray;
for (int j=0; j<N; j++) {
byte v = sig[j];
int d = (v>>4)&0xf;
text[j*2] = (char)(d >= 10 ? ('a' + d - 10) : ('0' + d));
d = v&0xf;
text[j*2+1] = (char)(d >= 10 ? ('a' + d - 10) : ('0' + d));
}
if (outLen != null) outLen[0] = N;
return text;
}
/**
* Return the result of {@link #toChars()} as a String.
*/
public String toCharsString() {
String str = mStringRef == null ? null : mStringRef.get();
if (str != null) {
return str;
}
str = new String(toChars());
mStringRef = new SoftReference<String>(str);
return str;
}
/**
* @return the contents of this signature as a byte array.
*/
public byte[] toByteArray() {
byte[] bytes = new byte[mSignature.length];
System.arraycopy(mSignature, 0, bytes, 0, mSignature.length);
return bytes;
}
/**
* Returns the public key for this signature.
*
* @throws CertificateException when Signature isn't a valid X.509
* certificate; shouldn't happen.
* @hide
*/
public PublicKey getPublicKey() throws CertificateException {
final CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
final ByteArrayInputStream bais = new ByteArrayInputStream(mSignature);
final Certificate cert = certFactory.generateCertificate(bais);
return cert.getPublicKey();
}
@Override
public boolean equals(Object obj) {
try {
if (obj != null) {
Signature other = (Signature)obj;
return this == other || Arrays.equals(mSignature, other.mSignature);
}
} catch (ClassCastException e) {
}
return false;
}
@Override
public int hashCode() {
if (mHaveHashCode) {
return mHashCode;
}
mHashCode = Arrays.hashCode(mSignature);
mHaveHashCode = true;
return mHashCode;
}
public int describeContents() {
return 0;
}
public void writeToParcel(Parcel dest, int parcelableFlags) {
dest.writeByteArray(mSignature);
}
public static final Parcelable.Creator<Signature> CREATOR
= new Parcelable.Creator<Signature>() {
public Signature createFromParcel(Parcel source) {
return new Signature(source);
}
public Signature[] newArray(int size) {
return new Signature[size];
}
};
private Signature(Parcel source) {
mSignature = source.createByteArray();
}
}
@@ -0,0 +1,87 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.content.pm;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* Encapsulates a package and its version code.
*/
public final class VersionedPackage implements Parcelable {
private final String mPackageName;
private final int mVersionCode;
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@IntRange(from = PackageManager.VERSION_CODE_HIGHEST)
public @interface VersionCode{}
/**
* Creates a new instance. Use {@link PackageManager#VERSION_CODE_HIGHEST}
* to refer to the highest version code of this package.
* @param packageName The package name.
* @param versionCode The version code.
*/
public VersionedPackage(@NonNull String packageName,
@VersionCode int versionCode) {
mPackageName = packageName;
mVersionCode = versionCode;
}
private VersionedPackage(Parcel parcel) {
mPackageName = parcel.readString();
mVersionCode = parcel.readInt();
}
/**
* Gets the package name.
*
* @return The package name.
*/
public @NonNull String getPackageName() {
return mPackageName;
}
/**
* Gets the version code.
*
* @return The version code.
*/
public @VersionCode int getVersionCode() {
return mVersionCode;
}
@Override
public String toString() {
return "VersionedPackage[" + mPackageName + "/" + mVersionCode + "]";
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int flags) {
parcel.writeString(mPackageName);
parcel.writeInt(mVersionCode);
}
public static final Creator<VersionedPackage> CREATOR = new Creator<VersionedPackage>() {
@Override
public VersionedPackage createFromParcel(Parcel source) {
return new VersionedPackage(source);
}
@Override
public VersionedPackage[] newArray(int size) {
return new VersionedPackage[size];
}
};
}
@@ -0,0 +1,296 @@
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.content.res;
import android.content.pm.ApplicationInfo;
import android.graphics.Canvas;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.DisplayMetrics;
import android.view.MotionEvent;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
/**
* CompatibilityInfo class keeps the information about compatibility mode that the application is
* running under.
*
* {@hide}
*/
public class CompatibilityInfo implements Parcelable {
/** default compatibility info object for compatible applications */
public static final CompatibilityInfo DEFAULT_COMPATIBILITY_INFO = null;
/**
* This is the number of pixels we would like to have along the
* short axis of an app that needs to run on a normal size screen.
*/
public static final int DEFAULT_NORMAL_SHORT_DIMENSION = 320;
/**
* This is the maximum aspect ratio we will allow while keeping
* applications in a compatible screen size.
*/
public static final float MAXIMUM_ASPECT_RATIO = (854f/480f);
/**
* A compatibility flags
*/
private final int mCompatibilityFlags;
/**
* A flag mask to tell if the application needs scaling (when mApplicationScale != 1.0f)
* {@see compatibilityFlag}
*/
private static final int SCALING_REQUIRED = 1;
/**
* Application must always run in compatibility mode?
*/
private static final int ALWAYS_NEEDS_COMPAT = 2;
/**
* Application never should run in compatibility mode?
*/
private static final int NEVER_NEEDS_COMPAT = 4;
/**
* Set if the application needs to run in screen size compatibility mode.
*/
private static final int NEEDS_SCREEN_COMPAT = 8;
/**
* The effective screen density we have selected for this application.
*/
public final int applicationDensity;
/**
* Application's scale.
*/
public final float applicationScale;
/**
* Application's inverted scale.
*/
public final float applicationInvertedScale;
public CompatibilityInfo(ApplicationInfo appInfo, int screenLayout, int sw, boolean forceCompat) {
throw new RuntimeException("Stub!");
}
private CompatibilityInfo(int compFlags, int dens, float scale, float invertedScale) {
throw new RuntimeException("Stub!");
}
private CompatibilityInfo() {
throw new RuntimeException("Stub!");
}
/**
* @return true if the scaling is required
*/
public boolean isScalingRequired() {
throw new RuntimeException("Stub!");
}
public boolean supportsScreen() {
throw new RuntimeException("Stub!");
}
public boolean neverSupportsScreen() {
throw new RuntimeException("Stub!");
}
public boolean alwaysSupportsScreen() {
throw new RuntimeException("Stub!");
}
/**
* Returns the translator which translates the coordinates in compatibility mode.
* @param params the window's parameter
*/
public Translator getTranslator() {
throw new RuntimeException("Stub!");
}
/**
* A helper object to translate the screen and window coordinates back and forth.
* @hide
*/
public class Translator {
public final float applicationScale;
public final float applicationInvertedScale;
private Rect mContentInsetsBuffer = null;
private Rect mVisibleInsetsBuffer = null;
private Region mTouchableAreaBuffer = null;
Translator(float applicationScale, float applicationInvertedScale) {
throw new RuntimeException("Stub!");
}
Translator() {
throw new RuntimeException("Stub!");
}
/**
* Translate the screen rect to the application frame.
*/
public void translateRectInScreenToAppWinFrame(Rect rect) {
throw new RuntimeException("Stub!");
}
/**
* Translate the region in window to screen.
*/
public void translateRegionInWindowToScreen(Region transparentRegion) {
throw new RuntimeException("Stub!");
}
/**
* Apply translation to the canvas that is necessary to draw the content.
*/
public void translateCanvas(Canvas canvas) {
throw new RuntimeException("Stub!");
}
/**
* Translate the motion event captured on screen to the application's window.
*/
public void translateEventInScreenToAppWindow(MotionEvent event) {
throw new RuntimeException("Stub!");
}
/**
* Translate the window's layout parameter, from application's view to
* Screen's view.
*/
public void translateWindowLayout(WindowManager.LayoutParams params) {
throw new RuntimeException("Stub!");
}
/**
* Translate a Rect in application's window to screen.
*/
public void translateRectInAppWindowToScreen(Rect rect) {
throw new RuntimeException("Stub!");
}
/**
* Translate a Rect in screen coordinates into the app window's coordinates.
*/
public void translateRectInScreenToAppWindow(Rect rect) {
throw new RuntimeException("Stub!");
}
/**
* Translate a Point in screen coordinates into the app window's coordinates.
*/
public void translatePointInScreenToAppWindow(PointF point) {
throw new RuntimeException("Stub!");
}
/**
* Translate the location of the sub window.
* @param params
*/
public void translateLayoutParamsInAppWindowToScreen(LayoutParams params) {
throw new RuntimeException("Stub!");
}
/**
* Translate the content insets in application window to Screen. This uses
* the internal buffer for content insets to avoid extra object allocation.
*/
public Rect getTranslatedContentInsets(Rect contentInsets) {
throw new RuntimeException("Stub!");
}
/**
* Translate the visible insets in application window to Screen. This uses
* the internal buffer for visible insets to avoid extra object allocation.
*/
public Rect getTranslatedVisibleInsets(Rect visibleInsets) {
throw new RuntimeException("Stub!");
}
/**
* Translate the touchable area in application window to Screen. This uses
* the internal buffer for touchable area to avoid extra object allocation.
*/
public Region getTranslatedTouchableArea(Region touchableArea) {
throw new RuntimeException("Stub!");
}
}
public void applyToDisplayMetrics(DisplayMetrics inoutDm) {
throw new RuntimeException("Stub!");
}
public void applyToConfiguration(int displayDensity, Configuration inoutConfig) {
throw new RuntimeException("Stub!");
}
/**
* Compute the frame Rect for applications runs under compatibility mode.
*
* @param dm the display metrics used to compute the frame size.
* @param outDm If non-null the width and height will be set to their scaled values.
* @return Returns the scaling factor for the window.
*/
public static float computeCompatibleScaling(DisplayMetrics dm, DisplayMetrics outDm) {
throw new RuntimeException("Stub!");
}
@Override
public boolean equals(Object o) {
throw new RuntimeException("Stub!");
}
@Override
public String toString() {
throw new RuntimeException("Stub!");
}
@Override
public int hashCode() {
throw new RuntimeException("Stub!");
}
@Override
public int describeContents() {
throw new RuntimeException("Stub!");
}
@Override
public void writeToParcel(Parcel dest, int flags) {
throw new RuntimeException("Stub!");
}
public static final Parcelable.Creator<CompatibilityInfo> CREATOR = null;
private CompatibilityInfo(Parcel source) {
throw new RuntimeException("Stub!");
}
}