Search in sources :

Example 1 with PackageManagerInternal

use of android.content.pm.PackageManagerInternal in project android_frameworks_base by ResurrectionRemix.

the class TelecomLoaderService method registerDefaultAppNotifier.

private void registerDefaultAppNotifier() {
    final PackageManagerInternal packageManagerInternal = LocalServices.getService(PackageManagerInternal.class);
    // Notify the package manager on default app changes
    final Uri defaultSmsAppUri = Settings.Secure.getUriFor(Settings.Secure.SMS_DEFAULT_APPLICATION);
    final Uri defaultDialerAppUri = Settings.Secure.getUriFor(Settings.Secure.DIALER_DEFAULT_APPLICATION);
    ContentObserver contentObserver = new ContentObserver(new Handler(Looper.getMainLooper())) {

        @Override
        public void onChange(boolean selfChange, Uri uri, int userId) {
            if (defaultSmsAppUri.equals(uri)) {
                ComponentName smsComponent = SmsApplication.getDefaultSmsApplication(mContext, true);
                if (smsComponent != null) {
                    packageManagerInternal.grantDefaultPermissionsToDefaultSmsApp(smsComponent.getPackageName(), userId);
                }
            } else if (defaultDialerAppUri.equals(uri)) {
                String packageName = DefaultDialerManager.getDefaultDialerApplication(mContext);
                if (packageName != null) {
                    packageManagerInternal.grantDefaultPermissionsToDefaultDialerApp(packageName, userId);
                }
                updateSimCallManagerPermissions(packageManagerInternal, userId);
            }
        }
    };
    mContext.getContentResolver().registerContentObserver(defaultSmsAppUri, false, contentObserver, UserHandle.USER_ALL);
    mContext.getContentResolver().registerContentObserver(defaultDialerAppUri, false, contentObserver, UserHandle.USER_ALL);
}
Also used : PackageManagerInternal(android.content.pm.PackageManagerInternal) Handler(android.os.Handler) ComponentName(android.content.ComponentName) Uri(android.net.Uri) ContentObserver(android.database.ContentObserver)

Example 2 with PackageManagerInternal

use of android.content.pm.PackageManagerInternal in project android_frameworks_base by DirtyUnicorns.

the class TelecomLoaderService method registerCarrierConfigChangedReceiver.

private void registerCarrierConfigChangedReceiver() {
    final PackageManagerInternal packageManagerInternal = LocalServices.getService(PackageManagerInternal.class);
    BroadcastReceiver receiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction().equals(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED)) {
                for (int userId : UserManagerService.getInstance().getUserIds()) {
                    updateSimCallManagerPermissions(packageManagerInternal, userId);
                }
            }
        }
    };
    mContext.registerReceiverAsUser(receiver, UserHandle.ALL, new IntentFilter(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED), null, null);
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) PackageManagerInternal(android.content.pm.PackageManagerInternal) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver)

Example 3 with PackageManagerInternal

use of android.content.pm.PackageManagerInternal in project android_frameworks_base by DirtyUnicorns.

the class TelecomLoaderService method registerDefaultAppNotifier.

private void registerDefaultAppNotifier() {
    final PackageManagerInternal packageManagerInternal = LocalServices.getService(PackageManagerInternal.class);
    // Notify the package manager on default app changes
    final Uri defaultSmsAppUri = Settings.Secure.getUriFor(Settings.Secure.SMS_DEFAULT_APPLICATION);
    final Uri defaultDialerAppUri = Settings.Secure.getUriFor(Settings.Secure.DIALER_DEFAULT_APPLICATION);
    ContentObserver contentObserver = new ContentObserver(new Handler(Looper.getMainLooper())) {

        @Override
        public void onChange(boolean selfChange, Uri uri, int userId) {
            if (defaultSmsAppUri.equals(uri)) {
                ComponentName smsComponent = SmsApplication.getDefaultSmsApplication(mContext, true);
                if (smsComponent != null) {
                    packageManagerInternal.grantDefaultPermissionsToDefaultSmsApp(smsComponent.getPackageName(), userId);
                }
            } else if (defaultDialerAppUri.equals(uri)) {
                String packageName = DefaultDialerManager.getDefaultDialerApplication(mContext);
                if (packageName != null) {
                    packageManagerInternal.grantDefaultPermissionsToDefaultDialerApp(packageName, userId);
                }
                updateSimCallManagerPermissions(packageManagerInternal, userId);
            }
        }
    };
    mContext.getContentResolver().registerContentObserver(defaultSmsAppUri, false, contentObserver, UserHandle.USER_ALL);
    mContext.getContentResolver().registerContentObserver(defaultDialerAppUri, false, contentObserver, UserHandle.USER_ALL);
}
Also used : PackageManagerInternal(android.content.pm.PackageManagerInternal) Handler(android.os.Handler) ComponentName(android.content.ComponentName) Uri(android.net.Uri) ContentObserver(android.database.ContentObserver)

Example 4 with PackageManagerInternal

use of android.content.pm.PackageManagerInternal in project android_frameworks_base by AOSPA.

the class OverlayManagerService method updateSelectedAssets.

private void updateSelectedAssets(final int userId, List<String> targetPackageNames) {
    final PackageManagerInternal pm = LocalServices.getService(PackageManagerInternal.class);
    final boolean updateFrameworkRes = targetPackageNames.contains("android");
    if (updateFrameworkRes) {
        targetPackageNames = pm.getTargetPackageNames(userId);
    }
    final Map<String, String[]> allPaths = new ArrayMap<>(targetPackageNames.size());
    synchronized (mLock) {
        final List<String> frameworkPaths = mImpl.onGetEnabledOverlayPaths("android", userId);
        for (final String packageName : targetPackageNames) {
            final List<String> paths = new ArrayList<>();
            paths.addAll(frameworkPaths);
            if (!"android".equals(packageName)) {
                paths.addAll(mImpl.onGetEnabledOverlayPaths(packageName, userId));
            }
            allPaths.put(packageName, paths.isEmpty() ? null : paths.toArray(new String[paths.size()]));
        }
    }
    for (String packageName : targetPackageNames) {
        pm.setResourceDirs(userId, packageName, allPaths.get(packageName));
    }
    final IActivityManager am = ActivityManagerNative.getDefault();
    try {
        am.updateAssets(userId, targetPackageNames);
    } catch (RemoteException e) {
    // Intentionally left empty.
    }
}
Also used : ArrayList(java.util.ArrayList) PackageManagerInternal(android.content.pm.PackageManagerInternal) ArrayMap(android.util.ArrayMap) RemoteException(android.os.RemoteException) IActivityManager(android.app.IActivityManager)

Example 5 with PackageManagerInternal

use of android.content.pm.PackageManagerInternal in project platform_frameworks_base by android.

the class TelecomLoaderService method registerDefaultAppProviders.

private void registerDefaultAppProviders() {
    final PackageManagerInternal packageManagerInternal = LocalServices.getService(PackageManagerInternal.class);
    // Set a callback for the package manager to query the default sms app.
    packageManagerInternal.setSmsAppPackagesProvider(new PackageManagerInternal.PackagesProvider() {

        @Override
        public String[] getPackages(int userId) {
            synchronized (mLock) {
                if (mServiceConnection == null) {
                    if (mDefaultSmsAppRequests == null) {
                        mDefaultSmsAppRequests = new IntArray();
                    }
                    mDefaultSmsAppRequests.add(userId);
                    return null;
                }
            }
            ComponentName smsComponent = SmsApplication.getDefaultSmsApplication(mContext, true);
            if (smsComponent != null) {
                return new String[] { smsComponent.getPackageName() };
            }
            return null;
        }
    });
    // Set a callback for the package manager to query the default dialer app.
    packageManagerInternal.setDialerAppPackagesProvider(new PackageManagerInternal.PackagesProvider() {

        @Override
        public String[] getPackages(int userId) {
            synchronized (mLock) {
                if (mServiceConnection == null) {
                    if (mDefaultDialerAppRequests == null) {
                        mDefaultDialerAppRequests = new IntArray();
                    }
                    mDefaultDialerAppRequests.add(userId);
                    return null;
                }
            }
            String packageName = DefaultDialerManager.getDefaultDialerApplication(mContext);
            if (packageName != null) {
                return new String[] { packageName };
            }
            return null;
        }
    });
    // Set a callback for the package manager to query the default sim call manager.
    packageManagerInternal.setSimCallManagerPackagesProvider(new PackageManagerInternal.PackagesProvider() {

        @Override
        public String[] getPackages(int userId) {
            synchronized (mLock) {
                if (mServiceConnection == null) {
                    if (mDefaultSimCallManagerRequests == null) {
                        mDefaultSimCallManagerRequests = new IntArray();
                    }
                    mDefaultSimCallManagerRequests.add(userId);
                    return null;
                }
            }
            TelecomManager telecomManager = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
            PhoneAccountHandle phoneAccount = telecomManager.getSimCallManager(userId);
            if (phoneAccount != null) {
                return new String[] { phoneAccount.getComponentName().getPackageName() };
            }
            return null;
        }
    });
}
Also used : IntArray(android.util.IntArray) PhoneAccountHandle(android.telecom.PhoneAccountHandle) PackageManagerInternal(android.content.pm.PackageManagerInternal) ComponentName(android.content.ComponentName) TelecomManager(android.telecom.TelecomManager)

Aggregations

PackageManagerInternal (android.content.pm.PackageManagerInternal)16 ComponentName (android.content.ComponentName)8 IActivityManager (android.app.IActivityManager)4 BroadcastReceiver (android.content.BroadcastReceiver)4 Context (android.content.Context)4 Intent (android.content.Intent)4 IntentFilter (android.content.IntentFilter)4 ContentObserver (android.database.ContentObserver)4 Uri (android.net.Uri)4 Handler (android.os.Handler)4 RemoteException (android.os.RemoteException)4 PhoneAccountHandle (android.telecom.PhoneAccountHandle)4 TelecomManager (android.telecom.TelecomManager)4 ArrayMap (android.util.ArrayMap)4 IntArray (android.util.IntArray)4 ArrayList (java.util.ArrayList)4