Utils.getPackageUri() for creating Uris from packageNames
Since this is done a lot, might as well have a reusable method.
This commit is contained in:
parent
ae3ea85355
commit
677db72bb3
@ -158,7 +158,7 @@ public class TestUtils {
|
|||||||
context.setPackageManager(pm);
|
context.setPackageManager(pm);
|
||||||
pm.install(appId, versionCode, versionName);
|
pm.install(appId, versionCode, versionName);
|
||||||
Intent installIntent = new Intent(Intent.ACTION_PACKAGE_ADDED);
|
Intent installIntent = new Intent(Intent.ACTION_PACKAGE_ADDED);
|
||||||
installIntent.setData(Uri.parse("package:" + appId));
|
installIntent.setData(Utils.getPackageUri(appId));
|
||||||
new PackageAddedReceiver().onReceive(context, installIntent);
|
new PackageAddedReceiver().onReceive(context, installIntent);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -176,7 +176,7 @@ public class TestUtils {
|
|||||||
context.setPackageManager(pm);
|
context.setPackageManager(pm);
|
||||||
pm.install(appId, versionCode, versionName);
|
pm.install(appId, versionCode, versionName);
|
||||||
Intent installIntent = new Intent(Intent.ACTION_PACKAGE_CHANGED);
|
Intent installIntent = new Intent(Intent.ACTION_PACKAGE_CHANGED);
|
||||||
installIntent.setData(Uri.parse("package:" + appId));
|
installIntent.setData(Utils.getPackageUri(appId));
|
||||||
new PackageUpgradedReceiver().onReceive(context, installIntent);
|
new PackageUpgradedReceiver().onReceive(context, installIntent);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -189,7 +189,7 @@ public class TestUtils {
|
|||||||
context.setPackageManager(pm);
|
context.setPackageManager(pm);
|
||||||
pm.remove(appId);
|
pm.remove(appId);
|
||||||
Intent installIntent = new Intent(Intent.ACTION_PACKAGE_REMOVED);
|
Intent installIntent = new Intent(Intent.ACTION_PACKAGE_REMOVED);
|
||||||
installIntent.setData(Uri.parse("package:" + appId));
|
installIntent.setData(Utils.getPackageUri(appId));
|
||||||
new PackageRemovedReceiver().onReceive(context, installIntent);
|
new PackageRemovedReceiver().onReceive(context, installIntent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -267,6 +267,13 @@ public final class Utils {
|
|||||||
return b.build();
|
return b.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a standard {@link PackageManager} {@link Uri} for pointing to an app.
|
||||||
|
*/
|
||||||
|
public static Uri getPackageUri(String packageName) {
|
||||||
|
return Uri.parse("package:" + packageName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This location is only for caching, do not install directly from this location
|
* This location is only for caching, do not install directly from this location
|
||||||
* because if the file is on the External Storage, any other app could swap out
|
* because if the file is on the External Storage, any other app could swap out
|
||||||
|
@ -58,7 +58,7 @@ public class CacheSwapAppsService extends IntentService {
|
|||||||
if (!indexJarFile.exists()
|
if (!indexJarFile.exists()
|
||||||
|| FileUtils.isFileNewer(new File(applicationInfo.sourceDir), indexJarFile)) {
|
|| FileUtils.isFileNewer(new File(applicationInfo.sourceDir), indexJarFile)) {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setData(Uri.parse("package:" + applicationInfo.packageName));
|
intent.setData(Utils.getPackageUri(applicationInfo.packageName));
|
||||||
parseApp(context, intent);
|
parseApp(context, intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user