public void forceClose() { closeQuietly(mTarget); closeQuietly(mServer); closeQuietly(mClient); mClosed = true; }
@Override public void onPackageInstalled(String basePackageName, int returnCode, String msg, Bundle extras) { PackageInstallObserver.this.onPackageInstalled(basePackageName, returnCode, msg, extras); } };
public static String installStatusToString(int status, String msg) { final String str = installStatusToString(status); if (msg != null) { return str + ": " + msg; } else { return str; } }
@Override public void updateSessionAppIcon(int sessionId, Bitmap appIcon) { synchronized (mSessions) { final PackageInstallerSession session = mSessions.get(sessionId); if (session == null || !isCallingUidOwner(session)) { throw new SecurityException("Caller has no access to session " + sessionId); } session.params.appIcon = appIcon; session.params.appIconLastModified = -1; mInternalCallback.onSessionBadgingChanged(session); } }
@Override public void abandon() throws RemoteException { destroyInternal(); dispatchSessionFinished(INSTALL_FAILED_ABORTED, "Session was abandoned", null); }
private void computeProgressLocked(boolean forcePublish) { mProgress = constrain(mClientProgress * 0.8f, 0f, 0.8f) + constrain(mInternalProgress * 0.2f, 0f, 0.2f); // Only publish when meaningful change if (forcePublish || Math.abs(mProgress - mReportedProgress) >= 0.01) { mReportedProgress = mProgress; mCallback.onSessionProgressChanged(this, mProgress); } }
@Override public void abandonSession(int sessionId) throws RemoteException { synchronized (mSessions) { final PackageInstallerSession session = mSessions.get(sessionId); if (session == null || !isCallingUidOwner(session)) { throw new SecurityException("Caller has no access to session " + sessionId); } session.abandon(); } }
private IPackageInstallerSession openSessionInternal(int sessionId) throws IOException { synchronized (mSessions) { final PackageInstallerSession session = mSessions.get(sessionId); if (session == null || !isCallingUidOwner(session)) { throw new SecurityException("Caller has no access to session " + sessionId); } session.open(); return session; } }
@Override public void setClientProgress(float progress) throws RemoteException { synchronized (mLock) { // Always publish first staging movement final boolean forcePublish = (mClientProgress == 0); mClientProgress = progress; computeProgressLocked(forcePublish); } }
@Override public void addClientProgress(float progress) throws RemoteException { synchronized (mLock) { setClientProgress(mClientProgress + progress); } }
@Override protected VPackageInstallerService create() { return new VPackageInstallerService(); } };
@Override public void unregisterCallback(IPackageInstallerCallback callback) throws RemoteException { mCallbacks.unregister(callback); }
@Override public void registerCallback(IPackageInstallerCallback callback, int userId) throws RemoteException { mCallbacks.register(callback, userId); }
@Override public void onUserActionRequired(Intent intent) { PackageInstallObserver.this.onUserActionRequired(intent); }
@Override public IPackageInstaller getPackageInstaller() { return VPackageInstallerService.get(); }
@Override public void close() throws RemoteException { if (mActiveCount.decrementAndGet() == 0) { mCallback.onSessionActiveChanged(this, false); } }
public void onSessionFinished(final PackageInstallerSession session, boolean success) { mCallbacks.notifySessionFinished(session.sessionId, session.userId, success); mInstallHandler.post(new Runnable() { @Override public void run() { synchronized (mSessions) { mSessions.remove(session.sessionId); } } }); }
@Override public ParcelFileDescriptor openWrite(String name, long offsetBytes, long lengthBytes) throws RemoteException { try { return openWriteInternal(name, offsetBytes, lengthBytes); } catch (IOException e) { throw new IllegalStateException(e); } }
@Override public int createSession(SessionParams params, String installerPackageName, int userId) throws RemoteException { try { return createSessionInternal(params, installerPackageName, userId); } catch (IOException e) { throw new IllegalStateException(e); } }
@Override public void updateSessionAppLabel(int sessionId, String appLabel) throws RemoteException { synchronized (mSessions) { final PackageInstallerSession session = mSessions.get(sessionId); if (session == null || !isCallingUidOwner(session)) { throw new SecurityException("Caller has no access to session " + sessionId); } session.params.appLabel = appLabel; mInternalCallback.onSessionBadgingChanged(session); } }