android.content.pm.PackageInstaller.SessionInfo Java Examples
The following examples show how to use
android.content.pm.PackageInstaller.SessionInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PackageInstallerService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
@Override public ParceledListSlice<SessionInfo> getAllSessions(int userId) { mPermissionManager.enforceCrossUserPermission( Binder.getCallingUid(), userId, true, false, "getAllSessions"); final List<SessionInfo> result = new ArrayList<>(); synchronized (mSessions) { for (int i = 0; i < mSessions.size(); i++) { final PackageInstallerSession session = mSessions.valueAt(i); if (session.userId == userId) { result.add(session.generateInfo(false)); } } } return new ParceledListSlice<>(result); }
Example #2
Source File: PackageInstallerService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
@Override public ParceledListSlice<SessionInfo> getMySessions(String installerPackageName, int userId) { mPermissionManager.enforceCrossUserPermission( Binder.getCallingUid(), userId, true, false, "getMySessions"); mAppOps.checkPackage(Binder.getCallingUid(), installerPackageName); final List<SessionInfo> result = new ArrayList<>(); synchronized (mSessions) { for (int i = 0; i < mSessions.size(); i++) { final PackageInstallerSession session = mSessions.valueAt(i); SessionInfo info = session.generateInfo(false); if (Objects.equals(info.getInstallerPackageName(), installerPackageName) && session.userId == userId) { result.add(info); } } } return new ParceledListSlice<>(result); }
Example #3
Source File: PackageInstallerCompatVL.java From LB-Launcher with Apache License 2.0 | 6 votes |
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); } } }); }
Example #4
Source File: PackageInstallerCompatVL.java From Trebuchet with GNU General Public License v3.0 | 5 votes |
@Thunk void addSessionInfoToCahce(SessionInfo info, UserHandleCompat user) { String packageName = info.getAppPackageName(); if (packageName != null) { mCache.cachePackageInstallInfo(packageName, user, info.getAppIcon(), info.getAppLabel()); } }
Example #5
Source File: PackageInstallerCompatVL.java From LB-Launcher with Apache License 2.0 | 5 votes |
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); } }
Example #6
Source File: PackageInstallerCompatVL.java From LB-Launcher with Apache License 2.0 | 5 votes |
@Override public void onProgressChanged(int sessionId, float progress) { SessionInfo session = mInstaller.getSessionInfo(sessionId); if (session != null) { mPendingReplays.put(sessionId, session); replayUpdates(null); } }
Example #7
Source File: PackageInstallerCompatVL.java From LB-Launcher with Apache License 2.0 | 5 votes |
@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)); } }
Example #8
Source File: PackageInstallerCompatVL.java From LB-Launcher with Apache License 2.0 | 5 votes |
private void addSessionInfoToCahce(SessionInfo info, UserHandleCompat user) { String packageName = info.getAppPackageName(); if (packageName != null) { mCache.cachePackageInstallInfo(packageName, user, info.getAppIcon(), info.getAppLabel()); } }
Example #9
Source File: PackageInstallerCompatVL.java From LB-Launcher with Apache License 2.0 | 5 votes |
@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; }
Example #10
Source File: PackageInstallerCompatVL.java From Trebuchet with GNU General Public License v3.0 | 5 votes |
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()); } } }
Example #11
Source File: PackageInstallerCompatVL.java From Trebuchet with GNU General Public License v3.0 | 5 votes |
@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))); } }
Example #12
Source File: PackageInstallerCompatVL.java From Trebuchet with GNU General Public License v3.0 | 5 votes |
@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; }
Example #13
Source File: PackageInstallerCompatVL.java From LaunchEnr with GNU General Public License v3.0 | 5 votes |
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()); } } }
Example #14
Source File: PackageInstallerCompatVL.java From LaunchEnr with GNU General Public License v3.0 | 5 votes |
@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))); } }
Example #15
Source File: PackageInstallerCompatVL.java From LaunchEnr with GNU General Public License v3.0 | 5 votes |
@Thunk private void addSessionInfoToCache(SessionInfo info, UserHandle user) { String packageName = info.getAppPackageName(); if (packageName != null) { mCache.cachePackageInstallInfo(packageName, user, info.getAppIcon(), info.getAppLabel()); } }
Example #16
Source File: PackageInstallerCompatVL.java From LaunchEnr with GNU General Public License v3.0 | 5 votes |
@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; }
Example #17
Source File: PackageInstallerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public SessionInfo getSessionInfo(int sessionId) { synchronized (mSessions) { final PackageInstallerSession session = mSessions.get(sessionId); return session != null ? session.generateInfo() : null; } }
Example #18
Source File: PackageInstallerSession.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
public SessionInfo generateInfo(boolean includeIcon) { final SessionInfo info = new SessionInfo(); synchronized (mLock) { info.sessionId = sessionId; info.installerPackageName = mInstallerPackageName; info.resolvedBaseCodePath = (mResolvedBaseFile != null) ? mResolvedBaseFile.getAbsolutePath() : null; info.progress = mProgress; info.sealed = mSealed; info.active = mActiveCount.get() > 0; info.mode = params.mode; info.installReason = params.installReason; info.sizeBytes = params.sizeBytes; info.appPackageName = params.appPackageName; if (includeIcon) { info.appIcon = params.appIcon; } info.appLabel = params.appLabel; info.installLocation = params.installLocation; info.originatingUri = params.originatingUri; info.originatingUid = params.originatingUid; info.referrerUri = params.referrerUri; info.grantedRuntimePermissions = params.grantedRuntimePermissions; info.installFlags = params.installFlags; } return info; }
Example #19
Source File: PackageInstallerSession.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
public SessionInfo generateInfo() { return generateInfo(true); }
Example #20
Source File: PackageInstallerCompatVL.java From LB-Launcher with Apache License 2.0 | 4 votes |
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(); } }