public PackageInstallerImpl(Context paramContext) { this.mContext = paramContext; this.mPackageInstaller = this.mContext.getPackageManager().getPackageInstaller(); this.mSessionInfoMap = new HashMap(); Iterator localIterator = this.mPackageInstaller.getMySessions().iterator(); while (localIterator.hasNext()) { PackageInstaller.SessionInfo localSessionInfo1 = (PackageInstaller.SessionInfo)localIterator.next(); String str = localSessionInfo1.getAppPackageName(); PackageInstaller.SessionInfo localSessionInfo2 = (PackageInstaller.SessionInfo)this.mSessionInfoMap.put(str, localSessionInfo1); if (localSessionInfo2 != null) { Object[] arrayOfObject = new Object[3]; arrayOfObject[0] = str; arrayOfObject[1] = Integer.valueOf(localSessionInfo2.getSessionId()); arrayOfObject[2] = Integer.valueOf(localSessionInfo1.getSessionId()); FinskyLog.w("Multiple sessions for %s found. Removing %d & keeping %d.", arrayOfObject); } } this.mOpenSessionMap = new HashMap(); }
private static boolean a(Context paramContext, String paramString) { if (Build.VERSION.SDK_INT >= 21) {} for (int i = 1; i != 0; i = 0) { Iterator localIterator = paramContext.getPackageManager().getPackageInstaller().getAllSessions().iterator(); do { if (!localIterator.hasNext()) { break; } } while (!paramString.equals(((PackageInstaller.SessionInfo)localIterator.next()).getAppPackageName())); return true; } PackageManager localPackageManager = paramContext.getPackageManager(); try { boolean bool = localPackageManager.getApplicationInfo(paramString, 8192).enabled; if (bool) { return true; } } catch (PackageManager.NameNotFoundException localNameNotFoundException) {} return false; }
PackageInstallerCompatVL(Context context) { mInstaller = context.getPackageManager().getPackageInstaller(); LauncherAppState.setApplicationContext(context.getApplicationContext()); mCache = LauncherAppState.getInstance().getIconCache(); mWorker = new Handler(); mResumed = false; mBound = false; mInstaller.registerSessionCallback(mCallback, mWorker); // On start, send updates for all active sessions mWorker.post(new Runnable() { @Override public void run() { for (SessionInfo info : mInstaller.getAllSessions()) { mPendingReplays.append(info.getSessionId(), info); } } }); }
@Override public HashMap<String, Integer> updateAndGetActiveSessionCache() { HashMap<String, Integer> activePackages = new HashMap<>(); UserHandle user = Process.myUserHandle(); for (SessionInfo info : mInstaller.getAllSessions()) { addSessionInfoToCache(info, user); if (info.getAppPackageName() != null) { activePackages.put(info.getAppPackageName(), (int) (info.getProgress() * 100)); mActiveSessions.put(info.getSessionId(), info.getAppPackageName()); } } return activePackages; }
@Thunk private void addSessionInfoToCache(SessionInfo info, UserHandle user) { String packageName = info.getAppPackageName(); if (packageName != null) { mCache.cachePackageInstallInfo(packageName, user, info.getAppIcon(), info.getAppLabel()); } }
@Override public void onProgressChanged(int sessionId, float progress) { SessionInfo session = mInstaller.getSessionInfo(sessionId); if (session != null && session.getAppPackageName() != null) { sendUpdate(new PackageInstallInfo(session.getAppPackageName(), STATUS_INSTALLING, (int) (session.getProgress() * 100))); } }
private void pushSessionDisplayToLauncher(int sessionId) { SessionInfo session = mInstaller.getSessionInfo(sessionId); if (session != null && session.getAppPackageName() != null) { addSessionInfoToCache(session, Process.myUserHandle()); LauncherAppState app = LauncherAppState.getInstanceNoCreate(); if (app != null) { app.getModel().updateSessionDisplayInfo(session.getAppPackageName()); } } }
@Override public HashMap<String, Integer> updateAndGetActiveSessionCache() { HashMap<String, Integer> activePackages = new HashMap<>(); UserHandleCompat user = UserHandleCompat.myUserHandle(); for (SessionInfo info : mInstaller.getAllSessions()) { addSessionInfoToCahce(info, user); if (info.getAppPackageName() != null) { activePackages.put(info.getAppPackageName(), (int) (info.getProgress() * 100)); mActiveSessions.put(info.getSessionId(), info.getAppPackageName()); } } return activePackages; }
@Thunk void addSessionInfoToCahce(SessionInfo info, UserHandleCompat user) { String packageName = info.getAppPackageName(); if (packageName != null) { mCache.cachePackageInstallInfo(packageName, user, info.getAppIcon(), info.getAppLabel()); } }
private void pushSessionDisplayToLauncher(int sessionId) { SessionInfo session = mInstaller.getSessionInfo(sessionId); if (session != null && session.getAppPackageName() != null) { addSessionInfoToCahce(session, UserHandleCompat.myUserHandle()); LauncherAppState app = LauncherAppState.getInstanceNoCreate(); if (app != null) { app.getModel().updateSessionDisplayInfo(session.getAppPackageName()); } } }
@Override public void onProgressChanged(int sessionId, float progress) { SessionInfo session = mInstaller.getSessionInfo(sessionId); if (session != null) { sendUpdate(new PackageInstallInfo(session.getAppPackageName(), STATUS_INSTALLING, (int) (session.getProgress() * 100))); } }
private void pushSessionDisplayToLauncher(int sessionId) { SessionInfo session = mInstaller.getSessionInfo(sessionId); if (session != null) { addSessionInfoToCahce(session, UserHandleCompat.myUserHandle()); LauncherAppState app = LauncherAppState.getInstanceNoCreate(); if (app != null) { app.getModel().updateSessionDisplayInfo(session.getAppPackageName()); } } }
@Override public HashSet<String> updateAndGetActiveSessionCache() { HashSet<String> activePackages = new HashSet<String>(); UserHandleCompat user = UserHandleCompat.myUserHandle(); for (SessionInfo info : mInstaller.getAllSessions()) { addSessionInfoToCahce(info, user); if (info.getAppPackageName() != null) { activePackages.add(info.getAppPackageName()); } } return activePackages; }
private void addSessionInfoToCahce(SessionInfo info, UserHandleCompat user) { String packageName = info.getAppPackageName(); if (packageName != null) { mCache.cachePackageInstallInfo(packageName, user, info.getAppIcon(), info.getAppLabel()); } }
@Override public void onFinished(int sessionId, boolean success) { mPendingReplays.remove(sessionId); SessionInfo session = mInstaller.getSessionInfo(sessionId); if ((session != null) && (session.getAppPackageName() != null)) { mPendingBadgeUpdates.remove(session.getAppPackageName()); // Replay all updates with a one time update for this installed package. No // need to store this record for future updates, as the app list will get // refreshed on resume. replayUpdates(new PackageInstallInfo(session.getAppPackageName(), success ? STATUS_INSTALLED : STATUS_FAILED, 0)); } }
@Override public void onProgressChanged(int sessionId, float progress) { SessionInfo session = mInstaller.getSessionInfo(sessionId); if (session != null) { mPendingReplays.put(sessionId, session); replayUpdates(null); } }
private void pushSessionBadgeToLauncher(int sessionId) { SessionInfo session = mInstaller.getSessionInfo(sessionId); if (session != null) { addSessionInfoToCahce(session, UserHandleCompat.myUserHandle()); if (session.getAppPackageName() != null) { mPendingBadgeUpdates.add(session.getAppPackageName()); } mPendingReplays.put(sessionId, session); replayUpdates(null); } }
static boolean zzi(Context paramContext, String paramString) { boolean bool1 = true; if (zzq.zzdC(21)) { Iterator localIterator = paramContext.getPackageManager().getPackageInstaller().getAllSessions().iterator(); while (localIterator.hasNext()) { if (paramString.equals(((PackageInstaller.SessionInfo)localIterator.next()).getAppPackageName())) { return bool1; } } } if (zzq.zzdC(18)) { Bundle localBundle = ((UserManager)paramContext.getSystemService("user")).getApplicationRestrictions(paramContext.getPackageName()); if ((localBundle == null) || (!"true".equals(localBundle.getString("restricted_profile")))) {} } while (bool1) { return false; bool1 = false; } PackageManager localPackageManager = paramContext.getPackageManager(); try { boolean bool2 = localPackageManager.getApplicationInfo(paramString, 8192).enabled; return bool2; } catch (PackageManager.NameNotFoundException localNameNotFoundException) {} return false; }
private void replayUpdates(PackageInstallInfo newInfo) { if (DEBUG) Log.d(TAG, "updates resumed"); if (!mResumed || !mBound) { // Not yet ready return; } if ((mPendingReplays.size() == 0) && (newInfo == null)) { // Nothing to update return; } LauncherAppState app = LauncherAppState.getInstanceNoCreate(); if (app == null) { // Try again later if (DEBUG) Log.d(TAG, "app is null, delaying send"); return; } ArrayList<PackageInstallInfo> updates = new ArrayList<PackageInstallInfo>(); if ((newInfo != null) && (newInfo.state != STATUS_INSTALLED)) { updates.add(newInfo); } for (int i = mPendingReplays.size() - 1; i >= 0; i--) { SessionInfo session = mPendingReplays.valueAt(i); if (session.getAppPackageName() != null) { updates.add(new PackageInstallInfo(session.getAppPackageName(), STATUS_INSTALLING, (int) (session.getProgress() * 100))); } } mPendingReplays.clear(); if (!updates.isEmpty()) { app.setPackageState(updates); } if (!mPendingBadgeUpdates.isEmpty()) { for (String pkg : mPendingBadgeUpdates) { app.updatePackageBadge(pkg); } mPendingBadgeUpdates.clear(); } }