Example usage for android.os Process myUid

List of usage examples for android.os Process myUid

Introduction

In this page you can find the example usage for android.os Process myUid.

Prototype

public static final int myUid() 

Source Link

Document

Returns the identifier of this process's uid.

Usage

From source file:org.thoughtland.xlocation.ActivityShare.java

public static String getBaseURL() {
    int userId = Util.getUserId(Process.myUid());
    if (PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingHttps, true))
        return HTTPS_BASE_URL;
    else//from   w  w  w. j  av a2s . c o m
        return HTTP_BASE_URL;
}

From source file:eu.faircode.netguard.ServiceSinkhole.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Log.i(TAG, "Received " + intent);
    Util.logExtras(intent);//from   www. j a v a 2  s. co m

    // Check for set command
    if (intent != null && intent.hasExtra(EXTRA_COMMAND)
            && intent.getSerializableExtra(EXTRA_COMMAND) == Command.set) {
        set(intent);
        return START_STICKY;
    }

    // Keep awake
    getLock(this).acquire();

    // Get state
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    boolean enabled = prefs.getBoolean("enabled", false);

    // Handle service restart
    if (intent == null) {
        Log.i(TAG, "Restart");

        // Recreate intent
        intent = new Intent(this, ServiceSinkhole.class);
        intent.putExtra(EXTRA_COMMAND, enabled ? Command.start : Command.stop);
    }

    if (ACTION_HOUSE_HOLDING.equals(intent.getAction()))
        intent.putExtra(EXTRA_COMMAND, Command.householding);
    if (ACTION_WATCHDOG.equals(intent.getAction()))
        intent.putExtra(EXTRA_COMMAND, Command.watchdog);

    Command cmd = (Command) intent.getSerializableExtra(EXTRA_COMMAND);
    if (cmd == null)
        intent.putExtra(EXTRA_COMMAND, enabled ? Command.start : Command.stop);
    String reason = intent.getStringExtra(EXTRA_REASON);
    Log.i(TAG, "Start intent=" + intent + " command=" + cmd + " reason=" + reason + " vpn=" + (vpn != null)
            + " user=" + (Process.myUid() / 100000));

    commandHandler.queue(intent);
    return START_STICKY;
}

From source file:android.app.Activity.java

/**
 * @hide/*from www  .  j av  a  2  s . c o  m*/
 */
private void showMigrateNotification() {

    boolean flag = false;

    if (mMigrator == null) {
        mMigrator = IMigratorService.Stub.asInterface(ServiceManager.getService("Migrator"));
    }
    try {
        /* judge whether this App can migrate */
        flag = mMigrator.checkMigratableApp();
    } catch (RemoteException e) {
        Log.d(TAG, "Migrate failed in Dialog");
    }

    if (flag) {
        Intent intent = new Intent();
        intent.setClassName("com.android.migrationmanager", "com.android.migrationmanager.DeviceListDialog");
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        PendingIntent pi = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
        /* on tapping, show dialog Activity */

        Notification notification = new Notification.Builder(this)
                .setContentTitle("Migrator in " + getAppName())
                .setContentText("start Migration: " + getLocalClassName())
                .setSmallIcon(com.android.internal.R.drawable.ic_menu_send).setAutoCancel(true)
                .setContentIntent(pi).build();

        NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

        nm.notify(Process.myUid(), notification);
    }
}