android.content.pm.IPackageDataObserver Java Examples

The following examples show how to use android.content.pm.IPackageDataObserver. 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 Project: BlockCanaryEx   Author: seiginonakama   File: TestUtil.java    License: Apache License 2.0 6 votes vote down vote up
public static void testProvide() {
    IPackageDataObserver packageDataObserver = new IPackageDataObserver() {
        @Override
        public void onRemoveCompleted(String s, boolean b) throws RemoteException {
            doHeavyWork();
            doHeavyWork();
        }

        @Override
        public IBinder asBinder() {
            return null;
        }
    };
    try {
        packageDataObserver.onRemoveCompleted("haha", false);
    } catch (RemoteException e) {
        e.printStackTrace();
    }
    doHeavyWork();
}
 
Example #2
Source Project: MemoryCleaner   Author: towavephone   File: CleanerService.java    License: Apache License 2.0 6 votes vote down vote up
@Override protected Long doInBackground(Void... params) {
    final CountDownLatch countDownLatch = new CountDownLatch(1);

    StatFs stat = new StatFs(
            Environment.getDataDirectory().getAbsolutePath());

    try {
        mFreeStorageAndNotifyMethod.invoke(getPackageManager(),
                (long) stat.getBlockCount() *
                        (long) stat.getBlockSize(),
                new IPackageDataObserver.Stub() {
                    @Override
                    public void onRemoveCompleted(String packageName, boolean succeeded)
                            throws RemoteException {
                        countDownLatch.countDown();
                    }
                });

        countDownLatch.await();
    } catch (InvocationTargetException | InterruptedException | IllegalAccessException e) {
        e.printStackTrace();
    }

    return mCacheSize;
}
 
Example #3
Source Project: MemoryCleaner   Author: towavephone   File: CleanerService.java    License: Apache License 2.0 6 votes vote down vote up
@Override public void onCreate() {
    try {
        mGetPackageSizeInfoMethod = getPackageManager().getClass()
                                                       .getMethod(
                                                               "getPackageSizeInfo",
                                                               String.class,
                                                               IPackageStatsObserver.class);

        mFreeStorageAndNotifyMethod = getPackageManager().getClass()
                                                         .getMethod(
                                                                 "freeStorageAndNotify",
                                                                 long.class,
                                                                 IPackageDataObserver.class);
        mDeleteApplicationCacheFiles = getPackageManager().getClass()
                                                          .getMethod(
                                                                  "deleteApplicationCacheFiles",
                                                                  String.class,
                                                                  IPackageDataObserver.class);
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    }
}
 
Example #4
Source Project: MobileGuard   Author: ittianyu   File: AppManagerEngine.java    License: MIT License 6 votes vote down vote up
/**
 * clear all app cache
 * @param context
 * @param listener the completion listener, it can be null if you don't care the result.
 *                 onClearCompleted run on child thread.
 *                 onClearFailed run on UI thread.
 */
public static void clearAllCache(Context context, final ClearCacheListener listener) {
    /*
    public void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer) {
        freeStorageAndNotify(null, freeStorageSize, observer);
    }
     */
    PackageManager pm = context.getPackageManager();
    try {
        Method freeStorageAndNotify = pm.getClass().getDeclaredMethod("freeStorageAndNotify", long.class, IPackageDataObserver.class);
        freeStorageAndNotify.invoke(pm, Long.MAX_VALUE, new IPackageDataObserver.Stub(){
            @Override
            public void onRemoveCompleted(String packageName, boolean succeeded) throws RemoteException {
                if(null != listener)
                    listener.onClearCompleted();
            }
        });

    } catch (Exception e) {
        e.printStackTrace();
        if(null != listener)
            listener.onClearFailed();
    }
}
 
Example #5
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ApplicationPackageManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void clearApplicationUserData(String packageName,
                                     IPackageDataObserver observer) {
    try {
        mPM.clearApplicationUserData(packageName, observer, mContext.getUserId());
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #6
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ApplicationPackageManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void deleteApplicationCacheFiles(String packageName,
                                        IPackageDataObserver observer) {
    try {
        mPM.deleteApplicationCacheFiles(packageName, observer);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #7
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ApplicationPackageManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void deleteApplicationCacheFilesAsUser(String packageName, int userId,
        IPackageDataObserver observer) {
    try {
        mPM.deleteApplicationCacheFilesAsUser(packageName, userId, observer);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #8
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ApplicationPackageManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void freeStorageAndNotify(String volumeUuid, long idealStorageSize,
        IPackageDataObserver observer) {
    try {
        mPM.freeStorageAndNotify(volumeUuid, idealStorageSize, observer);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #9
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ApplicationPackageManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void clearApplicationUserData(String packageName,
                                     IPackageDataObserver observer) {
    try {
        mPM.clearApplicationUserData(packageName, observer, mContext.getUserId());
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #10
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ApplicationPackageManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void deleteApplicationCacheFiles(String packageName,
                                        IPackageDataObserver observer) {
    try {
        mPM.deleteApplicationCacheFiles(packageName, observer);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #11
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ApplicationPackageManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void deleteApplicationCacheFilesAsUser(String packageName, int userId,
        IPackageDataObserver observer) {
    try {
        mPM.deleteApplicationCacheFilesAsUser(packageName, userId, observer);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #12
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ApplicationPackageManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void freeStorageAndNotify(String volumeUuid, long idealStorageSize,
        IPackageDataObserver observer) {
    try {
        mPM.freeStorageAndNotify(volumeUuid, idealStorageSize, 0, observer);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #13
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ApplicationPackageManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void clearApplicationUserData(String packageName,
                                     IPackageDataObserver observer) {
    try {
        mPM.clearApplicationUserData(packageName, observer, mContext.getUserId());
    } catch (RemoteException e) {
        // Should never happen!
    }
}
 
Example #14
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ApplicationPackageManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void deleteApplicationCacheFiles(String packageName,
                                        IPackageDataObserver observer) {
    try {
        mPM.deleteApplicationCacheFiles(packageName, observer);
    } catch (RemoteException e) {
        // Should never happen!
    }
}
 
Example #15
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ApplicationPackageManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void freeStorageAndNotify(String volumeUuid, long idealStorageSize,
        IPackageDataObserver observer) {
    try {
        mPM.freeStorageAndNotify(volumeUuid, idealStorageSize, observer);
    } catch (RemoteException e) {
        // Should never happen!
    }
}
 
Example #16
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ApplicationPackageManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void clearApplicationUserData(String packageName,
                                     IPackageDataObserver observer) {
    try {
        mPM.clearApplicationUserData(packageName, observer, mContext.getUserId());
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #17
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ApplicationPackageManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void deleteApplicationCacheFiles(String packageName,
                                        IPackageDataObserver observer) {
    try {
        mPM.deleteApplicationCacheFiles(packageName, observer);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #18
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ApplicationPackageManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void deleteApplicationCacheFilesAsUser(String packageName, int userId,
        IPackageDataObserver observer) {
    try {
        mPM.deleteApplicationCacheFilesAsUser(packageName, userId, observer);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #19
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ApplicationPackageManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void freeStorageAndNotify(String volumeUuid, long idealStorageSize,
        IPackageDataObserver observer) {
    try {
        mPM.freeStorageAndNotify(volumeUuid, idealStorageSize, 0, observer);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #20
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ApplicationPackageManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void clearApplicationUserData(String packageName,
                                     IPackageDataObserver observer) {
    try {
        mPM.clearApplicationUserData(packageName, observer, mContext.getUserId());
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #21
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ApplicationPackageManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void deleteApplicationCacheFiles(String packageName,
                                        IPackageDataObserver observer) {
    try {
        mPM.deleteApplicationCacheFiles(packageName, observer);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #22
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ApplicationPackageManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void deleteApplicationCacheFilesAsUser(String packageName, int userId,
        IPackageDataObserver observer) {
    try {
        mPM.deleteApplicationCacheFilesAsUser(packageName, userId, observer);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #23
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ApplicationPackageManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void freeStorageAndNotify(String volumeUuid, long idealStorageSize,
        IPackageDataObserver observer) {
    try {
        mPM.freeStorageAndNotify(volumeUuid, idealStorageSize, 0, observer);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #24
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ApplicationPackageManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void clearApplicationUserData(String packageName,
                                     IPackageDataObserver observer) {
    try {
        mPM.clearApplicationUserData(packageName, observer);
    } catch (RemoteException e) {
        // Should never happen!
    }
}
 
Example #25
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ApplicationPackageManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void deleteApplicationCacheFiles(String packageName,
                                        IPackageDataObserver observer) {
    try {
        mPM.deleteApplicationCacheFiles(packageName, observer);
    } catch (RemoteException e) {
        // Should never happen!
    }
}
 
Example #26
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ApplicationPackageManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void freeStorageAndNotify(long idealStorageSize, IPackageDataObserver observer) {
    try {
        mPM.freeStorageAndNotify(idealStorageSize, observer);
    } catch (RemoteException e) {
        // Should never happen!
    }
}
 
Example #27
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ApplicationPackageManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void clearApplicationUserData(String packageName,
                                     IPackageDataObserver observer) {
    try {
        mPM.clearApplicationUserData(packageName, observer, mContext.getUserId());
    } catch (RemoteException e) {
        // Should never happen!
    }
}
 
Example #28
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ApplicationPackageManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void deleteApplicationCacheFiles(String packageName,
                                        IPackageDataObserver observer) {
    try {
        mPM.deleteApplicationCacheFiles(packageName, observer);
    } catch (RemoteException e) {
        // Should never happen!
    }
}
 
Example #29
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ApplicationPackageManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void freeStorageAndNotify(long idealStorageSize, IPackageDataObserver observer) {
    try {
        mPM.freeStorageAndNotify(idealStorageSize, observer);
    } catch (RemoteException e) {
        // Should never happen!
    }
}
 
Example #30
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ApplicationPackageManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void clearApplicationUserData(String packageName,
                                     IPackageDataObserver observer) {
    try {
        mPM.clearApplicationUserData(packageName, observer, mContext.getUserId());
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}