Search in sources :

Example 51 with PackageInfo

use of android.content.pm.PackageInfo in project android_frameworks_base by ResurrectionRemix.

the class BackupManagerService method dumpAgents.

private void dumpAgents(PrintWriter pw) {
    List<PackageInfo> agentPackages = allAgentPackages();
    pw.println("Defined backup agents:");
    for (PackageInfo pkg : agentPackages) {
        pw.print("  ");
        pw.print(pkg.packageName);
        pw.println(':');
        pw.print("      ");
        pw.println(pkg.applicationInfo.backupAgentName);
    }
}
Also used : PackageInfo(android.content.pm.PackageInfo)

Example 52 with PackageInfo

use of android.content.pm.PackageInfo in project android_frameworks_base by ResurrectionRemix.

the class PackageManagerBackupAgent method writeStateFile.

// Util: write out our new backup state file
private void writeStateFile(List<PackageInfo> pkgs, ComponentName preferredHome, long homeVersion, ArrayList<byte[]> homeSigHashes, ParcelFileDescriptor stateFile) {
    FileOutputStream outstream = new FileOutputStream(stateFile.getFileDescriptor());
    BufferedOutputStream outbuf = new BufferedOutputStream(outstream);
    DataOutputStream out = new DataOutputStream(outbuf);
    // by the time we get here we know we've done all our backing up
    try {
        // state file version header
        out.writeUTF(STATE_FILE_HEADER);
        out.writeInt(STATE_FILE_VERSION);
        // If we remembered a preferred home app, record that
        if (preferredHome != null) {
            out.writeUTF(DEFAULT_HOME_KEY);
            out.writeUTF(preferredHome.flattenToString());
            out.writeLong(homeVersion);
            writeSignatureHashArray(out, homeSigHashes);
        }
        // Conclude with the metadata block
        out.writeUTF(GLOBAL_METADATA_KEY);
        out.writeInt(Build.VERSION.SDK_INT);
        out.writeUTF(Build.VERSION.INCREMENTAL);
        // now write all the app names + versions
        for (PackageInfo pkg : pkgs) {
            out.writeUTF(pkg.packageName);
            out.writeInt(pkg.versionCode);
        }
        out.flush();
    } catch (IOException e) {
        Slog.e(TAG, "Unable to write package manager state file!");
    }
}
Also used : DataOutputStream(java.io.DataOutputStream) PackageInfo(android.content.pm.PackageInfo) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) BufferedOutputStream(java.io.BufferedOutputStream)

Example 53 with PackageInfo

use of android.content.pm.PackageInfo in project android_frameworks_base by ResurrectionRemix.

the class OverlayManagerServiceImpl method onTargetPackageUpgraded.

void onTargetPackageUpgraded(@NonNull final String packageName, final int userId) {
    if (DEBUG) {
        Slog.d(TAG, "onTargetPackageUpgraded packageName=" + packageName + " userId=" + userId);
    }
    final PackageInfo targetPackage = mPackageManager.getPackageInfo(packageName, userId);
    updateAllOverlaysForTarget(packageName, userId, targetPackage);
}
Also used : PackageInfo(android.content.pm.PackageInfo)

Example 54 with PackageInfo

use of android.content.pm.PackageInfo in project android_frameworks_base by ResurrectionRemix.

the class OverlayManagerServiceImpl method updateAllOverlaysForTarget.

private void updateAllOverlaysForTarget(@NonNull final String packageName, final int userId, @Nullable final PackageInfo targetPackage) {
    final List<OverlayInfo> ois = mSettings.getOverlaysForTarget(packageName, userId);
    for (final OverlayInfo oi : ois) {
        final PackageInfo overlayPackage = mPackageManager.getPackageInfo(oi.packageName, userId);
        if (overlayPackage == null) {
            mSettings.remove(oi.packageName, oi.userId);
            removeIdmapIfPossible(oi);
        } else {
            try {
                updateState(targetPackage, overlayPackage, userId);
            } catch (OverlayManagerSettings.BadKeyException e) {
                Slog.e(TAG, "failed to update settings", e);
                mSettings.remove(oi.packageName, userId);
            }
        }
    }
}
Also used : PackageInfo(android.content.pm.PackageInfo) OverlayInfo(android.content.om.OverlayInfo)

Example 55 with PackageInfo

use of android.content.pm.PackageInfo in project android_frameworks_base by ResurrectionRemix.

the class OverlayManagerServiceImpl method onTargetPackageChanged.

void onTargetPackageChanged(@NonNull final String packageName, final int userId) {
    if (DEBUG) {
        Slog.d(TAG, "onTargetPackageChanged packageName=" + packageName + " userId=" + userId);
    }
    final PackageInfo targetPackage = mPackageManager.getPackageInfo(packageName, userId);
    updateAllOverlaysForTarget(packageName, userId, targetPackage);
}
Also used : PackageInfo(android.content.pm.PackageInfo)

Aggregations

PackageInfo (android.content.pm.PackageInfo)1567 PackageManager (android.content.pm.PackageManager)703 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)327 ApplicationInfo (android.content.pm.ApplicationInfo)217 Test (org.junit.Test)193 RemoteException (android.os.RemoteException)179 ArrayList (java.util.ArrayList)166 Intent (android.content.Intent)126 IOException (java.io.IOException)121 Context (android.content.Context)81 IPackageManager (android.content.pm.IPackageManager)65 ResolveInfo (android.content.pm.ResolveInfo)65 File (java.io.File)62 SuppressLint (android.annotation.SuppressLint)58 ComponentName (android.content.ComponentName)57 ActivityInfo (android.content.pm.ActivityInfo)57 View (android.view.View)57 TextView (android.widget.TextView)54 Signature (android.content.pm.Signature)51 OverlayInfo (android.content.om.OverlayInfo)42