Search in sources :

Example 1 with PackageInfo

use of android.content.pm.PackageInfo in project cw-omnibus by commonsguy.

the class AbstractCPProxy method onCreate.

@Override
public boolean onCreate() {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
    if (prefs.getBoolean(PREFS_FIRST_RUN, true)) {
        SharedPreferences.Editor editor = prefs.edit().putBoolean(PREFS_FIRST_RUN, false);
        HashMap<PackageInfo, ArrayList<PermissionLint>> entries = PermissionUtils.checkCustomPermissions(getContext());
        for (Map.Entry<PackageInfo, ArrayList<PermissionLint>> entry : entries.entrySet()) {
            if (!"com.commonsware.android.cpproxy.consumer".equals(entry.getKey().packageName)) {
                tainted = true;
                break;
            }
        }
        editor.putBoolean(PREFS_TAINTED, tainted).apply();
    } else {
        tainted = prefs.getBoolean(PREFS_TAINTED, true);
    }
    return (true);
}
Also used : SharedPreferences(android.content.SharedPreferences) PackageInfo(android.content.pm.PackageInfo) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with PackageInfo

use of android.content.pm.PackageInfo in project materialistic by hidroh.

the class ReleaseNotesActivityTest method testUpdateSeen.

@Test
public void testUpdateSeen() throws PackageManager.NameNotFoundException {
    Preferences.sReleaseNotesSeen = null;
    PreferenceManager.getDefaultSharedPreferences(RuntimeEnvironment.application).edit().putInt(RuntimeEnvironment.application.getString(R.string.pref_latest_release), BuildConfig.LATEST_RELEASE).commit();
    PackageInfo info = RuntimeEnvironment.getPackageManager().getPackageInfo(RuntimeEnvironment.application.getPackageName(), 0);
    info.firstInstallTime = 0;
    info.lastUpdateTime = 1;
    assertTrue(Preferences.isReleaseNotesSeen(RuntimeEnvironment.application));
}
Also used : PackageInfo(android.content.pm.PackageInfo) Test(org.junit.Test)

Example 3 with PackageInfo

use of android.content.pm.PackageInfo in project detective-droid by michaelcarrano.

the class AppDetailActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_app_detail);
    int position = getIntent().getExtras().getInt(AppDetailFragment.ARG_ITEM_ID);
    // Show the Up button in the action bar.
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    // Set the ActionBar title, icon and up button
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    PackageManager pm = getPackageManager();
    PackageInfo pkg = AppSources.getInstance().getSources().get(position).getPackageInfo();
    getSupportActionBar().setIcon(pkg.applicationInfo.loadIcon(pm));
    getSupportActionBar().setTitle(pm.getApplicationLabel(pkg.applicationInfo).toString());
    // at: http://developer.android.com/guide/components/fragments.html
    if (savedInstanceState == null) {
        // Create the detail fragment and add it to the activity
        // using a fragment transaction.
        Bundle arguments = new Bundle();
        arguments.putInt(AppDetailFragment.ARG_ITEM_ID, position);
        AppDetailFragment fragment = new AppDetailFragment();
        fragment.setArguments(arguments);
        getSupportFragmentManager().beginTransaction().add(R.id.app_detail_container, fragment).commit();
    }
}
Also used : PackageManager(android.content.pm.PackageManager) PackageInfo(android.content.pm.PackageInfo) Bundle(android.os.Bundle)

Example 4 with PackageInfo

use of android.content.pm.PackageInfo in project AboutLibraries by mikepenz.

the class Libs method getAutoDetectedLibraries.

/**
     * Get all autoDetected Libraries
     *
     * @return an ArrayList Library with all found libs by their classpath
     */
public ArrayList<Library> getAutoDetectedLibraries(Context ctx) {
    ArrayList<Library> libraries = new ArrayList<>();
    PackageInfo pi = Util.getPackageInfo(ctx);
    if (pi != null) {
        String[] autoDetectedLibraries = ctx.getSharedPreferences("aboutLibraries_" + pi.versionCode, Context.MODE_PRIVATE).getString("autoDetectedLibraries", "").split(";");
        if (autoDetectedLibraries.length > 0) {
            for (String autoDetectedLibrary : autoDetectedLibraries) {
                Library lib = getLibrary(autoDetectedLibrary);
                if (lib != null) {
                    libraries.add(lib);
                }
            }
        }
    }
    if (libraries.size() == 0) {
        String delimiter = "";
        String autoDetectedLibrariesPref = "";
        for (Library lib : Detect.detect(ctx, getLibraries())) {
            libraries.add(lib);
            autoDetectedLibrariesPref = autoDetectedLibrariesPref + delimiter + lib.getDefinedName();
            delimiter = ";";
        }
        if (pi != null) {
            ctx.getSharedPreferences("aboutLibraries_" + pi.versionCode, Context.MODE_PRIVATE).edit().putString("autoDetectedLibraries", autoDetectedLibrariesPref).commit();
        }
    }
    return libraries;
}
Also used : PackageInfo(android.content.pm.PackageInfo) ArrayList(java.util.ArrayList) Library(com.mikepenz.aboutlibraries.entity.Library)

Example 5 with PackageInfo

use of android.content.pm.PackageInfo in project NewPipe by TeamNewPipe.

the class CrashHandler method init.

public static void init(Context context) {
    try {
        PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
        VERSION = info.versionName + info.versionCode;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : PackageInfo(android.content.pm.PackageInfo)

Aggregations

PackageInfo (android.content.pm.PackageInfo)1565 PackageManager (android.content.pm.PackageManager)701 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