Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2c828c1d authored by Narayan Kamath's avatar Narayan Kamath
Browse files

Implement ModuleInfoProvider

Implements the PackageManager's getModuleInfo and getInstalledModules
API. These APIs are now backed by XML metadata that's parsed from a
"module metadata" provider package. The package name for the module
metadata package is stored in the config_defaultModuleMetadataProvider
config value.

The module metadata provider must contain a <metadata> entry for its
<application> tag. The meta-data entry must contain a single key
android.content.pm.MODULE_METADATA whose value is a reference to an
XML resource that contains metadata about the list of modules on a
given device.

The XML document must consist of a single top level <module-metadata>
element with one or more children. Each of these children are <module>
elements. The <module> elements must contain each of the following
attributes :

name : A resource reference to a User visible package name, maps to
    ModuleInfo#getName
packageName : The package name of the module, see ModuleInfo#getPackageName
isHidden : Whether the module is hidden, see ModuleInfo#isHidden

Example :
<module-metadata>
    <module name="@string/resource" packageName="package_name" isHidden="false|true" />
    <module .... />
</module-metadata>

The module metadata is parsed eagerly and cached during system server
startup.

Test: atest FrameworksServicesTests:com.android.server.pm.ModuleInfoProviderTest

Change-Id: I0251c3f7429c42e3cce863eeeea792579dffecfb
parent 2c07da79
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -794,12 +794,25 @@ public class ApplicationPackageManager extends PackageManager {

    @Override
    public List<ModuleInfo> getInstalledModules(int flags) {
        return null;
        try {
            return mPM.getInstalledModules(flags);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    @Override
    public ModuleInfo getModuleInfo(String packageName, int flags) throws NameNotFoundException {
        return null;
        try {
            ModuleInfo mi = mPM.getModuleInfo(packageName, flags);
            if (mi != null) {
                return mi;
            }
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }

        throw new NameNotFoundException("No module info for package: " + packageName);
    }

    @SuppressWarnings("unchecked")
@@ -3002,7 +3015,6 @@ public class ApplicationPackageManager extends PackageManager {
        }
    }

    @Override
    public void sendDeviceCustomizationReadyBroadcast() {
        try {
            mPM.sendDeviceCustomizationReadyBroadcast();
+5 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.content.pm.IOnPermissionsChangeListener;
import android.content.pm.IntentFilterVerificationInfo;
import android.content.pm.InstrumentationInfo;
import android.content.pm.KeySet;
import android.content.pm.ModuleInfo;
import android.content.pm.PackageInfo;
import android.content.pm.ParceledListSlice;
import android.content.pm.ProviderInfo;
@@ -680,4 +681,8 @@ interface IPackageManager {
    boolean isPackageStateProtected(String packageName, int userId);

    void sendDeviceCustomizationReadyBroadcast();

    List<ModuleInfo> getInstalledModules(int flags);

    ModuleInfo getModuleInfo(String packageName, int flags);
}
+19 −0
Original line number Diff line number Diff line
/*
 * Copyright 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;

parcelable ModuleInfo;
+2 −0
Original line number Diff line number Diff line
@@ -3602,4 +3602,6 @@
         (android.view.InputEventCompatProcessor). -->
    <string name="config_inputEventCompatProcessorOverrideClassName" translatable="false"></string>

    <!-- Component name for the default module metadata provider on this device -->
    <string name="config_defaultModuleMetadataProvider">com.android.modulemetadata</string>
</resources>
+2 −0
Original line number Diff line number Diff line
@@ -3515,4 +3515,6 @@
  <java-symbol type="dimen" name="rounded_corner_radius" />
  <java-symbol type="dimen" name="rounded_corner_radius_top" />
  <java-symbol type="dimen" name="rounded_corner_radius_bottom" />

  <java-symbol type="string" name="config_defaultModuleMetadataProvider" />
</resources>
Loading