Java 类android.content.pm.ApplicationInfo 实例源码

项目:mobile-store    文件:InstalledAppTestUtils.java   
public static void install(Context context,
                           String packageName,
                           int versionCode, String versionName,
                           @Nullable String signingCert,
                           @Nullable String hash) {
    PackageInfo info = new PackageInfo();
    info.packageName = packageName;
    info.versionCode = versionCode;
    info.versionName = versionName;
    info.applicationInfo = new ApplicationInfo();
    info.applicationInfo.publicSourceDir = "/tmp/mock-location";
    if (signingCert != null) {
        info.signatures = new Signature[]{new Signature(signingCert)};
    }

    String hashType = "sha256";
    if (hash == null) {
        hash = "00112233445566778899aabbccddeeff";
    }

    InstalledAppProviderService.insertAppIntoDb(context, info, hashType, hash);
}
项目:COB    文件:SystemWebViewClient.java   
/**
 * Notify the host application that an SSL error occurred while loading a resource.
 * The host application must call either handler.cancel() or handler.proceed().
 * Note that the decision may be retained for use in response to future SSL errors.
 * The default behavior is to cancel the load.
 *
 * @param view          The WebView that is initiating the callback.
 * @param handler       An SslErrorHandler object that will handle the user's response.
 * @param error         The SSL error object.
 */
@TargetApi(8)
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {

    final String packageName = parentEngine.cordova.getActivity().getPackageName();
    final PackageManager pm = parentEngine.cordova.getActivity().getPackageManager();

    ApplicationInfo appInfo;
    try {
        appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
        if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
            // debug = true
            handler.proceed();
            return;
        } else {
            // debug = false
            super.onReceivedSslError(view, handler, error);
        }
    } catch (NameNotFoundException e) {
        // When it doubt, lock it out!
        super.onReceivedSslError(view, handler, error);
    }
}
项目:FireFiles    文件:RootsCache.java   
private void handleDocumentsProvider(ProviderInfo info) {
    // Ignore stopped packages for now; we might query them
    // later during UI interaction.
    if ((info.applicationInfo.flags & ApplicationInfo.FLAG_STOPPED) != 0) {
        if (LOGD) Log.d(TAG, "Ignoring stopped authority " + info.authority);
        mTaskStoppedAuthorities.add(info.authority);
        return;
    }

    // Try using cached roots if filtering
    boolean cacheHit = false;
    if (mAuthority != null && !mAuthority.equals(info.authority)) {
        synchronized (mLock) {
            if (mTaskRoots.putAll(info.authority, mRoots.get(info.authority))) {
                if (LOGD) Log.d(TAG, "Used cached roots for " + info.authority);
                cacheHit = true;
            }
        }
    }

    // Cache miss, or loading everything
    if (!cacheHit) {
        mTaskRoots.putAll(info.authority,
                loadRootsForAuthority(mContext.getContentResolver(), info.authority));
    }
}
项目:MVVMFrames    文件:ManifestParser.java   
public List<ConfigModule> parse() {
    List<ConfigModule> modules = new ArrayList<ConfigModule>();
    try {
        ApplicationInfo appInfo = context.getPackageManager().getApplicationInfo(
                context.getPackageName(), PackageManager.GET_META_DATA);
        if (appInfo.metaData != null) {
            for (String key : appInfo.metaData.keySet()) {
                if (MODULE_VALUE.equals(appInfo.metaData.get(key))) {
                    modules.add(parseModule(key));
                }
            }
        }
    } catch (PackageManager.NameNotFoundException e) {
        throw new RuntimeException("Unable to find metadata to parse ConfigModule", e);
    }

    return modules;
}
项目:ServiceDownLoadApp-master    文件:UpdateService.java   
private int getIcon(Context context){

            final PackageManager packageManager = context.getPackageManager();
            ApplicationInfo appInfo = null;
            try {
                appInfo = packageManager.getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
            } catch (PackageManager.NameNotFoundException e) {
                e.printStackTrace();
            }
            if (appInfo != null){
                return appInfo.icon;
            }
            return 0;
        }
项目:IFWManager    文件:SenderFilter.java   
static boolean isPrivilegedApp(int callerUid, int callerPid) {
    if (callerUid == Process.SYSTEM_UID || callerUid == 0 ||
            callerPid == Process.myPid() || callerPid == 0) {
        return true;
    }

    IPackageManager pm = AppGlobals.getPackageManager();
    try {
        return (pm.getPrivateFlagsForUid(callerUid) & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED)
                != 0;
    } catch (RemoteException ex) {
        Slog.e(IntentFirewall.TAG, "Remote exception while retrieving uid flags",
                ex);
    }

    return false;
}
项目:cordova.plugins.X5WebView    文件:X5WebViewClient.java   
/**
 * Notify the host application that an SSL error occurred while loading a resource.
 * The host application must call either handler.cancel() or handler.proceed().
 * Note that the decision may be retained for use in response to future SSL errors.
 * The default behavior is to cancel the load.
 *
 * @param view          The WebView that is initiating the callback.
 * @param handler       An SslErrorHandler object that will handle the user's response.
 * @param error         The SSL error object.
 */
@TargetApi(8)
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {

    final String packageName = parentEngine.cordova.getActivity().getPackageName();
    final PackageManager pm = parentEngine.cordova.getActivity().getPackageManager();

    ApplicationInfo appInfo;
    try {
        appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
        if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
            // debug = true
            handler.proceed();
            return;
        } else {
            // debug = false
            super.onReceivedSslError(view, handler, error);
        }
    } catch (NameNotFoundException e) {
        // When it doubt, lock it out!
        super.onReceivedSslError(view, handler, error);
    }
}
项目:Leanplum-Android-SDK    文件:LocationManagerImplementation.java   
private boolean isMetaDataSet() {
  Context context = Leanplum.getContext();
  try {
    ApplicationInfo appInfo = context.getPackageManager().getApplicationInfo(
        context.getPackageName(), PackageManager.GET_META_DATA);
    if (appInfo != null) {
      if (appInfo.metaData != null) {
        Object value = appInfo.metaData.get(METADATA);
        if (value != null) {
          return true;
        }
      }
    }
    return false;
  } catch (NameNotFoundException e) {
    return false;
  }
}
项目:CustomLogger    文件:NSLoggerClient.java   
void pushClientInfoToFrontOfQueue()
{
    if (DEBUG_LOGGER)
        Log.v("NSLogger", "Pushing client info to front of queue");

    LogMessage lm = new LogMessage(LogMessage.LOGMSG_TYPE_CLIENTINFO, nextSequenceNumber.getAndIncrement());
    lm.addString(Build.MANUFACTURER + " " + Build.MODEL, LogMessage.PART_KEY_CLIENT_MODEL);
    lm.addString("Android", LogMessage.PART_KEY_OS_NAME);
    lm.addString(Build.VERSION.RELEASE, LogMessage.PART_KEY_OS_VERSION);
    lm.addString(Secure.getString(currentContext.getContentResolver(), Secure.ANDROID_ID), LogMessage.PART_KEY_UNIQUEID);
    ApplicationInfo ai = currentContext.getApplicationInfo();
    String appName = ai.packageName;
    if (appName == null)
    {
        appName = ai.processName;
        if (appName == null)
        {
            appName = ai.taskAffinity;
            if (appName == null)
                appName = ai.toString();
        }
    }
    lm.addString(appName, LogMessage.PART_KEY_CLIENT_NAME);
    logs.add(0, lm);
    clientInfoAdded = true;
}
项目:LaunchEnr    文件:IconsManager.java   
List<String> getMatchingDrawables(String packageName) {
    List<String> matchingDrawables = new ArrayList<>();
    ApplicationInfo info = null;
    try {
        info = mPackageManager.getApplicationInfo(packageName, 0);
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
    String packageLabel = (info != null ? mPackageManager.getApplicationLabel(info).toString()
            : packageName).replaceAll("[^a-zA-Z]", "").toLowerCase().trim();
    for (String drawable : mDrawables) {
        if (drawable == null) continue;
        String filteredDrawable = drawable.replaceAll("[^a-zA-Z]", "").toLowerCase().trim();
        if (filteredDrawable.length() > 2 && (packageLabel.contains(filteredDrawable)
                || filteredDrawable.contains(packageLabel))) {
            matchingDrawables.add(drawable);
        }
    }
    return matchingDrawables;
}
项目:TPlayer    文件:VActivityManagerService.java   
@Override
public void processRestarted(String packageName, String processName, int userId) {
    int callingPid = getCallingPid();
    int appId = VAppManagerService.get().getAppId(packageName);
    int uid = VUserHandle.getUid(userId, appId);
    synchronized (this) {
        ProcessRecord app = findProcessLocked(callingPid);
        if (app == null) {
            ApplicationInfo appInfo = VPackageManagerService.get().getApplicationInfo(packageName, 0, userId);
            appInfo.flags |= ApplicationInfo.FLAG_HAS_CODE;
            String stubProcessName = getProcessName(callingPid);
            int vpid = parseVPid(stubProcessName);
            if (vpid != -1) {
                performStartProcessLocked(uid, vpid, appInfo, processName);
            }
        }
    }
}
项目:mobile-store    文件:AppDiff.java   
private void init() {
    String pkgName = pkgInfo.packageName;
    // Check if there is already a package on the device with this name
    // but it has been renamed to something else.
    final String[] oldName = pm.canonicalToCurrentPackageNames(new String[]{pkgName});
    if (oldName != null && oldName.length > 0 && oldName[0] != null) {
        pkgName = oldName[0];
        pkgInfo.packageName = pkgName;
        pkgInfo.applicationInfo.packageName = pkgName;
    }
    // Check if package is already installed
    try {
        // This is a little convoluted because we want to get all uninstalled
        // apps, but this may include apps with just data, and if it is just
        // data we still want to count it as "installed".
        //noinspection WrongConstant (lint is actually wrong here!)
        installedAppInfo = pm.getApplicationInfo(pkgName,
                PackageManager.GET_UNINSTALLED_PACKAGES);
        if ((installedAppInfo.flags & ApplicationInfo.FLAG_INSTALLED) == 0) {
            installedAppInfo = null;
        }
    } catch (PackageManager.NameNotFoundException e) {
        installedAppInfo = null;
    }
}
项目:AndroidDevSamples    文件:ApplicationUtil.java   
public static String getMetaData(Context context, @NonNull String key) {
    String metaDataValue = "";
    try {
        PackageManager packageManager = context.getPackageManager();
        if (packageManager != null) {
            ApplicationInfo applicationInfo = packageManager.getApplicationInfo(
                    context.getPackageName(), PackageManager.GET_META_DATA);
            if (applicationInfo != null && applicationInfo.metaData != null) {
                metaDataValue = applicationInfo.metaData.getString(key);
            }
        }
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }

    return metaDataValue;
}
项目:DroidPlugin    文件:IActivityManagerHookHandle.java   
@Override
protected boolean beforeInvoke(Object receiver, Method method, Object[] args) throws Throwable {
    //API 2.3,15,16,17,18,19, 21
/* public boolean bindBackupAgent(ApplicationInfo appInfo, int backupRestoreMode)
    throws RemoteException;*/
    final int index = 0;
    if (args != null && args.length > index) {
        if (args[index] != null && args[index] instanceof ApplicationInfo) {
            ApplicationInfo appInfo = (ApplicationInfo) args[index];
            if (isPackagePlugin(appInfo.packageName)) {
                args[index] = mHostContext.getApplicationInfo();
            }
        }
    }
    return super.beforeInvoke(receiver, method, args);
}
项目:letv    文件:AppLinkNavigation.java   
private Bundle buildAppLinkDataForNavigation(Context context) {
    Bundle data = new Bundle();
    Bundle refererAppLinkData = new Bundle();
    if (context != null) {
        String refererAppPackage = context.getPackageName();
        if (refererAppPackage != null) {
            refererAppLinkData.putString(KEY_NAME_REFERER_APP_LINK_PACKAGE, refererAppPackage);
        }
        ApplicationInfo appInfo = context.getApplicationInfo();
        if (appInfo != null) {
            String refererAppName = context.getString(appInfo.labelRes);
            if (refererAppName != null) {
                refererAppLinkData.putString("app_name", refererAppName);
            }
        }
    }
    data.putAll(getAppLinkData());
    data.putString("target_url", getAppLink().getSourceUrl().toString());
    data.putString("version", "1.0");
    data.putString(KEY_NAME_USER_AGENT, "Bolts Android 1.2.1");
    data.putBundle(KEY_NAME_REFERER_APP_LINK, refererAppLinkData);
    data.putBundle("extras", getExtras());
    return data;
}
项目:MoligyMvpArms    文件:ManifestParser.java   
public List<ConfigModule> parse() {
    List<ConfigModule> modules = new ArrayList<ConfigModule>();
    try {
        ApplicationInfo appInfo = context.getPackageManager().getApplicationInfo(
                context.getPackageName(), PackageManager.GET_META_DATA);
        if (appInfo.metaData != null) {
            for (String key : appInfo.metaData.keySet()) {
                if (MODULE_VALUE.equals(appInfo.metaData.get(key))) {
                    modules.add(parseModule(key));
                }
            }
        }
    } catch (PackageManager.NameNotFoundException e) {
        throw new RuntimeException("Unable to find metadata to parse ConfigModule", e);
    }

    return modules;
}
项目:VirtualHook    文件:VActivityManagerService.java   
@Override
public void processRestarted(String packageName, String processName, int userId) {
    int callingPid = getCallingPid();
    int appId = VAppManagerService.get().getAppId(packageName);
    int uid = VUserHandle.getUid(userId, appId);
    synchronized (this) {
        ProcessRecord app = findProcessLocked(callingPid);
        if (app == null) {
            ApplicationInfo appInfo = VPackageManagerService.get().getApplicationInfo(packageName, 0, userId);
            appInfo.flags |= ApplicationInfo.FLAG_HAS_CODE;
            String stubProcessName = getProcessName(callingPid);
            int vpid = parseVPid(stubProcessName);
            if (vpid != -1) {
                performStartProcessLocked(uid, vpid, appInfo, processName);
            }
        }
    }
}
项目:https-github.com-hyb1996-NoRootScriptDroid    文件:AppUtils.java   
@ScriptInterface
public String getAppName(String packageName) {
    PackageManager packageManager = mContext.getPackageManager();
    try {
        ApplicationInfo applicationInfo = packageManager.getApplicationInfo(packageName, 0);
        CharSequence appName = packageManager.getApplicationLabel(applicationInfo);
        return appName == null ? null : appName.toString();
    } catch (PackageManager.NameNotFoundException e) {
        return null;
    }
}
项目:container    文件:VPackageManagerService.java   
@Override
public VParceledListSlice<ApplicationInfo> getInstalledApplications(int flags, int userId) {
    checkUserId(userId);
    ArrayList<ApplicationInfo> list = new ArrayList<>(mPackages.size());
    synchronized (mPackages) {
        for (PackageParser.Package pkg : mPackages.values()) {
            list.add(getApplicationInfo(pkg.packageName, flags, userId));
        }
    }
    return new VParceledListSlice<>(list);
}
项目:container    文件:GetInstalledApplications.java   
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {

    int flags = (Integer) args[0];
    int userId = VUserHandle.myUserId();
    List<ApplicationInfo> appInfos = VPackageManager.get().getInstalledApplications(flags, userId);
    if (ParceledListSliceCompat.isReturnParceledListSlice(method)) {
        return ParceledListSliceCompat.create(appInfos);
    }
    return appInfos;
}
项目:lockit    文件:InstalledApplication.java   
private boolean isInstalledApp(ApplicationInfo appInfo) {
        if (context.getPackageName().equals(appInfo.packageName))
            return false;
//        if ((appInfo.flags & appInfo.FLAG_SYSTEM) != 0)
//            return false;
//        if ((appInfo.flags & appInfo.FLAG_UPDATED_SYSTEM_APP) != 0)
//            return false;
        return true;
    }
项目:springreplugin    文件:ActivityInjector.java   
/**
 * 获取 activity 的 icon 属性
 */
private static Bitmap getIcon(Activity activity, ActivityInfo ai) {
    Drawable iconDrawable;
    Resources res = activity.getResources();

    // 获取 Activity icon
    iconDrawable = getIconById(res, ai.icon);

    // 获取插件 Application Icon
    if (iconDrawable == null) {
        iconDrawable = getIconById(res, ai.applicationInfo.icon);
    }

    // 获取 App(Host) Icon
    if (iconDrawable == null) {
        Context appContext = RePluginInternal.getAppContext();
        Resources appResource = appContext.getResources();
        ApplicationInfo appInfo = appContext.getApplicationInfo();
        iconDrawable = getIconById(appResource, appInfo.icon);
    }

    Bitmap bitmap = null;
    if (iconDrawable instanceof BitmapDrawable) {
        bitmap = ((BitmapDrawable) iconDrawable).getBitmap();
    }

    if (LOG) {
        LogDebug.d(TAG, "bitmap = " + bitmap);
    }
    return bitmap;
}
项目:OpenAPK    文件:MainActivity.java   
@Override
protected Void doInBackground(Void... params) {
    List<PackageInfo> packages = packageManager.getInstalledPackages(PackageManager.GET_META_DATA);
    for (PackageInfo packageInfo : packages) {
        AppItem appItem = new AppItem(packageInfo);
        if (!packageInfo.applicationInfo.enabled) {
            appItem.disable = true;
            appDisabledList.add(appItem);
        } else if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
            appItem.system = true;
            appSystemList.add(appItem);
        } else {
            appInstalledList.add(appItem);
        }
    }

    appInstalledList = sortAdapter(appInstalledList);
    appSystemList = sortAdapter(appSystemList);
    appDisabledList = sortAdapter(appDisabledList);

    appInstalledAdapter = new AppAdapter(context, appInstalledList);
    appSystemAdapter = new AppAdapter(context, appSystemList);
    appDisabledAdapter = new AppAdapter(context, appDisabledList);

    appHiddenList = sortAdapter(appHiddenList);
    appHiddenAdapter = new AppAdapter(context, appHiddenList);

    appFavoriteList = sortAdapter(appFavoriteList);
    appFavoriteAdapter = new AppAdapter(context, appFavoriteList);
    return null;
}
项目:VirtualHook    文件:PackageAppData.java   
private void loadData(Context context, ApplicationInfo appInfo) {
    if (appInfo == null) {
        return;
    }
    PackageManager pm = context.getPackageManager();
    try {
        CharSequence sequence = appInfo.loadLabel(pm);
        if (sequence != null) {
            name = sequence.toString();
        }
        icon = appInfo.loadIcon(pm);
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
项目:Ghost-Android    文件:WebViewFragment.java   
@SuppressLint("SetJavaScriptEnabled")
@NonNull @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    @LayoutRes int layoutId = getArguments().getInt(KEY_LAYOUT_ID);
    View view = inflater.inflate(layoutId, container, false);
    // not using ButterKnife to ensure WebView is private
    // but still need to call bindView() to maintain base class contract
    bindView(view);
    mWebView = (WebView) view.findViewById(R.id.web_view);
    mUrl = getArguments().getString(BundleKeys.URL);
    if (TextUtils.isEmpty(mUrl)) {
        throw new IllegalArgumentException("Empty URL passed to WebViewFragment!");
    }
    Log.i(TAG, "Loading URL: %s", mUrl);

    WebSettings settings = mWebView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setDomStorageEnabled(true);

    // enable remote debugging
    if (0 != (getActivity().getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE) &&
            Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        WebView.setWebContentsDebuggingEnabled(true);
    }

    mWebView.setWebViewClient(new DefaultWebViewClient());
    mWebView.loadUrl(mUrl);

    return view;
}
项目:GitHub    文件:AppUtils.java   
/**
 * 得到AppInfo的Bean
 *
 * @param pm 包的管理
 * @param pi 包的信息
 * @return AppInfo类
 */
private static AppInfo getBean(final PackageManager pm, final PackageInfo pi) {
    if (pm == null || pi == null) return null;
    ApplicationInfo ai = pi.applicationInfo;
    String packageName = pi.packageName;
    String name = ai.loadLabel(pm).toString();
    Drawable icon = ai.loadIcon(pm);
    String packagePath = ai.sourceDir;
    String versionName = pi.versionName;
    int versionCode = pi.versionCode;
    boolean isSystem = (ApplicationInfo.FLAG_SYSTEM & ai.flags) != 0;
    return new AppInfo(packageName, name, icon, packagePath, versionName, versionCode, isSystem);
}
项目:AutoInteraction-Library    文件:Util.java   
/**
 * 获取布局的ID
 */
public static int getLayoutResId(Context context, String name) {
    ApplicationInfo appInfo = context.getApplicationInfo();
    int resID = context.getResources().getIdentifier(name, "layout", appInfo.packageName);
    return resID;
}
项目:prevent    文件:LabelLoader.java   
private void loadLabelIfNeeded(final ApplicationInfo info) {
    executor.submit(new Runnable() {
        @Override
        public void run() {
            String packageName = info.packageName;
            String label = StringUtils.trim(info.loadLabel(mPm)).toString();
            if (!label.equals(mSp.getString(packageName, packageName))) {
                mSp.edit().putString(packageName, label).apply();
            }
        }
    });
}
项目:XamarinForms-Encryption    文件:MonoPackageManager.java   
public static void LoadApplication (Context context, ApplicationInfo runtimePackage, String[] apks)
{
    synchronized (lock) {
        if (context instanceof android.app.Application) {
            Context = context;
        }
        if (!initialized) {
            android.content.IntentFilter timezoneChangedFilter  = new android.content.IntentFilter (
                    android.content.Intent.ACTION_TIMEZONE_CHANGED
            );
            context.registerReceiver (new mono.android.app.NotifyTimeZoneChanges (), timezoneChangedFilter);

            System.loadLibrary("monodroid");
            Locale locale       = Locale.getDefault ();
            String language     = locale.getLanguage () + "-" + locale.getCountry ();
            String filesDir     = context.getFilesDir ().getAbsolutePath ();
            String cacheDir     = context.getCacheDir ().getAbsolutePath ();
            String dataDir      = getNativeLibraryPath (context);
            ClassLoader loader  = context.getClassLoader ();

            Runtime.init (
                    language,
                    apks,
                    getNativeLibraryPath (runtimePackage),
                    new String[]{
                        filesDir,
                        cacheDir,
                        dataDir,
                    },
                    loader,
                    new java.io.File (
                        android.os.Environment.getExternalStorageDirectory (),
                        "Android/data/" + context.getPackageName () + "/files/.__override__").getAbsolutePath (),
                    MonoPackageManager_Resources.Assemblies,
                    context.getPackageName ());

            mono.android.app.ApplicationRegistration.registerApplications ();

            initialized = true;
        }
    }
}
项目:MiPushFramework    文件:CondomProcess.java   
/**
 * Install the condom protection for current process if its process name matches. This method should be called in {@link Application#onCreate()}.
 *
 * @param process_names list of processes where Condom process should NOT be installed, in the form exactly as defined
 *                      by <code>"android:process"</code> attribute of components in <code>AndroidManifest.xml</code>.
 *                      <b>BEWARE: Default process must be explicitly listed here if it is expected to be excluded.</b>
 */
public static void installExcept(final Application app, final CondomOptions options, final String... process_names) {
    if (process_names.length == 0) throw new IllegalArgumentException("At lease one process name must be specified");
    validateCondomOptions(options);
    final String current_process_name = getProcessName(app);
    if (current_process_name == null) return;
    for (final String process_name : process_names)
        if (! current_process_name.equals(getFullProcessName(app, process_name))) {
            install(app, current_process_name, options);
            return;
        }

    if ((app.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) validateProcessNames(app, process_names);
}
项目:FreeStreams-TVLauncher    文件:TaskInfoProvider.java   
public List<TaskInfo> GetAllTask(List<RunningAppProcessInfo> list) {
    List<TaskInfo> taskInfos = new ArrayList<TaskInfo>();
    for (RunningAppProcessInfo appProcessInfo : list) {
        TaskInfo info = new TaskInfo();
        int id = appProcessInfo.pid;
        info.setId(id);
        String packageName = appProcessInfo.processName;
        info.setPackageName(packageName);
        try {
            // ApplicationInfo是AndroidMainfest文件里面整个Application节点的封装װ
            ApplicationInfo applicationInfo = pmManager.getPackageInfo(
                    packageName, 0).applicationInfo;
            Drawable icon = applicationInfo.loadIcon(pmManager);
            info.setIcon(icon);
            String name = applicationInfo.loadLabel(pmManager).toString();
            info.setName(name);
            info.setIsSystemProcess(!IsSystemApp(applicationInfo));
            android.os.Debug.MemoryInfo[] memoryInfo = aManager
                    .getProcessMemoryInfo(new int[] { id });
            int memory = memoryInfo[0].getTotalPrivateDirty();
            info.setMemory(memory);
            taskInfos.add(info);
            info = null;
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            info.setName(packageName);
            info.setIsSystemProcess(true);
        }
    }
    return taskInfos;
}
项目:boohee_v5.6    文件:SharePatchFileUtil.java   
public static File getPatchDirectory(Context context) {
    ApplicationInfo applicationInfo = context.getApplicationInfo();
    if (applicationInfo == null) {
        return null;
    }
    return new File(applicationInfo.dataDir, ShareConstants.PATCH_DIRECTORY_NAME);
}
项目:Paper-Launcher    文件:IconRow.java   
@Override
public String toString() {
    StringBuilder output = new StringBuilder();
    for (ApplicationInfo applicationInfo : mApplicationInfoList) {
        output.append("\n" + "Package name: ").append(
                applicationInfo == null ? "null" : applicationInfo.packageName);
    }

    return output.toString();
}
项目:TPlayer    文件:VPackageManagerService.java   
@Override
public ApplicationInfo getApplicationInfo(String packageName, int flags, int userId) {
    checkUserId(userId);
    flags = updateFlagsNought(flags);
    synchronized (mPackages) {
        VPackage p = mPackages.get(packageName);
        if (p != null) {
            PackageSetting ps = (PackageSetting) p.mExtras;
            return PackageParserEx.generateApplicationInfo(p, flags, ps.readUserState(userId), userId);
        }
    }
    return null;
}
项目:VirtualHook    文件:VPackageManager.java   
public List<ApplicationInfo> getInstalledApplications(int flags, int userId) {
    try {
        // noinspection unchecked
        return getInterface().getInstalledApplications(flags, userId).getList();
    } catch (RemoteException e) {
        return VirtualRuntime.crash(e);
    }
}
项目:AutoInteraction-Library    文件:Util.java   
/**
 * @return true: debug false:release
 * @description 判断当前程序是否出于DEBUG模式
 */
public static boolean isDebug(Context context) {
    // 如果是开发使用则直接开启日志,否则根据当前状态判断
    try {
        ApplicationInfo info = context.getPackageManager().getApplicationInfo(context.getPackageName(), 0);
        return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) == ApplicationInfo.FLAG_DEBUGGABLE;
    } catch (PackageManager.NameNotFoundException e) {
    }
    return false;
}
项目:RLibrary    文件:AppUtils.java   
/**
 * 得到AppInfo的Bean
 *
 * @param pm 包的管理
 * @param pi 包的信息
 * @return AppInfo类
 */
private static AppInfo getBean(PackageManager pm, PackageInfo pi) {
    if (pm == null || pi == null) return null;
    ApplicationInfo ai = pi.applicationInfo;
    String packageName = pi.packageName;
    String name = ai.loadLabel(pm).toString();
    Drawable icon = ai.loadIcon(pm);
    String packagePath = ai.sourceDir;
    String versionName = pi.versionName;
    int versionCode = pi.versionCode;
    boolean isSystem = (ApplicationInfo.FLAG_SYSTEM & ai.flags) != 0;
    return new AppInfo(packageName, name, icon, packagePath, versionName, versionCode, isSystem);
}
项目:easyfilemanager    文件:AppsProvider.java   
@Override
public String copyDocument(String sourceDocumentId, String targetParentDocumentId) throws FileNotFoundException {
    final String packageName = getPackageForDocId(sourceDocumentId);
    String fromFilePath = "";
    String fileName = "";
    try {
        PackageInfo packageInfo = packageManager.getPackageInfo(packageName, 0);
        ApplicationInfo appInfo = packageInfo.applicationInfo;
        fromFilePath = appInfo.sourceDir;
        fileName = (String) (appInfo.loadLabel(packageManager) != null ? appInfo.loadLabel(packageManager) : appInfo.packageName);
        fileName += getAppVersion(packageInfo.versionName);
    } catch (Exception e) {
    }

    final File fileFrom = new File(fromFilePath);
    final File fileTo = Utils.getAppsBackupFile(getContext());
    if(!fileTo.exists()){
        fileTo.mkdir();
    }
    if (!FileUtils.moveDocument(fileFrom, fileTo, fileName)) {
        throw new IllegalStateException("Failed to copy " + fileFrom);
    }
    else{
        FileUtils.updateMediaStore(getContext(), FileUtils.makeFilePath(fileTo.getPath(),
                fileName +"."+ FileUtils.getExtFromFilename(fileFrom.getPath())));
    }
    return fromFilePath;
}
项目:android_ui    文件:AppsAsyncTask.java   
@Override
protected List<ApplicationInfo> doInBackground(Void... params) {
    if (mAppsAdapter != null) {
        final Context context = mAppsAdapter.getContext();
        final PackageManager packageManager = context.getPackageManager();
        if (packageManager != null) {
            return packageManager.getInstalledApplications(PackageManager.GET_META_DATA);
        }

    }
    return null;
}
项目:support-application    文件:ApplicationCompat.java   
/**
 * 是否是debug构建包
 *
 * @return 是否是debug构建包
 */
public static boolean isDebuggable() {
    try {
        PackageManager packageManager = getApplication().getPackageManager();
        PackageInfo packInfo = packageManager.getPackageInfo(getApplication().getPackageName(), 0);
        ApplicationInfo info = packInfo.applicationInfo;
        return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}