use of android.content.pm.PackageManager in project platform_frameworks_base by android.
the class SystemImpl method uninstallAndDisablePackageForAllUsers.
@Override
public void uninstallAndDisablePackageForAllUsers(Context context, String packageName) {
enablePackageForAllUsers(context, packageName, false);
try {
PackageManager pm = AppGlobals.getInitialApplication().getPackageManager();
ApplicationInfo applicationInfo = pm.getApplicationInfo(packageName, 0);
if (applicationInfo != null && applicationInfo.isUpdatedSystemApp()) {
pm.deletePackage(packageName, new IPackageDeleteObserver.Stub() {
public void packageDeleted(String packageName, int returnCode) {
enablePackageForAllUsers(context, packageName, false);
}
}, PackageManager.DELETE_SYSTEM_APP | PackageManager.DELETE_ALL_USERS);
}
} catch (NameNotFoundException e) {
}
}
use of android.content.pm.PackageManager in project platform_frameworks_base by android.
the class GrantCredentialsPermissionActivity method onCreate.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.grant_credentials_permission);
setTitle(R.string.grant_permissions_header_text);
mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final Bundle extras = getIntent().getExtras();
if (extras == null) {
// we were somehow started with bad parameters. abort the activity.
setResult(Activity.RESULT_CANCELED);
finish();
return;
}
// Grant 'account'/'type' to mUID
mAccount = extras.getParcelable(EXTRAS_ACCOUNT);
mAuthTokenType = extras.getString(EXTRAS_AUTH_TOKEN_TYPE);
mUid = extras.getInt(EXTRAS_REQUESTING_UID);
final PackageManager pm = getPackageManager();
final String[] packages = pm.getPackagesForUid(mUid);
if (mAccount == null || mAuthTokenType == null || packages == null) {
// we were somehow started with bad parameters. abort the activity.
setResult(Activity.RESULT_CANCELED);
finish();
return;
}
String accountTypeLabel;
try {
accountTypeLabel = getAccountLabel(mAccount);
} catch (IllegalArgumentException e) {
// label or resource was missing. abort the activity.
setResult(Activity.RESULT_CANCELED);
finish();
return;
}
final TextView authTokenTypeView = (TextView) findViewById(R.id.authtoken_type);
authTokenTypeView.setVisibility(View.GONE);
final AccountManagerCallback<String> callback = new AccountManagerCallback<String>() {
public void run(AccountManagerFuture<String> future) {
try {
final String authTokenLabel = future.getResult();
if (!TextUtils.isEmpty(authTokenLabel)) {
runOnUiThread(new Runnable() {
public void run() {
if (!isFinishing()) {
authTokenTypeView.setText(authTokenLabel);
authTokenTypeView.setVisibility(View.VISIBLE);
}
}
});
}
} catch (OperationCanceledException e) {
} catch (IOException e) {
} catch (AuthenticatorException e) {
}
}
};
if (!AccountManager.ACCOUNT_ACCESS_TOKEN_TYPE.equals(mAuthTokenType)) {
AccountManager.get(this).getAuthTokenLabel(mAccount.type, mAuthTokenType, callback, null);
}
findViewById(R.id.allow_button).setOnClickListener(this);
findViewById(R.id.deny_button).setOnClickListener(this);
LinearLayout packagesListView = (LinearLayout) findViewById(R.id.packages_list);
for (String pkg : packages) {
String packageLabel;
try {
packageLabel = pm.getApplicationLabel(pm.getApplicationInfo(pkg, 0)).toString();
} catch (PackageManager.NameNotFoundException e) {
packageLabel = pkg;
}
packagesListView.addView(newPackageView(packageLabel));
}
((TextView) findViewById(R.id.account_name)).setText(mAccount.name);
((TextView) findViewById(R.id.account_type)).setText(accountTypeLabel);
}
use of android.content.pm.PackageManager in project newsrob by marianokamp.
the class EntryManager method maintainBootReceiverState.
public void maintainBootReceiverState() {
final ComponentName cName = new ComponentName(ctx, BootReceiver.class);
final PackageManager pm = ctx.getPackageManager();
final int newComponentState = isAutoSyncEnabled() ? PackageManager.COMPONENT_ENABLED_STATE_DEFAULT : PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
if (pm.getComponentEnabledSetting(cName) != newComponentState) {
Log.d(TAG, "Setting new component enabled state on BootReceiver: " + isAutoSyncEnabled());
pm.setComponentEnabledSetting(cName, newComponentState, PackageManager.DONT_KILL_APP);
}
PL.log("EntryManager.maintainBootReceiverState(): Component enabled=" + pm.getComponentEnabledSetting(cName), ctx);
}
use of android.content.pm.PackageManager in project newsrob by marianokamp.
the class EntryManager method maintainBootReceiverStateAndScheduler.
public void maintainBootReceiverStateAndScheduler() {
final ComponentName cName = new ComponentName(ctx, BootReceiver.class);
final PackageManager pm = ctx.getPackageManager();
final int newComponentState = isAutoSyncEnabled() ? PackageManager.COMPONENT_ENABLED_STATE_DEFAULT : PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
if (pm.getComponentEnabledSetting(cName) != newComponentState) {
Log.d(TAG, "Setting new component enabled state on BootReceiver: " + isAutoSyncEnabled());
pm.setComponentEnabledSetting(cName, newComponentState, PackageManager.DONT_KILL_APP);
}
PL.log("EntryManager.maintainBootReceiverState(): Component enabled=" + pm.getComponentEnabledSetting(cName), ctx);
scheduler.ensureSchedulingIsEnabled();
}
use of android.content.pm.PackageManager in project AndroidPerformanceMonitor by markzhai.
the class BlockCanary method setEnabledBlocking.
private static void setEnabledBlocking(Context appContext, Class<?> componentClass, boolean enabled) {
ComponentName component = new ComponentName(appContext, componentClass);
PackageManager packageManager = appContext.getPackageManager();
int newState = enabled ? COMPONENT_ENABLED_STATE_ENABLED : COMPONENT_ENABLED_STATE_DISABLED;
// Blocks on IPC.
packageManager.setComponentEnabledSetting(component, newState, DONT_KILL_APP);
}
Aggregations