Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d070e893 authored by Joe Onorato's avatar Joe Onorato
Browse files

Make AppWidgetService handle components enabling and disabling.

Change-Id: Ie6b75cb90be38bbce694ccf2d5a342d7f0172fa4
parent a85a9157
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -144,6 +144,7 @@ class AppWidgetService extends IAppWidgetService.Stub
        // update the provider list.
        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_PACKAGE_ADDED);
        filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
        filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
        filter.addDataScheme("package");
        mContext.registerReceiver(mBroadcastReceiver, filter);
@@ -643,6 +644,12 @@ class AppWidgetService extends IAppWidgetService.Stub
    }

    boolean addProviderLocked(ResolveInfo ri) {
        if ((ri.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0) {
            return false;
        }
        if (!ri.activityInfo.isEnabled()) {
            return false;
        }
        Provider p = parseProviderInfoXml(new ComponentName(ri.activityInfo.packageName,
                    ri.activityInfo.name), ri);
        if (p != null) {
@@ -1160,6 +1167,7 @@ class AppWidgetService extends IAppWidgetService.Stub
                }
            } else {
                boolean added = false;
                boolean changed = false;
                String pkgList[] = null;
                if (Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE.equals(action)) {
                    pkgList = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);
@@ -1178,14 +1186,16 @@ class AppWidgetService extends IAppWidgetService.Stub
                    }
                    pkgList = new String[] { pkgName };
                    added = Intent.ACTION_PACKAGE_ADDED.equals(action);
                    changed = Intent.ACTION_PACKAGE_CHANGED.equals(action);
                }
                if (pkgList == null || pkgList.length == 0) {
                    return;
                }
                if (added) {
                if (added || changed) {
                    synchronized (mAppWidgetIds) {
                        Bundle extras = intent.getExtras();
                        if (extras != null && extras.getBoolean(Intent.EXTRA_REPLACING, false)) {
                        if (changed || (extras != null &&
                                    extras.getBoolean(Intent.EXTRA_REPLACING, false))) {
                            for (String pkgName : pkgList) {
                                // The package was just upgraded
                                updateProvidersForPackageLocked(pkgName);
+1 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
    <uses-permission android:name="android.permission.STATUS_BAR" />
    <uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE" />

    <application>
        <activity android:name="StatusBarTest" android:label="_StatusBar">
+20 −0
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ import android.os.IBinder;
import android.os.IPowerManager;
import android.widget.ListView;
import android.content.Intent;
import android.content.ComponentName;
import android.content.pm.PackageManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.StatusBarManager;
@@ -66,6 +68,24 @@ public class PowerTest extends TestActivity
        return mTests;
    }
    private Test[] mTests = new Test[] {
        new Test("Enable settings widget") {
            public void run() {
                PackageManager pm = getPackageManager();
                pm.setComponentEnabledSetting(new ComponentName("com.android.settings",
                            "com.android.settings.widget.SettingsAppWidgetProvider"),
                        PackageManager.COMPONENT_ENABLED_STATE_ENABLED, 0);

            }
        },
        new Test("Disable settings widget") {
            public void run() {
                PackageManager pm = getPackageManager();
                pm.setComponentEnabledSetting(new ComponentName("com.android.settings",
                            "com.android.settings.widget.SettingsAppWidgetProvider"),
                        PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);

            }
        },
        new Test("Enable proximity") {
            public void run() {
                mProx.acquire();