Search in sources :

Example 56 with IntentFilter

use of android.content.IntentFilter in project android_frameworks_base by ParanoidAndroid.

the class BackupManagerService method initPackageTracking.

private void initPackageTracking() {
    if (DEBUG)
        Slog.v(TAG, "Initializing package tracking");
    // Remember our ancestral dataset
    mTokenFile = new File(mBaseStateDir, "ancestral");
    try {
        RandomAccessFile tf = new RandomAccessFile(mTokenFile, "r");
        int version = tf.readInt();
        if (version == CURRENT_ANCESTRAL_RECORD_VERSION) {
            mAncestralToken = tf.readLong();
            mCurrentToken = tf.readLong();
            int numPackages = tf.readInt();
            if (numPackages >= 0) {
                mAncestralPackages = new HashSet<String>();
                for (int i = 0; i < numPackages; i++) {
                    String pkgName = tf.readUTF();
                    mAncestralPackages.add(pkgName);
                }
            }
        }
        tf.close();
    } catch (FileNotFoundException fnf) {
        // Probably innocuous
        Slog.v(TAG, "No ancestral data");
    } catch (IOException e) {
        Slog.w(TAG, "Unable to read token file", e);
    }
    // Keep a log of what apps we've ever backed up.  Because we might have
    // rebooted in the middle of an operation that was removing something from
    // this log, we sanity-check its contents here and reconstruct it.
    mEverStored = new File(mBaseStateDir, "processed");
    File tempProcessedFile = new File(mBaseStateDir, "processed.new");
    // Ignore it -- we'll validate "processed" against the current package set.
    if (tempProcessedFile.exists()) {
        tempProcessedFile.delete();
    }
    // file to continue the recordkeeping.
    if (mEverStored.exists()) {
        RandomAccessFile temp = null;
        RandomAccessFile in = null;
        try {
            temp = new RandomAccessFile(tempProcessedFile, "rws");
            in = new RandomAccessFile(mEverStored, "r");
            while (true) {
                PackageInfo info;
                String pkg = in.readUTF();
                try {
                    info = mPackageManager.getPackageInfo(pkg, 0);
                    mEverStoredApps.add(pkg);
                    temp.writeUTF(pkg);
                    if (MORE_DEBUG)
                        Slog.v(TAG, "   + " + pkg);
                } catch (NameNotFoundException e) {
                    // nope, this package was uninstalled; don't include it
                    if (MORE_DEBUG)
                        Slog.v(TAG, "   - " + pkg);
                }
            }
        } catch (EOFException e) {
            // old one with the new one then reopen the file for continuing use.
            if (!tempProcessedFile.renameTo(mEverStored)) {
                Slog.e(TAG, "Error renaming " + tempProcessedFile + " to " + mEverStored);
            }
        } catch (IOException e) {
            Slog.e(TAG, "Error in processed file", e);
        } finally {
            try {
                if (temp != null)
                    temp.close();
            } catch (IOException e) {
            }
            try {
                if (in != null)
                    in.close();
            } catch (IOException e) {
            }
        }
    }
    // Register for broadcasts about package install, etc., so we can
    // update the provider list.
    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_PACKAGE_ADDED);
    filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    filter.addDataScheme("package");
    mContext.registerReceiver(mBroadcastReceiver, filter);
    // Register for events related to sdcard installation.
    IntentFilter sdFilter = new IntentFilter();
    sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
    sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
    mContext.registerReceiver(mBroadcastReceiver, sdFilter);
}
Also used : IntentFilter(android.content.IntentFilter) RandomAccessFile(java.io.RandomAccessFile) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) PackageInfo(android.content.pm.PackageInfo) FileNotFoundException(java.io.FileNotFoundException) EOFException(java.io.EOFException) IOException(java.io.IOException) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File)

Example 57 with IntentFilter

use of android.content.IntentFilter in project android_frameworks_base by ParanoidAndroid.

the class NetworkActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Register BroadcastReceiver to track connection changes.
    IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
    receiver = new NetworkReceiver();
    this.registerReceiver(receiver, filter);
}
Also used : IntentFilter(android.content.IntentFilter)

Example 58 with IntentFilter

use of android.content.IntentFilter in project android_frameworks_base by ParanoidAndroid.

the class ConnectivityService method systemReady.

void systemReady() {
    mCaptivePortalTracker = CaptivePortalTracker.makeCaptivePortalTracker(mContext, this);
    loadGlobalProxy();
    synchronized (this) {
        mSystemReady = true;
        if (mInitialBroadcast != null) {
            mContext.sendStickyBroadcastAsUser(mInitialBroadcast, UserHandle.ALL);
            mInitialBroadcast = null;
        }
    }
    // load the global proxy at startup
    mHandler.sendMessage(mHandler.obtainMessage(EVENT_APPLY_GLOBAL_HTTP_PROXY));
    // for user to unlock device.
    if (!updateLockdownVpn()) {
        final IntentFilter filter = new IntentFilter(Intent.ACTION_USER_PRESENT);
        mContext.registerReceiver(mUserPresentReceiver, filter);
    }
}
Also used : IntentFilter(android.content.IntentFilter)

Example 59 with IntentFilter

use of android.content.IntentFilter in project android_frameworks_base by ParanoidAndroid.

the class CommonTimeManagementService method systemReady.

void systemReady() {
    if (ServiceManager.checkService(CommonTimeConfig.SERVICE_NAME) == null) {
        Log.i(TAG, "No common time service detected on this platform.  " + "Common time services will be unavailable.");
        return;
    }
    mDetectedAtStartup = true;
    IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE);
    mNetMgr = INetworkManagementService.Stub.asInterface(b);
    // while trying to register this observer.
    try {
        mNetMgr.registerObserver(mIfaceObserver);
    } catch (RemoteException e) {
    }
    // Register with the connectivity manager for connectivity changed intents.
    IntentFilter filter = new IntentFilter();
    filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
    mContext.registerReceiver(mConnectivityMangerObserver, filter);
    // Connect to the common time config service and apply the initial configuration.
    connectToTimeConfig();
}
Also used : IntentFilter(android.content.IntentFilter) IBinder(android.os.IBinder) RemoteException(android.os.RemoteException)

Example 60 with IntentFilter

use of android.content.IntentFilter in project android_frameworks_base by ParanoidAndroid.

the class VibratorService method systemReady.

public void systemReady() {
    mIm = (InputManager) mContext.getSystemService(Context.INPUT_SERVICE);
    mContext.getContentResolver().registerContentObserver(Settings.System.getUriFor(Settings.System.VIBRATE_INPUT_DEVICES), true, new ContentObserver(mH) {

        @Override
        public void onChange(boolean selfChange) {
            updateInputDeviceVibrators();
        }
    }, UserHandle.USER_ALL);
    mContext.registerReceiver(new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            updateInputDeviceVibrators();
        }
    }, new IntentFilter(Intent.ACTION_USER_SWITCHED), null, mH);
    updateInputDeviceVibrators();
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver) ContentObserver(android.database.ContentObserver)

Aggregations

IntentFilter (android.content.IntentFilter)1441 Intent (android.content.Intent)493 Context (android.content.Context)292 BroadcastReceiver (android.content.BroadcastReceiver)274 PendingIntent (android.app.PendingIntent)148 RemoteException (android.os.RemoteException)80 ComponentName (android.content.ComponentName)54 Handler (android.os.Handler)53 View (android.view.View)45 Test (org.junit.Test)41 Uri (android.net.Uri)40 PowerManager (android.os.PowerManager)38 ArrayList (java.util.ArrayList)37 TextView (android.widget.TextView)36 ResolveInfo (android.content.pm.ResolveInfo)30 File (java.io.File)29 Point (android.graphics.Point)28 PackageManager (android.content.pm.PackageManager)27 IOException (java.io.IOException)25 HandlerThread (android.os.HandlerThread)24