upload android base code part7

This commit is contained in:
August 2018-08-08 18:09:17 +08:00
parent 4e516ec6ed
commit 841ae54672
25229 changed files with 1709508 additions and 0 deletions

View file

@ -0,0 +1,16 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := tests
# Only compile source java files in this apk.
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := SettingInjectorSample
LOCAL_SDK_VERSION := current
include $(BUILD_PACKAGE)
# Use the following include to make our test apk.
include $(call all-makefiles-under,$(LOCAL_PATH))

View file

@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2013 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Declare the contents of this Android application. The namespace
attribute brings in the Android platform namespace, and the package
supplies a unique name for the application. When writing your
own application, the package name must be changed from "com.example.*"
to come from a domain that you own or have control over. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.injector">
<application android:label="My Setting Activity!">
<activity android:name="MySettingActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<service android:name="com.example.android.injector.MyInjectorService" >
<intent-filter>
<action android:name="android.location.SettingInjectorService" />
</intent-filter>
<meta-data
android:name="android.location.SettingInjectorService"
android:resource="@xml/my_injected_location_setting" />
</service>
<service android:name="com.example.android.injector.DisabledInjectorService" >
<intent-filter>
<action android:name="android.location.SettingInjectorService" />
</intent-filter>
<meta-data
android:name="android.location.SettingInjectorService"
android:resource="@xml/disabled_injected_location_setting" />
</service>
<service android:name="com.example.android.injector.FailingInjectorService" >
<intent-filter>
<action android:name="android.location.SettingInjectorService" />
</intent-filter>
<meta-data
android:name="android.location.SettingInjectorService"
android:resource="@xml/failing_injected_location_setting" />
</service>
<service android:name="com.example.android.injector.SlowInjectorService" >
<intent-filter>
<action android:name="android.location.SettingInjectorService" />
</intent-filter>
<meta-data
android:name="android.location.SettingInjectorService"
android:resource="@xml/slow_injected_location_setting" />
</service>
<service android:name="com.example.android.injector.UpdatingInjectorService" >
<intent-filter>
<action android:name="android.location.SettingInjectorService" />
</intent-filter>
<meta-data
android:name="android.location.SettingInjectorService"
android:resource="@xml/updating_injected_location_setting" />
</service>
</application>
</manifest>

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2007 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<EditText xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="18sp"
android:autoText="true"
android:capitalize="sentences"
android:text="@string/my_setting_activity_text" />

View file

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2013 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<string name="my_setting_activity_text">Hello, World!</string>
<string name="my_injected_setting_label">Injected setting</string>
<string name="disabled_setting_label">Disabled injected setting</string>
<string name="failing_setting_label">Failing injected setting</string>
<string name="slow_setting_label">Slow injected setting</string>
<string name="updating_setting_label">Updating injected setting</string>
</resources>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<injected-location-setting xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/disabled_setting_label"
android:icon="@drawable/ic_launcher"
android:settingsActivity="com.example.android.injector.MySettingActivity"
/>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<injected-location-setting xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/failing_setting_label"
android:icon="@drawable/ic_launcher"
android:settingsActivity="com.example.android.injector.MySettingActivity"
/>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<injected-location-setting xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/my_injected_setting_label"
android:icon="@drawable/ic_my_injected_setting"
android:settingsActivity="com.example.android.injector.MySettingActivity"
/>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<injected-location-setting xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/slow_setting_label"
android:icon="@drawable/ic_launcher"
android:settingsActivity="com.example.android.injector.MySettingActivity"
/>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<injected-location-setting xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/updating_setting_label"
android:icon="@drawable/ic_launcher"
android:settingsActivity="com.example.android.injector.MySettingActivity"
/>

View file

@ -0,0 +1,48 @@
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.android.injector;
import android.location.SettingInjectorService;
import android.util.Log;
/**
* Receiver that returns the status disabled for an injected setting.
*/
public class DisabledInjectorService extends SettingInjectorService {
private static final String TAG = "DisabledInjectorService";
public DisabledInjectorService() {
super(TAG);
}
@Override
protected String onGetSummary() {
try {
// Simulate a delay while reading the setting from disk
Thread.sleep(500);
} catch (InterruptedException e) {
Log.e(TAG, "", e);
}
return null;
}
@Override
protected boolean onGetEnabled() {
return false;
}
}

View file

@ -0,0 +1,60 @@
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.android.injector;
import android.location.SettingInjectorService;
import android.util.Log;
/**
* Receiver that returns the status of the injected setting.
*/
public class FailingInjectorService extends SettingInjectorService {
private static final String TAG = "FailingInjectorService";
/**
* Whether to actually throw an exception here. Pretty disruptive when true, because it causes
* a "Unfortunately, My Setting Activity! has stopped" dialog to appear and also blocks the
* update of other settings from this app. So only set true when need to test the handling
* of the exception.
*/
private static final boolean ACTUALLY_THROW = false;
public FailingInjectorService() {
super(TAG);
}
@Override
protected String onGetSummary() {
try {
// Simulate a delay while reading the setting from disk
Thread.sleep(100);
} catch (InterruptedException e) {
Log.e(TAG, "", e);
}
if (ACTUALLY_THROW) {
throw new RuntimeException("Simulated failure reading setting");
}
return "Decided not to throw exception after all";
}
@Override
protected boolean onGetEnabled() {
return false;
}
}

View file

@ -0,0 +1,48 @@
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.android.injector;
import android.location.SettingInjectorService;
import android.util.Log;
/**
* Receiver that returns the status of the injected setting.
*/
public class MyInjectorService extends SettingInjectorService {
private static final String TAG = "MyInjectorService";
public MyInjectorService() {
super(TAG);
}
@Override
protected String onGetSummary() {
try {
// Simulate a delay while reading the setting from disk
Thread.sleep(500);
} catch (InterruptedException e) {
Log.e(TAG, "", e);
}
return "Example status value";
}
@Override
protected boolean onGetEnabled() {
return true;
}
}

View file

@ -0,0 +1,41 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.android.injector;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
/**
* A minimal "Hello, World!" application.
*/
public class MySettingActivity extends Activity {
/**
* Called with the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set the layout for this activity. You can find it
// in res/layout/my_setting_activity.xml
View view = getLayoutInflater().inflate(R.layout.my_setting_activity, null);
setContentView(view);
}
}

View file

@ -0,0 +1,48 @@
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.android.injector;
import android.location.SettingInjectorService;
import android.util.Log;
/**
* Receiver that returns the status of the injected setting.
*/
public class SlowInjectorService extends SettingInjectorService {
private static final String TAG = "SlowInjectorService";
public SlowInjectorService() {
super(TAG);
}
@Override
protected String onGetSummary() {
try {
// Simulate a delay while reading the setting from disk
Thread.sleep(5000);
} catch (InterruptedException e) {
Log.e(TAG, "", e);
}
return "Dang that took a long time!";
}
@Override
protected boolean onGetEnabled() {
return true;
}
}

View file

@ -0,0 +1,49 @@
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.android.injector;
import android.content.Intent;
import android.location.SettingInjectorService;
import android.util.Log;
/**
* Receiver that returns a constantly-updating status for an injected setting.
*/
public class UpdatingInjectorService extends SettingInjectorService {
private static final String TAG = "UpdatingInjectorService";
public UpdatingInjectorService() {
super(TAG);
}
@Override
protected String onGetSummary() {
// Every time it asks for our status, we tell it the setting has just changed. This will
// test the handling of races where we're getting many UPDATE_INTENT broadcasts in a short
// period of time
Intent intent = new Intent(ACTION_INJECTED_SETTING_CHANGED);
sendBroadcast(intent);
Log.d(TAG, "Broadcasting: " + intent);
return String.valueOf(System.currentTimeMillis());
}
@Override
protected boolean onGetEnabled() {
return true;
}
}