Merge "Add ModuleInfo class"
This commit is contained in:
committed by
Android (Google) Code Review
commit
2c07da7945
@@ -11227,6 +11227,15 @@ package android.content.pm {
|
||||
field public static final int FLAG_MATCH_PINNED_BY_ANY_LAUNCHER = 1024; // 0x400
|
||||
}
|
||||
|
||||
public final class ModuleInfo implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public java.lang.String getName();
|
||||
method public java.lang.String getPackageName();
|
||||
method public boolean isHidden();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final android.os.Parcelable.Creator<android.content.pm.ModuleInfo> CREATOR;
|
||||
}
|
||||
|
||||
public class PackageInfo implements android.os.Parcelable {
|
||||
ctor public PackageInfo();
|
||||
method public int describeContents();
|
||||
@@ -11443,6 +11452,7 @@ package android.content.pm {
|
||||
method public abstract android.graphics.drawable.Drawable getDefaultActivityIcon();
|
||||
method public abstract android.graphics.drawable.Drawable getDrawable(java.lang.String, int, android.content.pm.ApplicationInfo);
|
||||
method public abstract java.util.List<android.content.pm.ApplicationInfo> getInstalledApplications(int);
|
||||
method public java.util.List<android.content.pm.ModuleInfo> getInstalledModules(int);
|
||||
method public abstract java.util.List<android.content.pm.PackageInfo> getInstalledPackages(int);
|
||||
method public abstract java.lang.String getInstallerPackageName(java.lang.String);
|
||||
method public abstract byte[] getInstantAppCookie();
|
||||
@@ -11450,6 +11460,7 @@ package android.content.pm {
|
||||
method public abstract android.content.pm.InstrumentationInfo getInstrumentationInfo(android.content.ComponentName, int) throws android.content.pm.PackageManager.NameNotFoundException;
|
||||
method public abstract android.content.Intent getLaunchIntentForPackage(java.lang.String);
|
||||
method public abstract android.content.Intent getLeanbackLaunchIntentForPackage(java.lang.String);
|
||||
method public android.content.pm.ModuleInfo getModuleInfo(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
|
||||
method public abstract java.lang.String getNameForUid(int);
|
||||
method public android.content.pm.PackageInfo getPackageArchiveInfo(java.lang.String, int);
|
||||
method public abstract int[] getPackageGids(java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException;
|
||||
|
||||
@@ -44,6 +44,7 @@ import android.content.pm.InstantAppInfo;
|
||||
import android.content.pm.InstrumentationInfo;
|
||||
import android.content.pm.IntentFilterVerificationInfo;
|
||||
import android.content.pm.KeySet;
|
||||
import android.content.pm.ModuleInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageInstaller;
|
||||
import android.content.pm.PackageItemInfo;
|
||||
@@ -791,6 +792,16 @@ public class ApplicationPackageManager extends PackageManager {
|
||||
throw new NameNotFoundException("No shared userid for user:"+sharedUserName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ModuleInfo> getInstalledModules(int flags) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModuleInfo getModuleInfo(String packageName, int flags) throws NameNotFoundException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<PackageInfo> getInstalledPackages(int flags) {
|
||||
|
||||
146
core/java/android/content/pm/ModuleInfo.java
Normal file
146
core/java/android/content/pm/ModuleInfo.java
Normal file
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.Nullable;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Information you can retrieve about a particular system
|
||||
* module.
|
||||
*/
|
||||
public final class ModuleInfo implements Parcelable {
|
||||
|
||||
// NOTE: When adding new data members be sure to update the copy-constructor, Parcel
|
||||
// constructor, and writeToParcel.
|
||||
|
||||
/** Public name of this module. */
|
||||
private String mName;
|
||||
|
||||
/** The package name of this module. */
|
||||
private String mPackageName;
|
||||
|
||||
/** Whether or not this module is hidden from the user. */
|
||||
private boolean mHidden;
|
||||
|
||||
// TODO: Decide whether we need an additional metadata bundle to support out of band
|
||||
// updates to ModuleInfo.
|
||||
//
|
||||
// private Bundle mMetadata;
|
||||
|
||||
/** @hide */
|
||||
public ModuleInfo() {
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public ModuleInfo(ModuleInfo orig) {
|
||||
mName = orig.mName;
|
||||
mPackageName = orig.mPackageName;
|
||||
mHidden = orig.mHidden;
|
||||
}
|
||||
|
||||
/** @hide Sets the public name of this module. */
|
||||
public ModuleInfo setName(String name) {
|
||||
mName = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Gets the public name of this module. */
|
||||
public @Nullable String getName() {
|
||||
return mName;
|
||||
}
|
||||
|
||||
/** @hide Sets the package name of this module. */
|
||||
public ModuleInfo setPackageName(String packageName) {
|
||||
mPackageName = packageName;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Gets the package name of this module. */
|
||||
public @Nullable String getPackageName() {
|
||||
return mPackageName;
|
||||
}
|
||||
|
||||
/** @hide Sets whether or not this package is hidden. */
|
||||
public ModuleInfo setHidden(boolean hidden) {
|
||||
mHidden = hidden;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Gets whether or not this package is hidden. */
|
||||
public boolean isHidden() {
|
||||
return mHidden;
|
||||
}
|
||||
|
||||
/** Returns a string representation of this object. */
|
||||
public String toString() {
|
||||
return "ModuleInfo{"
|
||||
+ Integer.toHexString(System.identityHashCode(this))
|
||||
+ " " + mName + "}";
|
||||
}
|
||||
|
||||
/** Describes the kinds of special objects contained in this object. */
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hashCode = 0;
|
||||
hashCode = 31 * hashCode + Objects.hashCode(mName);
|
||||
hashCode = 31 * hashCode + Objects.hashCode(mPackageName);
|
||||
hashCode = 31 * hashCode + Boolean.hashCode(mHidden);
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof ModuleInfo)) {
|
||||
return false;
|
||||
}
|
||||
final ModuleInfo other = (ModuleInfo) obj;
|
||||
return Objects.equals(mName, other.mName)
|
||||
&& Objects.equals(mPackageName, other.mPackageName)
|
||||
&& mHidden == other.mHidden;
|
||||
}
|
||||
|
||||
/** Flattens this object into the given {@link Parcel}. */
|
||||
public void writeToParcel(Parcel dest, int parcelableFlags) {
|
||||
dest.writeString(mName);
|
||||
dest.writeString(mPackageName);
|
||||
dest.writeBoolean(mHidden);
|
||||
}
|
||||
|
||||
private ModuleInfo(Parcel source) {
|
||||
mName = source.readString();
|
||||
mPackageName = source.readString();
|
||||
mHidden = source.readBoolean();
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<ModuleInfo> CREATOR =
|
||||
new Parcelable.Creator<ModuleInfo>() {
|
||||
public ModuleInfo createFromParcel(Parcel source) {
|
||||
return new ModuleInfo(source);
|
||||
}
|
||||
public ModuleInfo[] newArray(int size) {
|
||||
return new ModuleInfo[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -218,6 +218,12 @@ public abstract class PackageManager {
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface ResolveInfoFlags {}
|
||||
|
||||
/** @hide */
|
||||
@IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface ModuleInfoFlags {}
|
||||
|
||||
/** @hide */
|
||||
@IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
|
||||
GET_META_DATA,
|
||||
@@ -3466,6 +3472,35 @@ public abstract class PackageManager {
|
||||
public abstract ProviderInfo getProviderInfo(ComponentName component,
|
||||
@ComponentInfoFlags int flags) throws NameNotFoundException;
|
||||
|
||||
/**
|
||||
* Retrieve information for a particular module.
|
||||
*
|
||||
* @param packageName The name of the module.
|
||||
* @param flags Additional option flags to modify the data returned.
|
||||
* @return A {@link ModuleInfo} object containing information about the
|
||||
* module.
|
||||
* @throws NameNotFoundException if a module with the given name cannot be
|
||||
* found on the system.
|
||||
*/
|
||||
public ModuleInfo getModuleInfo(String packageName, @ModuleInfoFlags int flags)
|
||||
throws NameNotFoundException {
|
||||
throw new UnsupportedOperationException(
|
||||
"getModuleInfo not implemented in subclass");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a List of all modules that are installed.
|
||||
*
|
||||
* @param flags Additional option flags to modify the data returned.
|
||||
* @return A {@link List} of {@link ModuleInfo} objects, one for each installed
|
||||
* module, containing information about the module. In the unlikely case
|
||||
* there are no installed modules, an empty list is returned.
|
||||
*/
|
||||
public @NonNull List<ModuleInfo> getInstalledModules(@ModuleInfoFlags int flags) {
|
||||
throw new UnsupportedOperationException(
|
||||
"getInstalledModules not implemented in subclass");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a List of all packages that are installed for the current user.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user